Log in

View Full Version : Forage Issues


Irreverent
07-07-2010, 09:11 PM
Example: In Firiona Vie, you only get the basic forages. (water/roots/berries/etc)

No one is getting the special forage like the Rose of Firiona.

I checked my table to make sure it isn't corrupted and has the rows. It does.

Not sure what is going on...any tips in researching this?

Irreverent
07-07-2010, 09:16 PM
ok researched a couple other issues with parchment/spell turn ins...the LAST one on the list of the random generator isn't getting rewarded on a list.

Was there a change to the way random numbers are generated? (in code or perl?)

Irreverent
07-07-2010, 09:44 PM
Found it! It was a change in the code!!

Just so many things started going wrong. Dyanmic/random mobs weren't working anymore...turnins that have an array, the last one wasn't being selected....

could this be it?

==06/22/2010==
gaeorn: replaced calls to rand() with calls to MakeRandomInt()

gaeorn
07-08-2010, 12:47 PM
Found it! It was a change in the code!!

Just so many things started going wrong. Dyanmic/random mobs weren't working anymore...turnins that have an array, the last one wasn't being selected....



Do you have evidence of the random mobs not working? From my experience, they do work as intended, but I'm happy to investigate a problem you are seeing if you have more specific information.

In regards to turnins, considering I can get ALL items from repeatedly doing a turnin that has an array of possible items, I'm quite certain that is not misbehaving as you say.

Foraging had some very strange logic in place that may have had a problem. I replaced that logic with more tried and true logic found elsewhere in the code to select an item from a list based on its chance to be selected.

Irreverent
07-08-2010, 01:01 PM
Sure, no problem!

I used this code:

sub EVENT_SAY {
if($text=~/Hail/i) {quest::say("Hi"); }

if($text=~/Test/i)
{
quest::say(quest::ChooseRandom(1,2,3,4,5));
quest::say(quest::ChooseRandom(1,2,3,4,5));
quest::say(quest::ChooseRandom(1,2,3,4,5));
quest::say(quest::ChooseRandom(1,2,3,4,5));
quest::say(quest::ChooseRandom(1,2,3,4,5));
quest::say(quest::ChooseRandom(1,2,3,4,5));
quest::say(quest::ChooseRandom(1,2,3,4,5));
quest::say(quest::ChooseRandom(1,2,3,4,5));
quest::say(quest::ChooseRandom(1,2,3,4,5));
quest::say(quest::ChooseRandom(1,2,3,4,5));
quest::say(quest::ChooseRandom(1,2,3,4,5));
quest::say(quest::ChooseRandom(1,2,3,4,5));
quest::say(quest::ChooseRandom(1,2,3,4,5));
quest::say(quest::ChooseRandom(1,2,3,4,5));

}
}


And got these results: http://irreverentlabs.com/EQ/RandomTest.jpg

joligario
07-08-2010, 01:06 PM
Are you sure you are using the latest? We had this issue resolved I believe.

Irreverent
07-08-2010, 01:08 PM
Yup, using the one that is a binary off the compiled link. 1535.

gaeorn
07-08-2010, 01:08 PM
Yes, what revision are you running that on? Because all evidence is that it works properly in my testing on PEQ.

Irreverent
07-08-2010, 01:09 PM
I'm using the 1535 binaries posted. I'm sure PEQ compiles their own...perhaps they were compiled differently?

gaeorn
07-08-2010, 01:10 PM
Yup, using the one that is a binary off the compiled link. 1535.

That is the latest precompiled version. That is not the latest. The latest is revision 1586.

The problem you are experiencing was resolved in revision 1547.

Irreverent
07-08-2010, 01:12 PM
Makes sense...can someone repost the windows binaries then...Please! :)

Caryatis
07-08-2010, 04:17 PM
No time like the present (http://www.eqemulator.net/wiki/wikka.php?wakka=VS2008)

Irreverent
07-15-2010, 11:06 AM
Well, FV now produces rares.

BUT for some reason Misty thicket, PoJ, and other zones are no longer producing rare forages. Any other 1590+ people having this problem? Can you test? I just have an active population, so this is a bug that it causing a lot of stops on TS/Epics.

Irreverent
07-18-2010, 10:48 AM
ok, I think I found the issue...now need a *real* coder than myself. :)

I put the following lines to show the results in the log. So either if you have multiple forages their sum must be = 100, or the code isn't working as intended....but then again I'm not a C++ guy. in the forage table for zone 33 there are 3 items with 100% chance within them

Added code:
if (RunQuery(query, MakeAnyLenString(&query, "SELECT itemid,chance FROM forage WHERE zoneid= '%i' and level <= '%i'", ZoneID, skill), errbuf, &result))
{
safe_delete_array(query);
while ((row = mysql_fetch_row(result)) && (index < FORAGE_ITEM_LIMIT)) {
item[index] = atoi(row[0]);
chance[index] = atoi(row[1])+chancepool;
LogFile->write(EQEMuLog::Commands, "Possible Forage: %d with a %d chance", item[index], chance[index]);
chancepool = chance[index];
index++;
}

and

if (MakeRandomInt(0,199) < skill_level) {
uint32 foragedfood = 0;
int32 stringid = FORAGE_NOEAT;

if (MakeRandomInt(0,99) <= 25) {
LogFile->write(EQEMuLog::Commands, "Requesting Forage from zone: %d with a %d skill", m_pp.zone_id, skill_level);
foragedfood = database.GetZoneForage(m_pp.zone_id, skill_level);
LogFile->write(EQEMuLog::Commands, "Returned item: %d from zone %d chance", foragedfood, m_pp.zone_id);
}


RESULT:
[07.18. - 10:36:40] Starting Log: logs/eqemu_commands_zone_4288.log
[07.18. - 10:36:40] Requesting Forage from zone: 33 with a 255 skill
[07.18. - 10:36:40] Possible Forage: 14933 with a 100 chance
[07.18. - 10:36:40] Possible Forage: 16496 with a 200 chance
[07.18. - 10:36:40] Possible Forage: 20465 with a 44 chance
[07.18. - 10:36:40] Returned item: 14933 from zone 33 chance
[07.18. - 10:43:33] Requesting Forage from zone: 33 with a 173 skill
[07.18. - 10:43:33] Possible Forage: 14933 with a 100 chance
[07.18. - 10:43:33] Possible Forage: 16496 with a 200 chance
[07.18. - 10:43:33] Possible Forage: 20465 with a 44 chance
[07.18. - 10:43:33] Returned item: 14933 from zone 33 chance
[07.18. - 10:45:15] Requesting Forage from zone: 33 with a 173 skill
[07.18. - 10:45:15] Possible Forage: 14933 with a 100 chance
[07.18. - 10:45:15] Possible Forage: 16496 with a 200 chance
[07.18. - 10:45:15] Possible Forage: 20465 with a 44 chance
[07.18. - 10:45:15] Returned item: 14933 from zone 33 chance

what is weird is where it selects what is returned:
rindex = MakeRandomInt(1, chancepool);
for(int i = 0; i < index; i++) {
if(rindex <= chance[i]) {
ret = item[i];
break;
}
}

return ret;

Again, not a coder...but it always just allows "black root" to be the foraged rare of the 3 available...log never changes and players never get anything else but commons

gaeorn
07-19-2010, 11:01 AM
The problem is because chance[] was an int8, making it's upper limit be 255. Since the pool you are pulling from has three items at 100 chance each, that meant it was trying to set the value to 300, but when you hit 256 it would change to 0. So setting it to 300 made a resultant value of 44.

It does not matter what the sum of the chances are. Only the relative values matter. And chance[index] is going to be the current item chance plus all prior item chances. It is required for the item select code to work properly. Just because the first item will show a 100 chance and the second item will show a 200 chance, it does not mean the second item has twice the chance of being foraged. It just means that when we generate the random number, any values less than or equal to 200 *might* be the second item, but since we check for the first item before the second and any value less than or equal to 100 will return the first, that means the actual range of values that would return the second item is 101-200.

Irreverent
07-19-2010, 02:47 PM
ok, thanks for looking into t again...maybe need to stop posting here and in PM. So I'll just post here for now on!

I don't know about the code and vs. intention or purpose....but all I do know is what my testing has objectively resulted in and its 100% reproducable. And that is being the only way to get rares to load correctly is to have the SUM of the entire zone's forage rate be 100% or less. Once I did that, all zones are now working correctly again. Maybe there was another change that took place this year because it USED to work. I just poorly associated it with the random change(since I am not a coder)

But now a fix has been identified, but not sure if it is the right one. Just need to either 1) fix the code so it properly handles up to 55(hardcoded limit) chances of 100% as per the tables....or 2) have someone update the entire forage table to make each zone = < 100%. I have already done the 2nd to make it work...but I know other servers are having the issue as well.

Secrets
07-19-2010, 03:43 PM
Irreverent, here's some Windows binaries that I compiled latest revision.

Anyone can use these who need those issues resolved.

http://ilikekitti.es/binaries/

Irreverent
07-19-2010, 03:51 PM
Thanks! Forgot to tell you that I'm a compiler type now! Had to learn how to do it, as well as basic code, so I could debug and assist with this issue. As usual, the entire emu staff is great!