*Fix a crash caused by shaffar script.

*Fix build.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-08-13 11:06:34 -05:00
parent eaf8c93f7a
commit 37b3b39322
2 changed files with 37 additions and 51 deletions
@@ -55,7 +55,7 @@ enum
struct TRINITY_DLL_DECL boss_nexusprince_shaffarAI : public ScriptedAI struct TRINITY_DLL_DECL boss_nexusprince_shaffarAI : public ScriptedAI
{ {
boss_nexusprince_shaffarAI(Creature *c) : ScriptedAI(c) { HasTaunted = false; } boss_nexusprince_shaffarAI(Creature *c) : ScriptedAI(c), summons(me) { HasTaunted = false; }
uint32 Blink_Timer; uint32 Blink_Timer;
uint32 Beacon_Timer; uint32 Beacon_Timer;
@@ -63,18 +63,11 @@ struct TRINITY_DLL_DECL boss_nexusprince_shaffarAI : public ScriptedAI
uint32 Frostbolt_Timer; uint32 Frostbolt_Timer;
uint32 FrostNova_Timer; uint32 FrostNova_Timer;
Creature* Beacon[NR_INITIAL_BEACONS]; SummonList summons;
bool HasTaunted; bool HasTaunted;
bool CanBlink; bool CanBlink;
void RemoveBeaconFromList(Creature* targetBeacon)
{
for(uint8 i = 0; i < NR_INITIAL_BEACONS; i++)
if(Beacon[i] && Beacon[i]->GetGUID() == targetBeacon->GetGUID())
Beacon[i] = NULL;
}
void Reset() void Reset()
{ {
Blink_Timer = 1500; Blink_Timer = 1500;
@@ -89,30 +82,14 @@ struct TRINITY_DLL_DECL boss_nexusprince_shaffarAI : public ScriptedAI
float posX, posY, posZ, angle; float posX, posY, posZ, angle;
m_creature->GetHomePosition(posX, posY, posZ, angle); m_creature->GetHomePosition(posX, posY, posZ, angle);
Beacon[0] = m_creature->SummonCreature(NPC_BEACON, posX - dist, posY - dist, posZ, angle, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 7200000); m_creature->SummonCreature(NPC_BEACON, posX - dist, posY - dist, posZ, angle, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 7200000);
Beacon[1] = m_creature->SummonCreature(NPC_BEACON, posX - dist, posY + dist, posZ, angle, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 7200000); m_creature->SummonCreature(NPC_BEACON, posX - dist, posY + dist, posZ, angle, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 7200000);
Beacon[2] = m_creature->SummonCreature(NPC_BEACON, posX + dist, posY, posZ, angle, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 7200000); m_creature->SummonCreature(NPC_BEACON, posX + dist, posY, posZ, angle, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 7200000);
for(uint8 i = 0; i < NR_INITIAL_BEACONS; i++)
{
if(Beacon[i])
Beacon[i]->CastSpell(Beacon[i], SPELL_ETHEREAL_BEACON_VISUAL, false);
}
} }
void EnterEvadeMode() void EnterEvadeMode()
{ {
//Despawn still living initial beacons. summons.DespawnAll();
for(uint8 i = 0; i < NR_INITIAL_BEACONS; i++)
{
if(Beacon[i] && Beacon[i]->isAlive())
{
Beacon[i]->RemoveAllAuras();
Beacon[i]->CombatStop();
Beacon[i]->StopMoving();
Beacon[i]->Kill(Beacon[i]);
}
}
ScriptedAI::EnterEvadeMode(); ScriptedAI::EnterEvadeMode();
} }
@@ -134,10 +111,8 @@ struct TRINITY_DLL_DECL boss_nexusprince_shaffarAI : public ScriptedAI
case 2: DoScriptText(SAY_AGGRO_3, m_creature); break; case 2: DoScriptText(SAY_AGGRO_3, m_creature); break;
} }
// Send initial beacons to join the fight if not already DoZoneInCombat();
for(uint8 i = 0; i < NR_INITIAL_BEACONS; i++) summons.DoZoneInCombat();
if(Beacon[i] && Beacon[i]->isAlive() && !Beacon[i]->isInCombat())
Beacon[i]->AI()->AttackStart(who);
} }
void JustSummoned(Creature *summoned) void JustSummoned(Creature *summoned)
@@ -149,6 +124,13 @@ struct TRINITY_DLL_DECL boss_nexusprince_shaffarAI : public ScriptedAI
if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) )
summoned->AI()->AttackStart(target); summoned->AI()->AttackStart(target);
} }
summons.Summon(summoned);
}
void SummonedCreatureDespawn(Creature *summon)
{
summons.Despawn(summon);
} }
void KilledUnit(Unit* victim) void KilledUnit(Unit* victim)
@@ -163,6 +145,7 @@ struct TRINITY_DLL_DECL boss_nexusprince_shaffarAI : public ScriptedAI
void JustDied(Unit* Killer) void JustDied(Unit* Killer)
{ {
DoScriptText(SAY_DEAD, m_creature); DoScriptText(SAY_DEAD, m_creature);
summons.DespawnAll();
} }
void UpdateAI(const uint32 diff) void UpdateAI(const uint32 diff)
@@ -265,14 +248,14 @@ struct TRINITY_DLL_DECL mob_ethereal_beaconAI : public ScriptedAI
void EnterCombat(Unit *who) void EnterCombat(Unit *who)
{ {
// Send Shaffar to fight // Send Shaffar to fight
Unit* Shaffar = me->FindNearestCreature(NPC_SHAFFAR, 100); Creature* Shaffar = me->FindNearestCreature(NPC_SHAFFAR, 100);
if(!Shaffar || Shaffar->isDead()) if(!Shaffar || Shaffar->isDead())
{ {
KillSelf(); KillSelf();
return; return;
} }
if(!Shaffar->isInCombat()) if(!Shaffar->isInCombat())
CAST_CRE(Shaffar)->AI()->AttackStart(who); Shaffar->AI()->AttackStart(who);
} }
void JustSummoned(Creature *summoned) void JustSummoned(Creature *summoned)
@@ -280,13 +263,6 @@ struct TRINITY_DLL_DECL mob_ethereal_beaconAI : public ScriptedAI
summoned->AI()->AttackStart(m_creature->getVictim()); summoned->AI()->AttackStart(m_creature->getVictim());
} }
void JustDied(Unit* Killer)
{
Creature *Shaffar = me->FindNearestCreature(NPC_SHAFFAR, 100);
if(Shaffar)
CAST_AI(boss_nexusprince_shaffarAI, Shaffar->AI())->RemoveBeaconFromList(m_creature);
}
void UpdateAI(const uint32 diff) void UpdateAI(const uint32 diff)
{ {
if (!UpdateVictim()) if (!UpdateVictim())
@@ -269,24 +269,30 @@ public:
bool GOHello_go_orb_of_the_blue_flight(Player *plr, GameObject* go) bool GOHello_go_orb_of_the_blue_flight(Player *plr, GameObject* go)
{ {
if(go->GetUInt32Value(GAMEOBJECT_FACTION) == 35){ if(go->GetUInt32Value(GAMEOBJECT_FACTION) == 35){
ScriptedInstance* pInstance = (go->GetInstanceData()); ScriptedInstance* pInstance = go->GetInstanceData();
float x,y,z, dx,dy,dz; float x,y,z;
//float dx,dy,dz;
go->SummonCreature(CREATURE_POWER_OF_THE_BLUE_DRAGONFLIGHT, plr->GetPositionX(), plr->GetPositionY(), plr->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_DESPAWN, 121000); go->SummonCreature(CREATURE_POWER_OF_THE_BLUE_DRAGONFLIGHT, plr->GetPositionX(), plr->GetPositionY(), plr->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_DESPAWN, 121000);
plr->CastSpell(plr, SPELL_VENGEANCE_OF_THE_BLUE_FLIGHT, true); plr->CastSpell(plr, SPELL_VENGEANCE_OF_THE_BLUE_FLIGHT, true);
go->SetUInt32Value(GAMEOBJECT_FACTION, 0); go->SetUInt32Value(GAMEOBJECT_FACTION, 0);
Unit* Kalec = CAST_CRE(Unit::GetUnit(*plr, pInstance->GetData64(DATA_KALECGOS_KJ))); Creature* Kalec = Unit::GetCreature(*plr, pInstance->GetData64(DATA_KALECGOS_KJ));
//Kalec->RemoveDynObject(SPELL_RING_OF_BLUE_FLAMES); //Kalec->RemoveDynObject(SPELL_RING_OF_BLUE_FLAMES);
go->GetPosition(x,y,z); go->GetPosition(x,y,z);
for(uint8 i = 0; i < 4; ++i){ // this won't work. need rewritten
DynamicObject* Dyn = Kalec->GetDynObject(SPELL_RING_OF_BLUE_FLAMES); /*
if(Dyn){ for(uint8 i = 0; i < 4; ++i)
{
if(DynamicObject* Dyn = Kalec->GetDynObject(SPELL_RING_OF_BLUE_FLAMES))
{
Dyn->GetPosition(dx,dy,dz); Dyn->GetPosition(dx,dy,dz);
if(x == dx && dy == y && dz == z){ if(x == dx && dy == y && dz == z)
{
Dyn->Delete(); Dyn->Delete();
break; break;
} }
} }
} }
*/
go->Refresh(); go->Refresh();
} }
return true; return true;
@@ -361,7 +367,11 @@ struct TRINITY_DLL_DECL boss_kalecgos_kjAI : public ScriptedAI
Orb[i]->setActive(true); Orb[i]->setActive(true);
Orb[i]->Refresh(); Orb[i]->Refresh();
} }
}else{ }
else
{
// this won't work
/*
float x,y,z, dx,dy,dz; float x,y,z, dx,dy,dz;
Orb[random]->GetPosition(x,y,z); Orb[random]->GetPosition(x,y,z);
for(uint8 i = 0; i < 4; ++i){ for(uint8 i = 0; i < 4; ++i){
@@ -373,7 +383,7 @@ struct TRINITY_DLL_DECL boss_kalecgos_kjAI : public ScriptedAI
break; break;
} }
} }
} }*/
Orb[random]->CastSpell(m_creature, SPELL_RING_OF_BLUE_FLAMES); Orb[random]->CastSpell(m_creature, SPELL_RING_OF_BLUE_FLAMES);
Orb[random]->SetUInt32Value(GAMEOBJECT_FACTION, 35); Orb[random]->SetUInt32Value(GAMEOBJECT_FACTION, 35);
Orb[random]->setActive(true); Orb[random]->setActive(true);