AzerothCore 3.3.5a
OpenSource WoW Emulator
No Matches
SimpleCharmedAI Class Reference

#include "UnitAI.h"

Inheritance diagram for SimpleCharmedAI:
PlayerAI UnitAI

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 UpdateAI (uint32)=0
virtual void InitializeAI ()
virtual void Reset ()
virtual void OnCharmed (bool apply)=0
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 (SelectTargetMethod targetType, uint32 position=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
template<class PREDICATE >
UnitSelectTarget (SelectTargetMethod targetType, uint32 position, PREDICATE const &predicate)
void SelectTargetList (std::list< Unit * > &targetList, uint32 num, SelectTargetMethod targetType, uint32 position=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
template<class PREDICATE >
void SelectTargetList (std::list< Unit * > &targetList, uint32 num, SelectTargetMethod targetType, uint32 position, PREDICATE const &predicate)
virtual void JustEnteredCombat (Unit *)
 Called when the unit enters combat (NOTE: Creature engage logic should NOT be here, but in JustEngagedWith, which happens once threat is established!)
virtual void JustExitedCombat ()
 Called when the unit leaves combat.
virtual void DamageDealt (Unit *, uint32 &, DamageEffectType)
virtual void DamageTaken (Unit *, uint32 &, DamageEffectType, SpellSchoolMask)
virtual void HealReceived (Unit *, uint32 &)
virtual void HealDone (Unit *, uint32 &)
void AttackStartCaster (Unit *victim, float dist)
SpellCastResult DoAddAuraToAllHostilePlayers (uint32 spellid)
SpellCastResult DoCast (uint32 spellId)
SpellCastResult DoCast (Unit *victim, uint32 spellId, bool triggered=false)
SpellCastResult DoCastSelf (uint32 spellId, bool triggered=false)
SpellCastResult DoCastToAllHostilePlayers (uint32 spellid, bool triggered=false)
SpellCastResult DoCastVictim (uint32 spellId, bool triggered=false)
SpellCastResult DoCastAOE (uint32 spellId, bool triggered=false)
SpellCastResult DoCastRandomTarget (uint32 spellId, uint32 threatTablePosition=0, float dist=0.0f, bool playerOnly=true, bool triggered=false)
SpellCastResult DoCastMaxThreat (uint32 spellId, uint32 threatTablePosition=0, float dist=0.0f, bool playerOnly=true, bool triggered=false)
 Cast spell on the max threat target, which may not always be the current victim.
float DoGetSpellMaxRange (uint32 spellId, bool positive=false)
void DoMeleeAttackIfReady ()
bool DoSpellAttackIfReady (uint32 spell)
void DoSpellAttackToRandomTargetIfReady (uint32 spell, uint32 threatTablePosition=0, float dist=0.f, bool playerOnly=true)
virtual void SummonMovementInform (Creature *, uint32, uint32)
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 sQuestComplete (Player *, Quest const *)
virtual void sQuestReward (Player *, Quest const *, uint32)
virtual void sOnGameEvent (bool, uint16)
virtual std::string GetDebugInfo () const

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

Detailed Description

Constructor & Destructor Documentation

◆ SimpleCharmedAI()

SimpleCharmedAI::SimpleCharmedAI ( Player player)
420: PlayerAI(player) {}
Definition: UnitAI.h:407

Member Function Documentation

◆ UpdateAI()

void SimpleCharmedAI::UpdateAI ( uint32  diff)

Implements UnitAI.

359 Creature* charmer = me->GetCharmer()->ToCreature();
361 //kill self if charm aura has infinite duration
362 if (charmer->IsInEvadeMode())
363 {
365 for (Unit::AuraEffectList::const_iterator iter = auras.begin(); iter != auras.end(); ++iter)
366 if ((*iter)->GetCasterGUID() == charmer->GetGUID() && (*iter)->GetBase()->IsPermanent())
367 {
368 Unit::Kill(charmer, me);
369 return;
370 }
371 }
373 if (!charmer->IsInCombat())
376 Unit* target = me->GetVictim();
377 if (!target || !charmer->IsValidAttackTarget(target))
Definition: ObjectDefines.h:25
Definition: PetDefines.h:197
Definition: SpellAuraDefines.h:69
virtual void AttackStart(Unit *)
Definition: UnitAI.cpp:28
Player *const me
Definition: UnitAI.h:409
Definition: Creature.h:46
Unit * SelectNearestTargetInAttackDistance(float dist) const
Definition: Creature.cpp:2330
bool IsInEvadeMode() const
Definition: Creature.h:129
Creature * ToCreature()
Definition: Object.h:197
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:106
Definition: Unit.h:1302
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1979
Unit * GetCharmer() const
Definition: Unit.cpp:10599
static void Kill(Unit *killer, Unit *victim, bool durabilityLoss=true, WeaponAttackType attackType=BASE_ATTACK, SpellInfo const *spellProto=nullptr, Spell const *spell=nullptr)
Definition: Unit.cpp:17940
MotionMaster * GetMotionMaster()
Definition: Unit.h:2274
virtual float GetFollowAngle() const
Definition: Unit.h:2404
Unit * GetVictim() const
Definition: Unit.h:1398
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1318
bool IsValidAttackTarget(Unit const *target, SpellInfo const *bySpell=nullptr) const
Definition: Unit.cpp:13851
bool IsInCombat() const
Definition: Unit.h:1700
void MoveFollow(Unit *target, float dist, float angle, MovementSlot slot=MOTION_SLOT_ACTIVE)
Definition: MotionMaster.cpp:393

References ATTACK_DISTANCE, UnitAI::AttackStart(), Unit::GetAuraEffectsByType(), Unit::GetCharmer(), Unit::GetFollowAngle(), Object::GetGUID(), Unit::GetMotionMaster(), Unit::GetVictim(), Unit::IsInCombat(), Creature::IsInEvadeMode(), Unit::IsValidAttackTarget(), Unit::Kill(), PlayerAI::me, MotionMaster::MoveFollow(), PET_FOLLOW_DIST, Creature::SelectNearestTargetInAttackDistance(), SPELL_AURA_MOD_CHARM, and Object::ToCreature().