aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/AI/CreatureAIImpl.h
diff options
context:
space:
mode:
authorVincent_Michael <Vincent_Michael@gmx.de>2013-01-31 00:10:17 +0100
committerVincent_Michael <Vincent_Michael@gmx.de>2013-01-31 00:10:17 +0100
commitf5fd7bad69c04352f5e367b8aca2035e0eff57d9 (patch)
treeb8017b150947261f628d25a94ef3d3430b28a69f /src/server/game/AI/CreatureAIImpl.h
parent15e42ac797099361fe7d85436cdc90ddbc5d1a67 (diff)
parent754418a8de569c2cb4d28e9dde5cf257490b73b9 (diff)
Merge branch 'master' of github.com:TrinityCore/TrinityCore into 4.3.4
Conflicts: sql/base/auth_database.sql src/server/scripts/EasternKingdoms/ZulGurub/boss_thekal.cpp src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp
Diffstat (limited to 'src/server/game/AI/CreatureAIImpl.h')
-rw-r--r--src/server/game/AI/CreatureAIImpl.h39
1 files changed, 33 insertions, 6 deletions
diff --git a/src/server/game/AI/CreatureAIImpl.h b/src/server/game/AI/CreatureAIImpl.h
index 559240c4a3f..bf5ab9703e0 100644
--- a/src/server/game/AI/CreatureAIImpl.h
+++ b/src/server/game/AI/CreatureAIImpl.h
@@ -336,21 +336,35 @@ class EventMap
// Sets event phase, must be in range 1 - 8
void SetPhase(uint32 phase)
{
- if (phase && phase < 8)
- _phase = (1 << (phase + 24));
+ if (phase && phase <= 8)
+ _phase = (1 << (phase + 23));
else if (!phase)
_phase = 0;
}
+ // Activates event phase, must be in range 1 - 8
+ void AddPhase(uint32 phase)
+ {
+ if (phase && phase <= 8)
+ _phase |= (1 << (phase + 23));
+ }
+
+ // Deactivates event phase, must be in range 1 - 8
+ void RemovePhase(uint32 phase)
+ {
+ if (phase && phase <= 8)
+ _phase &= ~(1 << (phase + 23));
+ }
+
// Creates new event entry in map with given id, time, group if given (1 - 8) and phase if given (1 - 8)
// 0 for group/phase means it belongs to no group or runs in all phases
void ScheduleEvent(uint32 eventId, uint32 time, uint32 groupId = 0, uint32 phase = 0)
{
time += _time;
if (groupId && groupId < 9)
- eventId |= (1 << (groupId + 16));
+ eventId |= (1 << (groupId + 15));
if (phase && phase < 8)
- eventId |= (1 << (phase + 24));
+ eventId |= (1 << (phase + 23));
StorageType::const_iterator itr = _eventMap.find(time);
while (itr != _eventMap.end())
{
@@ -443,8 +457,12 @@ class EventMap
// Delay all events having the specified Group
void DelayEvents(uint32 delay, uint32 groupId)
{
+ if (!groupId || groupId > 8)
+ return;
+
uint32 nextTime = _time + delay;
- uint32 groupMask = (1 << (groupId + 16));
+ uint32 groupMask = (1 << (groupId + 15));
+
for (StorageType::iterator itr = _eventMap.begin(); itr != _eventMap.end() && itr->first < nextTime;)
{
if (itr->second & groupMask)
@@ -476,7 +494,10 @@ class EventMap
// Cancel events belonging to specified group
void CancelEventGroup(uint32 groupId)
{
- uint32 groupMask = (1 << (groupId + 16));
+ if (!groupId || groupId > 8)
+ return;
+
+ uint32 groupMask = (1 << (groupId + 15));
for (StorageType::iterator itr = _eventMap.begin(); itr != _eventMap.end();)
{
@@ -501,6 +522,12 @@ class EventMap
return 0;
}
+ // Returns wether the eventmap is in the given phase or not.
+ bool IsInPhase(uint32 phase)
+ {
+ return phase <= 8 && (!phase || _phase & (1 << (phase + 23)));
+ }
+
private:
uint32 _time;
uint32 _phase;