EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Archive::Development (https://www.eqemulator.org/forums/forumdisplay.php?f=621)
-   -   A forage skill snippet (https://www.eqemulator.org/forums/showthread.php?t=1551)

Malevolent 04-28-2002 11:54 AM

A forage skill snippet
 
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

devn00b 04-28-2002 07:33 PM

Plugged it in and worked perfect! thanks much!

Drawde 04-30-2002 05:34 AM

I was just about to make a post asking if anyone had done any work on incorporating foraging (someone posted some code for it a month or so ago). But it looks like you've already done it - wish I had your programming skills!
There's a complete list of what can be foraged (and fished) in each zone at eqtraders.com.

Malevolent 04-30-2002 12:36 PM

Add this to have the skill go up.

Code:

                                                //See if the player increases their skill
                                                float wisebonus =  (pp.WIS > 200) ? 20 + ((pp.WIS - 200) * 0.05) : pp.WIS * 0.1;
                                                if ((55-(GetSkill(FORAGE)*0.236))+wisebonus > (float)rand()/RAND_MAX*100)
                                                                this->SetSkill(FORAGE,++pp.skills[FORAGE]);



All times are GMT -4. The time now is 02:58 AM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.