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
This commit is contained in:
Trazom62
2010-02-07 17:43:00 +01:00
parent 34755de77d
commit 8c87b682d3
+89 -86
View File
@@ -207,13 +207,13 @@ struct npc_sinkhole_kill_creditAI : public ScriptedAI
{ {
npc_sinkhole_kill_creditAI(Creature* c) : ScriptedAI(c){} npc_sinkhole_kill_creditAI(Creature* c) : ScriptedAI(c){}
uint32 Phase_Timer; uint32 uiPhaseTimer;
uint8 Phase; uint8 Phase;
uint64 casterGuid; uint64 casterGuid;
void Reset() void Reset()
{ {
Phase_Timer = 500; uiPhaseTimer = 500;
Phase = 0; Phase = 0;
casterGuid = 0; casterGuid = 0;
} }
@@ -238,7 +238,7 @@ struct npc_sinkhole_kill_creditAI : public ScriptedAI
if (!Phase) if (!Phase)
return; return;
if (Phase_Timer <= diff) if (uiPhaseTimer <= diff)
{ {
switch (Phase) switch (Phase)
{ {
@@ -247,19 +247,19 @@ struct npc_sinkhole_kill_creditAI : public ScriptedAI
DoCast(m_creature, SPELL_SUMMON_CART, true); DoCast(m_creature, SPELL_SUMMON_CART, true);
if (GameObject* cart = m_creature->FindNearestGameObject(188160,3)) if (GameObject* cart = m_creature->FindNearestGameObject(188160,3))
cart->SetUInt32Value(GAMEOBJECT_FACTION, 14); cart->SetUInt32Value(GAMEOBJECT_FACTION, 14);
Phase_Timer = 3000; uiPhaseTimer = 3000;
Phase = 2; Phase = 2;
break; break;
case 2: case 2:
if (GameObject* cart = m_creature->FindNearestGameObject(188160,3)) if (GameObject* cart = m_creature->FindNearestGameObject(188160,3))
cart->UseDoorOrButton(); cart->UseDoorOrButton();
DoCast(m_creature, SPELL_EXPLODE_CART, true); DoCast(m_creature, SPELL_EXPLODE_CART, true);
Phase_Timer = 3000; uiPhaseTimer = 3000;
Phase = 3; Phase = 3;
break; break;
case 3: case 3:
DoCast(m_creature, SPELL_EXPLODE_CART, true); DoCast(m_creature, SPELL_EXPLODE_CART, true);
Phase_Timer = 2000; uiPhaseTimer = 2000;
Phase = 4; Phase = 4;
case 5: case 5:
DoCast(m_creature, SPELL_SUMMON_WORM, true); 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->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
worm->HandleEmoteCommand(EMOTE_ONESHOT_EMERGE); worm->HandleEmoteCommand(EMOTE_ONESHOT_EMERGE);
} }
Phase_Timer = 1000; uiPhaseTimer = 1000;
Phase = 6; Phase = 6;
break; break;
case 6: case 6:
@@ -278,21 +278,21 @@ struct npc_sinkhole_kill_creditAI : public ScriptedAI
m_creature->Kill(worm); m_creature->Kill(worm);
worm->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); worm->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
} }
Phase_Timer = 2000; uiPhaseTimer = 2000;
Phase = 7; Phase = 7;
break; break;
case 7: case 7:
DoCast(m_creature, SPELL_EXPLODE_CART, true); DoCast(m_creature, SPELL_EXPLODE_CART, true);
if(Player *caster = Unit::GetPlayer(casterGuid)) if(Player *caster = Unit::GetPlayer(casterGuid))
caster->KilledMonster(m_creature->GetCreatureInfo(),m_creature->GetGUID()); caster->KilledMonster(m_creature->GetCreatureInfo(),m_creature->GetGUID());
Phase_Timer = 5000; uiPhaseTimer = 5000;
Phase = 8; Phase = 8;
break; break;
case 8: case 8:
EnterEvadeMode(); EnterEvadeMode();
break; break;
} }
} else Phase_Timer -= diff; } else uiPhaseTimer -= diff;
} }
@@ -655,12 +655,12 @@ struct npc_nesingwary_trapperAI : public ScriptedAI
GameObject *go_caribou; GameObject *go_caribou;
uint8 Phase; uint8 Phase;
uint32 Phase_Timer; uint32 uiPhaseTimer;
void Reset() void Reset()
{ {
m_creature->SetVisibility(VISIBILITY_OFF); m_creature->SetVisibility(VISIBILITY_OFF);
Phase_Timer = 2500; uiPhaseTimer = 2500;
Phase = 1; Phase = 1;
go_caribou = NULL; go_caribou = NULL;
} }
@@ -684,41 +684,41 @@ struct npc_nesingwary_trapperAI : public ScriptedAI
void UpdateAI(const uint32 diff) void UpdateAI(const uint32 diff)
{ {
if (Phase_Timer <= diff) if (uiPhaseTimer <= diff)
{ {
switch (Phase) switch (Phase)
{ {
case 1: case 1:
m_creature->SetVisibility(VISIBILITY_ON); m_creature->SetVisibility(VISIBILITY_ON);
Phase_Timer = 2000; uiPhaseTimer = 2000;
Phase = 2; Phase = 2;
break; break;
case 2: case 2:
if (GameObject *go_fur = m_creature->FindNearestGameObject(GO_HIGH_QUALITY_FUR, 11.0f)) 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()); m_creature->GetMotionMaster()->MovePoint(0, go_fur->GetPositionX(), go_fur->GetPositionY(), go_fur->GetPositionZ());
Phase_Timer = 1500; uiPhaseTimer = 1500;
Phase = 3; Phase = 3;
break; break;
case 3: case 3:
//DoScriptText(SAY_NESINGWARY_1, m_creature); //DoScriptText(SAY_NESINGWARY_1, m_creature);
Phase_Timer = 2000; uiPhaseTimer = 2000;
Phase = 4; Phase = 4;
break; break;
case 4: case 4:
m_creature->HandleEmoteCommand(EMOTE_ONESHOT_LOOT); m_creature->HandleEmoteCommand(EMOTE_ONESHOT_LOOT);
Phase_Timer = 1000; uiPhaseTimer = 1000;
Phase = 5; Phase = 5;
break; break;
case 5: case 5:
m_creature->HandleEmoteCommand(EMOTE_ONESHOT_NONE); m_creature->HandleEmoteCommand(EMOTE_ONESHOT_NONE);
Phase_Timer = 500; uiPhaseTimer = 500;
Phase = 6; Phase = 6;
break; break;
case 6: case 6:
if (GameObject *go_fur = m_creature->FindNearestGameObject(GO_HIGH_QUALITY_FUR, 11.0f)) if (GameObject *go_fur = m_creature->FindNearestGameObject(GO_HIGH_QUALITY_FUR, 11.0f))
go_fur->Delete(); go_fur->Delete();
Phase_Timer = 500; uiPhaseTimer = 500;
Phase = 7; Phase = 7;
break; break;
@@ -740,14 +740,14 @@ struct npc_nesingwary_trapperAI : public ScriptedAI
(go_caribou = m_creature->FindNearestGameObject(GO_CARIBOU_TRAP_15, 5.0f))) (go_caribou = m_creature->FindNearestGameObject(GO_CARIBOU_TRAP_15, 5.0f)))
go_caribou->SetGoState(GO_STATE_ACTIVE); go_caribou->SetGoState(GO_STATE_ACTIVE);
Phase = 8; Phase = 8;
Phase_Timer = 1000; uiPhaseTimer = 1000;
break; break;
case 8: case 8:
DoCast(m_creature, SPELL_TRAPPED, true); DoCast(m_creature, SPELL_TRAPPED, true);
Phase = 0; Phase = 0;
break; 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) npc_nexus_drake_hatchlingAI(Creature *c) : FollowerAI(c)
{ {
pHarpooner = NULL; pHarpooner = NULL;
} }
Player *pHarpooner; Player *pHarpooner;
@@ -932,7 +932,7 @@ struct npc_nexus_drake_hatchlingAI : public FollowerAI //The spell who makes the
void EnterCombat(Unit* pWho) void EnterCombat(Unit* pWho)
{ {
if (m_creature->canAttack(pWho)) if (m_creature->canAttack(pWho))
m_creature->AI()->AttackStart(pWho); AttackStart(pWho);
} }
void SpellHit(Unit *caster, const SpellEntry *spell) 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 (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();
{ StartFollow(pHarpooner, 35, NULL);
EnterEvadeMode();
pDrakeAI->StartFollow(pHarpooner, 35, NULL);
}
DoCast(m_creature, SPELL_SUBDUED, true); DoCast(m_creature, SPELL_SUBDUED, true);
pHarpooner->CastSpell(pHarpooner, SPELL_DRAKE_HATCHLING_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) npc_thassarianAI(Creature* pCreature) : npc_escortAI(pCreature)
{ {
pArthas = NULL;
pTalbot = NULL;
pLeryssa = NULL;
pArlos = NULL;
pCreature->RemoveStandFlags(UNIT_STAND_STATE_SIT);
} }
Creature* pArthas; uint64 uiArthas;
Creature* pTalbot; uint64 uiTalbot;
Creature* pLeryssa; uint64 uiLeryssa;
Creature* pArlos; uint64 uiArlos;
bool bArthasInPosition; bool bArthasInPosition;
bool bArlosInPosition; bool bArlosInPosition;
@@ -1058,20 +1050,25 @@ struct npc_thassarianAI : public npc_escortAI
bool bTalbotInPosition; bool bTalbotInPosition;
uint32 uiPhase; uint32 uiPhase;
uint32 uiPhase_Timer; uint32 uiPhaseTimer;
void Reset() void Reset()
{ {
m_creature->RestoreFaction(); m_creature->RestoreFaction();
m_creature->RemoveStandFlags(UNIT_STAND_STATE_SIT); m_creature->RemoveStandFlags(UNIT_STAND_STATE_SIT);
uiArthas = 0;
uiTalbot = 0;
uiLeryssa = 0;
uiArlos = 0;
bArthasInPosition = false; bArthasInPosition = false;
bArlosInPosition = false; bArlosInPosition = false;
bLeryssaInPosition = false; bLeryssaInPosition = false;
bTalbotInPosition = false; bTalbotInPosition = false;
uiPhase = 0; uiPhase = 0;
uiPhase_Timer = 0; uiPhaseTimer = 0;
} }
void WaypointReached(uint32 uiPointId) void WaypointReached(uint32 uiPointId)
@@ -1085,15 +1082,17 @@ struct npc_thassarianAI : public npc_escortAI
{ {
case 3: case 3:
SetEscortPaused(true); 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->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
pArthas->SetReactState(REACT_PASSIVE); pArthas->SetReactState(REACT_PASSIVE);
pArthas->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); pArthas->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
pArthas->GetMotionMaster()->MovePoint(0, 3737.374756,3564.841309,477.433014); 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->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
pTalbot->GetMotionMaster()->MovePoint(0, 3738.000977,3568.882080,477.433014); pTalbot->GetMotionMaster()->MovePoint(0, 3738.000977,3568.882080,477.433014);
} }
@@ -1126,14 +1125,16 @@ struct npc_thassarianAI : public npc_escortAI
SetEscortPaused(false); 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) switch (uiPhase)
{ {
case 1: case 1:
if (pTalbot) if (pTalbot)
pTalbot->SetStandState(UNIT_STAND_STATE_KNEEL); pTalbot->SetStandState(UNIT_STAND_STATE_KNEEL);
uiPhase_Timer = 3000; uiPhaseTimer = 3000;
++uiPhase; ++uiPhase;
break; break;
@@ -1145,51 +1146,53 @@ struct npc_thassarianAI : public npc_escortAI
pTalbot->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); pTalbot->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
pTalbot->SetReactState(REACT_PASSIVE); pTalbot->SetReactState(REACT_PASSIVE);
} }
uiPhase_Timer = 5000; uiPhaseTimer = 5000;
++uiPhase; ++uiPhase;
break; break;
case 3: case 3:
if (pTalbot) if (pTalbot)
DoScriptText(SAY_TALBOT_1, pTalbot); DoScriptText(SAY_TALBOT_1, pTalbot);
uiPhase_Timer = 5000; uiPhaseTimer = 5000;
++uiPhase; ++uiPhase;
break; break;
case 4: case 4:
if (pArthas) if (pArthas)
DoScriptText(SAY_LICH_1, pArthas); DoScriptText(SAY_LICH_1, pArthas);
uiPhase_Timer = 5000; uiPhaseTimer = 5000;
++uiPhase; ++uiPhase;
break; break;
case 5: case 5:
if (pTalbot) if (pTalbot)
DoScriptText(SAY_TALBOT_2, pTalbot); DoScriptText(SAY_TALBOT_2, pTalbot);
uiPhase_Timer = 5000; uiPhaseTimer = 5000;
++uiPhase; ++uiPhase;
break; break;
case 6: 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->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
pArlos->GetMotionMaster()->MovePoint(0, 3735.570068, 3572.419922, 477.441010); 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->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
pLeryssa->SetReactState(REACT_PASSIVE); pLeryssa->SetReactState(REACT_PASSIVE);
pLeryssa->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); pLeryssa->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
pLeryssa->GetMotionMaster()->MovePoint(0, 3741.969971, 3571.439941, 477.441010); pLeryssa->GetMotionMaster()->MovePoint(0, 3741.969971, 3571.439941, 477.441010);
} }
uiPhase_Timer = 2000; uiPhaseTimer = 2000;
uiPhase = 0; uiPhase = 0;
break; break;
case 7: case 7:
DoScriptText(SAY_THASSARIAN_2, m_creature); DoScriptText(SAY_THASSARIAN_2, m_creature);
uiPhase_Timer = 5000; uiPhaseTimer = 5000;
++uiPhase; ++uiPhase;
break; break;
@@ -1200,34 +1203,34 @@ struct npc_thassarianAI : public npc_escortAI
pTalbot->SetStandState(UNIT_STAND_STATE_STAND); pTalbot->SetStandState(UNIT_STAND_STATE_STAND);
DoScriptText(SAY_LICH_2, pArthas); DoScriptText(SAY_LICH_2, pArthas);
} }
uiPhase_Timer = 5000; uiPhaseTimer = 5000;
uiPhase = 9; uiPhase = 9;
break; break;
case 9: case 9:
DoScriptText(SAY_THASSARIAN_3, m_creature); DoScriptText(SAY_THASSARIAN_3, m_creature);
uiPhase_Timer = 5000; uiPhaseTimer = 5000;
uiPhase = 10; uiPhase = 10;
break; break;
case 10: case 10:
if (pTalbot) if (pTalbot)
DoScriptText(SAY_TALBOT_3, pTalbot); DoScriptText(SAY_TALBOT_3, pTalbot);
uiPhase_Timer = 5000; uiPhaseTimer = 5000;
uiPhase = 11; uiPhase = 11;
break; break;
case 11: case 11:
if (pArthas) if (pArthas)
DoScriptText(SAY_LICH_3, pArthas); DoScriptText(SAY_LICH_3, pArthas);
uiPhase_Timer = 5000; uiPhaseTimer = 5000;
uiPhase = 12; uiPhase = 12;
break; break;
case 12: case 12:
if (pTalbot) if (pTalbot)
DoScriptText(SAY_TALBOT_4, pTalbot); DoScriptText(SAY_TALBOT_4, pTalbot);
uiPhase_Timer = 2000; uiPhaseTimer = 2000;
uiPhase = 13; uiPhase = 13;
break; break;
@@ -1245,35 +1248,35 @@ struct npc_thassarianAI : public npc_escortAI
pTalbot->SetReactState(REACT_AGGRESSIVE); pTalbot->SetReactState(REACT_AGGRESSIVE);
pTalbot->CastSpell(m_creature, SPELL_SHADOW_BOLT, false); pTalbot->CastSpell(m_creature, SPELL_SHADOW_BOLT, false);
} }
uiPhase_Timer = 1500; uiPhaseTimer = 1500;
++uiPhase; ++uiPhase;
break; break;
case 15: case 15:
m_creature->SetReactState(REACT_AGGRESSIVE); m_creature->SetReactState(REACT_AGGRESSIVE);
m_creature->AI()->AttackStart(pTalbot); AttackStart(pTalbot);
uiPhase = 0; uiPhase = 0;
break; break;
case 16: case 16:
m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER);
uiPhase_Timer = 20000; uiPhaseTimer = 20000;
++uiPhase; ++uiPhase;
break; break;
case 17: case 17:
if (pLeryssa) if (Creature* pLeryssa = m_creature->GetCreature(*m_creature, uiLeryssa))
pLeryssa->RemoveFromWorld(); pLeryssa->RemoveFromWorld();
if (pArlos) if (Creature* pArlos= m_creature->GetCreature(*m_creature, uiArlos))
pArlos->RemoveFromWorld(); pArlos->RemoveFromWorld();
if (pTalbot) if (pTalbot)
pTalbot->RemoveFromWorld(); pTalbot->RemoveFromWorld();
m_creature->RemoveStandFlags(UNIT_STAND_STATE_SIT); m_creature->RemoveStandFlags(UNIT_STAND_STATE_SIT);
SetEscortPaused(false); SetEscortPaused(false);
uiPhase_Timer = 0; uiPhaseTimer = 0;
uiPhase = 0; uiPhase = 0;
} }
} else uiPhase_Timer -= uiDiff; } else uiPhaseTimer -= uiDiff;
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
@@ -1283,13 +1286,16 @@ struct npc_thassarianAI : public npc_escortAI
void JustDied(Unit* pKiller) void JustDied(Unit* pKiller)
{ {
if (pTalbot) if (Creature* pTalbot = m_creature->GetCreature(*m_creature, uiTalbot))
pTalbot->RemoveFromWorld(); pTalbot->RemoveFromWorld();
if (pLeryssa)
if (Creature* pLeryssa = m_creature->GetCreature(*m_creature, uiLeryssa))
pLeryssa->RemoveFromWorld(); pLeryssa->RemoveFromWorld();
if (pArlos)
if (Creature* pArlos = m_creature->GetCreature(*m_creature, uiArlos))
pArlos->RemoveFromWorld(); pArlos->RemoveFromWorld();
if (pArthas)
if (Creature* pArthas = m_creature->GetCreature(*m_creature, uiArthas))
pArthas->RemoveFromWorld(); pArthas->RemoveFromWorld();
} }
}; };
@@ -1376,14 +1382,14 @@ struct npc_general_arlosAI : public ScriptedAI
CreatureAI* GetAI_npc_general_arlos(Creature *pCreature) CreatureAI* GetAI_npc_general_arlos(Creature *pCreature)
{ {
return new npc_general_arlosAI (pCreature); return new npc_general_arlosAI(pCreature);
} }
/*###### /*######
## npc_counselor_talbot ## npc_counselor_talbot
######*/ ######*/
enum eCounselotTalbot enum eCounselorTalbot
{ {
SPELL_DEFLECTION = 51009, SPELL_DEFLECTION = 51009,
SPELL_SOUL_BLAST = 50992, SPELL_SOUL_BLAST = 50992,
@@ -1455,8 +1461,6 @@ struct npc_counselor_talbotAI : public ScriptedAI
DoCast(m_creature->getVictim(), SPELL_SOUL_BLAST); DoCast(m_creature->getVictim(), SPELL_SOUL_BLAST);
uiSoulBlastTimer = urand (12000,18000); uiSoulBlastTimer = urand (12000,18000);
} else uiSoulBlastTimer -= uiDiff; } else uiSoulBlastTimer -= uiDiff;
DoMeleeAttackIfReady();
} }
DoMeleeAttackIfReady(); DoMeleeAttackIfReady();
@@ -1496,7 +1500,7 @@ struct npc_leryssaAI : public ScriptedAI
{ {
bDone = false; bDone = false;
Phase = 0; Phase = 0;
Phase_Timer = 0; uiPhaseTimer = 0;
pCreature->RemoveStandFlags(UNIT_STAND_STATE_SIT); pCreature->RemoveStandFlags(UNIT_STAND_STATE_SIT);
} }
@@ -1504,7 +1508,7 @@ struct npc_leryssaAI : public ScriptedAI
bool bDone; bool bDone;
uint32 Phase; uint32 Phase;
uint32 Phase_Timer; uint32 uiPhaseTimer;
void MovementInform(uint32 uiType, uint32 uiId) void MovementInform(uint32 uiType, uint32 uiId)
{ {
@@ -1530,7 +1534,7 @@ struct npc_leryssaAI : public ScriptedAI
if (m_creature->isSummon()) if (m_creature->isSummon())
if (Unit* pSummoner = CAST_SUM(m_creature)->GetSummoner()) if (Unit* pSummoner = CAST_SUM(m_creature)->GetSummoner())
pSummoner->SetStandState(UNIT_STAND_STATE_SIT); pSummoner->SetStandState(UNIT_STAND_STATE_SIT);
Phase_Timer = 1500; uiPhaseTimer = 1500;
Phase = 1; Phase = 1;
} }
} }
@@ -1539,7 +1543,7 @@ struct npc_leryssaAI : public ScriptedAI
{ {
ScriptedAI::UpdateAI(uiDiff); ScriptedAI::UpdateAI(uiDiff);
if (Phase_Timer <= uiDiff) if (uiPhaseTimer <= uiDiff)
{ {
switch (Phase) switch (Phase)
{ {
@@ -1547,37 +1551,37 @@ struct npc_leryssaAI : public ScriptedAI
if (m_creature->isSummon()) if (m_creature->isSummon())
if (Unit* pThassarian = CAST_SUM(m_creature)->GetSummoner()) if (Unit* pThassarian = CAST_SUM(m_creature)->GetSummoner())
DoScriptText(SAY_THASSARIAN_4, pThassarian); DoScriptText(SAY_THASSARIAN_4, pThassarian);
Phase_Timer = 5000; uiPhaseTimer = 5000;
++Phase; ++Phase;
break; break;
case 2: case 2:
DoScriptText(SAY_LERYSSA_2, m_creature); DoScriptText(SAY_LERYSSA_2, m_creature);
Phase_Timer = 5000; uiPhaseTimer = 5000;
++Phase; ++Phase;
break; break;
case 3: case 3:
if (m_creature->isSummon()) if (m_creature->isSummon())
if (Unit* pThassarian = CAST_SUM(m_creature)->GetSummoner()) if (Unit* pThassarian = CAST_SUM(m_creature)->GetSummoner())
DoScriptText(SAY_THASSARIAN_5, pThassarian); DoScriptText(SAY_THASSARIAN_5, pThassarian);
Phase_Timer = 5000; uiPhaseTimer = 5000;
++Phase; ++Phase;
break; break;
case 4: case 4:
DoScriptText(SAY_LERYSSA_3, m_creature); DoScriptText(SAY_LERYSSA_3, m_creature);
Phase_Timer = 5000; uiPhaseTimer = 5000;
++Phase; ++Phase;
break; break;
case 5: case 5:
if (m_creature->isSummon()) if (m_creature->isSummon())
if (Unit* pThassarian = CAST_SUM(m_creature)->GetSummoner()) if (Unit* pThassarian = CAST_SUM(m_creature)->GetSummoner())
DoScriptText(SAY_THASSARIAN_6, pThassarian); DoScriptText(SAY_THASSARIAN_6, pThassarian);
Phase_Timer = 5000; uiPhaseTimer = 5000;
++Phase; ++Phase;
break; break;
case 6: case 6:
DoScriptText(SAY_LERYSSA_4, m_creature); DoScriptText(SAY_LERYSSA_4, m_creature);
Phase_Timer = 5000; uiPhaseTimer = 5000;
++Phase; ++Phase;
break; break;
case 7: case 7:
@@ -1587,11 +1591,11 @@ struct npc_leryssaAI : public ScriptedAI
DoScriptText(SAY_THASSARIAN_7, pThassarian); DoScriptText(SAY_THASSARIAN_7, pThassarian);
CAST_AI(npc_thassarianAI,CAST_CRE(pThassarian)->AI())->uiPhase = 16; CAST_AI(npc_thassarianAI,CAST_CRE(pThassarian)->AI())->uiPhase = 16;
} }
Phase_Timer = 5000; uiPhaseTimer = 5000;
Phase = 0; Phase = 0;
break; break;
} }
} else Phase_Timer -= uiDiff; } else uiPhaseTimer -= uiDiff;
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
@@ -1634,7 +1638,7 @@ struct npc_beryl_sorcererAI : public FollowerAI
void EnterCombat(Unit* pWho) void EnterCombat(Unit* pWho)
{ {
if (m_creature->canAttack(pWho)) if (m_creature->canAttack(pWho))
m_creature->AI()->AttackStart(pWho); AttackStart(pWho);
} }
void SpellHit(Unit* pCaster, const SpellEntry* pSpell) 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! EnterEvadeMode(); //We make sure that the npc is not attacking the player!
m_creature->SetReactState(REACT_PASSIVE); m_creature->SetReactState(REACT_PASSIVE);
if (npc_beryl_sorcererAI* pBerylAI = CAST_AI(npc_beryl_sorcererAI, m_creature->AI())) StartFollow(CAST_PLR(pCaster), NULL, NULL);
pBerylAI->StartFollow(CAST_PLR(pCaster), NULL, NULL);
m_creature->UpdateEntry(NPC_CAPTURED_BERLY_SORCERER, TEAM_NEUTRAL); m_creature->UpdateEntry(NPC_CAPTURED_BERLY_SORCERER, TEAM_NEUTRAL);
DoCast(m_creature, SPELL_COSMETIC_ENSLAVE_CHAINS_SELF, true); DoCast(m_creature, SPELL_COSMETIC_ENSLAVE_CHAINS_SELF, true);
CAST_PLR(pCaster)->KilledMonsterCredit(NPC_CAPTURED_BERLY_SORCERER, 0); CAST_PLR(pCaster)->KilledMonsterCredit(NPC_CAPTURED_BERLY_SORCERER, 0);