Fix ABM trigger chance being often way too high

This commit is contained in:
Perttu Ahola 2012-01-02 20:26:33 +02:00
parent cd0019acd2
commit 4630281318
2 changed files with 5 additions and 2 deletions

@ -588,15 +588,17 @@ public:
float trigger_interval = abm->getTriggerInterval(); float trigger_interval = abm->getTriggerInterval();
if(trigger_interval < 0.001) if(trigger_interval < 0.001)
trigger_interval = 0.001; trigger_interval = 0.001;
float actual_interval = dtime_s;
if(use_timers){ if(use_timers){
i->timer += dtime_s; i->timer += dtime_s;
if(i->timer < trigger_interval) if(i->timer < trigger_interval)
continue; continue;
i->timer -= trigger_interval; i->timer -= trigger_interval;
actual_interval = trigger_interval;
} }
ActiveABM aabm; ActiveABM aabm;
aabm.abm = abm; aabm.abm = abm;
float intervals = dtime_s / trigger_interval; float intervals = actual_interval / trigger_interval;
float chance = abm->getTriggerChance(); float chance = abm->getTriggerChance();
if(chance == 0) if(chance == 0)
chance = 1; chance = 1;

@ -130,7 +130,8 @@ struct ABMWithState
float timer; float timer;
ABMWithState(ActiveBlockModifier *abm_): ABMWithState(ActiveBlockModifier *abm_):
abm(abm_) abm(abm_),
timer(0)
{} {}
}; };