AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
Pet Class Reference

#include "Pet.h"

Inheritance diagram for Pet:
Guardian Minion TempSummon Creature Unit GridObject< Creature > MovableMapObject WorldObject Object WorldLocation Position

Public Member Functions

 Pet (Player *owner, PetType type=MAX_PET_TYPE)
 
 ~Pet () override=default
 
void AddToWorld () override
 
void RemoveFromWorld () override
 
float GetNativeObjectScale () const override
 
void SetDisplayId (uint32 modelId) override
 
PetType getPetType () const
 
void setPetType (PetType type)
 
bool isControlled () const
 
bool isTemporarySummoned () const
 
bool IsPermanentPetFor (Player *owner) const
 
bool Create (ObjectGuid::LowType guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 pet_number)
 
bool CreateBaseAtCreature (Creature *creature)
 
bool CreateBaseAtCreatureInfo (CreatureTemplate const *cinfo, Unit *owner)
 
bool CreateBaseAtTamed (CreatureTemplate const *cinfo, Map *map, uint32 phaseMask)
 
bool LoadPetFromDB (Player *owner, uint32 petEntry, uint32 petnumber, bool current, uint32 healthPct=0)
 
bool isBeingLoaded () const override
 
void SavePetToDB (PetSaveMode mode)
 
void FillPetInfo (PetStable::PetInfo *petInfo) const
 
void Remove (PetSaveMode mode, bool returnreagent=false)
 
void setDeathState (DeathState s, bool despawn=false) override
 
void Update (uint32 diff) override
 
uint8 GetPetAutoSpellSize () const override
 
uint32 GetPetAutoSpellOnPos (uint8 pos) const override
 
void LoseHappiness ()
 
HappinessState GetHappinessState ()
 
void GivePetXP (uint32 xp)
 
void GivePetLevel (uint8 level)
 
void SynchronizeLevelWithOwner ()
 
bool HaveInDiet (ItemTemplate const *item) const
 
uint32 GetCurrentFoodBenefitLevel (uint32 itemlevel) const
 
void SetDuration (Milliseconds dur)
 
Milliseconds GetDuration () const
 
void ToggleAutocast (SpellInfo const *spellInfo, bool apply)
 
bool HasSpell (uint32 spell) const override
 
void LearnPetPassives ()
 
void CastPetAuras (bool current)
 
void CastWhenWillAvailable (uint32 spellid, Unit *spellTarget, Unit *oldTarget, bool spellIsPositive=false)
 
void ClearCastWhenWillAvailable ()
 
void RemoveSpellCooldown (uint32 spell_id, bool update)
 
void _SaveSpellCooldowns (CharacterDatabaseTransaction trans)
 
void _SaveAuras (CharacterDatabaseTransaction trans)
 
void _SaveSpells (CharacterDatabaseTransaction trans)
 
void _LoadSpellCooldowns (PreparedQueryResult result)
 
void _LoadAuras (PreparedQueryResult result, uint32 timediff)
 
void _LoadSpells (PreparedQueryResult result)
 
bool addSpell (uint32 spellId, ActiveStates active=ACT_DECIDE, PetSpellState state=PETSPELL_NEW, PetSpellType type=PETSPELL_NORMAL)
 
bool learnSpell (uint32 spell_id)
 
void learnSpellHighRank (uint32 spellid)
 
void InitLevelupSpellsForLevel ()
 
bool unlearnSpell (uint32 spell_id, bool learn_prev, bool clear_ab=true)
 
bool removeSpell (uint32 spell_id, bool learn_prev, bool clear_ab=true)
 
void CleanupActionBar ()
 
std::string GenerateActionBarData () const
 
void InitPetCreateSpells ()
 
bool resetTalents ()
 
void InitTalentForLevel ()
 
uint8 GetMaxTalentPointsForLevel (uint8 level)
 
uint8 GetFreeTalentPoints ()
 
void SetFreeTalentPoints (uint8 points)
 
uint64 GetAuraUpdateMaskForRaid () const
 
void SetAuraUpdateMaskForRaid (uint8 slot)
 
void ResetAuraUpdateMaskForRaid ()
 
DeclinedName const * GetDeclinedNames () const
 
PlayerGetOwner () const
 
void SetLoading (bool load)
 
bool HasTempSpell () const
 
std::string GetDebugInfo () const override
 
- Public Member Functions inherited from Guardian
 Guardian (SummonPropertiesEntry const *properties, ObjectGuid owner, bool isWorldObject)
 
void InitStats (uint32 duration) override
 
bool InitStatsForLevel (uint8 level)
 
void InitSummon () override
 
bool UpdateStats (Stats stat) override
 
bool UpdateAllStats () override
 
void UpdateArmor () override
 
void UpdateMaxHealth () override
 
void UpdateMaxPower (Powers power) override
 
void UpdateAttackPowerAndDamage (bool ranged=false) override
 
void UpdateDamagePhysical (WeaponAttackType attType) override
 
std::string GetDebugInfo () const override
 
- Public Member Functions inherited from Minion
 Minion (SummonPropertiesEntry const *properties, ObjectGuid owner, bool isWorldObject)
 
void InitStats (uint32 duration) override
 
void RemoveFromWorld () override
 
UnitGetOwner () const
 
float GetFollowAngle () const override
 
void SetFollowAngle (float angle)
 
bool IsPetGhoul () const
 
bool IsGuardianPet () const
 
void setDeathState (DeathState s, bool despawn=false) override
 
std::string GetDebugInfo () const override
 
- Public Member Functions inherited from TempSummon
 TempSummon (SummonPropertiesEntry const *properties, ObjectGuid owner, bool isWorldObject)
 
 ~TempSummon () override=default
 
void Update (uint32 time) override
 
virtual void InitStats (uint32 lifetime)
 
virtual void InitSummon ()
 
virtual void UnSummon (uint32 msTime=0)
 
void RemoveFromWorld () override
 
void SetTempSummonType (TempSummonType type)
 
void SaveToDB (uint32, uint8, uint32) override
 
WorldObjectGetSummoner () const
 
UnitGetSummonerUnit () const
 
CreatureGetSummonerCreatureBase () const
 
GameObjectGetSummonerGameObject () const
 
ObjectGuid GetSummonerGUID () const
 
TempSummonType GetSummonType () const
 
uint32 GetTimer ()
 
void SetTimer (uint32 t)
 
void SetVisibleBySummonerOnly (bool visibleBySummonerOnly)
 
bool IsVisibleBySummonerOnly () const
 
std::string GetDebugInfo () const override
 
- Public Member Functions inherited from Creature
 Creature (bool isWorldObject=false)
 
 ~Creature () override
 
void AddToWorld () override
 
void RemoveFromWorld () override
 
float GetNativeObjectScale () const override
 
void SetObjectScale (float scale) override
 
void SetDisplayId (uint32 modelId) override
 
void DisappearAndDie ()
 
bool isVendorWithIconSpeak () const
 
bool Create (ObjectGuid::LowType guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 vehId, float x, float y, float z, float ang, const CreatureData *data=nullptr)
 
bool LoadCreaturesAddon (bool reload=false)
 
void SelectLevel (bool changelevel=true)
 
void LoadEquipment (int8 id=1, bool force=false)
 
ObjectGuid::LowType GetSpawnId () const
 
void Update (uint32 time) override
 
void GetRespawnPosition (float &x, float &y, float &z, float *ori=nullptr, float *dist=nullptr) const
 
void SetCorpseDelay (uint32 delay)
 
void SetCorpseRemoveTime (uint32 delay)
 
uint32 GetCorpseDelay () const
 
bool IsRacialLeader () const
 
bool IsCivilian () const
 
bool IsTrigger () const
 
bool IsGuard () const
 
CreatureMovementData const & GetMovementTemplate () const
 
bool CanWalk () const
 
bool CanSwim () const override
 This method check the current flag/status of a creature and its inhabit type.
 
bool CanEnterWater () const override
 
bool CanFly () const override
 
bool CanHover () const
 
MovementGeneratorType GetDefaultMovementType () const override
 -------—End of Pet responses methods-------—
 
void SetDefaultMovementType (MovementGeneratorType mgt)
 
void SetReactState (ReactStates st)
 
ReactStates GetReactState () const
 
bool HasReactState (ReactStates state) const
 
void InitializeReactState ()
 
bool isCanInteractWithBattleMaster (Player *player, bool msg) const
 
bool isCanTrainingAndResetTalentsOf (Player *player) const
 
bool IsValidTrainerForPlayer (Player *player, uint32 *npcFlags=nullptr) const
 
bool CanCreatureAttack (Unit const *victim, bool skipDistCheck=false) const
 
void LoadSpellTemplateImmunity ()
 
bool IsImmunedToSpell (SpellInfo const *spellInfo, Spell const *spell=nullptr) override
 
bool HasMechanicTemplateImmunity (uint32 mask) const
 
bool IsImmunedToSpellEffect (SpellInfo const *spellInfo, uint32 index) const override
 
bool isElite () const
 
bool isWorldBoss () const
 
bool IsDungeonBoss () const
 
bool IsImmuneToKnockback () const
 
bool IsAvoidingAOE () const
 
uint8 getLevelForTarget (WorldObject const *target) const override
 
bool IsInEvadeMode () const
 
bool IsEvadingAttacks () const
 
bool AIM_Initialize (CreatureAI *ai=nullptr)
 
void Motion_Initialize ()
 
CreatureAIAI () const
 
bool SetWalk (bool enable) override
 
bool SetDisableGravity (bool disable, bool packetOnly=false, bool updateAnimationTier=true) override
 
bool SetSwim (bool enable) override
 
bool SetCanFly (bool enable, bool packetOnly=false) override
 
bool SetWaterWalking (bool enable, bool packetOnly=false) override
 
bool SetFeatherFall (bool enable, bool packetOnly=false) override
 
bool SetHover (bool enable, bool packetOnly=false, bool updateAnimationTier=true) override
 
bool HasSpellFocus (Spell const *focusSpell=nullptr) const
 
uint32 GetShieldBlockValue () const override
 
SpellSchoolMask GetMeleeDamageSchoolMask (WeaponAttackType=BASE_ATTACK, uint8=0) const override
 
void SetMeleeDamageSchool (SpellSchools school)
 
void _AddCreatureSpellCooldown (uint32 spell_id, uint16 categoryId, uint32 end_time)
 
void AddSpellCooldown (uint32 spell_id, uint32, uint32 end_time, bool needSendToClient=false, bool forceSendToSpectator=false) override
 
bool HasSpellCooldown (uint32 spell_id) const override
 
uint32 GetSpellCooldown (uint32 spell_id) const
 
void ProhibitSpellSchool (SpellSchoolMask idSchoolMask, uint32 unTimeMs) override
 
bool IsSpellProhibited (SpellSchoolMask idSchoolMask) const
 
bool HasSpell (uint32 spellID) const override
 
void UpdateMovementFlags ()
 
uint32 GetRandomId (uint32 id1, uint32 id2, uint32 id3)
 
bool UpdateEntry (uint32 entry, const CreatureData *data=nullptr, bool changelevel=true, bool updateAI=false)
 
bool UpdateEntry (uint32 entry, bool updateAI)
 
bool UpdateStats (Stats stat) override
 
bool UpdateAllStats () override
 
void UpdateResistances (uint32 school) override
 
void UpdateArmor () override
 
void UpdateMaxHealth () override
 
void UpdateMaxPower (Powers power) override
 
void UpdateAttackPowerAndDamage (bool ranged=false) override
 
void CalculateMinMaxDamage (WeaponAttackType attType, bool normalized, bool addTotalPct, float &minDamage, float &maxDamage, uint8 damageIndex) override
 
void SetCanDualWield (bool value) override
 
int8 GetOriginalEquipmentId () const
 
uint8 GetCurrentEquipmentId ()
 
void SetCurrentEquipmentId (uint8 id)
 
float GetSpellDamageMod (int32 Rank)
 
VendorItemData const * GetVendorItems () const
 
uint32 GetVendorItemCurrentCount (VendorItem const *vItem)
 
uint32 UpdateVendorItemCurrentCount (VendorItem const *vItem, uint32 used_count)
 
TrainerSpellData const * GetTrainerSpells () const
 
CreatureTemplate const * GetCreatureTemplate () const
 
CreatureData const * GetCreatureData () const
 
void SetDetectionDistance (float dist)
 
CreatureAddon const * GetCreatureAddon () const
 
std::string const & GetAIName () const
 
std::string GetScriptName () const
 
uint32 GetScriptId () const
 
std::string const & GetNameForLocaleIdx (LocaleConstant locale_idx) const override
 
void setDeathState (DeathState s, bool despawn=false) override
 
bool LoadFromDB (ObjectGuid::LowType guid, Map *map, bool allowDuplicate=false)
 
bool LoadCreatureFromDB (ObjectGuid::LowType guid, Map *map, bool addToMap=true, bool gridLoad=false, bool allowDuplicate=false)
 
void SaveToDB ()
 
virtual void SaveToDB (uint32 mapid, uint8 spawnMask, uint32 phaseMask)
 
virtual void DeleteFromDB ()
 
ObjectGuid GetLootRecipientGUID () const
 
PlayerGetLootRecipient () const
 
ObjectGuid::LowType GetLootRecipientGroupGUID () const
 
GroupGetLootRecipientGroup () const
 
bool hasLootRecipient () const
 
bool isTappedBy (Player const *player) const
 
bool CanGeneratePickPocketLoot () const
 
void SetPickPocketLootTime ()
 
void ResetPickPocketLootTime ()
 
void SetLootRecipient (Unit *unit, bool withGroup=true)
 
void AllLootRemovedFromCorpse ()
 
uint16 GetLootMode () const
 
bool HasLootMode (uint16 lootMode) const
 
void SetLootMode (uint16 lootMode)
 
void AddLootMode (uint16 lootMode)
 
void RemoveLootMode (uint16 lootMode)
 
void ResetLootMode ()
 
SpellInfo const * reachWithSpellAttack (Unit *victim)
 
SpellInfo const * reachWithSpellCure (Unit *victim)
 
bool CanStartAttack (Unit const *u) const
 
float GetAggroRange (Unit const *target) const
 
float GetAttackDistance (Unit const *player) const
 
float GetDetectionRange () const
 
void SendAIReaction (AiReaction reactionType)
 
UnitSelectNearestTarget (float dist=0, bool playerOnly=false) const
 
UnitSelectNearestTargetInAttackDistance (float dist) const
 
void DoFleeToGetAssistance ()
 
void CallForHelp (float fRadius, Unit *target=nullptr)
 
void CallAssistance (Unit *target=nullptr)
 
void SetNoCallAssistance (bool val)
 
void SetNoSearchAssistance (bool val)
 
bool HasSearchedAssistance ()
 
bool CanAssistTo (Unit const *u, Unit const *enemy, bool checkfaction=true) const
 
bool _IsTargetAcceptable (Unit const *target) const
 
bool CanIgnoreFeignDeath () const
 
void UpdateMoveInLineOfSightState ()
 
bool IsMoveInLineOfSightDisabled ()
 
bool IsMoveInLineOfSightStrictlyDisabled ()
 
void RemoveCorpse (bool setSpawnTime=true, bool skipVisibility=false)
 
void DespawnOrUnsummon (Milliseconds msTimeToDespawn, Seconds forcedRespawnTimer)
 
void DespawnOrUnsummon (uint32 msTimeToDespawn=0)
 
void DespawnOnEvade (Seconds respawnDelay=20s)
 
time_t const & GetRespawnTime () const
 
time_t GetRespawnTimeEx () const
 
void SetRespawnTime (uint32 respawn)
 
void Respawn (bool force=false)
 
void SaveRespawnTime () override
 
uint32 GetRespawnDelay () const
 
void SetRespawnDelay (uint32 delay)
 
uint32 GetCombatPulseDelay () const
 
void SetCombatPulseDelay (uint32 delay)
 
float GetWanderDistance () const
 
void SetWanderDistance (float dist)
 
void DoImmediateBoundaryCheck ()
 
void SendZoneUnderAttackMessage (Player *attacker)
 Send a message to LocalDefense channel for players opposition team in the zone.
 
void SetInCombatWithZone ()
 
bool hasQuest (uint32 quest_id) const override
 
bool hasInvolvedQuest (uint32 quest_id) const override
 
bool isRegeneratingHealth ()
 
void SetRegeneratingHealth (bool c)
 
void SetRegeneratingPower (bool c)
 
virtual uint8 GetPetAutoSpellSize () const
 
virtual uint32 GetPetAutoSpellOnPos (uint8 pos) const
 
void SetCannotReachTarget (ObjectGuid const &target=ObjectGuid::Empty)
 
bool CanNotReachTarget () const
 
bool IsNotReachableAndNeedRegen () const
 
void SetPosition (float x, float y, float z, float o)
 
void SetPosition (const Position &pos)
 
void SetHomePosition (float x, float y, float z, float o)
 
void SetHomePosition (const Position &pos)
 
void GetHomePosition (float &x, float &y, float &z, float &ori) const
 
Position const & GetHomePosition () const
 
void SetTransportHomePosition (float x, float y, float z, float o)
 
void SetTransportHomePosition (const Position &pos)
 
void GetTransportHomePosition (float &x, float &y, float &z, float &ori) const
 
Position const & GetTransportHomePosition () const
 
uint32 GetWaypointPath () const
 
void LoadPath (uint32 pathid)
 
uint32 GetCurrentWaypointID () const
 
void UpdateWaypointID (uint32 wpID)
 
void SearchFormation ()
 
CreatureGroup const * GetFormation () const
 
CreatureGroupGetFormation ()
 
void SetFormation (CreatureGroup *formation)
 
UnitSelectVictim ()
 
void SetDisableReputationGain (bool disable)
 
bool IsReputationGainDisabled () const
 
bool IsDamageEnoughForLootingAndReward () const
 
void LowerPlayerDamageReq (uint32 unDamage, bool damagedByPlayer=true)
 
void ResetPlayerDamageReq ()
 
uint32 GetPlayerDamageReq () const
 
uint32 GetOriginalEntry () const
 
void SetOriginalEntry (uint32 entry)
 
void SetTarget (ObjectGuid guid=ObjectGuid::Empty) override
 
void FocusTarget (Spell const *focusSpell, WorldObject const *target)
 
void ReleaseFocus (Spell const *focusSpell)
 
bool IsMovementPreventedByCasting () const override
 
time_t GetLastDamagedTime () const
 
std::shared_ptr< time_t > const & GetLastDamagedTimePtr () const
 
void SetLastDamagedTime (time_t val)
 
void SetLastDamagedTimePtr (std::shared_ptr< time_t > const &val)
 
bool IsFreeToMove ()
 
bool HasSwimmingFlagOutOfCombat () const
 
void RefreshSwimmingFlag (bool recheck=false)
 
void SetAssistanceTimer (uint32 value)
 
void ModifyThreatPercentTemp (Unit *victim, int32 percent, Milliseconds duration)
 
void ResumeChasingVictim ()
 Helper to resume chasing current victim.
 
std::string GetDebugInfo () const override
 
- Public Member Functions inherited from Unit
 ~Unit () override
 
UnitAIGetAI ()
 
void SetAI (UnitAI *newAI)
 
void AddToWorld () override
 
void RemoveFromWorld () override
 
void CleanupBeforeRemoveFromMap (bool finalCleanup)
 
void CleanupsBeforeDelete (bool finalCleanup=true) override
 
uint32 GetDynamicFlags () const override
 
void ReplaceAllDynamicFlags (uint32 flag) override
 
DiminishingLevels GetDiminishing (DiminishingGroup group)
 
void IncrDiminishing (DiminishingGroup group)
 
float ApplyDiminishingToDuration (DiminishingGroup group, int32 &duration, Unit *caster, DiminishingLevels Level, int32 limitduration)
 
void ApplyDiminishingAura (DiminishingGroup group, bool apply)
 
void ClearDiminishings ()
 
float GetSpellMaxRangeForTarget (Unit const *target, SpellInfo const *spellInfo) const
 
float GetSpellMinRangeForTarget (Unit const *target, SpellInfo const *spellInfo) const
 
void Update (uint32 time) override
 
void setAttackTimer (WeaponAttackType type, int32 time)
 
void resetAttackTimer (WeaponAttackType type=BASE_ATTACK)
 
int32 getAttackTimer (WeaponAttackType type) const
 
bool isAttackReady (WeaponAttackType type=BASE_ATTACK) const
 
bool haveOffhandWeapon () const
 
bool CanDualWield () const
 
virtual void SetCanDualWield (bool value)
 
float GetCombatReach () const override
 
float GetMeleeReach () const
 
bool IsWithinRange (Unit const *obj, float dist) const
 
bool IsWithinCombatRange (Unit const *obj, float dist2compare) const
 
bool IsWithinMeleeRange (Unit const *obj, float dist=0.f) const
 
float GetMeleeRange (Unit const *target) const
 
virtual SpellSchoolMask GetMeleeDamageSchoolMask (WeaponAttackType attackType=BASE_ATTACK, uint8 damageIndex=0) const =0
 
bool GetRandomContactPoint (Unit const *target, float &x, float &y, float &z, bool force=false) const
 
void _addAttacker (Unit *pAttacker)
 
void _removeAttacker (Unit *pAttacker)
 
UnitgetAttackerForHelper () const
 
bool Attack (Unit *victim, bool meleeAttack)
 
void CastStop (uint32 except_spellid=0, bool withInstant=true)
 
bool AttackStop ()
 
void RemoveAllAttackers ()
 
AttackerSet const & getAttackers () const
 
bool GetMeleeAttackPoint (Unit *attacker, Position &pos)
 
bool isAttackingPlayer () const
 
UnitGetVictim () const
 
void CombatStop (bool includingCast=false)
 
void CombatStopWithPets (bool includingCast=false)
 
void StopAttackFaction (uint32 faction_id)
 
void StopAttackingInvalidTarget ()
 
UnitSelectNearbyTarget (Unit *exclude=nullptr, float dist=NOMINAL_MELEE_RANGE) const
 
UnitSelectNearbyNoTotemTarget (Unit *exclude=nullptr, float dist=NOMINAL_MELEE_RANGE) const
 
void SendMeleeAttackStop (Unit *victim=nullptr)
 
void SendMeleeAttackStart (Unit *victim, Player *sendTo=nullptr)
 
void AddUnitState (uint32 f)
 
bool HasUnitState (const uint32 f) const
 
void ClearUnitState (uint32 f)
 
uint32 GetUnitState () const
 
bool CanFreeMove () const
 
uint32 HasUnitTypeMask (uint32 mask) const
 
void AddUnitTypeMask (uint32 mask)
 
uint32 GetUnitTypeMask () const
 
bool IsSummon () const
 
bool IsGuardian () const
 
bool IsControllableGuardian () const
 
bool IsPet () const
 
bool IsHunterPet () const
 
bool IsTotem () const
 
bool IsVehicle () const
 
uint8 getLevel () const
 
uint8 GetLevel () const
 
uint8 getLevelForTarget (WorldObject const *) const override
 
void SetLevel (uint8 lvl, bool showLevelChange=true)
 
uint8 getRace (bool original=false) const
 
void setRace (uint8 race)
 
uint32 getRaceMask () const
 
uint8 getClass () const
 
uint32 getClassMask () const
 
uint8 getGender () const
 
float GetStat (Stats stat) const
 
void SetStat (Stats stat, int32 val)
 
uint32 GetArmor () const
 
void SetArmor (int32 val)
 
uint32 GetResistance (SpellSchools school) const
 
uint32 GetResistance (SpellSchoolMask mask) const
 
void SetResistance (SpellSchools school, int32 val)
 
uint32 GetHealth () const
 
uint32 GetMaxHealth () const
 
bool IsFullHealth () const
 
bool HealthBelowPct (int32 pct) const
 
bool HealthBelowPctDamaged (int32 pct, uint32 damage) const
 
bool HealthAbovePct (int32 pct) const
 
bool HealthAbovePctHealed (int32 pct, uint32 heal) const
 
float GetHealthPct () const
 
uint32 CountPctFromMaxHealth (int32 pct) const
 
uint32 CountPctFromCurHealth (int32 pct) const
 
float GetPowerPct (Powers power) const
 
void SetHealth (uint32 val)
 
void SetMaxHealth (uint32 val)
 
void SetFullHealth ()
 
int32 ModifyHealth (int32 val)
 
int32 GetHealthGain (int32 dVal)
 
Powers getPowerType () const
 
void setPowerType (Powers power)
 
uint32 GetPower (Powers power) const
 
uint32 GetMaxPower (Powers power) const
 
void SetPower (Powers power, uint32 val, bool withPowerUpdate=true, bool fromRegenerate=false)
 
void SetMaxPower (Powers power, uint32 val)
 
int32 ModifyPower (Powers power, int32 val, bool withPowerUpdate=true)
 
int32 ModifyPowerPct (Powers power, float pct, bool apply=true)
 
uint32 GetAttackTime (WeaponAttackType att) const
 
void SetAttackTime (WeaponAttackType att, uint32 val)
 
void ApplyAttackTimePercentMod (WeaponAttackType att, float val, bool apply)
 
void ApplyCastTimePercentMod (float val, bool apply)
 
UnitFlags GetUnitFlags () const
 
bool HasUnitFlag (UnitFlags flags) const
 
void SetUnitFlag (UnitFlags flags)
 
void RemoveUnitFlag (UnitFlags flags)
 
void ReplaceAllUnitFlags (UnitFlags flags)
 
UnitFlags2 GetUnitFlags2 () const
 
bool HasUnitFlag2 (UnitFlags2 flags) const
 
void SetUnitFlag2 (UnitFlags2 flags)
 
void RemoveUnitFlag2 (UnitFlags2 flags)
 
void ReplaceAllUnitFlags2 (UnitFlags2 flags)
 
SheathState GetSheath () const
 
virtual void SetSheath (SheathState sheathed)
 
uint32 GetFaction () const
 
void SetFaction (uint32 faction)
 
FactionTemplateEntry const * GetFactionTemplateEntry () const
 
ReputationRank GetReactionTo (Unit const *target, bool checkOriginalFaction=false) const
 
ReputationRank GetFactionReactionTo (FactionTemplateEntry const *factionTemplateEntry, Unit const *target) const
 
bool IsHostileTo (Unit const *unit) const
 
bool IsHostileToPlayers () const
 
bool IsFriendlyTo (Unit const *unit) const
 
bool IsNeutralToAll () const
 
bool IsInPartyWith (Unit const *unit) const
 
bool IsInRaidWith (Unit const *unit) const
 
void GetPartyMembers (std::list< Unit * > &units)
 
bool IsContestedGuard () const
 
bool IsInSanctuary () const
 
bool IsPvP () const
 
bool IsFFAPvP () const
 
void SetPvP (bool state)
 
uint32 GetCreatureType () const
 
uint32 GetCreatureTypeMask () const
 
uint8 getStandState () const
 
bool IsSitState () const
 
bool IsStandState () const
 
void SetStandState (uint8 state)
 
void SetStandFlags (uint8 flags)
 
void RemoveStandFlags (uint8 flags)
 
bool IsMounted () const
 
uint32 GetMountID () const
 
void Mount (uint32 mount, uint32 vehicleId=0, uint32 creatureEntry=0)
 
void Dismount ()
 
uint16 GetMaxSkillValueForLevel (Unit const *target=nullptr) const
 
void KillSelf (bool durabilityLoss=true, WeaponAttackType attackType=BASE_ATTACK, SpellInfo const *spellProto=nullptr, Spell const *spell=nullptr)
 
void ProcDamageAndSpellFor (bool isVictim, Unit *target, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, SpellInfo const *procSpellInfo, uint32 damage, SpellInfo const *procAura=nullptr, int8 procAuraEffectIndex=-1, Spell const *procSpell=nullptr, DamageInfo *damageInfo=nullptr, HealInfo *healInfo=nullptr, uint32 procPhase=2)
 
void GetProcAurasTriggeredOnEvent (std::list< AuraApplication * > &aurasTriggeringProc, std::list< AuraApplication * > *procAuras, ProcEventInfo eventInfo)
 
void TriggerAurasProcOnEvent (CalcDamageInfo &damageInfo)
 
void TriggerAurasProcOnEvent (std::list< AuraApplication * > *myProcAuras, std::list< AuraApplication * > *targetProcAuras, Unit *actionTarget, uint32 typeMaskActor, uint32 typeMaskActionTarget, uint32 spellTypeMask, uint32 spellPhaseMask, uint32 hitMask, Spell *spell, DamageInfo *damageInfo, HealInfo *healInfo)
 
void TriggerAurasProcOnEvent (ProcEventInfo &eventInfo, std::list< AuraApplication * > &procAuras)
 
void HandleEmoteCommand (uint32 emoteId)
 
void AttackerStateUpdate (Unit *victim, WeaponAttackType attType=BASE_ATTACK, bool extra=false, bool ignoreCasting=false)
 
void CalculateMeleeDamage (Unit *victim, CalcDamageInfo *damageInfo, WeaponAttackType attackType=BASE_ATTACK, const bool sittingVictim=false)
 
void DealMeleeDamage (CalcDamageInfo *damageInfo, bool durabilityLoss)
 
void HandleProcExtraAttackFor (Unit *victim, uint32 count)
 
void SetLastExtraAttackSpell (uint32 spellId)
 
uint32 GetLastExtraAttackSpell () const
 
void AddExtraAttacks (uint32 count)
 
void SetLastDamagedTargetGuid (ObjectGuid const &guid)
 
ObjectGuid const & GetLastDamagedTargetGuid () const
 
void CalculateSpellDamageTaken (SpellNonMeleeDamage *damageInfo, int32 damage, SpellInfo const *spellInfo, WeaponAttackType attackType=BASE_ATTACK, bool crit=false)
 
void DealSpellDamage (SpellNonMeleeDamage *damageInfo, bool durabilityLoss, Spell const *spell=nullptr)
 
float GetMeleeCritChanceReduction () const
 
float GetRangedCritChanceReduction () const
 
float GetSpellCritChanceReduction () const
 
uint32 GetMeleeCritDamageReduction (uint32 damage) const
 
uint32 GetRangedCritDamageReduction (uint32 damage) const
 
uint32 GetSpellCritDamageReduction (uint32 damage) const
 
uint32 GetMeleeDamageReduction (uint32 damage) const
 
uint32 GetRangedDamageReduction (uint32 damage) const
 
uint32 GetSpellDamageReduction (uint32 damage) const
 
float MeleeSpellMissChance (Unit const *victim, WeaponAttackType attType, int32 skillDiff, uint32 spellId) const
 
SpellMissInfo MeleeSpellHitResult (Unit *victim, SpellInfo const *spell)
 
SpellMissInfo MagicSpellHitResult (Unit *victim, SpellInfo const *spell)
 
SpellMissInfo SpellHitResult (Unit *victim, SpellInfo const *spell, bool canReflect=false)
 
SpellMissInfo SpellHitResult (Unit *victim, Spell const *spell, bool canReflect=false)
 
float GetUnitDodgeChance () const
 
float GetUnitParryChance () const
 
float GetUnitBlockChance () const
 
float GetUnitMissChance (WeaponAttackType attType) const
 
float GetUnitCriticalChance (WeaponAttackType attackType, Unit const *victim) const
 
int32 GetMechanicResistChance (SpellInfo const *spell)
 
bool CanUseAttackType (uint8 attacktype) const
 
virtual uint32 GetShieldBlockValue () const =0
 
uint32 GetShieldBlockValue (uint32 soft_cap, uint32 hard_cap) const
 
uint32 GetUnitMeleeSkill (Unit const *target=nullptr) const
 
uint32 GetDefenseSkillValue (Unit const *target=nullptr) const
 
uint32 GetWeaponSkillValue (WeaponAttackType attType, Unit const *target=nullptr) const
 
float GetWeaponProcChance () const
 
float GetPPMProcChance (uint32 WeaponSpeed, float PPM, SpellInfo const *spellProto) const
 
MeleeHitOutcome RollMeleeOutcomeAgainst (Unit const *victim, WeaponAttackType attType) const
 
MeleeHitOutcome RollMeleeOutcomeAgainst (Unit const *victim, WeaponAttackType attType, int32 crit_chance, int32 miss_chance, int32 dodge_chance, int32 parry_chance, int32 block_chance) const
 
NPCFlags GetNpcFlags () const
 
bool HasNpcFlag (NPCFlags flags) const
 
void SetNpcFlag (NPCFlags flags)
 
void RemoveNpcFlag (NPCFlags flags)
 
void ReplaceAllNpcFlags (NPCFlags flags)
 
bool IsVendor () const
 
bool IsTrainer () const
 
bool IsQuestGiver () const
 
bool IsGossip () const
 
bool IsTaxi () const
 
bool IsGuildMaster () const
 
bool IsBattleMaster () const
 
bool IsBanker () const
 
bool IsInnkeeper () const
 
bool IsSpiritHealer () const
 
bool IsSpiritGuide () const
 
bool IsTabardDesigner () const
 
bool IsAuctioner () const
 
bool IsArmorer () const
 
bool IsServiceProvider () const
 
bool IsSpiritService () const
 
bool IsCritter () const
 
bool IsInFlight () const
 
void SetImmuneToAll (bool apply, bool keepCombat=false)
 
bool IsImmuneToAll () const
 
void SetImmuneToPC (bool apply, bool keepCombat=false)
 
bool IsImmuneToPC () const
 
void SetImmuneToNPC (bool apply, bool keepCombat=false)
 
bool IsImmuneToNPC () const
 
bool IsEngaged () const
 
bool IsEngagedBy (Unit const *who) const
 
bool IsInCombat () const
 
bool IsInCombatWith (Unit const *who) const
 
bool IsPetInCombat () const
 
void CombatStart (Unit *target, bool initialAggro=true)
 
void CombatStartOnCast (Unit *target, bool initialAggro=true, uint32 duration=0)
 
void SetInCombatState (bool PvP, Unit *enemy=nullptr, uint32 duration=0)
 
void SetInCombatWith (Unit *enemy, uint32 duration=0)
 
void ClearInCombat ()
 
void ClearInPetCombat ()
 
uint32 GetCombatTimer () const
 
void SetCombatTimer (uint32 timer)
 
bool HasAuraTypeWithFamilyFlags (AuraType auraType, uint32 familyName, uint32 familyFlags) const
 
virtual bool HasSpell (uint32) const
 
bool HasBreakableByDamageAuraType (AuraType type, uint32 excludeAura=0) const
 
bool HasBreakableByDamageCrowdControlAura (Unit *excludeCasterChannel=nullptr) const
 
bool HasStealthAura () const
 
bool HasInvisibilityAura () const
 
bool isFeared () const
 
bool isInRoots () const
 
bool IsPolymorphed () const
 
bool isFrozen () const
 
bool isTargetableForAttack (bool checkFakeDeath=true, Unit const *byWho=nullptr) const
 
bool IsValidAttackTarget (Unit const *target, SpellInfo const *bySpell=nullptr) const
 
bool _IsValidAttackTarget (Unit const *target, SpellInfo const *bySpell, WorldObject const *obj=nullptr) const
 
bool IsValidAssistTarget (Unit const *target) const
 
bool _IsValidAssistTarget (Unit const *target, SpellInfo const *bySpell) const
 
virtual bool IsInWater () const
 
virtual bool IsUnderWater () const
 
bool isInAccessiblePlaceFor (Creature const *c) const
 
void SendHealSpellLog (Unit *victim, uint32 SpellID, uint32 Damage, uint32 OverHeal, uint32 Absorb, bool critical=false)
 
int32 HealBySpell (HealInfo &healInfo, bool critical=false)
 
void SendEnergizeSpellLog (Unit *victim, uint32 SpellID, uint32 Damage, Powers powertype)
 
void EnergizeBySpell (Unit *victim, uint32 SpellID, uint32 Damage, Powers powertype)
 
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)
 
SpellCastResult CastSpell (Unit *victim, uint32 spellId, bool triggered, Item *castItem=nullptr, AuraEffect const *triggeredByAura=nullptr, ObjectGuid originalCaster=ObjectGuid::Empty)
 
SpellCastResult CastSpell (Unit *victim, uint32 spellId, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=nullptr, AuraEffect const *triggeredByAura=nullptr, ObjectGuid originalCaster=ObjectGuid::Empty)
 
SpellCastResult CastSpell (Unit *victim, SpellInfo const *spellInfo, bool triggered, Item *castItem=nullptr, AuraEffect const *triggeredByAura=nullptr, ObjectGuid originalCaster=ObjectGuid::Empty)
 
SpellCastResult CastSpell (Unit *victim, SpellInfo const *spellInfo, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=nullptr, AuraEffect const *triggeredByAura=nullptr, ObjectGuid originalCaster=ObjectGuid::Empty)
 
SpellCastResult CastSpell (float x, float y, float z, uint32 spellId, bool triggered, Item *castItem=nullptr, AuraEffect const *triggeredByAura=nullptr, ObjectGuid originalCaster=ObjectGuid::Empty)
 
SpellCastResult CastSpell (GameObject *go, uint32 spellId, bool triggered, Item *castItem=nullptr, AuraEffect *triggeredByAura=nullptr, ObjectGuid originalCaster=ObjectGuid::Empty)
 
SpellCastResult CastCustomSpell (Unit *victim, uint32 spellId, int32 const *bp0, int32 const *bp1, int32 const *bp2, bool triggered, Item *castItem=nullptr, AuraEffect const *triggeredByAura=nullptr, ObjectGuid originalCaster=ObjectGuid::Empty)
 
SpellCastResult CastCustomSpell (uint32 spellId, SpellValueMod mod, int32 value, Unit *victim, bool triggered, Item *castItem=nullptr, AuraEffect const *triggeredByAura=nullptr, ObjectGuid originalCaster=ObjectGuid::Empty)
 
SpellCastResult CastCustomSpell (uint32 spellId, SpellValueMod mod, int32 value, Unit *victim=nullptr, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=nullptr, AuraEffect const *triggeredByAura=nullptr, ObjectGuid originalCaster=ObjectGuid::Empty)
 
SpellCastResult CastCustomSpell (uint32 spellId, CustomSpellValues const &value, Unit *victim=nullptr, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=nullptr, AuraEffect const *triggeredByAura=nullptr, ObjectGuid originalCaster=ObjectGuid::Empty)
 
AuraAddAura (uint32 spellId, Unit *target)
 
AuraAddAura (SpellInfo const *spellInfo, uint8 effMask, Unit *target)
 
void SetAuraStack (uint32 spellId, Unit *target, uint32 stack)
 
void SendPlaySpellVisual (uint32 id)
 
void SendPlaySpellImpact (ObjectGuid guid, uint32 id)
 
void BuildCooldownPacket (WorldPacket &data, uint8 flags, uint32 spellId, uint32 cooldown)
 
void BuildCooldownPacket (WorldPacket &data, uint8 flags, PacketCooldowns const &cooldowns)
 
void DeMorph ()
 
void SendAttackStateUpdate (CalcDamageInfo *damageInfo)
 
void SendAttackStateUpdate (uint32 HitInfo, Unit *target, uint8 SwingType, SpellSchoolMask damageSchoolMask, uint32 Damage, uint32 AbsorbDamage, uint32 Resist, VictimState TargetState, uint32 BlockedAmount)
 
void SendSpellNonMeleeDamageLog (SpellNonMeleeDamage *log)
 
void SendSpellNonMeleeReflectLog (SpellNonMeleeDamage *log, Unit *attacker)
 
void SendSpellNonMeleeDamageLog (Unit *target, SpellInfo const *spellInfo, uint32 Damage, SpellSchoolMask damageSchoolMask, uint32 AbsorbedDamage, uint32 Resist, bool PhysicalDamage, uint32 Blocked, bool CriticalHit=false, bool Split=false)
 
void SendPeriodicAuraLog (SpellPeriodicAuraLogInfo *pInfo)
 
void SendSpellMiss (Unit *target, uint32 spellID, SpellMissInfo missInfo)
 
void SendSpellDamageResist (Unit *target, uint32 spellId)
 
void SendSpellDamageImmune (Unit *target, uint32 spellId)
 
void NearTeleportTo (Position &pos, bool casting=false, bool vehicleTeleport=false, bool withPet=false, bool removeTransport=false)
 
void NearTeleportTo (float x, float y, float z, float orientation, bool casting=false, bool vehicleTeleport=false, bool withPet=false, bool removeTransport=false)
 
void SendTameFailure (uint8 result)
 
void SendTeleportPacket (Position &pos)
 
virtual bool UpdatePosition (float x, float y, float z, float ang, bool teleport=false)
 
bool UpdatePosition (const Position &pos, bool teleport=false)
 
void UpdateOrientation (float orientation)
 Only server-side orientation update, does not broadcast to client.
 
void UpdateHeight (float newZ)
 Only server-side height update, does not broadcast to client.
 
void KnockbackFrom (float x, float y, float speedXY, float speedZ)
 
void JumpTo (float speedXY, float speedZ, bool forward=true)
 
void JumpTo (WorldObject *obj, float speedZ)
 
void SendMonsterMove (float NewPosX, float NewPosY, float NewPosZ, uint32 TransitTime, SplineFlags sf=SPLINEFLAG_WALK_MODE)
 
void MonsterMoveWithSpeed (float x, float y, float z, float speed)
 
void SendMovementFlagUpdate (bool self=false)
 
virtual bool SetWalk (bool enable)
 
virtual bool SetDisableGravity (bool disable, bool packetOnly=false, bool updateAnimationTier=true)
 
virtual bool SetSwim (bool enable)
 
virtual bool SetCanFly (bool enable, bool packetOnly=false)
 
virtual bool SetWaterWalking (bool enable, bool packetOnly=false)
 
virtual bool SetFeatherFall (bool enable, bool packetOnly=false)
 
virtual bool SetHover (bool enable, bool packetOnly=false, bool updateAnimationTier=true)
 
void SendMovementWaterWalking (Player *sendTo)
 
void SendMovementFeatherFall (Player *sendTo)
 
void SendMovementHover (Player *sendTo)
 
void SetInFront (WorldObject const *target)
 
void SetFacingTo (float ori)
 
void SetFacingToObject (WorldObject *object)
 
void SendChangeCurrentVictimOpcode (HostileReference *pHostileReference)
 
void SendClearThreatListOpcode ()
 
void SendRemoveFromThreatListOpcode (HostileReference *pHostileReference)
 
void SendThreatListUpdate ()
 
void SendClearTarget ()
 
void BuildHeartBeatMsg (WorldPacket *data) const
 
bool IsAlive () const
 
bool isDying () const
 
bool isDead () const
 
DeathState getDeathState ()
 
virtual void setDeathState (DeathState s, bool despawn=false)
 
ObjectGuid GetOwnerGUID () const
 
void SetOwnerGUID (ObjectGuid owner)
 
ObjectGuid GetCreatorGUID () const
 
void SetCreatorGUID (ObjectGuid creator)
 
ObjectGuid GetMinionGUID () const
 
void SetMinionGUID (ObjectGuid guid)
 
ObjectGuid GetCharmerGUID () const
 
void SetCharmerGUID (ObjectGuid owner)
 
ObjectGuid GetCharmGUID () const
 
void SetPetGUID (ObjectGuid guid)
 
ObjectGuid GetPetGUID () const
 
void SetCritterGUID (ObjectGuid guid)
 
ObjectGuid GetCritterGUID () const
 
bool IsControlledByPlayer () const
 
bool IsCreatedByPlayer () const
 
ObjectGuid GetCharmerOrOwnerGUID () const
 
ObjectGuid GetCharmerOrOwnerOrOwnGUID () const
 
bool IsCharmedOwnedByPlayerOrPlayer () const
 
PlayerGetSpellModOwner () const
 
UnitGetOwner () const
 
GuardianGetGuardianPet () const
 
MinionGetFirstMinion () const
 
UnitGetCharmer () const
 
UnitGetCharm () const
 
UnitGetCharmerOrOwner () const
 
UnitGetCharmerOrOwnerOrSelf () const
 
PlayerGetCharmerOrOwnerPlayerOrPlayerItself () const
 
PlayerGetAffectingPlayer () const
 
void SetMinion (Minion *minion, bool apply)
 
void GetAllMinionsByEntry (std::list< Creature * > &Minions, uint32 entry)
 
void RemoveAllMinionsByEntry (uint32 entry)
 
void SetCharm (Unit *target, bool apply)
 
UnitGetNextRandomRaidMemberOrPet (float radius)
 
bool SetCharmedBy (Unit *charmer, CharmType type, AuraApplication const *aurApp=nullptr)
 
void RemoveCharmedBy (Unit *charmer)
 
void RestoreFaction ()
 
UnitGetFirstControlled () const
 
void RemoveAllControlled (bool onDeath=false)
 
bool IsCharmed () const
 
bool isPossessed () const
 
bool isPossessedByPlayer () const
 
bool isPossessing () const
 
bool isPossessing (Unit *u) const
 
CharmInfoGetCharmInfo ()
 
CharmInfoInitCharmInfo ()
 
void DeleteCharmInfo ()
 
void UpdateCharmAI ()
 
SharedVisionList const & GetSharedVisionList ()
 
void AddPlayerToVision (Player *player)
 
void RemovePlayerFromVision (Player *player)
 
bool HasSharedVision () const
 
void RemoveBindSightAuras ()
 
void RemoveCharmAuras ()
 
PetCreateTamedPetFrom (Creature *creatureTarget, uint32 spell_id=0)
 
PetCreateTamedPetFrom (uint32 creatureEntry, uint32 spell_id=0)
 
bool InitTamedPet (Pet *pet, uint8 level, uint32 spell_id)
 
Aura_TryStackingOrRefreshingExistingAura (SpellInfo const *newAura, uint8 effMask, Unit *caster, int32 *baseAmount=nullptr, Item *castItem=nullptr, ObjectGuid casterGUID=ObjectGuid::Empty, bool periodicReset=false)
 
void _AddAura (UnitAura *aura, Unit *caster)
 
AuraApplication_CreateAuraApplication (Aura *aura, uint8 effMask)
 
void _ApplyAuraEffect (Aura *aura, uint8 effIndex)
 
void _ApplyAura (AuraApplication *aurApp, uint8 effMask)
 
void _UnapplyAura (AuraApplicationMap::iterator &i, AuraRemoveMode removeMode)
 
void _UnapplyAura (AuraApplication *aurApp, AuraRemoveMode removeMode)
 
void _RemoveNoStackAuraApplicationsDueToAura (Aura *aura)
 
void _RemoveNoStackAurasDueToAura (Aura *aura)
 
bool _IsNoStackAuraDueToAura (Aura *appliedAura, Aura *existingAura) const
 
void _RegisterAuraEffect (AuraEffect *aurEff, bool apply)
 
AuraMapGetOwnedAuras ()
 
AuraMap const & GetOwnedAuras () const
 
void RemoveOwnedAura (AuraMap::iterator &i, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
 
void RemoveOwnedAura (uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
 
void RemoveOwnedAura (Aura *aura, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
 
AuraGetOwnedAura (uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, Aura *except=nullptr) const
 
AuraApplicationMapGetAppliedAuras ()
 
AuraApplicationMap const & GetAppliedAuras () const
 
void RemoveAura (AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
 
void RemoveAura (uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
 
void RemoveAura (AuraApplication *aurApp, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
 
void RemoveAura (Aura *aur, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
 
void RemoveAppliedAuras (std::function< bool(AuraApplication const *)> const &check)
 
void RemoveOwnedAuras (std::function< bool(Aura const *)> const &check)
 
void RemoveAppliedAuras (uint32 spellId, std::function< bool(AuraApplication const *)> const &check)
 
void RemoveOwnedAuras (uint32 spellId, std::function< bool(Aura const *)> const &check)
 
void RemoveAurasDueToSpell (uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
 
void RemoveAuraFromStack (uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
 
void RemoveAurasDueToSpellByDispel (uint32 spellId, uint32 dispellerSpellId, ObjectGuid casterGUID, Unit *dispeller, uint8 chargesRemoved=1)
 
void RemoveAurasDueToSpellBySteal (uint32 spellId, ObjectGuid casterGUID, Unit *stealer)
 
void RemoveAurasDueToItemSpell (uint32 spellId, ObjectGuid castItemGuid)
 
void RemoveAurasByType (AuraType auraType, ObjectGuid casterGUID=ObjectGuid::Empty, Aura *except=nullptr, bool negative=true, bool positive=true)
 
void RemoveNotOwnSingleTargetAuras ()
 
void RemoveAurasWithInterruptFlags (uint32 flag, uint32 except=0, bool isAutoshot=false)
 
void RemoveAurasWithAttribute (uint32 flags)
 
void RemoveAurasWithFamily (SpellFamilyNames family, uint32 familyFlag1, uint32 familyFlag2, uint32 familyFlag3, ObjectGuid casterGUID)
 
void RemoveAurasWithMechanic (uint32 mechanic_mask, AuraRemoveMode removemode=AURA_REMOVE_BY_DEFAULT, uint32 except=0)
 
void RemoveMovementImpairingAuras (bool withRoot)
 
void RemoveAurasByShapeShift ()
 
void RemoveAreaAurasDueToLeaveWorld ()
 
void RemoveAllAuras ()
 
void RemoveArenaAuras ()
 
void RemoveAllAurasOnDeath ()
 
void RemoveAllAurasRequiringDeadTarget ()
 
void RemoveAllAurasExceptType (AuraType type)
 
void RemoveEvadeAuras ()
 
void DelayOwnedAuras (uint32 spellId, ObjectGuid caster, int32 delaytime)
 
void _RemoveAllAuraStatMods ()
 
void _ApplyAllAuraStatMods ()
 
AuraEffectList const & GetAuraEffectsByType (AuraType type) const
 
AuraListGetSingleCastAuras ()
 
AuraList const & GetSingleCastAuras () const
 
AuraEffectGetAuraEffect (uint32 spellId, uint8 effIndex, ObjectGuid casterGUID=ObjectGuid::Empty) const
 
AuraEffectGetAuraEffectOfRankedSpell (uint32 spellId, uint8 effIndex, ObjectGuid casterGUID=ObjectGuid::Empty) const
 
AuraEffectGetAuraEffect (AuraType type, SpellFamilyNames name, uint32 iconId, uint8 effIndex) const
 
AuraEffectGetAuraEffect (AuraType type, SpellFamilyNames family, uint32 familyFlag1, uint32 familyFlag2, uint32 familyFlag3, ObjectGuid casterGUID=ObjectGuid::Empty) const
 
AuraEffectGetAuraEffectDummy (uint32 spellid) const
 
AuraEffectGetDummyAuraEffect (SpellFamilyNames name, uint32 iconId, uint8 effIndex) const
 
AuraApplicationGetAuraApplication (uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraApplication *except=nullptr) const
 
AuraGetAura (uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
 
AuraApplicationGetAuraApplicationOfRankedSpell (uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraApplication *except=nullptr) const
 
AuraGetAuraOfRankedSpell (uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
 
void GetDispellableAuraList (Unit *caster, uint32 dispelMask, DispelChargesList &dispelList)
 
bool HasAuraEffect (uint32 spellId, uint8 effIndex, ObjectGuid caster=ObjectGuid::Empty) const
 
uint32 GetAuraCount (uint32 spellId) const
 
bool HasAura (uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
 
bool HasAuraType (AuraType auraType) const
 
bool HasAuraTypeWithCaster (AuraType auratype, ObjectGuid caster) const
 
bool HasAuraTypeWithMiscvalue (AuraType auratype, int32 miscvalue) const
 
bool HasAuraTypeWithAffectMask (AuraType auratype, SpellInfo const *affectedSpell) const
 
bool HasAuraTypeWithValue (AuraType auratype, int32 value) const
 
bool HasAuraTypeWithTriggerSpell (AuraType auratype, uint32 triggerSpell) const
 
bool HasNegativeAuraWithInterruptFlag (uint32 flag, ObjectGuid guid=ObjectGuid::Empty)
 
bool HasVisibleAuraType (AuraType auraType) const
 
bool HasNegativeAuraWithAttribute (uint32 flag, ObjectGuid guid=ObjectGuid::Empty)
 
bool HasAuraWithMechanic (uint32 mechanicMask) const
 
AuraEffectIsScriptOverriden (SpellInfo const *spell, int32 script) const
 
uint32 GetDiseasesByCaster (ObjectGuid casterGUID, uint8 mode=0)
 
uint32 GetDoTsByCaster (ObjectGuid casterGUID) const
 
int32 GetTotalAuraModifierAreaExclusive (AuraType auratype) const
 
int32 GetTotalAuraModifier (AuraType auratype) const
 
float GetTotalAuraMultiplier (AuraType auratype) const
 
int32 GetMaxPositiveAuraModifier (AuraType auratype)
 
int32 GetMaxNegativeAuraModifier (AuraType auratype) const
 
int32 GetTotalAuraModifierByMiscMask (AuraType auratype, uint32 misc_mask) const
 
float GetTotalAuraMultiplierByMiscMask (AuraType auratype, uint32 misc_mask) const
 
int32 GetMaxPositiveAuraModifierByMiscMask (AuraType auratype, uint32 misc_mask, const AuraEffect *except=nullptr) const
 
int32 GetMaxNegativeAuraModifierByMiscMask (AuraType auratype, uint32 misc_mask) const
 
int32 GetTotalAuraModifierByMiscValue (AuraType auratype, int32 misc_value) const
 
float GetTotalAuraMultiplierByMiscValue (AuraType auratype, int32 misc_value) const
 
int32 GetMaxPositiveAuraModifierByMiscValue (AuraType auratype, int32 misc_value) const
 
int32 GetMaxNegativeAuraModifierByMiscValue (AuraType auratype, int32 misc_value) const
 
int32 GetTotalAuraModifierByAffectMask (AuraType auratype, SpellInfo const *affectedSpell) const
 
float GetTotalAuraMultiplierByAffectMask (AuraType auratype, SpellInfo const *affectedSpell) const
 
int32 GetMaxPositiveAuraModifierByAffectMask (AuraType auratype, SpellInfo const *affectedSpell) const
 
int32 GetMaxNegativeAuraModifierByAffectMask (AuraType auratype, SpellInfo const *affectedSpell) const
 
float GetResistanceBuffMods (SpellSchools school, bool positive) const
 
void SetResistanceBuffMods (SpellSchools school, bool positive, float val)
 
void ApplyResistanceBuffModsMod (SpellSchools school, bool positive, float val, bool apply)
 
void ApplyResistanceBuffModsPercentMod (SpellSchools school, bool positive, float val, bool apply)
 
void InitStatBuffMods ()
 
void ApplyStatBuffMod (Stats stat, float val, bool apply)
 
void ApplyStatPercentBuffMod (Stats stat, float val, bool apply)
 
void SetCreateStat (Stats stat, float val)
 
void SetCreateHealth (uint32 val)
 
uint32 GetCreateHealth () const
 
void SetCreateMana (uint32 val)
 
uint32 GetCreateMana () const
 
uint32 GetCreatePowers (Powers power) const
 
float GetPosStat (Stats stat) const
 
float GetNegStat (Stats stat) const
 
float GetCreateStat (Stats stat) const
 
void SetCurrentCastedSpell (Spell *pSpell)
 
virtual void ProhibitSpellSchool (SpellSchoolMask, uint32)
 
void InterruptSpell (CurrentSpellTypes spellType, bool withDelayed=true, bool withInstant=true, bool bySelf=false)
 
void FinishSpell (CurrentSpellTypes spellType, bool ok=true)
 
bool IsNonMeleeSpellCast (bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false, bool isAutoshoot=false, bool skipInstant=true) const
 
void InterruptNonMeleeSpells (bool withDelayed, uint32 spellid=0, bool withInstant=true, bool bySelf=false)
 
SpellGetCurrentSpell (CurrentSpellTypes spellType) const
 
SpellGetCurrentSpell (uint32 spellType) const
 
SpellFindCurrentSpellBySpellId (uint32 spell_id) const
 
int32 GetCurrentSpellCastTime (uint32 spell_id) const
 
virtual bool IsMovementPreventedByCasting () const
 
ShapeshiftForm GetShapeshiftForm () const
 
void SetShapeshiftForm (ShapeshiftForm form)
 
bool IsInFeralForm () const
 
bool IsInDisallowedMountForm () const
 
bool HandleStatModifier (UnitMods unitMod, UnitModifierType modifierType, float amount, bool apply)
 
void SetModifierValue (UnitMods unitMod, UnitModifierType modifierType, float value)
 
float GetModifierValue (UnitMods unitMod, UnitModifierType modifierType) const
 
float GetTotalStatValue (Stats stat, float additionalValue=0.0f) const
 
float GetTotalAuraModValue (UnitMods unitMod) const
 
SpellSchools GetSpellSchoolByAuraGroup (UnitMods unitMod) const
 
Stats GetStatByAuraGroup (UnitMods unitMod) const
 
Powers GetPowerTypeByAuraGroup (UnitMods unitMod) const
 
bool CanModifyStats () const
 
void SetCanModifyStats (bool modifyStats)
 
virtual bool UpdateStats (Stats stat)=0
 
virtual bool UpdateAllStats ()=0
 
virtual void UpdateResistances (uint32 school)=0
 
virtual void UpdateAllResistances ()
 
virtual void UpdateArmor ()=0
 
virtual void UpdateMaxHealth ()=0
 
virtual void UpdateMaxPower (Powers power)=0
 
virtual void UpdateAttackPowerAndDamage (bool ranged=false)=0
 
virtual void UpdateDamagePhysical (WeaponAttackType attType)
 
float GetTotalAttackPowerValue (WeaponAttackType attType, Unit *pVictim=nullptr) const
 
float GetWeaponDamageRange (WeaponAttackType attType, WeaponDamageRange type, uint8 damageIndex=0) const
 
void SetBaseWeaponDamage (WeaponAttackType attType, WeaponDamageRange damageRange, float value, uint8 damageIndex=0)
 
virtual void CalculateMinMaxDamage (WeaponAttackType attType, bool normalized, bool addTotalPct, float &minDamage, float &maxDamage, uint8 damageIndex=0)=0
 
uint32 CalculateDamage (WeaponAttackType attType, bool normalized, bool addTotalPct, uint8 itemDamagesMask=0)
 
float GetAPMultiplier (WeaponAttackType attType, bool normalized)
 
bool isInFrontInMap (Unit const *target, float distance, float arc=M_PI) const
 
bool isInBackInMap (Unit const *target, float distance, float arc=M_PI) const
 
bool IsVisible () const
 
void SetVisible (bool x)
 
void SetModelVisible (bool on)
 
uint32 GetPhaseByAuras () const
 
void SetPhaseMask (uint32 newPhaseMask, bool update) override
 
void UpdateObjectVisibility (bool forced=true, bool fromUpdate=false) override
 
bool CanHaveThreatList () const
 
void AddThreat (Unit *victim, float fThreat, SpellSchoolMask schoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellInfo const *threatSpell=nullptr)
 
float ApplyTotalThreatModifier (float fThreat, SpellSchoolMask schoolMask=SPELL_SCHOOL_MASK_NORMAL)
 
void TauntApply (Unit *victim)
 
void TauntFadeOut (Unit *taunter)
 
ThreatMgrGetThreatMgr ()
 
ThreatMgr const & GetThreatMgr () const
 
void addHatedBy (HostileReference *pHostileReference)
 
void removeHatedBy (HostileReference *)
 
HostileRefMgrgetHostileRefMgr ()
 
VisibleAuraMap const * GetVisibleAuras ()
 
AuraApplicationGetVisibleAura (uint8 slot)
 
void SetVisibleAura (uint8 slot, AuraApplication *aur)
 
void RemoveVisibleAura (uint8 slot)
 
uint32 GetInterruptMask () const
 
void AddInterruptMask (uint32 mask)
 
void UpdateInterruptMask ()
 
virtual float GetNativeObjectScale () const
 
virtual void RecalculateObjectScale ()
 
uint32 GetDisplayId () const
 
virtual void SetDisplayId (uint32 modelId)
 
uint32 GetNativeDisplayId () const
 
void RestoreDisplayId ()
 
void SetNativeDisplayId (uint32 modelId)
 
void setTransForm (uint32 spellid)
 
uint32 getTransForm () const
 
void _RegisterDynObject (DynamicObject *dynObj)
 
void _UnregisterDynObject (DynamicObject *dynObj)
 
DynamicObjectGetDynObject (uint32 spellId)
 
bool RemoveDynObject (uint32 spellId)
 
void RemoveAllDynObjects ()
 
GameObjectGetGameObject (uint32 spellId) const
 
void AddGameObject (GameObject *gameObj)
 
void RemoveGameObject (GameObject *gameObj, bool del)
 
void RemoveGameObject (uint32 spellid, bool del)
 
void RemoveAllGameObjects ()
 
void ModifyAuraState (AuraStateType flag, bool apply)
 
uint32 BuildAuraStateUpdateForTarget (Unit *target) const
 
bool HasAuraState (AuraStateType flag, SpellInfo const *spellProto=nullptr, Unit const *Caster=nullptr) const
 
void UnsummonAllTotems (bool onDeath=false)
 
UnitGetMagicHitRedirectTarget (Unit *victim, SpellInfo const *spellInfo)
 
UnitGetMeleeHitRedirectTarget (Unit *victim, SpellInfo const *spellInfo=nullptr)
 
int32 SpellBaseDamageBonusDone (SpellSchoolMask schoolMask)
 
int32 SpellBaseDamageBonusTaken (SpellSchoolMask schoolMask, bool isDoT=false)
 
float SpellPctDamageModsDone (Unit *victim, SpellInfo const *spellProto, DamageEffectType damagetype)
 
uint32 SpellDamageBonusDone (Unit *victim, SpellInfo const *spellProto, uint32 pdamage, DamageEffectType damagetype, uint8 effIndex, float TotalMod=0.0f, uint32 stack=1)
 
uint32 SpellDamageBonusTaken (Unit *caster, SpellInfo const *spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack=1)
 
int32 SpellBaseHealingBonusDone (SpellSchoolMask schoolMask)
 
int32 SpellBaseHealingBonusTaken (SpellSchoolMask schoolMask)
 
float SpellPctHealingModsDone (Unit *victim, SpellInfo const *spellProto, DamageEffectType damagetype)
 
uint32 SpellHealingBonusDone (Unit *victim, SpellInfo const *spellProto, uint32 healamount, DamageEffectType damagetype, uint8 effIndex, float TotalMod=0.0f, uint32 stack=1)
 
uint32 SpellHealingBonusTaken (Unit *caster, SpellInfo const *spellProto, uint32 healamount, DamageEffectType damagetype, uint32 stack=1)
 
uint32 MeleeDamageBonusDone (Unit *pVictim, uint32 damage, WeaponAttackType attType, SpellInfo const *spellProto=nullptr, SpellSchoolMask damageSchoolMask=SPELL_SCHOOL_MASK_NORMAL)
 
uint32 MeleeDamageBonusTaken (Unit *attacker, uint32 pdamage, WeaponAttackType attType, SpellInfo const *spellProto=nullptr, SpellSchoolMask damageSchoolMask=SPELL_SCHOOL_MASK_NORMAL)
 
bool isSpellBlocked (Unit *victim, SpellInfo const *spellProto, WeaponAttackType attackType=BASE_ATTACK)
 
bool isBlockCritical ()
 
float SpellDoneCritChance (Unit const *, SpellInfo const *spellProto, SpellSchoolMask schoolMask, WeaponAttackType attackType, bool skipEffectCheck) const
 
float SpellTakenCritChance (Unit const *caster, SpellInfo const *spellProto, SpellSchoolMask schoolMask, float doneChance, WeaponAttackType attackType, bool skipEffectCheck) const
 
void SetLastManaUse (uint32 spellCastTime)
 
bool IsUnderLastManaUseEffect () const
 
void SetContestedPvP (Player *attackedPlayer=nullptr, bool lookForNearContestedGuards=true)
 
uint32 GetCastingTimeForBonus (SpellInfo const *spellProto, DamageEffectType damagetype, uint32 CastingTime) const
 
float CalculateDefaultCoefficient (SpellInfo const *spellInfo, DamageEffectType damagetype) const
 
void CastDelayedSpellWithPeriodicAmount (Unit *caster, uint32 spellId, AuraType auraType, int32 addAmount, uint8 effectIndex=0)
 
void ApplySpellImmune (uint32 spellId, uint32 op, uint32 type, bool apply, SpellImmuneBlockType blockType=SPELL_BLOCK_TYPE_ALL)
 
void ApplySpellDispelImmunity (SpellInfo const *spellProto, DispelType type, bool apply)
 
virtual bool IsImmunedToSpell (SpellInfo const *spellInfo, Spell const *spell=nullptr)
 
bool IsImmunedToDamage (SpellSchoolMask meleeSchoolMask) const
 
bool IsImmunedToDamage (SpellInfo const *spellInfo) const
 
bool IsImmunedToDamage (Spell const *spell) const
 
bool IsImmunedToSchool (SpellSchoolMask meleeSchoolMask) const
 
bool IsImmunedToSchool (SpellInfo const *spellInfo) const
 
bool IsImmunedToSchool (Spell const *spell) const
 
bool IsImmunedToDamageOrSchool (SpellSchoolMask meleeSchoolMask) const
 
bool IsImmunedToDamageOrSchool (SpellInfo const *spellInfo) const
 
virtual bool IsImmunedToSpellEffect (SpellInfo const *spellInfo, uint32 index) const
 
void UpdateSpeed (UnitMoveType mtype, bool forced)
 
float GetSpeed (UnitMoveType mtype) const
 
float GetSpeedRate (UnitMoveType mtype) const
 
void SetSpeed (UnitMoveType mtype, float rate, bool forced=false)
 
void SetSpeedRate (UnitMoveType mtype, float rate)
 
float ApplyEffectModifiers (SpellInfo const *spellProto, uint8 effect_index, float value) const
 
int32 CalculateSpellDamage (Unit const *target, SpellInfo const *spellProto, uint8 effect_index, int32 const *basePoints=nullptr) const
 
int32 CalcSpellDuration (SpellInfo const *spellProto)
 
int32 ModSpellDuration (SpellInfo const *spellProto, Unit const *target, int32 duration, bool positive, uint32 effectMask)
 
void ModSpellCastTime (SpellInfo const *spellProto, int32 &castTime, Spell *spell=nullptr)
 
float CalculateLevelPenalty (SpellInfo const *spellProto) const
 
void addFollower (FollowerReference *pRef)
 
void removeFollower (FollowerReference *)
 
MotionMasterGetMotionMaster ()
 
const MotionMasterGetMotionMaster () const
 
virtual MovementGeneratorType GetDefaultMovementType () const
 -------—End of Pet responses methods-------—
 
bool IsStopped () const
 
void StopMoving ()
 
void StopMovingOnCurrentPos ()
 
virtual void PauseMovement (uint32 timer=0, uint8 slot=0)
 
void ResumeMovement (uint32 timer=0, uint8 slot=0)
 
void AddUnitMovementFlag (uint32 f)
 
void RemoveUnitMovementFlag (uint32 f)
 
bool HasUnitMovementFlag (uint32 f) const
 
uint32 GetUnitMovementFlags () const
 
void SetUnitMovementFlags (uint32 f)
 
void AddExtraUnitMovementFlag (uint16 f)
 
void RemoveExtraUnitMovementFlag (uint16 f)
 
uint16 HasExtraUnitMovementFlag (uint16 f) const
 
uint16 GetExtraUnitMovementFlags () const
 
void SetExtraUnitMovementFlags (uint16 f)
 
void SetControlled (bool apply, UnitState state, Unit *source=nullptr, bool isFear=false)
 
void DisableRotate (bool apply)
 
void DisableSpline ()
 
uint8 GetComboPoints (Unit const *who=nullptr) const
 --------—Combo point system----------------—
 
uint8 GetComboPoints (ObjectGuid const &guid) const
 
UnitGetComboTarget () const
 
ObjectGuid const GetComboTargetGUID () const
 
void AddComboPoints (Unit *target, int8 count)
 
void AddComboPoints (int8 count)
 
void ClearComboPoints ()
 
void SendComboPoints ()
 
void AddComboPointHolder (Unit *unit)
 
void RemoveComboPointHolder (Unit *unit)
 
void ClearComboPointHolders ()
 
void SendPetActionFeedback (uint8 msg)
 -------—Pet responses methods--------------—
 
void SendPetTalk (uint32 pettalk)
 
void SendPetAIReaction (ObjectGuid guid)
 
void propagateSpeedChange ()
 -------—End of Pet responses methods-------—
 
void ClearAllReactives ()
 
void StartReactiveTimer (ReactiveType reactive)
 
void UpdateReactives (uint32 p_time)
 
void UpdateAuraForGroup (uint8 slot)
 
bool CanProc ()
 
void SetCantProc (bool apply)
 
void AddPetAura (PetAura const *petSpell)
 
void RemovePetAura (PetAura const *petSpell)
 
void CastPetAura (PetAura const *aura)
 
bool IsPetAura (Aura const *aura)
 
uint32 GetModelForForm (ShapeshiftForm form, uint32 spellId) const
 
uint32 GetModelForTotem (PlayerTotemType totemType)
 
void SetRedirectThreat (ObjectGuid guid, uint32 pct)
 
void ResetRedirectThreat ()
 
void ModifyRedirectThreat (int32 amount)
 
uint32 GetRedirectThreatPercent ()
 
UnitGetRedirectThreatTarget () const
 
bool CreateVehicleKit (uint32 id, uint32 creatureEntry)
 
void RemoveVehicleKit ()
 
VehicleGetVehicleKit () const
 
VehicleGetVehicle () const
 
bool IsOnVehicle (Unit const *vehicle) const
 
UnitGetVehicleBase () const
 
CreatureGetVehicleCreatureBase () const
 
ObjectGuid GetTransGUID () const override
 
TransportBaseGetDirectTransport () const
 Returns the transport this unit is on directly (if on vehicle and transport, return vehicle)
 
bool HandleSpellClick (Unit *clicker, int8 seatId=-1)
 
void EnterVehicle (Unit *base, int8 seatId=-1)
 
void EnterVehicleUnattackable (Unit *base, int8 seatId=-1)
 
void ExitVehicle (Position const *exitPosition=nullptr)
 
void ChangeSeat (int8 seatId, bool next=true)
 
void _ExitVehicle (Position const *exitPosition=nullptr)
 
void _EnterVehicle (Vehicle *vehicle, int8 seatId, AuraApplication const *aurApp=nullptr)
 
void BuildMovementPacket (ByteBuffer *data) const
 
virtual bool CanSwim () const
 this method checks the current flag of a unit
 
bool IsLevitating () const
 
bool IsWalking () const
 
bool isMoving () const
 
bool isTurning () const
 
bool IsHovering () const
 
bool isSwimming () const
 
virtual bool CanFly () const =0
 
bool IsFlying () const
 
bool IsFalling () const
 
float GetHoverHeight () const
 
virtual bool CanEnterWater () const =0
 
void RewardRage (uint32 damage, uint32 weaponSpeedHitFactor, bool attacker)
 
virtual float GetFollowAngle () const
 
void OutDebugInfo () const
 
virtual bool isBeingLoaded () const
 
bool IsDuringRemoveFromWorld () const
 
PetToPet ()
 
TotemToTotem ()
 
TempSummonToTempSummon ()
 
const TempSummonToTempSummon () const
 
void AddPointedBy (SafeUnitPointer *sup)
 
void RemovePointedBy (SafeUnitPointer *sup)
 
void ExecuteDelayedUnitRelocationEvent ()
 
void ExecuteDelayedUnitAINotifyEvent ()
 
virtual bool HasSpellCooldown (uint32) const
 
virtual bool HasSpellItemCooldown (uint32, uint32) const
 
virtual void AddSpellCooldown (uint32, uint32, uint32, bool needSendToClient=false, bool forceSendToSpectator=false)
 
bool CanApplyResilience () const
 
void PetSpellFail (SpellInfo const *spellInfo, Unit *target, uint32 result)
 
int32 CalculateAOEDamageReduction (int32 damage, uint32 schoolMask, Unit *caster) const
 
ObjectGuid GetTarget () const
 
virtual void SetTarget (ObjectGuid=ObjectGuid::Empty)=0
 
void SetInstantCast (bool set)
 
bool CanInstantCast () const
 
virtual void Talk (std::string_view text, ChatMsg msgType, Language language, float textRange, WorldObject const *target)
 
virtual void Say (std::string_view text, Language language, WorldObject const *target=nullptr)
 
virtual void Yell (std::string_view text, Language language, WorldObject const *target=nullptr)
 
virtual void TextEmote (std::string_view text, WorldObject const *target=nullptr, bool isBossEmote=false)
 
virtual void Whisper (std::string_view text, Language language, Player *target, bool isBossWhisper=false)
 
virtual void Talk (uint32 textId, ChatMsg msgType, float textRange, WorldObject const *target)
 
virtual void Say (uint32 textId, WorldObject const *target=nullptr)
 
virtual void Yell (uint32 textId, WorldObject const *target=nullptr)
 
virtual void TextEmote (uint32 textId, WorldObject const *target=nullptr, bool isBossEmote=false)
 
virtual void Whisper (uint32 textId, Player *target, bool isBossWhisper=false)
 
float GetCollisionHeight () const override
 Return collision height sent to client.
 
float GetCollisionWidth () const override
 this method gets the diameter of a Unit by DB if any value is defined, otherwise it gets the value by the DBC
 
float GetCollisionRadius () const override
 this method gets the radius of a Unit by DB if any value is defined, otherwise it gets the value by the DBC
 
void ProcessPositionDataChanged (PositionFullTerrainStatus const &data) override
 
virtual void ProcessTerrainStatusUpdate ()
 
bool CanRestoreMana (SpellInfo const *spellInfo) const
 
std::string GetDebugInfo () const override
 
uint32 GetOldFactionId () const
 
- Public Member Functions inherited from WorldObject
 ~WorldObject () override
 
virtual void Update (uint32)
 
void _Create (ObjectGuid::LowType guidlow, HighGuid guidhigh, uint32 phaseMask)
 
void AddToWorld () override
 
void RemoveFromWorld () override
 
void GetNearPoint2D (WorldObject const *searcher, float &x, float &y, float distance, float absAngle, Position const *startPos=nullptr) const
 
void GetNearPoint2D (float &x, float &y, float distance, float absAngle, Position const *startPos=nullptr) const
 
void GetNearPoint (WorldObject const *searcher, float &x, float &y, float &z, float searcher_size, float distance2d, float absAngle, float controlZ=0, Position const *startPos=nullptr) const
 
void GetVoidClosePoint (float &x, float &y, float &z, float size, float distance2d=0, float relAngle=0, float controlZ=0) const
 
bool GetClosePoint (float &x, float &y, float &z, float size, float distance2d=0, float angle=0, WorldObject const *forWho=nullptr, bool force=false) const
 
void MovePosition (Position &pos, float dist, float angle)
 
Position GetNearPosition (float dist, float angle)
 
void MovePositionToFirstCollision (Position &pos, float dist, float angle)
 
Position GetFirstCollisionPosition (float startX, float startY, float startZ, float destX, float destY)
 
Position GetFirstCollisionPosition (float destX, float destY, float destZ)
 
Position GetFirstCollisionPosition (float dist, float angle)
 
Position GetRandomNearPosition (float radius)
 
void GetContactPoint (WorldObject const *obj, float &x, float &y, float &z, float distance2d=CONTACT_DISTANCE) const
 
void GetChargeContactPoint (WorldObject const *obj, float &x, float &y, float &z, float distance2d=CONTACT_DISTANCE) const
 
float GetObjectSize () const
 
virtual float GetCombatReach () const
 
void UpdateGroundPositionZ (float x, float y, float &z) const
 
void UpdateAllowedPositionZ (float x, float y, float &z, float *groundZ=nullptr) const
 
void GetRandomPoint (const Position &srcPos, float distance, float &rand_x, float &rand_y, float &rand_z) const
 
Position GetRandomPoint (const Position &srcPos, float distance) const
 
uint32 GetInstanceId () const
 
virtual void SetPhaseMask (uint32 newPhaseMask, bool update)
 
uint32 GetPhaseMask () const
 
bool InSamePhase (WorldObject const *obj) const
 
bool InSamePhase (uint32 phasemask) const
 
uint32 GetZoneId () const
 
uint32 GetAreaId () const
 
void GetZoneAndAreaId (uint32 &zoneid, uint32 &areaid) const
 
bool IsOutdoors () const
 
LiquidData const & GetLiquidData () const
 
InstanceScriptGetInstanceScript () const
 
std::string const & GetName () const
 
void SetName (std::string const &newname)
 
virtual std::string const & GetNameForLocaleIdx (LocaleConstant) const
 
float GetDistance (WorldObject const *obj) const
 
float GetDistance (const Position &pos) const
 
float GetDistance (float x, float y, float z) const
 
float GetDistance2d (WorldObject const *obj) const
 
float GetDistance2d (float x, float y) const
 
float GetDistanceZ (WorldObject const *obj) const
 
bool IsSelfOrInSameMap (WorldObject const *obj) const
 
bool IsInMap (WorldObject const *obj) const
 
bool IsWithinDist3d (float x, float y, float z, float dist) const
 
bool IsWithinDist3d (const Position *pos, float dist) const
 
bool IsWithinDist2d (float x, float y, float dist) const
 
bool IsWithinDist2d (const Position *pos, float dist) const
 
bool IsWithinDist (WorldObject const *obj, float dist2compare, bool is3D=true, bool useBoundingRadius=true) const
 
bool IsWithinDistInMap (WorldObject const *obj, float dist2compare, bool is3D=true, bool useBoundingRadius=true) const
 
bool IsWithinLOS (float x, float y, float z, VMAP::ModelIgnoreFlags ignoreFlags=VMAP::ModelIgnoreFlags::Nothing, LineOfSightChecks checks=LINEOFSIGHT_ALL_CHECKS) const
 
bool IsWithinLOSInMap (WorldObject const *obj, VMAP::ModelIgnoreFlags ignoreFlags=VMAP::ModelIgnoreFlags::Nothing, LineOfSightChecks checks=LINEOFSIGHT_ALL_CHECKS, Optional< float > collisionHeight={ }, Optional< float > combatReach={ }) const
 
Position GetHitSpherePointFor (Position const &dest, Optional< float > collisionHeight={ }, Optional< float > combatReach={ }) const
 
void GetHitSpherePointFor (Position const &dest, float &x, float &y, float &z, Optional< float > collisionHeight={ }, Optional< float > combatReach={ }) const
 
bool GetDistanceOrder (WorldObject const *obj1, WorldObject const *obj2, bool is3D=true) const
 
bool IsInRange (WorldObject const *obj, float minRange, float maxRange, bool is3D=true) const
 
bool IsInRange2d (float x, float y, float minRange, float maxRange) const
 
bool IsInRange3d (float x, float y, float z, float minRange, float maxRange) const
 
bool isInFront (WorldObject const *target, float arc=M_PI) const
 
bool isInBack (WorldObject const *target, float arc=M_PI) const
 
bool IsInBetween (WorldObject const *obj1, WorldObject const *obj2, float size=0) const
 
virtual void CleanupsBeforeDelete (bool finalCleanup=true)
 
virtual void SendMessageToSet (WorldPacket const *data, bool self) const
 
virtual void SendMessageToSetInRange (WorldPacket const *data, float dist, bool, bool includeMargin=false, Player const *skipped_rcvr=nullptr) const
 
virtual void SendMessageToSet (WorldPacket const *data, Player const *skipped_rcvr) const
 
virtual uint8 getLevelForTarget (WorldObject const *) const
 
void PlayDistanceSound (uint32 sound_id, Player *target=nullptr)
 
void PlayDirectSound (uint32 sound_id, Player *target=nullptr)
 
void PlayDirectMusic (uint32 music_id, Player *target=nullptr)
 
void SendObjectDeSpawnAnim (ObjectGuid guid)
 
virtual void SaveRespawnTime ()
 
void AddObjectToRemoveList ()
 
float GetGridActivationRange () const
 
float GetVisibilityRange () const
 
virtual float GetSightRange (WorldObject const *target=nullptr) const
 
bool CanSeeOrDetect (WorldObject const *obj, bool ignoreStealth=false, bool distanceCheck=false, bool checkAlert=false) const
 
void SendPlayMusic (uint32 Music, bool OnlySelf)
 
virtual void SetMap (Map *map)
 
virtual void ResetMap ()
 
MapGetMap () const
 
MapFindMap () const
 
void SetZoneScript ()
 
void ClearZoneScript ()
 
ZoneScriptGetZoneScript () const
 
TempSummonSummonCreature (uint32 id, const Position &pos, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0, uint32 vehId=0, SummonPropertiesEntry const *properties=nullptr, bool visibleBySummonerOnly=false) const
 
TempSummonSummonCreature (uint32 id, float x, float y, float z, float ang=0, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0, SummonPropertiesEntry const *properties=nullptr, bool visibleBySummonerOnly=false)
 
GameObjectSummonGameObject (uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime, bool checkTransport=true, GOSummonType summonType=GO_SUMMON_TIMED_OR_CORPSE_DESPAWN)
 
CreatureSummonTrigger (float x, float y, float z, float ang, uint32 dur, bool setLevel=false, CreatureAI *(*GetAI)(Creature *)=nullptr)
 
void SummonCreatureGroup (uint8 group, std::list< TempSummon * > *list=nullptr)
 
CreatureFindNearestCreature (uint32 entry, float range, bool alive=true) const
 
GameObjectFindNearestGameObject (uint32 entry, float range, bool onlySpawned=false) const
 
GameObjectFindNearestGameObjectOfType (GameobjectTypes type, float range) const
 
PlayerSelectNearestPlayer (float distance=0) const
 
void GetGameObjectListWithEntryInGrid (std::list< GameObject * > &lList, uint32 uiEntry, float fMaxSearchRange) const
 
void GetCreatureListWithEntryInGrid (std::list< Creature * > &lList, uint32 uiEntry, float fMaxSearchRange) const
 
void GetDeadCreatureListInGrid (std::list< Creature * > &lList, float maxSearchRange, bool alive=false) const
 
void DestroyForNearbyPlayers ()
 
virtual void UpdateObjectVisibility (bool forced=true, bool fromUpdate=false)
 
void BuildUpdate (UpdateDataMapType &data_map, UpdatePlayerSet &player_set) override
 
void GetCreaturesWithEntryInRange (std::list< Creature * > &creatureList, float radius, uint32 entry)
 
void SetPositionDataUpdate ()
 
void UpdatePositionData ()
 
void AddToObjectUpdate () override
 
void RemoveFromObjectUpdate () override
 
void AddToNotify (uint16 f)
 
void RemoveFromNotify (uint16 f)
 
bool isNeedNotify (uint16 f) const
 
uint16 GetNotifyFlags () const
 
bool NotifyExecuted (uint16 f) const
 
void SetNotified (uint16 f)
 
void ResetAllNotifies ()
 
bool isActiveObject () const
 
void setActive (bool isActiveObject)
 
bool IsFarVisible () const
 
bool IsVisibilityOverridden () const
 
void SetVisibilityDistanceOverride (VisibilityDistanceType type)
 
void SetWorldObject (bool apply)
 
bool IsPermanentWorldObject () const
 
bool IsWorldObject () const
 
bool IsInWintergrasp () const
 
TransportGetTransport () const
 
float GetTransOffsetX () const
 
float GetTransOffsetY () const
 
float GetTransOffsetZ () const
 
float GetTransOffsetO () const
 
uint32 GetTransTime () const
 
int8 GetTransSeat () const
 
virtual ObjectGuid GetTransGUID () const
 
void SetTransport (Transport *t)
 
virtual float GetStationaryX () const
 
virtual float GetStationaryY () const
 
virtual float GetStationaryZ () const
 
virtual float GetStationaryO () const
 
float GetMapWaterOrGroundLevel (float x, float y, float z, float *ground=nullptr) const
 
float GetMapHeight (float x, float y, float z, bool vmap=true, float distanceToSearch=50.0f) const
 
float GetFloorZ () const
 
float GetMinHeightInWater () const
 Get the minimum height of a object that should be in water to start floating/swim.
 
virtual float GetCollisionHeight () const
 
virtual float GetCollisionWidth () const
 
virtual float GetCollisionRadius () const
 
void AddAllowedLooter (ObjectGuid guid)
 
void ResetAllowedLooters ()
 
void SetAllowedLooters (GuidUnorderedSet const looters)
 
bool HasAllowedLooter (ObjectGuid guid) const
 
GuidUnorderedSet const & GetAllowedLooters () const
 
std::string GetDebugInfo () const override
 
- Public Member Functions inherited from Object
virtual ~Object ()
 
bool IsInWorld () const
 
virtual void AddToWorld ()
 
virtual void RemoveFromWorld ()
 
ObjectGuid GetGUID () const
 
PackedGuid const & GetPackGUID () const
 
uint32 GetEntry () const
 
void SetEntry (uint32 entry)
 
float GetObjectScale () const
 
virtual void SetObjectScale (float scale)
 
virtual uint32 GetDynamicFlags () const
 
bool HasDynamicFlag (uint32 flag) const
 
virtual void SetDynamicFlag (uint32 flag)
 
virtual void RemoveDynamicFlag (uint32 flag)
 
virtual void ReplaceAllDynamicFlags (uint32 flag)
 
TypeID GetTypeId () const
 
bool isType (uint16 mask) const
 
virtual void BuildCreateUpdateBlockForPlayer (UpdateData *data, Player *target) const
 
void SendUpdateToPlayer (Player *player)
 
void BuildValuesUpdateBlockForPlayer (UpdateData *data, Player *target) const
 
void BuildOutOfRangeUpdateBlock (UpdateData *data) const
 
void BuildMovementUpdateBlock (UpdateData *data, uint32 flags=0) const
 
virtual void DestroyForPlayer (Player *target, bool onDeath=false) const
 
int32 GetInt32Value (uint16 index) const
 
uint32 GetUInt32Value (uint16 index) const
 
uint64 GetUInt64Value (uint16 index) const
 
float GetFloatValue (uint16 index) const
 
uint8 GetByteValue (uint16 index, uint8 offset) const
 
uint16 GetUInt16Value (uint16 index, uint8 offset) const
 
ObjectGuid GetGuidValue (uint16 index) const
 
void SetInt32Value (uint16 index, int32 value)
 
void SetUInt32Value (uint16 index, uint32 value)
 
void UpdateUInt32Value (uint16 index, uint32 value)
 
void SetUInt64Value (uint16 index, uint64 value)
 
void SetFloatValue (uint16 index, float value)
 
void SetByteValue (uint16 index, uint8 offset, uint8 value)
 
void SetUInt16Value (uint16 index, uint8 offset, uint16 value)
 
void SetInt16Value (uint16 index, uint8 offset, int16 value)
 
void SetGuidValue (uint16 index, ObjectGuid value)
 
void SetStatFloatValue (uint16 index, float value)
 
void SetStatInt32Value (uint16 index, int32 value)
 
bool AddGuidValue (uint16 index, ObjectGuid value)
 
bool RemoveGuidValue (uint16 index, ObjectGuid value)
 
void ApplyModUInt32Value (uint16 index, int32 val, bool apply)
 
void ApplyModInt32Value (uint16 index, int32 val, bool apply)
 
void ApplyModUInt64Value (uint16 index, int32 val, bool apply)
 
void ApplyModPositiveFloatValue (uint16 index, float val, bool apply)
 
void ApplyModSignedFloatValue (uint16 index, float val, bool apply)
 
void ApplyPercentModFloatValue (uint16 index, float val, bool apply)
 
void SetFlag (uint16 index, uint32 newFlag)
 
void RemoveFlag (uint16 index, uint32 oldFlag)
 
void ToggleFlag (uint16 index, uint32 flag)
 
bool HasFlag (uint16 index, uint32 flag) const
 
void ApplyModFlag (uint16 index, uint32 flag, bool apply)
 
void SetByteFlag (uint16 index, uint8 offset, uint8 newFlag)
 
void RemoveByteFlag (uint16 index, uint8 offset, uint8 newFlag)
 
bool HasByteFlag (uint16 index, uint8 offset, uint8 flag) const
 
void SetFlag64 (uint16 index, uint64 newFlag)
 
void RemoveFlag64 (uint16 index, uint64 oldFlag)
 
void ToggleFlag64 (uint16 index, uint64 flag)
 
bool HasFlag64 (uint16 index, uint64 flag) const
 
void ApplyModFlag64 (uint16 index, uint64 flag, bool apply)
 
void ClearUpdateMask (bool remove)
 
uint16 GetValuesCount () const
 
virtual bool hasQuest (uint32) const
 
virtual bool hasInvolvedQuest (uint32) const
 
virtual void BuildUpdate (UpdateDataMapType &, UpdatePlayerSet &)
 
void BuildFieldsUpdate (Player *, UpdateDataMapType &) const
 
void SetFieldNotifyFlag (uint16 flag)
 
void RemoveFieldNotifyFlag (uint16 flag)
 
void ForceValuesUpdateAtIndex (uint32)
 
bool IsPlayer () const
 
PlayerToPlayer ()
 
Player const * ToPlayer () const
 
CreatureToCreature ()
 
Creature const * ToCreature () const
 
UnitToUnit ()
 
Unit const * ToUnit () const
 
GameObjectToGameObject ()
 
GameObject const * ToGameObject () const
 
CorpseToCorpse ()
 
Corpse const * ToCorpse () const
 
DynamicObjectToDynObject ()
 
DynamicObject const * ToDynObject () const
 
virtual std::string GetDebugInfo () const
 
- Public Member Functions inherited from WorldLocation
 WorldLocation (uint32 _mapId=MAPID_INVALID, float x=0.f, float y=0.f, float z=0.f, float o=0.f)
 
 WorldLocation (uint32 mapId, Position const &position)
 
void WorldRelocate (const WorldLocation &loc)
 
void WorldRelocate (uint32 mapId=MAPID_INVALID, float x=0.f, float y=0.f, float z=0.f, float o=0.f)
 
void SetMapId (uint32 mapId)
 
uint32 GetMapId () const
 
void GetWorldLocation (uint32 &mapId, float &x, float &y) const
 
void GetWorldLocation (uint32 &mapId, float &x, float &y, float &z) const
 
void GetWorldLocation (uint32 &mapId, float &x, float &y, float &z, float &o) const
 
void GetWorldLocation (WorldLocation *location) const
 
WorldLocation GetWorldLocation () const
 
std::string GetDebugInfo () const
 
- Public Member Functions inherited from Position
 Position (float x=0, float y=0, float z=0, float o=0)
 
 Position (Position const &loc)
 
 Position (Position &&)=default
 
Positionoperator= (const Position &)=default
 
Positionoperator= (Position &&)=default
 
bool operator== (Position const &a) const
 
bool operator!= (Position const &a)
 
 operator G3D::Vector3 () const
 
void Relocate (float x, float y)
 
void Relocate (float x, float y, float z)
 
void Relocate (float x, float y, float z, float orientation)
 
void Relocate (const Position &pos)
 
void Relocate (const Position *pos)
 
void RelocatePolarOffset (float angle, float dist, float z=0.0f)
 
void RelocateOffset (const Position &offset)
 
void SetOrientation (float orientation)
 
float GetPositionX () const
 
float GetPositionY () const
 
float GetPositionZ () const
 
float GetOrientation () const
 
void GetPosition (float &x, float &y) const
 
void GetPosition (float &x, float &y, float &z) const
 
void GetPosition (float &x, float &y, float &z, float &o) const
 
Position GetPosition () const
 
Position::PositionXYZStreamer PositionXYZStream ()
 
Position::PositionXYZOStreamer PositionXYZOStream ()
 
bool IsPositionValid () const
 
float GetExactDist2dSq (const float x, const float y) const
 
float GetExactDist2dSq (Position const &pos) const
 
float GetExactDist2dSq (Position const *pos) const
 
float GetExactDist2d (const float x, const float y) const
 
float GetExactDist2d (Position const &pos) const
 
float GetExactDist2d (Position const *pos) const
 
float GetExactDistSq (float x, float y, float z) const
 
float GetExactDistSq (Position const &pos) const
 
float GetExactDistSq (Position const *pos) const
 
float GetExactDist (float x, float y, float z) const
 
float GetExactDist (Position const &pos) const
 
float GetExactDist (Position const *pos) const
 
void GetPositionOffsetTo (const Position &endPos, Position &retOffset) const
 
Position GetPositionWithOffset (Position const &offset) const
 
float GetAngle (const Position *pos) const
 
float GetAngle (float x, float y) const
 
float GetAbsoluteAngle (float x, float y) const
 
float GetAbsoluteAngle (Position const &pos) const
 
float GetAbsoluteAngle (Position const *pos) const
 
float GetRelativeAngle (const Position *pos) const
 
float GetRelativeAngle (float x, float y) const
 
float ToAbsoluteAngle (float relAngle) const
 
void GetSinCos (float x, float y, float &vsin, float &vcos) const
 
bool IsInDist2d (float x, float y, float dist) const
 
bool IsInDist2d (const Position *pos, float dist) const
 
bool IsInDist (float x, float y, float z, float dist) const
 
bool IsInDist (const Position *pos, float dist) const
 
bool IsWithinBox (const Position &center, float xradius, float yradius, float zradius) const
 
bool HasInArc (float arcangle, const Position *pos, float targetRadius=0.0f) const
 
bool HasInLine (Position const *pos, float width) const
 
std::string ToString () const
 
- Public Member Functions inherited from GridObject< Creature >
bool IsInGrid () const
 
void AddToGrid (GridRefMgr< Creature > &m)
 
void RemoveFromGrid ()
 

Static Public Member Functions

static std::pair< PetStable::PetInfo const *, PetSaveModeGetLoadPetInfo (PetStable const &stable, uint32 petEntry, uint32 petnumber, bool current)
 
static void DeleteFromDB (ObjectGuid::LowType guidlow)
 
static void resetTalentsForAllPetsOf (Player *owner, Pet *online_pet=nullptr)
 
- Static Public Member Functions inherited from Creature
static float _GetDamageMod (int32 Rank)
 
- Static Public Member Functions inherited from Unit
static float GetEffectiveResistChance (Unit const *owner, SpellSchoolMask schoolMask, Unit const *victim)
 
static void DealDamageMods (Unit const *victim, uint32 &damage, uint32 *absorb)
 
static uint32 DealDamage (Unit *attacker, Unit *victim, uint32 damage, CleanDamage const *cleanDamage=nullptr, DamageEffectType damagetype=DIRECT_DAMAGE, SpellSchoolMask damageSchoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellInfo const *spellProto=nullptr, bool durabilityLoss=true, bool allowGM=false, Spell const *spell=nullptr)
 
static void Kill (Unit *killer, Unit *victim, bool durabilityLoss=true, WeaponAttackType attackType=BASE_ATTACK, SpellInfo const *spellProto=nullptr, Spell const *spell=nullptr)
 
static int32 DealHeal (Unit *healer, Unit *victim, uint32 addhealth)
 
static void ProcDamageAndSpell (Unit *actor, Unit *victim, uint32 procAttacker, uint32 procVictim, uint32 procEx, uint32 amount, WeaponAttackType attType=BASE_ATTACK, SpellInfo const *procSpellInfo=nullptr, SpellInfo const *procAura=nullptr, int8 procAuraEffectIndex=-1, Spell const *procSpell=nullptr, DamageInfo *damageInfo=nullptr, HealInfo *healInfo=nullptr, uint32 procPhase=2)
 
static void ApplyResilience (Unit const *victim, float *crit, int32 *damage, bool isCrit, CombatRating type)
 
static uint32 SpellCriticalDamageBonus (Unit const *caster, SpellInfo const *spellProto, uint32 damage, Unit const *victim)
 
static uint32 SpellCriticalHealingBonus (Unit const *caster, SpellInfo const *spellProto, uint32 damage, Unit const *victim)
 
static bool IsDamageReducedByArmor (SpellSchoolMask damageSchoolMask, SpellInfo const *spellInfo=nullptr, uint8 effIndex=MAX_SPELL_EFFECTS)
 
static uint32 CalcArmorReducedDamage (Unit const *attacker, Unit const *victim, const uint32 damage, SpellInfo const *spellInfo, uint8 attackerLevel=0, WeaponAttackType attackType=MAX_ATTACK)
 
static void CalcAbsorbResist (DamageInfo &dmgInfo, bool Splited=false)
 
static void CalcHealAbsorb (HealInfo &healInfo)
 
static void HandleSafeUnitPointersOnDelete (Unit *thisUnit)
 
- Static Public Member Functions inherited from Object
static ObjectGuid GetGUID (Object const *o)
 
- Static Public Member Functions inherited from Position
static float NormalizeOrientation (float o)
 

Public Attributes

PetSpellMap m_spells
 
AutoSpellList m_autospells
 
uint32 m_usedTalentCount
 
bool m_removed
 
- Public Attributes inherited from TempSummon
const SummonPropertiesEntry *const m_Properties
 
- Public Attributes inherited from Creature
struct {
   ::Spell const *   Spell = nullptr
 
   uint32   Delay = 0
 
   ObjectGuid   Target
 
   float   Orientation = 0.0f
 
_spellFocusInfo
 
Loot loot
 
uint32 m_spells [MAX_CREATURE_SPELLS]
 
CreatureSpellCooldowns m_CreatureSpellCooldowns
 
uint32 m_ProhibitSchoolTime [7]
 
uint32 m_groupLootTimer
 
uint32 lootingGroupLowGUID
 
float m_SightDistance
 
float m_CombatDistance
 
bool m_isTempWorldObject
 
uint32 m_moveCircleMovementTime = MOVE_CIRCLE_CHECK_INTERVAL
 
uint32 m_moveBackwardsMovementTime = MOVE_BACKWARDS_CHECK_INTERVAL
 
- Public Attributes inherited from Unit
uint32 m_extraAttacks
 
bool m_canDualWield
 
ControlSet m_Controlled
 
SafeUnitPointer m_movedByPlayer
 
ObjectGuid m_SummonSlot [MAX_SUMMON_SLOT]
 
ObjectGuid m_ObjectSlot [MAX_GAMEOBJECT_SLOT]
 
float m_modMeleeHitChance
 
float m_modRangedHitChance
 
float m_modSpellHitChance
 
int32 m_baseSpellCritChance
 
float m_threatModifier [MAX_SPELL_SCHOOL]
 
float m_modAttackSpeedPct [3]
 
EventProcessor m_Events
 
SpellImmuneList m_spellImmune [MAX_SPELL_IMMUNITY]
 
uint32 m_lastSanctuaryTime
 
PetAuraSet m_petAuras
 
bool IsAIEnabled
 
bool NeedChangeAI
 
bool m_ControlledByPlayer
 
bool m_CreatedByPlayer
 
std::set< SafeUnitPointer * > SafeUnitPointerSet
 
Position m_last_notify_position
 
uint32 m_last_notify_mstime
 
uint16 m_delayed_unit_relocation_timer
 
uint16 m_delayed_unit_ai_notify_timer
 
bool bRequestForcedVisibilityUpdate
 
Movement::MoveSplinemovespline
 
- Public Attributes inherited from WorldObject
FlaggedValuesArray32< int32, uint32, StealthType, TOTAL_STEALTH_TYPESm_stealth
 
FlaggedValuesArray32< int32, uint32, StealthType, TOTAL_STEALTH_TYPESm_stealthDetect
 
FlaggedValuesArray32< int32, uint32, InvisibilityType, TOTAL_INVISIBILITY_TYPESm_invisibility
 
FlaggedValuesArray32< int32, uint32, InvisibilityType, TOTAL_INVISIBILITY_TYPESm_invisibilityDetect
 
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPESm_serverSideVisibility
 
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPESm_serverSideVisibilityDetect
 
uint32 LastUsedScriptID
 
MovementInfo m_movementInfo
 
ElunaEventProcessor * elunaEvents
 
- Public Attributes inherited from Object
DataMap CustomData
 
- Public Attributes inherited from WorldLocation
uint32 m_mapId
 
- Public Attributes inherited from Position
float m_positionX = 0
 
float m_positionY = 0
 
float m_positionZ = 0
 
float m_orientation = 0
 

Protected Attributes

Playerm_owner
 
int32 m_happinessTimer
 
PetType m_petType
 
Milliseconds m_duration
 
uint64 m_auraRaidUpdateMask
 
bool m_loading
 
Milliseconds m_petRegenTimer
 
std::unique_ptr< DeclinedNamem_declinedname
 
Unitm_tempspellTarget
 
Unitm_tempoldTarget
 
bool m_tempspellIsPositive
 
uint32 m_tempspell
 
- Protected Attributes inherited from Minion
const ObjectGuid m_owner
 
float m_followAngle
 
- Protected Attributes inherited from Creature
VendorItemCounts m_vendorItemCounts
 
ObjectGuid m_lootRecipient
 
ObjectGuid::LowType m_lootRecipientGroup
 
time_t m_corpseRemoveTime
 Timers.
 
time_t m_respawnTime
 
time_t m_respawnedTime
 
uint32 m_respawnDelay
 
uint32 m_corpseDelay
 
float m_wanderDistance
 
uint32 m_boundaryCheckTime
 
uint16 m_transportCheckTimer
 
uint32 lootPickPocketRestoreTime
 
uint32 m_combatPulseTime
 
uint32 m_combatPulseDelay
 
ReactStates m_reactState
 
MovementGeneratorType m_defaultMovementType
 
ObjectGuid::LowType m_spawnId
 For new or temporary creatures is 0 for saved it is lowguid.
 
uint8 m_equipmentId
 
int8 m_originalEquipmentId
 
bool m_AlreadyCallAssistance
 
bool m_AlreadySearchedAssistance
 
bool m_regenHealth
 
bool m_regenPower
 
bool m_AI_locked
 
SpellSchoolMask m_meleeDamageSchoolMask
 
uint32 m_originalEntry
 
bool m_moveInLineOfSightDisabled
 
bool m_moveInLineOfSightStrictlyDisabled
 
Position m_homePosition
 
Position m_transportHomePosition
 
bool DisableReputationGain
 
CreatureTemplate const * m_creatureInfo
 
CreatureData const * m_creatureData
 
float m_detectionDistance
 
uint16 m_LootMode
 
- Protected Attributes inherited from Unit
UnitAIi_AI
 
UnitAIi_disabledAI
 
uint8 m_realRace
 
uint8 m_race
 
bool m_AutoRepeatFirstCast
 
int32 m_attackTimer [MAX_ATTACK]
 
float m_createStats [MAX_STATS]
 
AttackerSet m_attackers
 
Unitm_attacking
 
DeathState m_deathState
 
int32 m_procDeep
 
DynObjectList m_dynObj
 
GameObjectList m_gameObj
 
uint32 m_transform
 
Spellm_currentSpells [CURRENT_MAX_SPELL]
 
AuraMap m_ownedAuras
 
AuraApplicationMap m_appliedAuras
 
AuraList m_removedAuras
 
AuraMap::iterator m_auraUpdateIterator
 
uint32 m_removedAurasCount
 
AuraEffectList m_modAuras [TOTAL_AURAS]
 
AuraList m_scAuras
 
AuraApplicationList m_interruptableAuras
 
AuraStateAurasMap m_auraStateAuras
 
uint32 m_interruptMask
 
float m_auraModifiersGroup [UNIT_MOD_END][MODIFIER_TYPE_END]
 
float m_weaponDamage [MAX_ATTACK][MAX_WEAPON_DAMAGE_RANGE][MAX_ITEM_PROTO_DAMAGES]
 
bool m_canModifyStats
 
VisibleAuraMap m_visibleAuras
 
float m_speed_rate [MAX_MOVE_TYPE]
 
CharmInfom_charmInfo
 
SharedVisionList m_sharedVision
 
MotionMasteri_motionMaster
 
uint32 m_reactiveTimer [MAX_REACTIVE]
 
int32 m_regenTimer
 
ThreatMgr m_ThreatMgr
 
CharmThreatMap _charmThreatInfo
 
Vehiclem_vehicle
 
Vehiclem_vehicleKit
 
uint32 m_unitTypeMask
 
LiquidTypeEntry const * _lastLiquid
 
bool m_applyResilience
 
bool _instantCast
 
uint32 m_rootTimes
 
- Protected Attributes inherited from WorldObject
std::string m_name
 
bool m_isActive
 
bool m_isFarVisible
 
Optional< float > m_visibilityDistanceOverride
 
const bool m_isWorldObject
 
ZoneScriptm_zoneScript
 
uint32 _zoneId
 
uint32 _areaId
 
float _floorZ
 
bool _outdoors
 
LiquidData _liquidData
 
bool _updatePositionData
 
Transportm_transport
 
- Protected Attributes inherited from Object
uint16 m_objectType
 
TypeID m_objectTypeId
 
uint16 m_updateFlag
 
union {
   int32 *   m_int32Values
 
   uint32 *   m_uint32Values
 
   float *   m_floatValues
 
}; 
 
UpdateMask _changesMask
 
uint16 m_valuesCount
 
uint16 _fieldNotifyFlags
 
bool m_objectUpdated
 

Private Member Functions

void SaveToDB (uint32, uint8, uint32) override
 
void DeleteFromDB () override
 

Additional Inherited Members

- Public Types inherited from Unit
typedef std::unordered_set< Unit * > AttackerSet
 
typedef std::set< Unit * > ControlSet
 
typedef std::multimap< uint32, Aura * > AuraMap
 
typedef std::pair< AuraMap::const_iterator, AuraMap::const_iterator > AuraMapBounds
 
typedef std::pair< AuraMap::iterator, AuraMap::iterator > AuraMapBoundsNonConst
 
typedef std::multimap< uint32, AuraApplication * > AuraApplicationMap
 
typedef std::pair< AuraApplicationMap::const_iterator, AuraApplicationMap::const_iterator > AuraApplicationMapBounds
 
typedef std::pair< AuraApplicationMap::iterator, AuraApplicationMap::iterator > AuraApplicationMapBoundsNonConst
 
typedef std::multimap< AuraStateType, AuraApplication * > AuraStateAurasMap
 
typedef std::pair< AuraStateAurasMap::const_iterator, AuraStateAurasMap::const_iterator > AuraStateAurasMapBounds
 
typedef std::list< AuraEffect * > AuraEffectList
 
typedef std::list< Aura * > AuraList
 
typedef std::list< AuraApplication * > AuraApplicationList
 
typedef std::list< DiminishingReturnDiminishing
 
typedef GuidUnorderedSet ComboPointHolderSet
 
typedef std::map< uint8, AuraApplication * > VisibleAuraMap
 
typedef std::set< PetAura const * > PetAuraSet
 
- Static Public Attributes inherited from Creature
static constexpr uint32 MOVE_CIRCLE_CHECK_INTERVAL = 3000
 
static constexpr uint32 MOVE_BACKWARDS_CHECK_INTERVAL = 2000
 
- Protected Types inherited from Unit
typedef std::list< DynamicObject * > DynObjectList
 
typedef GuidList GameObjectList
 
typedef std::map< ObjectGuid, float > CharmThreatMap
 
- Protected Member Functions inherited from Creature
bool CreateFromProto (ObjectGuid::LowType guidlow, uint32 Entry, uint32 vehId, const CreatureData *data=nullptr)
 
bool InitEntry (uint32 entry, const CreatureData *data=nullptr)
 
void RegenerateHealth ()
 
void Regenerate (Powers power)
 
bool IsInvisibleDueToDespawn () const override
 
bool CanAlwaysSee (WorldObject const *obj) const override
 
bool IsAlwaysDetectableFor (WorldObject const *seer) const override
 
- Protected Member Functions inherited from Unit
 Unit (bool isWorldObject)
 
void BuildValuesUpdate (uint8 updatetype, ByteBuffer *data, Player *target) const override
 
void _UpdateSpells (uint32 time)
 
void _DeleteRemovedAuras ()
 
void _UpdateAutoRepeatSpell ()
 
bool IsAlwaysVisibleFor (WorldObject const *seer) const override
 
bool IsAlwaysDetectableFor (WorldObject const *seer) const override
 
void SetFeared (bool apply, Unit *fearedBy=nullptr, bool isFear=false)
 
void SetConfused (bool apply)
 
void SetStunned (bool apply)
 
void SetRooted (bool apply, bool isStun=false)
 
- Protected Member Functions inherited from WorldObject
 WorldObject (bool isWorldObject)
 
virtual void ProcessPositionDataChanged (PositionFullTerrainStatus const &data)
 
void SetLocationMapId (uint32 _mapId)
 
void SetLocationInstanceId (uint32 _instanceId)
 
virtual bool IsNeverVisible () const
 
virtual bool IsAlwaysVisibleFor (WorldObject const *) const
 
virtual bool IsInvisibleDueToDespawn () const
 
virtual bool IsAlwaysDetectableFor (WorldObject const *) const
 
- Protected Member Functions inherited from Object
 Object ()
 
void _InitValues ()
 
void _Create (ObjectGuid::LowType guidlow, uint32 entry, HighGuid guidhigh)
 
std::string _ConcatFields (uint16 startIndex, uint16 size) const
 
bool _LoadIntoDataField (std::string const &data, uint32 startOffset, uint32 count)
 
uint32 GetUpdateFieldData (Player const *target, uint32 *&flags) const
 
void BuildMovementUpdate (ByteBuffer *data, uint16 flags) const
 
virtual void BuildValuesUpdate (uint8 updatetype, ByteBuffer *data, Player *target) const
 
virtual void AddToObjectUpdate ()=0
 
virtual void RemoveFromObjectUpdate ()=0
 
void AddToObjectUpdateIfNeeded ()
 
- Protected Member Functions inherited from MovableMapObject
 MovableMapObject ()=default
 
- Static Protected Member Functions inherited from Creature
static float _GetHealthMod (int32 Rank)
 

Detailed Description

Constructor & Destructor Documentation

◆ Pet()

Pet::Pet ( Player owner,
PetType  type = MAX_PET_TYPE 
)
explicit
40 : Guardian(nullptr, owner ? owner->GetGUID() : ObjectGuid::Empty, true),
42 m_removed(false),
43 m_owner(owner),
45 m_petType(type),
46 m_duration(0),
48 m_loading(false),
50 m_tempspellTarget(nullptr),
51 m_tempoldTarget(nullptr),
54{
56
58
59 if (type == HUNTER_PET)
61
63 {
66 }
67
68 m_name = "Pet";
69}
#define ASSERT
Definition: Errors.h:68
constexpr Milliseconds PET_FOCUS_REGEN_INTERVAL
Definition: CreatureData.h:41
@ TYPEID_PLAYER
Definition: ObjectGuid.h:38
constexpr auto PET_LOSE_HAPPINES_INTERVAL
Definition: Pet.h:24
@ HUNTER_PET
Definition: PetDefines.h:32
@ UNIT_MASK_CONTROLABLE_GUARDIAN
Definition: Unit.h:683
@ UNIT_MASK_HUNTER_PET
Definition: Unit.h:682
@ UNIT_MASK_PET
Definition: Unit.h:679
Definition: TemporarySummon.h:95
TypeID GetTypeId() const
Definition: Object.h:121
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:106
std::string m_name
Definition: Object.h:623
static ObjectGuid const Empty
Definition: ObjectGuid.h:122
PetType m_petType
Definition: Pet.h:152
bool m_loading
Definition: Pet.h:155
uint32 m_usedTalentCount
Definition: Pet.h:133
Unit * m_tempspellTarget
Definition: Pet.h:160
Player * m_owner
Definition: Pet.h:150
Unit * m_tempoldTarget
Definition: Pet.h:161
uint32 m_tempspell
Definition: Pet.h:163
bool m_tempspellIsPositive
Definition: Pet.h:162
Milliseconds m_duration
Definition: Pet.h:153
bool m_removed
Definition: Pet.h:141
uint64 m_auraRaidUpdateMask
Definition: Pet.h:154
int32 m_happinessTimer
Definition: Pet.h:151
Milliseconds m_petRegenTimer
Definition: Pet.h:156
uint32 m_unitTypeMask
Definition: Unit.h:2537
CharmInfo * InitCharmInfo()
Definition: Unit.cpp:15704

References ASSERT, Object::GetTypeId(), HUNTER_PET, Unit::InitCharmInfo(), WorldObject::m_name, m_owner, Unit::m_unitTypeMask, TYPEID_PLAYER, UNIT_MASK_CONTROLABLE_GUARDIAN, UNIT_MASK_HUNTER_PET, and UNIT_MASK_PET.

◆ ~Pet()

Pet::~Pet ( )
overridedefault

Member Function Documentation

◆ _LoadAuras()

void Pet::_LoadAuras ( PreparedQueryResult  result,
uint32  timediff 
)
1576{
1577 LOG_DEBUG("entities.pet", "Loading auras for pet {}", GetGUID().ToString());
1578
1579 if (result)
1580 {
1581 do
1582 {
1583 int32 damage[3];
1584 int32 baseDamage[3];
1585 Field* fields = result->Fetch();
1586 ObjectGuid caster_guid = ObjectGuid(fields[0].Get<uint64>());
1587 // nullptr guid stored - pet is the caster of the spell - see Pet::_SaveAuras
1588 if (!caster_guid)
1589 caster_guid = GetGUID();
1590 uint32 spellid = fields[1].Get<uint32>();
1591 uint8 effmask = fields[2].Get<uint8>();
1592 uint8 recalculatemask = fields[3].Get<uint8>();
1593 uint8 stackcount = fields[4].Get<uint8>();
1594 damage[0] = fields[5].Get<int32>();
1595 damage[1] = fields[6].Get<int32>();
1596 damage[2] = fields[7].Get<int32>();
1597 baseDamage[0] = fields[8].Get<int32>();
1598 baseDamage[1] = fields[9].Get<int32>();
1599 baseDamage[2] = fields[10].Get<int32>();
1600 int32 maxduration = fields[11].Get<int32>();
1601 int32 remaintime = fields[12].Get<int32>();
1602 uint8 remaincharges = fields[13].Get<uint8>();
1603
1604 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellid);
1605 if (!spellInfo)
1606 {
1607 LOG_ERROR("entities.pet", "Unknown aura (spellid {}), ignore.", spellid);
1608 continue;
1609 }
1610
1611 // avoid higher level auras if any, and adjust
1612 SpellInfo const* scaledSpellInfo = spellInfo->GetAuraRankForLevel(GetLevel());
1613 if (scaledSpellInfo != spellInfo)
1614 spellInfo = scaledSpellInfo;
1615
1616 // again after level check
1617 if (!spellInfo)
1618 continue;
1619
1620 // negative effects should continue counting down after logout
1621 if (remaintime != -1 && (!spellInfo->IsPositive() || spellInfo->HasAttribute(SPELL_ATTR4_AURA_EXPIRES_OFFLINE)))
1622 {
1623 if (remaintime / IN_MILLISECONDS <= int32(timediff))
1624 {
1625 continue;
1626 }
1627
1628 remaintime -= timediff * IN_MILLISECONDS;
1629 }
1630
1631 // prevent wrong values of remaincharges
1632 if (spellInfo->ProcCharges)
1633 {
1634 if (remaincharges <= 0 || remaincharges > spellInfo->ProcCharges)
1635 remaincharges = spellInfo->ProcCharges;
1636 }
1637 else
1638 remaincharges = 0;
1639
1640 if (Aura* aura = Aura::TryCreate(spellInfo, effmask, this, nullptr, &baseDamage[0], nullptr, caster_guid))
1641 {
1642 if (!aura->CanBeSaved())
1643 {
1644 aura->Remove();
1645 continue;
1646 }
1647 aura->SetLoadedState(maxduration, remaintime, remaincharges, stackcount, recalculatemask, &damage[0]);
1648 aura->ApplyForTargets();
1649 LOG_DEBUG("entities.pet", "Added aura spellid {}, effectmask {}", spellInfo->Id, effmask);
1650 }
1651 } while (result->NextRow());
1652 }
1653}
constexpr auto IN_MILLISECONDS
Definition: Common.h:62
std::int32_t int32
Definition: Define.h:104
std::uint8_t uint8
Definition: Define.h:110
std::uint32_t uint32
Definition: Define.h:108
#define LOG_ERROR(filterType__,...)
Definition: Log.h:159
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:171
#define sSpellMgr
Definition: SpellMgr.h:818
@ SPELL_ATTR4_AURA_EXPIRES_OFFLINE
Definition: SharedDefines.h:504
Class used to access individual fields of database query result.
Definition: Field.h:99
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition: Field.h:113
ObjectGuid GetGUID() const
Definition: Object.h:107
Definition: ObjectGuid.h:120
std::string ToString() const
Definition: Position.cpp:51
uint8 GetLevel() const
Definition: Unit.h:1420
Definition: SpellAuras.h:87
static Aura * TryCreate(SpellInfo const *spellproto, uint8 effMask, WorldObject *owner, Unit *caster, int32 *baseAmount=nullptr, Item *castItem=nullptr, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemGUID=ObjectGuid::Empty)
Definition: SpellAuras.cpp:352
Definition: SpellInfo.h:314
SpellInfo const * GetAuraRankForLevel(uint8 level) const
Definition: SpellInfo.cpp:2509

References Field::Get(), SpellInfo::GetAuraRankForLevel(), Object::GetGUID(), Unit::GetLevel(), IN_MILLISECONDS, LOG_DEBUG, LOG_ERROR, SPELL_ATTR4_AURA_EXPIRES_OFFLINE, sSpellMgr, Position::ToString(), and Aura::TryCreate().

◆ _LoadSpellCooldowns()

void Pet::_LoadSpellCooldowns ( PreparedQueryResult  result)
1436{
1438
1439 if (result)
1440 {
1441 time_t curTime = GameTime::GetGameTime().count();
1442
1443 PacketCooldowns cooldowns;
1444 WorldPacket data;
1445
1446 do
1447 {
1448 Field* fields = result->Fetch();
1449
1450 uint32 spell_id = fields[0].Get<uint32>();
1451 uint16 category = fields[1].Get<uint16>();
1452 time_t db_time = time_t(fields[2].Get<uint32>());
1453
1454 if (!sSpellMgr->GetSpellInfo(spell_id))
1455 {
1456 LOG_ERROR("entities.pet", "Pet {} have unknown spell {} in `pet_spell_cooldown`, skipping.", m_charmInfo->GetPetNumber(), spell_id);
1457 continue;
1458 }
1459
1460 // skip outdated cooldown
1461 if (db_time <= curTime)
1462 continue;
1463
1464 uint32 cooldown = (db_time - curTime) * IN_MILLISECONDS;
1465 cooldowns[spell_id] = cooldown;
1466 _AddCreatureSpellCooldown(spell_id, category, cooldown);
1467
1468 LOG_DEBUG("entities.pet", "Pet (Number: {}) spell {} cooldown loaded ({} secs).", m_charmInfo->GetPetNumber(), spell_id, uint32(db_time - curTime));
1469 } while (result->NextRow());
1470
1471 if (!cooldowns.empty() && GetOwner())
1472 {
1474 GetOwner()->GetSession()->SendPacket(&data);
1475 }
1476 }
1477}
std::uint16_t uint16
Definition: Define.h:109
@ SPELL_COOLDOWN_FLAG_NONE
Definition: Unit.h:1230
std::unordered_map< uint32, uint32 > PacketCooldowns
Definition: Unit.h:1235
Seconds GetGameTime()
Definition: GameTime.cpp:38
void _AddCreatureSpellCooldown(uint32 spell_id, uint16 categoryId, uint32 end_time)
Definition: Creature.cpp:2756
CreatureSpellCooldowns m_CreatureSpellCooldowns
Definition: Creature.h:243
Player * GetOwner() const
Definition: Pet.cpp:2436
WorldSession * GetSession() const
Definition: Player.h:1948
uint32 GetPetNumber() const
Definition: Unit.h:1099
CharmInfo * m_charmInfo
Definition: Unit.h:2522
void BuildCooldownPacket(WorldPacket &data, uint8 flags, uint32 spellId, uint32 cooldown)
Definition: Unit.cpp:21164
Definition: WorldPacket.h:27
void SendPacket(WorldPacket const *packet)
Send a packet to the client.
Definition: WorldSession.cpp:207

References Creature::_AddCreatureSpellCooldown(), Unit::BuildCooldownPacket(), Field::Get(), GameTime::GetGameTime(), GetOwner(), CharmInfo::GetPetNumber(), Player::GetSession(), IN_MILLISECONDS, LOG_DEBUG, LOG_ERROR, Unit::m_charmInfo, Creature::m_CreatureSpellCooldowns, WorldSession::SendPacket(), SPELL_COOLDOWN_FLAG_NONE, and sSpellMgr.

◆ _LoadSpells()

void Pet::_LoadSpells ( PreparedQueryResult  result)
1514{
1515 if (result)
1516 {
1517 do
1518 {
1519 Field* fields = result->Fetch();
1520
1521 addSpell(fields[0].Get<uint32>(), ActiveStates(fields[1].Get<uint8>()), PETSPELL_UNCHANGED);
1522 } while (result->NextRow());
1523 }
1524}
@ PETSPELL_UNCHANGED
Definition: PetDefines.h:57
ActiveStates
Definition: Unit.h:1012
bool addSpell(uint32 spellId, ActiveStates active=ACT_DECIDE, PetSpellState state=PETSPELL_NEW, PetSpellType type=PETSPELL_NORMAL)
Definition: Pet.cpp:1737

References addSpell(), and PETSPELL_UNCHANGED.

◆ _SaveAuras()

void Pet::_SaveAuras ( CharacterDatabaseTransaction  trans)
1656{
1658 stmt->SetData(0, m_charmInfo->GetPetNumber());
1659 trans->Append(stmt);
1660
1661 for (AuraMap::const_iterator itr = m_ownedAuras.begin(); itr != m_ownedAuras.end(); ++itr)
1662 {
1663 // check if the aura has to be saved
1664 if (!itr->second->CanBeSaved() || IsPetAura(itr->second))
1665 continue;
1666
1667 Aura* aura = itr->second;
1668 if (aura->GetDuration() < 60 * IN_MILLISECONDS)
1669 continue;
1670
1671 // dont save infinite negative auras! (lavas, transformations etc)
1672 if (aura->IsPermanent() && !aura->GetSpellInfo()->IsPositive())
1673 continue;
1674
1675 // pussywizard: don't save auras that cannot be cancelled (needed for ICC buff on pets/summons)
1677 continue;
1678
1679 // xinef: don't save hidden auras
1681 continue;
1682
1683 // Xinef: Dont save auras with model change
1685 continue;
1686
1687 // xinef: don's save auras with interrupt flags on map change
1689 continue;
1690
1691 int32 damage[MAX_SPELL_EFFECTS];
1692 int32 baseDamage[MAX_SPELL_EFFECTS];
1693 uint8 effMask = 0;
1694 uint8 recalculateMask = 0;
1695 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1696 {
1697 if (aura->GetEffect(i))
1698 {
1699 baseDamage[i] = aura->GetEffect(i)->GetBaseAmount();
1700 damage[i] = aura->GetEffect(i)->GetAmount();
1701 effMask |= (1 << i);
1702 if (aura->GetEffect(i)->CanBeRecalculated())
1703 recalculateMask |= (1 << i);
1704 }
1705 else
1706 {
1707 baseDamage[i] = 0;
1708 damage[i] = 0;
1709 }
1710 }
1711
1712 // don't save guid of caster in case we are caster of the spell - guid for pet is generated every pet load, so it won't match saved guid anyways
1713 ObjectGuid casterGUID = (itr->second->GetCasterGUID() == GetGUID()) ? ObjectGuid::Empty : itr->second->GetCasterGUID();
1714
1715 uint8 index = 0;
1716
1718 stmt2->SetData(index++, m_charmInfo->GetPetNumber());
1719 stmt2->SetData(index++, casterGUID.GetRawValue());
1720 stmt2->SetData(index++, itr->second->GetId());
1721 stmt2->SetData(index++, effMask);
1722 stmt2->SetData(index++, recalculateMask);
1723 stmt2->SetData(index++, itr->second->GetStackAmount());
1724 stmt2->SetData(index++, damage[0]);
1725 stmt2->SetData(index++, damage[1]);
1726 stmt2->SetData(index++, damage[2]);
1727 stmt2->SetData(index++, baseDamage[0]);
1728 stmt2->SetData(index++, baseDamage[1]);
1729 stmt2->SetData(index++, baseDamage[2]);
1730 stmt2->SetData(index++, itr->second->GetMaxDuration());
1731 stmt2->SetData(index++, itr->second->GetDuration());
1732 stmt2->SetData(index++, itr->second->GetCharges());
1733 trans->Append(stmt2);
1734 }
1735}
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
@ CHAR_DEL_PET_AURAS
Definition: CharacterDatabase.h:464
@ CHAR_INS_PET_AURA
Definition: CharacterDatabase.h:469
@ SPELL_AURA_TRANSFORM
Definition: SpellAuraDefines.h:119
@ AURA_INTERRUPT_FLAG_CHANGE_MAP
Definition: SpellDefines.h:63
#define MAX_SPELL_EFFECTS
Definition: DBCStructure.h:1610
@ SPELL_ATTR1_NO_AURA_ICON
Definition: SharedDefines.h:419
@ SPELL_ATTR0_NO_AURA_CANCEL
Definition: SharedDefines.h:385
Definition: PreparedStatement.h:158
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition: PreparedStatement.h:78
uint64 GetRawValue() const
Definition: ObjectGuid.h:144
bool IsPetAura(Aura const *aura)
Definition: Unit.cpp:17496
AuraMap m_ownedAuras
Definition: Unit.h:2503
bool CanBeRecalculated() const
Definition: SpellAuraEffects.h:77
int32 GetBaseAmount() const
Definition: SpellAuraEffects.h:57
int32 GetAmount() const
Definition: SpellAuraEffects.h:63
int32 GetDuration() const
Definition: SpellAuras.h:133
AuraEffect * GetEffect(uint8 effIndex) const
Definition: SpellAuras.h:175
SpellInfo const * GetSpellInfo() const
Definition: SpellAuras.h:100
bool IsPermanent() const
Definition: SpellAuras.h:139
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:412
bool IsPositive() const
Definition: SpellInfo.cpp:1221
bool HasAura(AuraType aura) const
Definition: SpellInfo.cpp:877
uint32 AuraInterruptFlags
Definition: SpellInfo.h:351

References AURA_INTERRUPT_FLAG_CHANGE_MAP, SpellInfo::AuraInterruptFlags, AuraEffect::CanBeRecalculated(), CHAR_DEL_PET_AURAS, CHAR_INS_PET_AURA, CharacterDatabase, ObjectGuid::Empty, AuraEffect::GetAmount(), AuraEffect::GetBaseAmount(), Aura::GetDuration(), Aura::GetEffect(), Object::GetGUID(), CharmInfo::GetPetNumber(), ObjectGuid::GetRawValue(), Aura::GetSpellInfo(), SpellInfo::HasAttribute(), SpellInfo::HasAura(), IN_MILLISECONDS, Aura::IsPermanent(), Unit::IsPetAura(), SpellInfo::IsPositive(), Unit::m_charmInfo, Unit::m_ownedAuras, MAX_SPELL_EFFECTS, PreparedStatementBase::SetData(), SPELL_ATTR0_NO_AURA_CANCEL, SPELL_ATTR1_NO_AURA_ICON, and SPELL_AURA_TRANSFORM.

Referenced by SavePetToDB().

◆ _SaveSpellCooldowns()

void Pet::_SaveSpellCooldowns ( CharacterDatabaseTransaction  trans)
1480{
1482 stmt->SetData(0, m_charmInfo->GetPetNumber());
1483 trans->Append(stmt);
1484
1485 time_t curTime = GameTime::GetGameTime().count();
1486 uint32 curMSTime = GameTime::GetGameTimeMS().count();
1487 uint32 infTime = curMSTime + infinityCooldownDelayCheck;
1488
1489 // remove oudated and save active
1490 CreatureSpellCooldowns::iterator itr, itr2;
1491 for (itr = m_CreatureSpellCooldowns.begin(); itr != m_CreatureSpellCooldowns.end();)
1492 {
1493 itr2 = itr;
1494 ++itr;
1495
1496 if (itr2->second.end <= curMSTime + 1000)
1497 {
1498 m_CreatureSpellCooldowns.erase(itr2);
1499 }
1500 else if (itr2->second.end <= infTime)
1501 {
1502 uint32 cooldown = ((itr2->second.end - curMSTime) / IN_MILLISECONDS) + curTime;
1503 stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PET_SPELL_COOLDOWN);
1504 stmt->SetData(0, m_charmInfo->GetPetNumber());
1505 stmt->SetData(1, itr2->first);
1506 stmt->SetData(2, itr2->second.category);
1507 stmt->SetData(3, cooldown);
1508 trans->Append(stmt);
1509 }
1510 }
1511}
@ CHAR_INS_PET_SPELL_COOLDOWN
Definition: CharacterDatabase.h:466
@ CHAR_DEL_PET_SPELL_COOLDOWNS
Definition: CharacterDatabase.h:465
static constexpr uint32 infinityCooldownDelayCheck
Definition: Unit.h:155
Milliseconds GetGameTimeMS()
Definition: GameTime.cpp:43

References CHAR_DEL_PET_SPELL_COOLDOWNS, CHAR_INS_PET_SPELL_COOLDOWN, CharacterDatabase, GameTime::GetGameTime(), GameTime::GetGameTimeMS(), CharmInfo::GetPetNumber(), IN_MILLISECONDS, infinityCooldownDelayCheck, Unit::m_charmInfo, Creature::m_CreatureSpellCooldowns, and PreparedStatementBase::SetData().

Referenced by SavePetToDB().

◆ _SaveSpells()

void Pet::_SaveSpells ( CharacterDatabaseTransaction  trans)
1527{
1528 for (PetSpellMap::iterator itr = m_spells.begin(), next = m_spells.begin(); itr != m_spells.end(); itr = next)
1529 {
1530 ++next;
1531
1532 // prevent saving family passives to DB
1533 if (itr->second.type == PETSPELL_FAMILY)
1534 continue;
1535
1537
1538 switch (itr->second.state)
1539 {
1540 case PETSPELL_REMOVED:
1541 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PET_SPELL_BY_SPELL);
1542 stmt->SetData(0, m_charmInfo->GetPetNumber());
1543 stmt->SetData(1, itr->first);
1544 trans->Append(stmt);
1545
1546 m_spells.erase(itr);
1547 continue;
1548 case PETSPELL_CHANGED:
1549 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PET_SPELL_BY_SPELL);
1550 stmt->SetData(0, m_charmInfo->GetPetNumber());
1551 stmt->SetData(1, itr->first);
1552 trans->Append(stmt);
1553
1554 stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PET_SPELL);
1555 stmt->SetData(0, m_charmInfo->GetPetNumber());
1556 stmt->SetData(1, itr->first);
1557 stmt->SetData(2, itr->second.active);
1558 trans->Append(stmt);
1559
1560 break;
1561 case PETSPELL_NEW:
1562 stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PET_SPELL);
1563 stmt->SetData(0, m_charmInfo->GetPetNumber());
1564 stmt->SetData(1, itr->first);
1565 stmt->SetData(2, itr->second.active);
1566 trans->Append(stmt);
1567 break;
1568 case PETSPELL_UNCHANGED:
1569 continue;
1570 }
1571 itr->second.state = PETSPELL_UNCHANGED;
1572 }
1573}
@ CHAR_INS_PET_SPELL
Definition: CharacterDatabase.h:468
@ CHAR_DEL_PET_SPELL_BY_SPELL
Definition: CharacterDatabase.h:467
@ PETSPELL_NEW
Definition: PetDefines.h:59
@ PETSPELL_CHANGED
Definition: PetDefines.h:58
@ PETSPELL_REMOVED
Definition: PetDefines.h:60
@ PETSPELL_FAMILY
Definition: PetDefines.h:66
PetSpellMap m_spells
Definition: Pet.h:120

References CHAR_DEL_PET_SPELL_BY_SPELL, CHAR_INS_PET_SPELL, CharacterDatabase, CharmInfo::GetPetNumber(), Unit::m_charmInfo, m_spells, PETSPELL_CHANGED, PETSPELL_FAMILY, PETSPELL_NEW, PETSPELL_REMOVED, PETSPELL_UNCHANGED, and PreparedStatementBase::SetData().

Referenced by SavePetToDB().

◆ addSpell()

bool Pet::addSpell ( uint32  spellId,
ActiveStates  active = ACT_DECIDE,
PetSpellState  state = PETSPELL_NEW,
PetSpellType  type = PETSPELL_NORMAL 
)
1738{
1739 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
1740 if (!spellInfo)
1741 {
1742 // do pet spell book cleanup
1743 if (state == PETSPELL_UNCHANGED) // spell load case
1744 {
1745 LOG_ERROR("entities.pet", "Pet::addSpell: Non-existed in SpellStore spell #{} request, deleting for all pets in `pet_spell`.", spellId);
1746
1748 stmt->SetData(0, spellId);
1749 CharacterDatabase.Execute(stmt);
1750 }
1751 else
1752 LOG_ERROR("entities.pet", "Pet::addSpell: Non-existed in SpellStore spell #{} request.", spellId);
1753
1754 return false;
1755 }
1756
1757 auto const& itr = m_spells.find(spellId);
1758 if (itr != m_spells.end())
1759 {
1760 if (itr->second.state == PETSPELL_REMOVED)
1761 {
1762 m_spells.erase(itr);
1763 state = PETSPELL_CHANGED;
1764 }
1765 else if (state == PETSPELL_UNCHANGED && itr->second.state != PETSPELL_UNCHANGED)
1766 {
1767 // can be in case spell loading but learned at some previous spell loading
1768 itr->second.state = PETSPELL_UNCHANGED;
1769
1770 ToggleAutocast(spellInfo, active == ACT_ENABLED);
1771 return false;
1772 }
1773 else
1774 return false;
1775 }
1776
1777 PetSpell newspell;
1778 newspell.state = state;
1779 newspell.type = type;
1780
1781 if (active == ACT_DECIDE) // active was not used before, so we save it's autocast/passive state here
1782 {
1783 if (spellInfo->IsAutocastable())
1784 newspell.active = ACT_DISABLED;
1785 else
1786 newspell.active = ACT_PASSIVE;
1787 }
1788 else
1789 newspell.active = active;
1790
1791 // talent: unlearn all other talent ranks (high and low)
1792 if (TalentSpellPos const* talentPos = GetTalentSpellPos(spellId))
1793 {
1794 if (TalentEntry const* talentInfo = sTalentStore.LookupEntry(talentPos->talent_id))
1795 {
1796 for (uint32 rankSpellId : talentInfo->RankID)
1797 {
1798 // skip learning spell and no rank spell case
1799 if (!rankSpellId || rankSpellId == spellId)
1800 continue;
1801
1802 // skip unknown ranks
1803 if (!HasSpell(rankSpellId))
1804 continue;
1805 removeSpell(rankSpellId, false, false);
1806 }
1807 }
1808 }
1809 else if (spellInfo->IsRanked())
1810 {
1811 for (auto const& [spellID, petSpell] : m_spells)
1812 {
1813 if (petSpell.state == PETSPELL_REMOVED)
1814 continue;
1815
1816 SpellInfo const* oldRankSpellInfo = sSpellMgr->GetSpellInfo(spellID);
1817
1818 if (!oldRankSpellInfo)
1819 continue;
1820
1821 if (spellInfo->IsDifferentRankOf(oldRankSpellInfo))
1822 {
1823 // replace by new high rank
1824 if (spellInfo->IsHighRankOf(oldRankSpellInfo))
1825 {
1826 newspell.active = petSpell.active;
1827
1828 if (newspell.active == ACT_ENABLED)
1829 ToggleAutocast(oldRankSpellInfo, false);
1830
1831 unlearnSpell(spellID, false, false);
1832 break;
1833 }
1834 // ignore new lesser rank
1835 else
1836 return false;
1837 }
1838 }
1839 }
1840
1841 m_spells[spellId] = newspell;
1842
1843 if (spellInfo->IsPassive())
1844 CastSpell(this, spellId, true);
1845 else
1846 m_charmInfo->AddSpellToActionBar(spellInfo);
1847
1848 // unapply aura stats if dont meet requirements
1849 if (Aura* aura = GetAura(spellId))
1850 {
1851 if (aura->GetSpellInfo()->CasterAuraState == AURA_STATE_HEALTHLESS_35_PERCENT ||
1852 aura->GetSpellInfo()->CasterAuraState == AURA_STATE_HEALTH_ABOVE_75_PERCENT ||
1853 aura->GetSpellInfo()->CasterAuraState == AURA_STATE_HEALTHLESS_20_PERCENT )
1854 if (!HasAuraState((AuraStateType)aura->GetSpellInfo()->CasterAuraState))
1855 {
1856 aura->HandleAllEffects(aura->GetApplicationOfTarget(GetGUID()), AURA_EFFECT_HANDLE_REAL, false);
1857 }
1858 }
1859
1860 ToggleAutocast(spellInfo, (newspell.active == ACT_ENABLED));
1861
1862 uint32 talentCost = GetTalentSpellCost(spellId);
1863 if (talentCost)
1864 {
1865 int32 free_points = GetMaxTalentPointsForLevel(GetLevel());
1866 m_usedTalentCount += talentCost;
1867 // update free talent points
1868 free_points -= m_usedTalentCount;
1869 SetFreeTalentPoints(free_points > 0 ? free_points : 0);
1870 }
1871 return true;
1872}
@ CHAR_DEL_INVALID_PET_SPELL
Definition: CharacterDatabase.h:300
TalentSpellPos const * GetTalentSpellPos(uint32 spellId)
Definition: DBCStores.cpp:670
uint32 GetTalentSpellCost(uint32 spellId)
Definition: DBCStores.cpp:679
DBCStorage< TalentEntry > sTalentStore(TalentEntryfmt)
@ ACT_DECIDE
Definition: Unit.h:1018
@ ACT_ENABLED
Definition: Unit.h:1015
@ ACT_PASSIVE
Definition: Unit.h:1013
@ ACT_DISABLED
Definition: Unit.h:1014
@ AURA_EFFECT_HANDLE_REAL
Definition: SpellAuraDefines.h:42
AuraStateType
Definition: SharedDefines.h:1260
@ AURA_STATE_HEALTHLESS_35_PERCENT
Definition: SharedDefines.h:1277
@ AURA_STATE_HEALTH_ABOVE_75_PERCENT
Definition: SharedDefines.h:1287
@ AURA_STATE_HEALTHLESS_20_PERCENT
Definition: SharedDefines.h:1265
Definition: Pet.h:28
PetSpellState state
Definition: Pet.h:30
PetSpellType type
Definition: Pet.h:31
ActiveStates active
Definition: Pet.h:29
bool unlearnSpell(uint32 spell_id, bool learn_prev, bool clear_ab=true)
Definition: Pet.cpp:1930
void ToggleAutocast(SpellInfo const *spellInfo, bool apply)
Definition: Pet.cpp:2196
bool removeSpell(uint32 spell_id, bool learn_prev, bool clear_ab=true)
Definition: Pet.cpp:1947
void SetFreeTalentPoints(uint8 points)
Definition: Pet.h:131
uint8 GetMaxTalentPointsForLevel(uint8 level)
Definition: Pet.cpp:2184
bool HasSpell(uint32 spell) const override
Definition: Pet.cpp:2283
bool AddSpellToActionBar(SpellInfo const *spellInfo, ActiveStates newstate=ACT_DECIDE)
Definition: Unit.cpp:15860
Aura * GetAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition: Unit.cpp:5499
bool HasAuraState(AuraStateType flag, SpellInfo const *spellProto=nullptr, Unit const *Caster=nullptr) const
Definition: Unit.cpp:10507
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 IsAutocastable() const
Definition: SpellInfo.cpp:1087
bool IsPassive() const
Definition: SpellInfo.cpp:1082
bool IsRanked() const
Definition: SpellInfo.cpp:2472
bool IsHighRankOf(SpellInfo const *spellInfo) const
Definition: SpellInfo.cpp:2564
bool IsDifferentRankOf(SpellInfo const *spellInfo) const
Definition: SpellInfo.cpp:2557
Definition: DBCStructure.h:1899
Definition: DBCStructure.h:2205

References ACT_DECIDE, ACT_DISABLED, ACT_ENABLED, ACT_PASSIVE, PetSpell::active, CharmInfo::AddSpellToActionBar(), AURA_EFFECT_HANDLE_REAL, AURA_STATE_HEALTH_ABOVE_75_PERCENT, AURA_STATE_HEALTHLESS_20_PERCENT, AURA_STATE_HEALTHLESS_35_PERCENT, Unit::CastSpell(), CHAR_DEL_INVALID_PET_SPELL, CharacterDatabase, Unit::GetAura(), Object::GetGUID(), Unit::GetLevel(), GetMaxTalentPointsForLevel(), GetTalentSpellCost(), GetTalentSpellPos(), Unit::HasAuraState(), HasSpell(), SpellInfo::IsAutocastable(), SpellInfo::IsDifferentRankOf(), SpellInfo::IsHighRankOf(), SpellInfo::IsPassive(), SpellInfo::IsRanked(), LOG_ERROR, Unit::m_charmInfo, m_spells, m_usedTalentCount, PETSPELL_CHANGED, PETSPELL_REMOVED, PETSPELL_UNCHANGED, removeSpell(), PreparedStatementBase::SetData(), SetFreeTalentPoints(), sSpellMgr, sTalentStore, PetSpell::state, ToggleAutocast(), PetSpell::type, and unlearnSpell().

Referenced by _LoadSpells(), LearnPetPassives(), and learnSpell().

◆ AddToWorld()

void Pet::AddToWorld ( )
overridevirtual
  • Register the pet for guid lookup
  • Register the pet for guid lookup

Reimplemented from Creature.

72{
74 if (!IsInWorld())
75 {
81 }
82
83 // pussywizard: apply ICC buff to pets
84 if (GetOwnerGUID().IsPlayer() && GetMapId() == 631 && FindMap() && FindMap()->ToInstanceMap() && FindMap()->ToInstanceMap()->GetInstanceScript() && FindMap()->ToInstanceMap()->GetInstanceScript()->GetData(251 /*DATA_BUFF_AVAILABLE*/))
85 if (Unit* owner = GetOwner())
86 if (Player* plr = owner->ToPlayer())
87 {
88 SpellAreaForAreaMapBounds saBounds = sSpellMgr->GetSpellAreaForAreaMapBounds(4812);
89 for (SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr)
90 if ((itr->second->raceMask & plr->getRaceMask()) && !HasAura(itr->second->spellId))
91 if (SpellInfo const* si = sSpellMgr->GetSpellInfo(itr->second->spellId))
93 AddAura(itr->second->spellId, this);
94 }
95
96 // Prevent stuck pets when zoning. Pets default to "follow" when added to world
97 // so we'll reset flags and let the AI handle things
98 if (GetCharmInfo() && GetCharmInfo()->HasCommandState(COMMAND_FOLLOW))
99 {
102 GetCharmInfo()->SetIsAtStay(false);
105 }
106
107 if (GetOwnerGUID().IsPlayer())
108 {
109 sScriptMgr->OnPetAddToWorld(this);
110 }
111}
@ COMMAND_FOLLOW
Definition: Unit.h:1031
#define sScriptMgr
Definition: ScriptMgr.h:2702
@ SPELL_AURA_MOD_INCREASE_HEALTH_PERCENT
Definition: SpellAuraDefines.h:196
std::pair< SpellAreaForAreaMap::const_iterator, SpellAreaForAreaMap::const_iterator > SpellAreaForAreaMapBounds
Definition: SpellMgr.h:543
bool Insert(KEY_TYPE const &handle, SPECIFIC_TYPE *obj)
Definition: TypeContainer.h:135
bool AIM_Initialize(CreatureAI *ai=nullptr)
Definition: Creature.cpp:1061
void Motion_Initialize()
Definition: Creature.cpp:1086
bool IsPlayer() const
Definition: Object.h:194
Player * ToPlayer()
Definition: Object.h:195
bool IsInWorld() const
Definition: Object.h:101
Map * GetMap() const
Definition: Object.h:517
Map * FindMap() const
Definition: Object.h:518
InstanceScript * GetInstanceScript() const
Definition: Object.cpp:1192
uint32 GetMapId() const
Definition: Position.h:276
Definition: Pet.h:40
Definition: Player.h:1046
void SetIsCommandFollow(bool val)
Definition: Unit.cpp:20507
void SetIsAtStay(bool val)
Definition: Unit.cpp:20559
void SetIsFollowing(bool val)
Definition: Unit.cpp:20569
void SetIsReturning(bool val)
Definition: Unit.cpp:20579
void SetIsCommandAttack(bool val)
Definition: Unit.cpp:20497
Definition: Unit.h:1290
void AddToWorld() override
Definition: Unit.cpp:15580
Aura * AddAura(uint32 spellId, Unit *target)
Definition: Unit.cpp:19031
CharmInfo * GetCharmInfo()
Definition: Unit.h:1883
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition: Unit.cpp:5610
ObjectGuid GetOwnerGUID() const
Definition: Unit.h:1814
MapStoredObjectTypesContainer & GetObjectsStore()
Definition: Map.h:515

References Unit::AddAura(), Unit::AddToWorld(), Creature::AIM_Initialize(), COMMAND_FOLLOW, WorldObject::FindMap(), Unit::GetCharmInfo(), Object::GetGUID(), WorldObject::GetInstanceScript(), WorldObject::GetMap(), WorldLocation::GetMapId(), Map::GetObjectsStore(), GetOwner(), Unit::GetOwnerGUID(), Unit::HasAura(), TypeUnorderedMapContainer< OBJECT_TYPES, KEY_TYPE >::Insert(), Object::IsInWorld(), Object::IsPlayer(), Creature::Motion_Initialize(), CharmInfo::SetIsAtStay(), CharmInfo::SetIsCommandAttack(), CharmInfo::SetIsCommandFollow(), CharmInfo::SetIsFollowing(), CharmInfo::SetIsReturning(), SPELL_AURA_MOD_INCREASE_HEALTH_PERCENT, sScriptMgr, sSpellMgr, and Object::ToPlayer().

◆ CastPetAuras()

void Pet::CastPetAuras ( bool  current)
2312{
2313 Unit* owner = GetOwner();
2314 if (!owner || owner->GetTypeId() != TYPEID_PLAYER)
2315 return;
2316
2317 if (!IsPermanentPetFor(owner->ToPlayer()))
2318 return;
2319
2320 for (PetAuraSet::const_iterator itr = owner->m_petAuras.begin(); itr != owner->m_petAuras.end();)
2321 {
2322 PetAura const* pa = *itr;
2323 ++itr;
2324
2325 if (!current && pa->IsRemovedOnChangePet())
2326 owner->RemovePetAura(pa);
2327 else
2328 CastPetAura(pa);
2329 }
2330}
bool IsPermanentPetFor(Player *owner) const
Definition: Pet.cpp:2238
void RemovePetAura(PetAura const *petSpell)
Definition: Unit.cpp:17469
void CastPetAura(PetAura const *aura)
Definition: Unit.cpp:17481
PetAuraSet m_petAuras
Definition: Unit.h:2334
Definition: SpellMgr.h:463
bool IsRemovedOnChangePet() const
Definition: SpellMgr.h:495

References Unit::CastPetAura(), GetOwner(), Object::GetTypeId(), IsPermanentPetFor(), PetAura::IsRemovedOnChangePet(), Unit::m_petAuras, Unit::RemovePetAura(), Object::ToPlayer(), and TYPEID_PLAYER.

Referenced by InitPetCreateSpells(), and setDeathState().

◆ CastWhenWillAvailable()

void Pet::CastWhenWillAvailable ( uint32  spellid,
Unit spellTarget,
Unit oldTarget,
bool  spellIsPositive = false 
)
2378{
2379 if (!spellid)
2380 return;
2381
2382 if (!spellTarget)
2383 return;
2384
2385 m_tempspellTarget = spellTarget;
2386 m_tempspell = spellid;
2387 m_tempspellIsPositive = spellIsPositive;
2388
2389 if (oldTarget)
2390 m_tempoldTarget = oldTarget;
2391}

References m_tempoldTarget, m_tempspell, m_tempspellIsPositive, and m_tempspellTarget.

Referenced by WorldSession::HandlePetActionHelper().

◆ CleanupActionBar()

void Pet::CleanupActionBar ( )
1999{
2000 for (uint8 i = 0; i < MAX_UNIT_ACTION_BAR_INDEX; ++i)
2002 if (ab->GetAction() && ab->IsActionBarForSpell())
2003 {
2004 if (!HasSpell(ab->GetAction()))
2006 else if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(ab->GetAction()))
2007 ToggleAutocast(spellInfo, ab->GetType() == ACT_ENABLED);
2008 }
2009}
#define MAX_UNIT_ACTION_BAR_INDEX
Definition: Unit.h:1091
Definition: Unit.h:1041
void SetActionBar(uint8 index, uint32 spellOrAction, ActiveStates type)
Definition: Unit.h:1117
UnitActionBarEntry const * GetActionBarEntry(uint8 index) const
Definition: Unit.h:1121

References ACT_ENABLED, ACT_PASSIVE, CharmInfo::GetActionBarEntry(), HasSpell(), Unit::m_charmInfo, MAX_UNIT_ACTION_BAR_INDEX, CharmInfo::SetActionBar(), sSpellMgr, and ToggleAutocast().

Referenced by LoadPetFromDB().

◆ ClearCastWhenWillAvailable()

void Pet::ClearCastWhenWillAvailable ( )
2394{
2395 m_tempspellIsPositive = false;
2396 m_tempspell = 0;
2397 m_tempspellTarget = nullptr;
2398 m_tempoldTarget = nullptr;
2399}

References m_tempoldTarget, m_tempspell, m_tempspellIsPositive, and m_tempspellTarget.

Referenced by WorldSession::HandlePetActionHelper().

◆ Create()

bool Pet::Create ( ObjectGuid::LowType  guidlow,
Map map,
uint32  phaseMask,
uint32  Entry,
uint32  pet_number 
)
2262{
2263 ASSERT(map);
2264 SetMap(map);
2265
2266 SetPhaseMask(phaseMask, false);
2267
2268 Object::_Create(guidlow, pet_number, HighGuid::Pet);
2269
2270 m_spawnId = guidlow;
2272
2273 if (!InitEntry(Entry))
2274 return false;
2275
2276 // Force regen flag for player pets, just like we do for players themselves
2279
2280 return true;
2281}
@ UNIT_FLAG2_REGENERATE_POWER
Definition: Unit.h:498
@ SHEATH_STATE_MELEE
Definition: Unit.h:127
uint32 const Entry[3]
Definition: instance_blackwing_lair.cpp:70
ObjectGuid::LowType m_spawnId
For new or temporary creatures is 0 for saved it is lowguid.
Definition: Creature.h:432
bool InitEntry(uint32 entry, const CreatureData *data=nullptr)
Definition: Creature.cpp:385
uint32 m_originalEntry
Definition: Creature.h:443
void _Create(ObjectGuid::LowType guidlow, uint32 entry, HighGuid guidhigh)
Definition: Object.cpp:134
virtual void SetMap(Map *map)
Definition: Object.cpp:2071
void SetUnitFlag2(UnitFlags2 flags)
Definition: Unit.h:1487
virtual void SetSheath(SheathState sheathed)
Definition: Unit.h:1492
void SetPhaseMask(uint32 newPhaseMask, bool update) override
Definition: Unit.cpp:19217

References Object::_Create(), ASSERT, Entry, Creature::InitEntry(), Creature::m_originalEntry, Creature::m_spawnId, WorldObject::SetMap(), Unit::SetPhaseMask(), Unit::SetSheath(), Unit::SetUnitFlag2(), SHEATH_STATE_MELEE, and UNIT_FLAG2_REGENERATE_POWER.

Referenced by CreateBaseAtTamed(), LoadPetFromDB(), and Player::SummonPet().

◆ CreateBaseAtCreature()

bool Pet::CreateBaseAtCreature ( Creature creature)
933{
934 ASSERT(creature);
935
936 if (!CreateBaseAtTamed(creature->GetCreatureTemplate(), creature->GetMap(), creature->GetPhaseMask()))
937 return false;
938
939 Relocate(creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ(), creature->GetOrientation());
940
941 if (!IsPositionValid())
942 {
943 LOG_ERROR("entities.pet", "Pet {} not created base at creature. Suggested coordinates isn't valid (X: {} Y: {})",
945 return false;
946 }
947
948 CreatureTemplate const* cinfo = GetCreatureTemplate();
949 if (!cinfo)
950 {
951 LOG_ERROR("entities.pet", "CreateBaseAtCreature() failed, creatureInfo is missing!");
952 return false;
953 }
954
955 SetDisplayId(creature->GetDisplayId());
956
958
959 if (CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cinfo->family))
960 SetName(cFamily->Name[sWorld->GetDefaultDbcLocale()]);
961 else
962 SetName(creature->GetNameForLocaleIdx(sObjectMgr->GetDBCLocaleIndex()));
963
964 return true;
965}
DBCStorage< CreatureFamilyEntry > sCreatureFamilyStore(CreatureFamilyfmt)
#define sObjectMgr
Definition: ObjectMgr.h:1640
#define sWorld
Definition: World.h:451
std::string const & GetNameForLocaleIdx(LocaleConstant locale_idx) const override
Definition: Creature.cpp:3039
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:197
Definition: CreatureData.h:176
uint32 family
Definition: CreatureData.h:210
uint32 GetPhaseMask() const
Definition: Object.h:434
void SetName(std::string const &newname)
Definition: Object.h:447
void UpdatePositionData()
Definition: Object.cpp:1154
float GetPositionZ() const
Definition: Position.h:119
float GetOrientation() const
Definition: Position.h:120
bool IsPositionValid() const
Definition: Position.cpp:175
float GetPositionX() const
Definition: Position.h:117
float GetPositionY() const
Definition: Position.h:118
void Relocate(float x, float y)
Definition: Position.h:73
void SetDisplayId(uint32 modelId) override
Definition: Pet.cpp:2364
bool CreateBaseAtTamed(CreatureTemplate const *cinfo, Map *map, uint32 phaseMask)
Definition: Pet.cpp:982
uint32 GetDisplayId() const
Definition: Unit.h:2168
Definition: DBCStructure.h:754

References ASSERT, CreateBaseAtTamed(), CreatureTemplate::family, Creature::GetCreatureTemplate(), Unit::GetDisplayId(), Object::GetGUID(), WorldObject::GetMap(), Creature::GetNameForLocaleIdx(), Position::GetOrientation(), WorldObject::GetPhaseMask(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), Position::IsPositionValid(), LOG_ERROR, Position::Relocate(), sCreatureFamilyStore, SetDisplayId(), WorldObject::SetName(), sObjectMgr, sWorld, Position::ToString(), and WorldObject::UpdatePositionData().

Referenced by Unit::CreateTamedPetFrom().

◆ CreateBaseAtCreatureInfo()

bool Pet::CreateBaseAtCreatureInfo ( CreatureTemplate const *  cinfo,
Unit owner 
)

◆ CreateBaseAtTamed()

bool Pet::CreateBaseAtTamed ( CreatureTemplate const *  cinfo,
Map map,
uint32  phaseMask 
)
983{
984 LOG_DEBUG("entities.pet", "Pet::CreateBaseForTamed");
985 ObjectGuid::LowType guid = map->GenerateLowGuid<HighGuid::Pet>();
986 uint32 pet_number = sObjectMgr->GeneratePetNumber();
987 if (!Create(guid, map, phaseMask, cinfo->Entry, pet_number))
988 return false;
989
991 SetPower(POWER_HAPPINESS, 166500);
997
998 if (cinfo->type == CREATURE_TYPE_BEAST)
999 {
1003 }
1004
1005 return true;
1006}
@ UNIT_FIELD_PETEXPERIENCE
Definition: UpdateFields.h:134
@ UNIT_FIELD_BYTES_0
Definition: UpdateFields.h:95
@ UNIT_FIELD_PET_NAME_TIMESTAMP
Definition: UpdateFields.h:133
@ UNIT_FIELD_PETNEXTLEVELEXP
Definition: UpdateFields.h:135
@ UNIT_FIELD_BYTES_2
Definition: UpdateFields.h:161
@ UNIT_CAN_BE_RENAMED
Definition: Unit.h:149
@ UNIT_CAN_BE_ABANDONED
Definition: Unit.h:150
@ UNIT_NPC_FLAG_NONE
Definition: Unit.h:515
@ RATE_XP_PET_NEXT_LEVEL
Definition: IWorld.h:469
@ POWER_HAPPINESS
Definition: SharedDefines.h:245
@ POWER_FOCUS
Definition: SharedDefines.h:243
@ CREATURE_TYPE_BEAST
Definition: SharedDefines.h:2600
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:650
void SetByteFlag(uint16 index, uint8 offset, uint8 newFlag)
Definition: Object.cpp:911
uint32 LowType
Definition: ObjectGuid.h:124
bool Create(ObjectGuid::LowType guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 pet_number)
Definition: Pet.cpp:2261
uint32 GetCreatePowers(Powers power) const
Definition: Unit.cpp:15552
void SetPower(Powers power, uint32 val, bool withPowerUpdate=true, bool fromRegenerate=false)
Definition: Unit.cpp:15458
void SetMaxPower(Powers power, uint32 val)
Definition: Unit.cpp:15523
void setPowerType(Powers power)
Definition: Unit.cpp:9952
void ReplaceAllNpcFlags(NPCFlags flags)
Definition: Unit.h:1649
ObjectGuid::LowType GenerateLowGuid()
Definition: Map.h:632

References Create(), CREATURE_TYPE_BEAST, CreatureTemplate::Entry, Map::GenerateLowGuid(), Unit::GetCreatePowers(), Unit::GetLevel(), LOG_DEBUG, POWER_FOCUS, POWER_HAPPINESS, RATE_XP_PET_NEXT_LEVEL, Unit::ReplaceAllNpcFlags(), Object::SetByteFlag(), Unit::SetMaxPower(), Unit::SetPower(), Unit::setPowerType(), Unit::SetSheath(), Object::SetUInt32Value(), SHEATH_STATE_MELEE, sObjectMgr, sWorld, CreatureTemplate::type, UNIT_CAN_BE_ABANDONED, UNIT_CAN_BE_RENAMED, UNIT_FIELD_BYTES_0, UNIT_FIELD_BYTES_2, UNIT_FIELD_PET_NAME_TIMESTAMP, UNIT_FIELD_PETEXPERIENCE, UNIT_FIELD_PETNEXTLEVELEXP, and UNIT_NPC_FLAG_NONE.

Referenced by CreateBaseAtCreature(), and CreateBaseAtCreatureInfo().

◆ DeleteFromDB() [1/2]

void Pet::DeleteFromDB ( )
inlineoverrideprivatevirtual

Reimplemented from Creature.

171 {
172 ABORT();
173 }
#define ABORT
Definition: Errors.h:76

References ABORT.

Referenced by Player::DeleteFromDB(), and SavePetToDB().

◆ DeleteFromDB() [2/2]

void Pet::DeleteFromDB ( ObjectGuid::LowType  guidlow)
static
592{
593 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
594
596 stmt->SetData(0, guidlow);
597 trans->Append(stmt);
598
599 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_PET_DECLINEDNAME);
600 stmt->SetData(0, guidlow);
601 trans->Append(stmt);
602
603 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PET_AURAS);
604 stmt->SetData(0, guidlow);
605 trans->Append(stmt);
606
607 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PET_SPELLS);
608 stmt->SetData(0, guidlow);
609 trans->Append(stmt);
610
611 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PET_SPELL_COOLDOWNS);
612 stmt->SetData(0, guidlow);
613 trans->Append(stmt);
614
615 CharacterDatabase.CommitTransaction(trans);
616}
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:70
@ CHAR_DEL_PET_SPELLS
Definition: CharacterDatabase.h:471
@ CHAR_DEL_CHAR_PET_BY_ID
Definition: CharacterDatabase.h:481
@ CHAR_DEL_CHAR_PET_DECLINEDNAME
Definition: CharacterDatabase.h:476

References CHAR_DEL_CHAR_PET_BY_ID, CHAR_DEL_CHAR_PET_DECLINEDNAME, CHAR_DEL_PET_AURAS, CHAR_DEL_PET_SPELL_COOLDOWNS, CHAR_DEL_PET_SPELLS, CharacterDatabase, and PreparedStatementBase::SetData().

◆ FillPetInfo()

void Pet::FillPetInfo ( PetStable::PetInfo petInfo) const
2418{
2419 petInfo->PetNumber = m_charmInfo->GetPetNumber();
2420 petInfo->CreatureId = GetEntry();
2421 petInfo->DisplayId = GetNativeDisplayId();
2422 petInfo->Level = GetLevel();
2424 petInfo->ReactState = GetReactState();
2425 petInfo->Name = GetName();
2427 petInfo->Health = GetHealth();
2428 petInfo->Mana = GetPower(POWER_MANA);
2430 petInfo->ActionBar = GenerateActionBarData();
2431 petInfo->LastSaveTime = GameTime::GetGameTime().count();
2433 petInfo->Type = getPetType();
2434}
@ UNIT_CREATED_BY_SPELL
Definition: UpdateFields.h:138
@ POWER_MANA
Definition: SharedDefines.h:241
ReactStates GetReactState() const
Definition: Creature.h:90
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:305
uint32 GetEntry() const
Definition: Object.h:109
bool HasByteFlag(uint16 index, uint8 offset, uint8 flag) const
Definition: Object.cpp:949
std::string const & GetName() const
Definition: Object.h:446
PetType getPetType() const
Definition: Pet.h:51
std::string GenerateActionBarData() const
Definition: Pet.cpp:2464
uint32 Mana
Definition: PetDefines.h:210
uint32 Happiness
Definition: PetDefines.h:211
uint32 CreatedBySpellId
Definition: PetDefines.h:213
uint32 Health
Definition: PetDefines.h:209
uint32 CreatureId
Definition: PetDefines.h:206
bool WasRenamed
Definition: PetDefines.h:217
uint8 Level
Definition: PetDefines.h:214
uint32 DisplayId
Definition: PetDefines.h:207
ReactStates ReactState
Definition: PetDefines.h:215
std::string Name
Definition: PetDefines.h:203
PetType Type
Definition: PetDefines.h:216
uint32 Experience
Definition: PetDefines.h:208
uint32 PetNumber
Definition: PetDefines.h:205
uint32 LastSaveTime
Definition: PetDefines.h:212
std::string ActionBar
Definition: PetDefines.h:204
uint32 GetNativeDisplayId() const
Definition: Unit.h:2170
uint32 GetHealth() const
Definition: Unit.h:1440
uint32 GetPower(Powers power) const
Definition: Unit.h:1461

References PetStable::PetInfo::ActionBar, PetStable::PetInfo::CreatedBySpellId, PetStable::PetInfo::CreatureId, PetStable::PetInfo::DisplayId, PetStable::PetInfo::Experience, GenerateActionBarData(), Object::GetEntry(), GameTime::GetGameTime(), Unit::GetHealth(), Unit::GetLevel(), WorldObject::GetName(), Unit::GetNativeDisplayId(), CharmInfo::GetPetNumber(), getPetType(), Unit::GetPower(), Creature::GetReactState(), Object::GetUInt32Value(), PetStable::PetInfo::Happiness, Object::HasByteFlag(), PetStable::PetInfo::Health, PetStable::PetInfo::LastSaveTime, PetStable::PetInfo::Level, Unit::m_charmInfo, PetStable::PetInfo::Mana, PetStable::PetInfo::Name, PetStable::PetInfo::PetNumber, POWER_HAPPINESS, POWER_MANA, PetStable::PetInfo::ReactState, PetStable::PetInfo::Type, UNIT_CAN_BE_RENAMED, UNIT_CREATED_BY_SPELL, UNIT_FIELD_BYTES_2, UNIT_FIELD_PETEXPERIENCE, and PetStable::PetInfo::WasRenamed.

Referenced by Unit::InitTamedPet(), SavePetToDB(), and Player::SummonPet().

◆ GenerateActionBarData()

std::string Pet::GenerateActionBarData ( ) const
2465{
2466 std::ostringstream oss;
2467
2469 {
2470 oss << uint32(m_charmInfo->GetActionBarEntry(i)->GetType()) << ' '
2472 }
2473
2474 return oss.str();
2475}
@ ACTION_BAR_INDEX_END
Definition: Unit.h:1088
@ ACTION_BAR_INDEX_START
Definition: Unit.h:1085
ActiveStates GetType() const
Definition: Unit.h:1047
uint32 GetAction() const
Definition: Unit.h:1048

References ACTION_BAR_INDEX_END, ACTION_BAR_INDEX_START, UnitActionBarEntry::GetAction(), CharmInfo::GetActionBarEntry(), UnitActionBarEntry::GetType(), and Unit::m_charmInfo.

Referenced by FillPetInfo(), and SavePetToDB().

◆ GetAuraUpdateMaskForRaid()

uint64 Pet::GetAuraUpdateMaskForRaid ( ) const
inline

◆ GetCurrentFoodBenefitLevel()

uint32 Pet::GetCurrentFoodBenefitLevel ( uint32  itemlevel) const
1420{
1421 // -5 or greater food level
1422 if (GetLevel() <= itemlevel + 5) //possible to feed level 60 pet with level 55 level food for full effect
1423 return 35000;
1424 // -10..-6
1425 else if (GetLevel() <= itemlevel + 10) //pure guess, but sounds good
1426 return 17000;
1427 // -14..-11
1428 else if (GetLevel() <= itemlevel + 14) //level 55 food gets green on 70, makes sense to me
1429 return 8000;
1430 // -15 or less
1431 else
1432 return 0; //food too low level
1433}

References Unit::GetLevel().

Referenced by Spell::CheckCast(), and Spell::EffectFeedPet().

◆ GetDebugInfo()

std::string Pet::GetDebugInfo ( ) const
overridevirtual

Reimplemented from Guardian.

2478{
2479 std::stringstream sstr;
2480 sstr << Guardian::GetDebugInfo() << "\n"
2481 << std::boolalpha
2482 << "PetType: " << std::to_string(getPetType()) << " "
2483 << "PetNumber: " << m_charmInfo->GetPetNumber();
2484 return sstr.str();
2485}
std::string GetDebugInfo() const override
Definition: TemporarySummon.cpp:458

References Guardian::GetDebugInfo(), CharmInfo::GetPetNumber(), getPetType(), and Unit::m_charmInfo.

◆ GetDeclinedNames()

DeclinedName const * Pet::GetDeclinedNames ( ) const
inline
139{ return m_declinedname.get(); }
std::unique_ptr< DeclinedName > m_declinedname
Definition: Pet.h:158

References m_declinedname.

◆ GetDuration()

Milliseconds Pet::GetDuration ( ) const
inline
90{ return m_duration; }

References m_duration.

Referenced by Player::PetSpellInitialize().

◆ GetFreeTalentPoints()

uint8 Pet::GetFreeTalentPoints ( )
inline
130{ return GetByteValue(UNIT_FIELD_BYTES_1, 1); }
@ UNIT_FIELD_BYTES_1
Definition: UpdateFields.h:131
uint8 GetByteValue(uint16 index, uint8 offset) const
Definition: Object.cpp:323

References Object::GetByteValue(), and UNIT_FIELD_BYTES_1.

Referenced by Player::BuildPetTalentsInfoData(), and Player::LearnPetTalent().

◆ GetHappinessState()

HappinessState Pet::GetHappinessState ( )
863{
865 return UNHAPPY;
867 return HAPPY;
868 else
869 return CONTENT;
870}
constexpr auto HAPPINESS_LEVEL_SIZE
Definition: Pet.h:25
@ HAPPY
Definition: PetDefines.h:52
@ CONTENT
Definition: PetDefines.h:51
@ UNHAPPY
Definition: PetDefines.h:50

References CONTENT, Unit::GetPower(), HAPPINESS_LEVEL_SIZE, HAPPY, POWER_HAPPINESS, and UNHAPPY.

Referenced by Guardian::UpdateDamagePhysical().

◆ GetLoadPetInfo()

std::pair< PetStable::PetInfo const *, PetSaveMode > Pet::GetLoadPetInfo ( PetStable const &  stable,
uint32  petEntry,
uint32  petnumber,
bool  current 
)
static
163{
164 if (petnumber)
165 {
166 // Known petnumber entry
167 if (stable.CurrentPet && stable.CurrentPet->PetNumber == petnumber)
168 return { &stable.CurrentPet.value(), PET_SAVE_AS_CURRENT };
169
170 for (std::size_t stableSlot = 0; stableSlot < stable.StabledPets.size(); ++stableSlot)
171 if (stable.StabledPets[stableSlot] && stable.StabledPets[stableSlot]->PetNumber == petnumber)
172 return { &stable.StabledPets[stableSlot].value(), PetSaveMode(PET_SAVE_FIRST_STABLE_SLOT + stableSlot) };
173
174 for (PetStable::PetInfo const& pet : stable.UnslottedPets)
175 if (pet.PetNumber == petnumber)
176 return { &pet, PET_SAVE_NOT_IN_SLOT };
177 }
178 else if (current)
179 {
180 // Current pet (slot 0)
181 if (stable.CurrentPet)
182 return { &stable.CurrentPet.value(), PET_SAVE_AS_CURRENT };
183 }
184 else if (petEntry)
185 {
186 // known petEntry entry (unique for summoned pet, but non unique for hunter pet (only from current or not stabled pets)
187 if (stable.CurrentPet && stable.CurrentPet->CreatureId == petEntry)
188 return { &stable.CurrentPet.value(), PET_SAVE_AS_CURRENT };
189
190 for (PetStable::PetInfo const& pet : stable.UnslottedPets)
191 if (pet.CreatureId == petEntry)
192 return { &pet, PET_SAVE_NOT_IN_SLOT };
193 }
194 else
195 {
196 // Any current or other non-stabled pet (for hunter "call pet")
197 if (stable.CurrentPet)
198 return { &stable.CurrentPet.value(), PET_SAVE_AS_CURRENT };
199
200 if (!stable.UnslottedPets.empty())
201 return { &stable.UnslottedPets.front(), PET_SAVE_NOT_IN_SLOT };
202 }
203
204 return { nullptr, PET_SAVE_AS_DELETED };
205}
PetSaveMode
Definition: PetDefines.h:40
@ PET_SAVE_FIRST_STABLE_SLOT
Definition: PetDefines.h:43
@ PET_SAVE_AS_DELETED
Definition: PetDefines.h:41
@ PET_SAVE_NOT_IN_SLOT
Definition: PetDefines.h:45
@ PET_SAVE_AS_CURRENT
Definition: PetDefines.h:42
Definition: PetDefines.h:200

References PetStable::PetInfo::CreatureId, PetStable::CurrentPet, PET_SAVE_AS_CURRENT, PET_SAVE_AS_DELETED, PET_SAVE_FIRST_STABLE_SLOT, PET_SAVE_NOT_IN_SLOT, PetStable::PetInfo::PetNumber, PetStable::StabledPets, and PetStable::UnslottedPets.

Referenced by Spell::CheckCast(), and LoadPetFromDB().

◆ GetMaxTalentPointsForLevel()

uint8 Pet::GetMaxTalentPointsForLevel ( uint8  level)
2185{
2186 uint8 points = (level >= 20) ? ((level - 16) / 4) : 0;
2187 // Mod points from owner SPELL_AURA_MOD_PET_TALENT_POINTS
2188 if (Unit* owner = GetOwner())
2189 points += owner->GetTotalAuraModifier(SPELL_AURA_MOD_PET_TALENT_POINTS);
2190
2191 sScriptMgr->OnCalculateMaxTalentPointsForLevel(this, level, points);
2192
2193 return points;
2194}
@ SPELL_AURA_MOD_PET_TALENT_POINTS
Definition: SpellAuraDefines.h:208

References GetOwner(), SPELL_AURA_MOD_PET_TALENT_POINTS, and sScriptMgr.

Referenced by addSpell(), InitTalentForLevel(), removeSpell(), and resetTalents().

◆ GetNativeObjectScale()

float Pet::GetNativeObjectScale ( ) const
overridevirtual

Reimplemented from Creature.

2442{
2443 CreatureFamilyEntry const* creatureFamily = sCreatureFamilyStore.LookupEntry(GetCreatureTemplate()->family);
2444 if (creatureFamily && creatureFamily->minScale > 0.0f && getPetType() == HUNTER_PET)
2445 {
2446 float scale;
2447 if (GetLevel() >= creatureFamily->maxScaleLevel)
2448 scale = creatureFamily->maxScale;
2449 else if (GetLevel() <= creatureFamily->minScaleLevel)
2450 scale = creatureFamily->minScale;
2451 else
2452 scale = creatureFamily->minScale + float(GetLevel() - creatureFamily->minScaleLevel) / creatureFamily->maxScaleLevel * (creatureFamily->maxScale - creatureFamily->minScale);
2453
2454 if (CreatureDisplayInfoEntry const* displayInfo = sCreatureDisplayInfoStore.LookupEntry(GetNativeDisplayId()))
2455 if (displayInfo->scale > 1.f && GetCreatureTemplate()->IsExotic())
2456 scale *= displayInfo->scale;
2457
2458 return scale;
2459 }
2460
2462}
DBCStorage< CreatureDisplayInfoEntry > sCreatureDisplayInfoStore(CreatureDisplayInfofmt)
float GetNativeObjectScale() const override
Definition: Creature.cpp:3381
bool IsExotic() const
Definition: CreatureData.h:258
Definition: DBCStructure.h:721
float maxScale
Definition: DBCStructure.h:758
float minScale
Definition: DBCStructure.h:756
uint32 minScaleLevel
Definition: DBCStructure.h:757
uint32 maxScaleLevel
Definition: DBCStructure.h:759

References Creature::GetCreatureTemplate(), Unit::GetLevel(), Unit::GetNativeDisplayId(), Creature::GetNativeObjectScale(), getPetType(), HUNTER_PET, CreatureTemplate::IsExotic(), CreatureFamilyEntry::maxScale, CreatureFamilyEntry::maxScaleLevel, CreatureFamilyEntry::minScale, CreatureFamilyEntry::minScaleLevel, sCreatureDisplayInfoStore, and sCreatureFamilyStore.

◆ GetOwner()

◆ GetPetAutoSpellOnPos()

uint32 Pet::GetPetAutoSpellOnPos ( uint8  pos) const
inlineoverridevirtual

Reimplemented from Creature.

75 {
76 if (pos >= m_autospells.size())
77 return 0;
78 else
79 return m_autospells[pos];
80 }
AutoSpellList m_autospells
Definition: Pet.h:121

References m_autospells.

◆ GetPetAutoSpellSize()

uint8 Pet::GetPetAutoSpellSize ( ) const
inlineoverridevirtual

Reimplemented from Creature.

73{ return m_autospells.size(); }

References m_autospells.

◆ getPetType()

◆ GivePetLevel()

void Pet::GivePetLevel ( uint8  level)
917{
918 if (!level || level == GetLevel())
919 return;
920
921 if (getPetType() == HUNTER_PET)
922 {
925 }
926
927 InitStatsForLevel(level);
930}
bool InitStatsForLevel(uint8 level)
Definition: Pet.cpp:1009
void InitTalentForLevel()
Definition: Pet.cpp:2165
void InitLevelupSpellsForLevel()
Definition: Pet.cpp:1891

References Unit::GetLevel(), getPetType(), HUNTER_PET, InitLevelupSpellsForLevel(), Guardian::InitStatsForLevel(), InitTalentForLevel(), RATE_XP_PET_NEXT_LEVEL, Object::SetUInt32Value(), sObjectMgr, sWorld, UNIT_FIELD_PETEXPERIENCE, and UNIT_FIELD_PETNEXTLEVELEXP.

Referenced by GivePetXP(), and SynchronizeLevelWithOwner().

◆ GivePetXP()

void Pet::GivePetXP ( uint32  xp)
878{
879 if (getPetType() != HUNTER_PET)
880 return;
881
882 xp *= sWorld->getRate(RATE_XP_PET);
883
884 if (xp < 1)
885 return;
886
887 if (!IsAlive())
888 return;
889
890 uint8 maxlevel = std::min((uint8)sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL), GetOwner()->GetLevel());
891 uint8 petlevel = GetLevel();
892
893 // If pet is detected to be at, or above(?) the players level, don't hand out XP
894 if (petlevel >= maxlevel)
895 return;
896
899 uint32 newXP = curXP + xp;
900
901 // Check how much XP the pet should receive, and hand off have any left from previous levelups
902 while (newXP >= nextLvlXP && petlevel < maxlevel)
903 {
904 // Subtract newXP from amount needed for nextlevel, and give pet the level
905 newXP -= nextLvlXP;
906 ++petlevel;
907
908 GivePetLevel(petlevel);
909
911 }
912 // Not affected by special conditions - give it new XP
913 SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, petlevel < maxlevel ? newXP : 0);
914}
@ CONFIG_MAX_PLAYER_LEVEL
Definition: IWorld.h:234
@ RATE_XP_PET
Definition: IWorld.h:468
void GivePetLevel(uint8 level)
Definition: Pet.cpp:916
bool IsAlive() const
Definition: Unit.h:1808

References CONFIG_MAX_PLAYER_LEVEL, Unit::GetLevel(), GetOwner(), getPetType(), Object::GetUInt32Value(), GivePetLevel(), HUNTER_PET, Unit::IsAlive(), RATE_XP_PET, Object::SetUInt32Value(), sWorld, UNIT_FIELD_PETEXPERIENCE, and UNIT_FIELD_PETNEXTLEVELEXP.

◆ HasSpell()

bool Pet::HasSpell ( uint32  spell) const
overridevirtual

Reimplemented from Creature.

2284{
2285 PetSpellMap::const_iterator itr = m_spells.find(spell);
2286 return itr != m_spells.end() && itr->second.state != PETSPELL_REMOVED;
2287}

References m_spells, and PETSPELL_REMOVED.

Referenced by addSpell(), Player::BuildPetTalentsInfoData(), CleanupActionBar(), pet_commandscript::HandlePetLearnCommand(), pet_commandscript::HandlePetUnlearnCommand(), and Player::LearnPetTalent().

◆ HasTempSpell()

bool Pet::HasTempSpell ( ) const
inline
146{ return m_tempspell != 0; }

References m_tempspell.

Referenced by PetAI::UpdateAI().

◆ HaveInDiet()

bool Pet::HaveInDiet ( ItemTemplate const *  item) const
1402{
1403 if (!item->FoodType)
1404 return false;
1405
1406 CreatureTemplate const* cInfo = GetCreatureTemplate();
1407 if (!cInfo)
1408 return false;
1409
1410 CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cInfo->family);
1411 if (!cFamily)
1412 return false;
1413
1414 uint32 diet = cFamily->petFoodMask;
1415 uint32 FoodMask = 1 << (item->FoodType - 1);
1416 return diet & FoodMask;
1417}
uint32 petFoodMask
Definition: DBCStructure.h:761

References CreatureTemplate::family, ItemTemplate::FoodType, Creature::GetCreatureTemplate(), CreatureFamilyEntry::petFoodMask, and sCreatureFamilyStore.

Referenced by Spell::CheckCast().

◆ InitLevelupSpellsForLevel()

void Pet::InitLevelupSpellsForLevel ( )
1892{
1893 uint8 level = GetLevel();
1894
1895 if (PetLevelupSpellSet const* levelupSpells = GetCreatureTemplate()->family ? sSpellMgr->GetPetLevelupSpellList(GetCreatureTemplate()->family) : nullptr)
1896 {
1897 // PetLevelupSpellSet ordered by levels, process in reversed order
1898 for (PetLevelupSpellSet::const_reverse_iterator itr = levelupSpells->rbegin(); itr != levelupSpells->rend(); ++itr)
1899 {
1900 // will called first if level down
1901 if (itr->first > level && sScriptMgr->CanUnlearnSpellSet(this, itr->first, itr->second))
1902 unlearnSpell(itr->second, true); // will learn prev rank if any
1903 // will called if level up
1904 else
1905 learnSpell(itr->second); // will unlearn prev rank if any
1906 }
1907 }
1908
1910
1911 // default spells (can be not learned if pet level (as owner level decrease result for example) less first possible in normal game)
1912 if (PetDefaultSpellsEntry const* defSpells = sSpellMgr->GetPetDefaultSpellsEntry(petSpellsId))
1913 {
1914 for (uint32 spellId : defSpells->spellid)
1915 {
1916 SpellInfo const* spellEntry = sSpellMgr->GetSpellInfo(spellId);
1917 if (!spellEntry)
1918 continue;
1919
1920 // will called first if level down
1921 if (spellEntry->SpellLevel > level && sScriptMgr->CanUnlearnSpellDefault(this, spellEntry))
1922 unlearnSpell(spellEntry->Id, true);
1923 // will called if level up
1924 else
1925 learnSpell(spellEntry->Id);
1926 }
1927 }
1928}
std::multimap< uint32, uint32 > PetLevelupSpellSet
Definition: SpellMgr.h:579
uint32 PetSpellDataId
Definition: CreatureData.h:222
bool learnSpell(uint32 spell_id)
Definition: Pet.cpp:1874
uint32 SpellLevel
Definition: SpellInfo.h:358
uint32 Id
Definition: SpellInfo.h:318
Definition: SpellMgr.h:585

References Creature::GetCreatureTemplate(), Object::GetEntry(), Unit::GetLevel(), SpellInfo::Id, learnSpell(), CreatureTemplate::PetSpellDataId, SpellInfo::SpellLevel, sScriptMgr, sSpellMgr, and unlearnSpell().

Referenced by GivePetLevel(), and InitPetCreateSpells().

◆ InitPetCreateSpells()

void Pet::InitPetCreateSpells ( )
2012{
2014 m_spells.clear();
2015
2018
2019 CastPetAuras(false);
2020}
void LearnPetPassives()
Definition: Pet.cpp:2290
void CastPetAuras(bool current)
Definition: Pet.cpp:2311
void InitPetActionBar()
Definition: Unit.cpp:15747

References CastPetAuras(), InitLevelupSpellsForLevel(), CharmInfo::InitPetActionBar(), LearnPetPassives(), Unit::m_charmInfo, and m_spells.

Referenced by Unit::InitTamedPet(), and Player::SummonPet().

◆ InitTalentForLevel()

void Pet::InitTalentForLevel ( )
2166{
2167 uint8 level = GetLevel();
2168 uint32 talentPointsForLevel = GetMaxTalentPointsForLevel(level);
2169
2170 Unit* owner = GetOwner();
2171 if (!owner || owner->GetTypeId() != TYPEID_PLAYER)
2172 return;
2173
2174 // Reset talents in case low level (on level down) or wrong points for level (hunter can unlearn TP increase talent)
2175 if (talentPointsForLevel == 0 || m_usedTalentCount > talentPointsForLevel)
2176 resetTalents(); // Remove all talent points
2177
2178 SetFreeTalentPoints(talentPointsForLevel - m_usedTalentCount);
2179
2180 if (!m_loading)
2181 owner->ToPlayer()->SendTalentsInfoData(true);
2182}
bool resetTalents()
Definition: Pet.cpp:2022
void SendTalentsInfoData(bool pet)
Definition: Player.cpp:14305

References Unit::GetLevel(), GetMaxTalentPointsForLevel(), GetOwner(), Object::GetTypeId(), m_loading, m_usedTalentCount, resetTalents(), Player::SendTalentsInfoData(), SetFreeTalentPoints(), Object::ToPlayer(), and TYPEID_PLAYER.

Referenced by Player::CreatePet(), Spell::EffectCreateTamedPet(), Spell::EffectTameCreature(), GivePetLevel(), and Player::SummonPet().

◆ isBeingLoaded()

bool Pet::isBeingLoaded ( ) const
inlineoverridevirtual

Reimplemented from Unit.

64{ return m_loading; }

References m_loading.

◆ isControlled()

bool Pet::isControlled ( ) const
inline

◆ IsPermanentPetFor()

bool Pet::IsPermanentPetFor ( Player owner) const
2239{
2240 switch (getPetType())
2241 {
2242 case SUMMON_PET:
2243 switch (owner->getClass())
2244 {
2245 case CLASS_WARLOCK:
2247 case CLASS_DEATH_KNIGHT:
2249 case CLASS_MAGE:
2250 return GetEntry() == 37994;
2251 default:
2252 return false;
2253 }
2254 case HUNTER_PET:
2255 return true;
2256 default:
2257 return false;
2258 }
2259}
@ CREATURE_TYPE_UNDEAD
Definition: SharedDefines.h:2605
@ CREATURE_TYPE_DEMON
Definition: SharedDefines.h:2602
@ CLASS_WARLOCK
Definition: SharedDefines.h:121
@ CLASS_MAGE
Definition: SharedDefines.h:120
@ CLASS_DEATH_KNIGHT
Definition: SharedDefines.h:118
uint32 type
Definition: CreatureData.h:215
uint8 getClass() const
Definition: Unit.h:1426

References CLASS_DEATH_KNIGHT, CLASS_MAGE, CLASS_WARLOCK, CREATURE_TYPE_DEMON, CREATURE_TYPE_UNDEAD, Unit::getClass(), Creature::GetCreatureTemplate(), Object::GetEntry(), getPetType(), HUNTER_PET, SUMMON_PET, and CreatureTemplate::type.

Referenced by CastPetAuras(), reset_commandscript::HandleResetTalentsCommand(), LoadPetFromDB(), and Player::PetSpellInitialize().

◆ isTemporarySummoned()

bool Pet::isTemporarySummoned ( ) const
inline
54{ return m_duration > 0s; }

References m_duration.

Referenced by LoadPetFromDB(), and Player::UnsummonPetTemporaryIfAny().

◆ LearnPetPassives()

void Pet::LearnPetPassives ( )
2291{
2292 CreatureTemplate const* cInfo = GetCreatureTemplate();
2293 if (!cInfo)
2294 return;
2295
2296 CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cInfo->family);
2297 if (!cFamily)
2298 return;
2299
2300 PetFamilySpellsStore::const_iterator petStore = sPetFamilySpellsStore.find(cFamily->ID);
2301 if (petStore != sPetFamilySpellsStore.end())
2302 {
2303 // For general hunter pets skill 270
2304 // Passive 01~10, Passive 00 (20782, not used), Ferocious Inspiration (34457)
2305 // Scale 01~03 (34902~34904, bonus from owner, not used)
2306 for (uint32 spellId : petStore->second)
2308 }
2309}
PetFamilySpellsStore sPetFamilySpellsStore
Definition: DBCStores.cpp:151
uint32 ID
Definition: DBCStructure.h:755

References ACT_DECIDE, addSpell(), CreatureTemplate::family, Creature::GetCreatureTemplate(), CreatureFamilyEntry::ID, PETSPELL_FAMILY, PETSPELL_NEW, sCreatureFamilyStore, and sPetFamilySpellsStore.

Referenced by InitPetCreateSpells().

◆ learnSpell()

bool Pet::learnSpell ( uint32  spell_id)
1875{
1876 // prevent duplicated entires in spell book
1877 if (!addSpell(spell_id))
1878 return false;
1879
1880 if (!m_loading)
1881 {
1883 packet.SpellID = spell_id;
1884 m_owner->SendDirectMessage(packet.Write());
1886 }
1887
1888 return true;
1889}
void SendDirectMessage(WorldPacket const *data) const
Definition: Player.cpp:5594
void PetSpellInitialize()
Definition: Player.cpp:9366
Definition: PetPackets.h:71
uint32 SpellID
Definition: PetPackets.h:77
WorldPacket const * Write() override
Definition: PetPackets.cpp:42

References addSpell(), m_loading, m_owner, Player::PetSpellInitialize(), Player::SendDirectMessage(), WorldPackets::Pet::PetLearnedSpell::SpellID, and WorldPackets::Pet::PetLearnedSpell::Write().

Referenced by Spell::EffectLearnPetSpell(), pet_commandscript::HandlePetLearnCommand(), InitLevelupSpellsForLevel(), Player::LearnPetTalent(), learnSpellHighRank(), and removeSpell().

◆ learnSpellHighRank()

void Pet::learnSpellHighRank ( uint32  spellid)
2333{
2334 learnSpell(spellid);
2335
2336 if (uint32 next = sSpellMgr->GetNextSpellInChain(spellid))
2337 learnSpellHighRank(next);
2338}
void learnSpellHighRank(uint32 spellid)
Definition: Pet.cpp:2332

References learnSpell(), learnSpellHighRank(), and sSpellMgr.

Referenced by learn_commandscript::HandleLearnAllMyPetTalentsCommand(), and learnSpellHighRank().

◆ LoadPetFromDB()

bool Pet::LoadPetFromDB ( Player owner,
uint32  petEntry,
uint32  petnumber,
bool  current,
uint32  healthPct = 0 
)
Todo:
pets should be summoned from real cast instead of just faking it?
208{
209 m_loading = true;
210
211 PetStable* petStable = ASSERT_NOTNULL(owner->GetPetStable());
212
213 ObjectGuid::LowType ownerid = owner->GetGUID().GetCounter();
214 std::pair<PetStable::PetInfo const*, PetSaveMode> info = GetLoadPetInfo(*petStable, petEntry, petnumber, current);
215 PetStable::PetInfo const* petInfo = info.first;
216 PetSaveMode slot = info.second;
217 if (!petInfo)
218 {
219 m_loading = false;
220 return false;
221 }
222
223 // Don't try to reload the current pet
224 if (petStable->CurrentPet && owner->GetPet() && petStable->CurrentPet.value().PetNumber == petInfo->PetNumber)
225 return false;
226
227 // we are loading pet at that moment
228 if (owner->IsSpectator() || owner->GetPet() || !owner->IsInWorld() || !owner->FindMap())
229 return false;
230
231 bool forceLoadFromDB = false;
232 sScriptMgr->OnBeforeLoadPetFromDB(owner, petEntry, petnumber, current, forceLoadFromDB);
233
234 if (!forceLoadFromDB && (owner->getClass() == CLASS_DEATH_KNIGHT && !owner->CanSeeDKPet())) // DK Pet exception
235 return false;
236
237 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(petInfo->CreatedBySpellId);
238
239 bool isTemporarySummon = spellInfo && spellInfo->GetDuration() > 0;
240 if (current && isTemporarySummon)
241 return false;
242
243 if (petInfo->Type == HUNTER_PET)
244 {
245 CreatureTemplate const* creatureInfo = sObjectMgr->GetCreatureTemplate(petInfo->CreatureId);
246 if (!creatureInfo || !creatureInfo->IsTameable(owner->CanTameExoticPets()))
247 return false;
248 }
249
250 if (current && owner->IsPetNeedBeTemporaryUnsummoned())
251 {
253 return false;
254 }
255
256 Map* map = owner->GetMap();
257 ObjectGuid::LowType guid = map->GenerateLowGuid<HighGuid::Pet>();
258
259 if (!Create(guid, map, owner->GetPhaseMask(), petInfo->CreatureId, petInfo->PetNumber))
260 return false;
261
262 setPetType(petInfo->Type);
263 SetFaction(owner->GetFaction());
265
266 if (IsCritter())
267 {
268 float px, py, pz;
270 Relocate(px, py, pz, owner->GetOrientation());
271
272 if (!IsPositionValid())
273 {
274 LOG_ERROR("entities.pet", "Pet{} not loaded. Suggested coordinates isn't valid (X: {} Y: {})",
276 return false;
277 }
278
280 map->AddToMap(ToCreature(), true);
281 return true;
282 }
283
285 GetCharmInfo()->SetPetNumber(petInfo->PetNumber, IsPermanentPetFor(owner)); // Show pet details tab (Shift+P) only for hunter pets, demons or undead
286 else
287 GetCharmInfo()->SetPetNumber(petInfo->PetNumber, false);
288
289 SetDisplayId(petInfo->DisplayId);
292 uint8 petlevel = petInfo->Level;
294 SetName(petInfo->Name);
295
296 switch (getPetType())
297 {
298 case SUMMON_PET:
299 petlevel = owner->GetLevel();
300
301 if (IsPetGhoul())
302 SetUInt32Value(UNIT_FIELD_BYTES_0, 0x400); // class = rogue
303 else
304 SetUInt32Value(UNIT_FIELD_BYTES_0, 0x800); // class = mage
305
306 ReplaceAllUnitFlags(UNIT_FLAG_PLAYER_CONTROLLED); // this enables popup window (pet dismiss, cancel)
307 break;
308 case HUNTER_PET:
309 SetUInt32Value(UNIT_FIELD_BYTES_0, 0x02020100); // class = warrior, gender = none, power = focus
312
314 // this enables popup window (pet abandon, cancel)
318 break;
319 default:
320 if (!IsPetGhoul())
321 LOG_ERROR("entities.pet", "Pet have incorrect type ({}) for pet loading.", getPetType());
322 break;
323 }
324
325 SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(GameTime::GetGameTime().count())); // cast can't be helped here
326 SetCreatorGUID(owner->GetGUID());
327
328 InitStatsForLevel(petlevel);
330
332
333 // Set pet's position after setting level, its size depends on it
334 float px, py, pz;
336 Relocate(px, py, pz, owner->GetOrientation());
337 if (!IsPositionValid())
338 {
339 LOG_ERROR("entities.pet", "Pet {} not loaded. Suggested coordinates isn't valid (X: {} Y: {})",
341 return false;
342 }
343
344 SetReactState(petInfo->ReactState);
345 SetCanModifyStats(true);
346
347 // set current pet as current
348 // 0=current
349 // 1..MAX_PET_STABLES in stable slot
350 // PET_SAVE_NOT_IN_SLOT(100) = not stable slot (summoning))
351 if (slot == PET_SAVE_NOT_IN_SLOT)
352 {
353 uint32 petInfoNumber = petInfo->PetNumber;
354 if (petStable->CurrentPet)
355 owner->RemovePet(nullptr, PET_SAVE_NOT_IN_SLOT);
356
357 auto unslottedPetItr = std::find_if(petStable->UnslottedPets.begin(), petStable->UnslottedPets.end(), [&](PetStable::PetInfo const& unslottedPet)
358 {
359 return unslottedPet.PetNumber == petInfoNumber;
360 });
361
362 ASSERT(!petStable->CurrentPet);
363 ASSERT(unslottedPetItr != petStable->UnslottedPets.end());
364
365 petStable->CurrentPet = std::move(*unslottedPetItr);
366 petStable->UnslottedPets.erase(unslottedPetItr);
367
368 // old petInfo pointer is no longer valid, refresh it
369 petInfo = &petStable->CurrentPet.value();
370 }
371 else if (PET_SAVE_FIRST_STABLE_SLOT <= slot && slot <= PET_SAVE_LAST_STABLE_SLOT)
372 {
373 auto stabledPet = std::find_if(petStable->StabledPets.begin(), petStable->StabledPets.end(), [petnumber](Optional<PetStable::PetInfo> const& pet)
374 {
375 return pet && pet->PetNumber == petnumber;
376 });
377
378 ASSERT(stabledPet != petStable->StabledPets.end());
379
380 std::swap(*stabledPet, petStable->CurrentPet);
381
382 // old petInfo pointer is no longer valid, refresh it
383 petInfo = &petStable->CurrentPet.value();
384 }
385
386 // Send fake summon spell cast - this is needed for correct cooldown application for spells
387 // Example: 46584 - without this cooldown (which should be set always when pet is loaded) isn't set clientside
389 if (petInfo->CreatedBySpellId)
390 {
391 WorldPacket data(SMSG_SPELL_GO, (8 + 8 + 4 + 4 + 2));
392 data << owner->GetPackGUID();
393 data << owner->GetPackGUID();
394 data << uint8(0);
395 data << uint32(petInfo->CreatedBySpellId);
396 data << uint32(256); // CAST_FLAG_UNKNOWN3
397 data << uint32(0);
398 owner->SendMessageToSet(&data, true);
399 }
400
401 owner->SetMinion(this, true);
402
403 if (!isTemporarySummon)
405
406 map->AddToMap(ToCreature(), true);
407
408 //set last used pet number (for use in BG's)
410 owner->ToPlayer()->SetLastPetNumber(petInfo->PetNumber);
411
412 owner->GetSession()->AddQueryHolderCallback(CharacterDatabase.DelayQueryHolder(std::make_shared<PetLoadQueryHolder>(ownerid, petInfo->PetNumber)))
413 .AfterComplete([this, owner, session = owner->GetSession(), isTemporarySummon, current, lastSaveTime = petInfo->LastSaveTime, savedhealth = petInfo->Health, savedmana = petInfo->Mana, healthPct]
414 (SQLQueryHolderBase const& holder)
415 {
416 if (session->GetPlayer() != owner || owner->GetPet() != this)
417 return;
418
419 // passing previous checks ensure that 'this' is still valid
420 if (m_removed)
421 return;
422
423 InitTalentForLevel(); // set original talents points before spell loading
424
425 uint32 timediff = uint32(GameTime::GetGameTime().count() - lastSaveTime);
426 _LoadAuras(holder.GetPreparedResult(PetLoadQueryHolder::AURAS), timediff);
427
428 // load action bar, if data broken will fill later by default spells.
429 if (!isTemporarySummon)
430 {
431 _LoadSpells(holder.GetPreparedResult(PetLoadQueryHolder::SPELLS));
432 InitTalentForLevel(); // re-init to check talent count
433 _LoadSpellCooldowns(holder.GetPreparedResult(PetLoadQueryHolder::COOLDOWNS));
434 LearnPetPassives();
435 InitLevelupSpellsForLevel();
436 if (GetMap()->IsBattleArena())
437 RemoveArenaAuras();
438
439 CastPetAuras(current);
440 }
441
442 CleanupActionBar(); // remove unknown spells from action bar after load
443
444 LOG_DEBUG("entities.pet", "New Pet has {}", GetGUID().ToString());
445
446 owner->PetSpellInitialize();
447 owner->SendTalentsInfoData(true);
448
449 if (owner->GetGroup())
451
452 if (getPetType() == HUNTER_PET)
453 {
455 {
456 m_declinedname = std::make_unique<DeclinedName>();
457 Field* fields = result->Fetch();
458 for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
459 m_declinedname->name[i] = fields[i].Get<std::string>();
460 }
461 }
462
463 uint32 curHealth = savedhealth;
464 if (healthPct)
465 {
466 curHealth = CountPctFromMaxHealth(healthPct);
467 }
468
469 if (getPetType() == SUMMON_PET && !current) //all (?) summon pets come with full health when called, but not when they are current
470 {
473 }
474 else
475 {
476 if (!curHealth && getPetType() == HUNTER_PET)
478 else
479 {
480 SetHealth(curHealth > GetMaxHealth() ? GetMaxHealth() : curHealth);
481 SetPower(POWER_MANA, savedmana > GetMaxPower(POWER_MANA) ? GetMaxPower(POWER_MANA) : savedmana);
482 }
483 }
484
485 // must be after SetMinion (owner guid check)
486 //LoadTemplateImmunities();
487 //LoadMechanicTemplateImmunity();
488 m_loading = false;
489 });
490
491 return true;
492}
#define ASSERT_NOTNULL(pointer)
Definition: Errors.h:85
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition: Optional.h:24
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: DatabaseEnvFwd.h:46
@ PET_SAVE_LAST_STABLE_SLOT
Definition: PetDefines.h:44
#define PET_FOLLOW_DIST
Definition: PetDefines.h:193
@ JUST_DIED
Definition: Unit.h:317
#define MAX_DECLINED_NAME_CASES
Definition: Unit.h:969
@ UNIT_FLAG_PLAYER_CONTROLLED
Definition: Unit.h:451
@ GROUP_UPDATE_PET
Definition: Group.h:119
@ SMSG_SPELL_GO
Definition: Opcodes.h:336
Definition: QueryHolder.h:25
PreparedQueryResult GetPreparedResult(size_t index) const
Definition: QueryHolder.cpp:37
void AfterComplete(std::function< void(SQLQueryHolderBase const &)> callback) &
Definition: QueryHolder.h:77
void SetReactState(ReactStates st)
Definition: Creature.h:89
bool IsTameable(bool exotic) const
Definition: CreatureData.h:263
float GetFollowAngle() const override
Definition: TemporarySummon.h:82
bool IsPetGhoul() const
Definition: TemporarySummon.h:84
PackedGuid const & GetPackGUID() const
Definition: Object.h:108
Creature * ToCreature()
Definition: Object.h:197
bool GetClosePoint(float &x, float &y, float &z, float size, float distance2d=0, float angle=0, WorldObject const *forWho=nullptr, bool force=false) const
Definition: Object.cpp:2662
LowType GetCounter() const
Definition: ObjectGuid.h:147
@ DECLINED_NAMES
Definition: Pet.cpp:129
void setDeathState(DeathState s, bool despawn=false) override
Definition: Pet.cpp:618
void setPetType(PetType type)
Definition: Pet.h:52
void SynchronizeLevelWithOwner()
Definition: Pet.cpp:2340
void CleanupActionBar()
Definition: Pet.cpp:1998
bool isTemporarySummoned() const
Definition: Pet.h:54
bool isControlled() const
Definition: Pet.h:53
static std::pair< PetStable::PetInfo const *, PetSaveMode > GetLoadPetInfo(PetStable const &stable, uint32 petEntry, uint32 petnumber, bool current)
Definition: Pet.cpp:162
Definition: PetDefines.h:197
std::array< Optional< PetInfo >, MAX_PET_STABLES > StabledPets
Definition: PetDefines.h:221
Optional< PetInfo > CurrentPet
Definition: PetDefines.h:220
std::vector< PetInfo > UnslottedPets
Definition: PetDefines.h:223
void SetGroupUpdateFlag(uint32 flag)
Definition: Player.h:2424
bool CanTameExoticPets() const
Definition: Player.h:2138
void SetTemporaryUnsummonedPetNumber(uint32 petnumber)
Definition: Player.h:2364
bool IsPetNeedBeTemporaryUnsummoned() const
Definition: Player.h:2367
PetStable * GetPetStable()
Definition: Player.h:1178
bool CanSeeDKPet() const
Definition: Player.h:2543
Pet * GetPet() const
Definition: Player.cpp:8784
void RemovePet(Pet *pet, PetSaveMode mode, bool returnreagent=false)
Definition: Player.cpp:8935
Group * GetGroup()
Definition: Player.h:2418
bool IsSpectator() const
Definition: Player.h:2523
void SendMessageToSet(WorldPacket const *data, bool self) const override
Definition: Player.h:1976
void SetLastPetNumber(uint32 petnumber)
Definition: Player.h:2408
void LoadPetActionBar(const std::string &data)
Definition: Unit.cpp:15949
void SetPetNumber(uint32 petnumber, bool statwindow)
Definition: Unit.cpp:15940
void SetMinion(Minion *minion, bool apply)
Definition: Unit.cpp:10640
void SetFullHealth()
Definition: Unit.h:1455
void SetFaction(uint32 faction)
Definition: Unit.cpp:10029
void ReplaceAllUnitFlags(UnitFlags flags)
Definition: Unit.h:1483
uint32 GetMaxHealth() const
Definition: Unit.h:1441
float GetCombatReach() const override
Definition: Unit.h:1347
void SetHealth(uint32 val)
Definition: Unit.cpp:15370
uint32 GetFaction() const
Definition: Unit.h:1495
uint32 GetMaxPower(Powers power) const
Definition: Unit.h:1462
void SetNativeDisplayId(uint32 modelId)
Definition: Unit.h:2172
bool IsCritter() const
Definition: Unit.h:1674
void SetCanModifyStats(bool modifyStats)
Definition: Unit.h:2106
uint32 CountPctFromMaxHealth(int32 pct) const
Definition: Unit.h:1449
void SetCreatorGUID(ObjectGuid creator)
Definition: Unit.h:1817
Definition: Map.h:312
bool AddToMap(T *, bool checkTransport=false)
Definition: Map.cpp:557
SQLQueryHolderCallback & AddQueryHolderCallback(SQLQueryHolderCallback &&callback)
Definition: WorldSession.cpp:1310
int32 GetDuration() const
Definition: SpellInfo.cpp:2321

References PetStable::PetInfo::ActionBar, WorldSession::AddQueryHolderCallback(), Map::AddToMap(), SQLQueryHolderCallback::AfterComplete(), ASSERT, ASSERT_NOTNULL, Player::CanSeeDKPet(), Player::CanTameExoticPets(), CharacterDatabase, CLASS_DEATH_KNIGHT, CleanupActionBar(), Unit::CountPctFromMaxHealth(), Create(), PetStable::PetInfo::CreatedBySpellId, CREATURE_TYPE_DEMON, CREATURE_TYPE_UNDEAD, PetStable::PetInfo::CreatureId, PetStable::CurrentPet, PetLoadQueryHolder::DECLINED_NAMES, PetStable::PetInfo::DisplayId, PetStable::PetInfo::Experience, WorldObject::FindMap(), Map::GenerateLowGuid(), Field::Get(), Unit::GetCharmInfo(), Unit::getClass(), WorldObject::GetClosePoint(), Unit::GetCombatReach(), ObjectGuid::GetCounter(), Unit::GetCreatePowers(), Creature::GetCreatureTemplate(), SpellInfo::GetDuration(), Unit::GetFaction(), Minion::GetFollowAngle(), GameTime::GetGameTime(), Player::GetGroup(), Object::GetGUID(), Unit::GetLevel(), GetLoadPetInfo(), WorldObject::GetMap(), Unit::GetMaxHealth(), Unit::GetMaxPower(), Position::GetOrientation(), Object::GetPackGUID(), Player::GetPet(), Player::GetPetStable(), getPetType(), WorldObject::GetPhaseMask(), Position::GetPositionX(), Position::GetPositionY(), SQLQueryHolderBase::GetPreparedResult(), Player::GetSession(), Object::GetTypeId(), GROUP_UPDATE_PET, PetStable::PetInfo::Happiness, PetStable::PetInfo::Health, HUNTER_PET, Guardian::InitStatsForLevel(), isControlled(), Unit::IsCritter(), Object::IsInWorld(), IsPermanentPetFor(), Minion::IsPetGhoul(), Player::IsPetNeedBeTemporaryUnsummoned(), Position::IsPositionValid(), Player::IsSpectator(), CreatureTemplate::IsTameable(), isTemporarySummoned(), JUST_DIED, PetStable::PetInfo::LastSaveTime, PetStable::PetInfo::Level, CharmInfo::LoadPetActionBar(), LOG_DEBUG, LOG_ERROR, Unit::m_charmInfo, m_declinedname, m_loading, PetStable::PetInfo::Mana, MAX_DECLINED_NAME_CASES, PetStable::PetInfo::Name, PET_FOLLOW_DIST, PET_SAVE_FIRST_STABLE_SLOT, PET_SAVE_LAST_STABLE_SLOT, PET_SAVE_NOT_IN_SLOT, PetStable::PetInfo::PetNumber, Player::PetSpellInitialize(), POWER_FOCUS, POWER_HAPPINESS, POWER_MANA, PetStable::PetInfo::ReactState, Position::Relocate(), Player::RemovePet(), Unit::ReplaceAllNpcFlags(), Unit::ReplaceAllUnitFlags(), Player::SendMessageToSet(), Player::SendTalentsInfoData(), Object::SetByteFlag(), Unit::SetCanModifyStats(), Unit::SetCreatorGUID(), setDeathState(), SetDisplayId(), Unit::SetFaction(), Unit::SetFullHealth(), Player::SetGroupUpdateFlag(), Unit::SetHealth(), Player::SetLastPetNumber(), Unit::SetMaxPower(), Unit::SetMinion(), WorldObject::SetName(), Unit::SetNativeDisplayId(), CharmInfo::SetPetNumber(), setPetType(), Unit::SetPower(), Unit::setPowerType(), Creature::SetReactState(), Unit::SetSheath(), Player::SetTemporaryUnsummonedPetNumber(), Object::SetUInt32Value(), SHEATH_STATE_MELEE, SMSG_SPELL_GO, sObjectMgr, sScriptMgr, sSpellMgr, PetStable::StabledPets, SUMMON_PET, SynchronizeLevelWithOwner(), Object::ToCreature(), Object::ToPlayer(), Position::ToString(), PetStable::PetInfo::Type, TYPEID_PLAYER, UNIT_CAN_BE_ABANDONED, UNIT_CAN_BE_RENAMED, UNIT_CREATED_BY_SPELL, UNIT_FIELD_BYTES_0, UNIT_FIELD_BYTES_2, UNIT_FIELD_PET_NAME_TIMESTAMP, UNIT_FIELD_PETEXPERIENCE, UNIT_FLAG_PLAYER_CONTROLLED, UNIT_NPC_FLAG_NONE, PetStable::UnslottedPets, WorldObject::UpdatePositionData(), and PetStable::PetInfo::WasRenamed.

Referenced by spell_gen_pet_summoned::HandleScript(), WorldSession::HandleStableSwapPet(), WorldSession::HandleUnstablePet(), Player::LoadPet(), Player::ResummonPetTemporaryUnSummonedIfAny(), and Player::SummonPet().

◆ LoseHappiness()

void Pet::LoseHappiness ( )
852{
853 uint32 curValue = GetPower(POWER_HAPPINESS);
854 if (curValue <= 0)
855 return;
856 int32 addvalue = 670; //value is 70/35/17/8/4 (per min) * 1000 / 8 (timer 7.5 secs)
857 if (IsInCombat()) //we know in combat happiness fades faster, multiplier guess
858 addvalue = int32(addvalue * 1.5f);
859 ModifyPower(POWER_HAPPINESS, -addvalue);
860}
int32 ModifyPower(Powers power, int32 val, bool withPowerUpdate=true)
Definition: Unit.cpp:14051
bool IsInCombat() const
Definition: Unit.h:1688

References Unit::GetPower(), Unit::IsInCombat(), Unit::ModifyPower(), and POWER_HAPPINESS.

Referenced by Update().

◆ Remove()

void Pet::Remove ( PetSaveMode  mode,
bool  returnreagent = false 
)
873{
874 GetOwner()->RemovePet(this, mode, returnreagent);
875}

References GetOwner(), and Player::RemovePet().

Referenced by Spell::EffectDismissPet(), AuraEffect::HandleModPossessPet(), TempSummon::UnSummon(), and Update().

◆ RemoveFromWorld()

void Pet::RemoveFromWorld ( )
overridevirtual
  • Remove the pet from the accessor
  • Don't call the function for Creature, normal mobs + totems go in a different storage

Reimplemented from Minion.

114{
116 if (IsInWorld())
117 {
121 }
122}
bool Remove(KEY_TYPE const &handle)
Definition: TypeContainer.h:141
void RemoveFromWorld() override
Definition: Unit.cpp:15588

References Object::GetGUID(), WorldObject::GetMap(), Map::GetObjectsStore(), Object::IsInWorld(), TypeUnorderedMapContainer< OBJECT_TYPES, KEY_TYPE >::Remove(), and Unit::RemoveFromWorld().

◆ removeSpell()

bool Pet::removeSpell ( uint32  spell_id,
bool  learn_prev,
bool  clear_ab = true 
)
1948{
1949 PetSpellMap::iterator itr = m_spells.find(spell_id);
1950 if (itr == m_spells.end())
1951 return false;
1952
1953 if (itr->second.state == PETSPELL_REMOVED)
1954 return false;
1955
1956 if (itr->second.state == PETSPELL_NEW)
1957 m_spells.erase(itr);
1958 else
1959 itr->second.state = PETSPELL_REMOVED;
1960
1961 RemoveAurasDueToSpell(spell_id);
1962
1963 uint32 talentCost = GetTalentSpellCost(spell_id);
1964 if (talentCost > 0)
1965 {
1966 if (m_usedTalentCount > talentCost)
1967 m_usedTalentCount -= talentCost;
1968 else
1970 // update free talent points
1972 SetFreeTalentPoints(free_points > 0 ? free_points : 0);
1973 }
1974
1975 if (learn_prev)
1976 {
1977 if (uint32 prev_id = sSpellMgr->GetPrevSpellInChain (spell_id))
1978 learnSpell(prev_id);
1979 else
1980 learn_prev = false;
1981 }
1982
1983 // if remove last rank or non-ranked then update action bar at server and client if need
1984 if (clear_ab && !learn_prev && m_charmInfo->RemoveSpellFromActionBar(spell_id))
1985 {
1986 if (!m_loading)
1987 {
1988 // need update action bar for last removed rank
1989 if (Unit* owner = GetOwner())
1990 if (owner->GetTypeId() == TYPEID_PLAYER)
1991 owner->ToPlayer()->PetSpellInitialize();
1992 }
1993 }
1994
1995 return true;
1996}
bool RemoveSpellFromActionBar(uint32 spell_id)
Definition: Unit.cpp:15911
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:4835

References Unit::GetLevel(), GetMaxTalentPointsForLevel(), GetOwner(), GetTalentSpellCost(), learnSpell(), Unit::m_charmInfo, m_loading, m_spells, m_usedTalentCount, PETSPELL_NEW, PETSPELL_REMOVED, Unit::RemoveAurasDueToSpell(), CharmInfo::RemoveSpellFromActionBar(), SetFreeTalentPoints(), sSpellMgr, and TYPEID_PLAYER.

Referenced by addSpell(), pet_commandscript::HandlePetUnlearnCommand(), and unlearnSpell().

◆ RemoveSpellCooldown()

void Pet::RemoveSpellCooldown ( uint32  spell_id,
bool  update 
)
2402{
2403 m_CreatureSpellCooldowns.erase(spell_id);
2404
2405 if (update)
2406 {
2407 if (Player* playerOwner = GetCharmerOrOwnerPlayerOrPlayerItself())
2408 {
2409 WorldPacket data(SMSG_CLEAR_COOLDOWN, 4 + 8);
2410 data << uint32(spell_id);
2411 data << GetGUID();
2412 playerOwner->SendDirectMessage(&data);
2413 }
2414 }
2415}
@ SMSG_CLEAR_COOLDOWN
Definition: Opcodes.h:508
Player * GetCharmerOrOwnerPlayerOrPlayerItself() const
Definition: Unit.cpp:10576

References Unit::GetCharmerOrOwnerPlayerOrPlayerItself(), Object::GetGUID(), Creature::m_CreatureSpellCooldowns, and SMSG_CLEAR_COOLDOWN.

Referenced by WorldSession::HandlePetActionHelper().

◆ ResetAuraUpdateMaskForRaid()

void Pet::ResetAuraUpdateMaskForRaid ( )
inline

References m_auraRaidUpdateMask.

◆ resetTalents()

bool Pet::resetTalents ( )
2023{
2024 Unit* owner = GetOwner();
2025 if (!owner || owner->GetTypeId() != TYPEID_PLAYER)
2026 return false;
2027
2028 if (!sScriptMgr->CanResetTalents(this))
2029 return false;
2030
2031 // not need after this call
2034
2036 if (!ci)
2037 return false;
2038 // Check pet talent type
2039 CreatureFamilyEntry const* pet_family = sCreatureFamilyStore.LookupEntry(ci->family);
2040 if (!pet_family || pet_family->petTalentType < 0)
2041 return false;
2042
2043 Player* player = owner->ToPlayer();
2044
2045 uint8 level = GetLevel();
2046 uint32 talentPointsForLevel = GetMaxTalentPointsForLevel(level);
2047
2048 if (m_usedTalentCount == 0)
2049 {
2050 SetFreeTalentPoints(talentPointsForLevel);
2051 return false;
2052 }
2053
2054 for (uint32 i = 0; i < sTalentStore.GetNumRows(); ++i)
2055 {
2056 TalentEntry const* talentInfo = sTalentStore.LookupEntry(i);
2057 if (!talentInfo)
2058 continue;
2059
2060 TalentTabEntry const* talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab);
2061 if (!talentTabInfo)
2062 continue;
2063
2064 // unlearn only talents for pets family talent type
2065 if (!((1 << pet_family->petTalentType) & talentTabInfo->petTalentMask))
2066 continue;
2067
2068 for (uint32 talentSpellId : talentInfo->RankID)
2069 {
2070 for (PetSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end();)
2071 {
2072 if (itr->second.state == PETSPELL_REMOVED)
2073 {
2074 ++itr;
2075 continue;
2076 }
2077 // remove learned spells (all ranks)
2078 uint32 itrFirstId = sSpellMgr->GetFirstSpellInChain(itr->first);
2079
2080 // unlearn if first rank is talent or learned by talent
2081 if (itrFirstId == talentSpellId)
2082 {
2083 unlearnSpell(itr->first, false);
2084 itr = m_spells.begin();
2085 continue;
2086 }
2087 else
2088 ++itr;
2089 }
2090 }
2091 }
2092
2093 SetFreeTalentPoints(talentPointsForLevel);
2094
2095 if (!m_loading)
2096 player->PetSpellInitialize();
2097 return true;
2098}
DBCStorage< TalentTabEntry > sTalentTabStore(TalentTabEntryfmt)
@ AT_LOGIN_RESET_PET_TALENTS
Definition: Player.h:605
void RemoveAtLoginFlag(AtLoginFlags flags, bool persist=false)
Definition: Player.cpp:14520
bool HasAtLoginFlag(AtLoginFlags f) const
Definition: Player.h:2352
int32 petTalentType
Definition: DBCStructure.h:762
std::array< uint32, MAX_TALENT_RANK > RankID
Definition: DBCStructure.h:1904
uint32 TalentTab
Definition: DBCStructure.h:1901
Definition: DBCStructure.h:1916
uint32 petTalentMask
Definition: DBCStructure.h:1923

References AT_LOGIN_RESET_PET_TALENTS, CreatureTemplate::family, Creature::GetCreatureTemplate(), Unit::GetLevel(), GetMaxTalentPointsForLevel(), GetOwner(), Object::GetTypeId(), Player::HasAtLoginFlag(), m_loading, m_spells, m_usedTalentCount, PETSPELL_REMOVED, Player::PetSpellInitialize(), TalentTabEntry::petTalentMask, CreatureFamilyEntry::petTalentType, TalentEntry::RankID, Player::RemoveAtLoginFlag(), sCreatureFamilyStore, SetFreeTalentPoints(), sScriptMgr, sSpellMgr, sTalentStore, sTalentTabStore, TalentEntry::TalentTab, Object::ToPlayer(), TYPEID_PLAYER, and unlearnSpell().

Referenced by reset_commandscript::HandleResetTalentsCommand(), InitTalentForLevel(), Player::ResetPetTalents(), and resetTalentsForAllPetsOf().

◆ resetTalentsForAllPetsOf()

void Pet::resetTalentsForAllPetsOf ( Player owner,
Pet online_pet = nullptr 
)
static
2101{
2102 // not need after this call
2105
2106 // reset for online
2107 if (onlinePet)
2108 onlinePet->resetTalents();
2109
2110 PetStable* petStable = owner->GetPetStable();
2111 if (!petStable)
2112 return;
2113
2114 std::unordered_set<uint32> petIds;
2115 if (petStable->CurrentPet)
2116 petIds.insert(petStable->CurrentPet->PetNumber);
2117
2118 for (Optional<PetStable::PetInfo> const& stabledPet : petStable->StabledPets)
2119 if (stabledPet)
2120 petIds.insert(stabledPet->PetNumber);
2121
2122 for (PetStable::PetInfo const& unslottedPet : petStable->UnslottedPets)
2123 petIds.insert(unslottedPet.PetNumber);
2124
2125 // now need only reset for offline pets (all pets except online case)
2126 if (onlinePet)
2127 petIds.erase(onlinePet->GetCharmInfo()->GetPetNumber());
2128
2129 // no offline pets
2130 if (!petIds.empty())
2131 return;
2132
2133 bool need_comma = false;
2134 std::ostringstream ss;
2135 ss << "DELETE FROM pet_spell WHERE guid IN (";
2136
2137 for (uint32 id : petIds)
2138 {
2139 if (need_comma)
2140 ss << ',';
2141
2142 ss << id;
2143
2144 need_comma = true;
2145 }
2146
2147 ss << ") AND spell IN (";
2148
2149 need_comma = false;
2150 for (uint32 spell : sPetTalentSpells)
2151 {
2152 if (need_comma)
2153 ss << ',';
2154
2155 ss << spell;
2156
2157 need_comma = true;
2158 }
2159
2160 ss << ')';
2161
2162 CharacterDatabase.Execute(ss.str().c_str());
2163}
std::unordered_set< uint32 > sPetTalentSpells
Definition: DBCStores.cpp:167

References AT_LOGIN_RESET_PET_TALENTS, CharacterDatabase, PetStable::CurrentPet, Unit::GetCharmInfo(), CharmInfo::GetPetNumber(), Player::GetPetStable(), Player::HasAtLoginFlag(), PetStable::PetInfo::PetNumber, Player::RemoveAtLoginFlag(), resetTalents(), sPetTalentSpells, PetStable::StabledPets, Object::ToPlayer(), and PetStable::UnslottedPets.

Referenced by WorldSession::HandlePlayerLoginFromDB(), and reset_commandscript::HandleResetTalentsCommand().

◆ SavePetToDB()

void Pet::SavePetToDB ( PetSaveMode  mode)
495{
496 // not save not player pets
497 if (!GetOwnerGUID().IsPlayer())
498 return;
499
500 // dont allow to save pet when it is loaded, possibly bugs action bar!, save only fully controlled creature
501 Player* owner = GetOwner()->ToPlayer();
502 if (!owner || m_loading || !GetEntry() || !isControlled())
503 return;
504
505 // not save pet as current if another pet temporary unsummoned
508 {
509 // pet will lost anyway at restore temporary unsummoned
510 if (getPetType() == HUNTER_PET)
511 return;
512
513 // for warlock case
515 }
516
517 uint32 curhealth = GetHealth();
518 uint32 curmana = GetPower(POWER_MANA);
519
520 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
521 // save auras before possibly removing them
522 _SaveAuras(trans);
523
524 // stable and not in slot saves
525 if (mode > PET_SAVE_AS_CURRENT)
527
528 _SaveSpells(trans);
529 _SaveSpellCooldowns(trans);
530 CharacterDatabase.CommitTransaction(trans);
531
532 // current/stable/not_in_slot
533 if (mode >= PET_SAVE_AS_CURRENT)
534 {
536 trans = CharacterDatabase.BeginTransaction();
537 // remove current data
538
540 stmt->SetData(0, m_charmInfo->GetPetNumber());
541 trans->Append(stmt);
542
543 // prevent existence another hunter pet in PET_SAVE_AS_CURRENT and PET_SAVE_NOT_IN_SLOT
545 {
546 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_PET_BY_SLOT);
547 stmt->SetData(0, ownerLowGUID);
550 trans->Append(stmt);
551 }
552
553 // save pet
554 std::string actionBar = GenerateActionBarData();
555
556 if (owner->GetPetStable()->CurrentPet && owner->GetPetStable()->CurrentPet->PetNumber == m_charmInfo->GetPetNumber())
557 {
558 FillPetInfo(&owner->GetPetStable()->CurrentPet.value());
559 }
560
561 stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CHAR_PET);
562 stmt->SetData(0, m_charmInfo->GetPetNumber());
563 stmt->SetData(1, GetEntry());
564 stmt->SetData(2, ownerLowGUID);
565 stmt->SetData(3, GetNativeDisplayId());
567 stmt->SetData(5, uint8(getPetType()));
568 stmt->SetData(6, GetLevel());
570 stmt->SetData(8, uint8(GetReactState()));
571 stmt->SetData(9, GetName());
573 stmt->SetData(11, uint8(mode));
574 stmt->SetData(12, curhealth);
575 stmt->SetData(13, curmana);
576 stmt->SetData(14, GetPower(POWER_HAPPINESS));
577 stmt->SetData(15, GameTime::GetGameTime().count());
578 stmt->SetData(16, actionBar);
579
580 trans->Append(stmt);
581 CharacterDatabase.CommitTransaction(trans);
582 }
583 // delete
584 else
585 {
588 }
589}
@ CHAR_DEL_CHAR_PET_BY_SLOT
Definition: CharacterDatabase.h:482
@ CHAR_REP_CHAR_PET
Definition: CharacterDatabase.h:483
void FillPetInfo(PetStable::PetInfo *petInfo) const
Definition: Pet.cpp:2417
void _SaveAuras(CharacterDatabaseTransaction trans)
Definition: Pet.cpp:1655
void _SaveSpellCooldowns(CharacterDatabaseTransaction trans)
Definition: Pet.cpp:1479
void _SaveSpells(CharacterDatabaseTransaction trans)
Definition: Pet.cpp:1526
void DeleteFromDB() override
Definition: Pet.h:170
uint32 GetTemporaryUnsummonedPetNumber() const
Definition: Player.h:2363
void RemoveAllAuras()
Definition: Unit.cpp:5239

References _SaveAuras(), _SaveSpellCooldowns(), _SaveSpells(), CHAR_DEL_CHAR_PET_BY_ID, CHAR_DEL_CHAR_PET_BY_SLOT, CHAR_REP_CHAR_PET, CharacterDatabase, PetStable::CurrentPet, DeleteFromDB(), FillPetInfo(), GenerateActionBarData(), ObjectGuid::GetCounter(), Object::GetEntry(), GameTime::GetGameTime(), Unit::GetHealth(), Unit::GetLevel(), WorldObject::GetName(), Unit::GetNativeDisplayId(), GetOwner(), Unit::GetOwnerGUID(), CharmInfo::GetPetNumber(), Player::GetPetStable(), getPetType(), Unit::GetPower(), Creature::GetReactState(), Player::GetTemporaryUnsummonedPetNumber(), Object::GetUInt32Value(), Object::HasByteFlag(), HUNTER_PET, isControlled(), Object::IsPlayer(), Unit::m_charmInfo, m_loading, PET_SAVE_AS_CURRENT, PET_SAVE_LAST_STABLE_SLOT, PET_SAVE_NOT_IN_SLOT, POWER_HAPPINESS, POWER_MANA, Unit::RemoveAllAuras(), PreparedStatementBase::SetData(), Object::ToPlayer(), UNIT_CAN_BE_RENAMED, UNIT_CREATED_BY_SPELL, UNIT_FIELD_BYTES_2, and UNIT_FIELD_PETEXPERIENCE.

Referenced by Player::CreatePet(), Spell::EffectCreateTamedPet(), Spell::EffectLearnPetSpell(), Spell::EffectResurrectPet(), Spell::EffectTameCreature(), Player::RemovePet(), and Player::SummonPet().

◆ SaveToDB()

void Pet::SaveToDB ( uint32  ,
uint8  ,
uint32   
)
inlineoverrideprivatevirtual

Reimplemented from TempSummon.

167 {
168 ABORT();
169 }

References ABORT.

◆ SetAuraUpdateMaskForRaid()

void Pet::SetAuraUpdateMaskForRaid ( uint8  slot)
inline
136{ m_auraRaidUpdateMask |= (uint64(1) << slot); }
std::uint64_t uint64
Definition: Define.h:107

References m_auraRaidUpdateMask.

Referenced by Unit::UpdateAuraForGroup().

◆ setDeathState()

void Pet::setDeathState ( DeathState  s,
bool  despawn = false 
)
overridevirtual

Reimplemented from Minion.

619{
621 if (getDeathState() == CORPSE)
622 {
623 if (getPetType() == HUNTER_PET)
624 {
625 // pet corpse non lootable and non skinnable
628
629 //lose happiness when died and not in BG/Arena
630 MapEntry const* mapEntry = sMapStore.LookupEntry(GetMapId());
631 if (!mapEntry || (mapEntry->map_type != MAP_ARENA && mapEntry->map_type != MAP_BATTLEGROUND))
633
634 //SetUnitFlag(UNIT_FLAG_STUNNED);
635 }
636 }
637 else if (getDeathState() == ALIVE)
638 {
639 //RemoveUnitFlag(UNIT_FLAG_STUNNED);
640 CastPetAuras(true);
641 }
642}
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
@ CORPSE
Definition: Unit.h:318
@ ALIVE
Definition: Unit.h:316
@ UNIT_FLAG_SKINNABLE
Definition: Unit.h:474
@ MAP_BATTLEGROUND
Definition: DBCEnums.h:354
@ MAP_ARENA
Definition: DBCEnums.h:355
@ UNIT_DYNFLAG_NONE
Definition: SharedDefines.h:3092
void setDeathState(DeathState s, bool despawn=false) override
Definition: Creature.cpp:1934
void ReplaceAllDynamicFlags(uint32 flag) override
Definition: Unit.h:1326
DeathState getDeathState()
Definition: Unit.h:1811
void RemoveUnitFlag(UnitFlags flags)
Definition: Unit.h:1482
Definition: DBCStructure.h:1308
uint32 map_type
Definition: DBCStructure.h:1311

References ALIVE, CastPetAuras(), CORPSE, Unit::getDeathState(), WorldLocation::GetMapId(), getPetType(), HAPPINESS_LEVEL_SIZE, HUNTER_PET, MAP_ARENA, MAP_BATTLEGROUND, MapEntry::map_type, Unit::ModifyPower(), POWER_HAPPINESS, Unit::RemoveUnitFlag(), Unit::ReplaceAllDynamicFlags(), Creature::setDeathState(), sMapStore, UNIT_DYNFLAG_NONE, and UNIT_FLAG_SKINNABLE.

Referenced by Spell::EffectResurrectPet(), and LoadPetFromDB().

◆ SetDisplayId()

void Pet::SetDisplayId ( uint32  modelId)
overridevirtual

Reimplemented from Creature.

2365{
2366 Guardian::SetDisplayId(modelId);
2367
2368 if (!isControlled())
2369 return;
2370
2371 if (Unit* owner = GetOwner())
2372 if (Player* player = owner->ToPlayer())
2373 if (player->GetGroup())
2374 player->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_MODEL_ID);
2375}
@ GROUP_UPDATE_FLAG_PET_MODEL_ID
Definition: Group.h:111
void SetDisplayId(uint32 modelId) override
Definition: Creature.cpp:3405

References GetOwner(), GROUP_UPDATE_FLAG_PET_MODEL_ID, isControlled(), Creature::SetDisplayId(), and Object::ToPlayer().

Referenced by CreateBaseAtCreature(), Spell::EffectResurrectPet(), and LoadPetFromDB().

◆ SetDuration()

void Pet::SetDuration ( Milliseconds  dur)
inline
89{ m_duration = dur; }

References m_duration.

Referenced by Player::SummonPet().

◆ SetFreeTalentPoints()

void Pet::SetFreeTalentPoints ( uint8  points)
inline

◆ SetLoading()

void Pet::SetLoading ( bool  load)
inline
144{ m_loading = load; }

References m_loading.

◆ setPetType()

void Pet::setPetType ( PetType  type)
inline
52{ m_petType = type; }

References m_petType.

Referenced by LoadPetFromDB().

◆ SynchronizeLevelWithOwner()

void Pet::SynchronizeLevelWithOwner ( )
2341{
2342 Unit* owner = GetOwner();
2343 if (!owner || owner->GetTypeId() != TYPEID_PLAYER)
2344 return;
2345
2346 switch (getPetType())
2347 {
2348 // always same level
2349 case SUMMON_PET:
2350 GivePetLevel(owner->GetLevel());
2351 break;
2352 // can't be greater owner level
2353 case HUNTER_PET:
2354 if (GetLevel() > owner->GetLevel())
2355 GivePetLevel(owner->GetLevel());
2356 else if (GetLevel() + 5 < owner->GetLevel())
2357 GivePetLevel(owner->GetLevel() - 5);
2358 break;
2359 default:
2360 break;
2361 }
2362}

References Unit::GetLevel(), GetOwner(), getPetType(), Object::GetTypeId(), GivePetLevel(), HUNTER_PET, SUMMON_PET, and TYPEID_PLAYER.

Referenced by LoadPetFromDB().

◆ ToggleAutocast()

void Pet::ToggleAutocast ( SpellInfo const *  spellInfo,
bool  apply 
)
2197{
2198 ASSERT(spellInfo);
2199
2200 if (!spellInfo->IsAutocastable())
2201 return;
2202
2203 PetSpellMap::iterator itr = m_spells.find(spellInfo->Id);
2204 if (itr == m_spells.end())
2205 return;
2206
2207 auto autospellItr = std::find(m_autospells.begin(), m_autospells.end(), spellInfo->Id);
2208
2209 if (apply)
2210 {
2211 if (autospellItr == m_autospells.end())
2212 {
2213 m_autospells.push_back(spellInfo->Id);
2214
2215 if (itr->second.active != ACT_ENABLED)
2216 {
2217 itr->second.active = ACT_ENABLED;
2218 if (itr->second.state != PETSPELL_NEW)
2219 itr->second.state = PETSPELL_CHANGED;
2220 }
2221 }
2222 }
2223 else
2224 {
2225 if (autospellItr != m_autospells.end())
2226 {
2227 m_autospells.erase(autospellItr);
2228 if (itr->second.active != ACT_DISABLED)
2229 {
2230 itr->second.active = ACT_DISABLED;
2231 if (itr->second.state != PETSPELL_NEW)
2232 itr->second.state = PETSPELL_CHANGED;
2233 }
2234 }
2235 }
2236}

References ACT_DISABLED, ACT_ENABLED, ASSERT, SpellInfo::Id, SpellInfo::IsAutocastable(), m_autospells, m_spells, PETSPELL_CHANGED, and PETSPELL_NEW.

Referenced by addSpell(), and CleanupActionBar().

◆ unlearnSpell()

bool Pet::unlearnSpell ( uint32  spell_id,
bool  learn_prev,
bool  clear_ab = true 
)
1931{
1932 if (removeSpell(spell_id, learn_prev, clear_ab))
1933 {
1934 if (!m_loading)
1935 {
1937 packet.SpellID = spell_id;
1938 m_owner->SendDirectMessage(packet.Write());
1939 }
1940
1941 return true;
1942 }
1943
1944 return false;
1945}
Definition: PetPackets.h:81
WorldPacket const * Write() override
Definition: PetPackets.cpp:48
uint32 SpellID
Definition: PetPackets.h:87

References m_loading, m_owner, removeSpell(), Player::SendDirectMessage(), WorldPackets::Pet::PetUnlearnedSpell::SpellID, and WorldPackets::Pet::PetUnlearnedSpell::Write().

Referenced by addSpell(), InitLevelupSpellsForLevel(), and resetTalents().

◆ Update()

void Pet::Update ( uint32  diff)
overridevirtual

Reimplemented from TempSummon.

645{
646 auto _diff = Milliseconds(diff);
647
648 if (m_removed) // pet already removed, just wait in remove queue, no updates
649 return;
650
651 if (m_loading)
652 return;
653
654 switch (m_deathState)
655 {
656 case CORPSE:
657 {
659 {
660 Remove(PET_SAVE_NOT_IN_SLOT); //hunters' pets never get removed because of death, NEVER!
661 return;
662 }
663 break;
664 }
665 case ALIVE:
666 {
667 // unsummon pet that lost owner
668 Player* owner = GetOwner();
669 if (!owner || (!IsWithinDistInMap(owner, GetMap()->GetVisibilityRange()) && !isPossessed()) || (isControlled() && !owner->GetPetGUID()))
670 //if (!owner || (!IsWithinDistInMap(owner, GetMap()->GetVisibilityDistance()) && (owner->GetCharmGUID() && (owner->GetCharmGUID() != GetGUID()))) || (isControlled() && !owner->GetPetGUID()))
671 {
673 return;
674 }
675
676 if (isControlled())
677 {
678 if (owner->GetPetGUID() != GetGUID())
679 {
680 LOG_ERROR("entities.pet", "Pet {} is not pet of owner {}, removed", GetEntry(), GetOwner()->GetName());
681 ASSERT(getPetType() != HUNTER_PET, "Unexpected unlinked pet found for owner {}", owner->GetSession()->GetPlayerInfo());
683 return;
684 }
685 }
686
687 if (m_duration > 0s)
688 {
689 if (m_duration > _diff)
690 m_duration -= _diff;
691 else
692 {
694 return;
695 }
696 }
697
698 // xinef: m_regenTimer is decrased in Creature::Update()
699 // xinef: just check if we can update focus in current period
700 if (getPowerType() == POWER_FOCUS)
701 {
702 m_petRegenTimer -= _diff;
703 if (m_petRegenTimer <= 0s)
704 {
707 }
708 }
709
710 if (m_tempspell)
711 {
712 Unit* tempspellTarget = m_tempspellTarget;
713 Unit* tempoldTarget = m_tempoldTarget;
714 bool tempspellIsPositive = m_tempspellIsPositive;
715 uint32 tempspell = m_tempspell;
716 Unit* charmer = GetCharmerOrOwner();
717 if (!charmer)
718 return;
719
720 if (!GetCharmInfo())
721 return;
722
723 if (tempspellTarget && tempspellTarget->IsAlive())
724 {
725 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(tempspell);
726 if (!spellInfo)
727 return;
728 float max_range = GetSpellMaxRangeForTarget(tempspellTarget, spellInfo);
729 if (spellInfo->RangeEntry->Flags == SPELL_RANGE_MELEE)
730 max_range -= 2 * MIN_MELEE_REACH;
731
732 if (IsWithinLOSInMap(tempspellTarget) && GetDistance(tempspellTarget) < max_range)
733 {
734 if (!GetCharmInfo()->GetGlobalCooldownMgr().HasGlobalCooldown(spellInfo) && !HasSpellCooldown(tempspell))
735 {
736 StopMoving();
737 GetMotionMaster()->Clear(false);
739
740 bool oldCmdAttack = GetCharmInfo()->IsCommandAttack();
741
743 GetCharmInfo()->SetIsAtStay(true);
748
749 GetCharmInfo()->SetIsCommandAttack(oldCmdAttack);
750
751 AddSpellCooldown(tempspell, 0, spellInfo->IsCooldownStartedOnEvent() ? infinityCooldownDelay : 0);
752
753 CastSpell(tempspellTarget, tempspell, false);
754 m_tempspell = 0;
755 m_tempspellTarget = nullptr;
756
757 if (tempspellIsPositive)
758 {
759 if (tempoldTarget && tempoldTarget->IsAlive())
760 {
762 GetCharmInfo()->SetIsAtStay(false);
766
768 ToCreature()->AI()->AttackStart(tempoldTarget);
769 }
770 else
771 {
772 if (IsAIEnabled)
773 AI()->PetStopAttack();
774 else
775 {
778 GetCharmInfo()->SetIsAtStay(false);
783 }
784 }
785
786 m_tempoldTarget = nullptr;
787 m_tempspellIsPositive = false;
788 }
789 }
790 }
791 }
792 else
793 {
794 m_tempspell = 0;
795 m_tempspellTarget = nullptr;
796 m_tempoldTarget = nullptr;
797 m_tempspellIsPositive = false;
798
799 Unit* victim = charmer->GetVictim();
800 if (victim && victim->IsAlive())
801 {
802 StopMoving();
803 GetMotionMaster()->Clear(false);
805
807 GetCharmInfo()->SetIsAtStay(false);
811
813 ToCreature()->AI()->AttackStart(victim);
814 }
815 else
816 {
817 StopMoving();
818 GetMotionMaster()->Clear(false);
820
823 GetCharmInfo()->SetIsAtStay(false);
828 }
829 }
830 }
831
832 if (getPetType() == HUNTER_PET)
833 {
834 m_happinessTimer -= diff;
835 if (m_happinessTimer <= int32(0))
836 {
839 }
840 }
841
842 break;
843 }
844 default:
845 break;
846 }
847
848 Creature::Update(diff);
849}
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition: Duration.h:27
#define MIN_MELEE_REACH
Definition: ObjectDefines.h:47
static constexpr uint32 infinityCooldownDelay
Definition: Unit.h:154
@ SPELL_RANGE_MELEE
Definition: Spell.h:89
virtual void AttackStart(Unit *)
Definition: UnitAI.cpp:28
virtual void PetStopAttack()
Definition: CreatureAI.h:205
bool HasSpellCooldown(uint32 spell_id) const override
Definition: Creature.cpp:2819
void Update(uint32 time) override
Definition: Creature.cpp:601
time_t m_corpseRemoveTime
Timers.
Definition: Creature.h:416
void AddSpellCooldown(uint32 spell_id, uint32, uint32 end_time, bool needSendToClient=false, bool forceSendToSpectator=false) override
Definition: Creature.cpp:2764
void Regenerate(Powers power)
Definition: Creature.cpp:924
CreatureAI * AI() const
Definition: Creature.h:135
bool IsWithinLOSInMap(WorldObject const *obj, VMAP::ModelIgnoreFlags ignoreFlags=VMAP::ModelIgnoreFlags::Nothing, LineOfSightChecks checks=LINEOFSIGHT_ALL_CHECKS, Optional< float > collisionHeight={ }, Optional< float > combatReach={ }) const
Definition: Object.cpp:1347
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool useBoundingRadius=true) const
Definition: Object.cpp:1321
float GetVisibilityRange() const
Definition: Object.cpp:1645
float GetDistance(WorldObject const *obj) const
Definition: Object.cpp:1245
void Remove(PetSaveMode mode, bool returnreagent=false)
Definition: Pet.cpp:872
void LoseHappiness()
Definition: Pet.cpp:851
bool IsCommandAttack()
Definition: Unit.cpp:20502
void SaveStayPosition(bool atCurrentPos)
Definition: Unit.cpp:20517
void SetCommandState(CommandStates st)
Definition: Unit.h:1102
MotionMaster * GetMotionMaster()
Definition: Unit.h:2262
DeathState m_deathState
Definition: Unit.h:2490
void StopMoving()
Definition: Unit.cpp:16824
float GetSpellMaxRangeForTarget(Unit const *target, SpellInfo const *spellInfo) const
Definition: Unit.cpp:15039
Unit * GetCharmerOrOwner() const
Definition: Unit.h:1847
bool isPossessed() const
Definition: Unit.h:1872
Unit * GetVictim() const
Definition: Unit.h:1386
bool IsAIEnabled
Definition: Unit.h:2350
Powers getPowerType() const
Definition: Unit.h:1459
ObjectGuid GetPetGUID() const
Definition: Unit.h:1824
void MoveFollow(Unit *target, float dist, float angle, MovementSlot slot=MOTION_SLOT_ACTIVE)
Definition: MotionMaster.cpp:367
void MoveIdle()
Definition: MotionMaster.cpp:231
void Clear(bool reset=true)
Definition: MotionMaster.h:165
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:184
bool IsCooldownStartedOnEvent() const
Definition: SpellInfo.cpp:1196
SpellRangeEntry const * RangeEntry
Definition: SpellInfo.h:367
uint32 Flags
Definition: DBCStructure.h:1772

References Creature::AddSpellCooldown(), Creature::AI(), ALIVE, ASSERT, UnitAI::AttackStart(), Unit::CastSpell(), MotionMaster::Clear(), COMMAND_FOLLOW, CORPSE, SpellRangeEntry::Flags, Unit::GetCharmerOrOwner(), Unit::GetCharmInfo(), WorldObject::GetDistance(), Object::GetEntry(), Minion::GetFollowAngle(), GameTime::GetGameTime(), Object::GetGUID(), WorldObject::GetMap(), Unit::GetMotionMaster(), WorldObject::GetName(), GetOwner(), Unit::GetPetGUID(), getPetType(), WorldSession::GetPlayerInfo(), Unit::getPowerType(), Player::GetSession(), Unit::GetSpellMaxRangeForTarget(), Unit::GetVictim(), WorldObject::GetVisibilityRange(), Creature::HasSpellCooldown(), HUNTER_PET, infinityCooldownDelay, Unit::IsAIEnabled, Unit::IsAlive(), CharmInfo::IsCommandAttack(), isControlled(), SpellInfo::IsCooldownStartedOnEvent(), Unit::isPossessed(), WorldObject::IsWithinDistInMap(), WorldObject::IsWithinLOSInMap(), LOG_ERROR, LoseHappiness(), Creature::m_corpseRemoveTime, Unit::m_deathState, m_duration, m_happinessTimer, m_loading, m_petRegenTimer, m_removed, m_tempoldTarget, m_tempspell, m_tempspellIsPositive, m_tempspellTarget, MIN_MELEE_REACH, MotionMaster::MoveFollow(), MotionMaster::MoveIdle(), PET_FOCUS_REGEN_INTERVAL, PET_FOLLOW_DIST, PET_LOSE_HAPPINES_INTERVAL, PET_SAVE_AS_DELETED, PET_SAVE_NOT_IN_SLOT, CreatureAI::PetStopAttack(), POWER_FOCUS, SpellInfo::RangeEntry, Creature::Regenerate(), Remove(), CharmInfo::SaveStayPosition(), CharmInfo::SetCommandState(), CharmInfo::SetIsAtStay(), CharmInfo::SetIsCommandAttack(), CharmInfo::SetIsCommandFollow(), CharmInfo::SetIsFollowing(), CharmInfo::SetIsReturning(), SPELL_RANGE_MELEE, sSpellMgr, Unit::StopMoving(), SUMMON_PET, Object::ToCreature(), and Creature::Update().

Member Data Documentation

◆ m_auraRaidUpdateMask

uint64 Pet::m_auraRaidUpdateMask
protected

◆ m_autospells

◆ m_declinedname

std::unique_ptr<DeclinedName> Pet::m_declinedname
protected

Referenced by GetDeclinedNames(), and LoadPetFromDB().

◆ m_duration

Milliseconds Pet::m_duration
protected

◆ m_happinessTimer

int32 Pet::m_happinessTimer
protected

Referenced by Update().

◆ m_loading

◆ m_owner

Player* Pet::m_owner
protected

◆ m_petRegenTimer

Milliseconds Pet::m_petRegenTimer
protected

Referenced by Update().

◆ m_petType

PetType Pet::m_petType
protected

Referenced by getPetType(), and setPetType().

◆ m_removed

bool Pet::m_removed

Referenced by Player::RemovePet(), and Update().

◆ m_spells

◆ m_tempoldTarget

Unit* Pet::m_tempoldTarget
protected

◆ m_tempspell

uint32 Pet::m_tempspell
protected

◆ m_tempspellIsPositive

bool Pet::m_tempspellIsPositive
protected

◆ m_tempspellTarget

Unit* Pet::m_tempspellTarget
protected

◆ m_usedTalentCount