All pastes #835146 Raw Edit

Unbenannt

public text v1 · immutable
#835146 ·published 2007-12-28 18:41 UTC
rendered paste body
/* 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_DRUIDS_SLUMBER                8040

struct MANGOS_DLL_DECL boss_Wailing_CavernsAI : public ScriptedAI
{
    boss_Wailing_CavernsAI(Creature *c) : ScriptedAI(c) {EnterEvadeMode();}   

    uint32 Druids_Slumber_timer;

    void EnterEvadeMode()
    {   
        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_EFFECT, SPELL_EFFECT_INTERRUPT_CAST, true);
        m_creature->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_SILENCE, true); 
        m_creature->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_CONFUSED, true);
        m_creature->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_CHARM , true);
        m_creature->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_FEAR , true);
        m_creature->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_ROOT, true);
        m_creature->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_STUN, true);
        m_creature->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_FREEZE, true);
        m_creature->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_HORROR, true);
        m_creature->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_DAZE, true);
        m_creature->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_SLEEP, true);
        m_creature->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_BANISH, true);

        Druids_Slumber_timer = 15000+rand()%20;
        InCombat = false;
    }

    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)
    {
	    if (!m_creature->SelectHostilTarget() || !m_creature->getVictim())
            return;

        if(Druids_Slumber_timer < diff)
        {    
            Unit* target = NULL;
            target = SelectUnit(SELECT_TARGET_RANDOM,1);
            if(target) 
            {
                DoCast(target,SPELL_DRUIDS_SLUMBER);
                Druids_Slumber_timer = 15000+rand()%20;
            }
        }else Druids_Slumber_timer -= diff;
            
        DoMeleeAttackIfReady();
    }
};

CreatureAI* GetAI_boss_Wailing_CavernsAI(Creature *_Creature)
{
    return new boss_Wailing_CavernsAI (_Creature);
}

void AddSC_boss_Wailing_Caverns()
{
    Script *newscript;
    newscript = new Script;
    newscript->Name="boss_Wailing_Caverns";
    newscript->GetAI = GetAI_boss_Wailing_CavernsAI;
    m_scripts[nrscripts++] = newscript;
}