Scripts/PetMage: fixed a crash with DK's Gargoyle and Mirror Image

This commit is contained in:
ShinDarth
2016-08-26 18:52:51 +02:00
parent 76b59632c0
commit 3d5d8a663c
+9 -8
View File
@@ -51,7 +51,7 @@ class npc_pet_mage_mirror_image : public CreatureScript
npc_pet_mage_mirror_imageAI(Creature* creature) : CasterAI(creature) { } npc_pet_mage_mirror_imageAI(Creature* creature) : CasterAI(creature) { }
uint32 selectionTimer; uint32 selectionTimer;
uint64 _ebonGarogyleGUID; uint64 _ebonGargoyleGUID;
void InitializeAI() void InitializeAI()
{ {
@@ -92,7 +92,7 @@ class npc_pet_mage_mirror_image : public CreatureScript
ref = ref->next(); ref = ref->next();
} }
_ebonGarogyleGUID = 0; _ebonGargoyleGUID = 0;
// Xinef: copy caster auras // Xinef: copy caster auras
Unit::VisibleAuraMap const* visibleAuraMap = owner->GetVisibleAuras(); Unit::VisibleAuraMap const* visibleAuraMap = owner->GetVisibleAuras();
@@ -102,8 +102,8 @@ class npc_pet_mage_mirror_image : public CreatureScript
// Ebon Gargoyle // Ebon Gargoyle
if (visAura->GetId() == 49206 && me->GetUInt32Value(UNIT_CREATED_BY_SPELL) == SPELL_SUMMON_MIRROR_IMAGE1) if (visAura->GetId() == 49206 && me->GetUInt32Value(UNIT_CREATED_BY_SPELL) == SPELL_SUMMON_MIRROR_IMAGE1)
{ {
if (Unit* garogyle = visAura->GetCaster()) if (Unit* gargoyle = visAura->GetCaster())
_ebonGarogyleGUID = garogyle->GetGUID(); _ebonGargoyleGUID = gargoyle->GetGUID();
continue; continue;
} }
SpellScriptsBounds bounds = sObjectMgr->GetSpellScriptsBounds(visAura->GetId()); SpellScriptsBounds bounds = sObjectMgr->GetSpellScriptsBounds(visAura->GetId());
@@ -137,11 +137,12 @@ class npc_pet_mage_mirror_image : public CreatureScript
bool MySelectNextTarget() bool MySelectNextTarget()
{ {
if (_ebonGarogyleGUID) if (_ebonGargoyleGUID)
{ {
if (Unit* garogyle = ObjectAccessor::GetUnit(*me, _ebonGarogyleGUID)) Unit* gargoyle = ObjectAccessor::GetUnit(*me, _ebonGargoyleGUID);
garogyle->GetAI()->AttackStart(me); if (gargoyle && gargoyle->GetAI())
_ebonGarogyleGUID = 0; gargoyle->GetAI()->AttackStart(me);
_ebonGargoyleGUID = 0;
} }
Unit* owner = me->GetOwner(); Unit* owner = me->GetOwner();
if (owner && owner->GetTypeId() == TYPEID_PLAYER) if (owner && owner->GetTypeId() == TYPEID_PLAYER)