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 | |
parent | ca7377369f603081259adea0ba49cb03e74e609f (diff) |
Scripts/Icecrown: Use guid instead of cached Creature* to avoid crashes in npc_margrave_dhakar
-rw-r--r-- | src/server/game/Globals/ObjectMgr.cpp | 2 | ||||
-rw-r--r-- | src/server/scripts/Northrend/zone_icecrown.cpp | 30 |
2 files changed, 20 insertions, 12 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index ae389dd69f2..7bf87a72e8c 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -2179,7 +2179,7 @@ void ObjectMgr::LoadItemTemplates() itemTemplate.Name1 = fields[4].GetString(); itemTemplate.DisplayInfoID = fields[5].GetUInt32(); itemTemplate.Quality = uint32(fields[6].GetUInt8()); - itemTemplate.Flags = uint32(fields[7].GetUInt32()); + itemTemplate.Flags = fields[7].GetUInt32(); itemTemplate.Flags2 = fields[8].GetUInt32(); itemTemplate.BuyCount = uint32(fields[9].GetUInt8()); itemTemplate.BuyPrice = int32(fields[10].GetInt64()); 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; }; |