TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
SimpleCharmedAI Class Reference

#include <UnitAI.h>

Public Member Functions

void UpdateAI (uint32 diff) override
 
 SimpleCharmedAI (Player *player)
 
- Public Member Functions inherited from PlayerAI
 PlayerAI (Player *player)
 
void OnCharmed (bool apply) override
 
- Public Member Functions inherited from UnitAI
 UnitAI (Unit *unit)
 
virtual ~UnitAI ()
 
virtual bool CanAIAttack (Unit const *) const
 
virtual void AttackStart (Unit *)
 
virtual void InitializeAI ()
 
virtual void Reset ()
 
virtual void DoAction (int32)
 
virtual uint32 GetData (uint32) const
 
virtual void SetData (uint32, uint32)
 
virtual void SetGUID (ObjectGuid, int32=0)
 
virtual ObjectGuid GetGUID (int32=0) const
 
UnitSelectTarget (SelectAggroTarget targetType, uint32 position=0, float dist=0.0f, bool playerOnly=false, int32 aura=0)
 
template<class PREDICATE >
UnitSelectTarget (SelectAggroTarget targetType, uint32 position, PREDICATE const &predicate)
 
void SelectTargetList (std::list< Unit * > &targetList, uint32 num, SelectAggroTarget targetType, float dist=0.0f, bool playerOnly=false, int32 aura=0)
 
template<class PREDICATE >
void SelectTargetList (std::list< Unit * > &targetList, PREDICATE const &predicate, uint32 maxTargets, SelectAggroTarget targetType)
 
virtual void DamageDealt (Unit *, uint32 &, DamageEffectType)
 
virtual void DamageTaken (Unit *, uint32 &)
 
virtual void HealReceived (Unit *, uint32 &)
 
virtual void HealDone (Unit *, uint32 &)
 
virtual void SpellInterrupted (uint32, uint32)
 
void AttackStartCaster (Unit *victim, float dist)
 
void DoCast (uint32 spellId)
 
void DoCast (Unit *victim, uint32 spellId, bool triggered=false)
 
void DoCastVictim (uint32 spellId, bool triggered=false)
 
void DoCastAOE (uint32 spellId, bool triggered=false)
 
void DoMeleeAttackIfReady ()
 
bool DoSpellAttackIfReady (uint32 spellId)
 
virtual void sGossipHello (Player *)
 
virtual void sGossipSelect (Player *, uint32, uint32)
 
virtual void sGossipSelectCode (Player *, uint32, uint32, char const *)
 
virtual void sQuestAccept (Player *, Quest const *)
 
virtual void sQuestSelect (Player *, Quest const *)
 
virtual void sQuestReward (Player *, Quest const *, uint32)
 
virtual bool sOnDummyEffect (Unit *, uint32, SpellEffIndex)
 
virtual void sOnGameEvent (bool, uint16)
 

Additional Inherited Members

- Static Public Member Functions inherited from UnitAI
static void FillAISpellInfo ()
 
- Static Public Attributes inherited from UnitAI
static AISpellInfoTypeAISpellInfo
 
- Protected Attributes inherited from PlayerAI
Player *const me
 
- Protected Attributes inherited from UnitAI
Unit *const me
 

Constructor & Destructor Documentation

SimpleCharmedAI::SimpleCharmedAI ( Player player)
inline
281 : PlayerAI(player) { }
PlayerAI(Player *player)
Definition: UnitAI.h:272

Member Function Documentation

void SimpleCharmedAI::UpdateAI ( uint32  diff)
overridevirtual

Implements UnitAI.

238 {
239  Creature* charmer = me->GetCharmer()->ToCreature();
240 
241  //kill self if charm aura has infinite duration
242  if (charmer->IsInEvadeMode())
243  {
244  Unit::AuraEffectList const& auras = me->GetAuraEffectsByType(SPELL_AURA_MOD_CHARM);
245  for (Unit::AuraEffectList::const_iterator iter = auras.begin(); iter != auras.end(); ++iter)
246  if ((*iter)->GetCasterGUID() == charmer->GetGUID() && (*iter)->GetBase()->IsPermanent())
247  {
248  charmer->Kill(me);
249  return;
250  }
251  }
252 
253  if (!charmer->IsInCombat())
254  me->GetMotionMaster()->MoveFollow(charmer, PET_FOLLOW_DIST, me->GetFollowAngle());
255 
256  Unit* target = me->GetVictim();
257  if (!target || !charmer->IsValidAttackTarget(target))
259 }
void Kill(Unit *victim, bool durabilityLoss=true)
Definition: Unit.cpp:13513
Definition: SpellAuraDefines.h:66
Unit * SelectNearestTargetInAttackDistance(float dist=0) const
Definition: Creature.cpp:1970
Player *const me
Definition: UnitAI.h:270
bool IsInCombat() const
Definition: Unit.h:1584
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
bool IsValidAttackTarget(Unit const *target) const
Definition: Unit.cpp:10002
bool IsInEvadeMode() const
Definition: Creature.h:520
Definition: Creature.h:467
ObjectGuid const & GetGUID() const
Definition: Object.h:105
#define PET_FOLLOW_DIST
Definition: PetDefines.h:77
Definition: Unit.h:1305
virtual void AttackStart(Unit *)
Definition: UnitAI.cpp:29

+ Here is the call graph for this function:


The documentation for this class was generated from the following files: