client_process.cpp
Code:
case OP_Forage:
{
/******************************************************
An interesting problem is determining in advance what the qualifications
are for a given piece of food for even if you were to
select from the database items table for edible food (if there is a flag)
you would need to still sort the item by skill and the like. Thus,
I would argue a food table is necessary. Until one is constructed
or a better method built, this will work.
--MV
*******************************************************/
#define MAX_POSSIBLE_FOOD_IDS 5
uint32 possible_food_ids[MAX_POSSIBLE_FOOD_IDS];
possible_food_ids[0] = 13977; /* Carrot */
possible_food_ids[1] = 14912; /* Mill Carrot */
possible_food_ids[2] = 14920; /* Wild Raddish */
possible_food_ids[3] = 12845; /* Creeper Cabbage */
possible_food_ids[4] = 14913; /* Wild Cabbage */
possible_food_ids[5] = 1429; /* Snow Griffin Egg */
/******************************************************
My rational: The higher your skill in forage, the more
likely you are to forage something. With a slight chance that
even at 255 you will fail
/*****************************************************/
if (rand()%265<GetSkill(FORAGE)){
uint32 food_id=possible_food_ids[rand()%MAX_POSSIBLE_FOOD_IDS];
Item_Struct* food_item = database.GetItem(food_id);
if (food_item->name!=0) {
this->Message(MT_Emote, "You forage a %s",food_item->name);
this->PutItemInInventory(0,food_item);
}
} else {
if (rand()%4==1){
this->Message(MT_Emote, "You failed to find anything worthwhile.");
} else {
this->Message(MT_Emote, "You fail to find anything to forage.");
}
}
break;
}
"Better than nothing" (TM)
--MV