rendered paste bodydiff --git a/doc/EventAI.txt b/doc/EventAI.txtindex 7a2087d..cf8785a 100644--- a/doc/EventAI.txt+++ b/doc/EventAI.txt@@ -259,6 +259,8 @@ This Event is commonly used for NPC's who do something or say something to you w --------------------- Expires at initial spawn and at creature respawn. This Event is commonly used for setting ranged movement type or Summoning a Pet on Spawn+Parameter 1: 0: works always, 1: works on map in Parameter 2, 2: works on zone in Parameter 2, 3: works on area in Parameter 2+Parameter 2: depends on Parameter 1: for 1 it is map ID, for 2 it is area ID, for 3 it is zone ID to check ----------------------- 12 = EVENT_T_TARGET_HP:diff --git a/src/game/CreatureEventAI.cpp b/src/game/CreatureEventAI.cppindex 9e66310..212749d 100644--- a/src/game/CreatureEventAI.cpp+++ b/src/game/CreatureEventAI.cpp@@ -100,7 +100,10 @@ CreatureEventAI::CreatureEventAI(Creature *c ) : CreatureAI(c) for (std::list<CreatureEventAIHolder>::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i) { if ((*i).Event.event_type == EVENT_T_SPAWNED)- ProcessEvent(*i);+ {+ if (SpawnedConditionsCheck((*i).Event))+ ProcessEvent(*i);+ } } } Reset();@@ -753,7 +756,10 @@ void CreatureEventAI::JustRespawned() for (std::list<CreatureEventAIHolder>::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i) { if ((*i).Event.event_type == EVENT_T_SPAWNED)- ProcessEvent(*i);+ {+ if (SpawnedConditionsCheck((*i).Event))+ ProcessEvent(*i);+ } } } @@ -1364,3 +1370,34 @@ void CreatureEventAI::ReceiveEmote(Player* pPlayer, uint32 text_emote) } } }++bool CreatureEventAI::SpawnedConditionsCheck(CreatureEventAI_Event& Event)+{+ switch (Event.spawned.condition)+ {+ case 0: + // always+ return true;+ case 1: + // map ID check+ if (m_creature->GetMapId() == Event.spawned.conditionValue1)+ return true;+ break;+ case 2: + // zone ID check+ if (m_creature->GetZoneId() == Event.spawned.conditionValue1)+ return true;+ break;+ case 3: + // area ID check+ if (m_creature->GetAreaId() == Event.spawned.conditionValue1)+ return true;+ break;+ default:+ // something wrong+ sLog.outError("CreatureEventAI: Unknown condition (%u) for EVENT_T_SPAWNED event (%u), event skipped", Event.spawned.condition, Event.event_id);+ break;+ }++ return false;+}diff --git a/src/game/CreatureEventAI.h b/src/game/CreatureEventAI.hindex d357e58..cb25a11 100644--- a/src/game/CreatureEventAI.h+++ b/src/game/CreatureEventAI.h@@ -45,7 +45,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@@ -426,6 +426,12 @@ struct CreatureEventAI_Event uint32 repeatMin; uint32 repeatMax; } ooc_los;+ // EVENT_T_SPAWNED+ struct+ {+ uint32 condition;+ uint32 conditionValue1;+ } spawned; // EVENT_T_TARGET_CASTING = 13 struct {@@ -556,6 +562,8 @@ class MANGOS_DLL_SPEC CreatureEventAI : public CreatureAI void DoMeleeAttackIfReady(); bool CanCast(Unit* Target, SpellEntry const *Spell, bool Triggered); + bool SpawnedConditionsCheck(CreatureEventAI_Event& 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);