diff options
author | Trazom62 <none@none> | 2010-02-07 17:43:00 +0100 |
---|---|---|
committer | Trazom62 <none@none> | 2010-02-07 17:43:00 +0100 |
commit | 8c87b682d3e394aa1022d7f4fcfea86d4b47709b (patch) | |
tree | e99eb042ac2d638e34b33572af84493c34e9ee48 /src | |
parent | 34755de77d2d6ca809c6a8c56fce446981cfd249 (diff) |
Fix crash in npc_thassarianAI::JustDied.
Fixes issue #531.
- store GUID instead of pointers to creature that may despawn.
- and some code style updates.
--HG--
branch : trunk
Diffstat (limited to 'src')
-rw-r--r-- | src/scripts/northrend/borean_tundra.cpp | 175 |
1 files changed, 89 insertions, 86 deletions
diff --git a/src/scripts/northrend/borean_tundra.cpp b/src/scripts/northrend/borean_tundra.cpp index 4622877c9fe..0fb147d9d0b 100644 --- a/src/scripts/northrend/borean_tundra.cpp +++ b/src/scripts/northrend/borean_tundra.cpp @@ -207,13 +207,13 @@ struct npc_sinkhole_kill_creditAI : public ScriptedAI { npc_sinkhole_kill_creditAI(Creature* c) : ScriptedAI(c){} - uint32 Phase_Timer; + uint32 uiPhaseTimer; uint8 Phase; uint64 casterGuid; void Reset() { - Phase_Timer = 500; + uiPhaseTimer = 500; Phase = 0; casterGuid = 0; } @@ -238,7 +238,7 @@ struct npc_sinkhole_kill_creditAI : public ScriptedAI if (!Phase) return; - if (Phase_Timer <= diff) + if (uiPhaseTimer <= diff) { switch (Phase) { @@ -247,19 +247,19 @@ struct npc_sinkhole_kill_creditAI : public ScriptedAI DoCast(m_creature, SPELL_SUMMON_CART, true); if (GameObject* cart = m_creature->FindNearestGameObject(188160,3)) cart->SetUInt32Value(GAMEOBJECT_FACTION, 14); - Phase_Timer = 3000; + uiPhaseTimer = 3000; Phase = 2; break; case 2: if (GameObject* cart = m_creature->FindNearestGameObject(188160,3)) cart->UseDoorOrButton(); DoCast(m_creature, SPELL_EXPLODE_CART, true); - Phase_Timer = 3000; + uiPhaseTimer = 3000; Phase = 3; break; case 3: DoCast(m_creature, SPELL_EXPLODE_CART, true); - Phase_Timer = 2000; + uiPhaseTimer = 2000; Phase = 4; case 5: DoCast(m_creature, SPELL_SUMMON_WORM, true); @@ -268,7 +268,7 @@ struct npc_sinkhole_kill_creditAI : public ScriptedAI worm->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); worm->HandleEmoteCommand(EMOTE_ONESHOT_EMERGE); } - Phase_Timer = 1000; + uiPhaseTimer = 1000; Phase = 6; break; case 6: @@ -278,21 +278,21 @@ struct npc_sinkhole_kill_creditAI : public ScriptedAI m_creature->Kill(worm); worm->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); } - Phase_Timer = 2000; + uiPhaseTimer = 2000; Phase = 7; break; case 7: DoCast(m_creature, SPELL_EXPLODE_CART, true); if(Player *caster = Unit::GetPlayer(casterGuid)) caster->KilledMonster(m_creature->GetCreatureInfo(),m_creature->GetGUID()); - Phase_Timer = 5000; + uiPhaseTimer = 5000; Phase = 8; break; case 8: EnterEvadeMode(); break; } - } else Phase_Timer -= diff; + } else uiPhaseTimer -= diff; } @@ -655,12 +655,12 @@ struct npc_nesingwary_trapperAI : public ScriptedAI GameObject *go_caribou; uint8 Phase; - uint32 Phase_Timer; + uint32 uiPhaseTimer; void Reset() { m_creature->SetVisibility(VISIBILITY_OFF); - Phase_Timer = 2500; + uiPhaseTimer = 2500; Phase = 1; go_caribou = NULL; } @@ -684,41 +684,41 @@ struct npc_nesingwary_trapperAI : public ScriptedAI void UpdateAI(const uint32 diff) { - if (Phase_Timer <= diff) + if (uiPhaseTimer <= diff) { switch (Phase) { case 1: m_creature->SetVisibility(VISIBILITY_ON); - Phase_Timer = 2000; + uiPhaseTimer = 2000; Phase = 2; break; case 2: if (GameObject *go_fur = m_creature->FindNearestGameObject(GO_HIGH_QUALITY_FUR, 11.0f)) m_creature->GetMotionMaster()->MovePoint(0, go_fur->GetPositionX(), go_fur->GetPositionY(), go_fur->GetPositionZ()); - Phase_Timer = 1500; + uiPhaseTimer = 1500; Phase = 3; break; case 3: //DoScriptText(SAY_NESINGWARY_1, m_creature); - Phase_Timer = 2000; + uiPhaseTimer = 2000; Phase = 4; break; case 4: m_creature->HandleEmoteCommand(EMOTE_ONESHOT_LOOT); - Phase_Timer = 1000; + uiPhaseTimer = 1000; Phase = 5; break; case 5: m_creature->HandleEmoteCommand(EMOTE_ONESHOT_NONE); - Phase_Timer = 500; + uiPhaseTimer = 500; Phase = 6; break; case 6: if (GameObject *go_fur = m_creature->FindNearestGameObject(GO_HIGH_QUALITY_FUR, 11.0f)) go_fur->Delete(); - Phase_Timer = 500; + uiPhaseTimer = 500; Phase = 7; break; @@ -740,14 +740,14 @@ struct npc_nesingwary_trapperAI : public ScriptedAI (go_caribou = m_creature->FindNearestGameObject(GO_CARIBOU_TRAP_15, 5.0f))) go_caribou->SetGoState(GO_STATE_ACTIVE); Phase = 8; - Phase_Timer = 1000; + uiPhaseTimer = 1000; break; case 8: DoCast(m_creature, SPELL_TRAPPED, true); Phase = 0; break; } - } else Phase_Timer -= diff; + } else uiPhaseTimer -= diff; } }; @@ -918,7 +918,7 @@ struct npc_nexus_drake_hatchlingAI : public FollowerAI //The spell who makes the { npc_nexus_drake_hatchlingAI(Creature *c) : FollowerAI(c) { - pHarpooner = NULL; + pHarpooner = NULL; } Player *pHarpooner; @@ -932,7 +932,7 @@ struct npc_nexus_drake_hatchlingAI : public FollowerAI //The spell who makes the void EnterCombat(Unit* pWho) { if (m_creature->canAttack(pWho)) - m_creature->AI()->AttackStart(pWho); + AttackStart(pWho); } void SpellHit(Unit *caster, const SpellEntry *spell) @@ -969,11 +969,8 @@ struct npc_nexus_drake_hatchlingAI : public FollowerAI //The spell who makes the { if (WithRedDragonBlood && pHarpooner && pHarpooner->IsInWorld() && !m_creature->HasAura(SPELL_RED_DRAGONBLOOD)) { - if (npc_nexus_drake_hatchlingAI* pDrakeAI = CAST_AI(npc_nexus_drake_hatchlingAI, m_creature->AI())) - { - EnterEvadeMode(); - pDrakeAI->StartFollow(pHarpooner, 35, NULL); - } + EnterEvadeMode(); + StartFollow(pHarpooner, 35, NULL); DoCast(m_creature, SPELL_SUBDUED, true); pHarpooner->CastSpell(pHarpooner, SPELL_DRAKE_HATCHLING_SUBDUED, true); @@ -1040,17 +1037,12 @@ struct npc_thassarianAI : public npc_escortAI { npc_thassarianAI(Creature* pCreature) : npc_escortAI(pCreature) { - pArthas = NULL; - pTalbot = NULL; - pLeryssa = NULL; - pArlos = NULL; - pCreature->RemoveStandFlags(UNIT_STAND_STATE_SIT); } - Creature* pArthas; - Creature* pTalbot; - Creature* pLeryssa; - Creature* pArlos; + uint64 uiArthas; + uint64 uiTalbot; + uint64 uiLeryssa; + uint64 uiArlos; bool bArthasInPosition; bool bArlosInPosition; @@ -1058,20 +1050,25 @@ struct npc_thassarianAI : public npc_escortAI bool bTalbotInPosition; uint32 uiPhase; - uint32 uiPhase_Timer; + uint32 uiPhaseTimer; void Reset() { m_creature->RestoreFaction(); m_creature->RemoveStandFlags(UNIT_STAND_STATE_SIT); + uiArthas = 0; + uiTalbot = 0; + uiLeryssa = 0; + uiArlos = 0; + bArthasInPosition = false; bArlosInPosition = false; bLeryssaInPosition = false; bTalbotInPosition = false; uiPhase = 0; - uiPhase_Timer = 0; + uiPhaseTimer = 0; } void WaypointReached(uint32 uiPointId) @@ -1085,15 +1082,17 @@ struct npc_thassarianAI : public npc_escortAI { case 3: SetEscortPaused(true); - if (pArthas = m_creature->SummonCreature(NPC_IMAGE_LICH_KING, 3730.313, 3518.689, 473.324, 1.562, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 120000)) + if (Creature *pArthas = m_creature->SummonCreature(NPC_IMAGE_LICH_KING, 3730.313, 3518.689, 473.324, 1.562, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 120000)) { + uiArthas = pArthas->GetGUID(); pArthas->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); pArthas->SetReactState(REACT_PASSIVE); pArthas->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); pArthas->GetMotionMaster()->MovePoint(0, 3737.374756,3564.841309,477.433014); } - if (pTalbot = m_creature->SummonCreature(NPC_COUNSELOR_TALBOT, 3747.23, 3614.936, 473.321, 4.462012, TEMPSUMMON_CORPSE_TIMED_DESPAWN,120000)) + if (Creature *pTalbot = m_creature->SummonCreature(NPC_COUNSELOR_TALBOT, 3747.23, 3614.936, 473.321, 4.462012, TEMPSUMMON_CORPSE_TIMED_DESPAWN,120000)) { + uiTalbot = pTalbot->GetGUID(); pTalbot->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); pTalbot->GetMotionMaster()->MovePoint(0, 3738.000977,3568.882080,477.433014); } @@ -1126,14 +1125,16 @@ struct npc_thassarianAI : public npc_escortAI SetEscortPaused(false); } - if (uiPhase_Timer <= uiDiff) + if (uiPhaseTimer <= uiDiff) { + Creature* pTalbot = m_creature->GetCreature(*m_creature, uiTalbot); + Creature* pArthas = m_creature->GetCreature(*m_creature, uiArthas); switch (uiPhase) { case 1: if (pTalbot) pTalbot->SetStandState(UNIT_STAND_STATE_KNEEL); - uiPhase_Timer = 3000; + uiPhaseTimer = 3000; ++uiPhase; break; @@ -1145,51 +1146,53 @@ struct npc_thassarianAI : public npc_escortAI pTalbot->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); pTalbot->SetReactState(REACT_PASSIVE); } - uiPhase_Timer = 5000; + uiPhaseTimer = 5000; ++uiPhase; break; case 3: if (pTalbot) DoScriptText(SAY_TALBOT_1, pTalbot); - uiPhase_Timer = 5000; + uiPhaseTimer = 5000; ++uiPhase; break; case 4: if (pArthas) DoScriptText(SAY_LICH_1, pArthas); - uiPhase_Timer = 5000; + uiPhaseTimer = 5000; ++uiPhase; break; case 5: if (pTalbot) DoScriptText(SAY_TALBOT_2, pTalbot); - uiPhase_Timer = 5000; + uiPhaseTimer = 5000; ++uiPhase; break; case 6: - if (pArlos = m_creature->SummonCreature(NPC_GENERAL_ARLOS, 3745.527100, 3615.655029, 473.321533, 4.447805, TEMPSUMMON_CORPSE_TIMED_DESPAWN,120000)) + if (Creature* pArlos = m_creature->SummonCreature(NPC_GENERAL_ARLOS, 3745.527100, 3615.655029, 473.321533, 4.447805, TEMPSUMMON_CORPSE_TIMED_DESPAWN,120000)) { + uiArlos = pArlos->GetGUID(); pArlos->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); pArlos->GetMotionMaster()->MovePoint(0, 3735.570068, 3572.419922, 477.441010); } - if (pLeryssa = m_creature->SummonCreature(NPC_LERYSSA, 3749.654541, 3614.959717, 473.323486, 4.524959, TEMPSUMMON_CORPSE_TIMED_DESPAWN,120000)) + if (Creature *pLeryssa = m_creature->SummonCreature(NPC_LERYSSA, 3749.654541, 3614.959717, 473.323486, 4.524959, TEMPSUMMON_CORPSE_TIMED_DESPAWN,120000)) { + uiLeryssa = pLeryssa->GetGUID(); pLeryssa->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); pLeryssa->SetReactState(REACT_PASSIVE); pLeryssa->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); pLeryssa->GetMotionMaster()->MovePoint(0, 3741.969971, 3571.439941, 477.441010); } - uiPhase_Timer = 2000; + uiPhaseTimer = 2000; uiPhase = 0; break; case 7: DoScriptText(SAY_THASSARIAN_2, m_creature); - uiPhase_Timer = 5000; + uiPhaseTimer = 5000; ++uiPhase; break; @@ -1200,34 +1203,34 @@ struct npc_thassarianAI : public npc_escortAI pTalbot->SetStandState(UNIT_STAND_STATE_STAND); DoScriptText(SAY_LICH_2, pArthas); } - uiPhase_Timer = 5000; + uiPhaseTimer = 5000; uiPhase = 9; break; case 9: DoScriptText(SAY_THASSARIAN_3, m_creature); - uiPhase_Timer = 5000; + uiPhaseTimer = 5000; uiPhase = 10; break; case 10: if (pTalbot) DoScriptText(SAY_TALBOT_3, pTalbot); - uiPhase_Timer = 5000; + uiPhaseTimer = 5000; uiPhase = 11; break; case 11: if (pArthas) DoScriptText(SAY_LICH_3, pArthas); - uiPhase_Timer = 5000; + uiPhaseTimer = 5000; uiPhase = 12; break; case 12: if (pTalbot) DoScriptText(SAY_TALBOT_4, pTalbot); - uiPhase_Timer = 2000; + uiPhaseTimer = 2000; uiPhase = 13; break; @@ -1245,35 +1248,35 @@ struct npc_thassarianAI : public npc_escortAI pTalbot->SetReactState(REACT_AGGRESSIVE); pTalbot->CastSpell(m_creature, SPELL_SHADOW_BOLT, false); } - uiPhase_Timer = 1500; + uiPhaseTimer = 1500; ++uiPhase; break; case 15: m_creature->SetReactState(REACT_AGGRESSIVE); - m_creature->AI()->AttackStart(pTalbot); + AttackStart(pTalbot); uiPhase = 0; break; case 16: m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); - uiPhase_Timer = 20000; + uiPhaseTimer = 20000; ++uiPhase; break; case 17: - if (pLeryssa) + if (Creature* pLeryssa = m_creature->GetCreature(*m_creature, uiLeryssa)) pLeryssa->RemoveFromWorld(); - if (pArlos) + if (Creature* pArlos= m_creature->GetCreature(*m_creature, uiArlos)) pArlos->RemoveFromWorld(); if (pTalbot) pTalbot->RemoveFromWorld(); m_creature->RemoveStandFlags(UNIT_STAND_STATE_SIT); SetEscortPaused(false); - uiPhase_Timer = 0; + uiPhaseTimer = 0; uiPhase = 0; } - } else uiPhase_Timer -= uiDiff; + } else uiPhaseTimer -= uiDiff; if (!UpdateVictim()) return; @@ -1283,13 +1286,16 @@ struct npc_thassarianAI : public npc_escortAI void JustDied(Unit* pKiller) { - if (pTalbot) + if (Creature* pTalbot = m_creature->GetCreature(*m_creature, uiTalbot)) pTalbot->RemoveFromWorld(); - if (pLeryssa) + + if (Creature* pLeryssa = m_creature->GetCreature(*m_creature, uiLeryssa)) pLeryssa->RemoveFromWorld(); - if (pArlos) + + if (Creature* pArlos = m_creature->GetCreature(*m_creature, uiArlos)) pArlos->RemoveFromWorld(); - if (pArthas) + + if (Creature* pArthas = m_creature->GetCreature(*m_creature, uiArthas)) pArthas->RemoveFromWorld(); } }; @@ -1376,14 +1382,14 @@ struct npc_general_arlosAI : public ScriptedAI CreatureAI* GetAI_npc_general_arlos(Creature *pCreature) { - return new npc_general_arlosAI (pCreature); + return new npc_general_arlosAI(pCreature); } /*###### ## npc_counselor_talbot ######*/ -enum eCounselotTalbot +enum eCounselorTalbot { SPELL_DEFLECTION = 51009, SPELL_SOUL_BLAST = 50992, @@ -1455,8 +1461,6 @@ struct npc_counselor_talbotAI : public ScriptedAI DoCast(m_creature->getVictim(), SPELL_SOUL_BLAST); uiSoulBlastTimer = urand (12000,18000); } else uiSoulBlastTimer -= uiDiff; - - DoMeleeAttackIfReady(); } DoMeleeAttackIfReady(); @@ -1496,7 +1500,7 @@ struct npc_leryssaAI : public ScriptedAI { bDone = false; Phase = 0; - Phase_Timer = 0; + uiPhaseTimer = 0; pCreature->RemoveStandFlags(UNIT_STAND_STATE_SIT); } @@ -1504,7 +1508,7 @@ struct npc_leryssaAI : public ScriptedAI bool bDone; uint32 Phase; - uint32 Phase_Timer; + uint32 uiPhaseTimer; void MovementInform(uint32 uiType, uint32 uiId) { @@ -1530,7 +1534,7 @@ struct npc_leryssaAI : public ScriptedAI if (m_creature->isSummon()) if (Unit* pSummoner = CAST_SUM(m_creature)->GetSummoner()) pSummoner->SetStandState(UNIT_STAND_STATE_SIT); - Phase_Timer = 1500; + uiPhaseTimer = 1500; Phase = 1; } } @@ -1539,7 +1543,7 @@ struct npc_leryssaAI : public ScriptedAI { ScriptedAI::UpdateAI(uiDiff); - if (Phase_Timer <= uiDiff) + if (uiPhaseTimer <= uiDiff) { switch (Phase) { @@ -1547,37 +1551,37 @@ struct npc_leryssaAI : public ScriptedAI if (m_creature->isSummon()) if (Unit* pThassarian = CAST_SUM(m_creature)->GetSummoner()) DoScriptText(SAY_THASSARIAN_4, pThassarian); - Phase_Timer = 5000; + uiPhaseTimer = 5000; ++Phase; break; case 2: DoScriptText(SAY_LERYSSA_2, m_creature); - Phase_Timer = 5000; + uiPhaseTimer = 5000; ++Phase; break; case 3: if (m_creature->isSummon()) if (Unit* pThassarian = CAST_SUM(m_creature)->GetSummoner()) DoScriptText(SAY_THASSARIAN_5, pThassarian); - Phase_Timer = 5000; + uiPhaseTimer = 5000; ++Phase; break; case 4: DoScriptText(SAY_LERYSSA_3, m_creature); - Phase_Timer = 5000; + uiPhaseTimer = 5000; ++Phase; break; case 5: if (m_creature->isSummon()) if (Unit* pThassarian = CAST_SUM(m_creature)->GetSummoner()) DoScriptText(SAY_THASSARIAN_6, pThassarian); - Phase_Timer = 5000; + uiPhaseTimer = 5000; ++Phase; break; case 6: DoScriptText(SAY_LERYSSA_4, m_creature); - Phase_Timer = 5000; + uiPhaseTimer = 5000; ++Phase; break; case 7: @@ -1587,11 +1591,11 @@ struct npc_leryssaAI : public ScriptedAI DoScriptText(SAY_THASSARIAN_7, pThassarian); CAST_AI(npc_thassarianAI,CAST_CRE(pThassarian)->AI())->uiPhase = 16; } - Phase_Timer = 5000; + uiPhaseTimer = 5000; Phase = 0; break; } - } else Phase_Timer -= uiDiff; + } else uiPhaseTimer -= uiDiff; if (!UpdateVictim()) return; @@ -1634,7 +1638,7 @@ struct npc_beryl_sorcererAI : public FollowerAI void EnterCombat(Unit* pWho) { if (m_creature->canAttack(pWho)) - m_creature->AI()->AttackStart(pWho); + AttackStart(pWho); } void SpellHit(Unit* pCaster, const SpellEntry* pSpell) @@ -1643,8 +1647,7 @@ struct npc_beryl_sorcererAI : public FollowerAI { EnterEvadeMode(); //We make sure that the npc is not attacking the player! m_creature->SetReactState(REACT_PASSIVE); - if (npc_beryl_sorcererAI* pBerylAI = CAST_AI(npc_beryl_sorcererAI, m_creature->AI())) - pBerylAI->StartFollow(CAST_PLR(pCaster), NULL, NULL); + StartFollow(CAST_PLR(pCaster), NULL, NULL); m_creature->UpdateEntry(NPC_CAPTURED_BERLY_SORCERER, TEAM_NEUTRAL); DoCast(m_creature, SPELL_COSMETIC_ENSLAVE_CHAINS_SELF, true); CAST_PLR(pCaster)->KilledMonsterCredit(NPC_CAPTURED_BERLY_SORCERER, 0); |