2009-05-10 16:07:49 -05:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
|
|
|
|
*
|
2010-01-16 20:19:18 +03:00
|
|
|
* Copyright (C) 2008-2010 Trinity <http://www.trinitycore.org/>
|
2009-05-10 16:07:49 -05:00
|
|
|
*
|
|
|
|
|
* 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
|
|
|
|
|
*/
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-10 16:07:49 -05:00
|
|
|
#include "UnitAI.h"
|
2009-05-12 00:52:16 -05:00
|
|
|
#include "Player.h"
|
|
|
|
|
#include "Creature.h"
|
2009-05-10 16:07:49 -05:00
|
|
|
#include "SpellAuras.h"
|
2010-01-10 01:23:15 +01:00
|
|
|
#include "SpellAuraEffects.h"
|
2009-05-20 11:44:38 -05:00
|
|
|
#include "SpellMgr.h"
|
|
|
|
|
#include "CreatureAIImpl.h"
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-10 16:07:49 -05:00
|
|
|
void UnitAI::AttackStart(Unit *victim)
|
|
|
|
|
{
|
2009-05-20 11:44:38 -05:00
|
|
|
if(victim && me->Attack(victim, true))
|
2009-05-10 16:07:49 -05:00
|
|
|
me->GetMotionMaster()->MoveChase(victim);
|
2009-05-20 11:44:38 -05:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-20 11:44:38 -05:00
|
|
|
void UnitAI::AttackStartCaster(Unit *victim, float dist)
|
|
|
|
|
{
|
|
|
|
|
if(victim && me->Attack(victim, false))
|
|
|
|
|
me->GetMotionMaster()->MoveChase(victim, dist);
|
2009-05-10 16:07:49 -05:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-10 16:07:49 -05:00
|
|
|
void UnitAI::DoMeleeAttackIfReady()
|
|
|
|
|
{
|
2009-05-10 22:48:22 -05:00
|
|
|
if(me->hasUnitState(UNIT_STAT_CASTING))
|
|
|
|
|
return;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-10 16:07:49 -05:00
|
|
|
//Make sure our attack is ready and we aren't currently casting before checking distance
|
2009-05-10 22:48:22 -05:00
|
|
|
if (me->isAttackReady())
|
2009-05-10 16:07:49 -05:00
|
|
|
{
|
|
|
|
|
//If we are within range melee the target
|
|
|
|
|
if (me->IsWithinMeleeRange(me->getVictim()))
|
|
|
|
|
{
|
|
|
|
|
me->AttackerStateUpdate(me->getVictim());
|
|
|
|
|
me->resetAttackTimer();
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-05-10 22:48:22 -05:00
|
|
|
if (me->haveOffhandWeapon() && me->isAttackReady(OFF_ATTACK))
|
2009-05-10 16:07:49 -05:00
|
|
|
{
|
|
|
|
|
//If we are within range melee the target
|
|
|
|
|
if (me->IsWithinMeleeRange(me->getVictim()))
|
|
|
|
|
{
|
|
|
|
|
me->AttackerStateUpdate(me->getVictim(), OFF_ATTACK);
|
|
|
|
|
me->resetAttackTimer(OFF_ATTACK);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-20 11:44:38 -05:00
|
|
|
bool UnitAI::DoSpellAttackIfReady(uint32 spell)
|
|
|
|
|
{
|
|
|
|
|
if(me->hasUnitState(UNIT_STAT_CASTING))
|
|
|
|
|
return true;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-20 11:44:38 -05:00
|
|
|
if(me->isAttackReady())
|
|
|
|
|
{
|
|
|
|
|
if(me->IsWithinCombatRange(me->getVictim(), GetSpellMaxRange(spell, false)))
|
|
|
|
|
{
|
|
|
|
|
me->CastSpell(me->getVictim(), spell, false);
|
|
|
|
|
me->resetAttackTimer();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-20 11:44:38 -05:00
|
|
|
inline bool SelectTargetHelper(const Unit * me, const Unit * target, const bool &playerOnly, const float &dist, const int32 &aura)
|
|
|
|
|
{
|
2009-09-20 19:07:53 -07:00
|
|
|
if(playerOnly && (!target || target->GetTypeId() != TYPEID_PLAYER))
|
2009-05-20 11:44:38 -05:00
|
|
|
return false;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-09-20 19:07:53 -07:00
|
|
|
if(dist && (!me || !target || !me->IsWithinCombatRange(target, dist)))
|
2009-05-20 11:44:38 -05:00
|
|
|
return false;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-20 11:44:38 -05:00
|
|
|
if(aura)
|
|
|
|
|
{
|
|
|
|
|
if(aura > 0)
|
|
|
|
|
{
|
|
|
|
|
if(!target->HasAura(aura))
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if(target->HasAura(aura))
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-20 11:44:38 -05:00
|
|
|
return true;
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-20 11:44:38 -05:00
|
|
|
struct TargetDistanceOrder : public std::binary_function<const Unit *, const Unit *, bool>
|
|
|
|
|
{
|
|
|
|
|
const Unit * me;
|
|
|
|
|
TargetDistanceOrder(const Unit* Target) : me(Target) {};
|
|
|
|
|
// functor for operator ">"
|
|
|
|
|
bool operator()(const Unit * _Left, const Unit * _Right) const
|
|
|
|
|
{
|
2009-08-23 00:46:21 -05:00
|
|
|
return (me->GetExactDistSq(_Left) < me->GetExactDistSq(_Right));
|
2009-05-20 11:44:38 -05:00
|
|
|
}
|
|
|
|
|
};
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-20 11:44:38 -05:00
|
|
|
Unit* UnitAI::SelectTarget(SelectAggroTarget targetType, uint32 position, float dist, bool playerOnly, int32 aura)
|
|
|
|
|
{
|
2010-01-29 19:46:30 +01:00
|
|
|
const std::list<HostilReference *> &threatlist = me->getThreatManager().getThreatList();
|
|
|
|
|
std::list<Unit*> targetList;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2010-01-29 19:46:30 +01:00
|
|
|
if (position >= threatlist.size())
|
|
|
|
|
return NULL;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2010-01-29 19:46:30 +01:00
|
|
|
for (std::list<HostilReference*>::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr)
|
|
|
|
|
if (SelectTargetHelper(me, (*itr)->getTarget(), playerOnly, dist, aura))
|
|
|
|
|
targetList.push_back((*itr)->getTarget());
|
|
|
|
|
|
|
|
|
|
if (position >= targetList.size())
|
|
|
|
|
return NULL;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2010-01-29 19:46:30 +01:00
|
|
|
if (targetType == SELECT_TARGET_NEAREST || targetType == SELECT_TARGET_FARTHEST)
|
2009-05-20 11:44:38 -05:00
|
|
|
targetList.sort(TargetDistanceOrder(me));
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2010-01-29 19:46:30 +01:00
|
|
|
switch(targetType)
|
2009-05-20 11:44:38 -05:00
|
|
|
{
|
2010-01-29 19:46:30 +01:00
|
|
|
case SELECT_TARGET_NEAREST:
|
|
|
|
|
case SELECT_TARGET_TOPAGGRO:
|
2009-05-20 11:44:38 -05:00
|
|
|
{
|
2010-01-29 19:46:30 +01:00
|
|
|
std::list<Unit*>::iterator itr = targetList.begin();
|
|
|
|
|
advance(itr, position);
|
|
|
|
|
return *itr;
|
2009-05-20 11:44:38 -05:00
|
|
|
}
|
2010-01-29 19:46:30 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case SELECT_TARGET_FARTHEST:
|
|
|
|
|
case SELECT_TARGET_BOTTOMAGGRO:
|
2009-05-20 11:44:38 -05:00
|
|
|
{
|
2010-01-29 19:46:30 +01:00
|
|
|
std::list<Unit*>::reverse_iterator ritr = targetList.rbegin();
|
|
|
|
|
advance(ritr, position);
|
|
|
|
|
return *ritr;
|
2009-05-20 11:44:38 -05:00
|
|
|
}
|
2010-01-29 19:46:30 +01:00
|
|
|
break;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2010-01-29 19:46:30 +01:00
|
|
|
case SELECT_TARGET_RANDOM:
|
|
|
|
|
{
|
|
|
|
|
std::list<Unit*>::iterator itr = targetList.begin();
|
|
|
|
|
advance(itr, urand(position, targetList.size()-1));
|
|
|
|
|
return *itr;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2009-05-20 11:44:38 -05:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-20 11:44:38 -05:00
|
|
|
return NULL;
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-20 11:44:38 -05:00
|
|
|
void UnitAI::SelectTargetList(std::list<Unit*> &targetList, uint32 num, SelectAggroTarget targetType, float dist, bool playerOnly, int32 aura)
|
|
|
|
|
{
|
2010-01-29 19:46:30 +01:00
|
|
|
const std::list<HostilReference*> &threatlist = me->getThreatManager().getThreatList();
|
|
|
|
|
|
|
|
|
|
if (threatlist.empty())
|
|
|
|
|
return;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2010-01-29 19:46:30 +01:00
|
|
|
for (std::list<HostilReference*>::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr)
|
|
|
|
|
if (SelectTargetHelper(me, (*itr)->getTarget(), playerOnly, dist, aura))
|
|
|
|
|
targetList.push_back((*itr)->getTarget());
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2010-01-29 19:46:30 +01:00
|
|
|
if (targetType == SELECT_TARGET_NEAREST || targetType == SELECT_TARGET_FARTHEST)
|
2009-05-20 11:44:38 -05:00
|
|
|
targetList.sort(TargetDistanceOrder(me));
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2010-01-29 19:46:30 +01:00
|
|
|
if (targetType == SELECT_TARGET_FARTHEST || targetType == SELECT_TARGET_BOTTOMAGGRO)
|
|
|
|
|
targetList.reverse();
|
|
|
|
|
|
2010-01-30 22:42:04 +01:00
|
|
|
if (targetList.size() < num)
|
|
|
|
|
return;
|
|
|
|
|
|
2010-01-29 19:46:30 +01:00
|
|
|
if (targetType == SELECT_TARGET_RANDOM)
|
|
|
|
|
{
|
2010-01-30 22:42:04 +01:00
|
|
|
while (num < targetList.size()) {
|
2010-01-29 19:46:30 +01:00
|
|
|
std::list<Unit*>::iterator itr = targetList.begin();
|
|
|
|
|
advance(itr, urand(0, targetList.size()-1));
|
|
|
|
|
targetList.erase(itr);
|
2009-05-20 11:44:38 -05:00
|
|
|
}
|
|
|
|
|
}
|
2010-01-29 19:46:30 +01:00
|
|
|
else
|
|
|
|
|
targetList.resize(num);
|
2009-05-20 11:44:38 -05:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-08-17 22:34:18 -05:00
|
|
|
float UnitAI::DoGetSpellMaxRange(uint32 spellId, bool positive)
|
|
|
|
|
{
|
|
|
|
|
return GetSpellMaxRange(spellId, positive);
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-11-13 16:34:04 +01:00
|
|
|
void UnitAI::DoAddAuraToAllHostilePlayers(uint32 spellid)
|
|
|
|
|
{
|
|
|
|
|
if (me->isInCombat())
|
|
|
|
|
{
|
|
|
|
|
std::list<HostilReference*>& threatlist = me->getThreatManager().getThreatList();
|
|
|
|
|
for (std::list<HostilReference*>::iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr)
|
|
|
|
|
{
|
|
|
|
|
if (Unit *pTemp = Unit::GetUnit(*me,(*itr)->getUnitGuid()))
|
|
|
|
|
if (pTemp->GetTypeId() == TYPEID_PLAYER)
|
|
|
|
|
me->AddAura(spellid, pTemp);
|
|
|
|
|
}
|
|
|
|
|
}else
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UnitAI::DoCastToAllHostilePlayers(uint32 spellid, bool triggered)
|
|
|
|
|
{
|
|
|
|
|
if (me->isInCombat())
|
|
|
|
|
{
|
|
|
|
|
std::list<HostilReference*>& threatlist = me->getThreatManager().getThreatList();
|
|
|
|
|
for (std::list<HostilReference*>::iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr)
|
|
|
|
|
{
|
|
|
|
|
if (Unit *pTemp = Unit::GetUnit(*me,(*itr)->getUnitGuid()))
|
|
|
|
|
if (pTemp->GetTypeId() == TYPEID_PLAYER)
|
|
|
|
|
me->CastSpell(pTemp, spellid, triggered);
|
|
|
|
|
}
|
|
|
|
|
}else
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-20 11:44:38 -05:00
|
|
|
void UnitAI::DoCast(uint32 spellId)
|
|
|
|
|
{
|
|
|
|
|
Unit *target = NULL;
|
|
|
|
|
//sLog.outError("aggre %u %u", spellId, (uint32)AISpellInfo[spellId].target);
|
|
|
|
|
switch(AISpellInfo[spellId].target)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
case AITARGET_SELF: target = me; break;
|
|
|
|
|
case AITARGET_VICTIM: target = me->getVictim(); break;
|
|
|
|
|
case AITARGET_ENEMY:
|
|
|
|
|
{
|
|
|
|
|
const SpellEntry * spellInfo = GetSpellStore()->LookupEntry(spellId);
|
|
|
|
|
bool playerOnly = spellInfo->AttributesEx3 & SPELL_ATTR_EX3_PLAYERS_ONLY;
|
|
|
|
|
float range = GetSpellMaxRange(spellInfo, false);
|
|
|
|
|
target = SelectTarget(SELECT_TARGET_RANDOM, 0, GetSpellMaxRange(spellInfo, false), playerOnly);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case AITARGET_ALLY: target = me; break;
|
|
|
|
|
case AITARGET_BUFF: target = me; break;
|
|
|
|
|
case AITARGET_DEBUFF:
|
|
|
|
|
{
|
|
|
|
|
const SpellEntry * spellInfo = GetSpellStore()->LookupEntry(spellId);
|
|
|
|
|
bool playerOnly = spellInfo->AttributesEx3 & SPELL_ATTR_EX3_PLAYERS_ONLY;
|
|
|
|
|
float range = GetSpellMaxRange(spellInfo, false);
|
|
|
|
|
if(!(spellInfo->Attributes & SPELL_ATTR_BREAKABLE_BY_DAMAGE)
|
|
|
|
|
&& !(spellInfo->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_VICTIM)
|
|
|
|
|
&& SelectTargetHelper(me, me->getVictim(), playerOnly, range, -(int32)spellId))
|
|
|
|
|
target = me->getVictim();
|
|
|
|
|
else
|
|
|
|
|
target = SelectTarget(SELECT_TARGET_RANDOM, 0, range, playerOnly, -(int32)spellId);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-20 11:44:38 -05:00
|
|
|
if(target)
|
|
|
|
|
me->CastSpell(target, spellId, false);
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-20 11:44:38 -05:00
|
|
|
#define UPDATE_TARGET(a) {if(AIInfo->target<a) AIInfo->target=a;}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-20 11:44:38 -05:00
|
|
|
void UnitAI::FillAISpellInfo()
|
|
|
|
|
{
|
|
|
|
|
AISpellInfo = new AISpellInfoType[GetSpellStore()->GetNumRows()];
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-20 11:44:38 -05:00
|
|
|
AISpellInfoType *AIInfo = AISpellInfo;
|
|
|
|
|
const SpellEntry * spellInfo;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-10-17 16:20:24 -07:00
|
|
|
for (uint32 i = 0; i < GetSpellStore()->GetNumRows(); ++i, ++AIInfo)
|
2009-05-20 11:44:38 -05:00
|
|
|
{
|
|
|
|
|
spellInfo = GetSpellStore()->LookupEntry(i);
|
|
|
|
|
if(!spellInfo)
|
|
|
|
|
continue;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-20 11:44:38 -05:00
|
|
|
if(spellInfo->Attributes & SPELL_ATTR_CASTABLE_WHILE_DEAD)
|
|
|
|
|
AIInfo->condition = AICOND_DIE;
|
|
|
|
|
else if(IsPassiveSpell(i) || GetSpellDuration(spellInfo) == -1)
|
|
|
|
|
AIInfo->condition = AICOND_AGGRO;
|
|
|
|
|
else
|
|
|
|
|
AIInfo->condition = AICOND_COMBAT;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-20 11:44:38 -05:00
|
|
|
if(AIInfo->cooldown < spellInfo->RecoveryTime)
|
|
|
|
|
AIInfo->cooldown = spellInfo->RecoveryTime;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-20 11:44:38 -05:00
|
|
|
if(!GetSpellMaxRange(spellInfo, false))
|
|
|
|
|
UPDATE_TARGET(AITARGET_SELF)
|
|
|
|
|
else
|
|
|
|
|
{
|
2009-10-17 16:20:24 -07:00
|
|
|
for (uint32 j = 0; j < 3; ++j)
|
2009-05-20 11:44:38 -05:00
|
|
|
{
|
|
|
|
|
uint32 targetType = spellInfo->EffectImplicitTargetA[j];
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-20 11:44:38 -05:00
|
|
|
if(targetType == TARGET_UNIT_TARGET_ENEMY
|
|
|
|
|
|| targetType == TARGET_DST_TARGET_ENEMY)
|
|
|
|
|
UPDATE_TARGET(AITARGET_VICTIM)
|
|
|
|
|
else if(targetType == TARGET_UNIT_AREA_ENEMY_DST)
|
|
|
|
|
UPDATE_TARGET(AITARGET_ENEMY)
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-20 11:44:38 -05:00
|
|
|
if(spellInfo->Effect[j] == SPELL_EFFECT_APPLY_AURA)
|
|
|
|
|
{
|
|
|
|
|
if(targetType == TARGET_UNIT_TARGET_ENEMY)
|
|
|
|
|
UPDATE_TARGET(AITARGET_DEBUFF)
|
|
|
|
|
else if(IsPositiveSpell(i))
|
|
|
|
|
UPDATE_TARGET(AITARGET_BUFF)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-08-06 23:10:36 +02:00
|
|
|
AIInfo->realCooldown = spellInfo->RecoveryTime + spellInfo->StartRecoveryTime;
|
|
|
|
|
SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(spellInfo->rangeIndex);
|
|
|
|
|
if (srange)
|
|
|
|
|
AIInfo->maxRange = srange->maxRangeHostile * 3 / 4;
|
2009-05-20 11:44:38 -05:00
|
|
|
}
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-10 16:07:49 -05:00
|
|
|
//Enable PlayerAI when charmed
|
|
|
|
|
void PlayerAI::OnCharmed(bool apply) { me->IsAIEnabled = apply; }
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-10 16:07:49 -05:00
|
|
|
void SimpleCharmedAI::UpdateAI(const uint32 /*diff*/)
|
|
|
|
|
{
|
|
|
|
|
Creature *charmer = (Creature*)me->GetCharmer();
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-10 16:07:49 -05:00
|
|
|
//kill self if charm aura has infinite duration
|
|
|
|
|
if(charmer->IsInEvadeMode())
|
|
|
|
|
{
|
2010-01-10 01:23:15 +01:00
|
|
|
Unit::AuraEffectList const& auras = me->GetAuraEffectsByType(SPELL_AURA_MOD_CHARM);
|
2009-10-17 16:20:24 -07:00
|
|
|
for (Unit::AuraEffectList::const_iterator iter = auras.begin(); iter != auras.end(); ++iter)
|
2010-01-10 01:23:15 +01:00
|
|
|
if((*iter)->GetCasterGUID() == charmer->GetGUID() && (*iter)->GetBase()->IsPermanent())
|
2009-05-10 16:07:49 -05:00
|
|
|
{
|
|
|
|
|
charmer->Kill(me);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-10 16:07:49 -05:00
|
|
|
if(!charmer->isInCombat())
|
2009-07-22 17:10:30 +02:00
|
|
|
me->GetMotionMaster()->MoveFollow(charmer, PET_FOLLOW_DIST, me->GetFollowAngle());
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-10 16:07:49 -05:00
|
|
|
Unit *target = me->getVictim();
|
|
|
|
|
if(!target || !charmer->canAttack(target))
|
|
|
|
|
AttackStart(charmer->SelectNearestTarget());
|
|
|
|
|
}
|