|
| | PetAI (Creature *c) |
| |
| void | UpdateAI (uint32) override |
| | Use to start attacking a target. Called just before JustEngagedWith()
|
| |
| void | KilledUnit (Unit *) override |
| |
| void | AttackStart (Unit *target) override |
| |
| void | MovementInform (uint32 moveType, uint32 data) override |
| |
| void | OwnerAttackedBy (Unit *attacker) override |
| |
| void | OwnerAttacked (Unit *target) override |
| |
| void | AttackedBy (Unit *attacker) override |
| |
| void | ReceiveEmote (Player *player, uint32 textEmote) override |
| |
| void | MoveInLineOfSight (Unit *) override |
| |
| void | MoveInLineOfSight_Safe (Unit *) |
| |
| void | EnterEvadeMode (EvadeReason) override |
| |
| void | SpellHit (Unit *caster, SpellInfo const *spellInfo) override |
| |
| void | PetStopAttack () override |
| |
| void | Talk (uint8 id, WorldObject const *whisperTarget=nullptr, Milliseconds delay=0ms) |
| | Causes the creature to talk/say the text assigned to their entry in the creature_text database table.
|
| |
| void | Talk (uint8 id, Milliseconds delay) |
| |
| WorldObject * | GetSummoner () const |
| | Returns the summoner creature/object, if the creature is a temporary summon.
|
| |
| | CreatureAI (Creature *creature) |
| |
| | ~CreatureAI () override |
| |
| bool | IsEngaged () const |
| | Check if creature is currently engaged in combat.
|
| |
| void | MoveCircleChecks () |
| |
| void | MoveBackwardsChecks () |
| |
| void | MoveInLineOfSight_Safe (Unit *who) |
| | == Reactions At =================================
|
| |
| void | TriggerAlert (Unit const *who) const |
| |
| virtual bool | CanRespawn () |
| |
| virtual bool | IsEscortNPC (bool=true) const |
| |
| void | JustEnteredCombat (Unit *who) override |
| | Called when the unit enters combat.
|
| |
| virtual void | JustStartedThreateningMe (Unit *who) |
| |
| virtual void | JustEngagedWith (Unit *) |
| | Called for reaction when initially engaged - this happens after JustEnteredCombat.
|
| |
| void | EngagementStart (Unit *who) |
| |
| void | EngagementOver () |
| |
| void | JustExitedCombat () override |
| | Called when the unit leaves combat.
|
| |
| virtual void | JustDied (Unit *) |
| |
| virtual void | JustSummoned (Creature *) |
| |
| virtual void | IsSummonedBy (WorldObject *) |
| |
| virtual void | SummonedCreatureDespawn (Creature *) |
| |
| virtual void | SummonedCreatureDies (Creature *, Unit *) |
| |
| virtual void | SummonedCreatureDespawnAll () |
| |
| virtual void | SummonedCreatureEvade (Creature *) |
| |
| virtual void | SpellHitTarget (Unit *, SpellInfo const *) |
| |
| virtual void | OnSpellStart (SpellInfo const *) |
| |
| virtual void | OnSpellCast (SpellInfo const *) |
| |
| virtual void | OnSpellFailed (SpellInfo const *) |
| |
| virtual void | OnChannelFinished (SpellInfo const *) |
| |
| virtual bool | IsEscorted () |
| |
| virtual void | JustRespawned () |
| |
| virtual void | PathEndReached (uint32) |
| |
| virtual void | WaypointPathStarted (uint32) |
| | == Waypoints system =============================
|
| |
| virtual void | WaypointStarted (uint32, uint32) |
| |
| virtual void | WaypointReached (uint32, uint32) |
| |
| virtual void | WaypointPathEnded (uint32, uint32) |
| |
| void | OnCharmed (bool apply) override |
| | Called when unit is charmed.
|
| |
| virtual void | JustReachedHome () |
| |
| void | DoZoneInCombat (Creature *creature=nullptr, float maxRangeToNearestTarget=250.0f) |
| |
| void | OnOwnerCombatInteraction (Unit *target) |
| |
| 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 *) |
| |
| int32 | VisualizeBoundary (uint32 duration, Unit *owner=nullptr, bool fill=false, bool checkZ=false) const |
| |
| 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 *) |
| |
| virtual void | OnAuraRemove (AuraApplication *, AuraRemoveMode) |
| |
| virtual void | DistancingStarted () |
| |
| virtual void | DistancingEnded () |
| |
| | 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 const &, int32=0) |
| |
| virtual ObjectGuid | GetGUID (int32=0) const |
| |
| Unit * | SelectTarget (SelectTargetMethod targetType, uint32 position=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0) |
| |
| template<class PREDICATE > |
| Unit * | SelectTarget (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) |
| | Select the best (up to) <num> targets (in <targetType> order) from the threat list that fulfill the following:
|
| |
| template<class PREDICATE > |
| void | SelectTargetList (std::list< Unit * > &targetList, uint32 num, SelectTargetMethod targetType, uint32 position, PREDICATE const &predicate) |
| |
| virtual void | OnDespawn () |
| | Called when the unit is about to be removed from the world (despawn, grid unload, corpse disappearing, player logging out etc.)
|
| |
| virtual void | EvadeTimerExpired () |
| | Called when evade timer expires (target unreachable for too long)
|
| |
| virtual void | DamageDealt (Unit *, uint32 &, DamageEffectType, SpellSchoolMask) |
| | Called at any Damage to any victim (before damage apply)
|
| |
| virtual void | DamageTaken (Unit *, uint32 &, DamageEffectType, SpellSchoolMask) |
| | Called at any Damage from any attacker (before damage apply)
|
| |
| virtual void | HealReceived (Unit *, uint32 &) |
| | Called when the creature receives heal.
|
| |
| virtual void | OnPowerUpdate (Powers, int32, int32, uint32) |
| | Called when the creature power updates.
|
| |
| virtual void | HealDone (Unit *, uint32 &) |
| | Called when the unit heals.
|
| |
| virtual void | OnCalculateMeleeDamageReceived (uint32 &, Unit *) |
| | Called during damage calculations.
|
| |
| virtual void | OnCalculateSpellDamageReceived (int32 &, Unit *) |
| |
| virtual void | OnCalculatePeriodicTickReceived (uint32 &, Unit *) |
| | Called during calculation when receiving periodic healing or damage (DoT or HoT)
|
| |
| 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) |
| | To specify the caster as target if the spell is self-cast.
|
| |
| 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, bool withTank=true, int32 aura=0) |
| | Cast the spell on a random unit from the threat list.
|
| |
| SpellCastResult | DoCastMaxThreat (uint32 spellId, uint32 threatTablePosition=0, float dist=0.0f, bool playerOnly=true, bool triggered=false) |
| | Cast spell on the top threat target, which may not 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) |
| | Called when a summon reaches a waypoint or point movement finished.
|
| |
| 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 |
| |
| void PetAI::UpdateAI |
( |
uint32 |
| ) |
|
|
overridevirtual |
Use to start attacking a target. Called just before JustEngagedWith()
Implements UnitAI.
149{
151 return;
152
154
156
158 else
160
162 {
163
165 {
167 return;
168 }
169
171 {
174 return;
175 }
176
178
181 {
184 }
185
186
188 {
191 }
192 else
194 }
196 {
198 {
199
200
201
202
203
205
206 if (nextTarget)
208 else
210 }
211 else
213 }
214
215
217 return;
218
219
221 {
223 {
225
226
228 {
230 {
233 }
234 else
236 }
237 return;
238 }
239
240
242 return;
243
244 typedef std::vector<std::pair<Unit*, Spell*> > TargetSpellList;
245 TargetSpellList targetSpellStore;
246
248 {
250 if (!spellID)
251 continue;
252
254 if (!spellInfo)
255 continue;
256
258 continue;
259
260
262 continue;
263
265 {
267 {
268
270 {
271 continue;
272 }
273 }
274
277 bool spellUsed = false;
278
279
280
282 if (!target && owner)
284
285 if (target)
286 {
288 {
289 targetSpellStore.emplace_back(target, spell);
290 spellUsed = true;
291 }
292 }
293
295 {
296 if (!spellUsed)
297 delete spell;
298
299 continue;
300 }
301
302
303 if (!spellUsed)
304 {
306 {
308
309
310 if (!ally)
311 continue;
312
314 {
315 targetSpellStore.emplace_back(ally, spell);
316 spellUsed = true;
317 break;
318 }
319 }
320 }
321
322
323 if (!spellUsed)
324 delete spell;
325 }
327 {
330 targetSpellStore.emplace_back(
me->
GetVictim(), spell);
331 else
332 delete spell;
333 }
334 }
335
336
337 if (!targetSpellStore.empty())
338 {
339 uint32 index =
urand(0, targetSpellStore.size() - 1);
340
341 Spell* spell = targetSpellStore[index].second;
342 Unit* target = targetSpellStore[index].first;
343
344 targetSpellStore.erase(targetSpellStore.begin() + index);
345
348
350 {
354
357 }
358
360
362
363
366 && controlledPet->IsMovementPreventedByCasting())
367 controlledPet->StopMoving();
368 }
369
370
371 for (TargetSpellList::const_iterator itr = targetSpellStore.begin(); itr != targetSpellStore.end(); ++itr)
372 delete itr->second;
373 }
374}
@ ACT_ENABLED
Definition CharmInfo.h:63
uint32 urand(uint32 min, uint32 max)
Definition Random.cpp:44
@ POWER_ENERGY
Definition SharedDefines.h:260
@ SPELL_EFFECT_JUMP_DEST
Definition SharedDefines.h:808
@ TRIGGERED_NONE
Definition SpellDefines.h:141
bool HasSpellCooldown(uint32 spell_id) const override
Definition Creature.cpp:3064
void AddSpellCooldown(uint32 spell_id, uint32, uint32 end_time, bool needSendToClient=false, bool forceSendToSpectator=false) override
Definition Creature.cpp:2989
bool IsMovementPreventedByCasting() const override
Definition Creature.cpp:3674
bool HasGlobalCooldown(SpellInfo const *spellInfo) const
Definition CharmInfo.cpp:397
Definition ObjectGuid.h:121
void SendUpdateToPlayer(Player *player)
Definition Object.cpp:244
bool _needToStop(void)
Definition PetAI.cpp:49
GuidSet m_AllySet
Definition PetAI.h:83
void _doMeleeAttack()
Definition PetAI.cpp:91
uint32 m_updateAlliesTimer
Definition PetAI.h:84
bool HasTempSpell() const
Definition Pet.h:147
WorldSession * GetSession() const
Definition Player.h:2031
void SetUnitTarget(Unit *target)
Definition Spell.cpp:276
uint32 Id
Definition SpellInfo.h:344
bool IsActionAllowedChannel() const
Definition SpellInfo.cpp:1306
int32 GetMaxDuration() const
Definition SpellInfo.cpp:2771
bool CanBeUsedInCombat() const
Definition SpellInfo.cpp:1277
bool IsChanneled() const
Definition SpellInfo.cpp:1301
bool HasEffect(SpellEffects effect) const
Definition SpellInfo.cpp:889
bool IsPositive() const
Definition SpellInfo.cpp:1282
void LoadScripts()
Definition Spell.cpp:8855
SpellCastResult prepare(SpellCastTargets const *targets, AuraEffect const *triggeredByAura=nullptr)
Definition Spell.cpp:3556
SpellInfo const *const m_spellInfo
Definition Spell.h:535
bool CanAutoCast(Unit *target)
Definition Spell.cpp:7261
void StopMoving()
Definition Unit.cpp:12583
bool IsPetInCombat() const
Definition Unit.h:944
void SetInFront(WorldObject const *target)
Definition Unit.cpp:16003
bool IsInCombat() const
Definition Unit.h:941
void HandlePetActionHelper(Unit *pet, ObjectGuid guid1, uint32 spellid, uint16 flag, ObjectGuid guid2)
Definition PetHandler.cpp:150
Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition ObjectAccessor.cpp:223
int32 GetForcedSpell()
Definition CharmInfo.h:178
ObjectGuid GetForcedTarget()
Definition CharmInfo.h:180
GlobalCooldownMgr & GetGlobalCooldownMgr()
Definition CharmInfo.h:160
bool HasInArc(float arcangle, Position const *pos, float targetRadius=0.0f) const
Definition Position.cpp:148
References _doMeleeAttack(), _needToStop(), _stopAttack(), ACT_ENABLED, Creature::AddSpellCooldown(), AttackStart(), CanAttack(), Spell::CanAutoCast(), SpellInfo::CanBeUsedInCombat(), MotionMaster::Clear(), COMMAND_FOLLOW, COMMAND_STAY, Unit::getAttackerForHelper(), Unit::GetCharmerOrOwner(), Unit::GetCharmInfo(), CharmInfo::GetForcedSpell(), CharmInfo::GetForcedTarget(), CharmInfo::GetGlobalCooldownMgr(), Object::GetGUID(), SpellInfo::GetMaxDuration(), Unit::GetMotionMaster(), Creature::GetPetAutoSpellOnPos(), Creature::GetPetAutoSpellSize(), Unit::GetPower(), Player::GetSession(), ObjectAccessor::GetUnit(), Unit::GetVictim(), WorldSession::HandlePetActionHelper(), HandleReturnMovement(), Unit::HasBreakableByDamageCrowdControlAura(), CharmInfo::HasCommandState(), SpellInfo::HasEffect(), GlobalCooldownMgr::HasGlobalCooldown(), Position::HasInArc(), Creature::HasReactState(), Creature::HasSpellCooldown(), Pet::HasTempSpell(), Unit::HasUnitState(), SpellInfo::Id, Unit::InterruptNonMeleeSpells(), SpellInfo::IsActionAllowedChannel(), Unit::IsAlive(), CharmInfo::IsAtStay(), SpellInfo::IsChanneled(), CharmInfo::IsCommandAttack(), Unit::IsInCombat(), Creature::IsMovementPreventedByCasting(), Unit::IsPet(), Minion::IsPetGhoul(), Unit::IsPetInCombat(), Object::IsPlayer(), SpellInfo::IsPositive(), Unit::IsWithinMeleeRange(), Spell::LoadScripts(), LOG_DEBUG, m_AllySet, Spell::m_spellInfo, m_updateAlliesTimer, CreatureAI::me, POWER_ENERGY, Spell::prepare(), REACT_AGGRESSIVE, REACT_PASSIVE, SelectNextTarget(), Object::SendUpdateToPlayer(), Unit::SetInFront(), CharmInfo::SetIsAtStay(), SpellCastTargets::SetUnitTarget(), SPELL_EFFECT_JUMP_DEST, sSpellMgr, StartChase(), Unit::StopMoving(), Unit::ToPet(), Object::ToPlayer(), ObjectGuid::ToString(), TRIGGERED_NONE, UNIT_STATE_CASTING, UpdateAllies(), and urand().