Thread: Forage oddness
View Single Post
  #2  
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