aboutsummaryrefslogtreecommitdiff
path: root/src
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
parent8d771cc9f7b8800ccf8a799740d0b95cc95b4cbe (diff)
[7863] Implement for EVENT_T_SPAWNED map/zone/subzone only event conditions. Author: Alex
--HG-- branch : trunk
Diffstat (limited to 'src')
-rw-r--r--src/game/CreatureEventAI.cpp35
-rw-r--r--src/game/CreatureEventAI.h17
-rw-r--r--src/game/CreatureEventAIMgr.cpp18
3 files changed, 62 insertions, 8 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;
+}
diff --git a/src/game/CreatureEventAI.h b/src/game/CreatureEventAI.h
index e8dcbaeca40..7b9fe84453e 100644
--- a/src/game/CreatureEventAI.h
+++ b/src/game/CreatureEventAI.h
@@ -44,7 +44,7 @@ enum EventAI_Type
EVENT_T_SPELLHIT = 8, // SpellID, School, RepeatMin, RepeatMax
EVENT_T_RANGE = 9, // MinDist, MaxDist, RepeatMin, RepeatMax
EVENT_T_OOC_LOS = 10, // NoHostile, MaxRnage, RepeatMin, RepeatMax
- EVENT_T_SPAWNED = 11, // NONE
+ EVENT_T_SPAWNED = 11, // Condition, CondValue1
EVENT_T_TARGET_HP = 12, // HPMax%, HPMin%, RepeatMin, RepeatMax
EVENT_T_TARGET_CASTING = 13, // RepeatMin, RepeatMax
EVENT_T_FRIENDLY_HP = 14, // HPDeficit, Radius, RepeatMin, RepeatMax
@@ -160,6 +160,13 @@ enum EventFlags
EFLAG_DEBUG_ONLY = 0x80, //Event only occurs in debug build
};
+enum SpawnedEventMode
+{
+ SPAWNED_EVENT_ALWAY = 0,
+ SPAWNED_EVENT_MAP = 1,
+ SPAWNED_EVENT_ZONE = 2
+};
+
// String text additional data, used in (CreatureEventAI)
struct StringTextData
{
@@ -436,6 +443,12 @@ struct CreatureEventAI_Event
uint32 repeatMin;
uint32 repeatMax;
} ooc_los;
+ // EVENT_T_SPAWNED = 11
+ struct
+ {
+ uint32 condition;
+ uint32 conditionValue1;
+ } spawned;
// EVENT_T_TARGET_CASTING = 13
struct
{
@@ -563,6 +576,8 @@ class TRINITY_DLL_SPEC CreatureEventAI : public CreatureAI
void DoScriptText(int32 textEntry, WorldObject* pSource, Unit* target);
bool CanCast(Unit* Target, SpellEntry const *Spell, bool Triggered);
+ bool SpawnedEventConditionsCheck(CreatureEventAI_Event const& event);
+
Unit* DoSelectLowestHpFriendly(float range, uint32 MinHPDiff);
void DoFindFriendlyMissingBuff(std::list<Creature*>& _list, float range, uint32 spellid);
void DoFindFriendlyCC(std::list<Creature*>& _list, float range);
diff --git a/src/game/CreatureEventAIMgr.cpp b/src/game/CreatureEventAIMgr.cpp
index 5a163089d4c..1905fa72d41 100644
--- a/src/game/CreatureEventAIMgr.cpp
+++ b/src/game/CreatureEventAIMgr.cpp
@@ -283,6 +283,23 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
if (temp.ooc_los.repeatMax < temp.ooc_los.repeatMin)
sLog.outErrorDb("CreatureEventAI: Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i);
break;
+ case EVENT_T_SPAWNED:
+ switch(temp.spawned.condition)
+ {
+ case SPAWNED_EVENT_ALWAY:
+ break;
+ case SPAWNED_EVENT_MAP:
+ if(!sMapStore.LookupEntry(temp.spawned.conditionValue1))
+ sLog.outErrorDb("CreatureEventAI: Creature %u are using spawned event(%u) with param1 = %u 'map specific' but with not existed map (%u) in param2. Event will never repeat.", temp.creature_id, i, temp.spawned.condition, temp.spawned.conditionValue1);
+ break;
+ case SPAWNED_EVENT_ZONE:
+ if(!GetAreaEntryByAreaID(temp.spawned.conditionValue1))
+ sLog.outErrorDb("CreatureEventAI: Creature %u are using spawned event(%u) with param1 = %u 'area specific' but with not existed area (%u) in param2. Event will never repeat.", temp.creature_id, i, temp.spawned.condition, temp.spawned.conditionValue1);
+ default:
+ sLog.outErrorDb("CreatureEventAI: Creature %u are using invalid spawned event %u mode (%u) in param1", temp.creature_id, i, temp.spawned.condition);
+ break;
+ }
+ break;
case EVENT_T_FRIENDLY_HP:
if (temp.friendly_hp.repeatMax < temp.friendly_hp.repeatMin)
sLog.outErrorDb("CreatureEventAI: Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i);
@@ -327,7 +344,6 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
case EVENT_T_AGGRO:
case EVENT_T_DEATH:
case EVENT_T_EVADE:
- case EVENT_T_SPAWNED:
case EVENT_T_REACHED_HOME:
{
if (temp.event_flags & EFLAG_REPEATABLE)