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 UpdatableMapObject 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, std::optional< float > displayScale={}) 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 fullMana=false)
 
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
 A creature can be in 4 different states: Alive, JustDied, Corpse, and JustRespawned. The cycle follows the next order:
 
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, ObjectGuid oldTarget, bool spellIsPositive=false)
 
void ClearCastWhenWillAvailable ()
 
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
 
Player * GetOwner () 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)
 
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
 
- Public Member Functions inherited from Minion
 Minion (SummonPropertiesEntry const *properties, ObjectGuid owner)
 
void InitStats (uint32 duration) override
 
Unit * GetOwner () const
 
float GetFollowAngle () const override
 
void SetFollowAngle (float angle)
 
bool IsPetGhoul () const
 
bool IsGuardianPet () const
 
- Public Member Functions inherited from TempSummon
 TempSummon (SummonPropertiesEntry const *properties, ObjectGuid owner)
 
 ~TempSummon () override=default
 
void Update (uint32 time) override
 
virtual void UnSummon (Milliseconds msTime=0ms)
 
void UpdateObjectVisibilityOnCreate () override
 
void RemoveFromWorld () override
 
void SetTempSummonType (TempSummonType type)
 
void SaveToDB (uint32, uint8, uint32) override
 
WorldObject * GetSummoner () const
 
Unit * GetSummonerUnit () const
 
Creature * GetSummonerCreatureBase () const
 
GameObject * GetSummonerGameObject () 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 ()
 
 ~Creature () override
 
void SetObjectScale (float scale) override
 
void SetDisplayFromModel (uint32 modelIdx)
 
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, CreatureData const *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 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 HasFlagsExtra (uint32 flag) const
 
bool IsRacialLeader () const
 
bool IsCivilian () const
 
bool IsTrigger () const
 
bool IsGuard () const
 
CreatureMovementData const & GetMovementTemplate () const
 
void PauseMovementForInteraction ()
 
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
 
bool IsRooted () const
 
MovementGeneratorType GetDefaultMovementType () const override
 -------—End of Pet responses methods-------—
 
void SetDefaultMovementType (MovementGeneratorType mgt)
 
void SetReactState (ReactStates state)
 A creature can have 3 ReactStates : Agressive, Passive, Neutral.
 
ReactStates GetReactState () const
 
bool HasReactState (ReactStates state) const
 
void InitializeReactState ()
 Check if the creature has the specified ReactState.
 
bool isCanInteractWithBattleMaster (Player *player, bool msg) const
 
bool CanResetTalents (Player *player) const
 
bool CanCreatureAttack (Unit const *victim, bool skipDistCheck=false) const
 
bool IsImmunedToSpell (SpellInfo const *spellInfo, Spell const *spell=nullptr) override
 
bool HasMechanicTemplateImmunity (uint64 mask) const
 
bool IsImmunedToSpellEffect (SpellInfo const *spellInfo, uint32 index, WorldObject const *caster=nullptr) 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 ()
 
CreatureAI * AI () const
 
bool SetWalk (bool enable) override
 Enable or disable the creature's walk mode by removing: MOVEMENTFLAG_WALKING. Infom also the client.
 
bool SetSwim (bool enable) 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 RemoveSpellCooldown (uint32 spell_id, bool update)
 
void ProhibitSpellSchool (SpellSchoolMask idSchoolMask, uint32 unTimeMs) override
 
bool IsSpellProhibited (SpellSchoolMask idSchoolMask) const
 
void ClearProhibitedSpellTimers ()
 
void UpdateMovementFlags ()
 
uint32 GetRandomId (uint32 id1, uint32 id2, uint32 id3)
 
bool UpdateEntry (uint32 entry, CreatureData const *data=nullptr, bool changelevel=true, bool updateAI=false)
 
bool UpdateEntry (uint32 entry, bool updateAI)
 
void UpdateResistances (uint32 school) override
 
void CalculateMinMaxDamage (WeaponAttackType attType, bool normalized, bool addTotalPct, float &minDamage, float &maxDamage, uint8 damageIndex) override
 
void LoadTemplateImmunities (int32 creatureImmunitiesId)
 
void LoadSparringPct ()
 
float GetSparringPct () const
 
bool HasWeapon (WeaponAttackType type) const override
 
bool HasWeaponForAttack (WeaponAttackType type) const 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)
 
CreatureTemplate const * GetCreatureTemplate () const
 
CreatureData const * GetCreatureData () const
 
uint32 GetGossipMenuId () const
 
void SetGossipMenuId (uint32 gossipMenuId)
 
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
 
bool LoadFromDB (ObjectGuid::LowType guid, Map *map, bool allowDuplicate=false)
 
bool LoadCreatureFromDB (ObjectGuid::LowType guid, Map *map, bool addToMap=true, bool allowDuplicate=false)
 
bool IsRespawnCompatibilityMode () const
 
void SaveToDB ()
 
ObjectGuid GetLootRecipientGUID () const
 
Player * GetLootRecipient () const
 
ObjectGuid::LowType GetLootRecipientGroupGUID () const
 
Group * GetLootRecipientGroup () 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, bool force=false) const
 
float GetAggroRange (Unit const *target) const
 
float GetAttackDistance (Unit const *player) const
 
float GetDetectionRange () const
 
void SendAIReaction (AiReaction reactionType)
 
Unit * SelectNearestTarget (float dist=0, bool playerOnly=false) const
 Select nearest hostile unit within the given distance (regardless of threat list).
 
Unit * SelectNearestTargetInAttackDistance (float dist) const
 Select nearest hostile unit within the given attack distance (i.e. distance is ignored if > than ATTACK_DISTANCE), regardless of threat list.
 
void DoFleeToGetAssistance ()
 
void CallForHelp (float fRadius, Unit *target=nullptr)
 
void CallAssistance (Unit *target=nullptr)
 
void SetNoCallForHelp (bool val)
 
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=0ms, Seconds forcedRespawnTimer=0s)
 
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 ()
 Set in combat all units in the dungeon/raid. Affect only units with IsAIEnabled.
 
void AtEngage (Unit *target) override
 
void AtDisengage () override
 
bool IsEngaged () const override
 
bool hasQuest (uint32 quest_id) const override
 
bool hasInvolvedQuest (uint32 quest_id) const override
 
bool isRegeneratingHealth ()
 
void SetRegeneratingHealth (bool enable)
 
void SetRegeneratingPower (bool enable)
 
void SetCannotReachTarget (ObjectGuid const &target=ObjectGuid::Empty)
 
bool CanNotReachTarget () const
 
ObjectGuid const & GetCannotReachTarget () const
 
bool IsNotReachableAndNeedRegen () const
 
void SetPosition (float x, float y, float z, float o)
 
void SetPosition (Position const &pos)
 
void SetHomePosition (float x, float y, float z, float o)
 
void SetHomePosition (Position const &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 (Position const &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)
 
std::pair< uint32, uint32 > GetCurrentWaypointInfo () const
 
void UpdateCurrentWaypointInfo (uint32 nodeId, uint32 pathId)
 
bool IsFormationLeader () const
 
void SignalFormationMovement ()
 
bool IsFormationLeaderMoveAllowed () const
 
void SearchFormation ()
 
CreatureGroup const * GetFormation () const
 
CreatureGroup * GetFormation ()
 
void SetFormation (CreatureGroup *formation)
 
Unit * SelectVictim ()
 
void SetReputationRewardDisabled (bool disable)
 
bool IsReputationRewardDisabled () const
 
void SetLootRewardDisabled (bool disable)
 
bool IsLootRewardDisabled () const
 
bool IsDamageEnoughForLootingAndReward () const
 
void LowerPlayerDamageReq (uint32 unDamage, bool damagedByPlayer=true, uint8 attackerLevel=0)
 
void ResetPlayerDamageReq ()
 
uint32 GetPlayerDamageReq () const
 
uint8 GetHighestPlayerAttackerLevel () const
 
uint32 GetOriginalEntry () const
 
void SetOriginalEntry (uint32 entry)
 
void SetTarget (ObjectGuid guid=ObjectGuid::Empty) override
 
void ClearTarget ()
 
void FocusTarget (Spell const *focusSpell, WorldObject const *target)
 
void ReleaseFocus (Spell const *focusSpell)
 
bool IsMovementPreventedByCasting () const override
 
std::shared_ptr< time_t > const & GetLastLeashExtensionTimePtr () const
 
void SetLastLeashExtensionTimePtr (std::shared_ptr< time_t > const &timer)
 
void ClearLastLeashExtensionTimePtr ()
 
time_t GetLastLeashExtensionTime () const
 
void UpdateLeashExtensionTime ()
 
uint8 GetLeashTimer () const
 
CreatureTextRepeatIds const & GetTextRepeatGroup (uint8 textGroup)
 
void SetTextRepeatId (uint8 textGroup, uint8 id)
 
void ClearTextRepeatGroup (uint8 textGroup)
 
bool IsTextOnCooldown (uint8 textGroup) const
 
void SetTextCooldown (uint8 textGroup, uint32 cooldownMs)
 
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.
 
bool CanCastSpell (uint32 spellID) const
 Returns true if the creature is able to cast the spell.
 
ObjectGuid GetSummonerGUID () const
 Helper to get the creature's summoner GUID, if it is a summon.
 
void SetCombatMovement (bool allowMovement)
 
bool IsCombatMovementAllowed () const
 
bool IsUpdateNeeded () override
 
- Public Member Functions inherited from Unit
 ~Unit () override
 
void Update (uint32 time) override
 
UnitAI * GetAI ()
 
void SetAI (UnitAI *newAI)
 
void AddToWorld () override
 
void RemoveFromWorld () override
 
void CleanupBeforeRemoveFromMap (bool finalCleanup)
 
void CleanupsBeforeDelete (bool finalCleanup=true) override
 
bool IsDuringRemoveFromWorld () const
 
void SetUInt32Value (uint16 index, uint32 value)
 
Unit * GetOwner () const
 
ObjectGuid GetOwnerGUID () const override
 
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
 
ObjectGuid GetTransGUID () const override
 
Pet * ToPet ()
 
Totem * ToTotem ()
 
TempSummon * ToTempSummon ()
 
TempSummon const * ToTempSummon () const
 
void AddUnitState (uint32 f)
 
bool HasUnitState (const uint32 f) const
 
void ClearUnitState (uint32 f)
 
uint32 GetUnitState () const
 
uint32 HasUnitTypeMask (uint32 mask) const
 
void AddUnitTypeMask (uint32 mask)
 
uint32 GetUnitTypeMask () const
 
UnitFlags GetUnitFlags () const
 
bool HasUnitFlag (UnitFlags flags) const
 
void SetUnitFlag (UnitFlags flags)
 UnitFlags available in UnitDefines.h.
 
void RemoveUnitFlag (UnitFlags flags)
 UnitFlags available in UnitDefines.h.
 
void ReplaceAllUnitFlags (UnitFlags flags)
 Remove the Unit flag specify only.
 
UnitFlags2 GetUnitFlags2 () const
 Remove all UnitFlags and set new ones. UnitFlags available in UnitDefines.h.
 
bool HasUnitFlag2 (UnitFlags2 flags) const
 
void SetUnitFlag2 (UnitFlags2 flags)
 
void RemoveUnitFlag2 (UnitFlags2 flags)
 
void ReplaceAllUnitFlags2 (UnitFlags2 flags)
 
void SetEmoteState (Emote emoteState)
 
void ClearEmoteState ()
 Sets emote state (looping emote). Emotes available in SharedDefines.h.
 
NPCFlags GetNpcFlags () const
 Clears emote state (looping emote)
 
bool HasNpcFlag (NPCFlags flags) const
 
void SetNpcFlag (NPCFlags flags)
 
void RemoveNpcFlag (NPCFlags flags)
 
void ReplaceAllNpcFlags (NPCFlags flags)
 
uint32 GetDynamicFlags () const override
 
void ReplaceAllDynamicFlags (uint32 flag) override
 
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)
 
bool IsCrowdControlled () const
 
bool IsImmobilizedState () const
 
void SetAnimTier (AnimTier animTier)
 
bool IsSummon () const
 
bool IsGuardian () const
 
bool IsControllableGuardian () const
 
bool IsPet () const
 
bool IsHunterPet () const
 
bool IsTotem () const
 
bool IsVehicle () const
 
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
 
uint32 GetCreatureType () const
 
uint32 GetCreatureTypeMask () const
 
bool IsCritter () const
 
uint8 getRace (bool original=false) const
 
void setRace (uint8 race)
 
uint32 getRaceMask () const
 
DisplayRace GetDisplayRaceFromModelId (uint32 modelId) const
 
DisplayRace GetDisplayRace () const
 
uint8 getClass () const
 
virtual bool IsClass (Classes unitClass, ClassContext context=CLASS_CONTEXT_NONE) const
 
uint32 getClassMask () const
 
uint8 getGender () const
 
uint32 GetFaction () const override
 
FactionTemplateEntry const * GetFactionTemplateEntry () const
 
void SetFaction (uint32 faction)
 
void RestoreFaction ()
 
uint32 GetOldFactionId () const
 
ObjectGuid GetTarget () 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 IsAreaEffectPvPBlocked (Unit const *target, SpellInfo const *bySpell) const
 
bool IsValidAssistTarget (Unit const *target) const
 
bool _IsValidAssistTarget (Unit const *target, SpellInfo const *bySpell) const
 
bool IsClientControlled (Player const *exactClient=nullptr) const
 
Player const * GetClientControlling () const
 
float GetBoundaryRadius () const
 
float GetCombatReach () const override
 
float GetMeleeReach () const
 
bool IsWithinRange (Unit const *obj, float dist) const
 
bool IsWithinBoundaryRadius (Unit const *obj) 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
 
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 GetRandomContactPoint (Unit const *target, float &x, float &y, float &z, bool force=false) const
 
Unit * getAttackerForHelper () const
 
bool Attack (Unit *victim, bool meleeAttack)
 
void CastStop (uint32 except_spellid=0, bool withInstant=true)
 Interrupt the unit cast for all the current spells.
 
bool AttackStop ()
 Force the unit to stop attacking. This will clear UNIT_STATE_MELEE_ATTACKING, Interrupt current spell, AI assistance, and call SendMeleeAttackStop() to the client.
 
void RemoveAllAttackers ()
 Remove all units in m_attackers list and send them AttackStop()
 
AttackerSet const & getAttackers () const
 
bool GetMeleeAttackPoint (Unit *attacker, Position &pos)
 
bool isAttackingPlayer () const
 
Unit * GetVictim () const
 
void CombatStop (bool includingCast=false, bool mutualPvP=true, bool keepPvPForOthers=false)
 
void CombatStopWithPets (bool includingCast=false)
 
void StopAttackFaction (uint32 faction_id)
 
void StopAttackingInvalidTarget ()
 
Unit * SelectNearbyTarget (Unit *exclude=nullptr, float dist=NOMINAL_MELEE_RANGE) const
 
Unit * SelectNearbyNoTotemTarget (Unit *exclude=nullptr, float dist=NOMINAL_MELEE_RANGE) const
 
void SendMeleeAttackStop (Unit const *victim=nullptr) const
 Send to the client SMSG_ATTACKSTOP but doesn't clear UNIT_STATE_MELEE_ATTACKING on server side or interrupt spells. Unless you know exactly what you're doing, use AttackStop() or RemoveAllAttackers() instead.
 
void SendMeleeAttackStart (Unit *victim, Player *sendTo=nullptr)
 
uint32 GetAttackTime (WeaponAttackType att) const
 
uint32 GetRageWeaponSpeedHitFactor (WeaponAttackType att) const
 
void SetAttackTime (WeaponAttackType att, uint32 val)
 
void ApplyAttackTimePercentMod (WeaponAttackType att, float val, bool apply)
 
void ApplyCastTimePercentMod (float val, bool apply)
 
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 IsEngagedBy (Unit const *who) const
 
void EngageWithTarget (Unit *who)
 
bool IsInCombat () const
 
bool IsInCombatWith (Unit const *who) const
 
bool IsPetInCombat () const
 
void SetInCombatWith (Unit *enemy, bool addSecondUnitSuppressed=false)
 
void ClearInCombat (bool keepPvPForOthers=false)
 
void ClearInPetCombat ()
 
uint32 GetCombatTimer () const
 
void SetCombatTimer (uint32 timer)
 
bool CanHaveThreatList (bool skipAliveCheck=false) const
 
void AddThreat (Unit *victim, float fThreat, SpellSchoolMask schoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellInfo const *threatSpell=nullptr)
 
void AtTargetAttacked (Unit *target, bool canInitialAggro)
 
ThreatManager & GetThreatMgr ()
 
ThreatManager const & GetThreatMgr () const
 
CombatManager & GetCombatManager ()
 
CombatManager const & GetCombatManager () const
 
bool IsThreatened () const
 
bool IsThreatenedBy (Unit const *who) const
 
void UpdatePetCombatState ()
 
virtual void AtEnterCombat ()
 
virtual void AtExitCombat ()
 
bool IsCombatDisallowed () const
 
void SetIsCombatDisallowed (bool value)
 
void SetLastDamagedTargetGuid (ObjectGuid const &guid)
 
ObjectGuid const & GetLastDamagedTargetGuid () const
 
void AttackerStateUpdate (Unit *victim, WeaponAttackType attType=BASE_ATTACK, bool extra=false, bool ignoreCasting=false)
 
bool haveOffhandWeapon () const
 
bool CanDualWield () const
 
virtual void SetDualWieldMode (DualWieldMode mode)
 
bool HasMainhandWeapon () const
 
bool HasOffhandWeapon () const
 
bool HasRangedWeapon () const
 
bool hasMainhandWeaponForAttack () const
 
bool HasMainhandWeaponForAttack () const
 
bool HasOffhandWeaponForAttack () const
 
bool HasRangedWeaponForAttack () const
 
bool CanUseAttackType (WeaponAttackType attacktype) const
 
void HandleProcExtraAttackFor (Unit *victim, uint32 count)
 
void SetLastExtraAttackSpell (uint32 spellId)
 
uint32 GetLastExtraAttackSpell () const
 
void AddExtraAttacks (uint32 count)
 
uint8 GetComboPoints (Unit const *who=nullptr) const
 
uint8 GetComboPoints (ObjectGuid const &guid) const
 
Unit * GetComboTarget () const
 
ObjectGuid const GetComboTargetGUID () const
 
void AddComboPoints (Unit *target, int8 count)
 
void AddComboPoints (int8 count)
 
void ClearComboPoints ()
 
void AddComboPointHolder (Unit *unit)
 
void RemoveComboPointHolder (Unit *unit)
 
void ClearComboPointHolders ()
 
void SetContestedPvP (Player *attackedPlayer=nullptr, bool lookForNearContestedGuards=true)
 
bool IsContestedGuard () const
 
bool RespondsToCallForHelp () const
 
bool IsInSanctuary () const
 
bool IsPvP () const
 
bool IsFFAPvP () const
 
void SetPvP (bool state)
 
float GetStat (Stats stat) const
 
void SetStat (Stats stat, int32 val)
 
Stats GetStatByAuraGroup (UnitMods unitMod) const
 
float GetCreateStat (Stats stat) const
 
void SetCreateStat (Stats stat, float val)
 
float GetPosStat (Stats stat) const
 
float GetNegStat (Stats stat) const
 
void InitStatBuffMods ()
 
bool HandleStatFlatModifier (UnitMods unitMod, UnitModifierFlatType modifierType, float amount, bool apply)
 
void ApplyStatPctModifier (UnitMods unitMod, UnitModifierPctType modifierType, float amount)
 
void SetStatFlatModifier (UnitMods unitMod, UnitModifierFlatType modifierType, float val)
 
void SetStatPctModifier (UnitMods unitMod, UnitModifierPctType modifierType, float val)
 
float GetFlatModifierValue (UnitMods unitMod, UnitModifierFlatType modifierType) const
 
float GetPctModifierValue (UnitMods unitMod, UnitModifierPctType modifierType) const
 
void UpdateUnitMod (UnitMods unitMod)
 
virtual bool CheckAttackFitToAuraRequirement (WeaponAttackType, AuraEffect const *) const
 
virtual void UpdateDamageDoneMods (WeaponAttackType attackType, int32 skipEnchantSlot=-1)
 
void UpdateAllDamageDoneMods ()
 
void UpdateDamagePctDoneMods (WeaponAttackType attackType)
 
void UpdateAllDamagePctDoneMods ()
 
float GetTotalStatValue (Stats stat, float additionalValue=0.0f) const
 
void SetCanModifyStats (bool modifyStats)
 
bool CanModifyStats () const
 
void UpdateStatBuffMod (Stats stat)
 
uint8 GetLevel () const
 
uint8 getLevelForTarget (WorldObject const *) const override
 
void SetLevel (uint8 lvl, bool showLevelChange=true)
 
uint32 GetHealth () const
 
uint32 GetMaxHealth () const
 
float GetHealthPct () const
 
int32 GetHealthGain (int32 dVal)
 
uint32 GetCreateHealth () 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
 
uint32 CountPctFromMaxHealth (int32 pct) const
 
uint32 CountPctFromCurHealth (int32 pct) const
 
void SetHealth (uint32 val)
 
void SetMaxHealth (uint32 val)
 
void SetFullHealth ()
 
int32 ModifyHealth (int32 val)
 
void SetCreateHealth (uint32 val)
 
Powers getPowerType () const
 
virtual bool HasActivePowerType (Powers power)
 
Powers GetPowerTypeByAuraGroup (UnitMods unitMod) const
 
uint32 GetPower (Powers power) const
 
uint32 GetMaxPower (Powers power) const
 
float GetPowerPct (Powers power) const
 
uint32 GetCreatePowers (Powers power) const
 
void setPowerType (Powers power)
 
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)
 
void RewardRage (uint32 damage, uint32 weaponSpeedHitFactor, bool attacker)
 
uint32 GetCreateMana () const
 
void SetCreateMana (uint32 val)
 
bool CanRestoreMana (SpellInfo const *spellInfo) const
 
void SetLastManaUse (uint32 spellCastTime)
 
bool IsUnderLastManaUseEffect () const
 
float GetAPMultiplier (WeaponAttackType attType, bool normalized)
 
uint32 GetArmor () const
 
void SetArmor (int32 val)
 
float GetUnitDodgeChance () const
 
float GetUnitParryChance () const
 
float GetUnitBlockChance () const
 
float GetUnitMissChance (WeaponAttackType attType) const
 
float GetUnitCriticalChance (WeaponAttackType attackType, Unit const *victim) const
 
float GetCritChanceFromSkillDiff (Unit const *victim) 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
 
bool CanApplyResilience () const
 
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
 
int32 GetMechanicResistChance (SpellInfo const *spell)
 
uint32 GetResistance (SpellSchoolMask mask) const
 
uint32 GetResistance (SpellSchools school) const
 
void SetResistance (SpellSchools school, int32 val)
 
void UpdateResistanceBuffModsMod (SpellSchools school)
 
uint16 GetMaxSkillValueForLevel (Unit const *target=nullptr) const
 
float GetTotalAuraModValue (UnitMods unitMod) const
 
SpellSchools GetSpellSchoolByAuraGroup (UnitMods unitMod) const
 
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 UpdateAllResistances ()
 
void DealMeleeDamage (CalcDamageInfo *damageInfo, bool durabilityLoss)
 
void DealSpellDamage (SpellNonMeleeDamage *damageInfo, bool durabilityLoss, Spell const *spell=nullptr)
 
void DealDamageShieldDamage (Unit *victim)
 
void KillSelf (bool durabilityLoss=true, WeaponAttackType attackType=BASE_ATTACK, SpellInfo const *spellProto=nullptr, Spell const *spell=nullptr)
 
uint32 CalculateDamage (WeaponAttackType attType, bool normalized, bool addTotalPct, uint8 itemDamagesMask=0)
 
void CalculateMeleeDamage (Unit *victim, CalcDamageInfo *damageInfo, WeaponAttackType attackType=BASE_ATTACK, const bool sittingVictim=false)
 
void CalculateSpellDamageTaken (SpellNonMeleeDamage *damageInfo, int32 damage, SpellInfo const *spellInfo, WeaponAttackType attackType=BASE_ATTACK, bool crit=false)
 
float CalculateDefaultCoefficient (SpellInfo const *spellInfo, DamageEffectType damagetype) const
 
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)
 
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 CalculateAOEDamageReduction (int32 damage, uint32 schoolMask, bool npcCaster) const
 
uint32 GetMeleeDamageReduction (uint32 damage) const
 
uint32 GetRangedDamageReduction (uint32 damage) const
 
uint32 GetSpellDamageReduction (uint32 damage) const
 
float GetMeleeCritChanceReduction () const
 
float GetRangedCritChanceReduction () const
 
float GetSpellCritChanceReduction () const
 
uint32 GetMeleeCritDamageReduction (uint32 damage) const
 
uint32 GetRangedCritDamageReduction (uint32 damage) const
 
uint32 GetSpellCritDamageReduction (uint32 damage) const
 
CharmInfo * GetCharmInfo ()
 
CharmInfo * InitCharmInfo ()
 
Unit * GetCharmer () const
 
Unit * GetCharm () const
 
Unit * GetCharmerOrOwner () const
 
Unit * GetCharmerOrOwnerOrSelf () const
 
Player * GetCharmerOrOwnerPlayerOrPlayerItself () const
 
ObjectGuid GetCharmerOrOwnerGUID () const override
 
ObjectGuid GetCharmerOrOwnerOrOwnGUID () const
 
Player * GetAffectingPlayer () const
 
Unit * GetFirstControlled () const
 
bool IsControlledByPlayer () const
 
bool IsCreatedByPlayer () const
 
bool IsCharmedOwnedByPlayerOrPlayer () const
 
bool IsCharmed () const
 
bool isPossessed () const
 
bool isPossessedByPlayer () const
 
bool isPossessing () const
 
bool isPossessing (Unit *u) const
 
void SetCharm (Unit *target, bool apply)
 
bool SetCharmedBy (Unit *charmer, CharmType type, AuraApplication const *aurApp=nullptr)
 
void UpdateCharmAI ()
 
void RemoveCharmedBy (Unit *charmer)
 
void RemoveCharmAuras ()
 
void RemoveAllControlled (bool onDeath=false)
 
void DeleteCharmInfo ()
 
virtual bool HasSpellItemCooldown (uint32, uint32) const
 
void BuildCooldownPacket (WorldPacket &data, uint8 flags, uint32 spellId, uint32 cooldown)
 
void BuildCooldownPacket (WorldPacket &data, uint8 flags, PacketCooldowns const &cooldowns)
 
Aura * AddAura (uint32 spellId, Unit *target)
 
Aura * AddAura (SpellInfo const *spellInfo, uint8 effMask, Unit *target)
 
void SetAuraStack (uint32 spellId, Unit *target, uint32 stack)
 
int32 GetHighestExclusiveSameEffectSpellGroupValue (AuraEffect const *aurEff, AuraType auraType, bool checkMiscValue=false, int32 miscValue=0) const
 
bool IsHighestExclusiveAura (Aura const *aura, bool removeOtherAuraApplications=false)
 
bool IsHighestExclusiveAuraEffect (SpellInfo const *spellInfo, AuraType auraType, int32 effectAmount, uint8 auraEffectMask, bool removeOtherAuraApplications=false)
 
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 owned)
 
bool _IsNoStackAuraDueToAura (Aura *appliedAura, Aura *existingAura) const
 
void _RegisterAuraEffect (AuraEffect *aurEff, bool apply)
 
AuraMap & GetOwnedAuras ()
 
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)
 
Aura * GetOwnedAura (uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, Aura *except=nullptr) const
 
AuraApplicationMap & GetAppliedAuras ()
 
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 RemoveBindSightAuras ()
 
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 (uint64 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
 
AuraList & GetSingleCastAuras ()
 
AuraList const & GetSingleCastAuras () const
 
AuraEffect * GetAuraEffect (uint32 spellId, uint8 effIndex, ObjectGuid casterGUID=ObjectGuid::Empty) const
 
AuraEffect * GetAuraEffectOfRankedSpell (uint32 spellId, uint8 effIndex, ObjectGuid casterGUID=ObjectGuid::Empty) const
 
AuraEffect * GetAuraEffect (AuraType type, SpellFamilyNames name, uint32 iconId, uint8 effIndex) const
 
AuraEffect * GetAuraEffect (AuraType type, SpellFamilyNames family, uint32 familyFlag1, uint32 familyFlag2, uint32 familyFlag3, ObjectGuid casterGUID=ObjectGuid::Empty) const
 
AuraEffect * GetAuraEffectDummy (uint32 spellid) const
 
AuraEffect * GetDummyAuraEffect (SpellFamilyNames name, uint32 iconId, uint8 effIndex) const
 
AuraApplication * GetAuraApplication (uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraApplication *except=nullptr) const
 
Aura * GetAura (uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
 
AuraApplication * GetAuraApplicationOfRankedSpell (uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraApplication *except=nullptr) const
 
Aura * GetAuraOfRankedSpell (uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
 
void GetDispellableAuraList (Unit *caster, uint32 dispelMask, DispelChargesList &dispelList, SpellInfo const *dispelSpell)
 
bool HasAuraEffect (uint32 spellId, uint8 effIndex, ObjectGuid caster=ObjectGuid::Empty) const
 
uint32 GetAuraCount (uint32 spellId) const
 
bool HasAuras (SearchMethod sm, std::vector< uint32 > &spellIds) const
 Check if unit has ANY or ALL specified auras.
 
template<typename... Auras>
bool HasAnyAuras (Auras... spellIds) const
 Checks if the unit has ANY specified auras.
 
template<typename... Auras>
bool HasAllAuras (Auras... spellIds) const
 Checks if the unit has ALL specified auras.
 
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 (uint64 mechanicMask) const
 
bool HasAuraTypeWithFamilyFlags (AuraType auraType, uint32 familyName, uint32 familyFlags) const
 
bool HasBreakableByDamageAuraType (AuraType type, uint32 excludeAura=0) const
 
bool HasBreakableByDamageCrowdControlAura (Unit *excludeCasterChannel=nullptr) const
 
AuraEffect * IsScriptOverriden (SpellInfo const *spell, int32 script) const
 
uint32 GetDiseasesByCaster (ObjectGuid casterGUID, uint8 mode=0)
 
uint32 GetDoTsByCaster (ObjectGuid casterGUID) const
 
int32 GetTotalAuraModifier (AuraType auratype) const
 
float GetTotalAuraMultiplier (AuraType auratype) const
 
int32 GetMaxPositiveAuraModifier (AuraType auratype) const
 
int32 GetMaxNegativeAuraModifier (AuraType auratype) const
 
int32 GetTotalAuraModifier (AuraType auratype, std::function< bool(AuraEffect const *)> const &predicate) const
 
float GetTotalAuraMultiplier (AuraType auraType, std::function< bool(AuraEffect const *)> const &predicate) const
 
int32 GetMaxPositiveAuraModifier (AuraType auraType, std::function< bool(AuraEffect const *)> const &predicate) const
 
int32 GetMaxNegativeAuraModifier (AuraType auraType, std::function< bool(AuraEffect const *)> const &predicate) const
 
int32 GetTotalAuraModifierByMiscMask (AuraType auratype, uint32 misc_mask) const
 
float GetTotalAuraMultiplierByMiscMask (AuraType auratype, uint32 misc_mask) const
 
int32 GetMaxPositiveAuraModifierByMiscMask (AuraType auratype, uint32 misc_mask, AuraEffect const *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
 
VisibleAuraMap const * GetVisibleAuras ()
 
AuraApplication * GetVisibleAura (uint8 slot)
 
void SetVisibleAura (uint8 slot, AuraApplication *aur)
 
void RemoveVisibleAura (uint8 slot)
 
void ModifyAuraState (AuraStateType flag, bool apply)
 
uint32 BuildAuraStateUpdateForTarget (Unit *target) const
 
bool HasAuraState (AuraStateType flag, SpellInfo const *spellProto=nullptr, Unit const *Caster=nullptr) const
 
bool CanProc ()
 
void SetCantProc (bool apply)
 
void ProcSkillsAndReactives (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 (AuraApplicationProcContainer &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, AuraApplicationProcContainer &procAuras)
 
float GetWeaponProcChance () const
 
float GetPPMProcChance (uint32 WeaponSpeed, float PPM, SpellInfo const *spellProto) const
 
Player * GetSpellModOwner () const override
 
Spell * GetCurrentSpell (CurrentSpellTypes spellType) const
 
Spell * GetCurrentSpell (uint32 spellType) const
 
Spell * GetFirstCurrentCastingSpell () const
 
Spell * FindCurrentSpellBySpellId (uint32 spell_id) const
 
int32 GetCurrentSpellCastTime (uint32 spell_id) const
 
void SetCurrentCastedSpell (Spell *pSpell)
 
void SetInstantCast (bool set)
 
bool CanInstantCast () const
 
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)
 
float GetSpellMaxRangeForTarget (Unit const *target, SpellInfo const *spellInfo) const
 
float GetSpellMinRangeForTarget (Unit const *target, SpellInfo const *spellInfo) const
 
uint32 GetInterruptMask () const
 
void AddInterruptMask (uint32 mask)
 
void UpdateInterruptMask ()
 
void InterruptSpell (CurrentSpellTypes spellType, bool withDelayed=true, bool withInstant=true, bool bySelf=false)
 
bool isSpellBlocked (Unit *victim, SpellInfo const *spellProto, WeaponAttackType attackType=BASE_ATTACK)
 
void FinishSpell (CurrentSpellTypes spellType, bool ok=true)
 
Unit * GetMagicHitRedirectTarget (Unit *victim, SpellInfo const *spellInfo)
 
Unit * GetMeleeHitRedirectTarget (Unit *victim, SpellInfo const *spellInfo=nullptr)
 
float MeleeSpellMissChance (Unit const *victim, WeaponAttackType attType, int32 skillDiff, uint32 spellId) const
 
SpellMissInfo MeleeSpellHitResult (Unit *victim, SpellInfo const *spell) override
 
void SendHealSpellLog (HealInfo const &healInfo, bool critical=false)
 
int32 HealBySpell (HealInfo &healInfo, bool critical=false)
 
int32 SpellBaseHealingBonusDone (SpellSchoolMask schoolMask)
 
float SpellPctHealingModsDone (Unit *victim, SpellInfo const *spellProto, DamageEffectType damagetype, bool includeHealingDonePct=true)
 
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)
 
void SendEnergizeSpellLog (Unit *victim, uint32 SpellID, uint32 Damage, Powers powertype)
 
void EnergizeBySpell (Unit *victim, uint32 SpellID, uint32 Damage, Powers powertype)
 
void ApplySpellImmune (uint32 spellId, uint32 op, uint32 type, bool apply, SpellImmuneBlockType blockType=SPELL_BLOCK_TYPE_ALL)
 
bool IsImmunedToSpell (SpellInfo const *spellInfo, Unit const *caster)
 
bool IsImmunedToSpell (SpellInfo const *spellInfo, Unit const *caster, SpellSchoolMask spellSchoolMask)
 
bool IsImmunedToSpell (SpellInfo const *spellInfo, uint32 effectMask, Unit const *caster=nullptr)
 
bool IgnoresSchoolImmunityFromFriendlyCaster (Unit const *caster, uint32 immunityAuraId, SpellInfo const *immunitySpellInfo) const
 
bool IsImmunedToDamage (SpellSchoolMask schoolMask) const
 
bool IsImmunedToDamage (Unit const *caster, SpellInfo const *spellInfo) const
 
bool IsImmunedToSchool (SpellSchoolMask schoolMask) const
 
bool HasSchoolImmunityForMask (SpellSchoolMask schoolMask, Unit const *caster, SpellInfo const *spellInfo) const
 
uint32 GetSchoolImmunityMask () const
 
uint32 GetDamageImmunityMask () const
 
bool IsImmunedToDamageOrSchool (SpellSchoolMask schoolMask) const
 
bool IsImmunedToAuraPeriodicTick (Unit const *caster, SpellInfo const *spellInfo) const
 
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
 
float ApplyEffectModifiers (SpellInfo const *spellProto, uint8 effect_index, float value) const
 
float CalculateLevelPenalty (SpellInfo const *spellProto) const
 
uint32 GetCastingTimeForBonus (SpellInfo const *spellProto, DamageEffectType damagetype, uint32 CastingTime) const
 
void CastDelayedSpellWithPeriodicAmount (Unit *caster, uint32 spellId, AuraType auraType, int32 addAmount, uint8 effectIndex=0, TriggerCastFlags extraTriggerFlags=TRIGGERED_NONE)
 
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)
 
SpellCastResult CastCustomSpell (SpellInfo const *spellInfo, CustomSpellValues const &value, Unit *victim=nullptr, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=nullptr, AuraEffect const *triggeredByAura=nullptr, ObjectGuid originalCaster=ObjectGuid::Empty)
 
void _RegisterDynObject (DynamicObject *dynObj)
 
void _UnregisterDynObject (DynamicObject *dynObj)
 
DynamicObject * GetDynObject (uint32 spellId)
 
bool RemoveDynObject (uint32 spellId)
 
void RemoveAllDynObjects ()
 
GameObject * GetGameObject (uint32 spellId) const
 
void AddGameObject (GameObject *gameObj)
 
void RemoveGameObject (GameObject *gameObj, bool del)
 
void RemoveGameObject (uint32 spellid, bool del)
 
void RemoveGameObjectsByType (GameobjectTypes type, bool del)
 
void RemoveAllGameObjects ()
 
bool IsPolymorphed () const
 
bool isFrozen () const
 
bool IsInFlight () const
 
bool IsLevitating () const
 
bool IsWalking () const
 
bool isMoving () const
 
bool isTurning () const
 
bool IsHovering () const
 
bool isSwimming () const
 
bool IsFlying () const
 
bool IsFalling () const
 
bool IsRooted () const
 
float GetHoverHeight () const
 
bool IsActionPreventedByCasting () const
 
bool CanFreeMove () const
 
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 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)
 
void SendSpeedToController (UnitMoveType mtype, Player *target) const
 
void propagateSpeedChange ()
 
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 SetDisableGravity (bool disable)
 
void SetCanFly (bool enable)
 Add the movement flag: MOVEMENTFLAGCAN_FLY. Generaly only use by players, allowing them to fly by pressing space for example. For creatures, please look for DisableGravity().
 
void SetWaterWalking (bool enable)
 
void SetFeatherFall (bool enable)
 
void SetHover (bool enable)
 
MotionMaster * GetMotionMaster ()
 
MotionMaster const * GetMotionMaster () const
 
bool IsStopped () const
 
void StopMoving ()
 
void StopMovingOnCurrentPos ()
 
virtual void PauseMovement (uint32 timer=0, uint8 slot=0)
 Disable the unit movement by clearing UNIT_STATE_MOVING and stopping the spline.
 
void ResumeMovement (uint32 timer=0, uint8 slot=0)
 
void SetControlled (bool apply, UnitState state, Unit *source=nullptr, bool isFear=false)
 
void DisableRotate (bool apply)
 
void DisableSpline ()
 
SheathState GetSheath () const
 
virtual void SetSheath (SheathState sheathed)
 
uint8 getStandState () const
 
bool IsSitState () const
 
bool IsStandState () const
 
bool IsStandUpOnMovementState () const
 
void SetStandState (uint8 state)
 
void SetStandFlags (uint8 flags)
 
void RemoveStandFlags (uint8 flags)
 
DeathState getDeathState ()
 
Milliseconds GetLastDeathTime () const
 
bool IsInPreDeathAuraTick () const
 
void SetInPreDeathAuraTick (bool value)
 
bool IsAlive () const
 
bool isDying () const
 
bool isDead () const
 
bool HasGhostAura () const
 
bool HasMountedAura () const
 
bool HasWaterWalkAura () const
 
bool HasFeatherFallAura () const
 
bool HasHoverAura () const
 
bool HasFlyAura () const
 
bool HasSpiritOfRedemptionAura () const
 
bool HasPreventsFleeingAura () const
 
bool HasPreventDurabilityLossAura () const
 
bool HasPreventResurectionAura () const
 
bool HasTransformAura () const
 
bool HasInterruptRegenAura () const
 
bool HasNoPVPCreditAura () const
 
bool HasWaterBreathingAura () const
 
bool HasIgnoreHitDirectionAura () const
 
bool HasSpellMagnetAura () const
 
bool HasOpenStableAura () const
 
bool HasCloneCasterAura () const
 
bool HasReflectSpellsAura () const
 
bool HasDetectAmoreAura () const
 
bool HasAllowOnlyAbilityAura () const
 
bool HasPeriodicDummyAura () const
 
bool HasControlVehicleAura () const
 
bool HasAOECharmAura () const
 
bool HasDetectSpellsAura () const
 
bool HasPacifySilenceAura () const
 
bool HasSilenceAura () const
 
bool HasShapeshiftAura () const
 
bool HasDecreaseSpeedAura () const
 
bool HasPacifyAura () const
 
bool HasIgnoreTargetResistModifiersAura () const
 
bool HasIncreaseMountedSpeedAura () const
 
bool HasIncreaseMountedFlightSpeedAura () const
 
bool HasAttackerSpellCritChanceAura () const
 
bool HasUnattackableAura () const
 
bool HasHealthRegenInCombatAura () const
 
bool HasRegenDuringCombatAura () const
 
bool HasFearAura () const
 
bool HasConfuseAura () const
 
bool HasRootAura () const
 
bool HasStunAura () const
 
bool HasTauntAura () const
 
bool HasStealthAura () const
 
bool HasStealthDetectAura () const
 
bool HasInvisibilityAura () const
 
bool HasInvisibilityDetectAura () const
 
bool IsHostileTo (Unit const *unit) const
 
bool IsHostileToPlayers () const
 
bool IsFriendlyTo (Unit const *unit) const
 
bool IsNeutralToAll () const
 
void ClearAllReactives ()
 
void StartReactiveTimer (ReactiveType reactive)
 
void UpdateReactives (uint32 p_time)
 
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 ()
 
bool IsInPartyWith (Unit const *unit) const
 
bool IsInRaidWith (Unit const *unit) const
 
void GetPartyMembers (std::list< Unit * > &units)
 
Unit * GetNextRandomRaidMemberOrPet (float radius)
 
void UpdateAuraForGroup (uint8 slot)
 
ReputationRank GetReactionTo (Unit const *target, bool checkOriginalFaction=false) const
 
ReputationRank GetFactionReactionTo (FactionTemplateEntry const *factionTemplateEntry, Unit const *target) const
 
SharedVisionList const & GetSharedVisionList ()
 
void AddPlayerToVision (Player *player)
 
void RemovePlayerFromVision (Player *player)
 
bool HasSharedVision () const
 
uint32 GetVirtualItemId (uint32 slot) const
 
void SetVirtualItem (uint32 slot, uint32 itemId)
 
bool IsMounted () const
 
uint32 GetMountID () const
 
void Mount (uint32 mount, uint32 vehicleId=0, uint32 creatureEntry=0)
 
void Dismount ()
 
bool IsInDisallowedMountForm () const
 
void FollowerAdded (AbstractFollower *f)
 
void FollowerRemoved (AbstractFollower *f)
 
void RemoveAllFollowers ()
 
Guardian * GetGuardianPet () const
 
Minion * GetFirstMinion () const
 
Creature * GetCompanionPet () const
 
Pet * CreateTamedPetFrom (Creature *creatureTarget, uint32 spell_id=0)
 
Pet * CreateTamedPetFrom (uint32 creatureEntry, uint32 spell_id=0)
 
bool InitTamedPet (Pet *pet, uint8 level, uint32 spell_id)
 
void SetMinion (Minion *minion, bool apply)
 
void GetAllMinionsByEntry (std::list< Creature * > &Minions, uint32 entry)
 
void RemoveAllMinionsByEntry (uint32 entry)
 
void AddPetAura (PetAura const *petSpell)
 
void RemovePetAura (PetAura const *petSpell)
 
void CastPetAura (PetAura const *aura)
 
bool IsPetAura (Aura const *aura)
 
void PetSpellFail (SpellInfo const *spellInfo, Unit *target, uint32 result)
 
void UnsummonAllTotems (bool onDeath=false)
 
TransportBase * GetDirectTransport () const
 
bool CreateVehicleKit (uint32 id, uint32 creatureEntry)
 Returns the transport this unit is on directly (if on vehicle and transport, return vehicle)
 
void RemoveVehicleKit ()
 
Vehicle * GetVehicleKit () const
 
Vehicle * GetVehicle () const
 
bool IsOnVehicle (Unit const *vehicle) const
 
Unit * GetVehicleBase () const
 
Creature * GetVehicleCreatureBase () const
 
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)
 
bool HandleSpellClick (Unit *clicker, int8 seatId=-1)
 
void _ExitVehicle (Position const *exitPosition=nullptr)
 
void _EnterVehicle (Vehicle *vehicle, int8 seatId, AuraApplication const *aurApp=nullptr)
 
void HandleEmoteCommand (uint32 emoteId)
 
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)
 
ShapeshiftForm GetShapeshiftForm () const
 
void SetShapeshiftForm (ShapeshiftForm form)
 
bool IsAttackSpeedOverridenShapeShift () const
 
bool IsInFeralForm () const
 
void setTransForm (uint32 spellid)
 
uint32 getTransForm () const
 
void DeMorph ()
 
virtual void RecalculateObjectScale ()
 
uint32 GetDisplayId () const
 
uint32 GetNativeDisplayId () const
 
void RestoreDisplayId ()
 
void SetNativeDisplayId (uint32 displayId)
 
uint32 GetModelForForm (ShapeshiftForm form, uint32 spellId)
 
virtual bool IsInWater () const
 
virtual bool IsUnderWater () const
 
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 SetInFront (WorldObject const *target)
 
void SetFacingTo (float ori)
 
void SetFacingToObject (WorldObject *object, Milliseconds timed=0ms)
 
bool isInAccessiblePlaceFor (Creature const *c) const
 
bool isInFrontInMap (Unit const *target, float distance, float arc=M_PI) const
 
bool isInBackInMap (Unit const *target, float distance, float arc=M_PI) const
 
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 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.
 
virtual bool UpdatePosition (float x, float y, float z, float ang, bool teleport=false)
 
bool UpdatePosition (Position const &pos, bool teleport=false)
 
void ProcessPositionDataChanged (PositionFullTerrainStatus const &data) override
 
virtual void ProcessTerrainStatusUpdate ()
 
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
 
void AddPointedBy (SafeUnitPointer *sup)
 
void RemovePointedBy (SafeUnitPointer *sup)
 
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 SendComboPoints ()
 
void SendPlaySpellVisual (uint32 id)
 
void SendPlaySpellImpact (ObjectGuid guid, uint32 id)
 
void SendPetActionFeedback (uint8 msg) const
 -------—Pet responses methods--------------—
 
void SendPetActionSound (PetAction action) const
 
void SendPetDismissSound () const
 
void SendPetAIReaction (ObjectGuid guid) const
 
void SendPeriodicAuraLog (SpellPeriodicAuraLogInfo *pInfo)
 
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 SendSpellDamageResist (Unit *target, uint32 spellId)
 
void SendSpellDamageImmune (Unit *target, uint32 spellId)
 
void SendTameFailure (uint8 result)
 
void SendTeleportPacket (Position &pos)
 
void SendMovementFlagUpdate (bool self=false)
 
void SendMovementWaterWalking (Player *sendTo)
 
void SendMovementFeatherFall (Player *sendTo)
 
void SendMovementHover (Player *sendTo)
 
void SendClearTarget ()
 
void ExecuteDelayedUnitRelocationEvent ()
 
void ExecuteDelayedUnitAINotifyEvent ()
 
void BuildHeartBeatMsg (WorldPacket *data) const
 
void BuildMovementPacket (ByteBuffer *data) const
 
void OutDebugInfo () const
 
std::string GetDebugInfo () const override
 
SpellCastResult CastSpell (CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={})
 
SpellCastResult CastSpell (CastSpellTargetArg const &targets, SpellInfo const *info, CastSpellExtraArgs const &args={})
 
bool IsHostileTo (WorldObject const *target) const
 
bool IsFriendlyTo (WorldObject const *target) const
 
- Public Member Functions inherited from WorldObject
 ~WorldObject () override
 
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
 
void UpdateGroundPositionZ (float x, float y, float &z) const
 
void UpdateAllowedPositionZ (float x, float y, float &z, float *groundZ=nullptr) const
 
void GetRandomPoint (Position const &srcPos, float distance, float &rand_x, float &rand_y, float &rand_z) const
 
Position GetRandomPoint (Position const &srcPos, float distance) const
 
uint32 GetInstanceId () const
 
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
 
InstanceScript * GetInstanceScript () const
 
std::string const & GetName () const
 
void SetName (std::string const &newname)
 
float GetDistance (WorldObject const *obj) const
 
float GetDistance (Position const &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 (Position const *pos, float dist) const
 
bool IsWithinDist2d (float x, float y, float dist) const
 
bool IsWithinDist2d (Position const *pos, float dist) const
 
virtual bool IsWithinSightRange (Position const &pos, float dist) const
 
bool IsWithinDist (WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
 
bool IsWithinDistInMap (WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=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 SendMessageToSet (WorldPacket const *data, bool self) const
 
virtual void SendMessageToSetInRange (WorldPacket const *data, float dist, bool self) const
 
virtual void SendMessageToSet (WorldPacket const *data, Player const *skipped_rcvr) const
 
void PlayDistanceSound (uint32 sound_id, Player *target=nullptr)
 
void PlayDirectSound (uint32 sound_id, Player *target=nullptr)
 
void PlayRadiusSound (uint32 sound_id, float radius)
 
void PlayDirectMusic (uint32 music_id, Player *target=nullptr)
 
void PlayRadiusMusic (uint32 music_id, float radius)
 
template<typename Worker >
void DoForAllVisiblePlayers (Worker &&worker)
 
template<typename Worker >
void DoForAllVisibleWorldObjects (Worker &&worker)
 
void DestroyForVisiblePlayers ()
 
void SendObjectDeSpawnAnim (ObjectGuid guid)
 
void AddObjectToRemoveList ()
 
float GetGridActivationRange () const
 
float GetVisibilityRange () const
 
virtual float GetSightRange (WorldObject const *target=nullptr) const
 
float GetLeewayBonusRange (Unit const *target) const
 
float GetLeewayBonusRadius () 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 ()
 
Map * GetMap () const
 
Map * FindMap () const
 
void SetZoneScript ()
 
void ClearZoneScript ()
 
ZoneScript * GetZoneScript () const
 
TempSummon * SummonCreature (uint32 id, Position const &pos, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0, uint32 vehId=0, SummonPropertiesEntry const *properties=nullptr, bool visibleBySummonerOnly=false) const
 
TempSummon * SummonCreature (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)
 
GameObject * SummonGameObject (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)
 
Creature * SummonTrigger (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)
 
void SummonGameObjectGroup (uint8 group, std::list< GameObject * > *list=nullptr)
 
Creature * FindNearestCreature (uint32 entry, float range, bool alive=true) const
 
GameObject * FindNearestGameObject (uint32 entry, float range, bool onlySpawned=false) const
 
GameObject * FindNearestGameObjectOfType (GameobjectTypes type, float range) const
 
Player * SelectNearestPlayer (float distance=0) const
 
void GetGameObjectListWithEntryInGrid (std::list< GameObject * > &lList, uint32 uiEntry, float fMaxSearchRange) const
 
void GetGameObjectListWithEntryInGrid (std::list< GameObject * > &gameobjectList, std::vector< uint32 > const &entries, float maxSearchRange) const
 
void GetCreatureListWithEntryInGrid (std::list< Creature * > &lList, uint32 uiEntry, float fMaxSearchRange) const
 
void GetCreatureListWithEntryInGrid (std::list< Creature * > &creatureList, std::vector< uint32 > const &entries, float maxSearchRange) const
 
void GetDeadCreatureListInGrid (std::list< Creature * > &lList, float maxSearchRange, bool alive=false) const
 
void BuildUpdate (UpdateDataMapType &data_map) override
 
void GetCreaturesWithEntryInRange (std::list< Creature * > &creatureList, float radius, uint32 entry)
 
void SetPositionDataUpdate ()
 
void UpdatePositionData ()
 
bool IsPositionDataUpdatePending () const
 
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)
 
VisibilityDistanceType GetVisibilityOverrideType () const
 
bool IsVisibilityOverridden () const
 
bool IsZoneWideVisible () const
 
bool IsFarVisible () const
 
float GetVisibilityOverrideDistance () const
 
void SetVisibilityDistanceOverride (VisibilityDistanceType type)
 
bool IsInWintergrasp () const
 
Transport * GetTransport () const
 
float GetTransOffsetX () const
 
float GetTransOffsetY () const
 
float GetTransOffsetZ () const
 
float GetTransOffsetO () const
 
uint32 GetTransTime () const
 
int8 GetTransSeat () const
 
void SetTransport (Transport *t)
 
virtual float GetStationaryX () const
 
virtual float GetStationaryY () const
 
virtual float GetStationaryZ () const
 
virtual float GetStationaryO () const
 
float GetMapWaterOrGroundLevel (Position pos, float *ground=nullptr) 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.
 
void AddAllowedLooter (ObjectGuid guid)
 
void ResetAllowedLooters ()
 
void SetAllowedLooters (GuidUnorderedSet const looters)
 
bool HasAllowedLooter (ObjectGuid guid) const
 
GuidUnorderedSet const & GetAllowedLooters () const
 
void RemoveAllowedLooter (ObjectGuid guid)
 
bool CanBeAddedToMapUpdateList ()
 
std::string GetDebugInfo () const override
 
ObjectVisibilityContainer & GetObjectVisibilityContainer ()
 
ObjectVisibilityContainer const & GetObjectVisibilityContainer () const
 
SpellCastResult CastSpell (CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={})
 
SpellCastResult CastSpell (CastSpellTargetArg const &targets, SpellInfo const *info, CastSpellExtraArgs const &args={})
 
Unit * GetOwnerUnit () const
 
Unit * GetCharmerOrOwnerUnit () const
 
Unit * GetCharmerOrOwnerOrSelfUnit () const
 
Player * GetCharmerOrOwnerPlayerOrPlayerItself () const
 
Player * GetAffectingPlayer () const
 
FactionTemplateEntry const * GetFactionTemplateEntry () const
 
ReputationRank GetReactionTo (WorldObject const *target) const
 
bool IsHostileTo (WorldObject const *target) const
 
bool IsFriendlyTo (WorldObject const *target) const
 
float GetSpellMaxRangeForTarget (Unit const *target, SpellInfo const *spellInfo) const
 
float GetSpellMinRangeForTarget (Unit const *target, SpellInfo const *spellInfo) const
 
bool IsValidAttackTarget (WorldObject const *target, SpellInfo const *bySpell=nullptr) const
 
bool IsValidAssistTarget (WorldObject const *target, SpellInfo const *bySpell=nullptr) const
 
Unit * GetMagicHitRedirectTarget (Unit *victim, SpellInfo const *spellInfo)
 
Unit * GetMeleeHitRedirectTarget (Unit *victim, SpellInfo const *spellInfo)
 
int32 CalculateSpellDamage (Unit const *target, SpellInfo const *spellProto, uint8 effect_index, int32 const *basePoints=nullptr) const
 
int32 CalcSpellDuration (SpellInfo const *spellProto) const
 
int32 ModSpellDuration (SpellInfo const *spellProto, Unit const *target, int32 duration, bool positive, uint32 effectMask) const
 
void ModSpellCastTime (SpellInfo const *spellProto, int32 &castTime, Spell *spell=nullptr) const
 
SpellMissInfo MagicSpellHitResult (Unit *victim, SpellInfo const *spellInfo)
 
SpellMissInfo SpellHitResult (Unit *victim, SpellInfo const *spellInfo, bool canReflect=false)
 
SpellMissInfo SpellHitResult (Unit *victim, Spell const *spell, bool canReflect=false)
 
void SendSpellMiss (Unit *target, uint32 spellID, SpellMissInfo missInfo)
 
void SendSpellNonMeleeDamageLog (Unit *target, SpellInfo const *spellInfo, uint32 damage, SpellSchoolMask schoolMask, uint32 absorb, uint32 resist)
 
- Public Member Functions inherited from Object
virtual ~Object ()
 
bool IsInWorld () const
 
ObjectGuid GetGUID () const
 
PackedGuid const & GetPackGUID () const
 
uint32 GetEntry () const
 
void SetEntry (uint32 entry)
 
float GetObjectScale () const
 
bool HasDynamicFlag (uint32 flag) const
 
virtual void SetDynamicFlag (uint32 flag)
 
virtual void RemoveDynamicFlag (uint32 flag)
 
TypeID GetTypeId () const
 
bool isType (uint16 mask) const
 
virtual void BuildCreateUpdateBlockForPlayer (UpdateData *data, Player *target)
 
void SendUpdateToPlayer (Player *player)
 
void BuildValuesUpdateBlockForPlayer (UpdateData *data, Player *target)
 
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 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
 
void BuildFieldsUpdate (Player *, UpdateDataMapType &)
 
void SetFieldNotifyFlag (uint16 flag)
 
void RemoveFieldNotifyFlag (uint16 flag)
 
void ForceValuesUpdateAtIndex (uint32)
 
bool IsPlayer () const
 
Player * ToPlayer ()
 
Player const * ToPlayer () const
 
bool IsCreature () const
 
Creature * ToCreature ()
 
Creature const * ToCreature () const
 
bool IsUnit () const
 
Unit * ToUnit ()
 
Unit const * ToUnit () const
 
bool IsGameObject () const
 
GameObject * ToGameObject ()
 
GameObject const * ToGameObject () const
 
bool IsCorpse () const
 
Corpse * ToCorpse ()
 
Corpse const * ToCorpse () const
 
bool IsDynamicObject () const
 
DynamicObject * ToDynObject ()
 
DynamicObject const * ToDynObject () const
 
bool IsItem () const
 
virtual void Heartbeat ()
 
template<typename... T>
bool EntryEquals (T... entries) 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 (WorldLocation const &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
 
Position & operator= (Position const &)=default
 
Position & operator= (Position &&)=default
 
bool operator== (Position const &a) const
 
bool operator!= (Position const &a)
 
bool operator!= (Position const &a) const
 
 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 (Position const &pos)
 
void Relocate (Position const *pos)
 
void RelocatePolarOffset (float angle, float dist, float z=0.0f)
 
void RelocateOffset (Position const &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 (Position const &endPos, Position &retOffset) const
 
Position GetPositionWithOffset (Position const &offset) const
 
float GetAngle (Position const *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 (Position const *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 (Position const *pos, float dist) const
 
bool IsInDist (float x, float y, float z, float dist) const
 
bool IsInDist (Position const *pos, float dist) const
 
bool IsWithinBox (Position const &center, float xradius, float yradius, float zradius) const
 
bool HasInArc (float arcangle, Position const *pos, float targetRadius=0.0f) const
 
bool HasInLine (Position const *pos, float width) const
 
bool HasInLine (Position const *pos, float objSize, 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 *, PetSaveMode > GetLoadPetInfo (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 void ApplyResilience (Unit const *victim, float *crit, int32 *damage, bool isCrit, CombatRating type)
 
static float GetEffectiveResistChance (Unit const *owner, SpellSchoolMask schoolMask, Unit const *victim, SpellInfo const *spellInfo=nullptr, uint8 casterLevel=0)
 
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, bool skipCombat=false)
 
static void DealDamageMods (Unit const *victim, uint32 &damage, uint32 *absorb)
 
static void Kill (Unit *killer, Unit *victim, bool durabilityLoss=true, WeaponAttackType attackType=BASE_ATTACK, SpellInfo const *spellProto=nullptr, Spell const *spell=nullptr)
 
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 uint32 SpellCriticalDamageBonus (Unit const *caster, SpellInfo const *spellProto, uint32 damage, Unit const *victim)
 
static void ProcSkillsAndAuras (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 int32 DealHeal (Unit *healer, Unit *victim, uint32 addhealth)
 
static uint32 SpellCriticalHealingBonus (Unit const *caster, SpellInfo const *spellProto, uint32 damage, Unit const *victim)
 
static void CalcAbsorbResist (DamageInfo &dmgInfo, bool Splited=false, uint8 casterLevel=0)
 
static void CalcHealAbsorb (HealInfo &healInfo)
 
static bool IsImmuneMaskFully (SpellSchoolMask immuneMask, SpellSchoolMask schoolMask)
 
static ReputationRank GetFactionReactionTo (FactionTemplateEntry const *factionTemplateEntry, FactionTemplateEntry const *targetFactionTemplateEntry)
 
static void HandleSafeUnitPointersOnDelete (Unit *thisUnit)
 
- Static Public Member Functions inherited from WorldObject
static float GetLeewayBonusRangeForTargets (Player const *player, Unit const *target)
 
static ReputationRank GetFactionReactionTo (FactionTemplateEntry const *factionTemplateEntry, WorldObject const *target)
 
- 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
SummonPropertiesEntry const *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
 
uint32 m_moveCircleMovementTime = MOVE_CIRCLE_CHECK_INTERVAL
 
uint32 m_moveBackwardsMovementTime = MOVE_BACKWARDS_CHECK_INTERVAL
 
uint32 m_extendLeashTime = EXTEND_LEASH_CHECK_INTERVAL
 
- Public Attributes inherited from Unit
uint32 m_extraAttacks
 
DualWieldMode _dualWieldMode
 
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_modAttackSpeedPct [3]
 
SpellImmuneContainer m_spellImmune [MAX_SPELL_IMMUNITY]
 
uint32 m_lastSanctuaryTime
 
PetAuraSet m_petAuras
 
ObjectGuid LastCharmerGUID
 
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::MoveSpline * movespline
 
- Public Attributes inherited from WorldObject
FlaggedValuesArray32< int32, uint32, StealthType, TOTAL_STEALTH_TYPES > m_stealth
 
FlaggedValuesArray32< int32, uint32, StealthType, TOTAL_STEALTH_TYPES > m_stealthDetect
 
FlaggedValuesArray32< int32, uint32, InvisibilityType, TOTAL_INVISIBILITY_TYPES > m_invisibility
 
FlaggedValuesArray32< int32, uint32, InvisibilityType, TOTAL_INVISIBILITY_TYPES > m_invisibilityDetect
 
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPES > m_serverSideVisibility
 
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPES > m_serverSideVisibilityDetect
 
uint32 LastUsedScriptID
 
MovementInfo m_movementInfo
 
ALEEventProcessor * ALEEvents
 
EventProcessor m_Events
 
- 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

Player * m_owner
 
int32 m_happinessTimer
 
PetType m_petType
 
Milliseconds m_duration
 
uint64 m_auraRaidUpdateMask
 
bool m_loading
 
Milliseconds m_petRegenTimer
 
std::unique_ptr< DeclinedName > m_declinedname
 
ObjectGuid m_tempspellTarget
 
ObjectGuid m_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
 
bool _respawnCompatibilityMode {true}
 
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_alreadyCallForHelp
 
bool m_AlreadyCallAssistance
 
bool m_AlreadySearchedAssistance
 
bool m_regenHealth
 
bool m_regenPower
 
bool m_AI_locked
 
SpellSchoolMask m_meleeDamageSchoolMask
 
uint32 m_originalEntry
 
int32 _creatureImmunitiesId
 
uint32 _gossipMenuId
 
bool m_moveInLineOfSightDisabled
 
bool m_moveInLineOfSightStrictlyDisabled
 
Position m_homePosition
 
Position m_transportHomePosition
 
Position LastMovementFlagsPos
 
bool DisableReputationReward
 
bool DisableLootReward
 
CreatureTemplate const * m_creatureInfo
 
CreatureData const * m_creatureData
 
uint32 CachedScriptId = 0
 
uint32 CachedScriptIdEntry = 0
 
float m_detectionDistance
 
uint16 m_LootMode
 
float _sparringPct
 
- Protected Attributes inherited from Unit
UnitAI * i_AI
 
UnitAI * i_disabledAI
 
uint8 m_realRace
 
uint8 m_race
 
bool m_AutoRepeatFirstCast
 
int32 m_attackTimer [MAX_ATTACK]
 
float m_createStats [MAX_STATS]
 
AttackerSet m_attackers
 
Unit * m_attacking
 
DeathState m_deathState
 
Milliseconds m_lastDeathTime {Milliseconds::min()}
 
bool m_inPreDeathAuraTick {false}
 
int32 m_procDeep
 
DynObjectList m_dynObj
 
GameObjectList m_gameObj
 
uint32 m_transform
 
Spell * m_currentSpells [CURRENT_MAX_SPELL]
 
AuraMap m_ownedAuras
 
AuraApplicationMap m_appliedAuras
 
AuraList m_removedAuras
 
std::vector< Aura * > m_auraUpdateSnapshot
 
uint32 m_removedAurasCount
 
AuraEffectList m_modAuras [TOTAL_AURAS]
 
AuraList m_scAuras
 
AuraApplicationList m_interruptableAuras
 
AuraStateAurasMap m_auraStateAuras
 
uint32 m_interruptMask
 
float m_auraFlatModifiersGroup [UNIT_MOD_END][MODIFIER_TYPE_FLAT_END]
 
float m_auraPctModifiersGroup [UNIT_MOD_END][MODIFIER_TYPE_PCT_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]
 
float _charmStartSpeedRate [MAX_MOVE_TYPE] {}
 
CharmInfo * m_charmInfo
 
SharedVisionList m_sharedVision
 
MotionMaster * i_motionMaster
 
uint32 m_reactiveTimer [MAX_REACTIVE]
 
int32 m_regenTimer
 
ThreatManager m_threatManager
 
CombatManager m_combatManager
 
CharmThreatMap _charmThreatInfo
 
Vehicle * m_vehicle
 
Vehicle * m_vehicleKit
 
uint32 m_unitTypeMask
 
LiquidTypeEntry const * _lastLiquid
 
bool m_applyResilience
 
bool _instantCast
 
- Protected Attributes inherited from WorldObject
std::string m_name
 
bool m_isActive
 
VisibilityDistanceType _visibilityDistanceOverrideType
 
ZoneScript * m_zoneScript
 
uint32 _zoneId
 
uint32 _areaId
 
float _floorZ
 
bool _outdoors
 
LiquidData _liquidData
 
bool _updatePositionData
 
Transport * m_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
 
void CastPendingSpell ()
 

Additional Inherited Members

- Public Types inherited from Unit
typedef std::unordered_set< Unit * > AttackerSet
 
typedef std::set< Unit * > ControlSet
 
typedef boost::container::flat_multimap< uint32, Aura * > AuraMap
 
typedef std::pair< AuraMap::const_iterator, AuraMap::const_iterator > AuraMapBounds
 
typedef std::pair< AuraMap::iterator, AuraMap::iterator > AuraMapBoundsNonConst
 
typedef boost::container::flat_multimap< uint32, AuraApplication * > AuraApplicationMap
 
typedef std::pair< AuraApplicationMap::const_iterator, AuraApplicationMap::const_iterator > AuraApplicationMapBounds
 
typedef std::pair< AuraApplicationMap::iterator, AuraApplicationMap::iterator > AuraApplicationMapBoundsNonConst
 
typedef boost::container::flat_multimap< AuraStateType, AuraApplication * > AuraStateAurasMap
 
typedef std::pair< AuraStateAurasMap::const_iterator, AuraStateAurasMap::const_iterator > AuraStateAurasMapBounds
 
typedef std::vector< AuraEffect * > AuraEffectList
 
typedef std::list< Aura * > AuraList
 
typedef std::list< AuraApplication * > AuraApplicationList
 
typedef std::vector< std::pair< uint8, AuraApplication * > > AuraApplicationProcContainer
 
typedef std::list< DiminishingReturn > Diminishing
 
typedef GuidUnorderedSet ComboPointHolderSet
 
typedef std::map< uint8, AuraApplication * > VisibleAuraMap
 
typedef std::unordered_multimap< uint32, uint32 > SpellImmuneContainer
 
typedef std::set< PetAura const * > PetAuraSet
 
- Public Types inherited from UpdatableMapObject
enum  UpdateState : uint8 {
  NotUpdating ,
  PendingAdd ,
  Updating
}
 
- Static Public Attributes inherited from Creature
static constexpr uint32 MOVE_CIRCLE_CHECK_INTERVAL = 3000
 
static constexpr uint32 MOVE_BACKWARDS_CHECK_INTERVAL = 2000
 
static constexpr uint32 EXTEND_LEASH_CHECK_INTERVAL = 3000
 
- 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, CreatureData const *data=nullptr)
 
bool InitEntry (uint32 entry, CreatureData const *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 ()
 
void BuildValuesUpdate (uint8 updateType, ByteBuffer *data, Player *target) override
 
void _UpdateSpells (uint32 time)
 
void _DeleteRemovedAuras ()
 
void _UpdateAutoRepeatSpell ()
 
bool CanSparringWith (Unit const *attacker) const
 
bool IsAlwaysVisibleFor (WorldObject const *seer) const override
 : Check if unit is eligible for sparring damages. Work only if attacker and victim are creatures.
 
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 stun=false, bool logout=false)
 
void SendMoveRoot (bool state)
 
- Protected Member Functions inherited from WorldObject
 WorldObject ()
 
void SetLocationMapId (uint32 _mapId)
 
void SetLocationInstanceId (uint32 _instanceId)
 
virtual bool IsNeverVisible () const
 
- Protected Member Functions inherited from Object
 Object ()
 
void _InitValues ()
 
void _Create (ObjectGuid::LowType guidlow, uint32 entry, HighGuid guidhigh)
 
void _Create (ObjectGuid guid)
 
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
 
void AddToObjectUpdateIfNeeded ()
 
- Protected Member Functions inherited from MovableMapObject
 MovableMapObject ()=default
 
Cell const & GetCurrentCell () const
 
- Protected Member Functions inherited from UpdatableMapObject
 UpdatableMapObject ()
 
- 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
41 : Guardian(nullptr, owner ? owner->GetGUID() : ObjectGuid::Empty),
43 m_removed(false),
44 m_owner(owner),
46 m_petType(type),
47 m_duration(0),
49 m_loading(false),
55{
57
59
60 if (type == HUNTER_PET)
62
64 {
67 }
68
69 m_name = "Pet";
70}
constexpr Milliseconds PET_FOCUS_REGEN_INTERVAL
Definition CreatureData.h:38
#define ASSERT
Definition Errors.h:68
@ HUNTER_PET
Definition PetDefines.h:33
constexpr auto PET_LOSE_HAPPINES_INTERVAL
Definition Pet.h:25
@ UNIT_MASK_HUNTER_PET
Definition UnitDefines.h:166
@ UNIT_MASK_CONTROLLABLE_GUARDIAN
Definition UnitDefines.h:167
@ UNIT_MASK_PET
Definition UnitDefines.h:163
Definition TemporarySummon.h:106
Definition ObjectGuid.h:121
bool IsPlayer() const
Definition Object.h:207
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:120
PetType m_petType
Definition Pet.h:152
bool m_loading
Definition Pet.h:155
uint32 m_usedTalentCount
Definition Pet.h:133
Player * m_owner
Definition Pet.h:150
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
ObjectGuid m_tempspellTarget
Definition Pet.h:160
ObjectGuid m_tempoldTarget
Definition Pet.h:161
uint32 m_unitTypeMask
Definition Unit.h:2228
CharmInfo * InitCharmInfo()
Definition Unit.cpp:12346
std::string m_name
Definition Object.h:799

References ASSERT, HUNTER_PET, Unit::InitCharmInfo(), Object::IsPlayer(), WorldObject::m_name, m_owner, Unit::m_unitTypeMask, UNIT_MASK_CONTROLLABLE_GUARDIAN, UNIT_MASK_HUNTER_PET, and UNIT_MASK_PET.

◆ ~Pet()

Pet::~Pet ( )
overridedefault

Member Function Documentation

◆ _LoadAuras()

void Pet::_LoadAuras ( PreparedQueryResult  result,
uint32  timediff 
)
1633{
1634 LOG_DEBUG("entities.pet", "Loading auras for pet {}", GetGUID().ToString());
1635
1636 if (result)
1637 {
1638 do
1639 {
1640 int32 damage[3];
1641 int32 baseDamage[3];
1642 Field* fields = result->Fetch();
1643 ObjectGuid caster_guid = ObjectGuid(fields[0].Get<uint64>());
1644 // nullptr guid stored - pet is the caster of the spell - see Pet::_SaveAuras
1645 if (!caster_guid)
1646 caster_guid = GetGUID();
1647 uint32 spellid = fields[1].Get<uint32>();
1648 uint8 effmask = fields[2].Get<uint8>();
1649 uint8 recalculatemask = fields[3].Get<uint8>();
1650 uint8 stackcount = fields[4].Get<uint8>();
1651 damage[0] = fields[5].Get<int32>();
1652 damage[1] = fields[6].Get<int32>();
1653 damage[2] = fields[7].Get<int32>();
1654 baseDamage[0] = fields[8].Get<int32>();
1655 baseDamage[1] = fields[9].Get<int32>();
1656 baseDamage[2] = fields[10].Get<int32>();
1657 int32 maxduration = fields[11].Get<int32>();
1658 int32 remaintime = fields[12].Get<int32>();
1659 uint8 remaincharges = fields[13].Get<uint8>();
1660
1661 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellid);
1662 if (!spellInfo)
1663 {
1664 LOG_ERROR("entities.pet", "Unknown aura (spellid {}), ignore.", spellid);
1665 continue;
1666 }
1667
1668 // avoid higher level auras if any, and adjust
1669 SpellInfo const* scaledSpellInfo = spellInfo->GetAuraRankForLevel(GetLevel());
1670 if (scaledSpellInfo != spellInfo)
1671 spellInfo = scaledSpellInfo;
1672
1673 // again after level check
1674 if (!spellInfo)
1675 continue;
1676
1677 // negative effects should continue counting down after logout
1678 if (remaintime != -1 && (!spellInfo->IsPositive() || spellInfo->HasAttribute(SPELL_ATTR4_AURA_EXPIRES_OFFLINE)))
1679 {
1680 if (remaintime / IN_MILLISECONDS <= int32(timediff))
1681 {
1682 continue;
1683 }
1684
1685 remaintime -= timediff * IN_MILLISECONDS;
1686 }
1687
1688 // prevent wrong values of remaincharges
1689 if (spellInfo->ProcCharges)
1690 {
1691 if (remaincharges <= 0 || remaincharges > spellInfo->ProcCharges)
1692 remaincharges = spellInfo->ProcCharges;
1693 }
1694 else
1695 remaincharges = 0;
1696
1697 if (Aura* aura = Aura::TryCreate(spellInfo, effmask, this, nullptr, &baseDamage[0], nullptr, caster_guid))
1698 {
1699 if (!aura->CanBeSaved())
1700 {
1701 aura->Remove();
1702 continue;
1703 }
1704 aura->SetLoadedState(maxduration, remaintime, remaincharges, stackcount, recalculatemask, &damage[0]);
1705 aura->ApplyForTargets();
1706 LOG_DEBUG("entities.pet", "Added aura spellid {}, effectmask {}", spellInfo->Id, effmask);
1707 }
1708 } while (result->NextRow());
1709 }
1710}
constexpr auto IN_MILLISECONDS
Definition Common.h:53
std::int32_t int32
Definition Define.h:103
std::uint8_t uint8
Definition Define.h:109
std::uint32_t uint32
Definition Define.h:107
#define LOG_ERROR(filterType__,...)
Definition Log.h:145
#define LOG_DEBUG(filterType__,...)
Definition Log.h:157
@ SPELL_ATTR4_AURA_EXPIRES_OFFLINE
Definition SharedDefines.h:520
#define sSpellMgr
Definition SpellMgr.h:851
Definition SpellAuras.h:88
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:296
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:121
Definition SpellInfo.h:340
uint32 ProcCharges
Definition SpellInfo.h:381
SpellInfo const * GetAuraRankForLevel(uint8 level) const
Definition SpellInfo.cpp:2973
uint8 GetLevel() const
Definition Unit.h:1117
std::string ToString() const
Definition Position.cpp:59

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

◆ _LoadSpellCooldowns()

void Pet::_LoadSpellCooldowns ( PreparedQueryResult  result)
1510{
1512
1513 if (result)
1514 {
1515 time_t curTime = GameTime::GetGameTime().count();
1516
1517 PacketCooldowns cooldowns;
1518 WorldPacket data;
1519
1520 do
1521 {
1522 Field* fields = result->Fetch();
1523
1524 uint32 spell_id = fields[0].Get<uint32>();
1525 uint16 category = fields[1].Get<uint16>();
1526 time_t db_time = time_t(fields[2].Get<uint32>());
1527
1528 if (!sSpellMgr->GetSpellInfo(spell_id))
1529 {
1530 LOG_ERROR("entities.pet", "Pet {} have unknown spell {} in `pet_spell_cooldown`, skipping.", m_charmInfo->GetPetNumber(), spell_id);
1531 continue;
1532 }
1533
1534 // skip outdated cooldown
1535 if (db_time <= curTime)
1536 continue;
1537
1538 uint32 cooldown = (db_time - curTime) * IN_MILLISECONDS;
1539 cooldowns[spell_id] = cooldown;
1540 _AddCreatureSpellCooldown(spell_id, category, cooldown);
1541
1542 LOG_DEBUG("entities.pet", "Pet (Number: {}) spell {} cooldown loaded ({} secs).", m_charmInfo->GetPetNumber(), spell_id, uint32(db_time - curTime));
1543 } while (result->NextRow());
1544
1545 if (!cooldowns.empty() && GetOwner())
1546 {
1548 GetOwner()->SendDirectMessage(&data);
1549 }
1550 }
1551}
std::uint16_t uint16
Definition Define.h:108
@ SPELL_COOLDOWN_FLAG_NONE
Definition Unit.h:638
std::unordered_map< uint32, uint32 > PacketCooldowns
Definition Unit.h:643
void _AddCreatureSpellCooldown(uint32 spell_id, uint16 categoryId, uint32 end_time)
Definition Creature.cpp:3005
CreatureSpellCooldowns m_CreatureSpellCooldowns
Definition Creature.h:256
Player * GetOwner() const
Definition Pet.cpp:2497
void SendDirectMessage(WorldPacket const *data) const
Definition Player.cpp:5886
CharmInfo * m_charmInfo
Definition Unit.h:2212
void BuildCooldownPacket(WorldPacket &data, uint8 flags, uint32 spellId, uint32 cooldown)
Definition Unit.cpp:16747
Definition WorldPacket.h:26
Seconds GetGameTime()
Definition GameTime.cpp:39
uint32 GetPetNumber() const
Definition CharmInfo.h:132

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

◆ _LoadSpells()

void Pet::_LoadSpells ( PreparedQueryResult  result)
1588{
1589 if (result)
1590 {
1591 do
1592 {
1593 Field* fields = result->Fetch();
1594
1595 addSpell(fields[0].Get<uint32>(), ActiveStates(fields[1].Get<uint8>()), PETSPELL_UNCHANGED);
1596 } while (result->NextRow());
1597 }
1598}
ActiveStates
Definition CharmInfo.h:60
@ PETSPELL_UNCHANGED
Definition PetDefines.h:58
bool addSpell(uint32 spellId, ActiveStates active=ACT_DECIDE, PetSpellState state=PETSPELL_NEW, PetSpellType type=PETSPELL_NORMAL)
Definition Pet.cpp:1794

References addSpell(), and PETSPELL_UNCHANGED.

◆ _SaveAuras()

void Pet::_SaveAuras ( CharacterDatabaseTransaction  trans)
1713{
1715 stmt->SetData(0, m_charmInfo->GetPetNumber());
1716 trans->Append(stmt);
1717
1718 for (AuraMap::const_iterator itr = m_ownedAuras.begin(); itr != m_ownedAuras.end(); ++itr)
1719 {
1720 // check if the aura has to be saved
1721 if (!itr->second->CanBeSaved() || IsPetAura(itr->second))
1722 continue;
1723
1724 Aura* aura = itr->second;
1725 if (aura->GetDuration() < 60 * IN_MILLISECONDS)
1726 continue;
1727
1728 // dont save infinite negative auras! (lavas, transformations etc)
1729 if (aura->IsPermanent() && !aura->GetSpellInfo()->IsPositive())
1730 continue;
1731
1732 // pussywizard: don't save auras that cannot be cancelled (needed for ICC buff on pets/summons)
1734 continue;
1735
1736 // xinef: don't save hidden auras
1738 continue;
1739
1740 // Xinef: Dont save auras with model change
1742 continue;
1743
1744 // xinef: don's save auras with interrupt flags on map change
1746 continue;
1747
1748 int32 damage[MAX_SPELL_EFFECTS];
1749 int32 baseDamage[MAX_SPELL_EFFECTS];
1750 uint8 effMask = 0;
1751 uint8 recalculateMask = 0;
1752 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1753 {
1754 if (aura->GetEffect(i))
1755 {
1756 baseDamage[i] = aura->GetEffect(i)->GetBaseAmount();
1757 damage[i] = aura->GetEffect(i)->GetAmount();
1758 effMask |= (1 << i);
1759 if (aura->GetEffect(i)->CanBeRecalculated())
1760 recalculateMask |= (1 << i);
1761 }
1762 else
1763 {
1764 baseDamage[i] = 0;
1765 damage[i] = 0;
1766 }
1767 }
1768
1769 // 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
1770 ObjectGuid casterGUID = (itr->second->GetCasterGUID() == GetGUID()) ? ObjectGuid::Empty : itr->second->GetCasterGUID();
1771
1772 uint8 index = 0;
1773
1775 stmt2->SetData(index++, m_charmInfo->GetPetNumber());
1776 stmt2->SetData(index++, casterGUID.GetRawValue());
1777 stmt2->SetData(index++, itr->second->GetId());
1778 stmt2->SetData(index++, effMask);
1779 stmt2->SetData(index++, recalculateMask);
1780 stmt2->SetData(index++, itr->second->GetStackAmount());
1781 stmt2->SetData(index++, damage[0]);
1782 stmt2->SetData(index++, damage[1]);
1783 stmt2->SetData(index++, damage[2]);
1784 stmt2->SetData(index++, baseDamage[0]);
1785 stmt2->SetData(index++, baseDamage[1]);
1786 stmt2->SetData(index++, baseDamage[2]);
1787 stmt2->SetData(index++, itr->second->GetMaxDuration());
1788 stmt2->SetData(index++, itr->second->GetDuration());
1789 stmt2->SetData(index++, itr->second->GetCharges());
1790 trans->Append(stmt2);
1791 }
1792}
@ CHAR_DEL_PET_AURAS
Definition CharacterDatabase.h:480
@ CHAR_INS_PET_AURA
Definition CharacterDatabase.h:484
#define MAX_SPELL_EFFECTS
Definition DBCStructure.h:1673
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition DatabaseEnv.cpp:21
@ SPELL_ATTR1_NO_AURA_ICON
Definition SharedDefines.h:435
@ SPELL_ATTR0_NO_AURA_CANCEL
Definition SharedDefines.h:401
@ SPELL_AURA_TRANSFORM
Definition SpellAuraDefines.h:119
@ AURA_INTERRUPT_FLAG_CHANGE_MAP
Definition SpellDefines.h:70
bool CanBeRecalculated() const
Definition SpellAuraEffects.h:78
int32 GetBaseAmount() const
Definition SpellAuraEffects.h:57
int32 GetAmount() const
Definition SpellAuraEffects.h:64
int32 GetDuration() const
Definition SpellAuras.h:135
AuraEffect * GetEffect(uint8 effIndex) const
Definition SpellAuras.h:178
SpellInfo const * GetSpellInfo() const
Definition SpellAuras.h:101
bool IsPermanent() const
Definition SpellAuras.h:141
static ObjectGuid const Empty
Definition ObjectGuid.h:123
uint64 GetRawValue() const
Definition ObjectGuid.h:145
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition PreparedStatement.h:77
Definition PreparedStatement.h:157
bool HasAttribute(SpellAttr0 attribute) const
Definition SpellInfo.h:441
bool IsPositive() const
Definition SpellInfo.cpp:1282
bool HasAura(AuraType aura) const
Definition SpellInfo.cpp:906
uint32 AuraInterruptFlags
Definition SpellInfo.h:377
bool IsPetAura(Aura const *aura)
Definition Unit.cpp:13424
AuraMap m_ownedAuras
Definition Unit.h:2189

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)
1554{
1556 stmt->SetData(0, m_charmInfo->GetPetNumber());
1557 trans->Append(stmt);
1558
1559 time_t curTime = GameTime::GetGameTime().count();
1560 uint32 curMSTime = GameTime::GetGameTimeMS().count();
1561 uint32 infTime = curMSTime + infinityCooldownDelayCheck;
1562
1563 // remove oudated and save active
1564 CreatureSpellCooldowns::iterator itr, itr2;
1565 for (itr = m_CreatureSpellCooldowns.begin(); itr != m_CreatureSpellCooldowns.end();)
1566 {
1567 itr2 = itr;
1568 ++itr;
1569
1570 if (itr2->second.end <= curMSTime + 1000)
1571 {
1572 m_CreatureSpellCooldowns.erase(itr2);
1573 }
1574 else if (itr2->second.end <= infTime)
1575 {
1576 uint32 cooldown = ((itr2->second.end - curMSTime) / IN_MILLISECONDS) + curTime;
1577 stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PET_SPELL_COOLDOWN);
1578 stmt->SetData(0, m_charmInfo->GetPetNumber());
1579 stmt->SetData(1, itr2->first);
1580 stmt->SetData(2, itr2->second.category);
1581 stmt->SetData(3, cooldown);
1582 trans->Append(stmt);
1583 }
1584 }
1585}
@ CHAR_INS_PET_SPELL_COOLDOWN
Definition CharacterDatabase.h:482
@ CHAR_DEL_PET_SPELL_COOLDOWNS
Definition CharacterDatabase.h:481
static constexpr uint32 infinityCooldownDelayCheck
Definition Unit.h:49
Milliseconds GetGameTimeMS()
Definition GameTime.cpp:44

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)
1601{
1602 // rewrite the whole spell book: pet numbers are recycled, so an incremental save would let a
1603 // new pet inherit the rows of whichever pet held the number before it
1605 stmt->SetData(0, m_charmInfo->GetPetNumber());
1606 trans->Append(stmt);
1607
1608 for (PetSpellMap::iterator itr = m_spells.begin(), next = m_spells.begin(); itr != m_spells.end(); itr = next)
1609 {
1610 ++next;
1611
1612 // prevent saving family passives to DB
1613 if (itr->second.type == PETSPELL_FAMILY)
1614 continue;
1615
1616 if (itr->second.state == PETSPELL_REMOVED)
1617 {
1618 m_spells.erase(itr);
1619 continue;
1620 }
1621
1622 stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PET_SPELL);
1623 stmt->SetData(0, m_charmInfo->GetPetNumber());
1624 stmt->SetData(1, itr->first);
1625 stmt->SetData(2, itr->second.active);
1626 trans->Append(stmt);
1627
1628 itr->second.state = PETSPELL_UNCHANGED;
1629 }
1630}
@ CHAR_DEL_PET_SPELLS
Definition CharacterDatabase.h:486
@ CHAR_INS_PET_SPELL
Definition CharacterDatabase.h:483
@ PETSPELL_REMOVED
Definition PetDefines.h:61
@ PETSPELL_FAMILY
Definition PetDefines.h:67
PetSpellMap m_spells
Definition Pet.h:120

References CHAR_DEL_PET_SPELLS, CHAR_INS_PET_SPELL, CharacterDatabase, CharmInfo::GetPetNumber(), Unit::m_charmInfo, m_spells, PETSPELL_FAMILY, 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 
)
1795{
1796 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
1797 if (!spellInfo)
1798 {
1799 // do pet spell book cleanup
1800 if (state == PETSPELL_UNCHANGED) // spell load case
1801 {
1802 LOG_ERROR("entities.pet", "Pet::addSpell: Non-existed in SpellStore spell #{} request, deleting for all pets in `pet_spell`.", spellId);
1803
1805 stmt->SetData(0, spellId);
1806 CharacterDatabase.Execute(stmt);
1807 }
1808 else
1809 LOG_ERROR("entities.pet", "Pet::addSpell: Non-existed in SpellStore spell #{} request.", spellId);
1810
1811 return false;
1812 }
1813
1814 auto const& itr = m_spells.find(spellId);
1815 if (itr != m_spells.end())
1816 {
1817 if (itr->second.state == PETSPELL_REMOVED)
1818 {
1819 m_spells.erase(itr);
1820 state = PETSPELL_CHANGED;
1821 }
1822 else if (state == PETSPELL_UNCHANGED && itr->second.state != PETSPELL_UNCHANGED)
1823 {
1824 // can be in case spell loading but learned at some previous spell loading
1825 itr->second.state = PETSPELL_UNCHANGED;
1826
1827 ToggleAutocast(spellInfo, active == ACT_ENABLED);
1828 return false;
1829 }
1830 else
1831 return false;
1832 }
1833
1834 PetSpell newspell;
1835 newspell.state = state;
1836 newspell.type = type;
1837
1838 if (active == ACT_DECIDE) // active was not used before, so we save it's autocast/passive state here
1839 {
1840 if (spellInfo->IsAutocastable())
1841 newspell.active = ACT_DISABLED;
1842 else
1843 newspell.active = ACT_PASSIVE;
1844 }
1845 else
1846 newspell.active = active;
1847
1848 // talent: unlearn all other talent ranks (high and low)
1849 if (TalentSpellPos const* talentPos = GetTalentSpellPos(spellId))
1850 {
1851 if (TalentEntry const* talentInfo = sTalentStore.LookupEntry(talentPos->talent_id))
1852 {
1853 for (uint32 rankSpellId : talentInfo->RankID)
1854 {
1855 // skip learning spell and no rank spell case
1856 if (!rankSpellId || rankSpellId == spellId)
1857 continue;
1858
1859 // skip unknown ranks
1860 if (!HasSpell(rankSpellId))
1861 continue;
1862 removeSpell(rankSpellId, false, false);
1863 }
1864 }
1865 }
1866 else if (spellInfo->IsRanked())
1867 {
1868 for (auto const& [spellID, petSpell] : m_spells)
1869 {
1870 if (petSpell.state == PETSPELL_REMOVED)
1871 continue;
1872
1873 SpellInfo const* oldRankSpellInfo = sSpellMgr->GetSpellInfo(spellID);
1874
1875 if (!oldRankSpellInfo)
1876 continue;
1877
1878 if (spellInfo->IsDifferentRankOf(oldRankSpellInfo))
1879 {
1880 // replace by new high rank
1881 if (spellInfo->IsHighRankOf(oldRankSpellInfo))
1882 {
1883 newspell.active = petSpell.active;
1884
1885 if (newspell.active == ACT_ENABLED)
1886 ToggleAutocast(oldRankSpellInfo, false);
1887
1888 unlearnSpell(spellID, false, false);
1889 break;
1890 }
1891 // ignore new lesser rank
1892 else
1893 return false;
1894 }
1895 }
1896 }
1897
1898 m_spells[spellId] = newspell;
1899
1900 if (spellInfo->IsPassive())
1901 CastSpell(this, spellId, true);
1902 else
1903 m_charmInfo->AddSpellToActionBar(spellInfo);
1904
1905 // unapply aura stats if dont meet requirements
1906 if (Aura* aura = GetAura(spellId))
1907 {
1908 if (aura->GetSpellInfo()->CasterAuraState == AURA_STATE_HEALTHLESS_35_PERCENT ||
1909 aura->GetSpellInfo()->CasterAuraState == AURA_STATE_HEALTH_ABOVE_75_PERCENT ||
1910 aura->GetSpellInfo()->CasterAuraState == AURA_STATE_HEALTHLESS_20_PERCENT )
1911 if (!HasAuraState((AuraStateType)aura->GetSpellInfo()->CasterAuraState))
1912 {
1913 aura->HandleAllEffects(aura->GetApplicationOfTarget(GetGUID()), AURA_EFFECT_HANDLE_REAL, false);
1914 }
1915 }
1916
1917 ToggleAutocast(spellInfo, (newspell.active == ACT_ENABLED));
1918
1919 uint32 talentCost = GetTalentSpellCost(spellId);
1920 if (talentCost)
1921 {
1922 int32 free_points = GetMaxTalentPointsForLevel(GetLevel());
1923 m_usedTalentCount += talentCost;
1924 // update free talent points
1925 free_points -= m_usedTalentCount;
1926 SetFreeTalentPoints(free_points > 0 ? free_points : 0);
1927 }
1928 return true;
1929}
@ CHAR_DEL_INVALID_PET_SPELL
Definition CharacterDatabase.h:305
@ ACT_DECIDE
Definition CharmInfo.h:66
@ ACT_ENABLED
Definition CharmInfo.h:63
@ ACT_PASSIVE
Definition CharmInfo.h:61
@ ACT_DISABLED
Definition CharmInfo.h:62
TalentSpellPos const * GetTalentSpellPos(uint32 spellId)
Definition DBCStores.cpp:694
uint32 GetTalentSpellCost(uint32 spellId)
Definition DBCStores.cpp:703
DBCStorage< TalentEntry > sTalentStore(TalentEntryfmt)
@ PETSPELL_CHANGED
Definition PetDefines.h:59
AuraStateType
Definition SharedDefines.h:1276
@ AURA_STATE_HEALTHLESS_35_PERCENT
Definition SharedDefines.h:1293
@ AURA_STATE_HEALTH_ABOVE_75_PERCENT
Definition SharedDefines.h:1303
@ AURA_STATE_HEALTHLESS_20_PERCENT
Definition SharedDefines.h:1281
@ AURA_EFFECT_HANDLE_REAL
Definition SpellAuraDefines.h:42
bool unlearnSpell(uint32 spell_id, bool learn_prev, bool clear_ab=true)
Definition Pet.cpp:1987
void ToggleAutocast(SpellInfo const *spellInfo, bool apply)
Definition Pet.cpp:2275
bool removeSpell(uint32 spell_id, bool learn_prev, bool clear_ab=true)
Definition Pet.cpp:2004
void SetFreeTalentPoints(uint8 points)
Definition Pet.h:131
uint8 GetMaxTalentPointsForLevel(uint8 level)
Definition Pet.cpp:2263
bool HasSpell(uint32 spell) const override
Definition Pet.cpp:2360
bool IsAutocastable() const
Definition SpellInfo.cpp:1148
bool IsPassive() const
Definition SpellInfo.cpp:1143
bool IsRanked() const
Definition SpellInfo.cpp:2936
bool IsHighRankOf(SpellInfo const *spellInfo) const
Definition SpellInfo.cpp:3032
bool IsDifferentRankOf(SpellInfo const *spellInfo) const
Definition SpellInfo.cpp:3025
Aura * GetAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition Unit.cpp:5658
bool HasAuraState(AuraStateType flag, SpellInfo const *spellProto=nullptr, Unit const *Caster=nullptr) const
Definition Unit.cpp:7464
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:1378
bool AddSpellToActionBar(SpellInfo const *spellInfo, ActiveStates newstate=ACT_DECIDE, uint32 index=MAX_UNIT_ACTION_BAR_INDEX+1)
Definition CharmInfo.cpp:145
Definition Pet.h:29
PetSpellState state
Definition Pet.h:31
PetSpellType type
Definition Pet.h:32
ActiveStates active
Definition Pet.h:30
Definition DBCStructure.h:1959
Definition DBCStructure.h:2268

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.

73{
75 if (!IsInWorld())
76 {
82 }
83
84 // pussywizard: apply ICC buff to pets
85 if (GetOwnerGUID().IsPlayer() && GetMapId() == MAP_ICECROWN_CITADEL && FindMap() && FindMap()->ToInstanceMap() && FindMap()->ToInstanceMap()->GetInstanceScript() && FindMap()->ToInstanceMap()->GetInstanceScript()->GetData(251 /*DATA_BUFF_AVAILABLE*/))
86 if (Unit* owner = GetOwner())
87 if (Player* plr = owner->ToPlayer())
88 {
89 SpellAreaForAreaMapBounds saBounds = sSpellMgr->GetSpellAreaForAreaMapBounds(4812);
90 for (SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr)
91 if ((itr->second->raceMask & plr->getRaceMask()) && !HasAura(itr->second->spellId))
92 if (SpellInfo const* si = sSpellMgr->GetSpellInfo(itr->second->spellId))
94 AddAura(itr->second->spellId, this);
95 }
96
97 // Prevent stuck pets when zoning. Pets default to "follow" when added to world
98 // so we'll reset flags and let the AI handle things
100 {
103 GetCharmInfo()->SetIsAtStay(false);
106 }
107
108 if (GetOwnerGUID().IsPlayer())
109 {
110 if (Player* owner = GetOwner())
111 {
112 if (getPetType() == SUMMON_PET && owner->IsClass(CLASS_WARLOCK, CLASS_CONTEXT_PET))
113 {
114 owner->SetLastPetSpell(GetUInt32Value(UNIT_CREATED_BY_SPELL));
115 }
116 }
117
118 sScriptMgr->OnPetAddToWorld(this);
119 }
120}
@ MAP_ICECROWN_CITADEL
Definition AreaDefines.h:269
@ SUMMON_PET
Definition PetDefines.h:32
#define sScriptMgr
Definition ScriptMgr.h:769
@ CLASS_WARLOCK
Definition SharedDefines.h:134
@ SPELL_AURA_MOD_INCREASE_HEALTH_PERCENT
Definition SpellAuraDefines.h:196
std::pair< SpellAreaForAreaMap::const_iterator, SpellAreaForAreaMap::const_iterator > SpellAreaForAreaMapBounds
Definition SpellMgr.h:549
@ CLASS_CONTEXT_PET
Definition UnitDefines.h:243
@ COMMAND_FOLLOW
Definition Unit.h:582
@ UNIT_CREATED_BY_SPELL
Definition UpdateFields.h:138
Definition Creature.h:47
bool AIM_Initialize(CreatureAI *ai=nullptr)
Definition Creature.cpp:1118
void Motion_Initialize()
Definition Creature.cpp:1139
MapStoredObjectTypesContainer & GetObjectsStore()
Definition Map.h:358
uint32 GetUInt32Value(uint16 index) const
Definition Object.cpp:303
Player * ToPlayer()
Definition Object.h:208
bool IsInWorld() const
Definition Object.h:115
PetType getPetType() const
Definition Pet.h:52
Definition Player.h:1086
bool Insert(KEY_TYPE const &handle, SPECIFIC_TYPE *obj)
Definition TypeContainer.h:177
Definition Unit.h:670
void AddToWorld() override
Definition Unit.cpp:12216
ObjectGuid GetOwnerGUID() const override
Definition Unit.h:719
Aura * AddAura(uint32 spellId, Unit *target)
Definition Unit.cpp:14825
CharmInfo * GetCharmInfo()
Definition Unit.h:1298
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition Unit.cpp:5798
uint32 GetMapId() const
Definition Position.h:281
Map * GetMap() const
Definition Object.h:637
Map * FindMap() const
Definition Object.h:638
InstanceScript * GetInstanceScript() const
Definition Object.cpp:1247
void SetIsCommandFollow(bool val)
Definition CharmInfo.cpp:313
void SetIsAtStay(bool val)
Definition CharmInfo.cpp:365
void SetIsFollowing(bool val)
Definition CharmInfo.cpp:375
void SetIsReturning(bool val)
Definition CharmInfo.cpp:385
bool HasCommandState(CommandStates state) const
Definition CharmInfo.h:137
void SetIsCommandAttack(bool val)
Definition CharmInfo.cpp:303

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

◆ CastPendingSpell()

void Pet::CastPendingSpell ( )
private
768{
769 if (!m_tempspell)
770 return;
771
772 Unit* tempSpellTarget = nullptr;
774 tempSpellTarget = ObjectAccessor::GetUnit(*this, m_tempspellTarget);
775
776 Unit* tempOldTarget = nullptr;
778 tempOldTarget = ObjectAccessor::GetUnit(*this, m_tempoldTarget);
779
780 bool tempSpellIsPositive = m_tempspellIsPositive;
781 uint32 tempSpell = m_tempspell;
782 Unit* charmer = GetCharmerOrOwner();
783 if (!charmer)
784 return;
785
786 CharmInfo* charmInfo = GetCharmInfo();
787 if (!charmInfo)
788 return;
789
790 if (!tempSpellTarget || !tempSpellTarget->IsAlive())
791 {
792 m_tempspell = 0;
795 m_tempspellIsPositive = false;
796
797 Unit* victim = charmer->GetVictim();
798
799 StopMoving();
800 GetMotionMaster()->Clear(false);
802
803 if (victim && victim->IsAlive())
804 {
805 charmInfo->SetIsCommandAttack(true);
806 charmInfo->SetIsAtStay(false);
807 charmInfo->SetIsFollowing(false);
808 charmInfo->SetIsCommandFollow(false);
809 charmInfo->SetIsReturning(false);
810
812 ToCreature()->AI()->AttackStart(victim);
813 }
814 else
815 {
817 charmInfo->SetIsCommandAttack(false);
818 charmInfo->SetIsAtStay(false);
819 charmInfo->SetIsFollowing(false);
820 charmInfo->SetIsCommandFollow(true);
821 charmInfo->SetIsReturning(true);
822
824 }
825
826 return;
827 }
828
829 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(tempSpell);
830 if (!spellInfo)
831 return;
832
833 float maxRange = GetSpellMaxRangeForTarget(tempSpellTarget, spellInfo);
834 if (spellInfo->RangeEntry->Flags == SPELL_RANGE_MELEE)
835 maxRange -= 2 * MIN_MELEE_REACH;
836
837 if (!IsWithinLOSInMap(tempSpellTarget) || GetDistance(tempSpellTarget) >= maxRange)
838 return;
839
840 if (charmInfo->GetGlobalCooldownMgr().HasGlobalCooldown(spellInfo) || HasSpellCooldown(tempSpell))
841 return;
842
843 StopMoving();
844 GetMotionMaster()->Clear(false);
846
847 charmInfo->SetIsAtStay(true);
848 charmInfo->SetIsCommandFollow(false);
849 charmInfo->SetIsFollowing(false);
850 charmInfo->SetIsReturning(false);
851 charmInfo->SaveStayPosition(true);
852
853 AddSpellCooldown(tempSpell, 0, spellInfo->IsCooldownStartedOnEvent() ? infinityCooldownDelay : 0);
854
855 CastSpell(tempSpellTarget, tempSpell, false);
856 m_tempspell = 0;
858
859 if (tempSpellIsPositive)
860 {
861 if (tempOldTarget && tempOldTarget->IsAlive())
862 {
863 charmInfo->SetIsCommandAttack(true);
864 charmInfo->SetIsAtStay(false);
865 charmInfo->SetIsFollowing(false);
866 charmInfo->SetIsCommandFollow(false);
867 charmInfo->SetIsReturning(false);
868
870 ToCreature()->AI()->AttackStart(tempOldTarget);
871 }
872 else
873 {
874 if (IsAIEnabled)
875 {
876 // Do not use PetStopAttack here: it interrupts the spell just started above.
877 AttackStop();
878 charmInfo->SetIsCommandAttack(false);
879 charmInfo->SetIsAtStay(false);
880 charmInfo->SetIsFollowing(false);
881 charmInfo->SetIsReturning(false);
882 }
883 else
884 {
886 charmInfo->SetIsCommandAttack(false);
887 charmInfo->SetIsAtStay(false);
888 charmInfo->SetIsFollowing(false);
889 charmInfo->SetIsCommandFollow(true);
890 charmInfo->SetIsReturning(true);
891
893 }
894 }
895
897 m_tempspellIsPositive = false;
898 }
900 {
901 // Do not use PetStopAttack here: it interrupts the spell just started above.
902 // Once the cast finishes, PetAI will see no victim and resume following the owner.
903 AttackStop();
904 charmInfo->SetIsCommandAttack(false);
905 charmInfo->SetIsAtStay(false);
906 charmInfo->SetIsFollowing(false);
907 charmInfo->SetIsReturning(false);
908 }
909}
#define MIN_MELEE_REACH
Definition ObjectDefines.h:46
constexpr float PET_FOLLOW_DIST
Definition PetDefines.h:206
@ SPELL_RANGE_MELEE
Definition Spell.h:101
@ REACT_PASSIVE
Definition Unit.h:574
static constexpr uint32 infinityCooldownDelay
Definition Unit.h:48
bool HasSpellCooldown(uint32 spell_id) const override
Definition Creature.cpp:3088
bool HasReactState(ReactStates state) const
Definition Creature.h:101
void AddSpellCooldown(uint32 spell_id, uint32, uint32 end_time, bool needSendToClient=false, bool forceSendToSpectator=false) override
Definition Creature.cpp:3013
CreatureAI * AI() const
Definition Creature.h:143
bool HasGlobalCooldown(SpellInfo const *spellInfo) const
Definition CharmInfo.cpp:397
float GetFollowAngle() const override
Definition TemporarySummon.h:93
void MoveIdle()
Definition MotionMaster.cpp:235
void MoveFollow(Unit *target, float dist, float angle, MovementSlot slot=MOTION_SLOT_ACTIVE, bool inheritWalkState=true, bool inheritSpeed=true)
The unit will follow this target. Doesn't work with UNIT_FLAG_DISABLE_MOVE.
Definition MotionMaster.cpp:448
void Clear(bool reset=true)
Definition MotionMaster.h:194
bool IsEmpty() const
Definition ObjectGuid.h:165
Creature * ToCreature()
Definition Object.h:212
bool IsCooldownStartedOnEvent() const
Definition SpellInfo.cpp:1257
SpellRangeEntry const * RangeEntry
Definition SpellInfo.h:393
virtual void AttackStart(Unit *)
Definition UnitAI.cpp:29
MotionMaster * GetMotionMaster()
Definition Unit.h:1774
bool IsAlive() const
Definition Unit.h:1812
void StopMoving()
Definition Unit.cpp:12709
float GetSpellMaxRangeForTarget(Unit const *target, SpellInfo const *spellInfo) const
Definition Unit.cpp:11559
Unit * GetCharmerOrOwner() const
Definition Unit.h:1303
Unit * GetVictim() const
Definition Unit.h:910
bool IsAIEnabled
Definition Unit.h:2118
bool AttackStop()
Force the unit to stop attacking. This will clear UNIT_STATE_MELEE_ATTACKING, Interrupt current spell...
Definition Unit.cpp:7270
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:1412
float GetDistance(WorldObject const *obj) const
Definition Object.cpp:1304
Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition ObjectAccessor.cpp:223
Definition CharmInfo.h:127
GlobalCooldownMgr & GetGlobalCooldownMgr()
Definition CharmInfo.h:160
void SaveStayPosition(bool atCurrentPos)
Definition CharmInfo.cpp:323
void SetCommandState(CommandStates st)
Definition CharmInfo.h:135
uint32 Flags
Definition DBCStructure.h:1833

References Creature::AddSpellCooldown(), Creature::AI(), UnitAI::AttackStart(), Unit::AttackStop(), Unit::CastSpell(), MotionMaster::Clear(), COMMAND_FOLLOW, ObjectGuid::Empty, SpellRangeEntry::Flags, Unit::GetCharmerOrOwner(), Unit::GetCharmInfo(), WorldObject::GetDistance(), Minion::GetFollowAngle(), CharmInfo::GetGlobalCooldownMgr(), Unit::GetMotionMaster(), Unit::GetSpellMaxRangeForTarget(), ObjectAccessor::GetUnit(), Unit::GetVictim(), CharmInfo::HasCommandState(), GlobalCooldownMgr::HasGlobalCooldown(), Creature::HasReactState(), Creature::HasSpellCooldown(), infinityCooldownDelay, Unit::IsAIEnabled, Unit::IsAlive(), SpellInfo::IsCooldownStartedOnEvent(), ObjectGuid::IsEmpty(), WorldObject::IsWithinLOSInMap(), m_tempoldTarget, m_tempspell, m_tempspellIsPositive, m_tempspellTarget, MIN_MELEE_REACH, MotionMaster::MoveFollow(), MotionMaster::MoveIdle(), PET_FOLLOW_DIST, SpellInfo::RangeEntry, REACT_PASSIVE, CharmInfo::SaveStayPosition(), CharmInfo::SetCommandState(), CharmInfo::SetIsAtStay(), CharmInfo::SetIsCommandAttack(), CharmInfo::SetIsCommandFollow(), CharmInfo::SetIsFollowing(), CharmInfo::SetIsReturning(), SPELL_RANGE_MELEE, sSpellMgr, Unit::StopMoving(), and Object::ToCreature().

Referenced by Update().

◆ CastPetAuras()

void Pet::CastPetAuras ( bool  current)
2389{
2390 Unit* owner = GetOwner();
2391 if (!owner || !owner->IsPlayer())
2392 return;
2393
2394 if (!IsPermanentPetFor(owner->ToPlayer()))
2395 return;
2396
2397 for (PetAuraSet::const_iterator itr = owner->m_petAuras.begin(); itr != owner->m_petAuras.end();)
2398 {
2399 PetAura const* pa = *itr;
2400 ++itr;
2401
2402 if (!current && pa->IsRemovedOnChangePet())
2403 owner->RemovePetAura(pa);
2404 else
2405 CastPetAura(pa);
2406 }
2407}
Definition SpellMgr.h:469
bool IsRemovedOnChangePet() const
Definition SpellMgr.h:501
bool IsPermanentPetFor(Player *owner) const
Definition Pet.cpp:2317
void RemovePetAura(PetAura const *petSpell)
Definition Unit.cpp:13397
void CastPetAura(PetAura const *aura)
Definition Unit.cpp:13409
PetAuraSet m_petAuras
Definition Unit.h:2115

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

Referenced by InitPetCreateSpells(), and setDeathState().

◆ CastWhenWillAvailable()

void Pet::CastWhenWillAvailable ( uint32  spellid,
Unit *  spellTarget,
ObjectGuid  oldTarget,
bool  spellIsPositive = false 
)
2455{
2456 if (!spellid)
2457 return;
2458
2459 if (!spellTarget)
2460 return;
2461
2462 m_tempspellTarget = spellTarget->GetGUID();
2463 m_tempspell = spellid;
2464 m_tempspellIsPositive = spellIsPositive;
2465
2466 if (!oldTarget.IsEmpty())
2467 m_tempoldTarget = oldTarget;
2468}

References Object::GetGUID(), ObjectGuid::IsEmpty(), m_tempoldTarget, m_tempspell, m_tempspellIsPositive, and m_tempspellTarget.

Referenced by WorldSession::HandlePetActionHelper().

◆ CleanupActionBar()

void Pet::CleanupActionBar ( )
2056{
2057 for (uint8 i = 0; i < MAX_UNIT_ACTION_BAR_INDEX; ++i)
2059 if (ab->GetAction() && ab->IsActionBarForSpell())
2060 {
2061 if (!HasSpell(ab->GetAction()))
2063 else if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(ab->GetAction()))
2064 ToggleAutocast(spellInfo, ab->GetType() == ACT_ENABLED);
2065 }
2066}
#define MAX_UNIT_ACTION_BAR_INDEX
Definition CharmInfo.h:29
void SetActionBar(uint8 index, uint32 spellOrAction, ActiveStates type)
Definition CharmInfo.h:150
UnitActionBarEntry const * GetActionBarEntry(uint8 index) const
Definition CharmInfo.h:154
Definition CharmInfo.h:95

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()

◆ Create()

bool Pet::Create ( ObjectGuid::LowType  guidlow,
Map *  map,
uint32  phaseMask,
uint32  Entry,
uint32  pet_number 
)
2338{
2339 ASSERT(map);
2340 SetMap(map);
2341
2342 SetPhaseMask(phaseMask, false);
2343
2344 Object::_Create(guidlow, pet_number, HighGuid::Pet);
2345
2346 m_spawnId = guidlow;
2348
2349 if (!InitEntry(Entry))
2350 return false;
2351
2352 // Force regen flag for player pets, just like we do for players themselves
2356
2357 return true;
2358}
@ UNIT_FLAG2_REGENERATE_POWER
Definition UnitDefines.h:306
@ SHEATH_STATE_MELEE
Definition UnitDefines.h:130
ObjectGuid::LowType m_spawnId
For new or temporary creatures is 0 for saved it is lowguid.
Definition Creature.h:493
uint32 m_originalEntry
Definition Creature.h:505
bool InitEntry(uint32 entry, CreatureData const *data=nullptr)
Definition Creature.cpp:482
void _Create(ObjectGuid::LowType guidlow, uint32 entry, HighGuid guidhigh)
Definition Object.cpp:128
void Initialize()
Definition ThreatManager.cpp:248
void SetUnitFlag2(UnitFlags2 flags)
Definition Unit.h:760
virtual void SetSheath(SheathState sheathed)
Definition Unit.h:1793
void SetPhaseMask(uint32 newPhaseMask, bool update) override
Definition Unit.cpp:15011
ThreatManager & GetThreatMgr()
Definition Unit.h:965
virtual void SetMap(Map *map)
Definition Object.cpp:2203
uint32 const Entry[3]
Definition instance_blackwing_lair.cpp:73

References Object::_Create(), ASSERT, Entry, Unit::GetThreatMgr(), Creature::InitEntry(), ThreatManager::Initialize(), Creature::m_originalEntry, Creature::m_spawnId, Pet, 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)
993{
994 ASSERT(creature);
995
996 if (!CreateBaseAtTamed(creature->GetCreatureTemplate(), creature->GetMap(), creature->GetPhaseMask()))
997 return false;
998
999 Relocate(creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ(), creature->GetOrientation());
1000
1001 if (!IsPositionValid())
1002 {
1003 LOG_ERROR("entities.pet", "Pet {} not created base at creature. Suggested coordinates isn't valid (X: {} Y: {})",
1005 return false;
1006 }
1007
1008 CreatureTemplate const* cinfo = GetCreatureTemplate();
1009 if (!cinfo)
1010 {
1011 LOG_ERROR("entities.pet", "CreateBaseAtCreature() failed, creatureInfo is missing!");
1012 return false;
1013 }
1014
1015 SetDisplayId(creature->GetDisplayId());
1016
1018
1019 if (CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cinfo->family))
1020 SetName(cFamily->Name[sWorld->GetDefaultDbcLocale()]);
1021 else
1022 SetName(creature->GetNameForLocaleIdx(sObjectMgr->GetDBCLocaleIndex()));
1023
1024 return true;
1025}
DBCStorage< CreatureFamilyEntry > sCreatureFamilyStore(CreatureFamilyfmt)
#define sObjectMgr
Definition ObjectMgr.h:1731
std::string const & GetNameForLocaleIdx(LocaleConstant locale_idx) const override
Definition Creature.cpp:3350
CreatureTemplate const * GetCreatureTemplate() const
Definition Creature.h:207
void SetDisplayId(uint32 modelId, std::optional< float > displayScale={}) override
Definition Pet.cpp:2441
bool CreateBaseAtTamed(CreatureTemplate const *cinfo, Map *map, uint32 phaseMask)
Definition Pet.cpp:1042
uint32 GetDisplayId() const
Definition Unit.h:1996
uint32 GetPhaseMask() const
Definition Object.h:523
void SetName(std::string const &newname)
Definition Object.h:536
void UpdatePositionData()
Definition Object.cpp:1188
#define sWorld
Definition World.h:337
Definition DBCStructure.h:781
Definition CreatureData.h:187
uint32 family
Definition CreatureData.h:217
float GetPositionZ() const
Definition Position.h:123
float GetOrientation() const
Definition Position.h:124
bool IsPositionValid() const
Definition Position.cpp:183
float GetPositionX() const
Definition Position.h:121
float GetPositionY() const
Definition Position.h:122
void Relocate(float x, float y)
Definition Position.h:77

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 
)
1028{
1029 if (!CreateBaseAtTamed(cinfo, owner->GetMap(), owner->GetPhaseMask()))
1030 return false;
1031
1032 if (CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cinfo->family))
1033 SetName(cFamily->Name[sWorld->GetDefaultDbcLocale()]);
1034
1035 Relocate(owner->GetPositionX(), owner->GetPositionY(), owner->GetPositionZ(), owner->GetOrientation());
1036
1038
1039 return true;
1040}

References CreateBaseAtTamed(), CreatureTemplate::family, WorldObject::GetMap(), Position::GetOrientation(), WorldObject::GetPhaseMask(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), Position::Relocate(), sCreatureFamilyStore, WorldObject::SetName(), sWorld, and WorldObject::UpdatePositionData().

Referenced by Unit::CreateTamedPetFrom().

◆ CreateBaseAtTamed()

bool Pet::CreateBaseAtTamed ( CreatureTemplate const *  cinfo,
Map *  map,
uint32  phaseMask 
)
1043{
1044 LOG_DEBUG("entities.pet", "Pet::CreateBaseForTamed");
1046 uint32 pet_number = sObjectMgr->GeneratePetNumber();
1047 if (!Create(guid, map, phaseMask, cinfo->Entry, pet_number))
1048 return false;
1049
1051 SetPower(POWER_HAPPINESS, 166500);
1057
1058 if (cinfo->type == CREATURE_TYPE_BEAST)
1059 {
1063 }
1064
1065 return true;
1066}
@ POWER_HAPPINESS
Definition SharedDefines.h:261
@ POWER_FOCUS
Definition SharedDefines.h:259
@ CREATURE_TYPE_BEAST
Definition SharedDefines.h:2622
@ UNIT_CAN_BE_RENAMED
Definition UnitDefines.h:152
@ UNIT_CAN_BE_ABANDONED
Definition UnitDefines.h:153
@ UNIT_NPC_FLAG_NONE
Definition UnitDefines.h:321
@ 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
@ RATE_XP_PET_NEXT_LEVEL
Definition WorldConfig.h:453
ObjectGuid::LowType GenerateLowGuid()
Definition Map.h:530
uint32 LowType
Definition ObjectGuid.h:125
void SetByteFlag(uint16 index, uint8 offset, uint8 newFlag)
Definition Object.cpp:902
bool Create(ObjectGuid::LowType guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 pet_number)
Definition Pet.cpp:2337
uint32 GetCreatePowers(Powers power) const
Definition Unit.cpp:12188
void SetPower(Powers power, uint32 val, bool withPowerUpdate=true, bool fromRegenerate=false)
Definition Unit.cpp:12108
void SetMaxPower(Powers power, uint32 val)
Definition Unit.cpp:12159
void SetUInt32Value(uint16 index, uint32 value)
Definition Unit.cpp:17078
void setPowerType(Powers power)
Definition Unit.cpp:6809
void ReplaceAllNpcFlags(NPCFlags flags)
Definition Unit.h:772

References Create(), CREATURE_TYPE_BEAST, CreatureTemplate::Entry, Map::GenerateLowGuid(), Unit::GetCreatePowers(), Unit::GetLevel(), LOG_DEBUG, Pet, POWER_FOCUS, POWER_HAPPINESS, RATE_XP_PET_NEXT_LEVEL, Unit::ReplaceAllNpcFlags(), Object::SetByteFlag(), Unit::SetMaxPower(), Unit::SetPower(), Unit::setPowerType(), Unit::SetSheath(), Unit::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(), pet_commandscript::HandlePetDeleteCommand(), and SavePetToDB().

◆ DeleteFromDB() [2/2]

void Pet::DeleteFromDB ( ObjectGuid::LowType  guidlow)
static
628{
629 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
630
632 stmt->SetData(0, guidlow);
633 trans->Append(stmt);
634
635 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_PET_DECLINEDNAME);
636 stmt->SetData(0, guidlow);
637 trans->Append(stmt);
638
639 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PET_AURAS);
640 stmt->SetData(0, guidlow);
641 trans->Append(stmt);
642
643 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PET_SPELLS);
644 stmt->SetData(0, guidlow);
645 trans->Append(stmt);
646
647 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PET_SPELL_COOLDOWNS);
648 stmt->SetData(0, guidlow);
649 trans->Append(stmt);
650
651 CharacterDatabase.CommitTransaction(trans);
652}
@ CHAR_DEL_CHAR_PET_BY_ID
Definition CharacterDatabase.h:497
@ CHAR_DEL_CHAR_PET_DECLINEDNAME
Definition CharacterDatabase.h:491
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition DatabaseEnvFwd.h:69

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
2479{
2480 petInfo->PetNumber = m_charmInfo->GetPetNumber();
2481 petInfo->CreatureId = GetEntry();
2482 petInfo->DisplayId = GetNativeDisplayId();
2483 petInfo->Level = GetLevel();
2485 petInfo->ReactState = GetReactState();
2486 petInfo->Name = GetName();
2488 petInfo->Health = GetHealth();
2489 petInfo->Mana = GetPower(POWER_MANA);
2491 petInfo->ActionBar = GenerateActionBarData();
2492 petInfo->LastSaveTime = GameTime::GetGameTime().count();
2494 petInfo->Type = getPetType();
2495}
@ POWER_MANA
Definition SharedDefines.h:257
ReactStates GetReactState() const
Definition Creature.h:100
uint32 GetEntry() const
Definition Object.h:123
bool HasByteFlag(uint16 index, uint8 offset, uint8 flag) const
Definition Object.cpp:940
std::string GenerateActionBarData() const
Definition Pet.cpp:2553
uint32 GetNativeDisplayId() const
Definition Unit.h:1998
uint32 GetHealth() const
Definition Unit.h:1122
uint32 GetPower(Powers power) const
Definition Unit.h:1149
std::string const & GetName() const
Definition Object.h:535
uint32 Mana
Definition PetDefines.h:225
uint32 Happiness
Definition PetDefines.h:226
uint32 CreatedBySpellId
Definition PetDefines.h:228
uint32 Health
Definition PetDefines.h:224
uint32 CreatureId
Definition PetDefines.h:221
bool WasRenamed
Definition PetDefines.h:232
uint8 Level
Definition PetDefines.h:229
uint32 DisplayId
Definition PetDefines.h:222
ReactStates ReactState
Definition PetDefines.h:230
std::string Name
Definition PetDefines.h:218
PetType Type
Definition PetDefines.h:231
uint32 Experience
Definition PetDefines.h:223
uint32 PetNumber
Definition PetDefines.h:220
uint32 LastSaveTime
Definition PetDefines.h:227
std::string ActionBar
Definition PetDefines.h:219

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
2554{
2555 std::ostringstream oss;
2556
2558 {
2559 oss << uint32(m_charmInfo->GetActionBarEntry(i)->GetType()) << ' '
2561 }
2562
2563 return oss.str();
2564}
@ ACTION_BAR_INDEX_END
Definition CharmInfo.h:56
@ ACTION_BAR_INDEX_START
Definition CharmInfo.h:53
ActiveStates GetType() const
Definition CharmInfo.h:101
uint32 GetAction() const
Definition CharmInfo.h:102

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
1494{
1495 // -5 or greater food level
1496 if (GetLevel() <= itemlevel + 5) //possible to feed level 60 pet with level 55 level food for full effect
1497 return 35000;
1498 // -10..-6
1499 else if (GetLevel() <= itemlevel + 10) //pure guess, but sounds good
1500 return 17000;
1501 // -14..-11
1502 else if (GetLevel() <= itemlevel + 14) //level 55 food gets green on 70, makes sense to me
1503 return 8000;
1504 // -15 or less
1505 else
1506 return 0; //food too low level
1507}

References Unit::GetLevel().

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

◆ GetDebugInfo()

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

Reimplemented from Guardian.

2567{
2568 std::stringstream sstr;
2569 sstr << Guardian::GetDebugInfo() << "\n"
2570 << std::boolalpha
2571 << "PetType: " << std::to_string(getPetType()) << " "
2572 << "PetNumber: " << m_charmInfo->GetPetNumber();
2573 return sstr.str();
2574}
std::string GetDebugInfo() const override
Definition TemporarySummon.cpp:462

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
91{ 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:321

References Object::GetByteValue(), and UNIT_FIELD_BYTES_1.

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

◆ GetHappinessState()

HappinessState Pet::GetHappinessState ( )
923{
925 return UNHAPPY;
927 return HAPPY;
928 else
929 return CONTENT;
930}
@ HAPPY
Definition PetDefines.h:53
@ CONTENT
Definition PetDefines.h:52
@ UNHAPPY
Definition PetDefines.h:51
constexpr auto HAPPINESS_LEVEL_SIZE
Definition Pet.h:26

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
172{
173 if (petnumber)
174 {
175 // Known petnumber entry
176 if (stable.CurrentPet && stable.CurrentPet->PetNumber == petnumber)
177 return { &stable.CurrentPet.value(), PET_SAVE_AS_CURRENT };
178
179 for (std::size_t stableSlot = 0; stableSlot < stable.StabledPets.size(); ++stableSlot)
180 if (stable.StabledPets[stableSlot] && stable.StabledPets[stableSlot]->PetNumber == petnumber)
181 return { &stable.StabledPets[stableSlot].value(), PetSaveMode(PET_SAVE_FIRST_STABLE_SLOT + stableSlot) };
182
183 for (PetStable::PetInfo const& pet : stable.UnslottedPets)
184 if (pet.PetNumber == petnumber)
185 return { &pet, PET_SAVE_NOT_IN_SLOT };
186 }
187 else if (current)
188 {
189 // Current pet (slot 0)
190 if (stable.CurrentPet)
191 return { &stable.CurrentPet.value(), PET_SAVE_AS_CURRENT };
192 }
193 else if (petEntry)
194 {
195 // known petEntry entry (unique for summoned pet, but non unique for hunter pet (only from current or not stabled pets)
196 if (stable.CurrentPet && stable.CurrentPet->CreatureId == petEntry)
197 return { &stable.CurrentPet.value(), PET_SAVE_AS_CURRENT };
198
199 for (PetStable::PetInfo const& pet : stable.UnslottedPets)
200 if (pet.CreatureId == petEntry)
201 return { &pet, PET_SAVE_NOT_IN_SLOT };
202 }
203 else
204 {
205 // Any current or other non-stabled pet (for hunter "call pet")
206 if (stable.CurrentPet)
207 return { &stable.CurrentPet.value(), PET_SAVE_AS_CURRENT };
208
209 if (!stable.UnslottedPets.empty())
210 return { &stable.UnslottedPets.front(), PET_SAVE_NOT_IN_SLOT };
211 }
212
213 return { nullptr, PET_SAVE_AS_DELETED };
214}
PetSaveMode
Definition PetDefines.h:41
@ PET_SAVE_FIRST_STABLE_SLOT
Definition PetDefines.h:44
@ PET_SAVE_AS_DELETED
Definition PetDefines.h:42
@ PET_SAVE_NOT_IN_SLOT
Definition PetDefines.h:46
@ PET_SAVE_AS_CURRENT
Definition PetDefines.h:43
Definition PetDefines.h:215

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

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

◆ GetMaxTalentPointsForLevel()

uint8 Pet::GetMaxTalentPointsForLevel ( uint8  level)
2264{
2265 uint8 points = (level >= 20) ? ((level - 16) / 4) : 0;
2266 // Mod points from owner SPELL_AURA_MOD_PET_TALENT_POINTS
2267 if (Unit* owner = GetOwner())
2268 points += owner->GetTotalAuraModifier(SPELL_AURA_MOD_PET_TALENT_POINTS);
2269
2270 sScriptMgr->OnCalculateMaxTalentPointsForLevel(this, level, points);
2271
2272 return uint8(points * sWorld->getRate(RATE_TALENT_PET));
2273}
@ SPELL_AURA_MOD_PET_TALENT_POINTS
Definition SpellAuraDefines.h:208
@ RATE_TALENT_PET
Definition WorldConfig.h:492

References GetOwner(), RATE_TALENT_PET, SPELL_AURA_MOD_PET_TALENT_POINTS, sScriptMgr, and sWorld.

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

◆ GetNativeObjectScale()

float Pet::GetNativeObjectScale ( ) const
overridevirtual

Reimplemented from Creature.

2503{
2504 uint8 ctFamily = GetCreatureTemplate()->family;
2505
2506 CreatureFamilyEntry const* creatureFamily = sCreatureFamilyStore.LookupEntry(ctFamily);
2507 if (creatureFamily && creatureFamily->minScale > 0.0f && getPetType() & HUNTER_PET)
2508 {
2509 float minScaleLevel = creatureFamily->minScaleLevel;
2510 uint8 level = GetLevel();
2511
2512 float minLevelScaleMod = level >= minScaleLevel ? (level / minScaleLevel) : 0.0f;
2513 float maxScaleMod = creatureFamily->maxScaleLevel - minScaleLevel;
2514
2515 if (minLevelScaleMod > maxScaleMod)
2516 minLevelScaleMod = maxScaleMod;
2517
2518 float scaleMod = creatureFamily->maxScaleLevel != minScaleLevel ? minLevelScaleMod / maxScaleMod : 0.f;
2519
2520 float maxScale = creatureFamily->maxScale;
2521
2522 // override maxScale
2523 switch (ctFamily)
2524 {
2536 maxScale = 1.0f;
2537 break;
2538 default:
2539 break;
2540 }
2541
2542 float scale = (maxScale - creatureFamily->minScale) * scaleMod + creatureFamily->minScale;
2543
2544 scale = std::min(scale, maxScale);
2545
2546 return scale;
2547 }
2548
2549 // take value for non-hunter pets from DB
2551}
@ CREATURE_FAMILY_SPIDER
Definition SharedDefines.h:2646
@ CREATURE_FAMILY_CHIMAERA
Definition SharedDefines.h:2676
@ CREATURE_FAMILY_CORE_HOUND
Definition SharedDefines.h:2683
@ CREATURE_FAMILY_NETHER_RAY
Definition SharedDefines.h:2673
@ CREATURE_FAMILY_TURTLE
Definition SharedDefines.h:2661
@ CREATURE_FAMILY_CRAB
Definition SharedDefines.h:2651
@ CREATURE_FAMILY_WARP_STALKER
Definition SharedDefines.h:2671
@ CREATURE_FAMILY_WIND_SERPENT
Definition SharedDefines.h:2666
@ CREATURE_FAMILY_RHINO
Definition SharedDefines.h:2681
@ CREATURE_FAMILY_DEVILSAUR
Definition SharedDefines.h:2677
@ CREATURE_FAMILY_WASP
Definition SharedDefines.h:2682
float GetNativeObjectScale() const override
Definition Creature.cpp:3586
float maxScale
Definition DBCStructure.h:785
float minScale
Definition DBCStructure.h:783
uint32 minScaleLevel
Definition DBCStructure.h:784
uint32 maxScaleLevel
Definition DBCStructure.h:786

References CREATURE_FAMILY_CHIMAERA, CREATURE_FAMILY_CORE_HOUND, CREATURE_FAMILY_CRAB, CREATURE_FAMILY_DEVILSAUR, CREATURE_FAMILY_NETHER_RAY, CREATURE_FAMILY_RHINO, CREATURE_FAMILY_SPIDER, CREATURE_FAMILY_TURTLE, CREATURE_FAMILY_WARP_STALKER, CREATURE_FAMILY_WASP, CREATURE_FAMILY_WIND_SERPENT, CreatureTemplate::family, Creature::GetCreatureTemplate(), Unit::GetLevel(), Creature::GetNativeObjectScale(), getPetType(), HUNTER_PET, CreatureFamilyEntry::maxScale, CreatureFamilyEntry::maxScaleLevel, CreatureFamilyEntry::minScale, CreatureFamilyEntry::minScaleLevel, and sCreatureFamilyStore.

◆ GetOwner()

◆ GetPetAutoSpellOnPos()

uint32 Pet::GetPetAutoSpellOnPos ( uint8  pos) const
inlineoverridevirtual

Reimplemented from Creature.

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

References m_autospells.

◆ GetPetAutoSpellSize()

uint8 Pet::GetPetAutoSpellSize ( ) const
inlineoverridevirtual

Reimplemented from Creature.

74{ return m_autospells.size(); }

References m_autospells.

◆ getPetType()

◆ GivePetLevel()

void Pet::GivePetLevel ( uint8  level)
977{
978 if (!level || level == GetLevel())
979 return;
980
981 if (getPetType() == HUNTER_PET)
982 {
985 }
986
987 InitStatsForLevel(level);
990}
bool InitStatsForLevel(uint8 level)
Definition Pet.cpp:1069
void InitTalentForLevel()
Definition Pet.cpp:2244
void InitLevelupSpellsForLevel()
Definition Pet.cpp:1948

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

Referenced by GivePetXP(), and SynchronizeLevelWithOwner().

◆ GivePetXP()

void Pet::GivePetXP ( uint32  xp)
938{
939 if (getPetType() != HUNTER_PET)
940 return;
941
942 xp *= sWorld->getRate(RATE_XP_PET);
943
944 if (xp < 1)
945 return;
946
947 if (!IsAlive())
948 return;
949
950 uint8 maxlevel = std::min((uint8)sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL), GetOwner()->GetLevel());
951 uint8 petlevel = GetLevel();
952
953 // If pet is detected to be at, or above(?) the players level, don't hand out XP
954 if (petlevel >= maxlevel)
955 return;
956
959 uint32 newXP = curXP + xp;
960
961 // Check how much XP the pet should receive, and hand off have any left from previous levelups
962 while (newXP >= nextLvlXP && petlevel < maxlevel)
963 {
964 // Subtract newXP from amount needed for nextlevel, and give pet the level
965 newXP -= nextLvlXP;
966 ++petlevel;
967
968 GivePetLevel(petlevel);
969
971 }
972 // Not affected by special conditions - give it new XP
973 SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, petlevel < maxlevel ? newXP : 0);
974}
@ CONFIG_MAX_PLAYER_LEVEL
Definition WorldConfig.h:195
@ RATE_XP_PET
Definition WorldConfig.h:452
void GivePetLevel(uint8 level)
Definition Pet.cpp:976

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

◆ HasSpell()

bool Pet::HasSpell ( uint32  spell) const
overridevirtual

Reimplemented from Creature.

2361{
2362 PetSpellMap::const_iterator itr = m_spells.find(spell);
2363 return itr != m_spells.end() && itr->second.state != PETSPELL_REMOVED;
2364}

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
1476{
1477 if (!item->FoodType)
1478 return false;
1479
1480 CreatureTemplate const* cInfo = GetCreatureTemplate();
1481 if (!cInfo)
1482 return false;
1483
1484 CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cInfo->family);
1485 if (!cFamily)
1486 return false;
1487
1488 uint32 diet = cFamily->petFoodMask;
1489 uint32 FoodMask = 1 << (item->FoodType - 1);
1490 return diet & FoodMask;
1491}
uint32 petFoodMask
Definition DBCStructure.h:788

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

Referenced by Spell::CheckCast().

◆ InitLevelupSpellsForLevel()

void Pet::InitLevelupSpellsForLevel ( )
1949{
1950 uint8 level = GetLevel();
1951
1952 if (PetLevelupSpellSet const* levelupSpells = GetCreatureTemplate()->family ? sSpellMgr->GetPetLevelupSpellList(GetCreatureTemplate()->family) : nullptr)
1953 {
1954 // PetLevelupSpellSet ordered by levels, process in reversed order
1955 for (PetLevelupSpellSet::const_reverse_iterator itr = levelupSpells->rbegin(); itr != levelupSpells->rend(); ++itr)
1956 {
1957 // will called first if level down
1958 if (itr->first > level && sScriptMgr->CanUnlearnSpellSet(this, itr->first, itr->second))
1959 unlearnSpell(itr->second, true); // will learn prev rank if any
1960 // will called if level up
1961 else
1962 learnSpell(itr->second); // will unlearn prev rank if any
1963 }
1964 }
1965
1967
1968 // default spells (can be not learned if pet level (as owner level decrease result for example) less first possible in normal game)
1969 if (PetDefaultSpellsEntry const* defSpells = sSpellMgr->GetPetDefaultSpellsEntry(petSpellsId))
1970 {
1971 for (uint32 spellId : defSpells->spellid)
1972 {
1973 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
1974 if (!spellInfo)
1975 continue;
1976
1977 // will called first if level down
1978 if (spellInfo->SpellLevel > level && sScriptMgr->CanUnlearnSpellDefault(this, spellInfo))
1979 unlearnSpell(spellInfo->Id, true);
1980 // will called if level up
1981 else
1982 learnSpell(spellInfo->Id);
1983 }
1984 }
1985}
std::multimap< uint32, uint32 > PetLevelupSpellSet
Definition SpellMgr.h:597
bool learnSpell(uint32 spell_id)
Definition Pet.cpp:1931
uint32 SpellLevel
Definition SpellInfo.h:384
uint32 Id
Definition SpellInfo.h:344
uint32 PetSpellDataId
Definition CreatureData.h:225
Definition SpellMgr.h:603

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 ( )
2069{
2071 m_spells.clear();
2072
2075
2076 CastPetAuras(false);
2077}
void LearnPetPassives()
Definition Pet.cpp:2367
void CastPetAuras(bool current)
Definition Pet.cpp:2388
void InitPetActionBar()
Definition CharmInfo.cpp:52

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

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

◆ InitTalentForLevel()

void Pet::InitTalentForLevel ( )
2245{
2246 uint8 level = GetLevel();
2247 uint32 talentPointsForLevel = GetMaxTalentPointsForLevel(level);
2248
2249 Unit* owner = GetOwner();
2250 if (!owner || !owner->IsPlayer())
2251 return;
2252
2253 // Reset talents in case low level (on level down) or wrong points for level (hunter can unlearn TP increase talent)
2254 if (talentPointsForLevel == 0 || m_usedTalentCount > talentPointsForLevel)
2255 resetTalents(); // Remove all talent points
2256
2257 SetFreeTalentPoints(talentPointsForLevel - m_usedTalentCount);
2258
2259 if (!m_loading)
2260 owner->ToPlayer()->SendTalentsInfoData(true);
2261}
bool resetTalents()
Definition Pet.cpp:2079
void SendTalentsInfoData(bool pet)
Definition Player.cpp:14916

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

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

◆ isBeingLoaded()

bool Pet::isBeingLoaded ( ) const
inlineoverridevirtual

Reimplemented from Unit.

65{ return m_loading; }

References m_loading.

◆ isControlled()

◆ IsPermanentPetFor()

bool Pet::IsPermanentPetFor ( Player *  owner) const
2318{
2319 switch (getPetType())
2320 {
2321 case SUMMON_PET:
2326 else if (owner->IsClass(CLASS_MAGE, CLASS_CONTEXT_PET))
2327 return GetEntry() == 37994;
2328 else
2329 return false;
2330 case HUNTER_PET:
2331 return true;
2332 default:
2333 return false;
2334 }
2335}
@ CREATURE_TYPE_UNDEAD
Definition SharedDefines.h:2627
@ CREATURE_TYPE_DEMON
Definition SharedDefines.h:2624
@ CLASS_MAGE
Definition SharedDefines.h:133
@ CLASS_DEATH_KNIGHT
Definition SharedDefines.h:131
bool IsClass(Classes playerClass, ClassContext context=CLASS_CONTEXT_NONE) const override
Definition Player.cpp:1351
uint32 type
Definition CreatureData.h:218

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

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

◆ isTemporarySummoned()

bool Pet::isTemporarySummoned ( ) const
inline
55{ return m_duration > 0ms; }

References m_duration.

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

◆ LearnPetPassives()

void Pet::LearnPetPassives ( )
2368{
2369 CreatureTemplate const* cInfo = GetCreatureTemplate();
2370 if (!cInfo)
2371 return;
2372
2373 CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cInfo->family);
2374 if (!cFamily)
2375 return;
2376
2377 PetFamilySpellsStore::const_iterator petStore = sPetFamilySpellsStore.find(cFamily->ID);
2378 if (petStore != sPetFamilySpellsStore.end())
2379 {
2380 // For general hunter pets skill 270
2381 // Passive 01~10, Passive 00 (20782, not used), Ferocious Inspiration (34457)
2382 // Scale 01~03 (34902~34904, bonus from owner, not used)
2383 for (uint32 spellId : petStore->second)
2385 }
2386}
PetFamilySpellsStore sPetFamilySpellsStore
Definition DBCStores.cpp:157
@ PETSPELL_NEW
Definition PetDefines.h:60
uint32 ID
Definition DBCStructure.h:782

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)
1932{
1933 // prevent duplicated entires in spell book
1934 if (!addSpell(spell_id))
1935 return false;
1936
1937 if (!m_loading)
1938 {
1940 packet.SpellID = spell_id;
1941 m_owner->SendDirectMessage(packet.Write());
1943 }
1944
1945 return true;
1946}
void PetSpellInitialize()
Definition Player.cpp:9774
Definition PetPackets.h:72
uint32 SpellID
Definition PetPackets.h:78
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)
2410{
2411 learnSpell(spellid);
2412
2413 if (uint32 next = sSpellMgr->GetNextSpellInChain(spellid))
2414 learnSpellHighRank(next);
2415}
void learnSpellHighRank(uint32 spellid)
Definition Pet.cpp:2409

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,
bool  fullMana = false 
)
Todo:
pets should be summoned from real cast instead of just faking it?
217{
218 m_loading = true;
219
220 PetStable* petStable = ASSERT_NOTNULL(owner->GetPetStable());
221
222 ObjectGuid::LowType ownerid = owner->GetGUID().GetCounter();
223 std::pair<PetStable::PetInfo const*, PetSaveMode> info = GetLoadPetInfo(*petStable, petEntry, petnumber, current);
224 PetStable::PetInfo const* petInfo = info.first;
225 PetSaveMode slot = info.second;
226 if (!petInfo)
227 {
228 m_loading = false;
229 return false;
230 }
231
232 // Don't try to reload the current pet
233 if (petStable->CurrentPet && owner->GetPet() && petStable->CurrentPet.value().PetNumber == petInfo->PetNumber)
234 return false;
235
236 // we are loading pet at that moment
237 if (owner->IsSpectator() || owner->GetPet() || !owner->IsInWorld() || !owner->FindMap())
238 return false;
239
240 bool forceLoadFromDB = false;
241 sScriptMgr->OnPlayerBeforeLoadPetFromDB(owner, petEntry, petnumber, current, forceLoadFromDB);
242
243 if (!forceLoadFromDB && (owner->IsClass(CLASS_DEATH_KNIGHT, CLASS_CONTEXT_PET) && !owner->CanSeeDKPet())) // DK Pet exception
244 return false;
245
246 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(petInfo->CreatedBySpellId);
247
248 bool isTemporarySummon = spellInfo && spellInfo->GetDuration() > 0;
249 if (current && isTemporarySummon)
250 return false;
251
252 if (petInfo->Type == HUNTER_PET)
253 {
254 CreatureTemplate const* creatureInfo = sObjectMgr->GetCreatureTemplate(petInfo->CreatureId);
255 if (!creatureInfo || !creatureInfo->IsTameable(owner->CanTameExoticPets()))
256 return false;
257 }
258
259 if (current && owner->IsPetNeedBeTemporaryUnsummoned())
260 {
261 owner->SetLastPetSpell(petInfo->CreatedBySpellId);
263 return false;
264 }
265
266 Map* map = owner->GetMap();
268
269 if (!Create(guid, map, owner->GetPhaseMask(), petInfo->CreatureId, petInfo->PetNumber))
270 return false;
271
272 setPetType(petInfo->Type);
273 SetFaction(owner->GetFaction());
275
276 if (IsCritter())
277 {
278 float px, py, pz;
280 Relocate(px, py, pz, owner->GetOrientation());
281
282 if (!IsPositionValid())
283 {
284 LOG_ERROR("entities.pet", "Pet{} not loaded. Suggested coordinates isn't valid (X: {} Y: {})",
286 return false;
287 }
288
290 map->AddToMap(ToCreature(), true);
291 return true;
292 }
293
295 GetCharmInfo()->SetPetNumber(petInfo->PetNumber, IsPermanentPetFor(owner)); // Show pet details tab (Shift+P) only for hunter pets, demons or undead
296 else
297 GetCharmInfo()->SetPetNumber(petInfo->PetNumber, false);
298
299 SetDisplayId(petInfo->DisplayId);
302 uint8 petlevel = petInfo->Level;
304 SetName(petInfo->Name);
305
306 switch (getPetType())
307 {
308 case SUMMON_PET:
309 petlevel = owner->GetLevel();
310 ReplaceAllUnitFlags(UNIT_FLAG_PLAYER_CONTROLLED); // this enables popup window (pet dismiss, cancel)
311 break;
312 case HUNTER_PET:
313 SetUInt32Value(UNIT_FIELD_BYTES_0, 0x02020100); // class = warrior, gender = none, power = focus
316
318 // this enables popup window (pet abandon, cancel)
322 break;
323 default:
324 if (!IsPetGhoul())
325 LOG_ERROR("entities.pet", "Pet have incorrect type ({}) for pet loading.", getPetType());
326 break;
327 }
328
329 SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(GameTime::GetGameTime().count())); // cast can't be helped here
330 SetCreatorGUID(owner->GetGUID());
331
332 InitStatsForLevel(petlevel);
334
336
337 // Set pet's position after setting level, its size depends on it
338 float px, py, pz;
340 Relocate(px, py, pz, owner->GetOrientation());
341 if (!IsPositionValid())
342 {
343 LOG_ERROR("entities.pet", "Pet {} not loaded. Suggested coordinates isn't valid (X: {} Y: {})",
345 return false;
346 }
347
348 SetReactState(petInfo->ReactState);
349 SetCanModifyStats(true);
350
351 // set current pet as current
352 // 0=current
353 // 1..MAX_PET_STABLES in stable slot
354 // PET_SAVE_NOT_IN_SLOT(100) = not stable slot (summoning))
355 if (slot == PET_SAVE_NOT_IN_SLOT)
356 {
357 uint32 petInfoNumber = petInfo->PetNumber;
358 if (petStable->CurrentPet)
359 owner->RemovePet(nullptr, PET_SAVE_NOT_IN_SLOT);
360
361 auto unslottedPetItr = std::find_if(petStable->UnslottedPets.begin(), petStable->UnslottedPets.end(), [&](PetStable::PetInfo const& unslottedPet)
362 {
363 return unslottedPet.PetNumber == petInfoNumber;
364 });
365
366 ASSERT(!petStable->CurrentPet);
367 ASSERT(unslottedPetItr != petStable->UnslottedPets.end());
368
369 petStable->CurrentPet = std::move(*unslottedPetItr);
370 petStable->UnslottedPets.erase(unslottedPetItr);
371
372 // old petInfo pointer is no longer valid, refresh it
373 petInfo = &petStable->CurrentPet.value();
374 }
375 else if (PET_SAVE_FIRST_STABLE_SLOT <= slot && slot <= PET_SAVE_LAST_STABLE_SLOT)
376 {
377 auto stabledPet = std::find_if(petStable->StabledPets.begin(), petStable->StabledPets.end(), [petnumber](Optional<PetStable::PetInfo> const& pet)
378 {
379 return pet && pet->PetNumber == petnumber;
380 });
381
382 ASSERT(stabledPet != petStable->StabledPets.end());
383
384 std::swap(*stabledPet, petStable->CurrentPet);
385
386 // old petInfo pointer is no longer valid, refresh it
387 petInfo = &petStable->CurrentPet.value();
388 }
389
390 // Send fake summon spell cast - this is needed for correct cooldown application for spells
391 // Example: 46584 - without this cooldown (which should be set always when pet is loaded) isn't set clientside
393 if (petInfo->CreatedBySpellId && spellInfo && (spellInfo->CategoryRecoveryTime > 0 || spellInfo->RecoveryTime > 0))
394 {
395 WorldPacket data(SMSG_SPELL_GO, (8 + 8 + 4 + 4 + 2));
396 data << owner->GetPackGUID();
397 data << owner->GetPackGUID();
398 data << uint8(0);
399 data << uint32(petInfo->CreatedBySpellId);
400 data << uint32(256); // CAST_FLAG_UNKNOWN3
401 data << uint32(0);
402 owner->SendMessageToSet(&data, true);
403 }
404
405 owner->SetMinion(this, true);
406
407 if (!isTemporarySummon)
409
410 map->AddToMap(ToCreature(), true);
411
412 //set last used pet number (for use in BG's)
413 if (owner->IsPlayer() && isControlled() && !isTemporarySummoned() && (getPetType() == SUMMON_PET || getPetType() == HUNTER_PET))
414 owner->ToPlayer()->SetLastPetNumber(petInfo->PetNumber);
415
416 owner->GetSession()->AddQueryHolderCallback(CharacterDatabase.DelayQueryHolder(std::make_shared<PetLoadQueryHolder>(ownerid, petInfo->PetNumber)))
417 .AfterComplete([this, owner, session = owner->GetSession(), isTemporarySummon, current, lastSaveTime = petInfo->LastSaveTime, savedhealth = petInfo->Health, savedmana = petInfo->Mana, healthPct, fullMana]
418 (SQLQueryHolderBase const& holder)
419 {
420 if (session->GetPlayer() != owner || owner->GetPet() != this)
421 return;
422
423 // passing previous checks ensure that 'this' is still valid
424 if (m_removed)
425 return;
426
427 InitTalentForLevel(); // set original talents points before spell loading
428
429 uint32 timediff = uint32(GameTime::GetGameTime().count() - lastSaveTime);
430 _LoadAuras(holder.GetPreparedResult(PetLoadQueryHolder::AURAS), timediff);
431
432 // load action bar, if data broken will fill later by default spells.
433 if (!isTemporarySummon)
434 {
435 _LoadSpells(holder.GetPreparedResult(PetLoadQueryHolder::SPELLS));
436 InitTalentForLevel(); // re-init to check talent count
437 _LoadSpellCooldowns(holder.GetPreparedResult(PetLoadQueryHolder::COOLDOWNS));
438 LearnPetPassives();
439 InitLevelupSpellsForLevel();
440 if (GetMap()->IsBattleArena())
441 RemoveArenaAuras();
442
443 CastPetAuras(current);
444 }
445
446 CleanupActionBar(); // remove unknown spells from action bar after load
447
448 LOG_DEBUG("entities.pet", "New Pet has {}", GetGUID().ToString());
449
450 owner->PetSpellInitialize();
451 owner->SendTalentsInfoData(true);
452
453 if (owner->GetGroup())
455
456 if (getPetType() == HUNTER_PET)
457 {
459 {
460 m_declinedname = std::make_unique<DeclinedName>();
461 Field* fields = result->Fetch();
462 for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
463 m_declinedname->name[i] = fields[i].Get<std::string>();
464 }
465 }
466
467 uint32 curHealth = savedhealth;
468 if (healthPct)
469 {
470 curHealth = CountPctFromMaxHealth(healthPct);
471 }
472
473 uint32 curMana = savedmana;
474 if (fullMana)
475 curMana = GetMaxPower(POWER_MANA);
476
477 if (getPetType() == SUMMON_PET && !current) //all (?) summon pets come with full health when called, but not when they are current
478 {
481 }
482 else
483 {
484 if (!curHealth && getPetType() == HUNTER_PET)
486 else
487 {
488 SetHealth(curHealth > GetMaxHealth() ? GetMaxHealth() : curHealth);
490 }
491 }
492
493 // must be after SetMinion (owner guid check)
495 //LoadMechanicTemplateImmunity();
496 m_loading = false;
497 });
498
499 return true;
500}
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition DatabaseEnvFwd.h:45
#define ASSERT_NOTNULL(pointer)
Definition Errors.h:85
@ GROUP_UPDATE_PET
Definition Group.h:121
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition Optional.h:24
@ PET_SAVE_LAST_STABLE_SLOT
Definition PetDefines.h:45
@ UNIT_FLAG_PLAYER_CONTROLLED
Definition UnitDefines.h:260
#define MAX_DECLINED_NAME_CASES
Definition Unit.h:554
void LoadTemplateImmunities(int32 creatureImmunitiesId)
Definition Creature.cpp:2269
void SetReactState(ReactStates state)
A creature can have 3 ReactStates : Agressive, Passive, Neutral.
Definition Creature.h:99
Definition Map.h:168
bool AddToMap(T *, bool checkTransport=false)
Definition Map.cpp:307
bool IsPetGhoul() const
Definition TemporarySummon.h:95
LowType GetCounter() const
Definition ObjectGuid.h:149
PackedGuid const & GetPackGUID() const
Definition Object.h:122
@ DECLINED_NAMES
Definition Pet.cpp:138
Definition PetDefines.h:212
std::array< Optional< PetInfo >, MAX_PET_STABLES > StabledPets
Definition PetDefines.h:236
Optional< PetInfo > CurrentPet
Definition PetDefines.h:235
std::vector< PetInfo > UnslottedPets
Definition PetDefines.h:238
void setDeathState(DeathState s, bool despawn=false) override
A creature can be in 4 different states: Alive, JustDied, Corpse, and JustRespawned....
Definition Pet.cpp:654
void setPetType(PetType type)
Definition Pet.h:53
void SynchronizeLevelWithOwner()
Definition Pet.cpp:2417
void CleanupActionBar()
Definition Pet.cpp:2055
bool isTemporarySummoned() const
Definition Pet.h:55
bool isControlled() const
Definition Pet.h:54
static std::pair< PetStable::PetInfo const *, PetSaveMode > GetLoadPetInfo(PetStable const &stable, uint32 petEntry, uint32 petnumber, bool current)
Definition Pet.cpp:171
void SetGroupUpdateFlag(uint32 flag)
Definition Player.h:2524
bool CanTameExoticPets() const
Definition Player.h:2221
void SetTemporaryUnsummonedPetNumber(uint32 petnumber)
Definition Player.h:2464
bool IsPetNeedBeTemporaryUnsummoned() const
Definition Player.h:2467
PetStable * GetPetStable()
Definition Player.h:1226
bool CanSeeDKPet() const
Definition Player.h:2646
Pet * GetPet() const
Definition Player.cpp:9171
WorldSession * GetSession() const
Definition Player.h:2032
void RemovePet(Pet *pet, PetSaveMode mode, bool returnreagent=false)
Definition Player.cpp:9321
Group * GetGroup()
Definition Player.h:2518
void SetLastPetSpell(uint32 petspell)
Definition Player.h:2510
bool IsSpectator() const
Definition Player.h:2626
void SendMessageToSet(WorldPacket const *data, bool self) const override
Definition Player.cpp:5863
void SetLastPetNumber(uint32 petnumber)
Definition Player.h:2508
Definition QueryHolder.h:25
PreparedQueryResult GetPreparedResult(std::size_t index) const
Definition QueryHolder.cpp:37
void AfterComplete(std::function< void(SQLQueryHolderBase const &)> callback) &
Definition QueryHolder.h:77
uint32 RecoveryTime
Definition SpellInfo.h:372
uint32 CategoryRecoveryTime
Definition SpellInfo.h:373
int32 GetDuration() const
Definition SpellInfo.cpp:2778
void SetMinion(Minion *minion, bool apply)
Definition Unit.cpp:7602
void SetFullHealth()
Definition Unit.h:1140
void SetFaction(uint32 faction)
Definition Unit.cpp:6886
void ReplaceAllUnitFlags(UnitFlags flags)
Remove the Unit flag specify only.
Definition Unit.h:756
uint32 GetMaxHealth() const
Definition Unit.h:1123
float GetCombatReach() const override
Definition Unit.h:884
void SetHealth(uint32 val)
Definition Unit.cpp:12020
void SetNativeDisplayId(uint32 displayId)
Definition Unit.h:2000
uint32 GetMaxPower(Powers power) const
Definition Unit.h:1150
uint32 GetFaction() const override
Definition Unit.h:857
bool IsCritter() const
Definition Unit.h:839
void SetCanModifyStats(bool modifyStats)
Definition Unit.h:1111
uint32 CountPctFromMaxHealth(int32 pct) const
Definition Unit.h:1135
void SetCreatorGUID(ObjectGuid creator)
Definition Unit.h:722
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:2832
SQLQueryHolderCallback & AddQueryHolderCallback(SQLQueryHolderCallback &&callback)
Definition WorldSession.cpp:1429
@ SMSG_SPELL_GO
Definition Opcodes.h:336
void LoadPetActionBar(std::string const &data)
Definition CharmInfo.cpp:249
void SetPetNumber(uint32 petnumber, bool statwindow)
Definition CharmInfo.cpp:240
bool IsTameable(bool exotic) const
Definition CreatureData.h:269

References PetStable::PetInfo::ActionBar, WorldSession::AddQueryHolderCallback(), Map::AddToMap(), SQLQueryHolderCallback::AfterComplete(), ASSERT, ASSERT_NOTNULL, Player::CanSeeDKPet(), Player::CanTameExoticPets(), SpellInfo::CategoryRecoveryTime, CharacterDatabase, CLASS_CONTEXT_PET, 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(), WorldObject::GetClosePoint(), Unit::GetCombatReach(), ObjectGuid::GetCounter(), Unit::GetCreatePowers(), Creature::GetCreatureTemplate(), SpellInfo::GetDuration(), Unit::GetFaction(), Minion::GetFollowAngle(), GameTime::GetGameTime(), Player::GetGroup(), Object::GetGUID(), 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(), GROUP_UPDATE_PET, PetStable::PetInfo::Happiness, PetStable::PetInfo::Health, HUNTER_PET, Guardian::InitStatsForLevel(), Player::IsClass(), isControlled(), Unit::IsCritter(), Object::IsInWorld(), IsPermanentPetFor(), Minion::IsPetGhoul(), Player::IsPetNeedBeTemporaryUnsummoned(), Object::IsPlayer(), Position::IsPositionValid(), Player::IsSpectator(), CreatureTemplate::IsTameable(), isTemporarySummoned(), JustDied, PetStable::PetInfo::LastSaveTime, PetStable::PetInfo::Level, CharmInfo::LoadPetActionBar(), Creature::LoadTemplateImmunities(), LOG_DEBUG, LOG_ERROR, Unit::m_charmInfo, m_declinedname, m_loading, PetStable::PetInfo::Mana, MAX_DECLINED_NAME_CASES, PetStable::PetInfo::Name, Pet, 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, SpellInfo::RecoveryTime, 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(), Player::SetLastPetSpell(), Unit::SetMaxPower(), Unit::SetMinion(), WorldObject::SetName(), Unit::SetNativeDisplayId(), CharmInfo::SetPetNumber(), setPetType(), Unit::SetPower(), Unit::setPowerType(), Creature::SetReactState(), Unit::SetSheath(), Player::SetTemporaryUnsummonedPetNumber(), Unit::SetUInt32Value(), SHEATH_STATE_MELEE, SMSG_SPELL_GO, sObjectMgr, sScriptMgr, sSpellMgr, PetStable::StabledPets, SUMMON_PET, SynchronizeLevelWithOwner(), Object::ToCreature(), Object::ToPlayer(), Position::ToString(), PetStable::PetInfo::Type, 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 ( )
912{
913 uint32 curValue = GetPower(POWER_HAPPINESS);
914 if (curValue <= 0)
915 return;
916 int32 addvalue = 670; //value is 70/35/17/8/4 (per min) * 1000 / 8 (timer 7.5 secs)
917 if (IsInCombat()) //we know in combat happiness fades faster, multiplier guess
918 addvalue = int32(addvalue * 1.5f);
919 ModifyPower(POWER_HAPPINESS, -addvalue);
920}
int32 ModifyPower(Powers power, int32 val, bool withPowerUpdate=true)
Definition Unit.cpp:10842
bool IsInCombat() const
Definition Unit.h:949

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

Referenced by Update().

◆ Remove()

void Pet::Remove ( PetSaveMode  mode,
bool  returnreagent = false 
)
933{
934 GetOwner()->RemovePet(this, mode, returnreagent);
935}

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.

123{
125 if (IsInWorld())
126 {
130 }
131}
bool Remove(KEY_TYPE const &handle)
Definition TypeContainer.h:183
void RemoveFromWorld() override
Definition Unit.cpp:12224

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 
)
2005{
2006 PetSpellMap::iterator itr = m_spells.find(spell_id);
2007 if (itr == m_spells.end())
2008 return false;
2009
2010 if (itr->second.state == PETSPELL_REMOVED)
2011 return false;
2012
2013 if (itr->second.state == PETSPELL_NEW)
2014 m_spells.erase(itr);
2015 else
2016 itr->second.state = PETSPELL_REMOVED;
2017
2018 RemoveAurasDueToSpell(spell_id);
2019
2020 uint32 talentCost = GetTalentSpellCost(spell_id);
2021 if (talentCost > 0)
2022 {
2023 if (m_usedTalentCount > talentCost)
2024 m_usedTalentCount -= talentCost;
2025 else
2027 // update free talent points
2029 SetFreeTalentPoints(free_points > 0 ? free_points : 0);
2030 }
2031
2032 if (learn_prev)
2033 {
2034 if (uint32 prev_id = sSpellMgr->GetPrevSpellInChain (spell_id))
2035 learnSpell(prev_id);
2036 else
2037 learn_prev = false;
2038 }
2039
2040 // if remove last rank or non-ranked then update action bar at server and client if need
2041 if (clear_ab && !learn_prev && m_charmInfo->RemoveSpellFromActionBar(spell_id))
2042 {
2043 if (!m_loading)
2044 {
2045 // need update action bar for last removed rank
2046 if (Unit* owner = GetOwner())
2047 if (owner->IsPlayer())
2048 owner->ToPlayer()->PetSpellInitialize();
2049 }
2050 }
2051
2052 return true;
2053}
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:4969
bool RemoveSpellFromActionBar(uint32 spell_id)
Definition CharmInfo.cpp:211

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(), and sSpellMgr.

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

◆ ResetAuraUpdateMaskForRaid()

void Pet::ResetAuraUpdateMaskForRaid ( )
inline

References m_auraRaidUpdateMask.

◆ resetTalents()

bool Pet::resetTalents ( )
2080{
2081 Unit* owner = GetOwner();
2082 if (!owner || !owner->IsPlayer())
2083 return false;
2084
2085 if (!sScriptMgr->CanResetTalents(this))
2086 return false;
2087
2088 // not need after this call
2091
2093 if (!ci)
2094 return false;
2095 // Check pet talent type
2096 CreatureFamilyEntry const* pet_family = sCreatureFamilyStore.LookupEntry(ci->family);
2097 if (!pet_family || pet_family->petTalentType < 0)
2098 return false;
2099
2100 Player* player = owner->ToPlayer();
2101
2102 uint8 level = GetLevel();
2103 uint32 talentPointsForLevel = GetMaxTalentPointsForLevel(level);
2104
2105 if (m_usedTalentCount == 0)
2106 {
2107 SetFreeTalentPoints(talentPointsForLevel);
2108 return false;
2109 }
2110
2111 for (uint32 i = 0; i < sTalentStore.GetNumRows(); ++i)
2112 {
2113 TalentEntry const* talentInfo = sTalentStore.LookupEntry(i);
2114 if (!talentInfo)
2115 continue;
2116
2117 TalentTabEntry const* talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab);
2118 if (!talentTabInfo)
2119 continue;
2120
2121 // unlearn only talents for pets family talent type
2122 if (!((1 << pet_family->petTalentType) & talentTabInfo->petTalentMask))
2123 continue;
2124
2125 for (uint32 talentSpellId : talentInfo->RankID)
2126 {
2127 for (PetSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end();)
2128 {
2129 if (itr->second.state == PETSPELL_REMOVED)
2130 {
2131 ++itr;
2132 continue;
2133 }
2134 // remove learned spells (all ranks)
2135 uint32 itrFirstId = sSpellMgr->GetFirstSpellInChain(itr->first);
2136
2137 // unlearn if first rank is talent or learned by talent
2138 if (itrFirstId == talentSpellId)
2139 {
2140 unlearnSpell(itr->first, false);
2141 itr = m_spells.begin();
2142 continue;
2143 }
2144 else
2145 ++itr;
2146 }
2147 }
2148 }
2149
2150 SetFreeTalentPoints(talentPointsForLevel);
2151
2152 if (!m_loading)
2153 player->PetSpellInitialize();
2154 return true;
2155}
DBCStorage< TalentTabEntry > sTalentTabStore(TalentTabEntryfmt)
@ AT_LOGIN_RESET_PET_TALENTS
Definition Player.h:591
void RemoveAtLoginFlag(AtLoginFlags flags, bool persist=false)
Definition Player.cpp:15131
bool HasAtLoginFlag(AtLoginFlags f) const
Definition Player.h:2452
int32 petTalentType
Definition DBCStructure.h:789
uint32 TalentTab
Definition DBCStructure.h:1961
Definition DBCStructure.h:1976
uint32 petTalentMask
Definition DBCStructure.h:1983

References AT_LOGIN_RESET_PET_TALENTS, CreatureTemplate::family, Creature::GetCreatureTemplate(), Unit::GetLevel(), GetMaxTalentPointsForLevel(), GetOwner(), Player::HasAtLoginFlag(), Object::IsPlayer(), 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(), and unlearnSpell().

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

◆ resetTalentsForAllPetsOf()

void Pet::resetTalentsForAllPetsOf ( Player *  owner,
Pet *  online_pet = nullptr 
)
static
2158{
2159 // not need after this call
2161 {
2163 }
2164
2165 // reset for online
2166 if (onlinePet)
2167 {
2168 onlinePet->resetTalents();
2169 }
2170
2171 PetStable* petStable = owner->GetPetStable();
2172 if (!petStable)
2173 {
2174 return;
2175 }
2176
2177 std::unordered_set<uint32> petIds;
2178 if (petStable->CurrentPet)
2179 {
2180 petIds.insert(petStable->CurrentPet->PetNumber);
2181 }
2182
2183 for (Optional<PetStable::PetInfo> const& stabledPet : petStable->StabledPets)
2184 {
2185 if (stabledPet)
2186 {
2187 petIds.insert(stabledPet->PetNumber);
2188 }
2189 }
2190
2191 for (PetStable::PetInfo const& unslottedPet : petStable->UnslottedPets)
2192 {
2193 petIds.insert(unslottedPet.PetNumber);
2194 }
2195
2196 // now need only reset for offline pets (all pets except online case)
2197 if (onlinePet)
2198 {
2199 petIds.erase(onlinePet->GetCharmInfo()->GetPetNumber());
2200 }
2201
2202 // no offline pets
2203 if (petIds.empty())
2204 {
2205 return;
2206 }
2207
2208 bool need_comma = false;
2209 std::ostringstream ss;
2210 ss << "DELETE FROM pet_spell WHERE guid IN (";
2211
2212 for (uint32 id : petIds)
2213 {
2214 if (need_comma)
2215 {
2216 ss << ',';
2217 }
2218
2219 ss << id;
2220
2221 need_comma = true;
2222 }
2223
2224 ss << ") AND spell IN (";
2225
2226 need_comma = false;
2227 for (uint32 spell : sPetTalentSpells)
2228 {
2229 if (need_comma)
2230 {
2231 ss << ',';
2232 }
2233
2234 ss << spell;
2235
2236 need_comma = true;
2237 }
2238
2239 ss << ')';
2240
2241 CharacterDatabase.Execute(ss.str().c_str());
2242}
std::unordered_set< uint32 > sPetTalentSpells
Definition DBCStores.cpp:173

References AT_LOGIN_RESET_PET_TALENTS, CharacterDatabase, PetStable::CurrentPet, Unit::GetCharmInfo(), CharmInfo::GetPetNumber(), Player::GetPetStable(), Player::HasAtLoginFlag(), 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)
503{
504 // not save not player pets
505 if (!GetOwnerGUID().IsPlayer())
506 return;
507
508 // save only fully controlled creature
509 Player* owner = GetOwner()->ToPlayer();
510 if (!owner || !GetEntry() || !isControlled())
511 return;
512
513 // Spells and auras are not loaded yet and saving them would wipe the stored ones,
514 // but the caller still updates the pet stable, so a slot change or deletion must reach the DB.
515 if (m_loading)
516 {
517 if (mode == PET_SAVE_AS_DELETED)
519 else if (mode > PET_SAVE_AS_CURRENT)
520 {
522 stmt->SetData(0, uint8(mode));
523 stmt->SetData(1, GetOwnerGUID().GetCounter());
524 stmt->SetData(2, m_charmInfo->GetPetNumber());
525 CharacterDatabase.Execute(stmt);
526 }
527
528 return;
529 }
530
531 // not save pet as current if another pet temporary unsummoned
534 {
535 // pet will lost anyway at restore temporary unsummoned
536 if (getPetType() == HUNTER_PET)
537 return;
538
539 // for warlock case
541 }
542
543 uint32 curhealth = GetHealth();
544 uint32 curmana = GetPower(POWER_MANA);
545
546 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
547 // save auras before possibly removing them
548 _SaveAuras(trans);
549
550 // stable and not in slot saves
551 if (mode > PET_SAVE_AS_CURRENT)
553
554 _SaveSpells(trans);
555 _SaveSpellCooldowns(trans);
556 CharacterDatabase.CommitTransaction(trans);
557
558 // current/stable/not_in_slot
559 if (mode >= PET_SAVE_AS_CURRENT)
560 {
562 trans = CharacterDatabase.BeginTransaction();
563 // remove current data
564
566 stmt->SetData(0, m_charmInfo->GetPetNumber());
567 trans->Append(stmt);
568
569 // prevent existence another hunter pet in PET_SAVE_AS_CURRENT and PET_SAVE_NOT_IN_SLOT
571 {
572 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_PET_BY_SLOT);
573 stmt->SetData(0, ownerLowGUID);
576 trans->Append(stmt);
577 }
578 // other pets keep their rows when unsummoned, so only move them out of the current slot
579 else if (mode == PET_SAVE_AS_CURRENT)
580 {
583 stmt->SetData(1, ownerLowGUID);
585 stmt->SetData(3, m_charmInfo->GetPetNumber());
586 trans->Append(stmt);
587 }
588
589 // save pet
590 std::string actionBar = GenerateActionBarData();
591
592 if (owner->GetPetStable()->CurrentPet && owner->GetPetStable()->CurrentPet->PetNumber == m_charmInfo->GetPetNumber())
593 {
594 FillPetInfo(&owner->GetPetStable()->CurrentPet.value());
595 }
596
597 stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CHAR_PET);
598 stmt->SetData(0, m_charmInfo->GetPetNumber());
599 stmt->SetData(1, GetEntry());
600 stmt->SetData(2, ownerLowGUID);
601 stmt->SetData(3, GetNativeDisplayId());
603 stmt->SetData(5, uint8(getPetType()));
604 stmt->SetData(6, GetLevel());
606 stmt->SetData(8, uint8(GetReactState()));
607 stmt->SetData(9, GetName());
609 stmt->SetData(11, uint8(mode));
610 stmt->SetData(12, curhealth);
611 stmt->SetData(13, curmana);
612 stmt->SetData(14, GetPower(POWER_HAPPINESS));
613 stmt->SetData(15, GameTime::GetGameTime().count());
614 stmt->SetData(16, actionBar);
615
616 trans->Append(stmt);
617 CharacterDatabase.CommitTransaction(trans);
618 }
619 // delete
620 else
621 {
624 }
625}
@ CHAR_UPD_CHAR_PET_SLOT_BY_SLOT_EXCLUDE_ID
Definition CharacterDatabase.h:496
@ CHAR_DEL_CHAR_PET_BY_SLOT
Definition CharacterDatabase.h:498
@ CHAR_UPD_CHAR_PET_SLOT_BY_ID
Definition CharacterDatabase.h:495
@ CHAR_REP_CHAR_PET
Definition CharacterDatabase.h:499
void FillPetInfo(PetStable::PetInfo *petInfo) const
Definition Pet.cpp:2478
void _SaveAuras(CharacterDatabaseTransaction trans)
Definition Pet.cpp:1712
void _SaveSpellCooldowns(CharacterDatabaseTransaction trans)
Definition Pet.cpp:1553
void _SaveSpells(CharacterDatabaseTransaction trans)
Definition Pet.cpp:1600
void DeleteFromDB() override
Definition Pet.h:170
uint32 GetTemporaryUnsummonedPetNumber() const
Definition Player.h:2463
void RemoveAllAuras()
Definition Unit.cpp:5393

References _SaveAuras(), _SaveSpellCooldowns(), _SaveSpells(), CHAR_DEL_CHAR_PET_BY_ID, CHAR_DEL_CHAR_PET_BY_SLOT, CHAR_REP_CHAR_PET, CHAR_UPD_CHAR_PET_SLOT_BY_ID, CHAR_UPD_CHAR_PET_SLOT_BY_SLOT_EXCLUDE_ID, 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_AS_DELETED, 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(), 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 Creature.

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:106

References m_auraRaidUpdateMask.

Referenced by Unit::UpdateAuraForGroup().

◆ setDeathState()

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

A creature can be in 4 different states: Alive, JustDied, Corpse, and JustRespawned. The cycle follows the next order:

  • Alive: The creature is alive and has spawned in the world
  • JustDied: The creature has just died. This is the state just before his body appeared
  • Corpse: The creature has been removed from the world, and this corpse has been spawned
  • JustRespawned: The creature has just respawned. Follow when the corpse disappears and the respawn timer is finished
Parameters
stateSpecify one of 4 states above
despawnDespawn the creature immediately, without waiting for any movement to finish

Reimplemented from Minion.

655{
658 {
659 if (getPetType() == HUNTER_PET)
660 {
661 // pet corpse non lootable and non skinnable
664
665 //lose happiness when died and not in BG/Arena
666 MapEntry const* mapEntry = sMapStore.LookupEntry(GetMapId());
667 if (!mapEntry || (mapEntry->map_type != MAP_ARENA && mapEntry->map_type != MAP_BATTLEGROUND))
669
670 //SetUnitFlag(UNIT_FLAG_STUNNED);
671 }
672 }
673 else if (getDeathState() == DeathState::Alive)
674 {
675 //RemoveUnitFlag(UNIT_FLAG_STUNNED);
676 CastPetAuras(true);
677 }
678}
@ MAP_BATTLEGROUND
Definition DBCEnums.h:349
@ MAP_ARENA
Definition DBCEnums.h:350
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
@ UNIT_DYNFLAG_NONE
Definition SharedDefines.h:3353
@ UNIT_FLAG_SKINNABLE
Definition UnitDefines.h:283
void setDeathState(DeathState s, bool despawn=false) override
A creature can be in 4 different states: Alive, JustDied, Corpse, and JustRespawned....
Definition Creature.cpp:1972
void ReplaceAllDynamicFlags(uint32 flag) override
Definition Unit.h:775
DeathState getDeathState()
Definition Unit.h:1806
void RemoveUnitFlag(UnitFlags flags)
UnitFlags available in UnitDefines.h.
Definition Unit.h:755
Definition DBCStructure.h:1361
uint32 map_type
Definition DBCStructure.h:1364

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,
std::optional< float >  displayScale = {} 
)
overridevirtual

Reimplemented from Unit.

2442{
2443 Guardian::SetDisplayId(modelId, displayScale);
2444
2445 if (!isControlled())
2446 return;
2447
2448 if (Unit* owner = GetOwner())
2449 if (Player* player = owner->ToPlayer())
2450 if (player->GetGroup())
2451 player->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_MODEL_ID);
2452}
@ GROUP_UPDATE_FLAG_PET_MODEL_ID
Definition Group.h:113
virtual void SetDisplayId(uint32 modelId, std::optional< float > displayScale={})
Definition Unit.cpp:12837

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

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

◆ SetDuration()

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

References m_duration.

Referenced by Player::SummonPet().

◆ SetFreeTalentPoints()

void Pet::SetFreeTalentPoints ( uint8  points)
inline
@ UNIT_BYTES_1_OFFSET_PET_TALENTS
Definition UnitDefines.h:27
void SetByteValue(uint16 index, uint8 offset, uint8 value)
Definition Object.cpp:748

References Object::SetByteValue(), UNIT_BYTES_1_OFFSET_PET_TALENTS, and UNIT_FIELD_BYTES_1.

Referenced by addSpell(), learn_commandscript::HandleLearnAllMyPetTalentsCommand(), InitTalentForLevel(), Player::LearnPetTalent(), removeSpell(), and resetTalents().

◆ SetLoading()

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

References m_loading.

◆ setPetType()

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

References m_petType.

Referenced by LoadPetFromDB().

◆ SynchronizeLevelWithOwner()

void Pet::SynchronizeLevelWithOwner ( )
2418{
2419 Unit* owner = GetOwner();
2420 if (!owner || !owner->IsPlayer())
2421 return;
2422
2423 switch (getPetType())
2424 {
2425 // always same level
2426 case SUMMON_PET:
2427 GivePetLevel(owner->GetLevel());
2428 break;
2429 // can't be greater owner level
2430 case HUNTER_PET:
2431 if (GetLevel() > owner->GetLevel())
2432 GivePetLevel(owner->GetLevel());
2433 else if (GetLevel() + 5 < owner->GetLevel())
2434 GivePetLevel(owner->GetLevel() - 5);
2435 break;
2436 default:
2437 break;
2438 }
2439}

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

Referenced by LoadPetFromDB().

◆ ToggleAutocast()

void Pet::ToggleAutocast ( SpellInfo const *  spellInfo,
bool  apply 
)
2276{
2277 ASSERT(spellInfo);
2278
2279 if (!spellInfo->IsAutocastable())
2280 return;
2281
2282 PetSpellMap::iterator itr = m_spells.find(spellInfo->Id);
2283 if (itr == m_spells.end())
2284 return;
2285
2286 auto autospellItr = std::find(m_autospells.begin(), m_autospells.end(), spellInfo->Id);
2287
2288 if (apply)
2289 {
2290 if (autospellItr == m_autospells.end())
2291 {
2292 m_autospells.push_back(spellInfo->Id);
2293
2294 if (itr->second.active != ACT_ENABLED)
2295 {
2296 itr->second.active = ACT_ENABLED;
2297 if (itr->second.state != PETSPELL_NEW)
2298 itr->second.state = PETSPELL_CHANGED;
2299 }
2300 }
2301 }
2302 else
2303 {
2304 if (autospellItr != m_autospells.end())
2305 {
2306 m_autospells.erase(autospellItr);
2307 if (itr->second.active != ACT_DISABLED)
2308 {
2309 itr->second.active = ACT_DISABLED;
2310 if (itr->second.state != PETSPELL_NEW)
2311 itr->second.state = PETSPELL_CHANGED;
2312 }
2313 }
2314 }
2315}

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 
)
1988{
1989 if (removeSpell(spell_id, learn_prev, clear_ab))
1990 {
1991 if (!m_loading)
1992 {
1994 packet.SpellID = spell_id;
1995 m_owner->SendDirectMessage(packet.Write());
1996 }
1997
1998 return true;
1999 }
2000
2001 return false;
2002}
Definition PetPackets.h:82
WorldPacket const * Write() override
Definition PetPackets.cpp:48
uint32 SpellID
Definition PetPackets.h:88

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 Creature.

681{
682 auto _diff = Milliseconds(diff);
683
684 if (m_removed) // pet already removed, just wait in remove queue, no updates
685 return;
686
687 if (m_loading)
688 return;
689
690 switch (m_deathState)
691 {
693 {
695 {
696 Remove(PET_SAVE_NOT_IN_SLOT); //hunters' pets never get removed because of death, NEVER!
697 return;
698 }
699 break;
700 }
702 {
703 // unsummon pet that lost owner
704 Player* owner = GetOwner();
705 if (!owner || (!IsWithinDistInMap(owner, GetMap()->GetVisibilityRange()) && !isPossessed()) || (isControlled() && !owner->GetPetGUID()))
706 //if (!owner || (!IsWithinDistInMap(owner, GetMap()->GetVisibilityDistance()) && (owner->GetCharmGUID() && (owner->GetCharmGUID() != GetGUID()))) || (isControlled() && !owner->GetPetGUID()))
707 {
709 return;
710 }
711
712 if (isControlled())
713 {
714 if (owner->GetPetGUID() != GetGUID())
715 {
716 LOG_ERROR("entities.pet", "Pet {} is not pet of owner {}, removed", GetEntry(), GetOwner()->GetName());
717 ASSERT(getPetType() != HUNTER_PET, "Unexpected unlinked pet found for owner {}", owner->GetSession()->GetPlayerInfo());
719 return;
720 }
721 }
722
723 if (m_duration > 0ms)
724 {
725 if (m_duration > _diff)
726 m_duration -= _diff;
727 else
728 {
730 return;
731 }
732 }
733
734 // xinef: m_regenTimer is decrased in Creature::Update()
735 // xinef: just check if we can update focus in current period
736 if (getPowerType() == POWER_FOCUS)
737 {
738 m_petRegenTimer -= _diff;
739 if (m_petRegenTimer <= 0ms)
740 {
743 }
744 }
745
747
748 if (getPetType() == HUNTER_PET)
749 {
750 m_happinessTimer -= diff;
751 if (m_happinessTimer <= int32(0))
752 {
755 }
756 }
757
758 break;
759 }
760 default:
761 break;
762 }
763
764 Creature::Update(diff);
765}
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition Duration.h:27
void Update(uint32 time) override
Definition Creature.cpp:710
time_t m_corpseRemoveTime
Timers.
Definition Creature.h:477
void Regenerate(Powers power)
Definition Creature.cpp:986
void Remove(PetSaveMode mode, bool returnreagent=false)
Definition Pet.cpp:932
void CastPendingSpell()
Definition Pet.cpp:767
void LoseHappiness()
Definition Pet.cpp:911
DeathState m_deathState
Definition Unit.h:2174
bool isPossessed() const
Definition Unit.h:1328
Powers getPowerType() const
Definition Unit.h:1145
ObjectGuid GetPetGUID() const
Definition Unit.h:729
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition Object.cpp:1386
float GetVisibilityRange() const
Definition Object.cpp:1710
std::string GetPlayerInfo() const
Definition WorldSession.cpp:273

References Alive, ASSERT, CastPendingSpell(), Corpse, Object::GetEntry(), GameTime::GetGameTime(), Object::GetGUID(), WorldObject::GetMap(), WorldObject::GetName(), GetOwner(), Unit::GetPetGUID(), getPetType(), WorldSession::GetPlayerInfo(), Unit::getPowerType(), Player::GetSession(), WorldObject::GetVisibilityRange(), HUNTER_PET, isControlled(), Unit::isPossessed(), WorldObject::IsWithinDistInMap(), LOG_ERROR, LoseHappiness(), Creature::m_corpseRemoveTime, Unit::m_deathState, m_duration, m_happinessTimer, m_loading, m_petRegenTimer, m_removed, PET_FOCUS_REGEN_INTERVAL, PET_LOSE_HAPPINES_INTERVAL, PET_SAVE_AS_DELETED, PET_SAVE_NOT_IN_SLOT, POWER_FOCUS, Creature::Regenerate(), Remove(), SUMMON_PET, 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

ObjectGuid Pet::m_tempoldTarget
protected

◆ m_tempspell

◆ m_tempspellIsPositive

bool Pet::m_tempspellIsPositive
protected

◆ m_tempspellTarget

ObjectGuid Pet::m_tempspellTarget
protected

◆ m_usedTalentCount


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