Core/Scripts: Fixed possible crashes in instance scripts (Icecrown Citadel and Naxxramas)

Scripts/Sunwell Plateau: Fixed crash in Kil'jaeden
Scripts/Icecrown Citadel: Fixed crash in Blood-Queen Lana'thel

Closes issue #5051.
Closes issue #5050.
Closes issue #5035.

--HG--
branch : trunk
This commit is contained in:
Shauren
2010-12-08 17:24:31 +01:00
parent 611dc153b0
commit e4e048ed57
4 changed files with 74 additions and 22 deletions
@@ -724,8 +724,9 @@ public:
if (Speeches[speechCount].timer < SpeechTimer)
{
SpeechTimer = 0;
if (Creature* pSpeechCreature = Unit::GetCreature(*me, pInstance->GetData64(Speeches[speechCount].pCreature)))
DoScriptText(Speeches[speechCount].textid, pSpeechCreature);
if (pInstance)
if (Creature* pSpeechCreature = Unit::GetCreature(*me, pInstance->GetData64(Speeches[speechCount].pCreature)))
DoScriptText(Speeches[speechCount].textid, pSpeechCreature);
if (speechCount == 12)
if (Creature* pAnveena = Unit::GetCreature(*me, pInstance->GetData64(DATA_ANVEENA)))
pAnveena->CastSpell(me, SPELL_SACRIFICE_OF_ANVEENA, false);
@@ -826,18 +827,19 @@ public:
}
break;
case TIMER_ORBS_EMPOWER: //Phase 3
if (Creature* pKalec = Unit::GetCreature(*me, pInstance->GetData64(DATA_KALECGOS_KJ)))
{
switch (Phase)
if (pInstance)
if (Creature* pKalec = Unit::GetCreature(*me, pInstance->GetData64(DATA_KALECGOS_KJ)))
{
switch (Phase)
{
case PHASE_SACRIFICE:
CAST_AI(boss_kalecgos_kj::boss_kalecgos_kjAI, pKalec->AI())->EmpowerOrb(true);
break;
default:
CAST_AI(boss_kalecgos_kj::boss_kalecgos_kjAI, pKalec->AI())->EmpowerOrb(false);
break;
}
}
}
OrbActivated = true;
TimerIsDeactivated[TIMER_ORBS_EMPOWER] = true;
break;
@@ -307,6 +307,7 @@ class boss_blood_queen_lana_thel : public CreatureScript
std::list<Player*> targets;
SelectRandomTarget(false, &targets);
uint32 targetCount = 2;
// do not combine these checks! we want it incremented TWICE when both conditions are met
if (IsHeroic())
++targetCount;
if (Is25ManRaid())
@@ -401,7 +402,7 @@ class boss_blood_queen_lana_thel : public CreatureScript
}
std::list<Player*>::iterator itr = tempTargets.begin();
std::advance(itr, urand(1, tempTargets.size()-1));
std::advance(itr, urand(0, tempTargets.size()-1));
return *itr;
}
@@ -255,6 +255,34 @@ class instance_icecrown_citadel : public InstanceMapScript
}
}
void OnGameObjectRemove(GameObject* go)
{
switch (go->GetEntry())
{
case GO_DOODAD_ICECROWN_ICEWALL02:
case GO_ICEWALL:
case GO_LORD_MARROWGAR_S_ENTRANCE:
case GO_ORATORY_OF_THE_DAMNED_ENTRANCE:
case GO_ORANGE_PLAGUE_MONSTER_ENTRANCE:
case GO_GREEN_PLAGUE_MONSTER_ENTRANCE:
case GO_SCIENTIST_ENTRANCE:
case GO_CRIMSON_HALL_DOOR:
case GO_BLOOD_ELF_COUNCIL_DOOR:
case GO_BLOOD_ELF_COUNCIL_DOOR_RIGHT:
case GO_DOODAD_ICECROWN_BLOODPRINCE_DOOR_01:
case GO_DOODAD_ICECROWN_GRATE_01:
case GO_GREEN_DRAGON_BOSS_ENTRANCE:
case GO_GREEN_DRAGON_BOSS_EXIT:
case GO_SINDRAGOSA_ENTRANCE_DOOR:
case GO_SINDRAGOSA_SHORTCUT_ENTRANCE_DOOR:
case GO_SINDRAGOSA_SHORTCUT_EXIT_DOOR:
AddDoor(go, false);
break;
default:
break;
}
}
uint64 GetData64(uint32 type)
{
switch (type)
@@ -173,19 +173,35 @@ public:
return;
}
switch(go->GetEntry())
switch (go->GetEntry())
{
case GO_GOTHIK_GATE:
GothikGateGUID = go->GetGUID();
go->SetGoState(gothikDoorState);
break;
case GO_HORSEMEN_CHEST: HorsemenChestGUID = go->GetGUID(); break;
case GO_HORSEMEN_CHEST_HERO: HorsemenChestGUID = go->GetGUID(); break;
case GO_KELTHUZAD_PORTAL01: uiPortals[0] = go->GetGUID(); break;
case GO_KELTHUZAD_PORTAL02: uiPortals[1] = go->GetGUID(); break;
case GO_KELTHUZAD_PORTAL03: uiPortals[2] = go->GetGUID(); break;
case GO_KELTHUZAD_PORTAL04: uiPortals[3] = go->GetGUID(); break;
case GO_KELTHUZAD_TRIGGER: uiKelthuzadTrigger = go->GetGUID(); break;
case GO_HORSEMEN_CHEST:
HorsemenChestGUID = go->GetGUID();
break;
case GO_HORSEMEN_CHEST_HERO:
HorsemenChestGUID = go->GetGUID();
break;
case GO_KELTHUZAD_PORTAL01:
uiPortals[0] = go->GetGUID();
break;
case GO_KELTHUZAD_PORTAL02:
uiPortals[1] = go->GetGUID();
break;
case GO_KELTHUZAD_PORTAL03:
uiPortals[2] = go->GetGUID();
break;
case GO_KELTHUZAD_PORTAL04:
uiPortals[3] = go->GetGUID();
break;
case GO_KELTHUZAD_TRIGGER:
uiKelthuzadTrigger = go->GetGUID();
break;
default:
break;
}
AddDoor(go, true);
@@ -201,16 +217,21 @@ public:
return;
}
switch(go->GetEntry())
switch (go->GetEntry())
{
case GO_BIRTH:
if (SapphironGUID)
{
if (Creature* pSapphiron = instance->GetCreature(SapphironGUID))
pSapphiron->AI()->DoAction(DATA_SAPPHIRON_BIRTH);
return;
}
if (SapphironGUID)
{
if (Creature* pSapphiron = instance->GetCreature(SapphironGUID))
pSapphiron->AI()->DoAction(DATA_SAPPHIRON_BIRTH);
return;
}
break;
default:
break;
}
AddDoor(go, false);
}
void SetData(uint32 id, uint32 value)