aboutsummaryrefslogtreecommitdiff
path: root/src/game/CreatureAIImpl.h
diff options
context:
space:
mode:
authorTrazom62 <none@none>2010-04-08 21:03:26 +0200
committerTrazom62 <none@none>2010-04-08 21:03:26 +0200
commitd93e4079f78f48c9e591494456603940bcb79775 (patch)
tree35fbeb9479a8c85079dbd42346ef558785eeb574 /src/game/CreatureAIImpl.h
parent6f3996fd11bda5778b581a3a755b341311b458a6 (diff)
Script Instance Forge of Souls.
Script based on proposal of Synric on trinitycore forum (submitted by Skarabex on GC). Fix EventMap::DelayEvents Fixes issue #1310. --HG-- branch : trunk
Diffstat (limited to 'src/game/CreatureAIImpl.h')
-rw-r--r--src/game/CreatureAIImpl.h35
1 files changed, 26 insertions, 9 deletions
diff --git a/src/game/CreatureAIImpl.h b/src/game/CreatureAIImpl.h
index 45bc4e0dab0..a6cb52dedc5 100644
--- a/src/game/CreatureAIImpl.h
+++ b/src/game/CreatureAIImpl.h
@@ -405,18 +405,27 @@ class EventMap : private std::map<uint32, uint32>
return 0;
}
- void DelayEvents(uint32 time, uint32 gcd)
+ // Delay all events
+ void DelayEvents(uint32 delay)
{
- time += m_time;
+ if (delay < m_time)
+ m_time -= delay;
+ else
+ m_time = 0;
+ }
+
+ // Delay all events having the specified Global Cooldown.
+ void DelayEvents(uint32 delay, uint32 gcd)
+ {
+ uint32 nextTime = m_time + delay;
gcd = (1 << (gcd + 16));
- for (iterator itr = begin(); itr != end();)
+ for (iterator itr = begin(); itr != end() && itr->first < nextTime;)
{
- if (itr->first >= time)
- break;
if (itr->second & gcd)
{
- ScheduleEvent(time, itr->second);
- erase(itr++);
+ ScheduleEvent(itr->second, itr->first-m_time+delay);
+ erase(itr);
+ itr = begin();
}
else
++itr;
@@ -428,7 +437,10 @@ class EventMap : private std::map<uint32, uint32>
for (iterator itr = begin(); itr != end();)
{
if (eventId == (itr->second & 0x0000FFFF))
- erase(itr++);
+ {
+ erase(itr);
+ itr = begin();
+ }
else
++itr;
}
@@ -436,10 +448,15 @@ class EventMap : private std::map<uint32, uint32>
void CancelEventsByGCD(uint32 gcd)
{
+ gcd = (1 << (gcd + 16));
+
for (iterator itr = begin(); itr != end();)
{
if (itr->second & gcd)
- erase(itr++);
+ {
+ erase(itr);
+ itr = begin();
+ }
else
++itr;
}