/* 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_SMASH 38761
#define SPELL_BLOW 33230
#define SPELL_WHIRLWIND 41061
#define SPELL_CHARGE 41581
#define SAY_AGGRO "Go get killed"
struct MANGOS_DLL_DECL boss_maulgarAI : public ScriptedAI
{
boss_gruulAI(Creature *c) : ScriptedAI(c) {EnterEvadeMode();}
uint32 Smash_Timer;
uint32 Blow_Timer;
uint32 Whirlwind_Timer;
uint32 Charge_Timer;
uint32 Phase;
bool InCombat;
void EnterEvadeMode()
{
Smash_Timer= 30000;
Blow_Timer= 40000;
Whirlwind_Timer= 35000;
Charge_Timer= 8000;
Phase = 1;
InCombat = false;
m_creature->RemoveAllAuras();
m_creature->DeleteThreatList();
m_creature->CombatStop();
DoGoHome();
}
void AttackStart(Unit *who)
{
if (!who)
return;
if (who->isTargetableForAttack() && who != m_creature)
{
//Begin attack
DoStartMeleeAttack(who);
if (!InCombat)
{
DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL);
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);
//Begin attack
DoStartMeleeAttack(who);
if (!InCombat)
{
DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL);
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())
{
//Arcing Smash
if (Smash_Timer < diff )
{
DoCast(m_creature->getVictim(),SPELL_SMASH);
Smash_Timer = 30000;
}else Smash_Timer -= diff;
// Mighty Blow
if (Blow_Timer < diff)
{
DoCast(m_creature->getVictim(),SPELL_BLOW);
Blow_Timer= 8000;
}else Blow_Timer -= diff;
// Whirlwind
if (Whirlwind_Timer < diff )
{
DoCast(m_creature->getVictim(),SPELL_WHIRLWIND);
Whirlwind_Timer = 45000;
}else Whirlwind_Timer -= diff;
// Random Charge
if (Charge_Timer < diff && Phase == 2)
{
Unit* target = NULL;
target = SelectUnit(SELECT_TARGET_RANDOM,0);
if(target)
DoCast(target,SPELL_CHARGE);
Charge_Timer =40000;
}else Charge_Timer -= diff;
// Phase 2 Random Charging
if (m_creature->GetHealth() <= m_creature->GetMaxHealth() / 2)
{
Phase = 2;
}
// resets everything
//m_creature->m_canMove = true;
Smash_Timer= 30000;
Blow_Timer= 40000;
Whirlwind_Timer= 35000;
Charge_Timer= 8000;
Phase = 1;
InCombat = false;
}
DoMeleeAttackIfReady();
}
};
CreatureAI* GetAI_boss_maulgar(Creature *_Creature)
{
return new boss_maulgarAI (_Creature);
}
void AddSC_boss_maulgar()
{
Script *newscript;
newscript = new Script;
newscript->Name="boss_maulgar";
newscript->GetAI = GetAI_boss_maulgar;
m_scripts[nrscripts++] = newscript;
}