All pastes #835759 Raw Edit

Unbenannt

public text v1 · immutable
#835759 ·published 2007-12-29 00:48 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
#define SPELL_COBRAHN_SERPENT_FORM          7965
#define SPELL_HEALING_TOUCH                 5188
 
struct MANGOS_DLL_DECL boss_wailing_cavernsAI : public ScriptedAI
{
    boss_wailing_cavernsAI(Creature *c) : ScriptedAI(c) {EnterEvadeMode();}   
 
    uint32 Druids_Slumber_Timer;
    uint32 Cobrahn_Serpent_Timer;
    uint32 Healing_Touch_Timer;
	uint32 Cobrahn_Serpent_Counter
    bool InCombat;
 
    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 = 5000;
        Cobrahn_Serpent_Timer = 5000;
        Healing_Touch_Timer = 1000;
        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 = 5000;
            }
        }else Druids_Slumber_Timer -= diff;
 
        if (Cobrahn_Serpent_Timer < diff)
        {
            DoCast(m_creature,SPELL_COBRAHN_SERPENT_FORM);
            Cobrahn_Serpent_Timer = 5000;
            Cobrahn_Serpent_Counter++;
            if (Cobrahn_Serpent_Counter == 1;
			{
                Cobrahn_Serpent_Timer = 45000;
                Cobrahn_Serpent_Counter = 0;
			}
		}else Cobrahn_Serpent_Timer -= diff;
 
        if (m_creature->HasAura(SPELL_COBRAHN_SERPENT_FORM,0) && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 30))
        m_creature->RemoveAura(SPELL_COBRAHN_SERPENT_FORM,0);
 
        if (Healing_Touch_Timer < diff && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 25))
        {
            DoCast(m_creature,SPELL_HEALING_TOUCH);
            Healing_Touch_Timer = 1000;
        }else Healing_Touch_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_Lord_Cobrahn";
    newscript->GetAI = GetAI_boss_wailing_cavernsAI;
    m_scripts[nrscripts++] = newscript;
}