Wolftousen
05-15-2010, 10:16 PM
Was confused as to why a certain spawn kept going off at the same spawn time even though it had variance set in the database entry.
Went and found out that the function that controls spawn time has some minor bugs that prevent variance from working properly:
zone/spawn2.cpp rev 1488:
int32 Spawn2::resetTimer()
{
int32 rspawn = respawn_ * 1000;
if (variance_ != 0) {
int var_over_2 = variance_/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);
}
this should be:
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);
}
return (rspawn);
}
The if statement that tests rspawn < 100 prevents the spawn time from varying to be less than it's base.
Not multiplying variance_ by 1000 means it is not operating in seconds, but something smaller (micro seconds i think, i forget...).
Went and found out that the function that controls spawn time has some minor bugs that prevent variance from working properly:
zone/spawn2.cpp rev 1488:
int32 Spawn2::resetTimer()
{
int32 rspawn = respawn_ * 1000;
if (variance_ != 0) {
int var_over_2 = variance_/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);
}
this should be:
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);
}
return (rspawn);
}
The if statement that tests rspawn < 100 prevents the spawn time from varying to be less than it's base.
Not multiplying variance_ by 1000 means it is not operating in seconds, but something smaller (micro seconds i think, i forget...).