/* Copyright (C) 2006 - 2008 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 */ /* ScriptData SDName: npc_Guardian SD%Complete: 100 SDComment: GuardianAI used to prevent players from accessing off-limits areas SDCategory: NPCs EndScriptData */ #include "../sc_defines.h" #define SAY_AGGRO "PUT YOUR MESSAGE HERE struct MANGOS_DLL_DECL npc_guardian1AI : public ScriptedAI { npc_guardian1AI(Creature *c) : ScriptedAI(c) {EnterEvadeMode();} bool InCombat; void EnterEvadeMode() { InCombat = false; m_creature->RemoveAllAuras(); m_creature->DeleteThreatList(); m_creature->CombatStop(); DoGoHome(); m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); } void AttackStart(Unit *who) { if (!who) return; if (who->isTargetableForAttack() && who!= m_creature) { //Say our dialog if(!InCombat) { DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); InCombat = true; } DoStartMeleeAttack(who); } } 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) /2); if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= 1 && m_creature->IsWithinLOSInMap(who)) { if(who->HasStealthAura()) who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); } } } }; CreatureAI* GetAI_npc_guardian1(Creature *_Creature) { return new npc_guardian1AI (_Creature); } void AddSC_npc_guardian1() { Script *newscript; newscript = new Script; newscript->Name="npc_guardian1"; newscript->GetAI = GetAI_npc_guardian; m_scripts[nrscripts++] = newscript; }