/* Copyright (C) 2006,2007 ScriptDev2 * 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_SERPENT_FORM 8041 #define SPELL_HEALING_TOUCH 5188 #define SPELL_WRATH 5178 struct MANGOS_DLL_DECL npc_druid_of_the_fangAI : public ScriptedAI { npc_druid_of_the_fangAI(Creature *c) : ScriptedAI(c) {EnterEvadeMode();} uint32 SlumberTimer; uint32 SerpentTimer; uint32 HealingTimer; uint32 WrathTimer; bool InCombat; void EnterEvadeMode() { m_creature->RemoveAllAuras(); m_creature->DeleteThreatList(); m_creature->CombatStop(); DoGoHome(); m_creature->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_INTERRUPT_CAST, true); SlumberTimer = 5000; SerpentTimer = 5000; HealingTimer = 1000; WrathTimer = 10000; 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(SlumberTimer < diff) { Unit* target = NULL; target = SelectUnit(SELECT_TARGET_RANDOM,1); if(target) { DoCast(target,SPELL_DRUIDS_SLUMBER); SlumberTimer = 5000; } }else SlumberTimer -= diff; if (!m_creature->HasAura(SPELL_SERPENT_FORM,0) && SerpentTimer < diff) { DoCast(m_creature,SPELL_SERPENT_FORM); SerpentTimer = 20000; }else SerpentTimer -= diff; if (m_creature->HasAura(SPELL_SERPENT_FORM,0) && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 10)) m_creature->RemoveAura(SPELL_SERPENT_FORM,0); if (!m_creature->HasAura(SPELL_SERPENT_FORM,0) && HealingTimer < diff && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 25)) { DoCast(m_creature,SPELL_HEALING_TOUCH); HealingTimer = 1000; }else HealingTimer -= diff; if (!m_creature->HasAura(SPELL_SERPENT_FORM,0) && WrathTimer < diff) { DoCast(m_creature->getVictim(),SPELL_WRATH); WrathTimer = 10000; }else WrathTimer -= diff; DoMeleeAttackIfReady(); } }; CreatureAI* GetAI_npc_druid_of_the_fangAI(Creature *_Creature) { return new npc_druid_of_the_fangAI (_Creature); } void AddSC_npc_Druid_of_the_Fang() { Script *newscript; newscript = new Script; newscript->Name="npc_druid_of_the_fang"; newscript->GetAI = GetAI_npc_druid_of_the_fangAI; m_scripts[nrscripts++] = newscript; }