View Single Post
  #1  
Old 05-16-2010, 05:00 AM
Wolftousen
Sarnak
 
Join Date: Apr 2008
Posts: 49
Default

Code:
int32 Spawn2::resetTimer()
{
1.	int32 rspawn = respawn_ * 1000;
	
2.	if (variance_ != 0) {
3.		int var_over_2 = variance_/2;
4.		rspawn = MakeRandomInt(rspawn - var_over_2, rspawn + var_over_2);
		
		//put a lower bound on it, not a lot of difference below 100, so set that as the bound.
5.		if(rspawn < 100)
6.			rspawn = 100;
	}
	
7.	return (rspawn);
	
}
Line 1 - takes the stored spawn time (that is stored in seconds) and converts it to milliseconds.

Line 3 - takes the variance (stored in seconds) to the spawn time and divides it in half
Issue: variance is never converted to milliseconds, so you are only adding/subtracting fractions of a second to the spawn time.

Line 5,6: test to see if the acquired spawn time is less than 100
Issue: scrap this issue, i was wrong about it, this actually insures > 0 spawn time.


For example:
PEQ has Dozekar the Cursed set to spawn every 26.04 hours (93744 is value in database for this) with a variance of up to +-5.20805555555556 hours (18749 is value in database for this).

If i go through this function the way it is set up right now:
line 1: rspawn = 93744000;
line 2: evaluates to true
line 3: var_over_2 = 9374.5
line 4: rspawn = 93734625.5 to 93753374.5
line 5: rspawn will usually evaluate to false
line 7: return value from line 4


The values at line 4 should be 74995000 to 112493000 otherwise you are only varying the spawn time by fractions of a second which is pointless.

final code:

Code:
int32 Spawn2::resetTimer()
{
	int32 rspawn = respawn_ * 1000;
	
	if (variance_ != 0) {
		int var_over_2 = (variance_ * 1000) / 2;
		rspawn = MakeRandomInt(rspawn - var_over_2, rspawn + var_over_2);
	}

	//put a lower bound on it, not a lot of difference below 100, so set that as the bound.
		if(rspawn < 100)
			rspawn = 100;

	return (rspawn);
	
}
Hope that clears it up.
Reply With Quote