/* 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" // **** This script is still under Developement **** struct MANGOS_DLL_DECL npc_lunaclawAI : public ScriptedAI { npc_lunaclawAI(Creature *c) : ScriptedAI(c) {EnterEvadeMode();} bool SummonDone; Creature* Summoned; float oldTargetRange; int32 waitDuration; void EnterEvadeMode() { SummonDone = false; /*** SpellSystem ***/ //For selecting spell case oldTargetRange = 0.0f; waitDuration = -1; m_creature->m_spellsCoolDown[CREATURE_SPELL_MAX+1] = -1; for( uint8 i=0; i < CREATURE_SPELL_MAX+1; i++ ) m_creature->m_spellsCoolDown[i] = -1; m_creature->RemoveAllAuras(); m_creature->DeleteThreatList(); m_creature->CombatStop(); DoGoHome(); } void AttackStart(Unit *attacker) { AIAttackStart(attacker); } void MoveInLineOfSight(Unit *who) { AISelectAction(who); } void UpdateAI(const uint32 diff) { //Waiting Time, Like Casting time or any other purpose if( waitDuration > 0 ) waitDuration -= diff; if( m_creature->isDead() ) return; //If we are within range melee the target, we try to swing it with our melee weapon. if( m_creature->SelectHostilTarget() && m_creature->getVictim() && m_creature->IsWithinDistInMap(m_creature->getVictim(), 5.0f)) { //Make sure our attack is ready. if( /*!AISelectFriend() &&*/ m_creature->isAttackReady() ) { m_creature->AttackerStateUpdate(m_creature->getVictim()); m_creature->resetAttackTimer(); } AISelectFriend(); } //Spell CoolDown for( uint8 i=0; i < CREATURE_SPELL_MAX+1; i++ ) if( m_creature->m_spellsCoolDown[i] > -1 ) m_creature->m_spellsCoolDown[i] -= diff; // enum CREATURE_SPELL_MAX, is used for global cooldown, so no need to add another. if( waitDuration < 0 && m_creature->m_spellsCoolDown[CREATURE_SPELL_MAX] < 0 && m_creature->GetUInt64Value(UNIT_FIELD_TARGET) ) AISelectSpell( oldTargetRange, waitDuration); } void JustDied(Unit* Killer) { if( !SummonDone ) Killer->SummonCreature(12144,Killer->GetPositionX(),Killer->GetPositionY(),Killer->GetPositionZ(),5.000,TEMPSUMMON_TIMED_DESPAWN,60000); //Killer->CastSpell(Killer, 18986, true); } }; CreatureAI* GetAI_npc_lunaclaw(Creature *_Creature) { return new npc_lunaclawAI (_Creature); } void AddSC_npc_lunaclaw() { Script *newscript; newscript = new Script; newscript->Name="npc_lunaclaw"; newscript->GetAI = GetAI_npc_lunaclaw; m_scripts[nrscripts++] = newscript; }