Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Development

Development::Development Forum for development topics and for those interested in EQEMu development. (Not a support forum)

Reply
 
Thread Tools Display Modes
  #1  
Old 02-22-2012, 02:44 PM
Derision
Developer
 
Join Date: Feb 2004
Location: UK
Posts: 1,540
Default

Quote:
Originally Posted by Harcourt View Post
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 :)
Reply With Quote
  #2  
Old 02-22-2012, 03:03 PM
Harcourt
Sarnak
 
Join Date: Jul 2011
Posts: 33
Default

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.
Reply With Quote
  #3  
Old 02-22-2012, 03:19 PM
Derision
Developer
 
Join Date: Feb 2004
Location: UK
Posts: 1,540
Default

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
Reply With Quote
  #4  
Old 02-22-2012, 04:40 PM
Harcourt
Sarnak
 
Join Date: Jul 2011
Posts: 33
Default

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.
Reply With Quote
  #5  
Old 02-22-2012, 05:43 PM
Harcourt
Sarnak
 
Join Date: Jul 2011
Posts: 33
Default

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
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 11:55 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3