Scripts/Icecrown: Use guid instead of cached Creature* to avoid crashes in npc_margrave_dhakar
This commit is contained in:
1 parent
ca7377369f
commit
0691a4310f
2 files changed
+20
-12
No files matched your search
@@ -997,7 +997,7 @@ class npc_margrave_dhakar : public CreatureScript
|
||||
|
||||
struct npc_margrave_dhakarAI : public ScriptedAI
|
||||
{
|
||||
npc_margrave_dhakarAI(Creature* creature) : ScriptedAI(creature) , _summons(me), _lichKing(NULL) { }
|
||||
npc_margrave_dhakarAI(Creature* creature) : ScriptedAI(creature) , _summons(me), _lichKingGuid(0) { }
|
||||
|
||||
void Reset() OVERRIDE
|
||||
{
|
||||
@@ -1035,9 +1035,11 @@ class npc_margrave_dhakar : public CreatureScript
|
||||
|
||||
if (Creature* morbidus = me->FindNearestCreature(NPC_MORBIDUS, 50.0f, true))
|
||||
{
|
||||
_lichKing = me->SummonCreature(NPC_LICH_KING, morbidus->GetPositionX()+10, morbidus->GetPositionY(), morbidus->GetPositionZ());
|
||||
_lichKing->SetFacingTo(morbidus->GetOrientation());
|
||||
_lichKing->CastSpell(_lichKing, SPELL_SIMPLE_TELEPORT, true);
|
||||
Creature* lichKing = me->SummonCreature(NPC_LICH_KING, morbidus->GetPositionX()+10, morbidus->GetPositionY(), morbidus->GetPositionZ());
|
||||
_lichKingGuid = lichKing->GetGUID();
|
||||
lichKing = me->SummonCreature(NPC_LICH_KING, morbidus->GetPositionX()+10, morbidus->GetPositionY(), morbidus->GetPositionZ());
|
||||
lichKing->SetFacingTo(morbidus->GetOrientation());
|
||||
lichKing->CastSpell(_lichKing, SPELL_SIMPLE_TELEPORT, true);
|
||||
}
|
||||
|
||||
_events.ScheduleEvent(EVENT_LK_SAY_1, 5000);
|
||||
@@ -1045,31 +1047,36 @@ class npc_margrave_dhakar : public CreatureScript
|
||||
}
|
||||
case EVENT_LK_SAY_1:
|
||||
{
|
||||
_lichKing->AI()->Talk(SAY_LK_1);
|
||||
if (Creature* lichKing = Unit::GetCreature(*me, _lichKingGuid))
|
||||
lichKing->AI()->Talk(SAY_LK_1);
|
||||
_events.ScheduleEvent(EVENT_LK_SAY_2, 5000);
|
||||
break;
|
||||
}
|
||||
case EVENT_LK_SAY_2:
|
||||
{
|
||||
_lichKing->AI()->Talk(SAY_LK_2);
|
||||
if (Creature* lichKing = Unit::GetCreature(*me, _lichKingGuid))
|
||||
lichKing->AI()->Talk(SAY_LK_2);
|
||||
_events.ScheduleEvent(EVENT_LK_SAY_3, 5000);
|
||||
break;
|
||||
}
|
||||
case EVENT_LK_SAY_3:
|
||||
{
|
||||
_lichKing->AI()->Talk(SAY_LK_3);
|
||||
if (Creature* lichKing = Unit::GetCreature(*me, _lichKingGuid))
|
||||
lichKing->AI()->Talk(SAY_LK_3);
|
||||
_events.ScheduleEvent(EVENT_LK_SAY_4, 5000);
|
||||
break;
|
||||
}
|
||||
case EVENT_LK_SAY_4:
|
||||
{
|
||||
_lichKing->AI()->Talk(SAY_LK_4);
|
||||
if (Creature* lichKing = Unit::GetCreature(*me, _lichKingGuid))
|
||||
lichKing->AI()->Talk(SAY_LK_4);
|
||||
_events.ScheduleEvent(EVENT_OUTRO, 12000);
|
||||
break;
|
||||
}
|
||||
case EVENT_LK_SAY_5:
|
||||
{
|
||||
_lichKing->AI()->Talk(SAY_LK_5);
|
||||
if (Creature* lichKing = Unit::GetCreature(*me, _lichKingGuid))
|
||||
lichKing->AI()->Talk(SAY_LK_5);
|
||||
_events.ScheduleEvent(EVENT_OUTRO, 8000);
|
||||
break;
|
||||
}
|
||||
@@ -1078,7 +1085,8 @@ class npc_margrave_dhakar : public CreatureScript
|
||||
if (Creature* olakin = me->FindNearestCreature(NPC_OLAKIN, 50.0f, true))
|
||||
olakin->AI()->Talk(SAY_OLAKIN_PAY);
|
||||
|
||||
_lichKing->DespawnOrUnsummon(0);
|
||||
if (Creature* lichKing = Unit::GetCreature(*me, _lichKingGuid))
|
||||
lichKing->DespawnOrUnsummon(0);
|
||||
|
||||
_events.ScheduleEvent(EVENT_START, 5000);
|
||||
break;
|
||||
@@ -1101,7 +1109,7 @@ class npc_margrave_dhakar : public CreatureScript
|
||||
|
||||
private:
|
||||
EventMap _events;
|
||||
Creature* _lichKing;
|
||||
uint64 _lichKingGuid;
|
||||
SummonList _summons;
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user