Something else is affecting your chances of success. Please post the full function.
The number 101 is chosen so that whatever your practiced level of SKILL_FORAGE, that is the percentage of times you will succeed.
For reference, here is the implementation of the forage skill from Augmented Dimension (which is not currently run of course). You have my full permission to use it however you see fit. Hope it helps.
Code:
/* VNUMS of food objects that can be found on successful forage */
#define FORAGE_BERRY 20
#define FORAGE_ROOTS 21
#define FORAGE_GREENS 22
#define FORAGE_BARK 23
#define FORAGE_NUTS 24
ACMD(do_forage)
{
int move_cost = 10;
int success;
const obj_vnum forage_possibilities[] = {
FORAGE_BERRY,
FORAGE_ROOTS,
FORAGE_GREENS,
FORAGE_BARK,
FORAGE_NUTS
};
const int num_possibilities = sizeof(forage_possibilities)/sizeof(forage_possibilities[0]);
int food = rand_number(0, num_possibilities - 1);
if (GET_SKILL(ch, SKILL_FORAGE) < rand_number(1, 101))
success = FALSE;
else
success = TRUE;
if (world[IN_ROOM(ch)].sector_type != SECT_FOREST) {
send_to_char(ch, "You can only forage in the woods!\r\n");
return;
}
if (GET_MOVE(ch) < move_cost) {
send_to_char(ch, "You are too tired to forage.\r\n");
return;
}
if (success) {
struct obj_data *found = read_object(forage_possibilities[food], VIRTUAL);
send_to_char(ch, "You forage and find a %s!\r\n", found->short_description);
obj_to_char(found, ch);
improve_skill(ch, SKILL_FORAGE);
} else
send_to_char(ch, "You forage for a while and find nothing.\r\n");
GET_MOVE(ch) -= move_cost;
WAIT_STATE(ch, PULSE_VIOLENCE * 2);
}