aboutsummaryrefslogtreecommitdiff
path: root/src/bindings/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'src/bindings/scripts')
-rw-r--r--src/bindings/scripts/scripts/npc/npcs_special.cpp40
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)