AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
boss_faction_championsAI Struct Reference
Inheritance diagram for boss_faction_championsAI:
ScriptedAI CreatureAI UnitAI npc_toc_boomkin::npc_toc_boomkinAI npc_toc_dk::npc_toc_dkAI npc_toc_druid::npc_toc_druidAI npc_toc_enh_shaman::npc_toc_enh_shamanAI npc_toc_hunter::npc_toc_hunterAI npc_toc_mage::npc_toc_mageAI npc_toc_paladin::npc_toc_paladinAI npc_toc_pet_hunter::npc_toc_pet_hunterAI npc_toc_pet_warlock::npc_toc_pet_warlockAI npc_toc_priest::npc_toc_priestAI npc_toc_retro_paladin::npc_toc_retro_paladinAI npc_toc_rogue::npc_toc_rogueAI npc_toc_shadow_priest::npc_toc_shadow_priestAI npc_toc_shaman::npc_toc_shamanAI npc_toc_warlock::npc_toc_warlockAI npc_toc_warrior::npc_toc_warriorAI

Public Member Functions

 boss_faction_championsAI (Creature *pCreature, uint32 aitype)
 
void JustEngagedWith (Unit *) override
 Called for reaction when initially engaged.
 
void AttackStart (Unit *who) override
 
float GetThreatMod (float dist, float, uint32 health, uint32, Unit *target)
 
void RecalculateThreat ()
 
void EventMapGCD (EventMap &e, uint32 delay, uint32 gcd=0)
 
void JustDied (Unit *) override
 
void KilledUnit (Unit *) override
 
void EnterEvadeMode (EvadeReason) override
 
bool IsCCed ()
 
CreatureSelectTarget_MostHPLostFriendlyMissingBuff (uint32 spell, float range)
 
uint32 EnemiesInRange (float distance)
 
UnitSelectEnemyCaster (bool casting, float range)
 
void UpdateAI (uint32 diff) override
 
- Public Member Functions inherited from ScriptedAI
 ScriptedAI (Creature *creature)
 
 ~ScriptedAI () override
 
void AttackStartNoMove (Unit *target)
 
void DamageTaken (Unit *, uint32 &, DamageEffectType, SpellSchoolMask) override
 
void UpdateAI (uint32 diff) override
 
void JustDied (Unit *) override
 
void KilledUnit (Unit *) override
 
void JustSummoned (Creature *) override
 
void SummonedCreatureDespawn (Creature *) override
 
void SpellHit (Unit *, SpellInfo const *) override
 
void SpellHitTarget (Unit *, SpellInfo const *) override
 
void MovementInform (uint32, uint32) override
 
void OnPossess (bool)
 
bool IsInRoom (const Position *pos, Axis axis, bool above)
 
void Reset () override
 
void JustEngagedWith (Unit *) override
 Called for reaction when initially engaged.
 
void AttackStart (Unit *) override
 
void DoStartMovement (Unit *target, float distance=0.0f, float angle=0.0f)
 
void DoStartNoMovement (Unit *target)
 
void DoStopAttack ()
 
void DoCastSpell (Unit *target, SpellInfo const *spellInfo, bool triggered=false)
 
void DoPlaySoundToSet (WorldObject *source, uint32 soundId)
 
void DoPlayMusic (uint32 soundId, bool zone)
 
void DoAddThreat (Unit *unit, float amount)
 
void DoModifyThreatByPercent (Unit *unit, int32 pct)
 
void DoResetThreat (Unit *unit)
 
void DoResetThreatList ()
 
float DoGetThreat (Unit *unit)
 
void DoTeleportPlayer (Unit *unit, float x, float y, float z, float o)
 
void DoTeleportAll (float x, float y, float z, float o)
 
UnitDoSelectLowestHpFriendly (float range, uint32 minHPDiff=1)
 
std::list< Creature * > DoFindFriendlyCC (float range)
 
std::list< Creature * > DoFindFriendlyMissingBuff (float range, uint32 spellId)
 
PlayerGetPlayerAtMinimumRange (float minRange)
 
CreatureDoSpawnCreature (uint32 entry, float offsetX, float offsetY, float offsetZ, float angle, uint32 type, uint32 despawntime)
 
bool HealthBelowPct (uint32 pct) const
 
bool HealthAbovePct (uint32 pct) const
 
SpellInfo const * SelectSpell (Unit *target, uint32 school, uint32 mechanic, SelectTargetType targets, uint32 powerCostMin, uint32 powerCostMax, float rangeMin, float rangeMax, SelectEffect effect)
 
void SetEquipmentSlots (bool loadDefault, int32 mainHand=EQUIP_NO_CHANGE, int32 offHand=EQUIP_NO_CHANGE, int32 ranged=EQUIP_NO_CHANGE)
 
void SetCombatMovement (bool allowMovement)
 
bool IsCombatMovementAllowed () const
 
virtual bool CheckEvadeIfOutOfCombatArea () const
 
bool IsHeroic () const
 
Difficulty GetDifficulty () const
 
bool Is25ManRaid () const
 
template<class T >
const T & DUNGEON_MODE (const T &normal5, const T &heroic10) const
 
template<class T >
const T & RAID_MODE (const T &normal10, const T &normal25) const
 
template<class T >
const T & RAID_MODE (const T &normal10, const T &normal25, const T &heroic10, const T &heroic25) const
 
PlayerSelectTargetFromPlayerList (float maxdist, uint32 excludeAura=0, bool mustBeInLOS=false) const
 
- Public Member Functions inherited from CreatureAI
void Talk (uint8 id, WorldObject const *whisperTarget=nullptr, Milliseconds delay=0s)
 Causes the creature to talk/say the text assigned to their entry in the creature_text database table.
 
void Talk (uint8 id, Milliseconds delay)
 
 CreatureAI (Creature *creature)
 
 ~CreatureAI () override
 
void MoveCircleChecks ()
 
void MoveBackwardsChecks ()
 
void MoveInLineOfSight_Safe (Unit *who)
 == Reactions At =================================
 
void TriggerAlert (Unit const *who) const
 
virtual bool CanRespawn ()
 
virtual void EnterEvadeMode (EvadeReason why=EVADE_REASON_OTHER)
 
virtual void JustEngagedWith (Unit *)
 Called for reaction when initially engaged.
 
virtual void JustDied (Unit *)
 
virtual void KilledUnit (Unit *)
 
virtual void JustSummoned (Creature *)
 
virtual void IsSummonedBy (WorldObject *)
 
virtual void SummonedCreatureDespawn (Creature *)
 
virtual void SummonedCreatureDies (Creature *, Unit *)
 
virtual void SummonedCreatureDespawnAll ()
 
virtual void SpellHit (Unit *, SpellInfo const *)
 
virtual void SpellHitTarget (Unit *, SpellInfo const *)
 
virtual void AttackedBy (Unit *)
 
virtual bool IsEscorted ()
 
virtual void JustRespawned ()
 
virtual void MovementInform (uint32, uint32)
 
virtual void PathEndReached (uint32)
 
void OnCharmed (bool apply) override
 
virtual void JustReachedHome ()
 
void DoZoneInCombat (Creature *creature=nullptr, float maxRangeToNearestTarget=250.0f)
 
virtual void ReceiveEmote (Player *, uint32)
 
virtual void OwnerAttackedBy (Unit *)
 
virtual void OwnerAttacked (Unit *)
 
virtual void CorpseRemoved (uint32 &)
 == Triggered Actions Requested ==================
 
virtual void PassengerBoarded (Unit *, int8, bool)
 == Fields =======================================
 
virtual bool BeforeSpellClick (Unit *)
 
virtual void OnSpellClick (Unit *, bool &)
 
virtual bool CanSeeAlways (WorldObject const *)
 
virtual bool CanBeSeen (Player const *)
 
virtual bool CanAlwaysBeDetectable (WorldObject const *)
 
virtual void PetStopAttack ()
 
virtual bool CheckInRoom ()
 
CreatureBoundary const * GetBoundary () const
 
void SetBoundary (CreatureBoundary const *boundary, bool negativeBoundaries=false)
 
bool IsInBoundary (Position const *who=nullptr) const
 
virtual void CalculateThreat (Unit *, float &, SpellInfo const *)
 
virtual bool OnTeleportUnreacheablePlayer (Player *)
 
- 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
 

Public Attributes

InstanceScriptpInstance
 
uint32 mAIType
 
uint32 threatTimer
 
uint32 powerTimer
 
- Public Attributes inherited from ScriptedAI
Creatureme
 
bool IsFleeing
 

Additional Inherited Members

- Public Types inherited from ScriptedAI
enum class  Axis {
  AXIS_X ,
  AXIS_Y
}
 
- Public Types inherited from CreatureAI
enum  EvadeReason {
  EVADE_REASON_NO_HOSTILES ,
  EVADE_REASON_BOUNDARY ,
  EVADE_REASON_SEQUENCE_BREAK ,
  EVADE_REASON_NO_PATH ,
  EVADE_REASON_OTHER
}
 
- Static Public Member Functions inherited from CreatureAI
static bool IsInBounds (CreatureBoundary const &boundary, Position const *who)
 
- Static Public Member Functions inherited from UnitAI
static void FillAISpellInfo ()
 
- 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)
 
virtual void MoveInLineOfSight (Unit *)
 
bool _EnterEvadeMode (EvadeReason why=EVADE_REASON_OTHER)
 
- Protected Attributes inherited from CreatureAI
Creature *const me
 
EventMap events
 
CreatureBoundary const * _boundary
 
bool _negateBoundary
 
- Protected Attributes inherited from UnitAI
Unit *const me
 

Detailed Description

Constructor & Destructor Documentation

◆ boss_faction_championsAI()

boss_faction_championsAI::boss_faction_championsAI ( Creature pCreature,
uint32  aitype 
)
inline
40 : ScriptedAI(pCreature)
41 {
42 pInstance = pCreature->GetInstanceScript();
44 mAIType = aitype;
45 threatTimer = 2000;
46 powerTimer = 1000;
47 }
@ REACT_PASSIVE
Definition: Unit.h:1023
Definition: ScriptedCreature.h:192
Creature * me
Definition: ScriptedCreature.h:282
void SetReactState(ReactStates st)
Definition: Creature.h:89
InstanceScript * GetInstanceScript() const
Definition: Object.cpp:1192
uint32 powerTimer
Definition: boss_faction_champions.cpp:52
InstanceScript * pInstance
Definition: boss_faction_champions.cpp:49
uint32 threatTimer
Definition: boss_faction_champions.cpp:51
uint32 mAIType
Definition: boss_faction_champions.cpp:50

References WorldObject::GetInstanceScript(), mAIType, ScriptedAI::me, pInstance, powerTimer, REACT_PASSIVE, Creature::SetReactState(), and threatTimer.

Member Function Documentation

◆ AttackStart()

void boss_faction_championsAI::AttackStart ( Unit who)
inlineoverridevirtual

Reimplemented from ScriptedAI.

63 {
64 if( !who )
65 return;
66
67 if( mAIType == AI_MELEE || mAIType == AI_PET )
69 else
70 UnitAI::AttackStartCaster(who, 18.5f);
71 }
@ AI_MELEE
Definition: boss_faction_champions.cpp:26
@ AI_PET
Definition: boss_faction_champions.cpp:29
void AttackStartCaster(Unit *victim, float dist)
Definition: UnitAI.cpp:34
virtual void AttackStart(Unit *)
Definition: UnitAI.cpp:28

References AI_MELEE, AI_PET, UnitAI::AttackStart(), UnitAI::AttackStartCaster(), and mAIType.

◆ EnemiesInRange()

uint32 boss_faction_championsAI::EnemiesInRange ( float  distance)
inline
180 {
182 uint32 count = 0;
183 Unit* target;
184 for( ThreatContainer::StorageType::const_iterator iter = tList.begin(); iter != tList.end(); ++iter )
185 {
186 target = ObjectAccessor::GetUnit((*me), (*iter)->getUnitGuid());
187 if( target && me->GetDistance2d(target) < distance )
188 ++count;
189 }
190 return count;
191 }
std::uint32_t uint32
Definition: Define.h:108
Unit * GetUnit(WorldObject const &, ObjectGuid const guid)
Definition: ObjectAccessor.cpp:204
std::list< HostileReference * > StorageType
Definition: ThreatMgr.h:148
ThreatContainer::StorageType const & GetThreatList() const
Definition: ThreatMgr.h:274
float GetDistance2d(WorldObject const *obj) const
Definition: Object.cpp:1263
Definition: Unit.h:1290
ThreatMgr & GetThreatMgr()
Definition: Unit.h:2145

References WorldObject::GetDistance2d(), ThreatMgr::GetThreatList(), Unit::GetThreatMgr(), ObjectAccessor::GetUnit(), and ScriptedAI::me.

Referenced by npc_toc_priest::npc_toc_priestAI::UpdateAI(), npc_toc_shadow_priest::npc_toc_shadow_priestAI::UpdateAI(), npc_toc_warlock::npc_toc_warlockAI::UpdateAI(), npc_toc_mage::npc_toc_mageAI::UpdateAI(), npc_toc_hunter::npc_toc_hunterAI::UpdateAI(), npc_toc_warrior::npc_toc_warriorAI::UpdateAI(), npc_toc_rogue::npc_toc_rogueAI::UpdateAI(), and npc_toc_retro_paladin::npc_toc_retro_paladinAI::UpdateAI().

◆ EnterEvadeMode()

void boss_faction_championsAI::EnterEvadeMode ( EvadeReason  )
inlineoverridevirtual

Reimplemented from CreatureAI.

Reimplemented in npc_toc_pet_warlock::npc_toc_pet_warlockAI, and npc_toc_pet_hunter::npc_toc_pet_hunterAI.

139 {
140 if( pInstance )
142 }
@ TYPE_FAILED
Definition: trial_of_the_crusader.h:34
virtual void SetData(uint32, uint32)
Definition: ZoneScript.h:53

References pInstance, ZoneScript::SetData(), and TYPE_FAILED.

◆ EventMapGCD()

◆ GetThreatMod()

float boss_faction_championsAI::GetThreatMod ( float  dist,
float  ,
uint32  health,
uint32  ,
Unit target 
)
inline
74 {
75 /*float mod_health = ((float)health)/maxhealth;
76 if (mod_health < 0.4f) mod_health = 0.4f;
77 float unimportant_dist = (mAIType == AI_MELEE || mAIType == AI_PET ? 5.0f : 20.0f);
78 if (dist > unimportant_dist)
79 dist -= unimportant_dist; // compensate melee range
80 else
81 dist = 0.0f;
82 float mod_dist = 25.0f/(25.0f + dist);
83 float mod_armor = (mAIType == AI_MELEE || mAIType == AI_PET) ? armor / 16635.0f : 0.0f;
84 return mod_dist / ((0.15f+mod_armor)*mod_health);*/
85
86 // TC:
87 /*float dist_mod = (mAIType == AI_MELEE || mAIType == AI_PET) ? 15.0f / (15.0f + dist) : 1.0f;
88 float armor_mod = (mAIType == AI_MELEE || mAIType == AI_PET) ? armor / 16635.0f : 0.0f;
89 float eh = (health + 1) * (1.0f + armor_mod);
90 return dist_mod * 30000.0f / eh;*/
91
92 // third try:
93 float unimportant_dist = (mAIType == AI_MELEE || mAIType == AI_PET ? 5.0f : 35.0f);
94 if (dist > unimportant_dist) dist -= unimportant_dist;
95 else dist = 0.0f;
96 const float dist_factor = (mAIType == AI_MELEE || mAIType == AI_PET ? 15.0f : 25.0f);
97 float mod_dist = dist_factor / (dist_factor + dist); // 0.2 .. 1.0
98 float mod_health = health > 40000 ? 2.0f : (60000 - health) / 10000.0f; // 2.0 .. 6.0
99 float mod_armor = (mAIType == AI_MELEE || mAIType == AI_PET) ? Unit::CalcArmorReducedDamage(me, target, 10000, nullptr) / 10000.0f : 1.0f;
100 return mod_dist * mod_health * mod_armor;
101 }
static uint32 CalcArmorReducedDamage(Unit const *attacker, Unit const *victim, const uint32 damage, SpellInfo const *spellInfo, uint8 attackerLevel=0, WeaponAttackType attackType=MAX_ATTACK)
Definition: Unit.cpp:2001

References AI_MELEE, AI_PET, Unit::CalcArmorReducedDamage(), mAIType, and ScriptedAI::me.

Referenced by RecalculateThreat().

◆ IsCCed()

bool boss_faction_championsAI::IsCCed ( )
inline
145 {
146 // check for stun, fear, etc.
147 // for casting, silence, disarm check individually in the ai
149 {
150 if( !IsHeroic() )
151 return true;
153 return true;
154 else
155 {
158 }
159 }
160 return false;
161 }
@ UNIT_STATE_CONFUSED
Definition: Unit.h:336
@ UNIT_STATE_STUNNED
Definition: Unit.h:328
@ SPELL_PVP_TRINKET
Definition: boss_faction_champions.cpp:35
bool IsHeroic() const
Definition: ScriptedCreature.h:379
bool HasSpellCooldown(uint32 spell_id) const override
Definition: Creature.cpp:2819
void AddSpellCooldown(uint32 spell_id, uint32, uint32 end_time, bool needSendToClient=false, bool forceSendToSpectator=false) override
Definition: Creature.cpp:2764
bool isFrozen() const
Definition: Unit.cpp:16003
bool isFeared() const
Definition: Unit.h:1708
SpellCastResult CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=nullptr, AuraEffect const *triggeredByAura=nullptr, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:1169
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1398

References Creature::AddSpellCooldown(), Unit::CastSpell(), Creature::HasSpellCooldown(), Unit::HasUnitState(), Unit::isFeared(), Unit::isFrozen(), ScriptedAI::IsHeroic(), ScriptedAI::me, SPELL_PVP_TRINKET, UNIT_STATE_CONFUSED, and UNIT_STATE_STUNNED.

Referenced by npc_toc_druid::npc_toc_druidAI::myCanCast(), npc_toc_shaman::npc_toc_shamanAI::myCanCast(), npc_toc_paladin::npc_toc_paladinAI::myCanCast(), npc_toc_priest::npc_toc_priestAI::myCanCast(), npc_toc_shadow_priest::npc_toc_shadow_priestAI::myCanCast(), npc_toc_warlock::npc_toc_warlockAI::myCanCast(), npc_toc_mage::npc_toc_mageAI::myCanCast(), npc_toc_hunter::npc_toc_hunterAI::myCanCast(), npc_toc_boomkin::npc_toc_boomkinAI::myCanCast(), npc_toc_warrior::npc_toc_warriorAI::myCanCast(), npc_toc_dk::npc_toc_dkAI::myCanCast(), npc_toc_rogue::npc_toc_rogueAI::myCanCast(), npc_toc_enh_shaman::npc_toc_enh_shamanAI::myCanCast(), npc_toc_retro_paladin::npc_toc_retro_paladinAI::myCanCast(), npc_toc_pet_warlock::npc_toc_pet_warlockAI::myCanCast(), and npc_toc_pet_hunter::npc_toc_pet_hunterAI::myCanCast().

◆ JustDied()

void boss_faction_championsAI::JustDied ( Unit )
inlineoverridevirtual

Reimplemented from ScriptedAI.

127 {
128 if( pInstance && mAIType != AI_PET )
130 }
@ DONE
Definition: InstanceScript.h:59
@ TYPE_FACTION_CHAMPIONS
Definition: trial_of_the_crusader.h:42

References AI_PET, DONE, mAIType, pInstance, ZoneScript::SetData(), and TYPE_FACTION_CHAMPIONS.

◆ JustEngagedWith()

void boss_faction_championsAI::JustEngagedWith ( Unit )
inlineoverridevirtual

Called for reaction when initially engaged.

Reimplemented from ScriptedAI.

55 {
58 if( pInstance )
60 }
@ TYPE_FACTION_CHAMPIONS_START
Definition: trial_of_the_crusader.h:47
void SetInCombatWithZone()
Definition: Creature.cpp:2723
void RecalculateThreat()
Definition: boss_faction_champions.cpp:103

References ScriptedAI::me, pInstance, RecalculateThreat(), ZoneScript::SetData(), Creature::SetInCombatWithZone(), and TYPE_FACTION_CHAMPIONS_START.

◆ KilledUnit()

void boss_faction_championsAI::KilledUnit ( Unit )
inlineoverridevirtual

Reimplemented from ScriptedAI.

133 {
134 if( pInstance )
136 }
@ TYPE_FACTION_CHAMPIONS_PLAYER_DIED
Definition: trial_of_the_crusader.h:43

References pInstance, ZoneScript::SetData(), and TYPE_FACTION_CHAMPIONS_PLAYER_DIED.

◆ RecalculateThreat()

void boss_faction_championsAI::RecalculateThreat ( )
inline
104 {
106 for( ThreatContainer::StorageType::const_iterator itr = tList.begin(); itr != tList.end(); ++itr )
107 {
108 Unit* pUnit = ObjectAccessor::GetUnit(*me, (*itr)->getUnitGuid());
109 if( pUnit && pUnit->GetTypeId() == TYPEID_PLAYER && me->GetThreatMgr().GetThreat(pUnit) )
110 {
111 float threatMod = GetThreatMod(me->GetDistance2d(pUnit), (float)pUnit->GetArmor(), pUnit->GetHealth(), pUnit->GetMaxHealth(), pUnit);
112 me->GetThreatMgr().ModifyThreatByPercent(pUnit, -100);
113 //me->getThreatMgr().DoAddThreat(pUnit, 10000000.0f * threatMod);
115 ref->AddThreat(10000000.0f * threatMod);
116 }
117 }
118 }
@ TYPEID_PLAYER
Definition: ObjectGuid.h:38
Definition: ThreatMgr.h:49
HostileReference * getReferenceByTarget(Unit const *victim) const
Definition: ThreatMgr.cpp:262
float GetThreat(Unit *victim, bool alsoSearchOfflineList=false)
Definition: ThreatMgr.cpp:526
void ModifyThreatByPercent(Unit *victim, int32 percent)
Definition: ThreatMgr.cpp:509
ThreatContainer & GetOnlineContainer()
Definition: ThreatMgr.h:276
TypeID GetTypeId() const
Definition: Object.h:121
uint32 GetMaxHealth() const
Definition: Unit.h:1441
uint32 GetHealth() const
Definition: Unit.h:1440
uint32 GetArmor() const
Definition: Unit.h:1432
float GetThreatMod(float dist, float, uint32 health, uint32, Unit *target)
Definition: boss_faction_champions.cpp:73

References Unit::GetArmor(), WorldObject::GetDistance2d(), Unit::GetHealth(), Unit::GetMaxHealth(), ThreatMgr::GetOnlineContainer(), ThreatContainer::getReferenceByTarget(), ThreatMgr::GetThreat(), ThreatMgr::GetThreatList(), Unit::GetThreatMgr(), GetThreatMod(), Object::GetTypeId(), ObjectAccessor::GetUnit(), ScriptedAI::me, ThreatMgr::ModifyThreatByPercent(), and TYPEID_PLAYER.

Referenced by JustEngagedWith(), and UpdateAI().

◆ SelectEnemyCaster()

Unit * boss_faction_championsAI::SelectEnemyCaster ( bool  casting,
float  range 
)
inline
194 {
196 Unit* target;
197 for( ThreatContainer::StorageType::const_iterator iter = tList.begin(); iter != tList.end(); ++iter )
198 {
199 target = ObjectAccessor::GetUnit((*me), (*iter)->getUnitGuid());
200 if( target && target->getPowerType() == POWER_MANA && (!casting || target->HasUnitState(UNIT_STATE_CASTING)) && me->GetExactDist(target) <= range )
201 return target;
202 }
203 return nullptr;
204 }
@ UNIT_STATE_CASTING
Definition: Unit.h:340
@ POWER_MANA
Definition: SharedDefines.h:241
float GetExactDist(float x, float y, float z) const
Definition: Position.h:178
Powers getPowerType() const
Definition: Unit.h:1459

References Position::GetExactDist(), Unit::getPowerType(), ThreatMgr::GetThreatList(), Unit::GetThreatMgr(), ObjectAccessor::GetUnit(), Unit::HasUnitState(), ScriptedAI::me, POWER_MANA, and UNIT_STATE_CASTING.

Referenced by npc_toc_priest::npc_toc_priestAI::UpdateAI(), npc_toc_shadow_priest::npc_toc_shadow_priestAI::UpdateAI(), npc_toc_mage::npc_toc_mageAI::UpdateAI(), and npc_toc_dk::npc_toc_dkAI::UpdateAI().

◆ SelectTarget_MostHPLostFriendlyMissingBuff()

Creature * boss_faction_championsAI::SelectTarget_MostHPLostFriendlyMissingBuff ( uint32  spell,
float  range 
)
inline
164 {
165 std::list<Creature*> lst = DoFindFriendlyMissingBuff(range, spell);
166 if( lst.empty() )
167 return nullptr;
168 std::list<Creature*>::const_iterator iter = lst.begin();
169 uint32 lowestHP = (*iter)->GetMaxHealth() - (*iter)->GetHealth();
170 for( std::list<Creature*>::const_iterator itr = lst.begin(); itr != lst.end(); ++itr )
171 if( ((*itr)->GetMaxHealth() - (*itr)->GetHealth()) > lowestHP )
172 {
173 iter = itr;
174 lowestHP = (*itr)->GetMaxHealth() - (*itr)->GetHealth();
175 }
176 return (*iter);
177 }
std::list< Creature * > DoFindFriendlyMissingBuff(float range, uint32 spellId)
Definition: ScriptedCreature.cpp:474

References ScriptedAI::DoFindFriendlyMissingBuff().

Referenced by npc_toc_druid::npc_toc_druidAI::UpdateAI(), npc_toc_shaman::npc_toc_shamanAI::UpdateAI(), npc_toc_paladin::npc_toc_paladinAI::UpdateAI(), npc_toc_priest::npc_toc_priestAI::UpdateAI(), npc_toc_shadow_priest::npc_toc_shadow_priestAI::UpdateAI(), and npc_toc_retro_paladin::npc_toc_retro_paladinAI::UpdateAI().

◆ UpdateAI()

void boss_faction_championsAI::UpdateAI ( uint32  diff)
inlineoverridevirtual

Reimplemented from ScriptedAI.

Reimplemented in npc_toc_druid::npc_toc_druidAI, npc_toc_shaman::npc_toc_shamanAI, npc_toc_paladin::npc_toc_paladinAI, npc_toc_priest::npc_toc_priestAI, npc_toc_shadow_priest::npc_toc_shadow_priestAI, npc_toc_warlock::npc_toc_warlockAI, npc_toc_mage::npc_toc_mageAI, npc_toc_hunter::npc_toc_hunterAI, npc_toc_boomkin::npc_toc_boomkinAI, npc_toc_warrior::npc_toc_warriorAI, npc_toc_dk::npc_toc_dkAI, npc_toc_rogue::npc_toc_rogueAI, npc_toc_enh_shaman::npc_toc_enh_shamanAI, npc_toc_retro_paladin::npc_toc_retro_paladinAI, npc_toc_pet_warlock::npc_toc_pet_warlockAI, and npc_toc_pet_hunter::npc_toc_pet_hunterAI.

207 {
208 if (!me->IsInCombat())
209 return;
210
211 if( threatTimer <= diff )
212 {
214 threatTimer = urand(8750, 9250);
215 }
216 else
217 threatTimer -= diff;
218
219 if( me->getPowerType() == POWER_MANA )
220 {
221 if( powerTimer <= diff )
222 {
224 powerTimer = 4000;
225 }
226 else
227 powerTimer -= diff;
228 }
229 else if( me->getPowerType() == POWER_ENERGY )
230 {
231 if( powerTimer <= diff )
232 {
234 powerTimer = 1000;
235 }
236 else
237 powerTimer -= diff;
238 }
239 }
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:44
@ POWER_ENERGY
Definition: SharedDefines.h:244
int32 ModifyPower(Powers power, int32 val, bool withPowerUpdate=true)
Definition: Unit.cpp:14051
uint32 GetMaxPower(Powers power) const
Definition: Unit.h:1462
bool IsInCombat() const
Definition: Unit.h:1688

References Unit::GetMaxPower(), Unit::getPowerType(), Unit::IsInCombat(), ScriptedAI::me, Unit::ModifyPower(), POWER_ENERGY, POWER_MANA, powerTimer, RecalculateThreat(), threatTimer, and urand().

Referenced by npc_toc_druid::npc_toc_druidAI::UpdateAI(), npc_toc_shaman::npc_toc_shamanAI::UpdateAI(), npc_toc_paladin::npc_toc_paladinAI::UpdateAI(), npc_toc_priest::npc_toc_priestAI::UpdateAI(), npc_toc_shadow_priest::npc_toc_shadow_priestAI::UpdateAI(), npc_toc_warlock::npc_toc_warlockAI::UpdateAI(), npc_toc_mage::npc_toc_mageAI::UpdateAI(), npc_toc_hunter::npc_toc_hunterAI::UpdateAI(), npc_toc_boomkin::npc_toc_boomkinAI::UpdateAI(), npc_toc_warrior::npc_toc_warriorAI::UpdateAI(), npc_toc_dk::npc_toc_dkAI::UpdateAI(), npc_toc_rogue::npc_toc_rogueAI::UpdateAI(), npc_toc_enh_shaman::npc_toc_enh_shamanAI::UpdateAI(), npc_toc_retro_paladin::npc_toc_retro_paladinAI::UpdateAI(), npc_toc_pet_warlock::npc_toc_pet_warlockAI::UpdateAI(), and npc_toc_pet_hunter::npc_toc_pet_hunterAI::UpdateAI().

Member Data Documentation

◆ mAIType

uint32 boss_faction_championsAI::mAIType

◆ pInstance

InstanceScript* boss_faction_championsAI::pInstance

◆ powerTimer

uint32 boss_faction_championsAI::powerTimer

◆ threatTimer

uint32 boss_faction_championsAI::threatTimer