/* Copyright (C) 2006,2007 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "../../sc_defines.h"
#define SPELL_VOIDBLAST 32325
#define SPELL_DARKSHELL 32358
struct MANGOS_DLL_DECL boss_pandemoniusAI : public ScriptedAI
{
boss_pandemoniusAI(Creature *c) : ScriptedAI(c) {EnterEvadeMode();}
uint32 VoidBlast_Timer;
uint32 DarkShell_Timer;
bool InCombat;
void EnterEvadeMode()
{
VoidBlast_Timer = 25000;
DarkShell_Timer = 5000;
InCombat = false;
m_creature->RemoveAllAuras();
m_creature->DeleteThreatList();
m_creature->CombatStop();
DoGoHome();
m_creature->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_DISARM, true);
m_creature->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_POLYMORPH, true);
m_creature->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_INTERRUPTED, true);
m_creature->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_DAZED, true);
m_creature->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_FEAR, true);
m_creature->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_SILENCE, true);
m_creature->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_STUN, true);
m_creature->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_INTERRUPT_CAST, true);
}
void AttackStart(Unit *who)
{
if (!who)
return;
if (who->isTargetableForAttack() && who!= m_creature)
{
//Begin melee attack if we are within range
DoStartMeleeAttack(who);
InCombat = true;
}
}
void MoveInLineOfSight(Unit *who)
{
if (!who || m_creature->getVictim())
return;
if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who))
{
float attackRadius = m_creature->GetAttackDistance(who);
if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who))
{
if(who->HasStealthAura())
who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);
DoStartMeleeAttack(who);
InCombat = true;
}
}
}
void UpdateAI(const uint32 diff)
{
//Return since we have no target
if (!m_creature->SelectHostilTarget())
return;
//Check if we have a current target
if( m_creature->getVictim() && m_creature->isAlive())
{
//DarkShell_Timer
if (DarkShell_Timer < diff)
{
//Cast
DoCast(m_creature->getVictim(),SPELL_SHADOWBOLT);
//7 seconds until we should cast this agian
ShadowBolt_Timer = 5000;
}else DarkShell_Timer -= diff;
//VoidBlast_Timer
if (VoidBlast_Timer < diff)
{
//Cast
Unit* target = NULL;
target = SelectUnit(SELECT_TARGET_RANDOM,0);
if (target)
DoCast(target,SPELL_RAINOFFIRE);
//20 seconds until we should cast this agian
VoidBlast_Timer = 25000;
}else VoidBlast_Timer -= diff;
DoMeleeAttackIfReady();
}
}
};
CreatureAI* GetAI_boss_pandemonius(Creature *_Creature)
{
return new boss_pandemoniusAI (_Creature);
}
void AddSC_boss_pandemonius()
{
Script *newscript;
newscript = new Script;
newscript->Name="boss_pandemonius";
newscript->GetAI = GetAI_boss_pandemonius;
m_scripts[nrscripts++] = newscript;
}