[8018] Implement EVENT_T_BUFFED and EVENT_T_TARGET_BUFFED for creature EventAI.

Its can be used for check specific spell auras stack size for event triggering.
This commit is contained in:
VladimirMangos 2009-06-15 02:24:08 +04:00
parent 3c9f9e3fa3
commit 5350dbafd9
5 changed files with 73 additions and 2 deletions

View file

@ -274,8 +274,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))
@ -293,6 +293,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;

View file

@ -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,
};
@ -501,6 +503,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

View file

@ -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;

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "8017"
#define REVISION_NR "8018"
#endif // __REVISION_NR_H__