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. |
Quote:
Code:
chance[index] = atoi(row[1])+chancepool; Code:
chance[0] = 5 |
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. |
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 :) |
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.
|
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 |
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?
|
Check forage.cpp, the defaults are stored here:
Code:
uint32 common_food_ids[MAX_COMMON_FOOD_IDS] = { Code:
if(foragedfood == 0) { |
All times are GMT -4. The time now is 07:00 PM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.