*Some cleanup of Kalecgos script.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-08-21 23:38:04 -05:00
parent 0ee9bffd5a
commit 189d9fdd51
2 changed files with 90 additions and 90 deletions
@@ -136,14 +136,14 @@ struct TRINITY_DLL_DECL boss_kalecgosAI : public ScriptedAI
Door->SetLootState(GO_JUST_DEACTIVATED); Door->SetLootState(GO_JUST_DEACTIVATED);
} }
Unit *Sath = Unit::GetUnit(*m_creature,SathGUID); if(Creature *Sath = Unit::GetCreature(*me, SathGUID))
if (Sath) CAST_CRE(Sath)->AI()->EnterEvadeMode(); Sath->AI()->EnterEvadeMode();
m_creature->setFaction(14); me->setFaction(14);
m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE + UNIT_FLAG_NOT_SELECTABLE); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE + UNIT_FLAG_NOT_SELECTABLE);
m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_LEVITATING); me->RemoveUnitMovementFlag(MOVEMENTFLAG_LEVITATING);
m_creature->SetVisibility(VISIBILITY_ON); me->SetVisibility(VISIBILITY_ON);
m_creature->SetStandState(UNIT_STAND_STATE_SLEEP); me->SetStandState(UNIT_STAND_STATE_SLEEP);
ArcaneBuffetTimer = 8000; ArcaneBuffetTimer = 8000;
FrostBreathTimer = 15000; FrostBreathTimer = 15000;
@@ -161,14 +161,14 @@ struct TRINITY_DLL_DECL boss_kalecgosAI : public ScriptedAI
void DamageTaken(Unit *done_by, uint32 &damage) void DamageTaken(Unit *done_by, uint32 &damage)
{ {
if (damage >= m_creature->GetHealth() && done_by != m_creature) if (damage >= me->GetHealth() && done_by != me)
damage = 0; damage = 0;
} }
void EnterCombat(Unit* who) void EnterCombat(Unit* who)
{ {
m_creature->SetStandState(UNIT_STAND_STATE_STAND); me->SetStandState(UNIT_STAND_STATE_STAND);
DoScriptText(SAY_EVIL_AGGRO, m_creature); DoScriptText(SAY_EVIL_AGGRO, me);
if (GameObject *Door = pInstance ? pInstance->instance->GetGameObject(pInstance->GetData64(DoorGUID)) : NULL) if (GameObject *Door = pInstance ? pInstance->instance->GetGameObject(pInstance->GetData64(DoorGUID)) : NULL)
Door->SetLootState(GO_ACTIVATED); Door->SetLootState(GO_ACTIVATED);
DoZoneInCombat(); DoZoneInCombat();
@@ -181,19 +181,19 @@ struct TRINITY_DLL_DECL boss_kalecgosAI : public ScriptedAI
{ {
switch(rand()%2) switch(rand()%2)
{ {
case 0: DoScriptText(SAY_EVIL_SLAY1, m_creature); break; case 0: DoScriptText(SAY_EVIL_SLAY1, me); break;
case 1: DoScriptText(SAY_EVIL_SLAY2, m_creature); break; case 1: DoScriptText(SAY_EVIL_SLAY2, me); break;
} }
} }
void MovementInform(uint32 type,uint32 id) void MovementInform(uint32 type,uint32 id)
{ {
m_creature->SetVisibility(VISIBILITY_OFF); me->SetVisibility(VISIBILITY_OFF);
if (isFriendly) if (isFriendly)
m_creature->setDeathState(JUST_DIED); me->setDeathState(JUST_DIED);
else else
{ {
m_creature->GetMotionMaster()->MoveTargetedHome(); me->GetMotionMaster()->MoveTargetedHome();
TalkTimer = 30000; TalkTimer = 30000;
} }
} }
@@ -203,17 +203,16 @@ struct TRINITY_DLL_DECL boss_kalecgosAI : public ScriptedAI
switch(TalkSequence) switch(TalkSequence)
{ {
case 1: case 1:
m_creature->setFaction(35); me->setFaction(35);
TalkTimer = 1000; TalkTimer = 1000;
break; break;
case 2: case 2:
DoScriptText(SAY_GOOD_PLRWIN, m_creature); DoScriptText(SAY_GOOD_PLRWIN, me);
TalkTimer = 10000; TalkTimer = 10000;
break; break;
case 3: case 3:
m_creature->AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING); me->AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING);
m_creature->GetMotionMaster()->Clear(); me->GetMotionMaster()->MovePoint(0,FLY_X,FLY_Y,FLY_Z);
m_creature->GetMotionMaster()->MovePoint(0,FLY_X,FLY_Y,FLY_Z);
TalkTimer = 600000; TalkTimer = 600000;
break; break;
default: default:
@@ -226,13 +225,12 @@ struct TRINITY_DLL_DECL boss_kalecgosAI : public ScriptedAI
switch(TalkSequence) switch(TalkSequence)
{ {
case 1: case 1:
DoScriptText(SAY_EVIL_ENRAGE, m_creature); DoScriptText(SAY_EVIL_ENRAGE, me);
TalkTimer = 3000; TalkTimer = 3000;
break; break;
case 2: case 2:
m_creature->AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING); me->AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING);
m_creature->GetMotionMaster()->Clear(); me->GetMotionMaster()->MovePoint(0,FLY_X,FLY_Y,FLY_Z);
m_creature->GetMotionMaster()->MovePoint(0,FLY_X,FLY_Y,FLY_Z);
TalkTimer = 600000; TalkTimer = 600000;
break; break;
case 3: case 3:
@@ -276,7 +274,7 @@ struct TRINITY_DLL_DECL boss_sathrovarrAI : public ScriptedAI
if (KalecGUID) if (KalecGUID)
{ {
if (Unit* Kalec = Unit::GetUnit(*m_creature, KalecGUID)) if (Creature* Kalec = Unit::GetCreature(*me, KalecGUID))
Kalec->setDeathState(JUST_DIED); Kalec->setDeathState(JUST_DIED);
KalecGUID = 0; KalecGUID = 0;
} }
@@ -298,19 +296,18 @@ struct TRINITY_DLL_DECL boss_sathrovarrAI : public ScriptedAI
void EnterCombat(Unit* who) void EnterCombat(Unit* who)
{ {
Creature *Kalec = m_creature->SummonCreature(MOB_KALEC, m_creature->GetPositionX() + 10, m_creature->GetPositionY() + 5, m_creature->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 0); if(Creature *Kalec = me->SummonCreature(MOB_KALEC, me->GetPositionX() + 10, me->GetPositionY() + 5, me->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 0))
if (Kalec)
{ {
KalecGUID = Kalec->GetGUID(); KalecGUID = Kalec->GetGUID();
m_creature->CombatStart(Kalec); me->CombatStart(Kalec);
m_creature->AddThreat(Kalec, 100.0f); me->AddThreat(Kalec, 100.0f);
} }
DoScriptText(SAY_SATH_AGGRO, m_creature); DoScriptText(SAY_SATH_AGGRO, me);
} }
void DamageTaken(Unit *done_by, uint32 &damage) void DamageTaken(Unit *done_by, uint32 &damage)
{ {
if (damage >= m_creature->GetHealth() && done_by != m_creature) if (damage >= me->GetHealth() && done_by != me)
damage = 0; damage = 0;
} }
@@ -319,30 +316,30 @@ struct TRINITY_DLL_DECL boss_sathrovarrAI : public ScriptedAI
if (target->GetGUID() == KalecGUID) if (target->GetGUID() == KalecGUID)
{ {
TeleportAllPlayersBack(); TeleportAllPlayersBack();
if (Unit *Kalecgos = Unit::GetUnit(*m_creature, KalecgosGUID)) if (Creature *Kalecgos = Unit::GetCreature(*me, KalecgosGUID))
{ {
CAST_AI(boss_kalecgosAI, CAST_CRE(Kalecgos)->AI())->TalkTimer = 1; CAST_AI(boss_kalecgosAI, Kalecgos->AI())->TalkTimer = 1;
CAST_AI(boss_kalecgosAI, CAST_CRE(Kalecgos)->AI())->isFriendly = false; CAST_AI(boss_kalecgosAI, Kalecgos->AI())->isFriendly = false;
} }
EnterEvadeMode(); EnterEvadeMode();
return; return;
} }
switch(rand()%2) switch(rand()%2)
{ {
case 0: DoScriptText(SAY_SATH_SLAY1, m_creature); break; case 0: DoScriptText(SAY_SATH_SLAY1, me); break;
case 1: DoScriptText(SAY_SATH_SLAY2, m_creature); break; case 1: DoScriptText(SAY_SATH_SLAY2, me); break;
} }
} }
void JustDied(Unit *killer) void JustDied(Unit *killer)
{ {
DoScriptText(SAY_SATH_DEATH, m_creature); DoScriptText(SAY_SATH_DEATH, me);
m_creature->GetMap()->CreatureRelocation(m_creature, m_creature->GetPositionX(), m_creature->GetPositionY(), DRAGON_REALM_Z, m_creature->GetOrientation()); me->GetMap()->CreatureRelocation(me, me->GetPositionX(), me->GetPositionY(), DRAGON_REALM_Z, me->GetOrientation());
TeleportAllPlayersBack(); TeleportAllPlayersBack();
if (Unit *Kalecgos = Unit::GetUnit(*m_creature, KalecgosGUID)) if (Creature *Kalecgos = Unit::GetCreature(*me, KalecgosGUID))
{ {
CAST_AI(boss_kalecgosAI, CAST_CRE(Kalecgos)->AI())->TalkTimer = 1; CAST_AI(boss_kalecgosAI, Kalecgos->AI())->TalkTimer = 1;
CAST_AI(boss_kalecgosAI, CAST_CRE(Kalecgos)->AI())->isFriendly = true; CAST_AI(boss_kalecgosAI, Kalecgos->AI())->isFriendly = true;
} }
if (pInstance) if (pInstance)
@@ -351,14 +348,11 @@ struct TRINITY_DLL_DECL boss_sathrovarrAI : public ScriptedAI
void TeleportAllPlayersBack() void TeleportAllPlayersBack()
{ {
Map* pMap = m_creature->GetMap(); Map* pMap = me->GetMap();
if (!pMap->IsDungeon()) return; if (!pMap->IsDungeon()) return;
Map::PlayerList const &PlayerList = pMap->GetPlayers(); Map::PlayerList const &PlayerList = pMap->GetPlayers();
Map::PlayerList::const_iterator i; for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
for(i = PlayerList.begin(); i != PlayerList.end(); ++i) i->getSource()->RemoveAura(AURA_SPECTRAL_REALM);
if (Player* i_pl = i->getSource())
if (i_pl->HasAura(AURA_SPECTRAL_REALM))
i_pl->RemoveAurasDueToSpell(AURA_SPECTRAL_REALM);
} }
void UpdateAI(const uint32 diff) void UpdateAI(const uint32 diff)
@@ -368,36 +362,35 @@ struct TRINITY_DLL_DECL boss_sathrovarrAI : public ScriptedAI
if (CheckTimer < diff) if (CheckTimer < diff)
{ {
if (((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 10) && !isEnraged) if (HealthBelowPct(10) && !isEnraged)
{ {
Unit* Kalecgos = Unit::GetUnit(*m_creature, KalecgosGUID); if(Creature* Kalecgos = Unit::GetCreature(*me, KalecgosGUID))
if (Kalecgos)
{ {
Kalecgos->CastSpell(Kalecgos, SPELL_ENRAGE, true); Kalecgos->CastSpell(Kalecgos, SPELL_ENRAGE, true);
CAST_AI(boss_kalecgosAI, CAST_CRE(Kalecgos)->AI())->isEnraged = true; CAST_AI(boss_kalecgosAI, Kalecgos->AI())->isEnraged = true;
} }
DoCast(m_creature, SPELL_ENRAGE, true); DoCast(me, SPELL_ENRAGE, true);
isEnraged = true; isEnraged = true;
} }
if (!isBanished && (m_creature->GetHealth()*100)/m_creature->GetMaxHealth() < 1) if (!isBanished && HealthBelowPct(1))
{ {
if (Unit *Kalecgos = Unit::GetUnit(*m_creature, KalecgosGUID)) if (Creature *Kalecgos = Unit::GetCreature(*me, KalecgosGUID))
{ {
if (CAST_AI(boss_kalecgosAI, CAST_CRE(Kalecgos)->AI())->isBanished) if (CAST_AI(boss_kalecgosAI, Kalecgos->AI())->isBanished)
{ {
m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); me->DealDamage(me, me->GetHealth());
return; return;
} }
else else
{ {
DoCast(m_creature, SPELL_BANISH); DoCast(me, SPELL_BANISH);
isBanished = true; isBanished = true;
} }
} }
else else
{ {
m_creature->MonsterTextEmote("is unable to find Kalecgos", NULL); me->MonsterTextEmote("is unable to find Kalecgos", NULL);
EnterEvadeMode(); EnterEvadeMode();
return; return;
} }
@@ -407,11 +400,11 @@ struct TRINITY_DLL_DECL boss_sathrovarrAI : public ScriptedAI
if (ResetThreat < diff) if (ResetThreat < diff)
{ {
if ((m_creature->getVictim()->HasAura(AURA_SPECTRAL_EXHAUSTION)) && (m_creature->getVictim()->GetTypeId() == TYPEID_PLAYER)) if ((me->getVictim()->HasAura(AURA_SPECTRAL_EXHAUSTION)) && (me->getVictim()->GetTypeId() == TYPEID_PLAYER))
{ {
for(std::list<HostilReference*>::iterator itr = m_creature->getThreatManager().getThreatList().begin(); itr != m_creature->getThreatManager().getThreatList().end(); ++itr) for(std::list<HostilReference*>::iterator itr = me->getThreatManager().getThreatList().begin(); itr != me->getThreatManager().getThreatList().end(); ++itr)
{ {
if (((*itr)->getUnitGuid()) == (m_creature->getVictim()->GetGUID())) if (((*itr)->getUnitGuid()) == (me->getVictim()->GetGUID()))
{ {
(*itr)->removeReference(); (*itr)->removeReference();
break; break;
@@ -423,23 +416,23 @@ struct TRINITY_DLL_DECL boss_sathrovarrAI : public ScriptedAI
if (ShadowBoltTimer < diff) if (ShadowBoltTimer < diff)
{ {
DoScriptText(SAY_SATH_SPELL1, m_creature); DoScriptText(SAY_SATH_SPELL1, me);
DoCast(m_creature, SPELL_SHADOW_BOLT); DoCast(me, SPELL_SHADOW_BOLT);
ShadowBoltTimer = 7000+(rand()%3000); ShadowBoltTimer = 7000+(rand()%3000);
}else ShadowBoltTimer -= diff; }else ShadowBoltTimer -= diff;
if (AgonyCurseTimer < diff) if (AgonyCurseTimer < diff)
{ {
Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0); Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0);
if (!target) target = m_creature->getVictim(); if (!target) target = me->getVictim();
DoCast(target, SPELL_AGONY_CURSE); DoCast(target, SPELL_AGONY_CURSE);
AgonyCurseTimer = 20000; AgonyCurseTimer = 20000;
}else AgonyCurseTimer -= diff; }else AgonyCurseTimer -= diff;
if (CorruptionStrikeTimer < diff) if (CorruptionStrikeTimer < diff)
{ {
DoScriptText(SAY_SATH_SPELL2, m_creature); DoScriptText(SAY_SATH_SPELL2, me);
DoCast(m_creature->getVictim(), SPELL_CORRUPTION_STRIKE); DoCast(me->getVictim(), SPELL_CORRUPTION_STRIKE);
CorruptionStrikeTimer = 13000; CorruptionStrikeTimer = 13000;
}else CorruptionStrikeTimer -= diff; }else CorruptionStrikeTimer -= diff;
@@ -498,20 +491,20 @@ struct TRINITY_DLL_DECL boss_kalecAI : public ScriptedAI
switch(YellSequence) switch(YellSequence)
{ {
case 0: case 0:
DoScriptText(SAY_GOOD_AGGRO, m_creature); DoScriptText(SAY_GOOD_AGGRO, me);
YellSequence++; YellSequence++;
break; break;
case 1: case 1:
if ((m_creature->GetHealth()*100)/m_creature->GetMaxHealth() < 50) if (HealthBelowPct(50))
{ {
DoScriptText(SAY_GOOD_NEAR_DEATH, m_creature); DoScriptText(SAY_GOOD_NEAR_DEATH, me);
YellSequence++; YellSequence++;
} }
break; break;
case 2: case 2:
if ((m_creature->GetHealth()*100)/m_creature->GetMaxHealth() < 10) if (HealthBelowPct(10))
{ {
DoScriptText(SAY_GOOD_NEAR_DEATH2, m_creature); DoScriptText(SAY_GOOD_NEAR_DEATH2, me);
YellSequence++; YellSequence++;
} }
break; break;
@@ -523,13 +516,13 @@ struct TRINITY_DLL_DECL boss_kalecAI : public ScriptedAI
if (RevitalizeTimer < diff) if (RevitalizeTimer < diff)
{ {
DoCast(m_creature, SPELL_REVITALIZE); DoCast(me, SPELL_REVITALIZE);
RevitalizeTimer = 5000; RevitalizeTimer = 5000;
}else RevitalizeTimer -= diff; }else RevitalizeTimer -= diff;
if (HeroicStrikeTimer < diff) if (HeroicStrikeTimer < diff)
{ {
DoCast(m_creature->getVictim(), SPELL_HEROIC_STRIKE); DoCast(me->getVictim(), SPELL_HEROIC_STRIKE);
HeroicStrikeTimer = 2000; HeroicStrikeTimer = 2000;
}else HeroicStrikeTimer -= diff; }else HeroicStrikeTimer -= diff;
@@ -543,11 +536,11 @@ void boss_kalecgosAI::UpdateAI(const uint32 diff)
{ {
if (!TalkSequence) if (!TalkSequence)
{ {
m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE + UNIT_FLAG_NOT_SELECTABLE); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE + UNIT_FLAG_NOT_SELECTABLE);
m_creature->InterruptNonMeleeSpells(true); me->InterruptNonMeleeSpells(true);
m_creature->RemoveAllAuras(); me->RemoveAllAuras();
m_creature->DeleteThreatList(); me->DeleteThreatList();
m_creature->CombatStop(); me->CombatStop();
if (GameObject *Door = pInstance ? pInstance->instance->GetGameObject(pInstance->GetData64(DoorGUID)) : NULL) if (GameObject *Door = pInstance ? pInstance->instance->GetGameObject(pInstance->GetData64(DoorGUID)) : NULL)
Door->SetLootState(GO_JUST_DEACTIVATED); Door->SetLootState(GO_JUST_DEACTIVATED);
TalkSequence++; TalkSequence++;
@@ -568,30 +561,29 @@ void boss_kalecgosAI::UpdateAI(const uint32 diff)
if (CheckTimer < diff) if (CheckTimer < diff)
{ {
if (((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 10) && !isEnraged) if (HealthBelowPct(10) && !isEnraged)
{ {
Unit* Sath = Unit::GetUnit(*m_creature, SathGUID); if(Creature* Sath = Unit::GetCreature(*me, SathGUID))
if (Sath)
{ {
Sath->CastSpell(Sath, SPELL_ENRAGE, true); Sath->CastSpell(Sath, SPELL_ENRAGE, true);
CAST_AI(boss_sathrovarrAI, CAST_CRE(Sath)->AI())->isEnraged = true; CAST_AI(boss_sathrovarrAI, Sath->AI())->isEnraged = true;
} }
DoCast(m_creature, SPELL_ENRAGE, true); DoCast(me, SPELL_ENRAGE, true);
isEnraged = true; isEnraged = true;
} }
if (!isBanished && (m_creature->GetHealth()*100)/m_creature->GetMaxHealth() < 1) if (!isBanished && HealthBelowPct(1))
{ {
if (Unit *Sath = Unit::GetUnit(*m_creature, SathGUID)) if(Creature* Sath = Unit::GetCreature(*me, SathGUID))
{ {
if (CAST_AI(boss_sathrovarrAI, CAST_CRE(Sath)->AI())->isBanished) if (CAST_AI(boss_sathrovarrAI, Sath->AI())->isBanished)
{ {
Sath->DealDamage(Sath, Sath->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); Sath->DealDamage(Sath, Sath->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
return; return;
} }
else else
{ {
DoCast(m_creature, SPELL_BANISH); DoCast(me, SPELL_BANISH);
isBanished = true; isBanished = true;
} }
} }
@@ -632,8 +624,7 @@ void boss_kalecgosAI::UpdateAI(const uint32 diff)
if (SpectralBlastTimer < diff) if (SpectralBlastTimer < diff)
{ {
//this is a hack. we need to find a victim without aura in core //this is a hack. we need to find a victim without aura in core
Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0); if(Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, 0, true, -AURA_SPECTRAL_EXHAUSTION))
if (target && target != m_creature->getVictim() && target->isAlive() && !target->HasAura(AURA_SPECTRAL_EXHAUSTION))
{ {
DoCast(target, SPELL_SPECTRAL_BLAST); DoCast(target, SPELL_SPECTRAL_BLAST);
SpectralBlastTimer = 20000+(rand()%5000); SpectralBlastTimer = 20000+(rand()%5000);
+10 -1
View File
@@ -165,7 +165,16 @@ Unit* UnitAI::SelectTarget(SelectAggroTarget targetType, uint32 position, float
if(targetType == SELECT_TARGET_TOPAGGRO) if(targetType == SELECT_TARGET_TOPAGGRO)
advance(i, position); advance(i, position);
else // random else // random
advance(i, position + rand()%(m_threatlist.size() - position)); {
//advance(i, position + rand()%(m_threatlist.size() - position));
//if we use "random, 1", usually we want random except current victim
advance(i, rand()%m_threatlist.size());
if(position && (*i)->getTarget() == me->getVictim())
{
m_threatlist.erase(i);
continue;
}
}
} }
if(SelectTargetHelper(me, (*i)->getTarget(), playerOnly, dist, aura)) if(SelectTargetHelper(me, (*i)->getTarget(), playerOnly, dist, aura))