|
| 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=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) |
|
WorldObject * | GetSummoner () const |
| Returns the summoner creature/object, if the creature is a temporary summon.
|
|
| 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 | JustEngagedWith (Unit *) |
| Called for reaction when initially engaged.
|
|
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 bool | IsEscorted () |
|
virtual void | JustRespawned () |
|
virtual void | PathEndReached (uint32) |
|
void | OnCharmed (bool apply) override |
| Called when unit is charmed.
|
|
virtual void | JustReachedHome () |
|
void | DoZoneInCombat (Creature *creature=nullptr, float maxRangeToNearestTarget=250.0f) |
|
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 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) |
|
| 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 |
|
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 | JustEnteredCombat (Unit *) |
| Called when the unit enters combat.
|
|
virtual void | JustExitedCombat () |
| Called when the unit leaves combat.
|
|
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) |
| 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
177
179 {
182 }
183 else
185 }
187 {
189 {
190
191
192
193
194
196
197 if (nextTarget)
199 else
201 }
202 else
204 }
205
206
208 return;
209
210
212 {
214 {
216
217
219 {
221 {
224 }
225 else
227 }
228 return;
229 }
230
231
233 return;
234
235 typedef std::vector<std::pair<Unit*, Spell*> > TargetSpellList;
236 TargetSpellList targetSpellStore;
237
239 {
241 if (!spellID)
242 continue;
243
245 if (!spellInfo)
246 continue;
247
249 continue;
250
251
253 continue;
254
256 {
258 {
259
261 {
262 continue;
263 }
264 }
265
268 bool spellUsed = false;
269
270
271
273 if (!target && owner)
275
276 if (target)
277 {
279 {
280 targetSpellStore.emplace_back(target, spell);
281 spellUsed = true;
282 }
283 }
284
285
286 if (!spellUsed)
287 {
289 {
291
292
293 if (!ally)
294 continue;
295
297 {
298 targetSpellStore.emplace_back(ally, spell);
299 spellUsed = true;
300 break;
301 }
302 }
303 }
304
305
306 if (!spellUsed)
307 delete spell;
308 }
310 {
313 targetSpellStore.emplace_back(
me->
GetVictim(), spell);
314 else
315 delete spell;
316 }
317 }
318
319
320 if (!targetSpellStore.empty())
321 {
322 uint32 index =
urand(0, targetSpellStore.size() - 1);
323
324 Spell* spell = targetSpellStore[index].second;
325 Unit* target = targetSpellStore[index].first;
326
327 targetSpellStore.erase(targetSpellStore.begin() + index);
328
331
333 {
337
340 }
341
343
345 }
346
347
348 for (TargetSpellList::const_iterator itr = targetSpellStore.begin(); itr != targetSpellStore.end(); ++itr)
349 delete itr->second;
350 }
351}
@ ACT_ENABLED
Definition CharmInfo.h:63
uint32 urand(uint32 min, uint32 max)
Definition Random.cpp:44
@ POWER_ENERGY
Definition SharedDefines.h:272
@ TRIGGERED_NONE
Definition SpellDefines.h:133
bool HasSpellCooldown(uint32 spell_id) const override
Definition Creature.cpp:2932
void AddSpellCooldown(uint32 spell_id, uint32, uint32 end_time, bool needSendToClient=false, bool forceSendToSpectator=false) override
Definition Creature.cpp:2877
bool HasGlobalCooldown(SpellInfo const *spellInfo) const
Definition CharmInfo.cpp:397
Definition ObjectGuid.h:118
void SendUpdateToPlayer(Player *player)
Definition Object.cpp:246
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:2005
void SetUnitTarget(Unit *target)
Definition Spell.cpp:239
uint32 Id
Definition SpellInfo.h:320
int32 GetMaxDuration() const
Definition SpellInfo.cpp:2345
bool CanBeUsedInCombat() const
Definition SpellInfo.cpp:1232
bool IsPositive() const
Definition SpellInfo.cpp:1237
void LoadScripts()
Definition Spell.cpp:8537
SpellCastResult prepare(SpellCastTargets const *targets, AuraEffect const *triggeredByAura=nullptr)
Definition Spell.cpp:3485
SpellInfo const *const m_spellInfo
Definition Spell.h:523
bool CanAutoCast(Unit *target)
Definition Spell.cpp:7023
void StopMoving()
Definition Unit.cpp:16702
bool IsPetInCombat() const
Definition Unit.h:896
void SetInFront(WorldObject const *target)
Definition Unit.cpp:20575
bool IsInCombat() const
Definition Unit.h:893
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:199
int32 GetForcedSpell()
Definition CharmInfo.h:178
ObjectGuid GetForcedTarget()
Definition CharmInfo.h:180
GlobalCooldownMgr & GetGlobalCooldownMgr()
Definition CharmInfo.h:160
bool HasInArc(float arcangle, const Position *pos, float targetRadius=0.0f) const
Definition Position.cpp:141
References _doMeleeAttack(), _needToStop(), _stopAttack(), ACT_ENABLED, Creature::AddSpellCooldown(), AttackStart(), CanAttack(), Spell::CanAutoCast(), SpellInfo::CanBeUsedInCombat(), MotionMaster::Clear(), 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(), GlobalCooldownMgr::HasGlobalCooldown(), Position::HasInArc(), Creature::HasReactState(), Creature::HasSpellCooldown(), Pet::HasTempSpell(), Unit::HasUnitState(), SpellInfo::Id, Unit::InterruptNonMeleeSpells(), Unit::IsAlive(), CharmInfo::IsAtStay(), CharmInfo::IsCommandAttack(), Unit::IsInCombat(), 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(), SpellCastTargets::SetUnitTarget(), sSpellMgr, Unit::StopMoving(), Unit::ToPet(), Object::ToPlayer(), ObjectGuid::ToString(), TRIGGERED_NONE, UNIT_STATE_CASTING, UpdateAllies(), and urand().