diff options
| author | Nay <dnpd.dd@gmail.com> | 2013-07-19 02:27:56 +0100 |
|---|---|---|
| committer | Nay <dnpd.dd@gmail.com> | 2013-07-19 02:27:56 +0100 |
| commit | 0691a4310f865fe9fdd317f64b5e856a9b6f8ea9 (patch) | |
| tree | 311b42559b28377edaecc53d0969e32ee247f40d /src/server/scripts | |
| parent | ca7377369f603081259adea0ba49cb03e74e609f (diff) | |
Scripts/Icecrown: Use guid instead of cached Creature* to avoid crashes in npc_margrave_dhakar
Diffstat (limited to 'src/server/scripts')
| -rw-r--r-- | src/server/scripts/Northrend/zone_icecrown.cpp | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/src/server/scripts/Northrend/zone_icecrown.cpp b/src/server/scripts/Northrend/zone_icecrown.cpp index 3b550b0dab3..e736710eced 100644 --- a/src/server/scripts/Northrend/zone_icecrown.cpp +++ b/src/server/scripts/Northrend/zone_icecrown.cpp @@ -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; }; |
