From 1ad013e25b89cded916c49addacb7af441ddddb2 Mon Sep 17 00:00:00 2001 From: ApoC Date: Tue, 7 Jul 2009 21:54:23 +0200 Subject: [PATCH] [8146] Fixed handling of eventchance for CreatureEventAI. Check event chance after timers advances othewise event is not scheduled to next time period and event chance is again checked on next AI update. Signed-off-by: ApoC --- src/game/CreatureEventAI.cpp | 14 +++++++------- src/shared/revision_nr.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/game/CreatureEventAI.cpp b/src/game/CreatureEventAI.cpp index 7b7e6966e..ca0384740 100644 --- a/src/game/CreatureEventAI.cpp +++ b/src/game/CreatureEventAI.cpp @@ -112,13 +112,6 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction if (pHolder.Event.event_inverse_phase_mask & (1 << Phase)) return false; - //Store random here so that all random actions match up - uint32 rnd = rand(); - - //Return if chance for event is not met - if (pHolder.Event.event_chance <= rnd % 100) - return false; - CreatureEventAI_Event const& event = pHolder.Event; //Check event conditions based on the event type, also reset events @@ -330,6 +323,13 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction if (!(pHolder.Event.event_flags & EFLAG_REPEATABLE)) pHolder.Enabled = false; + //Store random here so that all random actions match up + uint32 rnd = rand(); + + //Return if chance for event is not met + if (pHolder.Event.event_chance <= rnd % 100) + return false; + //Process actions for (uint32 j = 0; j < MAX_ACTIONS; j++) ProcessAction(pHolder.Event.action[j], rnd, pHolder.Event.event_id, pActionInvoker); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 51560ed5e..1faff6528 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8145" + #define REVISION_NR "8146" #endif // __REVISION_NR_H__