From c15c25aca40d30b9ac978f3f6476dc52fa6ff94b Mon Sep 17 00:00:00 2001 From: QAston Date: Tue, 28 Jul 2009 21:34:18 +0200 Subject: *Cleanups and Fixes in Mirror Image script. --HG-- branch : trunk --- src/bindings/scripts/scripts/npc/npcs_special.cpp | 40 +++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 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 9bf3113a9c6..655ab7b4ffd 100644 --- a/src/bindings/scripts/scripts/npc/npcs_special.cpp +++ b/src/bindings/scripts/scripts/npc/npcs_special.cpp @@ -1636,7 +1636,7 @@ CreatureAI* GetAI_mob_mojo(Creature *_Creature) return new mob_mojoAI (_Creature); } -struct TRINITY_DLL_DECL npc_mirror_image : public SpellAI +struct TRINITY_DLL_DECL npc_mirror_image : SpellAI { npc_mirror_image(Creature *c) : SpellAI(c) {} @@ -1647,7 +1647,6 @@ struct TRINITY_DLL_DECL npc_mirror_image : public SpellAI owner = ((TempSummon*)me)->GetOwner(); if (!owner) return; - me->SetDisplayId(owner->GetDisplayId()); owner->SetLevel(owner->getLevel()); // Inherit Master's Threat List (not yet implemented) owner->CastSpell((Unit*)NULL, 58838, true); @@ -1656,6 +1655,43 @@ struct TRINITY_DLL_DECL npc_mirror_image : public SpellAI // Clone Me! 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); + } + } }; CreatureAI* GetAI_npc_mirror_image(Creature *_Creature) -- cgit v1.2.3