Code:
////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////// Anub'Arak ///////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
#define BOSS_ANUBARAK 29120
#define CARRION_BEETLES 53520
#define IMPALE 53454
#define LEECHING_SWARM 53467
#define POUND 53472
#define HC_IMPALE 59446
#define HC_LEECHING_SWARM 59430
#define HC_POUND 59433
#define SUBMERGE 65981
int fas = 0;
int fas_stop = false;
uint32 phase_one_first = 1;
uint32 phase_one_second = 1;
uint32 phase_one_third = 1;
class AnubArakAI : public MoonScriptBossAI
{
MOONSCRIPT_FACTORY_FUNCTION(AnubArakAI, MoonScriptBossAI);
AnubArakAI(Creature* pCreature) : MoonScriptBossAI(pCreature)
{
AddSpell(CARRION_BEETLES, Target_Self, 70, 0, 20);
SpellDesc* LeechingSwarm = AddSpell(LEECHING_SWARM, Target_Self, 20, 0, 25);
SpellDesc* Pound = AddSpell(POUND, Target_Self, 10, 3.2f, 20);
SpellDesc* HcLeechingSwarm = AddSpell(HC_LEECHING_SWARM, Target_Self, 20, 0, 25);
SpellDesc* HcPound = AddSpell(HC_POUND, Target_Self, 10, 3.2f, 20);
if( !IsHeroic() )
{
LeechingSwarm->mEnabled = true;
Pound->mEnabled = true;
HcLeechingSwarm->mEnabled = false;
HcPound->mEnabled = false;
AddPhaseSpell(2, AddSpell(IMPALE, Target_RandomDestination, 20, 0, 10, 0, 100));
}
else
{
LeechingSwarm->mEnabled = false;
Pound->mEnabled = false;
HcLeechingSwarm->mEnabled = true;
HcPound->mEnabled = true;
AddPhaseSpell(2, AddSpell(HC_IMPALE, Target_RandomDestination, 20, 0, 10, 0, 100));
};
LeechingSwarm->AddEmote("Your armor is useless against my locusts!", Text_Yell);
LeechingSwarm->AddEmote("The pestilence upon you!", Text_Yell);
HcLeechingSwarm->AddEmote("Your armor is useless against my locusts!", Text_Yell);
HcLeechingSwarm->AddEmote("The pestilence upon you!", Text_Yell);
AddEmote(Event_OnCombatStart, "Eternal agony awaits you!", Text_Yell);
AddEmote(Event_OnDied, "Never thought... I would be free of him...", Text_Yell);
}
void OnCombatStart(Unit* pTarget)
{
SetPhase(1);
ParentClass::OnCombatStart(pTarget);
}
void AIUpdate()
{
if(GetPhase() == 1)
{
if( !IsHeroic() )
{
LeechingSwarm->mEnabled = true;
Pound->mEnabled = true;
}
else
{
HcLeechingSwarm->mEnabled = true;
HcPound->mEnabled = true;
}
fas_stop = false;
}
//Phase 2 75%
if(GetHealthPercent() <= 75 && GetPhase() == 1 && phase_one_first == 1)
{
SetPhase(2);
fas++;
ApplyAura(SUBMERGE);
mPhaseSwitchTimer = AddTimer( 40000 );
Emote ("Come forth, my brethren. Feast on their flesh!");
LeechingSwarm->mEnabled = false;
Pound->mEnabled = false;
HcLeechingSwarm->mEnabled = false;
HcPound->mEnabled = false;
ClearHateList();
&AnubArakAI::AnubarAdds;
phase_one_first = 2;
phase_one_second = 1;
}
if( IsTimerFinished( mPhaseSwitchTimer ))
{
SetPhase(1);
ResetTimer(mAddsSpawn, 40000);
}
//Phase 2 50%
if(GetHealthPercent() <= 50 && GetPhase() == 1 && phase_one_second == 1)
{
SetPhase(2);
fas++;
ApplyAura(SUBMERGE);
mPhaseSwitchTimer = AddTimer( 40000 );
Emote ("Come forth, my brethren. Feast on their flesh!");
LeechingSwarm->mEnabled = false;
Pound->mEnabled = false;
HcLeechingSwarm->mEnabled = false;
HcPound->mEnabled = false;
ClearHateList();
&AnubArakAI::AnubarAdds;
phase_one_second = 2;
phase_one_third = 1;
}
if( IsTimerFinished( mPhaseSwitchTimer ))
{
SetPhase(1);
ResetTimer(mAddsSpawn, 40000);
}
//Phase 3 25%
if(GetHealthPercent() <= 50 && GetPhase() == 1 && phase_one_third == 1)
{
SetPhase(2);
fas++;
ApplyAura(SUBMERGE);
mPhaseSwitchTimer = AddTimer( 40000 );
Emote ("Come forth, my brethren. Feast on their flesh!");
LeechingSwarm->mEnabled = false;
Pound->mEnabled = false;
HcLeechingSwarm->mEnabled = false;
HcPound->mEnabled = false;
ClearHateList();
&AnubArakAI::AnubarAdds;
phase_one_third = 2;
}
if( IsTimerFinished( mPhaseSwitchTimer ))
{
SetPhase(1);
ResetTimer(mAddsSpawn, 40000);
}
}
void OnTargetDied(Unit* pTarget)
{
int randAnnounce;
randAnnounce=rand()%3;
switch (randAnnounce)
{
case 0:
Emote ("You shall experience my torment, first-hand!", Text_Yell);
break;
case 1:
Emote("You have made your choice.", Text_Yell);
break;
case 2:
Emote("Soon, the Master's voice will call to you.", Text_Yell);
break;
}
}
bool AnubarAdds(Creature *pCreature)
{
mAddsSpawn = AddTimer (40000);
//fas1
if (fas == 1 && fas_stop == false)
{
_unit->GetMapMgr()->GetInterface()->SpawnCreature(29214, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0, 0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(29214, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0 ,0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(31599, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0 ,0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(31599, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0 ,0);
fas_stop = true;
}
if (fas == 1 && mAddsSpawn >= 15000 && mAddsSpawn <= 17000 && !IsTimerFinished( mPhaseSwitchTimer ))
{
_unit->GetMapMgr()->GetInterface()->SpawnCreature(29214, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0, 0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(29214, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0 ,0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(31599, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0 ,0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(31599, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0 ,0);
}
if (fas == 1 && mAddsSpawn >= 30000 && mAddsSpawn <= 32000 && !IsTimerFinished( mPhaseSwitchTimer ))
{
_unit->GetMapMgr()->GetInterface()->SpawnCreature(29214, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0, 0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(29214, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0 ,0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(31599, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0 ,0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(31599, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0 ,0);
}
//fas2
if (fas == 2 && fas_stop == false)
{
_unit->GetMapMgr()->GetInterface()->SpawnCreature(29214, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0, 0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(29214, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0 ,0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(31599, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0 ,0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(31599, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0 ,0);
fas_stop = true;
}
if (fas == 2 && mAddsSpawn >= 10000 && mAddsSpawn <= 12000 && !IsTimerFinished( mPhaseSwitchTimer ))
{
_unit->GetMapMgr()->GetInterface()->SpawnCreature(29214, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0, 0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(29214, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0 ,0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(31599, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0 ,0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(31599, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0 ,0);
}
if (fas == 2 && mAddsSpawn >= 20000 && mAddsSpawn <= 22000 && !IsTimerFinished( mPhaseSwitchTimer ))
{
_unit->GetMapMgr()->GetInterface()->SpawnCreature(29214, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0, 0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(29214, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0 ,0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(31599, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0 ,0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(31599, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ()+ rand()%30, 0, true, false, 0 ,0);
}
if (fas == 2 && mAddsSpawn >= 30000 && mAddsSpawn <= 32000 && !IsTimerFinished( mPhaseSwitchTimer ))
{
_unit->GetMapMgr()->GetInterface()->SpawnCreature(29214, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0, 0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(29214, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0 ,0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(31599, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0 ,0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(31599, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0 ,0);
}
//fas3
if (fas == 3 && fas_stop == false)
{
_unit->GetMapMgr()->GetInterface()->SpawnCreature(29214, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0, 0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(29214, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0 ,0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(31599, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0 ,0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(31599, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0 ,0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(29214, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0 ,0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(31599, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0 ,0);
fas_stop = true;
}
if (fas == 3 && mAddsSpawn >= 10000 && mAddsSpawn <= 12000 && !IsTimerFinished( mPhaseSwitchTimer ))
{
_unit->GetMapMgr()->GetInterface()->SpawnCreature(29214, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0, 0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(29214, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0 ,0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(31599, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0 ,0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(31599, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0 ,0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(29214, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0 ,0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(31599, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0 ,0);
}
if (fas == 3 && mAddsSpawn >= 20000 && mAddsSpawn <= 22000 && !IsTimerFinished( mPhaseSwitchTimer ))
{
_unit->GetMapMgr()->GetInterface()->SpawnCreature(29214, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0, 0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(29214, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0 ,0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(31599, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0 ,0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(31599, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0 ,0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(29214, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0 ,0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(31599, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0 ,0);
}
if (fas == 3 && mAddsSpawn >= 30000 && mAddsSpawn <= 32000 && !IsTimerFinished( mPhaseSwitchTimer ))
{
_unit->GetMapMgr()->GetInterface()->SpawnCreature(29214, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0, 0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(29214, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0 ,0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(31599, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0 ,0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(31599, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0 ,0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(29214, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0 ,0);
_unit->GetMapMgr()->GetInterface()->SpawnCreature(31599, _unit->GetPositionX() + rand()%30, _unit->GetPositionY() + rand()%30, _unit->GetPositionZ() + rand()%30, 0, true, false, 0 ,0);
}
return true;
}
SpellDesc* Submerge;
SpellDesc* LeechingSwarm;
SpellDesc* Pound;
SpellDesc* HcLeechingSwarm;
SpellDesc* HcPound;
int32 mPhaseSwitchTimer;
int32 mAddsSpawn;
};