New Character: Hunger / Thirst
One of the first things I noticed when trying EQEmu about a year ago was that newly created players would eat 2 bread cakes and drink 2 milk skins almost as soon as they were first logged in. On a Live server, it normally takes ~10-15 minutes to eat your first item.
I have never programmed in C++ nor do I have any working knowledge of the language. So, I just simply accepted the fact that my new characters were very hungry and thirsty :) I decided to download the source code and Visual C++ 2008 Express. It took a good bit of reading to get everything to go in the right place, but in less than a morning's time, I was able to compile the source code and run my newly made server. Now it was time to delve into the code.......... I had no idea what a ride I was in for. :-D It took several hours just to get a working idea of how the files were set up and what general form the project (and C++) used. I *finally* tracked down where characters are created and where the starting stats are defined. A few searches through the code for things like "food", "hunger", "hungry", "eat" and "consume" generated several items for me to look at (and learn from). I tried a few different things before I finally came up with something that would work (took a few tries just to get a compile to work LOL). I have tested my changes and they seem to work without any issues. Please keep in mind, this is my *FIRST* ever attempt at working with C++. As such, I may have overlooked some major item, and if so, simply reply and I will try to learn. The idea is that we max out the hunger and thirst variables so the player does not need to eat or drink for a while after they are first created. This is more inline with the experience on a Live server. In \EQEmu-0.7.0-1118\world\client.cpp (Line 957) Change: Code:
//what was the point of this? zone dosent handle this: Code:
//what was the point of this? zone dosent handle this: -Codemephit |
i simply altered the hunger variable in Rule section =)
the default consumtion ratio was too heavy anyway - you were eating and drinking like every 10 min |
You make a very good point. I did not know about the hunger rule variable. But if I had, I may never have been motivated to look at C++ :D
Anyhow, I found where food is consumed. True to what you said, it is about 1 item every 10 minutes. I created a new character on a Live server and deleted all but 10 each of his bread / milk. I then used my logs to determine how long the food lasted and timed the 'you are low on food', 'you are out of food', 'you are hungry' messages. I found that 1 item is eaten / drank about once per hour, give or take a little. This was on a human by the way. If I recall correctly, small races ate slower and large races ate faster. Also, I remember something about eating more if you had a mount summoned. I will see what I can dig up on that. For now though, this will bring normal eating / drinking habits more inline with Live. In \EQEmu-0.7.0-1118\zone\client_packet.cpp (Line 1291) Change: Code:
m_pp.hunger_level += eat_item->CastTime*cons_mod; //roughly 1 item per 10 minutes Code:
// Codemephit [2008.07.18] - Added a multiplier of '6'. This makes food last about as long as on Live. -Codemephit |
you do realize that with the Rule variable you can allready set consumtipion to ANY level? every 5 min or every 5 days? no C coding requred
personaly i PREFER than char eats faster - cuase this makes them spend more money of food |
I've thought about upping the base consumption before the rule several times before honestly. I also don't see a problem with setting a character to having eaten something on character creation.
|
I think trying to find the most live-like starting point only makes the variable setting more accurate. If it's twice 'normal', then we have to be sure that 'normal' is 'normal' (as far as Live goes) before we modify it one way or the other =P
Good work, Mephit =) |
the variable that curently in rules allready VERY flexiable - ANYONE can set it to his liking to be more or less. there is absolutly no need for exact live-like hard coding
|
/shrug
Maybe I am missing something, but all I can find in the rules is: Character:ConsumpionMultiplier = 200 There is no comment or description. How is one to know what to set the value at to achieve a live-like consumption rate without trial and error? I understand that some folks want characters to eat more. This is perfectly fine. However, not everybody has that same desire. I believe that 'fast' or 'slow' eating should be the exception to the rule, and 'regular' eating should be the default. The change I am proposing will not stop a custom server from doing what the Admin wants it to do. They can still set the rule, and it will still take effect. Character will eat slower or faster. But for all the other folks, who simply want a like-like server, to me, this is a viable offering to the code-base. Another issue: I don't see how the Character:ConsumptionMultiplier handles the issues of small or large characters needing less or more food respectively. I also do not see it handling a mount's hunger. I know the code I have posted so far does not do these things either, but I am currently witting code that does. I am still learning C++ (teaching myself) so I can't churn a whole block of code out over night. It takes a little while. Here is the psuedo-code of what I am trying to accomplish: Code:
NutritionValue = 10 -Codemephit |
Quote:
anyway, the higher the number the longer it takes your char to get hungry. as far as diffirent races eating at diffirent rate - if you going to code it in, please make sure to include a rule to turn it off =) otherwise when food cost a 100 plat, soem race will be spendign way more than others wihout any benefit (its all back from the day when each race had diffirent XP gain modifier) Balance wise, Ogres, Trolls, and Iksar should be the only races who eat more due to their inherited racial bonus which actualy decently strong (given they actualy coded in) |
I could use a little guidance on variable usage please.
I have added the following line to \EQEmu-0.7.0-1118\zone\client_packet.cpp just before a character eats: Code:
Message(13, "My current race is: "); I then began changing it to print the 'race' variable. I have tried: Code:
Message(13, m_pp.race); None of the above attempts would work. I have also seen in other code where things like the following were used: Code:
scs->zone_id If anyone happens to know and can point me in the right direction, I would be *very* appreciative. Thanks -Codemephit |
Try:
Code:
Message(13, "My race is %d", m_pp.race); |
Many thanks Derision. I now have a working race detection system in place.
Dwarves, Halflings & Gnomes have a 25% increase in food value. Barbarians, Trolls, Ogres, Iksar & Vah Shir have a 25% decrease in food value. To answer ChaosSlayer's request: Quote:
If anyone can help point me in a good direction for testing which spells are currently active (in the buff window), I can code the mount's consumption. As always, any and all help is *greatly appreciated*! Thanks, -Codemephit |
This might work for testing if the player is on a mount (untested):
Code:
if(GetBuffSlotFromType(SE_SummonHorse) != -1) { zone/spdat.h has all the Spell Effect types you can use. Another way (probably more efficient) could be: Code:
if(GetHorseId()) { |
I have now finished the consumption code. It handles small and large races and mounts. Both of which can be turned off by rules in the database.
I made 3 characters on a live server and timed their eating & drinking. I can post the math for anyone interested, but the end result is I have an almost perfect live-like consumption rate (even with the rules turned off). I used unsigned integers which have no decimal place. To achieve a 'true' live-like rate, I would have to change this to use decimals. As it stands, food may only last a few extra seconds (42 to be exact), and I didn't think it was a big enough deal to worry with changing. For all of this to work, 4 changes must be made. 3 to the code and 1 to the database. In file \EQEmu-0.7.0-1119\common\ruletypes.h (Line 49) - ADD Code:
RULE_BOOL( Character, RacialConsumption, true) Code:
pp.hunger_level = 5000; Code:
void Client::Handle_OP_Consume(const EQApplicationPacket *app) Code:
INSERT INTO rule_values (ruleset_id, rule_name, rule_value) Also for the rule Character:ConsumptionMultiplier: A value of 100 = Normal rate. A lower value means faster eating. (ie. 50 would mean twice as fast) A higher value means slower eating. (ie 200 would mean twice as slow) Just keep in mind that everything is rounded to the nearest whole number during calculations. Thanks for all the help and ideas guys =) -Codemephit |
Great work, and quick, too!
Possibly related, but do the AAs that affect metabolism work currently? And does this code affect them or vice versa? |
All times are GMT -4. The time now is 09:44 PM. |
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.