aboutsummaryrefslogtreecommitdiff
path: root/src/game/CreatureEventAI.cpp
diff options
context:
space:
mode:
authormegamage <none@none>2009-05-21 10:52:05 -0500
committermegamage <none@none>2009-05-21 10:52:05 -0500
commit5fe179019fded52718f6fce9a76c052785df48a5 (patch)
treeace3db0feaba56ff9f452849c54b2ef25d1d840e /src/game/CreatureEventAI.cpp
parent8d771cc9f7b8800ccf8a799740d0b95cc95b4cbe (diff)
[7863] Implement for EVENT_T_SPAWNED map/zone/subzone only event conditions. Author: Alex
--HG-- branch : trunk
Diffstat (limited to 'src/game/CreatureEventAI.cpp')
-rw-r--r--src/game/CreatureEventAI.cpp35
1 files changed, 29 insertions, 6 deletions
diff --git a/src/game/CreatureEventAI.cpp b/src/game/CreatureEventAI.cpp
index 44a8dd6b31b..cd6e58361e6 100644
--- a/src/game/CreatureEventAI.cpp
+++ b/src/game/CreatureEventAI.cpp
@@ -134,10 +134,8 @@ CreatureEventAI::CreatureEventAI(Creature *c ) : CreatureAI(c)
if (!bEmptyList)
{
for (std::list<CreatureEventAIHolder>::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i)
- {
- if ((*i).Event.event_type == EVENT_T_SPAWNED)
+ if (SpawnedEventConditionsCheck((*i).Event))
ProcessEvent(*i);
- }
}
}
@@ -809,10 +807,8 @@ void CreatureEventAI::JustRespawned()
//Handle Spawned Events
for (std::list<CreatureEventAIHolder>::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i)
- {
- if ((*i).Event.event_type == EVENT_T_SPAWNED)
+ if (SpawnedEventConditionsCheck((*i).Event))
ProcessEvent(*i);
- }
}
void CreatureEventAI::Reset()
@@ -1344,3 +1340,30 @@ void CreatureEventAI::ReceiveEmote(Player* pPlayer, uint32 text_emote)
}
}
}
+
+bool CreatureEventAI::SpawnedEventConditionsCheck(CreatureEventAI_Event const& event)
+{
+ if(event.event_type != EVENT_T_SPAWNED)
+ return false;
+
+ switch (event.spawned.condition)
+ {
+ case SPAWNED_EVENT_ALWAY:
+ // always
+ return true;
+ case SPAWNED_EVENT_MAP:
+ // map ID check
+ return m_creature->GetMapId() == event.spawned.conditionValue1;
+ case SPAWNED_EVENT_ZONE:
+ {
+ // zone ID check
+ uint32 zone, area;
+ m_creature->GetZoneAndAreaId(zone,area);
+ return zone == event.spawned.conditionValue1 || area == event.spawned.conditionValue1;
+ }
+ default:
+ break;
+ }
+
+ return false;
+}