From 50c73d433ce54b5c119058ee295d0ffaa5ac95bc Mon Sep 17 00:00:00 2001 From: QAston Date: Thu, 6 Aug 2009 23:10:36 +0200 Subject: *Add SpellCasterAI as a framework for casting only units (like ebon gargoyle or mirror image. --HG-- branch : trunk --- src/bindings/scripts/scripts/npc/npcs_special.cpp | 46 +++-------------------- 1 file changed, 5 insertions(+), 41 deletions(-) (limited to 'src/bindings/scripts') diff --git a/src/bindings/scripts/scripts/npc/npcs_special.cpp b/src/bindings/scripts/scripts/npc/npcs_special.cpp index 9b31a9282d1..f6922745953 100644 --- a/src/bindings/scripts/scripts/npc/npcs_special.cpp +++ b/src/bindings/scripts/scripts/npc/npcs_special.cpp @@ -1639,12 +1639,13 @@ CreatureAI* GetAI_mob_mojo(Creature *_Creature) return new mob_mojoAI (_Creature); } -struct TRINITY_DLL_DECL npc_mirror_image : SpellAI +struct TRINITY_DLL_DECL npc_mirror_image : SpellCasterAI { - npc_mirror_image(Creature *c) : SpellAI(c) {Reset();} + npc_mirror_image(Creature *c) : SpellCasterAI(c) {} - void Reset() + void InitializeAI() { + SpellCasterAI::InitializeAI(); Unit * owner = me->GetOwner(); if (!owner) return; @@ -1656,43 +1657,7 @@ struct TRINITY_DLL_DECL npc_mirror_image : SpellAI owner->CastSpell(me, 45204, false); } - void EnterCombat(Unit *who) - { - if (spells.empty()) - return; - - uint32 spell = rand() % spells.size(); - uint32 count = 0; - for(SpellVct::iterator itr = spells.begin(); itr != spells.end(); ++itr, ++count) - { - uint32 cooldown = GetAISpellInfo(*itr)->cooldown; - if (count == spell) - { - DoCast(spells[spell]); - cooldown += me->GetCurrentSpellCastTime(*itr); - } - events.ScheduleEvent(*itr, cooldown); - } - } - - void UpdateAI(const uint32 diff) - { - if(!UpdateVictim()) - return; - - events.Update(diff); - - if(me->hasUnitState(UNIT_STAT_CASTING)) - return; - - if(uint32 spellId = events.ExecuteEvent()) - { - DoCast(spellId); - uint32 casttime = me->GetCurrentSpellCastTime(spellId); - events.ScheduleEvent(spellId, (casttime ? casttime : 500) + GetAISpellInfo(spellId)->cooldown); - } - } - + // Do not reload creature templates on evade mode enter - prevent visual lost void EnterEvadeMode() { if(me->IsInEvadeMode() || !me->isAlive()) @@ -1707,7 +1672,6 @@ struct TRINITY_DLL_DECL npc_mirror_image : SpellAI me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, m_creature->GetFollowAngle(), MOTION_SLOT_ACTIVE); } } - }; CreatureAI* GetAI_npc_mirror_image(Creature *_Creature) -- cgit v1.2.3