Thread: Forage Issues
View Single Post
  #6  
Old 07-18-2010, 10:48 AM
Irreverent
The Solo Server
 
Join Date: May 2007
Posts: 416
Default

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:
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

Code:
	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:
Code:
[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:
Code:
	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
__________________
OP of Irreverent Server (The Solo Server)
Our Forums
Reply With Quote