diff options
| author | QAston <none@none> | 2009-07-28 21:34:18 +0200 |
|---|---|---|
| committer | QAston <none@none> | 2009-07-28 21:34:18 +0200 |
| commit | c15c25aca40d30b9ac978f3f6476dc52fa6ff94b (patch) | |
| tree | f9d8df65afa21221b3be1d52f23891b8b6a5dc3d /src/bindings/scripts | |
| parent | cf0d8a2b035a60ed0fc9a70df8d2d4d9b3a598ea (diff) | |
*Cleanups and Fixes in Mirror Image script.
--HG--
branch : trunk
Diffstat (limited to 'src/bindings/scripts')
| -rw-r--r-- | src/bindings/scripts/scripts/npc/npcs_special.cpp | 40 |
1 files changed, 38 insertions, 2 deletions
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) |
