|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Development::Development Forum for development topics and for those interested in EQEMu development. (Not a support forum) |
02-22-2012, 02:27 PM
|
Sarnak
|
|
Join Date: Jul 2011
Posts: 33
|
|
Forage oddness
This looks odd to me, and I thought I'd run it by folks who know the code. By the way, if I created a local fix I have no idea how I'd communicate it to anyone. I assume commit privileges are not just given to everyone.
Anyhow, in forage.cpp (rev 2103), on line #111 the variable chancepool is repeatedly overwritten inside the loop. (I assume this was intended to be a += instead of =)
Next, on line #132 we have rindex being assigned a random value. (Why am I thinking of string operations now...) So far, so good. But below, it is compared against each of the chance values (from the forage table). I suspect that this loop is missing something like "rindex -= chance[i]"
I'm not 100% sure that this is a fair distribution of probability, but it looks like it would be better than what is in there.
|
02-22-2012, 02:44 PM
|
Developer
|
|
Join Date: Feb 2004
Location: UK
Posts: 1,540
|
|
Quote:
Originally Posted by Harcourt
Anyhow, in forage.cpp (rev 2103), on line #111 the variable chancepool is repeatedly overwritten inside the loop. (I assume this was intended to be a += instead of =)
|
If you look a little further up at line 109, you will see this:
Code:
chance[index] = atoi(row[1])+chancepool;
So if there are three possible forage items, the first with chance 5, the next with chance 10, and the last with chance 50, we get:
Code:
chance[0] = 5
chance[1] = 15
chance[2] = 65
On line 132, a random number between 1 and 65 is generated. Then, in the loop, if the random number is <=5, the first item is chosen, if it is > 5 and <=15, the second item is chosen, else the last item is chosen.
Last edited by Derision; 02-22-2012 at 02:49 PM..
Reason: I meant line 109 :)
|
02-22-2012, 03:03 PM
|
Sarnak
|
|
Join Date: Jul 2011
Posts: 33
|
|
Thanks for clearing that up. See, it is a good idea to ask about these things.
The only problem I have with that then is that items at the beginning of the forage table would seem to have a higher probability of dropping. I think that ideally one would want to start at a random spot in the table and wrap around.
Edit: On second thought this looks OK.
|
02-22-2012, 03:19 PM
|
Developer
|
|
Join Date: Feb 2004
Location: UK
Posts: 1,540
|
|
I don't follow why items at the beginning of the table would have a higher probability of dropping ?
If we assume the random number is truly random, then the probability of an item is in proportion to it's chance value versus the sum of the chance values of all the possible items, i.e.
Item 0 has a 5/65 chance, item 1 has a 10/65 chance, and item 2 has a 50/65 chance.
The position in the table should have no bearing on it's chance to be selected, unless there is something I am missing. I didn't write this code BTW, this is just my conclusion by looking at it.
EDIT: I took too long writing this before you edited your post
|
02-22-2012, 04:40 PM
|
Sarnak
|
|
Join Date: Jul 2011
Posts: 33
|
|
That is a good explanation. I needed to go through it myself before I edited it. This is one of the things I look for in my own code, so I tend to question it in new (to me) code.
|
02-22-2012, 05:43 PM
|
Sarnak
|
|
Join Date: Jul 2011
Posts: 33
|
|
Postscript: this entire question is moot.
Client::Forage only calls uses the database for 25% of the drops, the rest of the time using stock items. This looks like temporary code to get some sort of foraging behavior, and is definitely not like live. For example Mushrooms (14905) are not foraged in EK or Crescent Reach.
For my own use, I think I'll use the database for all forage drops. A couple of hours and a G15 keyboard gave me the stats from live for a zone. This may be more than the rest of community wants to do, but I only care about a few zones atm.
PS: it may be the case that I have yet again misread the code, but a breakpoint verified foraging without checking the db tables.
Anyhow, just a heads up to anyone OCD about foraging
|
04-19-2015, 08:13 AM
|
Hill Giant
|
|
Join Date: Feb 2013
Posts: 220
|
|
Just been looking at this today. Is there any easy way to remove the Mushrooms from the list of 'stock' forage drops? Where does it pull those items from?
|
04-19-2015, 11:36 AM
|
Administrator
|
|
Join Date: May 2013
Location: United States
Posts: 1,594
|
|
Check forage.cpp, the defaults are stored here:
Code:
uint32 common_food_ids[MAX_COMMON_FOOD_IDS] = {
13046, // Fruit
13045, // Berries
13419, // Vegetables
13048, // Rabbit Meat
13047, // Roots
13044, // Pod Of Water
14905, // mushroom
13106 // Fishing Grubs
};
So you can remove that and remove this:
Code:
if(foragedfood == 0) {
uint8 index = 0;
index = zone->random.Int(0, MAX_COMMON_FOOD_IDS-1);
foragedfood = common_food_ids[index];
}
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -4. The time now is 09:28 AM.
|
|
|
|
|
|
|
|
|
|
|
|
|