diff options
author | megamage <none@none> | 2009-06-15 23:10:06 -0500 |
---|---|---|
committer | megamage <none@none> | 2009-06-15 23:10:06 -0500 |
commit | 208fbe220db7be29e9ecb297441a1bc6daf59a14 (patch) | |
tree | 55ac2f0689e30eef184c3dea8f21b26bf0db9b59 | |
parent | 00f4a31b735f327b715ff12d82f78de33c95539e (diff) |
[8018] Implement EVENT_T_BUFFED and EVENT_T_TARGET_BUFFED for creature EventAI. Author: VladimirMangos
Its can be used for check specific spell auras stack size for event triggering.
[8017] Always reset creature EventAI phase at creature death.
--HG--
branch : trunk
-rw-r--r-- | doc/EventAI.txt | 18 | ||||
-rw-r--r-- | src/game/CreatureEventAI.cpp | 33 | ||||
-rw-r--r-- | src/game/CreatureEventAI.h | 11 | ||||
-rw-r--r-- | src/game/CreatureEventAIMgr.cpp | 14 |
4 files changed, 75 insertions, 1 deletions
diff --git a/doc/EventAI.txt b/doc/EventAI.txt index 76e4fa20c35..0f411b62833 100644 --- a/doc/EventAI.txt +++ b/doc/EventAI.txt @@ -80,6 +80,8 @@ Some events such as EVENT_T_AGGRO, EVENT_T_DEATH, EVENT_T_SPAWNED, and EVENT_T_E 18 EVENT_T_TARGET_MANA ManaMax%, ManaMin%, RepeatMin, RepeatMax 21 EVENT_T_REACHED_HOME NONE Expires when creature reach it's home(spawn) location after Evade. 22 EVENT_T_RECEIVE_EMOTE EmoteId, Condition, CondValue1, CondValue2 Expires when creature receive emote with text emote id(enum TextEmotes). Condition can be defined. If set, then most conditions has additional value (see enum ConditionType) +23 EVENT_T_BUFFED SpellID, AmmountInStack, RepeatMin, RepeatMax Expires when creature have spell (Param1) auras applied stack greater or equal provided in Param2 amount. Will repeat every (Param3) and (Param4). +24 EVENT_T_TARGET_BUFFED SpellID, AmmountInStack, RepeatMin, RepeatMax Expires when target unit have spell (Param1) auras applied stack greater or equal provided in Param2 amount. Will repeat every (Param3) and (Param4). ========================================= Action Types @@ -339,6 +341,22 @@ Most commonly used to cast spells that can not be casted in EVENT_T_EVADE and ot Expires only when creature receive emote from player. Valid text emote id's are in Mangos source (enum TextEmotes) Event does not require any conditions to process, however many are ecpected to have condition. +--------------------------- +23 = EVENT_T_BUFFED : +--------------------------- +Parameter 1: SpellId - This is the SpellID That the Aura Check will look for +Parameter 2: Amount - This is the amount of SpellID's auras at creature required for event expire. +Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire +Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire + +--------------------------- +24 = EVENT_T_TARGET_BUFFED: +--------------------------- +Parameter 1: SpellId - This is the SpellID That the Aura Check will look for +Parameter 2: Amount - This is the amount of SpellID's auras at target unit required for event expire. +Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire +Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire + EventAI use conditions from available in Mangos (enum ConditionType) Current implemented conditions: CONDITION_NONE (0) 0 0 diff --git a/src/game/CreatureEventAI.cpp b/src/game/CreatureEventAI.cpp index 000d59fac28..3d83b2c4fb4 100644 --- a/src/game/CreatureEventAI.cpp +++ b/src/game/CreatureEventAI.cpp @@ -275,8 +275,8 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction //Repeat Timers pHolder.UpdateRepeatTimer(m_creature,event.summon_unit.repeatMin,event.summon_unit.repeatMax); + break; } - break; case EVENT_T_TARGET_MANA: { if (!m_creature->isInCombat() || !m_creature->getVictim() || !m_creature->getVictim()->GetMaxPower(POWER_MANA)) @@ -294,6 +294,34 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction case EVENT_T_REACHED_HOME: case EVENT_T_RECEIVE_EMOTE: break; + case EVENT_T_BUFFED: + { + //Note: checked only aura for effect 0, if need check aura for effect 1/2 then + // possible way: pack in event.buffed.amount 2 uint16 (ammount+effectIdx) + Aura* aura = m_creature->GetAura(event.buffed.spellId,0); + if(!aura || aura->GetStackAmount() < event.buffed.amount) + return false; + + //Repeat Timers + pHolder.UpdateRepeatTimer(m_creature,event.buffed.repeatMin,event.buffed.repeatMax); + break; + } + case EVENT_T_TARGET_BUFFED: + { + //Prevent event from occuring on no unit + if (!pActionInvoker) + return false; + + //Note: checked only aura for effect 0, if need check aura for effect 1/2 then + // possible way: pack in event.buffed.amount 2 uint16 (ammount+effectIdx) + Aura* aura = pActionInvoker->GetAura(event.buffed.spellId,0); + if(!aura || aura->GetStackAmount() < event.buffed.amount) + return false; + + //Repeat Timers + pHolder.UpdateRepeatTimer(m_creature,event.buffed.repeatMin,event.buffed.repeatMax); + break; + } default: sLog.outErrorDb("CreatureEventAI: Creature %u using Event %u has invalid Event Type(%u), missing from ProcessEvent() Switch.", m_creature->GetEntry(), pHolder.Event.event_id, pHolder.Event.event_type); break; @@ -853,6 +881,9 @@ void CreatureEventAI::JustDied(Unit* killer) if ((*i).Event.event_type == EVENT_T_DEATH) ProcessEvent(*i, killer); } + + // reset phase after any death state events + Phase = 0; } void CreatureEventAI::KilledUnit(Unit* victim) diff --git a/src/game/CreatureEventAI.h b/src/game/CreatureEventAI.h index d94ceeeac18..db9cb680670 100644 --- a/src/game/CreatureEventAI.h +++ b/src/game/CreatureEventAI.h @@ -56,6 +56,8 @@ enum EventAI_Type EVENT_T_QUEST_COMPLETE = 20, // EVENT_T_REACHED_HOME = 21, // NONE EVENT_T_RECEIVE_EMOTE = 22, // EmoteId, Condition, CondValue1, CondValue2 + EVENT_T_BUFFED = 23, // Param1 = SpellID, Param2 = Number of Time STacked, Param3/4 Repeat Min/Max + EVENT_T_TARGET_BUFFED = 24, // Param1 = SpellID, Param2 = Number of Time STacked, Param3/4 Repeat Min/Max EVENT_T_END, }; @@ -507,6 +509,15 @@ struct CreatureEventAI_Event uint32 conditionValue1; uint32 conditionValue2; } receive_emote; + // EVENT_T_BUFFED = 23 + // EVENT_T_TARGET_BUFFED = 24 + struct + { + uint32 spellId; + uint32 amount; + uint32 repeatMin; + uint32 repeatMax; + } buffed; // RAW struct diff --git a/src/game/CreatureEventAIMgr.cpp b/src/game/CreatureEventAIMgr.cpp index 0a6fb8bdb59..643a5a3212a 100644 --- a/src/game/CreatureEventAIMgr.cpp +++ b/src/game/CreatureEventAIMgr.cpp @@ -378,6 +378,20 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() break; } + case EVENT_T_BUFFED: + case EVENT_T_TARGET_BUFFED: + { + SpellEntry const* pSpell = sSpellStore.LookupEntry(temp.buffed.spellId); + if (!pSpell) + { + sLog.outErrorDb("CreatureEventAI: Creature %u has non-existant SpellID(%u) defined in event %u.", temp.creature_id, temp.spell_hit.spellId, i); + continue; + } + if (temp.buffed.repeatMax < temp.buffed.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; + } + default: sLog.outErrorDb("CreatureEventAI: Creature %u using not checked at load event (%u) in event %u. Need check code update?", temp.creature_id, temp.event_id, i); break; |