TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ArcherAI Struct Reference

#include <CombatAI.h>

Public Member Functions

 ArcherAI (Creature *c)
 
void AttackStart (Unit *who) override
 
void UpdateAI (uint32 diff) override
 
- Public Member Functions inherited from CreatureAI
void Talk (uint8 id, WorldObject const *whisperTarget=nullptr)
 
 CreatureAI (Creature *creature)
 
virtual ~CreatureAI ()
 
void MoveInLineOfSight_Safe (Unit *who)
 == Reactions At ================================= More...
 
void TriggerAlert (Unit const *who) const
 
virtual bool CanRespawn ()
 
virtual void EnterEvadeMode (EvadeReason why=EVADE_REASON_OTHER)
 
virtual void EnterCombat (Unit *)
 
virtual void JustDied (Unit *)
 
virtual void KilledUnit (Unit *)
 
virtual void JustSummoned (Creature *)
 
virtual void IsSummonedBy (Unit *)
 
virtual void SummonedCreatureDespawn (Creature *)
 
virtual void SummonedCreatureDies (Creature *, Unit *)
 
virtual void SpellHit (Unit *, SpellInfo const *)
 
virtual void SpellHitTarget (Unit *, SpellInfo const *)
 
virtual void AttackedBy (Unit *)
 
virtual bool IsEscorted () const
 
virtual void JustRespawned ()
 
virtual void MovementInform (uint32, uint32)
 
void OnCharmed (bool apply) override
 
virtual void JustReachedHome ()
 
void DoZoneInCombat (Creature *creature=NULL, float maxRangeToNearestTarget=50.0f)
 
virtual void ReceiveEmote (Player *, uint32)
 
virtual void OwnerAttackedBy (Unit *)
 
virtual void OwnerAttacked (Unit *)
 
virtual void CorpseRemoved (uint32 &)
 == Triggered Actions Requested ================== More...
 
virtual void PassengerBoarded (Unit *, int8, bool)
 == Fields ======================================= More...
 
virtual void OnSpellClick (Unit *, bool &)
 
virtual bool CanSeeAlways (WorldObject const *)
 
int32 VisualizeBoundary (uint32 duration, Unit *owner=nullptr, bool fill=false) const
 
virtual bool CheckInRoom ()
 
CreatureBoundary constGetBoundary () const
 
- Public Member Functions inherited from UnitAI
 UnitAI (Unit *unit)
 
virtual ~UnitAI ()
 
virtual bool CanAIAttack (Unit const *) const
 
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)
 

Static Public Member Functions

static int Permissible (Creature const *)
 
- Static Public Member Functions inherited from UnitAI
static void FillAISpellInfo ()
 

Protected Attributes

float m_minRange
 
- Protected Attributes inherited from CreatureAI
Creature *const me
 
CreatureBoundary const_boundary
 
- Protected Attributes inherited from UnitAI
Unit *const me
 

Additional Inherited Members

- Public Types inherited from CreatureAI
enum  EvadeReason { EVADE_REASON_NO_HOSTILES, EVADE_REASON_BOUNDARY, EVADE_REASON_SEQUENCE_BREAK, EVADE_REASON_OTHER }
 
- Static Public Attributes inherited from UnitAI
static AISpellInfoTypeAISpellInfo
 
- Protected Member Functions inherited from CreatureAI
bool UpdateVictim ()
 
bool UpdateVictimWithGaze ()
 
void SetGazeOn (Unit *target)
 
CreatureDoSummon (uint32 entry, Position const &pos, uint32 despawnTime=30000, TempSummonType summonType=TEMPSUMMON_CORPSE_TIMED_DESPAWN)
 
CreatureDoSummon (uint32 entry, WorldObject *obj, float radius=5.0f, uint32 despawnTime=30000, TempSummonType summonType=TEMPSUMMON_CORPSE_TIMED_DESPAWN)
 
CreatureDoSummonFlyer (uint32 entry, WorldObject *obj, float flightZ, float radius=5.0f, uint32 despawnTime=30000, TempSummonType summonType=TEMPSUMMON_CORPSE_TIMED_DESPAWN)
 
bool CheckBoundary (Position const *who=nullptr) const
 
void SetBoundary (CreatureBoundary const *boundary)
 
virtual void MoveInLineOfSight (Unit *)
 
bool _EnterEvadeMode (EvadeReason why=EVADE_REASON_OTHER)
 

Constructor & Destructor Documentation

ArcherAI::ArcherAI ( Creature c)
explicit
175  : CreatureAI(c)
176 {
177  if (!me->m_spells[0])
178  TC_LOG_ERROR("misc", "ArcherAI set for creature (entry = %u) with spell1=0. AI will do nothing", me->GetEntry());
179 
180  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(me->m_spells[0]);
181  m_minRange = spellInfo ? spellInfo->GetMinRange(false) : 0;
182 
183  if (!m_minRange)
185  me->m_CombatDistance = spellInfo ? spellInfo->GetMaxRange(false) : 0;
187 }
Definition: SpellInfo.h:326
Creature *const me
Definition: CreatureAI.h:71
uint32 m_spells[CREATURE_MAX_SPELLS]
Definition: Creature.h:602
#define sSpellMgr
Definition: SpellMgr.h:756
float m_SightDistance
Definition: Creature.h:704
CreatureAI(Creature *creature)
Definition: CreatureAI.h:95
uint32 GetEntry() const
Definition: Object.h:107
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
#define MELEE_RANGE
Definition: Object.h:48
float m_CombatDistance
Definition: Creature.h:704
float m_minRange
Definition: CombatAI.h:80

+ Here is the call graph for this function:

Member Function Documentation

void ArcherAI::AttackStart ( Unit who)
overridevirtual

Reimplemented from UnitAI.

190 {
191  if (!who)
192  return;
193 
194  if (me->IsWithinCombatRange(who, m_minRange))
195  {
196  if (me->Attack(who, true) && !who->IsFlying())
197  me->GetMotionMaster()->MoveChase(who);
198  }
199  else
200  {
201  if (me->Attack(who, false) && !who->IsFlying())
203  }
204 
205  if (who->IsFlying())
207 }
bool IsWithinCombatRange(const Unit *obj, float dist2compare) const
Definition: Unit.cpp:492
bool Attack(Unit *victim, bool meleeAttack)
Definition: Unit.cpp:7222
bool IsFlying() const
Definition: Unit.h:2189
void MoveIdle()
Definition: MotionMaster.cpp:185
void MoveChase(Unit *target, float dist=0.0f, float angle=0.0f)
Definition: MotionMaster.cpp:241
MotionMaster * GetMotionMaster()
Definition: Unit.h:2101
Creature *const me
Definition: CreatureAI.h:71
float m_CombatDistance
Definition: Creature.h:704
float m_minRange
Definition: CombatAI.h:80

+ Here is the call graph for this function:

static int ArcherAI::Permissible ( Creature const )
inlinestatic
77 { return PERMIT_BASE_NO; }
Definition: CreatureAI.h:207
void ArcherAI::UpdateAI ( uint32  diff)
overridevirtual

Implements UnitAI.

210 {
211  if (!UpdateVictim())
212  return;
213 
216  else
218 }
bool IsWithinCombatRange(const Unit *obj, float dist2compare) const
Definition: Unit.cpp:492
bool UpdateVictim()
Definition: CreatureAI.cpp:233
bool DoSpellAttackIfReady(uint32 spellId)
Definition: UnitAI.cpp:73
Creature *const me
Definition: CreatureAI.h:71
uint32 m_spells[CREATURE_MAX_SPELLS]
Definition: Creature.h:602
Unit * GetVictim() const
Definition: Unit.h:1379
void DoMeleeAttackIfReady()
Definition: UnitAI.cpp:49
float m_minRange
Definition: CombatAI.h:80

+ Here is the call graph for this function:

Member Data Documentation

float ArcherAI::m_minRange
protected

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