OregonCore  revision fb2a440-git
Your Favourite TBC server
Pet Class Reference

#include <Pet.h>

+ Inheritance diagram for Pet:

Public Member Functions

 Pet (Player *owner, PetType type=MAX_PET_TYPE)
 ~Pet () override
void AddToWorld () override
void RemoveFromWorld () override
PetType getPetType () const
void setPetType (PetType type)
bool isControlled () const
bool isTemporarySummoned () const
bool IsPermanentPetFor (Player *owner)
bool Create (uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 pet_number)
bool CreateBaseAtCreature (Creature *creature)
bool LoadPetFromDB (Player *owner, uint32 petentry=0, uint32 petnumber=0, bool current=false)
void SavePetToDB (PetSaveMode mode)
void Remove (PetSaveMode mode, bool returnreagent=false)
void setDeathState (DeathState s) override
void Update (uint32 diff) override
uint8 GetPetAutoSpellSize () const override
uint32 GetPetAutoSpellOnPos (uint8 pos) const override
void RegenerateFocus ()
void LoseHappiness ()
void TickLoyaltyChange ()
void ModifyLoyalty (int32 addvalue)
HappinessState GetHappinessState ()
uint32 GetMaxLoyaltyPoints (uint32 level)
uint32 GetStartLoyaltyPoints (uint32 level)
void KillLoyaltyBonus (uint32 level)
uint32 GetLoyaltyLevel ()
void SetLoyaltyLevel (LoyaltyLevel level)
void GivePetXP (uint32 xp)
void GivePetLevel (uint32 level)
void InitPetAuras (const uint32 Entry)
bool HaveInDiet (ItemTemplate const *item) const
uint32 GetCurrentFoodBenefitLevel (uint32 itemlevel)
void SetDuration (int32 dur)
bool CanSwim () const
bool CanTakeMoreActiveSpells (uint32 SpellIconID)
void ToggleAutocast (uint32 spellid, bool apply)
bool HasTPForSpell (uint32 spellid)
int32 GetTPForSpell (uint32 spellid)
void ApplyModeFlags (PetModeFlags mode, bool apply)
PetModeFlags GetModeFlags () const
bool HasSpell (uint32 spell) const override
void AddTeachSpell (uint32 learned_id, uint32 source_id)
void LearnPetPassives ()
void CastPetAuras (bool current)
void CastPetAura (PetAura const *aura)
void _LoadSpellCooldowns ()
void _SaveSpellCooldowns ()
void _LoadAuras (uint32 timediff)
void _SaveAuras ()
void _LoadSpells ()
void _SaveSpells ()
bool addSpell (uint16 spell_id, uint16 active=ACT_DECIDE, PetSpellState state=PETSPELL_NEW, PetSpellType type=PETSPELL_NORMAL)
bool learnSpell (uint16 spell_id)
void removeSpell (uint16 spell_id)
void InitPetCreateSpells ()
void CheckLearning (uint32 spellid)
uint32 resetTalentsCost () const
void SetTP (int32 TP)
int32 GetDispTP ()
uint64 GetAuraUpdateMask ()
void SetAuraUpdateMask (uint8 slot)
void UnsetAuraUpdateMask (uint8 slot)
void ResetAuraUpdateMask ()
DeclinedName const * GetDeclinedNames () const
PlayerGetOwner ()
- Public Member Functions inherited from Guardian
 Guardian (SummonPropertiesEntry const *properties, Unit *owner, bool isWorldObject)
void InitStats (uint32 duration) override
bool InitStatsForLevel (uint32 level)
void InitSummon () override
bool UpdateStats (Stats stat) override
bool UpdateAllStats () override
void UpdateResistances (uint32 school) override
void UpdateArmor () override
void UpdateMaxHealth () override
void UpdateMaxPower (Powers power) override
void UpdateAttackPowerAndDamage (bool ranged=false) override
void UpdateDamagePhysical (WeaponAttackType attType) override
int32 GetBonusDamage ()
void SetBonusDamage (int32 damage)
- Public Member Functions inherited from Minion
 Minion (SummonPropertiesEntry const *properties, Unit *owner, bool isWorldObject)
void RemoveFromWorld () override
UnitGetOwner ()
float GetFollowAngle () const override
void SetFollowAngle (float angle)
bool IsGuardianPet () const
- Public Member Functions inherited from TempSummon
 TempSummon (SummonPropertiesEntry const *properties, Unit *owner, bool isWorldObject)
 ~TempSummon () override
void Update (uint32 time) override
void UnSummon (uint32 msTime=0)
void SetTempSummonType (TempSummonType type)
TempSummonType GetTempSummonType () const
void SaveToDB () override
UnitGetSummoner () const
void SetSummoner (Unit *summoner)
- Public Member Functions inherited from Creature
 Creature (bool isWorldObject=false)
 ~Creature () override
void DisappearAndDie ()
bool Create (uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 team, float x, float y, float z, float ang, const CreatureData *data=NULL)
bool LoadCreaturesAddon (bool reload=false)
void SelectLevel ()
void LoadEquipment (uint32 equip_entry, bool force=false)
uint32 GetDBTableGUIDLow () const
char const * GetSubName () const
void GetRespawnPosition (float &x, float &y, float &z, float *ori=NULL, float *dist=NULL) const
uint32 GetEquipmentId () const
void SetVirtualItem (VirtualItemSlot slot, uint32 item_id)
void SetVirtualItemRaw (VirtualItemSlot slot, uint32 display_id, uint32 info0, uint32 info1)
void SetCorpseDelay (uint32 delay)
bool IsRacialLeader () const
bool IsCivilian () const
bool IsTrigger () const
bool IsGuard () const
bool CanWalk () const
bool CanSwim () const
bool CanFly () const
void SetReactState (ReactStates st)
ReactStates GetReactState () const
bool HasReactState (ReactStates state) const
void InitializeReactState ()
bool IsTrainerOf (Player *player, bool msg) const
bool CanInteractWithBattleMaster (Player *player, bool msg) const
bool CanTrainAndResetTalentsOf (Player *pPlayer) const
bool CanCreatureAttack (Unit const *victim, bool force=true) const
bool IsImmuneToSpell (SpellEntry const *spellInfo, bool useCharges=false) override
bool IsImmuneToSpellEffect (SpellEntry const *spellInfo, uint32 index, bool castOnSelf) const override
bool isElite () const
bool isWorldBoss () const
uint8 getLevelForTarget (Unit const *target) const
bool IsInEvadeMode () const
bool AIM_Initialize (CreatureAI *ai=NULL)
CreatureAIAI () const
uint32 GetShieldBlockValue () const override
SpellSchoolMask GetMeleeDamageSchoolMask () const override
void SetMeleeDamageSchool (SpellSchools school)
void _AddCreatureSpellCooldown (uint32 spell_id, time_t end_time)
void _AddCreatureCategoryCooldown (uint32 category, time_t apply_time)
void AddCreatureSpellCooldown (uint32 spellid)
bool HasSpellCooldown (uint32 spell_id) const
bool HasCategoryCooldown (uint32 spell_id) const
bool UpdateEntry (uint32 entry, uint32 team=ALLIANCE, const CreatureData *data=NULL)
void UpdateMovementFlags (bool packetOnly=false)
void CalculateMinMaxDamage (WeaponAttackType attType, bool normalized, bool addTotalPct, float &minDamage, float &maxDamage) override
void SetCanDualWield (bool value)
void SetCurrentEquipmentId (uint8 id)
uint32 GetCurrentEquipmentId ()
float GetSpellDamageMod (int32 Rank) const
VendorItemData const * GetVendorItems () const
uint32 GetVendorItemCurrentCount (VendorItem const *vItem)
uint32 UpdateVendorItemCurrentCount (VendorItem const *vItem, uint32 used_count)
TrainerSpellData const * GetTrainerSpells () const
CreatureInfo const * GetCreatureTemplate () const
CreatureData const * GetCreatureData () const
CreatureDataAddon const * GetCreatureAddon () const
std::string GetAIName () const
std::string GetScriptName ()
uint32 GetScriptId ()
void setEmoteState (uint8 emote)
void Say (const char *text, uint32 language, uint64 TargetGuid)
void Yell (const char *text, uint32 language, uint64 TargetGuid)
void TextEmote (const char *text, uint64 TargetGuid, bool IsBossEmote=false)
void Whisper (const char *text, uint64 receiver, bool IsBossWhisper=false)
void Say (int32 textId, uint32 language, uint64 TargetGuid)
void Yell (int32 textId, uint32 language, uint64 TargetGuid)
void TextEmote (int32 textId, uint64 TargetGuid, bool IsBossEmote=false)
void Whisper (int32 textId, uint64 receiver, bool IsBossWhisper=false)
const char * GetNameForLocaleIdx (int32 locale_idx) const override
bool LoadFromDB (uint32 guid, Map *map)
bool LoadCreatureFromDB (uint32 guid, Map *map, bool addToMap=true)
void StartPickPocketRefillTimer ()
void ResetPickPocketRefillTimer ()
bool CanGeneratePickPocketLoot () const
void SetSkinner (uint64 guid)
uint64 GetSkinner () const
PlayerGetLootRecipient () const
GroupGetLootRecipientGroup () const
bool hasLootRecipient () const
bool isTappedBy (Player const *player) const
void SetLootRecipient (Unit *unit)
void AllLootRemovedFromCorpse ()
SpellEntry const * reachWithSpellAttack (Unit *pVictim)
SpellEntry const * reachWithSpellCure (Unit *pVictim)
bool canStartAttack (Unit const *u, bool force) const
float GetAttackDistance (Unit const *pl) const
float GetAggroRange (Unit const *target) const
void SendAIReaction (AiReaction reactionType)
UnitSelectNearestTarget (float dist=0, bool playerOnly=false) const
UnitSelectNearestTargetInAttackDistance (float dist=0) const
UnitSelectNearestHostileUnitInAggroRange (bool useLOS=false) const
void DoFleeToGetAssistance ()
void CallForHelp (float fRadius)
void CallAssistance ()
void SetNoCallAssistance (bool val)
void SetNoSearchAssistance (bool val)
bool HasSearchedAssistance () const
bool CanAssistTo (const Unit *u, const Unit *enemy, bool checkfaction=true) const
bool _IsTargetAcceptable (const Unit *target) const
MovementGeneratorType GetDefaultMovementType () const
void SetDefaultMovementType (MovementGeneratorType mgt)
Cell const & GetCurrentCell () const
void SetCurrentCell (Cell const &cell)
void RemoveCorpse (bool setSpawnTime=true)
void ForcedDespawn (uint32 timeMSToDespawn=0)
void DespawnOrUnsummon (uint32 msTimeToDespawn=0)
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)
float GetRespawnRadius () const
void SetRespawnRadius (float dist)
uint32 GetCombatPulseDelay () const
void SetCombatPulseDelay (uint32 delay)
time_t GetLinkedCreatureRespawnTime () const
const CreatureDataGetLinkedRespawnCreatureData () const
void SendZoneUnderAttackMessage (Player *attacker)
void SetInCombatWithZone ()
bool hasQuest (uint32 quest_id) const override
bool hasInvolvedQuest (uint32 quest_id) const override
bool isRegeneratingHealth ()
void setRegeneratingHealth (bool regenHealth)
void SetHomePosition (float x, float y, float z, float o)
void SetHomePosition (const Position &pos)
void GetHomePosition (float &x, float &y, float &z, float &ori)
Position GetHomePosition ()
uint32 GetGlobalCooldown () const
uint32 GetWaypointPath ()
void LoadPath (uint32 pathid)
uint32 GetCurrentWaypointID ()
void UpdateWaypointID (uint32 wpID)
void SearchFormation ()
CreatureGroupGetFormation ()
void SetFormation (CreatureGroup *formation)
UnitSelectVictim ()
void SetDisableReputationGain (bool disable)
bool IsReputationGainDisabled ()
bool IsDamageEnoughForLootingAndReward () const
void SetPlayerDamaged (bool set)
uint32 GetOriginalEntry () const
void SetOriginalEntry (uint32 entry)
bool SetLevitate (bool enable, bool packetOnly=false) override
bool SetWalk (bool enable) override
bool SetSwim (bool enable) override
bool SetCanFly (bool enable, bool packetOnly=false) override
bool SetFeatherFall (bool enable, bool packetOnly=false) override
bool SetWaterWalking (bool enable, bool packetOnly=false) override
bool SetHover (bool enable, bool packetOnly=false) override
CreatureTextRepeatIds GetTextRepeatGroup (uint8 textGroup)
void SetTextRepeatId (uint8 textGroup, uint8 id)
void ClearTextRepeatGroup (uint8 textGroup)
- Public Member Functions inherited from Unit
 ~Unit () override
void AddToWorld () override
void RemoveFromWorld () override
void CleanupsBeforeDelete () override
DiminishingLevels GetDiminishing (DiminishingGroup group)
void IncrDiminishing (DiminishingGroup group)
void ApplyDiminishingToDuration (DiminishingGroup group, int32 &duration, Unit *caster, DiminishingLevels Level)
void ApplyDiminishingAura (DiminishingGroup group, bool apply)
void ClearDiminishings ()
uint32 GetSpellRadiusForTarget (Unit *target, const SpellRadiusEntry *radiusEntry)
void Update (uint32 time) override
void setAttackTimer (WeaponAttackType type, uint32 time)
void resetAttackTimer (WeaponAttackType type=BASE_ATTACK)
uint32 getAttackTimer (WeaponAttackType type) const
bool isAttackReady (WeaponAttackType type=BASE_ATTACK) const
bool haveOffhandWeapon () const
bool UpdateMeleeAttackingState ()
bool CanUseEquippedWeapon (WeaponAttackType attackType) const
bool CanDualWield () const
float GetCombatReach () const
float GetMeleeReach () const
bool IsWithinCombatRange (const Unit *obj, float dist2compare) const
bool IsWithinMeleeRange (Unit *obj, float dist=MELEE_RANGE) const
void GetRandomContactPoint (const Unit *target, float &x, float &y, float &z, float distance2dMin, float distance2dMax) const
void _addAttacker (Unit *pAttacker)
void _removeAttacker (Unit *pAttacker)
UnitgetAttackerForHelper () const
bool Attack (Unit *victim, bool meleeAttack)
void CastStop (uint32 except_spellid=0)
bool AttackStop ()
void RemoveAllAttackers ()
AttackerSet const & getAttackers () const
bool isAttackingPlayer () const
UnitGetVictim () const
void CombatStop (bool cast=false)
void CombatStopWithPets (bool cast=false)
UnitSelectNearbyTarget (Unit *exclude=NULL, float dist=NOMINAL_MELEE_RANGE) const
PlayerSelectNearestPlayer (float distance=0) const
void SendMeleeAttackStop (Unit *victim=NULL)
void SendMeleeAttackStart (Unit *victim)
void SetCritterGUID (uint64 guid)
uint64 GetCritterGUID () const
void AddUnitState (uint32 f)
bool HasUnitState (const uint32 f) const
void ClearUnitState (uint32 f)
bool CanFreeMove () const
uint32 HasUnitTypeMask (uint32 mask) const
void AddUnitTypeMask (uint32 mask)
bool IsSummon () const
bool IsGuardian () const
bool IsPet () const
bool IsHunterPet () const
bool IsTotem () const
bool IsDuringRemoveFromWorld () const
PetToPet ()
Pet const * ToPet () const
uint8 getLevel () const
uint8 getLevelForTarget (WorldObject const *) const override
void SetLevel (uint32 lvl)
uint8 getRace () const
uint32 getRaceMask () const
uint8 getClass () const
uint32 getClassMask () const
uint8 getGender () const
float GetStat (Stats stat) const
void SetStat (Stats stat, int32 val)
uint32 GetArmor () const
void SetArmor (int32 val)
uint32 GetResistance (SpellSchools school) const
void SetResistance (SpellSchools school, int32 val)
uint32 GetHealth () const
uint32 GetMaxHealth () const
bool ShouldRevealHealthTo (Player *player) const
void SendHealthUpdateDueToCharm (Player *charmer)
bool IsFullHealth () const
bool HealthBelowPct (int32 pct) const
bool HealthBelowPctDamaged (int32 pct, uint32 damage) const
bool HealthAbovePct (int32 pct) const
bool HealthAbovePctHealed (int32 pct, uint32 heal) const
float GetHealthPct () const
uint32 CountPctFromMaxHealth (int32 pct) const
uint32 CountPctFromCurHealth (int32 pct) const
void SetHealth (uint32 val)
void SetMaxHealth (uint32 val)
void SetFullHealth ()
int32 ModifyHealth (int32 val)
Powers getPowerType () const
void setPowerType (Powers power)
uint32 GetPower (Powers power) const
uint32 GetMaxPower (Powers power) const
void SetPower (Powers power, uint32 val)
void SetMaxPower (Powers power, uint32 val)
int32 ModifyPower (Powers power, int32 val)
void ApplyPowerMod (Powers power, uint32 val, bool apply)
void ApplyMaxPowerMod (Powers power, uint32 val, bool apply)
uint32 GetAttackTime (WeaponAttackType att) const
void SetAttackTime (WeaponAttackType att, uint32 val)
void ApplyAttackTimePercentMod (WeaponAttackType att, float val, bool apply)
void ApplyCastTimePercentMod (float val, bool apply)
SheathState GetSheath () const
virtual void SetSheath (SheathState sheathed)
uint32 GetFaction () const
void SetFaction (uint32 faction)
FactionTemplateEntry const * GetFactionTemplateEntry () const
ReputationRank GetReactionTo (Unit const *target) const
bool IsHostileTo (Unit const *unit) const
bool IsHostileToPlayers () const
bool IsFriendlyTo (Unit const *unit) const
bool IsNeutralToAll () const
bool IsInPartyWith (Unit const *unit) const
bool IsInRaidWith (Unit const *unit) const
void GetPartyMember (std::list< Unit * > &units, float dist)
void GetRaidMember (std::list< Unit * > &units, float dist)
bool IsContestedGuard () const
bool IsInSanctuary () const
bool IsPvP () const
void SetPvP (bool state)
uint32 GetCreatureType () const
uint32 GetCreatureTypeMask () const
uint8 GetStandState () const
bool IsSitState () const
bool IsStandState () const
void SetStandState (uint8 state)
void SetStandFlags (uint8 flags)
void RemoveStandFlags (uint8 flags)
bool IsMounted () const
uint32 GetMountID () const
void Mount (uint32 mount, uint32 spellId=0)
void Dismount ()
bool HasShapeshiftChangingModel () const
uint32 GetMaxSkillValueForLevel (Unit const *target=nullptr) const
void RemoveSpellbyDamageTaken (uint32 damage, uint32 spell)
uint32 DealDamage (Unit *victim, uint32 damage, CleanDamage const *cleanDamage=NULL, DamageEffectType damagetype=DIRECT_DAMAGE, SpellSchoolMask damageSchoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellEntry const *spellProto=NULL, bool durabilityLoss=true)
void Kill (Unit *victim, bool durabilityLoss=true)
void ProcDamageAndSpell (Unit *victim, uint32 procAttacker, uint32 procVictim, uint32 procEx, uint32 amount, WeaponAttackType attType=BASE_ATTACK, SpellEntry const *procSpell=NULL, bool canTrigger=true)
void ProcDamageAndSpellFor (bool isVictim, Unit *pTarget, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, SpellEntry const *procSpell, uint32 damage)
void HandleEmoteCommand (uint32 anim_id)
void AttackerStateUpdate (Unit *victim, WeaponAttackType attType=BASE_ATTACK, bool extra=false)
float MeleeMissChanceCalc (const Unit *victim, WeaponAttackType attType) const
void CalculateMeleeDamage (Unit *victim, uint32 damage, CalcDamageInfo *damageInfo, WeaponAttackType attackType=BASE_ATTACK)
void DealMeleeDamage (CalcDamageInfo *damageInfo, bool durabilityLoss)
void CalculateSpellDamageTaken (SpellNonMeleeDamage *damageInfo, int32 damage, SpellEntry const *spellInfo, WeaponAttackType attackType=BASE_ATTACK, bool crit=false)
void DealSpellDamage (SpellNonMeleeDamage *damageInfo, bool durabilityLoss)
float MeleeSpellMissChance (const Unit *victim, WeaponAttackType attType, int32 skillDiff, uint32 spellId) const
SpellMissInfo MeleeSpellHitResult (Unit *victim, SpellEntry const *spell, bool cMiss=true)
SpellMissInfo MagicSpellHitResult (Unit *victim, SpellEntry const *spell)
SpellMissInfo SpellHitResult (Unit *victim, SpellEntry const *spell, bool canReflect=false, bool canMiss=true)
float GetUnitDodgeChance () const
float GetUnitParryChance () const
float GetUnitBlockChance () const
float GetUnitCriticalChance (WeaponAttackType attackType, const Unit *victim) const
int32 GetMechanicResistChance (const SpellEntry *spell)
bool CanUseAttackType (uint8 attacktype) const
uint32 GetUnitMeleeSkill (Unit const *target=NULL) const
uint32 GetDefenseSkillValue (Unit const *target=NULL) const
uint32 GetWeaponSkillValue (WeaponAttackType attType, Unit const *target=NULL) const
float GetWeaponProcChance () const
float GetPPMProcChance (uint32 WeaponSpeed, float PPM) const
MeleeHitOutcome RollMeleeOutcomeAgainst (const Unit *victim, WeaponAttackType attType) const
MeleeHitOutcome RollMeleeOutcomeAgainst (const Unit *victim, WeaponAttackType attType, int32 crit_chance, int32 miss_chance, int32 dodge_chance, int32 parry_chance, int32 block_chance, bool SpellCasted) 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
bool IsCritter () const
bool IsPlayer () const
bool IsInFlight () const
bool IsInitiatingCombat () const
bool IsInCombat () const
bool IsPetInCombat () const
bool IsInCombatWith (Unit const *who) const
void CombatStart (Unit *target, bool initialAggro=true)
void SetInCombatState (bool PvP, Unit *enemy=NULL)
void SetInitiatingCombat (bool flag)
void SetInCombatWith (Unit *enemy)
void ClearInCombat ()
void ClearInPetCombat ()
uint32 IsInPvPCombat () const
uint32 GetAuraCount (uint32 spellId) const
bool HasAuraType (AuraType auraType) const
bool HasAuraTypeWithCaster (AuraType auratype, uint64 caster) const
bool HasAuraTypeWithMiscvalue (AuraType auratype, int32 miscvalue) const
bool HasAuraTypeWithFamilyFlags (AuraType auraType, uint32 familyName, uint64 familyFlags) const
bool HasNegativeAuraWithInterruptFlag (uint32 flag)
bool HasAura (uint32 spellId, uint8 effIndex=0) const
bool HasHigherRankOfAura (uint32 spellid, uint8 effIndex) const
bool HasStealthAura () const
bool HasInvisibilityAura () const
bool IsFeared () const
bool IsInRoots () const
bool IsPolymorphed () const
bool isFrozen () const
bool isTargetableForAttack (bool checkFakeDeath=true) const
bool IsValidAttackTarget (Unit const *target) const
bool _IsValidAttackTarget (Unit const *target, SpellEntry const *bySpell, WorldObject const *obj=NULL) const
bool isAttackableByAOE (float x=0, float y=0, float z=0, bool LosCheck=false) const
bool IsValidAssistTarget (Unit const *target) const
bool _IsValidAssistTarget (Unit const *target, SpellEntry const *bySpell) const
virtual bool IsInWater () const
virtual bool IsUnderWater () const
bool isInAccessiblePlaceFor (Creature const *c) const
virtual uint32 GetHighestLearnedRankOf (uint32 spellid) const
void SendHealSpellLog (Unit *victim, uint32 SpellID, uint32 Damage, bool critical=false)
void SendEnergizeSpellLog (Unit *victim, uint32 SpellID, uint32 Damage, Powers powertype)
void EnergizeBySpell (Unit *victim, uint32 SpellID, uint32 Damage, Powers powertype)
uint32 SpellNonMeleeDamageLog (Unit *victim, uint32 spellID, uint32 damage, bool isTriggeredSpell=false, bool useSpellDamage=true)
void CastSpell (Unit *Victim, uint32 spellId, bool triggered, Item *castItem=NULL, Aura *triggeredByAura=NULL, uint64 originalCaster=0)
void CastSpell (Unit *Victim, SpellEntry const *spellInfo, bool triggered, Item *castItem=NULL, Aura *triggeredByAura=NULL, uint64 originalCaster=0)
void CastCustomSpell (Unit *Victim, uint32 spellId, int32 const *bp0, int32 const *bp1, int32 const *bp2, bool triggered, Item *castItem=NULL, Aura *triggeredByAura=NULL, uint64 originalCaster=0)
void CastCustomSpell (uint32 spellId, SpellValueMod mod, uint32 value, Unit *Victim=NULL, bool triggered=true, Item *castItem=NULL, Aura *triggeredByAura=NULL, uint64 originalCaster=0)
void CastCustomSpell (uint32 spellId, CustomSpellValues const &value, Unit *Victim=NULL, bool triggered=true, Item *castItem=NULL, Aura *triggeredByAura=NULL, uint64 originalCaster=0)
void CastSpell (float x, float y, float z, uint32 spellId, bool triggered, Item *castItem=NULL, Aura *triggeredByAura=NULL, uint64 originalCaster=0)
void CastSpell (GameObject *go, uint32 spellId, bool triggered, Item *castItem=NULL, Aura *triggeredByAura=NULL, uint64 originalCaster=0)
void AddAura (uint32 spellId, Unit *target)
void DeMorph ()
void SendAttackStateUpdate (CalcDamageInfo *damageInfo)
void SendAttackStateUpdate (uint32 HitInfo, Unit *target, uint8 SwingType, SpellSchoolMask damageSchoolMask, uint32 Damage, uint32 AbsorbDamage, uint32 Resist, VictimState TargetState, uint32 BlockedAmount)
void SendSpellNonMeleeDamageLog (SpellNonMeleeDamage *log)
void SendSpellNonMeleeDamageLog (Unit *target, uint32 SpellID, uint32 Damage, SpellSchoolMask damageSchoolMask, uint32 AbsorbedDamage, uint32 Resist, bool PhysicalDamage, uint32 Blocked, bool CriticalHit=false)
void SendSpellMiss (Unit *target, uint32 spellID, SpellMissInfo missInfo)
void SendSpellDamageImmune (Unit *target, uint32 spellId)
virtual bool SetPosition (float x, float y, float z, float orientation, bool teleport=false)
bool SetPosition (const Position &pos, bool teleport=false)
void NearTeleportTo (float x, float y, float z, float orientation, bool casting=false)
void SendTeleportPacket (Position &pos)
void SendMovementFlagUpdate (bool self=false)
void BuildHeartBeatMsg (WorldPacket *data) const
void BuildMovementPacket (ByteBuffer *data) const
bool isMoving () const
bool IsAlive () const
bool isDying () const
bool isDead () const
DeathState getDeathState () const
uint64 GetOwnerGUID () const
uint64 GetCreatorGUID () const
void SetCreatorGUID (uint64 creator)
uint64 GetMinionGUID () const
void SetMinionGUID (uint64 guid)
uint64 GetCharmerGUID () const
void SetCharmerGUID (uint64 owner)
uint64 GetCharmGUID () const
void SetPetGUID (uint64 guid)
uint64 GetPetGUID () const
bool IsControlledByPlayer () const
uint64 GetCharmerOrOwnerGUID () const
uint64 GetCharmerOrOwnerOrOwnGUID () const
bool IsCharmedOwnedByPlayerOrPlayer () const
PlayerGetAffectingPlayer () const
PlayerGetSpellModOwner () const
UnitGetOwner () const
GuardianGetGuardianPet () const
MinionGetFirstMinion () const
UnitGetCharmer () const
UnitGetCharm () const
UnitGetCharmerOrOwner () const
UnitGetCharmerOrOwnerOrSelf () const
PlayerGetCharmerOrOwnerPlayerOrPlayerItself () const
void SetMinion (Minion *minion, bool apply)
void RemoveAllMinionsByEntry (uint32 entry)
void SetCharm (Unit *target, bool apply)
void SetCharmedBy (Unit *charmer, CharmType type)
void RemoveCharmedBy (Unit *charmer)
void RestoreFaction ()
UnitGetFirstControlled () const
void RemoveAllControlled ()
bool isCharmed () const
bool isPossessed () const
bool isPossessedByPlayer () const
bool isPossessing () const
bool isPossessing (Unit *u) const
CharmInfoGetCharmInfo ()
CharmInfoInitCharmInfo ()
void DeleteCharmInfo ()
void UpdateCharmAI ()
SharedVisionList const & GetSharedVisionList ()
void AddPlayerToVision (Player *plr)
void RemovePlayerFromVision (Player *plr)
bool HasSharedVision () const
void RemoveBindSightAuras ()
void RemoveCharmAuras ()
PetCreateTamedPetFrom (Creature *creatureTarget, uint32 spell_id=0)
bool AddAura (Aura *aur)
void RemoveAura (AuraMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
void RemoveAura (uint32 spellId, uint32 effindex, Aura *except=NULL)
void RemoveSingleAuraFromStackByDispel (uint32 spellId)
void RemoveSingleAuraFromStack (uint32 spellId, uint32 effindex)
void RemoveAurasDueToSpell (uint32 spellId, Aura *except=NULL)
void RemoveAurasDueToItemSpell (Item *castItem, uint32 spellId)
void RemoveAurasByCasterSpell (uint32 spellId, uint64 casterGUID)
void SetAurasDurationByCasterSpell (uint32 spellId, uint64 casterGUID, int32 duration)
AuraGetAuraByCasterSpell (uint32 spellId, uint64 casterGUID)
void RemoveAurasDueToSpellByDispel (uint32 spellId, uint64 casterGUID, Unit *dispeler)
void RemoveAurasDueToSpellBySteal (uint32 spellId, uint64 casterGUID, Unit *stealer)
void RemoveAurasByType (AuraType auraType, uint64 casterGUID=0, Aura *except=NULL, bool negative=true, bool positive=true)
void RemoveAurasDueToSpellByCancel (uint32 spellId)
void RemoveAurasAtChanneledTarget (SpellEntry const *spellInfo, Unit *caster)
void RemoveNotOwnSingleTargetAuras ()
void RemoveSpellsCausingAura (AuraType auraType)
void RemoveAuraTypeByCaster (AuraType auraType, uint64 casterGUID)
void RemoveRankAurasDueToSpell (uint32 spellId)
bool RemoveNoStackAurasDueToAura (Aura *Aur)
void RemoveAurasWithInterruptFlags (uint32 flags, uint32 except=0)
void RemoveAurasWithAttribute (uint32 flags)
void RemoveAurasWithDispelType (DispelType type)
void RemoveMovementImpairingAuras ()
void RemoveAllAuras ()
void RemoveArenaAuras ()
void RemoveAllAurasOnDeath ()
void DelayAura (uint32 spellId, uint32 effindex, int32 delaytime)
float GetResistanceBuffMods (SpellSchools school, bool positive) const
void SetResistanceBuffMods (SpellSchools school, bool positive, float val)
void ApplyResistanceBuffModsMod (SpellSchools school, bool positive, float val, bool apply)
void ApplyResistanceBuffModsPercentMod (SpellSchools school, bool positive, float val, bool apply)
void InitStatBuffMods ()
void ApplyStatBuffMod (Stats stat, float val, bool apply)
void ApplyStatPercentBuffMod (Stats stat, float val, bool apply)
void SetCreateStat (Stats stat, float val)
void SetCreateHealth (uint32 val)
uint32 GetCreateHealth () const
void SetCreateMana (uint32 val)
uint32 GetCreateMana () const
uint32 GetCreatePowers (Powers power) const
float GetPosStat (Stats stat) const
float GetNegStat (Stats stat) const
float GetCreateStat (Stats stat) const
void SetCurrentCastedSpell (Spell *pSpell)
virtual void ProhibitSpellSchool (SpellSchoolMask, uint32)
void InterruptSpell (CurrentSpellTypes spellType, bool withDelayed=true, bool withInstant=true)
void FinishSpell (CurrentSpellTypes spellType, bool ok=true)
bool IsNonMeleeSpellCast (bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false) const
void InterruptNonMeleeSpells (bool withDelayed, uint32 spellid=0, bool withInstant=true)
uint64 GetTarget () const
void SetTarget (uint64 guid=0)
SpellGetCurrentSpell (CurrentSpellTypes spellType) const
SpellGetCurrentSpell (uint32 spellType) const
SpellFindCurrentSpellBySpellId (uint32 spell_id) const
int32 GetCurrentSpellCastTime (uint32 spell_id) const
bool CanMoveDuringChannel () const
bool IsInFeralForm () const
bool IsInTravelForm () const
bool IsInFlightForm () const
bool HandleStatModifier (UnitMods unitMod, UnitModifierType modifierType, float amount, bool apply)
void SetModifierValue (UnitMods unitMod, UnitModifierType modifierType, float value)
float GetModifierValue (UnitMods unitMod, UnitModifierType modifierType) const
float GetTotalStatValue (Stats stat) const
float GetTotalAuraModValue (UnitMods unitMod) const
SpellSchools GetSpellSchoolByAuraGroup (UnitMods unitMod) const
Stats GetStatByAuraGroup (UnitMods unitMod) const
Powers GetPowerTypeByAuraGroup (UnitMods unitMod) const
bool CanModifyStats () const
void SetCanModifyStats (bool modifyStats)
virtual void UpdateAllResistances ()
float GetTotalAttackPowerValue (WeaponAttackType attType) const
float GetWeaponDamageRange (WeaponAttackType attType, WeaponDamageRange type) const
void SetBaseWeaponDamage (WeaponAttackType attType, WeaponDamageRange damageRange, float value)
uint32 CalculateDamage (WeaponAttackType attType, bool normalized, bool addTotalPct)
float GetAPMultiplier (WeaponAttackType attType, bool normalized)
bool isInFrontInMap (Unit const *target, float distance, float arc=M_PI) const
void SetInFront (Unit const *target)
void SetInFront (float x, float y)
bool isInBackInMap (Unit const *target, float distance, float arc=M_PI) const
void SetFacingTo (float ori)
void SetFacingToObject (WorldObject *pObject)
bool IsVisible () const
void SetVisible (bool x)
bool isValid () const override
void SetPhaseMask (uint32 newPhaseMask, bool update) override
void UpdateObjectVisibility (bool forced=true) override
bool isInvisibleForAlive () const
 returns true if creature can't be seen by alive units More...
AuraListGetSingleCastAuras ()
AuraList const & GetSingleCastAuras () const
bool CanHaveThreatList () const
void AddThreat (Unit *victim, float threat, SpellSchoolMask schoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellEntry const *threatSpell=NULL)
void AddAssistThreat (Unit *victim, float threatToAdd, SpellEntry const *threatSpell)
float ApplyTotalThreatModifier (float threat, SpellSchoolMask schoolMask=SPELL_SCHOOL_MASK_NORMAL)
void DeleteThreatList ()
void TauntApply (Unit *victim)
void TauntFadeOut (Unit *taunter)
ThreatManagergetThreatManager ()
void addHatedBy (HostileReference *pHostileReference)
void removeHatedBy (HostileReference *)
HostileRefManagergetHostileRefManager ()
AuraGetAura (uint32 spellId, uint32 effindex)
AuraMapGetAuras ()
AuraMap const & GetAuras () const
AuraList const & GetAurasByType (AuraType type) const
void ApplyAuraProcTriggerDamage (Aura *aura, bool apply)
int32 GetTotalAuraModifier (AuraType auratype) const
float GetTotalAuraMultiplier (AuraType auratype) const
int32 GetMaxPositiveAuraModifier (AuraType auratype) const
int32 GetMaxNegativeAuraModifier (AuraType auratype) const
int32 GetTotalAuraModifierByMiscMask (AuraType auratype, uint32 misc_mask) const
float GetTotalAuraMultiplierByMiscMask (AuraType auratype, uint32 misc_mask) const
int32 GetMaxPositiveAuraModifierByMiscMask (AuraType auratype, uint32 misc_mask) const
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
AuraGetDummyAura (uint32 spell_id) const
uint32 GetInterruptMask () const
void AddInterruptMask (uint32 mask)
void UpdateInterruptMask ()
uint32 GetDisplayId ()
void SetDisplayId (uint32 modelId)
uint32 GetNativeDisplayId ()
void SetNativeDisplayId (uint32 modelId)
void setTransForm (uint32 spellid)
uint32 getTransForm () const
void AddDynObject (DynamicObject *dynObj)
void RemoveDynObject (uint32 spellid)
void RemoveDynObjectWithGUID (uint64 guid)
void RemoveAllDynObjects ()
void AddGameObject (GameObject *gameObj)
void RemoveGameObject (GameObject *gameObj, bool del)
void RemoveGameObject (uint32 spellid, bool del)
void RemoveAllGameObjects ()
DynamicObjectGetDynObject (uint32 spellId, uint32 effIndex)
DynamicObjectGetDynObject (uint32 spellId)
void ModifyAuraState (AuraState flag, bool apply)
bool HasAuraState (AuraState flag) const
void UnsummonAllTotems ()
int32 SpellBaseDamageBonus (SpellSchoolMask schoolMask)
int32 SpellBaseHealingBonus (SpellSchoolMask schoolMask)
int32 SpellBaseDamageBonusForVictim (SpellSchoolMask schoolMask, Unit *victim)
int32 SpellBaseHealingBonusForVictim (SpellSchoolMask schoolMask, Unit *victim)
uint32 SpellDamageBonus (Unit *victim, SpellEntry const *spellProto, uint32 damage, DamageEffectType damagetype)
uint32 SpellHealingBonus (SpellEntry const *spellProto, uint32 healamount, DamageEffectType damagetype, Unit *victim)
bool isSpellBlocked (Unit *victim, SpellEntry const *spellProto, WeaponAttackType attackType=BASE_ATTACK)
bool isSpellCrit (Unit *victim, SpellEntry const *spellProto, SpellSchoolMask schoolMask, WeaponAttackType attackType=BASE_ATTACK)
uint32 SpellCriticalBonus (SpellEntry const *spellProto, uint32 damage, Unit *victim)
void SetLastManaUse (uint32 spellCastTime)
bool IsUnderLastManaUseEffect () const
void SetContestedPvP (Player *attackedPlayer=NULL)
void MeleeDamageBonus (Unit *victim, uint32 *damage, WeaponAttackType attType, SpellEntry const *spellProto=NULL)
uint32 GetCastingTimeForBonus (SpellEntry const *spellProto, DamageEffectType damagetype, uint32 CastingTime)
void ApplySpellImmune (uint32 spellId, uint32 op, uint32 type, bool apply)
void ApplySpellDispelImmunity (const SpellEntry *spellProto, DispelType type, bool apply)
bool IsImmunedToDamage (SpellSchoolMask meleeSchoolMask, bool useCharges=false)
bool IsImmunedToDamage (SpellEntry const *spellInfo) const
uint32 CalculateEffectiveMagicResistance (Unit *attacker, SpellSchoolMask schoolMask) const
float CalculateMagicResistanceMitigation (Unit *attacker, uint32 resistance, bool binary) const
uint32 CalcArmorReducedDamage (Unit *victim, const uint32 damage)
void CalcAbsorbResist (Unit *victim, SpellSchoolMask schoolMask, DamageEffectType damagetype, const uint32 damage, uint32 *absorb, uint32 *resist, SpellEntry const *spellInfo=NULL, bool binary=false)
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)
bool isHover () const
void _RemoveAllAuraMods ()
void _ApplyAllAuraMods ()
int32 CalculateSpellDamage (SpellEntry const *spellProto, uint8 effect_index, int32 basePoints, Unit const *target)
int32 CalculateSpellDuration (SpellEntry const *spellProto, uint8 effect_index, Unit const *target)
float CalculateLevelPenalty (SpellEntry const *spellProto) const
void ModSpellCastTime (SpellEntry const *spellProto, int32 &castTime, Spell *spell)
void ModSpellDurationTime (SpellEntry const *spellProto, int32 &duration, Spell *spell)
void addFollower (FollowerReference *pRef)
void removeFollower (FollowerReference *)
MotionMasterGetMotionMaster ()
bool IsStopped () const
void StopMoving ()
void AddUnitMovementFlag (uint32 f)
void RemoveUnitMovementFlag (uint32 f)
bool HasUnitMovementFlag (uint32 f) const
uint32 GetUnitMovementFlags () const
void SetUnitMovementFlags (uint32 f)
void SetControlled (bool apply, UnitState state)
void SetFeared (bool apply)
void SetConfused (bool apply)
void SetStunned (bool apply)
void MonsterMoveWithSpeed (float x, float y, float z, float speed, bool generatePath=false, bool forceDestination=false)
void SendMonsterMoveWithSpeedToCurrentDestination (float speed)
void AddComboPointHolder (uint32 lowguid)
void RemoveComboPointHolder (uint32 lowguid)
void ClearComboPointHolders ()
void SendPetCastFail (uint32 spellid, SpellCastResult msg)
void SendPetActionFeedback (uint8 msg)
void SendPetTalk (uint32 pettalk)
void SendPetSpellCooldown (uint32 spellid, time_t cooltime)
void SendPetClearCooldown (uint32 spellid)
void SendPetAIReaction (uint64 guid)
void propagateSpeedChange ()
void ClearAllReactives ()
void StartReactiveTimer (ReactiveType reactive)
void UpdateReactives (uint32 p_time)
void UpdateAuraForGroup (uint8 slot)
void AddPetAura (PetAura const *petSpell)
void RemovePetAura (PetAura const *petSpell)
void SetReducedThreatPercent (uint32 pct, uint64 guid)
uint32 GetReducedThreatPercent ()
UnitGetMisdirectionTarget ()
bool IsFlying () const
bool IsFalling () const
bool IsWalking () const
bool IsRooted () const
void SetRooted (bool apply)
bool IsLevitating () const
time_t GetLastDamagedTime () const
void SetLastDamagedTime (time_t val)
TempSummonToTempSummon ()
TempSummon const * ToTempSummon () const
- Public Member Functions inherited from WorldObject
 ~WorldObject () override
void _Create (uint32 guidlow, HighGuid guidhigh, uint32 phaseMask)
void GetNearPoint2D (float &x, float &y, float distance, float absAngle) const
void GetNearPoint (WorldObject const *searcher, float &x, float &y, float &z, float searcher_size, float distance2d, float absAngle) const
void GetClosePoint (float &x, float &y, float &z, float size, float distance2d=0, float angle=0) 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 dist, float angle)
float GetPositionZTarget (Position &pos, float destx, float desty)
Position GetRandomNearPosition (float radius)
void GetContactPoint (const WorldObject *obj, float &x, float &y, float &z, float distance2d=CONTACT_DISTANCE) const
virtual float GetObjectBoundingRadius () const
float GetObjectSize () const
void UpdateGroundPositionZ (float x, float y, float &z) const
void UpdateAllowedPositionZ (float x, float y, float &z) const
void GetRandomPoint (const Position &srcPos, float distance, float &rand_x, float &rand_y, float &rand_z) const
void GetRandomPoint (const Position &srcPos, float distance, Position &pos) const
float GetDistanceSqr (float x, float y, float z) const
bool HasInArc (float arcangle, const Position *pos) const
bool HasInArc (const float arcangle, const float x, const float y) const
uint32 GetInstanceId () const
uint32 GetPhaseMask () const
bool InSamePhase (uint32 phasemask) const
bool InSamePhase (WorldObject const *obj) const
uint32 GetZoneId () const
uint32 GetAreaId () const
InstanceDataGetInstanceData ()
const char * GetName () const
void SetName (const std::string &newname)
float GetDistance (const WorldObject *obj) const
float GetDistance (const Position &pos) const
float GetDistance (float x, float y, float z) const
float GetDistance2d (const WorldObject *obj) const
float GetDistance2d (float x, float y) const
float GetDistanceZ (const WorldObject *obj) const
bool IsInMap (const WorldObject *obj) const
bool IsWithinDist3d (float x, float y, float z, float dist) const
bool IsWithinDist3d (const Position *pos, float dist) const
bool IsWithinDist2d (float x, float y, float dist) const
bool IsWithinDist2d (const Position *pos, float dist) const
bool _IsWithinDist (WorldObject const *obj, float dist2compare, bool is3D) const
bool IsWithinDist (WorldObject const *obj, float dist2compare, bool is3D=true) const
bool IsWithinDistInMap (WorldObject const *obj, float dist2compare, bool is3D=true) const
bool IsWithinLOS (float x, float y, float z) const
bool IsWithinLOSInMap (const WorldObject *obj) const
Position GetHitSpherePointFor (Position const &dest) const
void GetHitSpherePointFor (Position const &dest, float &x, float &y, float &z) 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
virtual void SendMessageToSet (WorldPacket *data, bool self)
virtual void SendMessageToSetInRange (WorldPacket *data, float dist, bool self)
void MonsterSay (const char *text, uint32 language, uint64 TargetGuid)
void MonsterYell (const char *text, uint32 language, uint64 TargetGuid)
void MonsterTextEmote (const char *text, uint64 TargetGuid, bool IsBossEmote=false)
void MonsterWhisper (const char *text, uint64 receiver, bool IsBossWhisper=false)
void MonsterSay (int32 textId, uint32 language, uint64 TargetGuid)
void MonsterYell (int32 textId, uint32 language, uint64 TargetGuid)
void MonsterTextEmote (int32 textId, uint64 TargetGuid, bool IsBossEmote=false)
void MonsterWhisper (int32 textId, uint64 receiver, bool IsBossWhisper=false)
void MonsterYellToZone (int32 textId, uint32 language, uint64 TargetGuid)
void BuildMonsterChat (WorldPacket *data, uint8 msgtype, char const *text, uint32 language, char const *name, uint64 TargetGuid) const
void PlayDistanceSound (uint32 sound_id, Player *target=NULL)
void PlayDirectSound (uint32 sound_id, Player *target=NULL)
void SendObjectDeSpawnAnim (uint64 guid)
void SendObjectCustomAnim (uint64 guid, uint32 anim=0)
void AddObjectToRemoveList ()
virtual bool IsNeverVisible () const
float GetGridActivationRange () const
float GetVisibilityRange () const
float GetSightRange (const WorldObject *target=NULL) const
bool CanSeeOrDetect (WorldObject const *obj, bool ignoreStealth=false, bool distanceCheck=false, bool checkAlert=false) const
void SendPlaySound (uint32 Sound, bool OnlySelf)
virtual void SetMap (Map *map)
virtual void ResetMap ()
MapGetMap () const
MapFindMap () const
Map const * GetBaseMap () const
void SetZoneScript ()
TempSummonSummonCreature (uint32 id, const Position &pos, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0)
TempSummonSummonCreature (uint32 id, float x, float y, float z, float ang, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0)
GameObjectSummonGameObject (uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime)
CreatureSummonTrigger (float x, float y, float z, float ang, uint32 dur, CreatureAI *(*GetAI)(Creature *)=NULL)
void SummonCreatureGroup (uint8 group, std::list< TempSummon * > *list=NULL)
CreatureFindNearestCreature (uint32 entry, float range, bool alive=true)
GameObjectFindNearestGameObject (uint32 entry, float range)
GameObjectFindNearestGameObjectOfType (GameobjectTypes type, float range) const
void GetGameObjectListWithEntryInGrid (std::list< GameObject * > &gameobjectList, uint32 entry=GRID_SEARCH_ALL_ENTRIES, float maxSearchRange=250.0f) const
void GetCreatureListWithEntryInGrid (std::list< Creature * > &creatureList, uint32 entry=GRID_SEARCH_ALL_ENTRIES, float maxSearchRange=250.0f) const
void DestroyForNearbyPlayers ()
virtual void UpdateObjectVisibilityOnCreate ()
void BuildUpdate (UpdateDataMapType &) override
void AddToNotify (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)
void SetWorldObject (bool apply)
bool IsPermanentWorldObject () const
bool IsWorldObject () const
template<class NOTIFIER >
void VisitNearbyWorldObject (const float &radius, NOTIFIER &notifier) const
template<class NOTIFIER >
void VisitNearbyObject (float const &radius, NOTIFIER &notifier) const
template<class NOTIFIER >
void VisitNearbyGridObject (float const &radius, NOTIFIER &notifier) const
- Public Member Functions inherited from Object
virtual ~Object ()
const bool & IsInWorld () const
const uint64GetGUID () const
uint32 GetGUIDLow () const
uint32 GetGUIDMid () const
uint32 GetGUIDHigh () const
PackedGuid const & GetPackGUID () const
ObjectGuid const & GetObjectGUID () const
std::string GetGuidStr () const
uint32 GetEntry () const
void SetEntry (uint32 entry)
float GetObjectScale () const
void SetObjectScale (float scale)
uint8 GetTypeId () const
bool isType (uint16 mask) const
virtual void BuildCreateUpdateBlockForPlayer (UpdateData *data, Player *target) const
void SendUpdateToPlayer (Player *player)
void BuildValuesUpdateBlockForPlayer (UpdateData *data, Player *target) const
void BuildOutOfRangeUpdateBlock (UpdateData *data) const
void BuildMovementUpdateBlock (UpdateData *data, uint32 flags=0) const
virtual void DestroyForPlayer (Player *target, bool onDeath=false) const
const int32GetInt32Value (uint16 index) const
const uint32GetUInt32Value (uint16 index) const
const uint64GetUInt64Value (uint16 index) const
const float & GetFloatValue (uint16 index) const
uint8 GetByteValue (uint16 index, uint8 offset) const
ObjectGuid const & GetGuidValue (uint16 index) const
uint16 GetUInt16Value (uint16 index, uint8 offset) const
void SetInt32Value (uint16 index, int32 value)
void SetUInt32Value (uint16 index, uint32 value)
void SetUInt64Value (uint16 index, const 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 SetStatFloatValue (uint16 index, float value)
void SetStatInt32Value (uint16 index, int32 value)
bool AddUInt64Value (uint16 index, const uint64 &value)
bool RemoveUInt64Value (uint16 index, const uint64 &value)
void ApplyModUInt32Value (uint16 index, int32 val, bool apply)
void ApplyModInt32Value (uint16 index, int32 val, bool apply)
void ApplyModUInt64Value (uint16 index, int32 val, bool apply)
void ApplyModPositiveFloatValue (uint16 index, float val, bool apply)
void ApplyModSignedFloatValue (uint16 index, float val, bool apply)
void ApplyPercentModFloatValue (uint16 index, float val, bool apply)
void SetFlag (uint16 index, uint32 newFlag)
void RemoveFlag (uint16 index, uint32 oldFlag)
void ToggleFlag (uint16 index, uint32 flag)
bool HasFlag (uint16 index, uint32 flag) const
void SetByteFlag (uint16 index, uint8 offset, uint8 newFlag)
void RemoveByteFlag (uint16 index, uint8 offset, uint8 newFlag)
void ToggleFlag (uint16 index, uint8 offset, uint8 flag)
bool HasByteFlag (uint16 index, uint8 offset, uint8 flag) const
void ApplyModFlag (uint16 index, uint32 flag, bool apply)
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)
bool LoadValues (const char *data)
uint16 GetValuesCount () const
void BuildFieldsUpdate (Player *, UpdateDataMapType &) const
void ForceValuesUpdateAtIndex (uint32)
PlayerToPlayer ()
Player const * ToPlayer () const
CreatureToCreature ()
Creature const * ToCreature () const
UnitToUnit ()
Unit const * ToUnit () const
GameObjectToGameObject ()
GameObject const * ToGameObject () const
CorpseToCorpse ()
Corpse const * ToCorpse () const
DynamicObjectToDynObject ()
DynamicObject const * ToDynObject () const
- Public Member Functions inherited from WorldLocation
 WorldLocation (uint32 _mapid=MAPID_INVALID, float _x=0, float _y=0, float _z=0, float _o=0)
 WorldLocation (const WorldLocation &loc)
void WorldRelocate (const WorldLocation &loc)
uint32 GetMapId () const
- Public Member Functions inherited from Position
 Position (float x=0, float y=0, float z=0, float o=0)
 Position (Position const &loc)
bool operator== (Position const &a)
bool operator!= (Position const &a)
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 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::PositionXYStreamer PositionXYStream ()
Position::PositionXYZStreamer PositionXYZStream ()
Position::PositionXYZOStreamer PositionXYZOStream ()
bool IsPositionValid () const
float GetExactDist2dSq (float x, float y) const
float GetExactDist2d (const float x, const float y) const
float GetExactDist2dSq (Position const *pos) const
float GetExactDist2d (Position const *pos) const
float GetExactDistSq (float x, float y, float z) const
float GetExactDist (float x, float y, float z) const
float GetExactDistSq (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 GetRelativeAngle (Position const *pos) const
float GetRelativeAngle (float x, float y) 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 (const Position &center, float xradius, float yradius, float zradius) const
bool HasInArc (float arcangle, Position const *pos, float border=2.0f) const
bool HasInLine (Position const *pos, float width) const
std::string ToString () const
- Public Member Functions inherited from GridObject< Creature >
bool IsInGrid () const
void AddToGrid (GridRefManager< Creature > &m)
void RemoveFromGrid ()

Static Public Member Functions

static void DeleteFromDB (uint32 guidlow)
- Static Public Member Functions inherited from Unit
static ReputationRank GetFactionReactionTo (FactionTemplateEntry const *factionTemplateEntry, Unit const *target)
static bool IsDamageReducedByArmor (SpellSchoolMask damageSchoolMask, SpellEntry const *spellInfo=NULL, uint8 effIndex=MAX_SPELL_EFFECTS)
static UnitGetUnit (WorldObject &object, uint64 guid)
static PlayerGetPlayer (WorldObject &object, uint64 guid)
static CreatureGetCreature (WorldObject &object, uint64 guid)
- Static Public Member Functions inherited from WorldObject
static bool InSamePhase (WorldObject const *a, WorldObject const *b)
- Static Public Member Functions inherited from Position
static float NormalizeOrientation (float o)

Public Attributes

PetSpellMap m_spells
TeachSpellMap m_teachspells
AutoSpellList m_autospells
int32 m_TrainingPoints
uint32 m_resetTalentsCost
time_t m_resetTalentsTime
bool m_removed
- Public Attributes inherited from TempSummon
SummonPropertiesEntry const * m_Properties
- Public Attributes inherited from Creature
Loot loot
uint32 m_spells [CREATURE_MAX_SPELLS]
CreatureSpellCooldowns m_CreatureSpellCooldowns
CreatureSpellCooldowns m_CreatureCategoryCooldowns
uint32 m_GlobalCooldown
bool hasPlayerDamaged
float m_SightDistance
float m_CombatDistance
bool m_isTempWorldObject
- Public Attributes inherited from Unit
uint32 m_extraAttacks
bool m_canDualWield
IntervalTimer m_CombatTimer
ControlList m_Controlled
uint64 m_SummonSlot [MAX_SUMMON_SLOT]
uint64 m_ObjectSlot [4]
uint32 m_ShapeShiftFormSpellId
uint32 m_ShapeShiftModelId
ShapeshiftForm m_form
float m_modMeleeHitChance
float m_modRangedHitChance
float m_modSpellHitChance
int32 m_baseSpellCritChance
float m_threatModifier [MAX_SPELL_SCHOOL]
float m_modAttackSpeedPct [3]
uint32 _oldFactionId
EventProcessor m_Events
SpellImmuneList m_spellImmune [MAX_SPELL_IMMUNITY]
uint32 m_lastSanctuaryTime
uint32 m_AuraFlags
PetAuraSet m_petAuras
bool IsAIEnabled
bool NeedChangeAI
uint64 LastCharmerGUID
bool m_ControlledByPlayer
- Public Attributes inherited from WorldObject
FlaggedValuesArray32< int32, uint32, StealthType, TOTAL_STEALTH_TYPESm_stealth
FlaggedValuesArray32< int32, uint32, StealthType, TOTAL_STEALTH_TYPESm_stealthDetect
FlaggedValuesArray32< int32, uint32, InvisibilityType, TOTAL_INVISIBILITY_TYPESm_invisibility
FlaggedValuesArray32< int32, uint32, InvisibilityType, TOTAL_INVISIBILITY_TYPESm_invisibilityDetect
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPESm_serverSideVisibility
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPESm_serverSideVisibilityDetect
uint32 m_groupLootTimer
uint64 lootingGroupLeaderGUID
MovementInfo m_movementInfo
- Public Attributes inherited from WorldLocation
uint32 m_mapId
- Public Attributes inherited from Position
float m_positionX
float m_positionY
float m_positionZ

Protected Attributes

uint32 m_regenTimer
uint32 m_happinessTimer
uint32 m_loyaltyTimer
PetType m_petType
int32 m_duration
int32 m_loyaltyPoints
uint64 m_auraUpdateMask
bool m_wasOutdoors
uint32 m_outdoorBonusCheckTimer
PetModeFlags m_petModeFlags
- Protected Attributes inherited from Guardian
int32 m_bonusdamage
- Protected Attributes inherited from Minion
Unit *const m_owner
float m_followAngle
- Protected Attributes inherited from Creature
VendorItemCounts m_vendorItemCounts
uint32 m_lootMoney
uint64 m_lootRecipient
uint32 m_lootRecipientGroup
uint64 _skinner
time_t _pickpocketLootRestore
 Timers. More...
uint32 m_corpseRemoveTime
time_t m_respawnTime
uint32 m_respawnDelay
uint32 m_corpseDelay
float m_respawnradius
uint32 m_combatPulseTime
uint32 m_combatPulseDelay
uint8 m_emoteState
ReactStates m_reactState
uint32 m_regenTimer
MovementGeneratorType m_defaultMovementType
Cell m_currentCell
uint32 m_DBTableGuid
uint32 m_equipmentId
bool m_AlreadyCallAssistance
bool m_AlreadySearchedAssistance
bool m_regenHealth
bool m_AI_locked
SpellSchoolMask m_meleeDamageSchoolMask
uint32 m_originalEntry
Position m_homePosition
bool DisableReputationGain
CreatureData const * m_creatureData
- Protected Attributes inherited from Unit
bool m_AutoRepeatFirstCast
bool m_initiatingCombat
uint32 m_attackTimer [MAX_ATTACK]
float m_createStats [MAX_STATS]
AttackerSet m_attackers
DeathState m_deathState
AuraMap m_Auras
AuraMap::iterator m_AurasUpdateIterator
uint32 m_removedAurasCount
DynObjectGUIDs m_dynObjGUIDs
std::list< GameObject * > m_gameObj
bool m_isSorted
uint32 m_transform
AuraList m_removedAuras
AuraList m_modAuras [TOTAL_AURAS]
AuraList m_scAuras
AuraList m_interruptableAuras
AuraList m_ccAuras
uint32 m_interruptMask
float m_auraModifiersGroup [UNIT_MOD_END][MODIFIER_TYPE_END]
float m_weaponDamage [MAX_ATTACK][2]
bool m_canModifyStats
float m_speed_rate [MAX_MOVE_TYPE]
uint32 m_unitTypeMask
SharedVisionList m_sharedVision
MotionMaster i_motionMaster
uint64 miniPetGuid
uint32 m_reactiveTimer [MAX_REACTIVE]
ThreatManager m_ThreatManager
- Protected Attributes inherited from WorldObject
std::string m_name
bool m_isActive
const bool m_isWorldObject
- Protected Attributes inherited from Object
uint16 m_objectType
uint8 m_objectTypeId
uint8 m_updateFlag
union {
   int32 *   m_int32Values
   uint32 *   m_uint32Values
   float *   m_floatValues
uint16 m_valuesCount
bool m_objectUpdated

Private Member Functions

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

Additional Inherited Members

- Public Types inherited from Unit
typedef std::set< Unit * > AttackerSet
typedef std::set< Unit * > ControlList
typedef std::pair< uint32, uint8spellEffectPair
typedef std::multimap< spellEffectPair, Aura * > AuraMap
typedef std::list< Aura * > AuraList
typedef std::list< DiminishingReturnDiminishing
typedef std::set< AuraTypeAuraTypeSet
typedef std::set< uint32ComboPointHolderSet
typedef std::set< PetAura const * > PetAuraSet
- Protected Types inherited from Unit
typedef std::list< uint64DynObjectGUIDs
- Protected Member Functions inherited from Creature
bool CreateFromProto (uint32 guidlow, uint32 Entry, uint32 team, const CreatureData *data=NULL)
bool InitEntry (uint32 entry, uint32 team=ALLIANCE, const CreatureData *data=NULL)
void _RealtimeSetCreatureInfo ()
void RegenerateMana ()
void RegenerateHealth ()
bool IsInvisibleDueToDespawn () const override
bool CanAlwaysSee (WorldObject const *obj) const override
- Protected Member Functions inherited from Unit
 Unit (bool isWorldObject)
void _UpdateSpells (uint32 time)
void _DeleteAuras ()
void _UpdateAutoRepeatSpell ()
void DisableSpline ()
bool IsAlwaysVisibleFor (WorldObject const *seer) const override
bool IsAlwaysDetectableFor (WorldObject const *seer) const override
- Protected Member Functions inherited from WorldObject
 WorldObject (bool isWorldObject)
void SetLocationMapId (uint32 _mapId)
void SetLocationInstanceId (uint32 _instanceId)
- Protected Member Functions inherited from Object
 Object ()
void _InitValues ()
void _Create (uint32 guidlow, uint32 entry, HighGuid guidhigh)
void _LoadIntoDataField (const char *data, uint32 startOffset, uint32 count)
virtual void _SetUpdateBits (UpdateMask *updateMask, Player *target) const
virtual void _SetCreateBits (UpdateMask *updateMask, Player *target) const
void _BuildMovementUpdate (ByteBuffer *data, uint8 updateFlags) const
void _BuildValuesUpdate (uint8 updatetype, ByteBuffer *data, UpdateMask *updateMask, Player *target) const
- Static Protected Member Functions inherited from Creature
static float _GetHealthMod (int32 Rank)
static float _GetDamageMod (int32 Rank)

Detailed Description

Definition at line 146 of file Pet.h.

Constructor & Destructor Documentation

Pet::Pet ( Player owner,
PetType  type = MAX_PET_TYPE 

Definition at line 54 of file Pet.cpp.

References CLASS_PET, HUNTER_PET, Unit::InitCharmInfo(), Unit::m_Auras, m_auraUpdateMask, m_autospells, Creature::m_CreatureCategoryCooldowns, Creature::m_CreatureSpellCooldowns, m_loyaltyPoints, m_loyaltyTimer, WorldObject::m_name, m_outdoorBonusCheckTimer, m_regenTimer, m_spells, m_TrainingPoints, Unit::m_unitTypeMask, m_wasOutdoors, REACT_AGGRESSIVE, Creature::SetReactState(), UNIT_MASK_CONTROLABLE_GUARDIAN, UNIT_MASK_HUNTER_PET, and UNIT_MASK_PET.

54  : Guardian(NULL, owner, true),
56  m_removed(false), m_owner(owner), m_happinessTimer(7500),
57  m_petType(type), m_duration(0), m_declinedname(NULL),
59 {
61  if (type == HUNTER_PET)
65  {
67  InitCharmInfo();
68  }
70  if (type == CLASS_PET)
73  m_name = "Pet";
75  m_regenTimer = 4000;
76  m_loyaltyTimer = 12000;
78  m_loyaltyPoints = 0;
79  m_TrainingPoints = 0;
81  m_auraUpdateMask = 0;
83  m_spells.clear();
84  m_Auras.clear();
87  m_autospells.clear();
89  m_wasOutdoors = false;
91 }
Guardian(SummonPropertiesEntry const *properties, Unit *owner, bool isWorldObject)
time_t m_resetTalentsTime
Definition: Pet.h:260
Player * m_owner
Definition: Pet.h:291
std::string m_name
Definition: Object.h:931
AutoSpellList m_autospells
Definition: Pet.h:249
uint32 m_regenTimer
Definition: Pet.h:292
uint32 m_happinessTimer
Definition: Pet.h:293
int32 m_duration
Definition: Pet.h:296
Definition: Pet.h:28
PetModeFlags m_petModeFlags
Definition: Pet.h:305
bool m_wasOutdoors
Definition: Pet.h:302
int32 m_TrainingPoints
Definition: Pet.h:258
CreatureSpellCooldowns m_CreatureSpellCooldowns
Definition: Creature.h:605
uint32 m_outdoorBonusCheckTimer
Definition: Pet.h:303
PetSpellMap m_spells
Definition: Pet.h:247
uint32 m_loyaltyTimer
Definition: Pet.h:294
bool m_removed
Definition: Pet.h:284
uint64 m_auraUpdateMask
Definition: Pet.h:298
PetType m_petType
Definition: Pet.h:295
uint32 m_unitTypeMask
Definition: Unit.h:2049
CharmInfo * InitCharmInfo()
Definition: Unit.cpp:11221
CreatureSpellCooldowns m_CreatureCategoryCooldowns
Definition: Creature.h:606
Definition: Pet.h:29
uint32 m_resetTalentsCost
Definition: Pet.h:259
void SetReactState(ReactStates st)
Definition: Creature.h:495
AuraMap m_Auras
Definition: Unit.h:2024
DeclinedName * m_declinedname
Definition: Pet.h:300
int32 m_loyaltyPoints
Definition: Pet.h:297
Pet::~Pet ( )

Definition at line 93 of file Pet.cpp.

References m_declinedname.

94 {
95  delete m_declinedname;
96 }
DeclinedName * m_declinedname
Definition: Pet.h:300

Member Function Documentation

void Pet::_LoadAuras ( uint32  timediff)

Definition at line 1355 of file Pet.cpp.

References Unit::AddAura(), CharacterDatabase, CreateAura(), Object::GetGUID(), Aura::GetModifier(), CharmInfo::GetPetNumber(), IN_MILLISECONDS, IsPositiveEffect(), IsSingleTargetSpell(), Modifier::m_amount, Unit::m_Auras, Unit::m_charmInfo, Unit::m_modAuras, Database::PQuery(), SpellEntry::procCharges, Aura::SetLoadedState(), Object::SetUInt32Value(), sLog, sSpellStore, TOTAL_AURAS, UNIT_FIELD_AURA, and UNIT_FIELD_AURASTATE.

Referenced by LoadPetFromDB().

1356 {
1357  m_Auras.clear();
1358  for (int i = 0; i < TOTAL_AURAS; i++)
1359  m_modAuras[i].clear();
1361  // all aura related fields
1362  for (int i = UNIT_FIELD_AURA; i <= UNIT_FIELD_AURASTATE; ++i)
1363  SetUInt32Value(i, 0);
1365  QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT caster_guid,item_caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges FROM pet_aura WHERE guid = '%u'", m_charmInfo->GetPetNumber());
1367  if (result)
1368  {
1369  do
1370  {
1371  Field* fields = result->Fetch();
1372  uint64 caster_guid = fields[0].GetUInt64();
1373  uint64 item_caster_guid = fields[1].GetUInt64();
1374  uint32 spellid = fields[2].GetUInt32();
1375  uint32 effindex = fields[3].GetUInt32();
1376  uint32 stackcount = fields[4].GetUInt32();
1377  int32 damage = fields[5].GetUInt32();
1378  int32 maxduration = fields[6].GetUInt32();
1379  int32 remaintime = fields[7].GetUInt32();
1380  int32 remaincharges = fields[8].GetUInt32();
1382  SpellEntry const* spellproto = sSpellStore.LookupEntry(spellid);
1383  if (!spellproto)
1384  {
1385  sLog.outError("Unknown aura (spellid %u, effindex %u), ignore.", spellid, effindex);
1386  continue;
1387  }
1389  if (effindex >= 3)
1390  {
1391  sLog.outError("Invalid effect index (spellid %u, effindex %u), ignore.", spellid, effindex);
1392  continue;
1393  }
1395  // negative effects should continue counting down after logout
1396  if (remaintime != -1 && !IsPositiveEffect(spellid, effindex))
1397  {
1398  if (remaintime / IN_MILLISECONDS <= int32(timediff))
1399  continue;
1401  remaintime -= timediff * IN_MILLISECONDS;
1402  }
1404  // prevent wrong values of remaincharges
1405  if (spellproto->procCharges)
1406  {
1407  if (remaincharges <= 0 || uint32(remaincharges) > spellproto->procCharges)
1408  remaincharges = spellproto->procCharges;
1409  }
1410  else
1411  remaincharges = -1;
1413  // do not load single target auras (unless they were cast by the player)
1414  if (caster_guid != GetGUID() && IsSingleTargetSpell(spellproto))
1415  continue;
1417  for (uint32 i = 0; i < stackcount; ++i)
1418  {
1419  Aura* aura = CreateAura(spellproto, effindex, NULL, this, NULL);
1421  if (!damage)
1422  damage = aura->GetModifier()->m_amount;
1423  aura->SetLoadedState(caster_guid, item_caster_guid, damage, maxduration, remaintime, remaincharges);
1424  AddAura(aura);
1425  }
1426  }
1427  while (result->NextRow());
1428  }
1429 }
bool IsSingleTargetSpell(SpellEntry const *spellInfo)
Definition: SpellMgr.cpp:783
QueryResult_AutoPtr PQuery(const char *format,...) ATTR_PRINTF(2
Definition: Database.cpp:400
Definition: Field.h:24
CharmInfo * m_charmInfo
Definition: Unit.h:2050
uint32 procCharges
Definition: DBCStructure.h:704
#define sLog
Log class singleton.
Definition: Log.h:187
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:779
ACE_INT32 int32
Definition: Define.h:67
void AddAura(uint32 spellId, Unit *target)
Definition: Unit.cpp:13463
Aura * CreateAura(SpellEntry const *spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster, Item *castItem)
Definition: SpellAuras.cpp:502
DBCStorage< SpellEntry > sSpellStore(SpellEntryfmt)
int32 m_amount
Definition: SpellAuras.h:35
uint32 GetPetNumber() const
Definition: Unit.h:803
bool IsPositiveEffect(uint32 spellId, uint32 effIndex)
Definition: SpellMgr.cpp:561
Modifier * GetModifier()
Definition: SpellAuras.h:221
AuraList m_modAuras[TOTAL_AURAS]
Definition: Unit.h:2036
ACE_UINT64 uint64
Definition: Define.h:70
ACE_Refcounted_Auto_Ptr< QueryResult, ACE_Null_Mutex > QueryResult_AutoPtr
Definition: QueryResult.h:113
DatabaseType CharacterDatabase
Accessor to the character database.
Definition: Main.cpp:54
ACE_UINT32 uint32
Definition: Define.h:71
void SetLoadedState(uint64 caster_guid, uint64 item_caster_guid, int32 damage, int32 maxduration, int32 duration, int32 charges)
Definition: SpellAuras.h:317
AuraMap m_Auras
Definition: Unit.h:2024
const uint64 & GetGUID() const
Definition: Object.h:162
void Pet::_LoadSpellCooldowns ( )

Definition at line 1240 of file Pet.cpp.

References Creature::_AddCreatureSpellCooldown(), CharacterDatabase, Object::GetGUID(), GetOwner(), CharmInfo::GetPetNumber(), Player::GetSession(), IN_MILLISECONDS, Unit::m_charmInfo, Creature::m_CreatureCategoryCooldowns, Creature::m_CreatureSpellCooldowns, Database::PQuery(), WorldSession::SendPacket(), sLog, SMSG_SPELL_COOLDOWN, sSpellStore, and Object::ToPlayer().

Referenced by LoadPetFromDB().

1241 {
1242  m_CreatureSpellCooldowns.clear();
1245  QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT spell,time FROM pet_spell_cooldown WHERE guid = '%u'", m_charmInfo->GetPetNumber());
1247  if (result)
1248  {
1249  time_t curTime = time(NULL);
1251  WorldPacket data(SMSG_SPELL_COOLDOWN, (8 + 1 + result->GetRowCount() * 8));
1252  data << GetGUID();
1253  data << uint8(0x0); // flags (0x1, 0x2)
1255  do
1256  {
1257  Field* fields = result->Fetch();
1259  uint32 spell_id = fields[0].GetUInt32();
1260  time_t db_time = (time_t)fields[1].GetUInt64();
1262  if (!sSpellStore.LookupEntry(spell_id))
1263  {
1264  sLog.outError("Pet %u has unknown spell %u in pet_spell_cooldown, skipping.", m_charmInfo->GetPetNumber(), spell_id);
1265  continue;
1266  }
1268  // skip outdated cooldown
1269  if (db_time <= curTime)
1270  continue;
1272  data << uint32(spell_id);
1273  data << uint32(uint32(db_time - curTime)*IN_MILLISECONDS); // in m.secs
1275  _AddCreatureSpellCooldown(spell_id, db_time);
1277  sLog.outDebug("Pet (Number: %u) spell %u cooldown loaded (%u secs).", m_charmInfo->GetPetNumber(), spell_id, uint32(db_time - curTime));
1278  }
1279  while (result->NextRow());
1281  if (!m_CreatureSpellCooldowns.empty() && GetOwner())
1282  GetOwner()->ToPlayer()->GetSession()->SendPacket(&data);
1283  }
1284 }
QueryResult_AutoPtr PQuery(const char *format,...) ATTR_PRINTF(2
Definition: Database.cpp:400
Definition: Field.h:24
CharmInfo * m_charmInfo
Definition: Unit.h:2050
#define sLog
Log class singleton.
Definition: Log.h:187
void _AddCreatureSpellCooldown(uint32 spell_id, time_t end_time)
Definition: Creature.cpp:2237
void SendPacket(WorldPacket const *packet)
DBCStorage< SpellEntry > sSpellStore(SpellEntryfmt)
Player * ToPlayer()
Definition: Object.h:392
ACE_UINT8 uint8
Definition: Define.h:73
uint32 GetPetNumber() const
Definition: Unit.h:803
Player * GetOwner()
Definition: Pet.h:286
CreatureSpellCooldowns m_CreatureSpellCooldowns
Definition: Creature.h:605
ACE_Refcounted_Auto_Ptr< QueryResult, ACE_Null_Mutex > QueryResult_AutoPtr
Definition: QueryResult.h:113
WorldSession * GetSession() const
Definition: Player.h:1944
DatabaseType CharacterDatabase
Accessor to the character database.
Definition: Main.cpp:54
CreatureSpellCooldowns m_CreatureCategoryCooldowns
Definition: Creature.h:606
ACE_UINT32 uint32
Definition: Define.h:71
const uint64 & GetGUID() const
Definition: Object.h:162
void Pet::_LoadSpells ( )

Definition at line 1308 of file Pet.cpp.

References addSpell(), CharacterDatabase, CharmInfo::GetPetNumber(), Unit::m_charmInfo, PETSPELL_UNCHANGED, and Database::PQuery().

Referenced by LoadPetFromDB().

1309 {
1310  QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT spell,active FROM pet_spell WHERE guid = '%u'", m_charmInfo->GetPetNumber());
1312  if (result)
1313  {
1314  do
1315  {
1316  Field* fields = result->Fetch();
1318  addSpell(fields[0].GetUInt32(), fields[1].GetUInt16(), PETSPELL_UNCHANGED);
1319  }
1320  while (result->NextRow());
1321  }
1322 }
QueryResult_AutoPtr PQuery(const char *format,...) ATTR_PRINTF(2
Definition: Database.cpp:400
Definition: Field.h:24
CharmInfo * m_charmInfo
Definition: Unit.h:2050
uint32 GetPetNumber() const
Definition: Unit.h:803
bool addSpell(uint16 spell_id, uint16 active=ACT_DECIDE, PetSpellState state=PETSPELL_NEW, PetSpellType type=PETSPELL_NORMAL)
Definition: Pet.cpp:1488
ACE_Refcounted_Auto_Ptr< QueryResult, ACE_Null_Mutex > QueryResult_AutoPtr
Definition: QueryResult.h:113
DatabaseType CharacterDatabase
Accessor to the character database.
Definition: Main.cpp:54
void Pet::_SaveAuras ( )

Definition at line 1431 of file Pet.cpp.

References CharacterDatabase, SpellEntry::Effect, SpellEntry::EffectApplyAuraName, Unit::GetAuras(), Object::GetGUID(), CharmInfo::GetPetNumber(), IsSingleTargetSpell(), Unit::m_charmInfo, Database::PExecute(), SPELL_AURA_MOD_CHARM, SPELL_AURA_MOD_POSSESS, SPELL_AURA_MOD_POSSESS_PET, SPELL_AURA_MOD_STEALTH, SPELL_EFFECT_APPLY_AREA_AURA_OWNER, SPELL_EFFECT_APPLY_AREA_AURA_PET, and UI64FMTD.

Referenced by SavePetToDB().

1432 {
1433  CharacterDatabase.PExecute("DELETE FROM pet_aura WHERE guid = '%u'", m_charmInfo->GetPetNumber());
1435  AuraMap const& auras = GetAuras();
1436  if (auras.empty())
1437  return;
1439  spellEffectPair lastEffectPair = auras.begin()->first;
1440  uint32 stackCounter = 1;
1442  for (AuraMap::const_iterator itr = auras.begin(); ; ++itr)
1443  {
1444  if (itr == auras.end() || lastEffectPair != itr->first)
1445  {
1446  AuraMap::const_iterator itr2 = itr;
1447  // save previous spellEffectPair to db
1448  itr2--;
1449  SpellEntry const* spellInfo = itr2->second->GetSpellProto();
1450  // do not save single target auras (unless they were cast by the player)
1451  if (!(itr2->second->GetCasterGUID() != GetGUID() && IsSingleTargetSpell(spellInfo)))
1452  {
1453  if (!itr2->second->IsPassive())
1454  {
1455  // skip all auras from spell that apply at cast SPELL_AURA_MOD_SHAPESHIFT or pet area auras.
1456  uint8 i;
1457  for (i = 0; i < 3; i++)
1458  if (spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_STEALTH ||
1459  spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_CHARM ||
1460  spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_POSSESS ||
1462  spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_OWNER ||
1463  spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_PET)
1464  break;
1466  if (i == 3)
1467  {
1468  CharacterDatabase.PExecute("INSERT INTO pet_aura (guid,caster_guid,item_caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges) "
1469  "VALUES ('%u', '" UI64FMTD "', '" UI64FMTD "', '%u', '%u', '%u', '%d', '%d', '%d', '%d')",
1470  m_charmInfo->GetPetNumber(), itr2->second->GetCasterGUID(), itr2->second->GetCastItemGUID(), (uint32)itr2->second->GetId(), (uint32)itr2->second->GetEffIndex(), (uint32)itr2->second->GetStackAmount(), itr2->second->GetModifier()->m_amount, int(itr2->second->GetAuraMaxDuration()), int(itr2->second->GetAuraDuration()), int(itr2->second->m_procCharges));
1471  }
1472  }
1473  }
1474  if (itr == auras.end())
1475  break;
1476  }
1478  if (lastEffectPair == itr->first)
1479  stackCounter++;
1480  else
1481  {
1482  lastEffectPair = itr->first;
1483  stackCounter = 1;
1484  }
1485  }
1486 }
bool IsSingleTargetSpell(SpellEntry const *spellInfo)
Definition: SpellMgr.cpp:783
AuraMap & GetAuras()
Definition: Unit.h:1739
CharmInfo * m_charmInfo
Definition: Unit.h:2050
std::pair< uint32, uint8 > spellEffectPair
Definition: Unit.h:915
uint32 Effect[MAX_SPELL_EFFECTS]
Definition: DBCStructure.h:724
uint32 EffectApplyAuraName[MAX_SPELL_EFFECTS]
Definition: DBCStructure.h:734
ACE_UINT8 uint8
Definition: Define.h:73
#define UI64FMTD
Definition: Common.h:149
uint32 GetPetNumber() const
Definition: Unit.h:803
std::multimap< spellEffectPair, Aura * > AuraMap
Definition: Unit.h:916
bool PExecute(const char *format,...) ATTR_PRINTF(2
Definition: Database.cpp:441
DatabaseType CharacterDatabase
Accessor to the character database.
Definition: Main.cpp:54
ACE_UINT32 uint32
Definition: Define.h:71
const uint64 & GetGUID() const
Definition: Object.h:162
void Pet::_SaveSpellCooldowns ( )

Definition at line 1286 of file Pet.cpp.

References CharacterDatabase, CharmInfo::GetPetNumber(), getPetType(), Unit::m_charmInfo, Creature::m_CreatureSpellCooldowns, Database::PExecute(), SUMMON_PET, and UI64FMTD.

Referenced by SavePetToDB().

1287 {
1288  if (getPetType() == SUMMON_PET) //don't save cooldowns for temp pets, thats senseless
1289  return;
1291  CharacterDatabase.PExecute("DELETE FROM pet_spell_cooldown WHERE guid = '%u'", m_charmInfo->GetPetNumber());
1293  time_t curTime = time(NULL);
1295  // remove oudated and save active
1296  for (CreatureSpellCooldowns::iterator itr = m_CreatureSpellCooldowns.begin(); itr != m_CreatureSpellCooldowns.end();)
1297  {
1298  if (itr->second <= curTime)
1299  m_CreatureSpellCooldowns.erase(itr++);
1300  else
1301  {
1302  CharacterDatabase.PExecute("INSERT INTO pet_spell_cooldown (guid,spell,time) VALUES ('%u', '%u', '" UI64FMTD "')", m_charmInfo->GetPetNumber(), itr->first, uint64(itr->second));
1303  ++itr;
1304  }
1305  }
1306 }
CharmInfo * m_charmInfo
Definition: Unit.h:2050
Definition: Pet.h:27
#define UI64FMTD
Definition: Common.h:149
uint32 GetPetNumber() const
Definition: Unit.h:803
bool PExecute(const char *format,...) ATTR_PRINTF(2
Definition: Database.cpp:441
CreatureSpellCooldowns m_CreatureSpellCooldowns
Definition: Creature.h:605
ACE_UINT64 uint64
Definition: Define.h:70
DatabaseType CharacterDatabase
Accessor to the character database.
Definition: Main.cpp:54
PetType getPetType() const
Definition: Pet.h:155
void Pet::_SaveSpells ( )

Definition at line 1324 of file Pet.cpp.

References CharacterDatabase, CharmInfo::GetPetNumber(), Unit::m_charmInfo, m_spells, PETSPELL_CHANGED, PETSPELL_FAMILY, PETSPELL_NEW, PETSPELL_REMOVED, PETSPELL_UNCHANGED, and Database::PExecute().

Referenced by SavePetToDB().

1325 {
1326  for (PetSpellMap::iterator itr = m_spells.begin(), next = m_spells.begin(); itr != m_spells.end(); itr = next)
1327  {
1328  ++next;
1330  // prevent saving family passives to DB
1331  if (itr->second.type == PETSPELL_FAMILY)
1332  continue;
1334  switch (itr->second.state)
1335  {
1337  CharacterDatabase.PExecute("DELETE FROM pet_spell WHERE guid = '%u' and spell = '%u'", m_charmInfo->GetPetNumber(), itr->first);
1338  m_spells.erase(itr);
1339  continue;
1341  CharacterDatabase.PExecute("DELETE FROM pet_spell WHERE guid = '%u' and spell = '%u'", m_charmInfo->GetPetNumber(), itr->first);
1342  CharacterDatabase.PExecute("INSERT INTO pet_spell (guid,spell,active) VALUES ('%u', '%u', '%u')", m_charmInfo->GetPetNumber(), itr->first, itr->second.active);
1343  break;
1344  case PETSPELL_NEW:
1345  CharacterDatabase.PExecute("INSERT INTO pet_spell (guid,spell,active) VALUES ('%u', '%u', '%u')", m_charmInfo->GetPetNumber(), itr->first, itr->second.active);
1346  break;
1348  continue;
1349  }
1351  itr->second.state = PETSPELL_UNCHANGED;
1352  }
1353 }
CharmInfo * m_charmInfo
Definition: Unit.h:2050
uint32 GetPetNumber() const
Definition: Unit.h:803
bool PExecute(const char *format,...) ATTR_PRINTF(2
Definition: Database.cpp:441
PetSpellMap m_spells
Definition: Pet.h:247
DatabaseType CharacterDatabase
Accessor to the character database.
Definition: Main.cpp:54
bool Pet::addSpell ( uint16  spell_id,
uint16  active = ACT_DECIDE,
PetSpellState  state = PETSPELL_NEW,
PetSpellType  type = PETSPELL_NORMAL 

Definition at line 1488 of file Pet.cpp.

References ACT_DECIDE, ACT_DISABLED, ACT_ENABLED, ACT_PASSIVE, PetSpell::active, CharmInfo::AddSpellToActionBar(), Unit::CastSpell(), CharacterDatabase, IsAutocastableSpell(), IsPassiveSpell(), Unit::m_charmInfo, m_spells, PETSPELL_CHANGED, PETSPELL_NEW, PETSPELL_REMOVED, PETSPELL_UNCHANGED, Database::PExecute(), removeSpell(), sLog, sSpellMgr, sSpellStore, PetSpell::state, ToggleAutocast(), and PetSpell::type.

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

1489 {
1490  SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell_id);
1491  if (!spellInfo)
1492  {
1493  // do pet spell book cleanup
1494  if (state == PETSPELL_UNCHANGED) // spell load case
1495  {
1496  sLog.outError("Pet::addSpell: Invalid SpellStore spell #%u request, deleting for all pets in pet_spell.", spell_id);
1497  CharacterDatabase.PExecute("DELETE FROM pet_spell WHERE spell = '%u'", spell_id);
1498  }
1499  else
1500  sLog.outError("Pet::addSpell: Invalid SpellStore spell #%u request.", spell_id);
1502  return false;
1503  }
1505  PetSpellMap::iterator itr = m_spells.find(spell_id);
1506  if (itr != m_spells.end())
1507  {
1508  if (itr->second.state == PETSPELL_REMOVED)
1509  {
1510  m_spells.erase(itr);
1511  state = PETSPELL_CHANGED;
1512  }
1513  else if (state == PETSPELL_UNCHANGED && itr->second.state != PETSPELL_UNCHANGED)
1514  {
1515  // can be in case spell loading but learned at some previous spell loading
1516  itr->second.state = PETSPELL_UNCHANGED;
1518  if (active == ACT_ENABLED)
1519  ToggleAutocast(spell_id, true);
1520  else if (active == ACT_DISABLED)
1521  ToggleAutocast(spell_id, false);
1523  return false;
1524  }
1525  else
1526  return false;
1527  }
1529  uint32 oldspell_id = 0;
1531  PetSpell newspell;
1532  newspell.state = state;
1533  newspell.type = type;
1535  if (active == ACT_DECIDE) // active was not used before, so we save it's autocast/passive state here
1536  {
1537  if (IsAutocastableSpell(spell_id))
1538  newspell.active = ACT_DISABLED;
1539  else
1540  newspell.active = ACT_PASSIVE;
1541  }
1542  else
1543  newspell.active = active;
1545  uint32 chainstart = sSpellMgr.GetFirstSpellInChain(spell_id);
1547  for (PetSpellMap::iterator itr2 = m_spells.begin(); itr2 != m_spells.end(); ++itr2)
1548  {
1549  if (itr2->second.state == PETSPELL_REMOVED) continue;
1551  if (sSpellMgr.GetFirstSpellInChain(itr2->first) == chainstart)
1552  {
1553  newspell.active = itr2->second.active;
1555  if (newspell.active == ACT_ENABLED)
1556  ToggleAutocast(itr2->first, false);
1558  oldspell_id = itr2->first;
1559  removeSpell(itr2->first);
1560  break;
1561  }
1562  }
1564  m_spells[spell_id] = newspell;
1566  if (IsPassiveSpell(spell_id))
1567  CastSpell(this, spell_id, true);
1568  else if (state == PETSPELL_NEW)
1569  m_charmInfo->AddSpellToActionBar(oldspell_id, spell_id, (ActiveStates)active);
1571  if (newspell.active == ACT_ENABLED)
1572  ToggleAutocast(spell_id, true);
1574  return true;
1575 }
PetSpellType type
Definition: Pet.h:99
bool AddSpellToActionBar(uint32 oldid, uint32 newid, ActiveStates newstate=ACT_DECIDE)
Definition: Unit.cpp:11362
void ToggleAutocast(uint32 spellid, bool apply)
Definition: Pet.cpp:1704
bool IsPassiveSpell(uint32 spellId)
Definition: SpellMgr.cpp:278
CharmInfo * m_charmInfo
Definition: Unit.h:2050
#define sLog
Log class singleton.
Definition: Log.h:187
DBCStorage< SpellEntry > sSpellStore(SpellEntryfmt)
Definition: Pet.h:94
void CastSpell(Unit *Victim, uint32 spellId, bool triggered, Item *castItem=NULL, Aura *triggeredByAura=NULL, uint64 originalCaster=0)
Definition: Unit.cpp:1223
#define sSpellMgr
Definition: SpellMgr.h:1239
bool IsAutocastableSpell(uint32 spellId)
Definition: SpellMgr.cpp:291
bool PExecute(const char *format,...) ATTR_PRINTF(2
Definition: Database.cpp:441
PetSpellMap m_spells
Definition: Pet.h:247
Definition: Unit.h:746
uint16 active
Definition: Pet.h:96
DatabaseType CharacterDatabase
Accessor to the character database.
Definition: Main.cpp:54
ACE_UINT32 uint32
Definition: Define.h:71
void removeSpell(uint16 spell_id)
Definition: Pet.cpp:1589
PetSpellState state
Definition: Pet.h:98
void Pet::AddTeachSpell ( uint32  learned_id,
uint32  source_id 

Definition at line 227 of file Pet.h.

References ACT_DECIDE, PetSpell::active, PETSPELL_NEW, PETSPELL_NORMAL, PetSpell::state, and PetSpell::type.

Referenced by InitPetCreateSpells(), and LoadPetFromDB().

228  {
229  m_teachspells[learned_id] = source_id;
230  }
TeachSpellMap m_teachspells
Definition: Pet.h:248
void Pet::AddToWorld ( )

Reimplemented from Creature.

Definition at line 98 of file Pet.cpp.

References ObjectAccessor::AddObject(), Unit::AddToWorld(), Creature::AIM_Initialize(), COMMAND_FOLLOW, Unit::GetCharmInfo(), Oregon::Singleton< ObjectAccessor, Oregon::ClassLevelLockable< ObjectAccessor, ACE_Thread_Mutex > >::Instance(), Object::IsInWorld(), CharmInfo::SetIsAtStay(), CharmInfo::SetIsCommandAttack(), CharmInfo::SetIsCommandFollow(), CharmInfo::SetIsFollowing(), and CharmInfo::SetIsReturning().

Referenced by Spell::EffectSummonDeadPet().

99 {
100  // Register the pet for guid lookup
101  if (!IsInWorld())
102  {
105  AIM_Initialize();
106  }
108  // Prevent stuck pets when zoning. Pets default to "follow" when added to world
109  // so we'll reset flags and let the AI handle things
110  if (GetCharmInfo() && GetCharmInfo()->HasCommandState(COMMAND_FOLLOW))
111  {
114  GetCharmInfo()->SetIsAtStay(false);
115  GetCharmInfo()->SetIsFollowing(false);
116  GetCharmInfo()->SetIsReturning(false);
117  }
118 }
void SetIsFollowing(bool val)
Definition: Unit.cpp:13580
void AddObject(T *object)
void AddToWorld() override
Definition: Unit.cpp:11129
bool AIM_Initialize(CreatureAI *ai=NULL)
Definition: Creature.cpp:746
CharmInfo * GetCharmInfo()
Definition: Unit.h:1458
const bool & IsInWorld() const
Definition: Object.h:135
void SetIsReturning(bool val)
Definition: Unit.cpp:13590
void SetIsAtStay(bool val)
Definition: Unit.cpp:13570
void SetIsCommandAttack(bool val)
Definition: Unit.cpp:13538
orders pet to follow
Definition: Unit.h:769
void SetIsCommandFollow(bool val)
Definition: Unit.cpp:13548
void Pet::ApplyModeFlags ( PetModeFlags  mode,
bool  apply 

Definition at line 1992 of file Pet.cpp.

References Object::GetGUID(), GetOwner(), Object::GetTypeId(), m_petModeFlags, SMSG_PET_MODE, and TYPEID_PLAYER.

1993 {
1994  if (apply)
1996  else
1999  Unit* owner = GetOwner();
2000  if(!owner || owner->GetTypeId()!=TYPEID_PLAYER)
2001  return;
2003  WorldPacket data(SMSG_PET_MODE, 12);
2004  data << uint64(GetGUID());
2005  data << uint32(m_petModeFlags);
2006  ((Player*)owner)->GetSession()->SendPacket(&data);
2007 }
void apply(T *val)
Definition: ByteConverter.h:41
PetModeFlags m_petModeFlags
Definition: Pet.h:305
uint8 GetTypeId() const
Definition: Object.h:210
Player * GetOwner()
Definition: Pet.h:286
ACE_UINT64 uint64
Definition: Define.h:70
ACE_UINT32 uint32
Definition: Define.h:71
Definition: Pet.h:53
Definition: Unit.h:908
Definition: Player.h:922
const uint64 & GetGUID() const
Definition: Object.h:162
bool Pet::CanSwim ( ) const

Definition at line 216 of file Pet.h.

References ByteConverter::apply().

216 { return true; }
bool Pet::CanTakeMoreActiveSpells ( uint32  SpellIconID)

Definition at line 738 of file Pet.cpp.

References ACTIVE_SPELLS_MAX, IsPassiveSpell(), m_spells, and sSpellMgr.

Referenced by Spell::CheckCast().

739 {
740  uint8 activecount = 1;
741  uint32 chainstartstore[ACTIVE_SPELLS_MAX];
743  if (IsPassiveSpell(spellid))
744  return true;
746  chainstartstore[0] = sSpellMgr.GetFirstSpellInChain(spellid);
748  for (PetSpellMap::iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr)
749  {
750  if (IsPassiveSpell(itr->first))
751  continue;
753  uint32 chainstart = sSpellMgr.GetFirstSpellInChain(itr->first);
755  uint8 x;
757  for (x = 0; x < activecount; x++)
758  {
759  if (chainstart == chainstartstore[x])
760  break;
761  }
763  if (x == activecount) //spellchain not yet saved -> add active count
764  {
765  ++activecount;
766  if (activecount > ACTIVE_SPELLS_MAX)
767  return false;
768  chainstartstore[x] = chainstart;
769  }
770  }
771  return true;
772 }
bool IsPassiveSpell(uint32 spellId)
Definition: SpellMgr.cpp:278
ACE_UINT8 uint8
Definition: Define.h:73
#define sSpellMgr
Definition: SpellMgr.h:1239
Definition: Pet.h:142
PetSpellMap m_spells
Definition: Pet.h:247
ACE_UINT32 uint32
Definition: Define.h:71
void Pet::CastPetAura ( PetAura const *  aura)

Definition at line 1977 of file Pet.cpp.

References CalculatePct(), Unit::CastCustomSpell(), Unit::CastSpell(), PetAura::GetAura(), PetAura::GetDamage(), Object::GetEntry(), Unit::GetStat(), STAT_INTELLECT, and STAT_STAMINA.

Referenced by CastPetAuras().

1978 {
1979  uint32 auraId = aura->GetAura(GetEntry());
1980  if (!auraId)
1981  return;
1983  if (auraId == 35696) // Demonic Knowledge
1984  {
1985  int32 basePoints = CalculatePct(aura->GetDamage(), GetStat(STAT_STAMINA) + GetStat(STAT_INTELLECT));
1986  CastCustomSpell(this, auraId, &basePoints, NULL, NULL, true);
1987  }
1988  else
1989  CastSpell(this, auraId, true);
1990 }
void CastCustomSpell(Unit *Victim, uint32 spellId, int32 const *bp0, int32 const *bp1, int32 const *bp2, bool triggered, Item *castItem=NULL, Aura *triggeredByAura=NULL, uint64 originalCaster=0)
Definition: Unit.cpp:1297
ACE_INT32 int32
Definition: Define.h:67
void CastSpell(Unit *Victim, uint32 spellId, bool triggered, Item *castItem=NULL, Aura *triggeredByAura=NULL, uint64 originalCaster=0)
Definition: Unit.cpp:1223
T CalculatePct(T base, U pct)
Definition: Util.h:97
uint32 GetEntry() const
Definition: Object.h:192
ACE_UINT32 uint32
Definition: Define.h:71
float GetStat(Stats stat) const
Definition: Unit.h:1066
void Pet::CastPetAuras ( bool  current)

Definition at line 1956 of file Pet.cpp.

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

Referenced by InitPetCreateSpells(), LoadPetFromDB(), and setDeathState().

1957 {
1958  Unit* owner = GetOwner();
1959  if (!owner || owner->GetTypeId() != TYPEID_PLAYER)
1960  return;
1962  if (!IsPermanentPetFor(owner->ToPlayer()))
1963  return;
1965  for (PetAuraSet::iterator itr = owner->m_petAuras.begin(); itr != owner->m_petAuras.end();)
1966  {
1967  PetAura const* pa = *itr;
1968  ++itr;
1970  if (!current && pa->IsRemovedOnChangePet())
1971  owner->RemovePetAura(pa);
1972  else
1973  CastPetAura(pa);
1974  }
1975 }
Player * ToPlayer()
Definition: Object.h:392
void RemovePetAura(PetAura const *petSpell)
Definition: Unit.cpp:12338
void CastPetAura(PetAura const *aura)
Definition: Pet.cpp:1977
bool IsRemovedOnChangePet() const
Definition: SpellMgr.h:759
uint8 GetTypeId() const
Definition: Object.h:210
bool IsPermanentPetFor(Player *owner)
Definition: Pet.cpp:1751
Player * GetOwner()
Definition: Pet.h:286
PetAuraSet m_petAuras
Definition: Unit.h:1954
Definition: Unit.h:908
void Pet::CheckLearning ( uint32  spellid)

Definition at line 1664 of file Pet.cpp.

References GetOwner(), getPetType(), Object::GetTypeId(), HUNTER_PET, Player::LearnSpell(), m_teachspells, Object::ToPlayer(), TYPEID_PLAYER, and urand().

Referenced by WorldSession::HandlePetCastSpellOpcode().

1665 {
1666  //charmed case -> prevent crash
1667  if (GetTypeId() == TYPEID_PLAYER || getPetType() != HUNTER_PET)
1668  return;
1670  Unit* owner = GetOwner();
1672  if (m_teachspells.empty() || !owner || owner->GetTypeId() != TYPEID_PLAYER)
1673  return;
1675  TeachSpellMap::iterator itr = m_teachspells.find(spellid);
1676  if (itr == m_teachspells.end())
1677  return;
1679  if (urand(0, 100) < 10)
1680  {
1681  owner->ToPlayer()->LearnSpell(itr->second);
1682  m_teachspells.erase(itr);
1683  }
1684 }
TeachSpellMap m_teachspells
Definition: Pet.h:248
Definition: Pet.h:28
Player * ToPlayer()
Definition: Object.h:392
uint8 GetTypeId() const
Definition: Object.h:210
Player * GetOwner()
Definition: Pet.h:286
Definition: Unit.h:908
void LearnSpell(uint32 spell_id)
Definition: Player.cpp:3140
PetType getPetType() const
Definition: Pet.h:155
uint32 urand(uint32 min, uint32 max)
Definition: Util.cpp:33
bool Pet::Create ( uint32  guidlow,
Map map,
uint32  phaseMask,
uint32  Entry,
uint32  pet_number 

Definition at line 1770 of file Pet.cpp.

References Object::_Create(), ASSERT, HIGHGUID_PET, Creature::InitEntry(), InitPetAuras(), Creature::m_DBTableGuid, Creature::m_originalEntry, Object::SetByteValue(), WorldObject::SetMap(), Unit::SetPhaseMask(), Unit::SetSheath(), SHEATH_STATE_MELEE, UNIT_BYTE2_FLAG_AURAS, UNIT_BYTE2_FLAG_SANCTUARY, and UNIT_FIELD_BYTES_2.

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

1771 {
1772  ASSERT(map);
1773  SetMap(map);
1774  SetPhaseMask(phaseMask, false);
1776  Object::_Create(guidlow, pet_number, HIGHGUID_PET);
1778  m_DBTableGuid = guidlow;
1779  m_originalEntry = Entry;
1781  if (!InitEntry(Entry))
1782  return false;
1787  InitPetAuras(Entry);
1789  return true;
1790 }
bool InitEntry(uint32 entry, uint32 team=ALLIANCE, const CreatureData *data=NULL)
Definition: Creature.cpp:260
void InitPetAuras(const uint32 Entry)
Definition: Pet.cpp:1792
virtual void SetMap(Map *map)
Definition: Object.cpp:1954
void _Create(uint32 guidlow, uint32 entry, HighGuid guidhigh)
Definition: Object.cpp:125
void SetPhaseMask(uint32 newPhaseMask, bool update) override
Definition: Unit.cpp:13499
uint32 m_DBTableGuid
Definition: Creature.h:839
void SetByteValue(uint16 index, uint8 offset, uint8 value)
Definition: Object.cpp:878
uint32 m_originalEntry
Definition: Creature.h:848
virtual void SetSheath(SheathState sheathed)
Definition: Unit.h:1113
#define ASSERT
Definition: Errors.h:29
bool Pet::CreateBaseAtCreature ( Creature creature)

Definition at line 906 of file Pet.cpp.

References Create(), CREATURE_TYPE_BEAST, CreatureInfo::family, Unit::GetCreatePowers(), Creature::GetCreatureTemplate(), Unit::GetDisplayId(), Object::GetEntry(), Object::GetGUIDLow(), Unit::getLevel(), WorldObject::GetMap(), WorldObject::GetName(), Unit::GetNativeDisplayId(), Position::GetOrientation(), WorldObject::GetPhaseMask(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), Object::GetUInt32Value(), HIGHGUID_PET, Position::IsPositionValid(), m_loyaltyPoints, CreatureFamilyEntry::Name, POWER_FOCUS, POWER_HAPPINESS, REBELLIOUS, Position::Relocate(), sCreatureFamilyStore, Object::SetByteValue(), Unit::SetDisplayId(), SetLoyaltyLevel(), Unit::SetMaxPower(), WorldObject::SetName(), Unit::SetNativeDisplayId(), Unit::SetPower(), Unit::setPowerType(), Unit::SetSheath(), Object::SetUInt32Value(), SHEATH_STATE_MELEE, sLog, sObjectMgr, sWorld, CreatureInfo::type, UNIT_BYTE2_FLAG_AURAS, UNIT_BYTE2_FLAG_SANCTUARY, UNIT_BYTE2_FLAG_UNK5, UNIT_FIELD_BYTES_0, UNIT_FIELD_BYTES_2, UNIT_FIELD_FLAGS, UNIT_FIELD_PET_NAME_TIMESTAMP, UNIT_FIELD_PETEXPERIENCE, UNIT_FIELD_PETNEXTLEVELEXP, UNIT_FLAG_PVP_ATTACKABLE, UNIT_MOD_CAST_SPEED, UNIT_NPC_FLAGS, UNIT_RENAME_ALLOWED, and Oregon::XP::xp_to_level().

Referenced by Unit::CreateTamedPetFrom(), and ChatHandler::HandleCreatePetCommand().

907 {
908  if (!creature)
909  {
910  sLog.outError("CRITICAL ERROR: NULL pointer parsed into CreateBaseAtCreature()");
911  return false;
912  }
913  uint32 guid = sObjectMgr.GenerateLowGuid(HIGHGUID_PET);
915  sLog.outDebug("Create pet");
916  uint32 pet_number = sObjectMgr.GeneratePetNumber();
917  if (!Create(guid, creature->GetMap(), creature->GetPhaseMask(), creature->GetEntry(), pet_number))
918  return false;
920  Relocate(creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ(), creature->GetOrientation());
922  if (!IsPositionValid())
923  {
924  sLog.outError("Pet (guidlow %d, entry %d) not created base at creature. Suggested coordinates isn't valid (X: %f Y: %f)",
926  return false;
927  }
929  CreatureInfo const* cinfo = GetCreatureTemplate();
930  if (!cinfo)
931  {
932  sLog.outError("CreateBaseAtCreature() failed, creatureInfo is missing!");
933  return false;
934  }
936  SetDisplayId(creature->GetDisplayId());
939  SetPower(POWER_HAPPINESS, 166500);
947  CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(creature->GetCreatureTemplate()->family);
948  if (char* familyname = cFamily->Name[sWorld.GetDefaultDbcLocale()])
949  SetName(familyname);
950  else
951  SetName(creature->GetName());
953  m_loyaltyPoints = 1000;
954  if (cinfo->type == CREATURE_TYPE_BEAST)
955  {
956  SetUInt32Value(UNIT_FIELD_BYTES_0, 0x02020100);
963  }
964  return true;
965 }
const uint32 & GetUInt32Value(uint16 index) const
Definition: Object.h:234
Map * GetMap() const
Definition: Object.h:841
#define sLog
Log class singleton.
Definition: Log.h:187
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:779
uint32 GetNativeDisplayId()
Definition: Unit.h:1787
void SetNativeDisplayId(uint32 modelId)
Definition: Unit.h:1791
uint32 GetGUIDLow() const
Definition: Object.h:166
#define sObjectMgr
Definition: ObjectMgr.h:1285
void setPowerType(Powers power)
Definition: Unit.cpp:7144
uint8 getLevel() const
Definition: Unit.h:1057
uint32 GetCreatePowers(Powers power) const
Definition: Unit.cpp:11111
float GetOrientation() const
Definition: Position.h:100
uint32 GetDisplayId()
Definition: Unit.h:1782
void Relocate(float x, float y)
Definition: Position.h:65
uint32 GetPhaseMask() const
Definition: Object.h:694
void SetDisplayId(uint32 modelId)
Definition: Unit.cpp:11975
uint32 type
Definition: Creature.h:169
uint32 xp_to_level(uint32 lvl)
Definition: Formulas.h:157
float GetPositionY() const
Definition: Position.h:98
void SetByteValue(uint16 index, uint8 offset, uint8 value)
Definition: Object.cpp:878
float GetPositionZ() const
Definition: Position.h:99
DBCStorage< CreatureFamilyEntry > sCreatureFamilyStore(CreatureFamilyfmt)
virtual void SetSheath(SheathState sheathed)
Definition: Unit.h:1113
const char * GetName() const
Definition: Object.h:704
void SetLoyaltyLevel(LoyaltyLevel level)
Definition: Pet.cpp:733
CreatureInfo const * GetCreatureTemplate() const
Definition: Creature.h:557
void SetName(const std::string &newname)
Definition: Object.h:708
void SetPower(Powers power, uint32 val)
Definition: Unit.cpp:10997
void SetMaxPower(Powers power, uint32 val)
Definition: Unit.cpp:11030
uint32 GetEntry() const
Definition: Object.h:192
bool IsPositionValid() const
Definition: Position.cpp:40
#define sWorld
Definition: World.h:860
ACE_UINT32 uint32
Definition: Define.h:71
float GetPositionX() const
Definition: Position.h:97
Definition: Pet.h:72
CreatureFamily family
Definition: Creature.h:164
bool Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 pet_number)
Definition: Pet.cpp:1770
int32 m_loyaltyPoints
Definition: Pet.h:297
void Pet::DeleteFromDB ( uint32  guidlow)

Definition at line 475 of file Pet.cpp.

References CharacterDatabase, and Database::PExecute().

476 {
477  CharacterDatabase.PExecute("DELETE FROM character_pet WHERE id = '%u'", guidlow);
478  CharacterDatabase.PExecute("DELETE FROM character_pet_declinedname WHERE id = '%u'", guidlow);
479  CharacterDatabase.PExecute("DELETE FROM pet_aura WHERE guid = '%u'", guidlow);
480  CharacterDatabase.PExecute("DELETE FROM pet_spell WHERE guid = '%u'", guidlow);
481  CharacterDatabase.PExecute("DELETE FROM pet_spell_cooldown WHERE guid = '%u'", guidlow);
482 }
bool PExecute(const char *format,...) ATTR_PRINTF(2
Definition: Database.cpp:441
DatabaseType CharacterDatabase
Accessor to the character database.
Definition: Main.cpp:54
void Pet::DeleteFromDB ( )

Reimplemented from Creature.

Definition at line 316 of file Pet.h.

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

317  {
318  assert(false);
319  }
uint64 Pet::GetAuraUpdateMask ( )

Definition at line 262 of file Pet.h.

Referenced by WorldSession::BuildPartyMemberStatsChangedPacket().

263  {
264  return m_auraUpdateMask;
265  }
uint64 m_auraUpdateMask
Definition: Pet.h:298
uint32 Pet::GetCurrentFoodBenefitLevel ( uint32  itemlevel)

Definition at line 1224 of file Pet.cpp.

References Unit::getLevel().

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

1225 {
1226  // -5 or greater food level
1227  if (getLevel() <= itemlevel + 5) //possible to feed level 60 pet with level 55 level food for full effect
1228  return 35000;
1229  // -10..-6
1230  else if (getLevel() <= itemlevel + 10) //pure guess, but sounds good
1231  return 17000;
1232  // -14..-11
1233  else if (getLevel() <= itemlevel + 14) //level 55 food gets green on 70, makes sense to me
1234  return 8000;
1235  // -15 or less
1236  else
1237  return 0; //food too low level
1238 }
uint8 getLevel() const
Definition: Unit.h:1057
DeclinedName const* Pet::GetDeclinedNames ( ) const

Definition at line 279 of file Pet.h.

280  {
281  return m_declinedname;
282  }
DeclinedName * m_declinedname
Definition: Pet.h:300
int32 Pet::GetDispTP ( )

Definition at line 844 of file Pet.cpp.

References getPetType(), HUNTER_PET, and m_TrainingPoints.

Referenced by SetTP().

845 {
846  if (getPetType() != HUNTER_PET)
847  return (0);
848  if (m_TrainingPoints < 0)
849  return -m_TrainingPoints;
850  else
851  return -(m_TrainingPoints + 1);
852 }
Definition: Pet.h:28
int32 m_TrainingPoints
Definition: Pet.h:258
PetType getPetType() const
Definition: Pet.h:155
HappinessState Pet::GetHappinessState ( )

Definition at line 723 of file Pet.cpp.


Referenced by TickLoyaltyChange(), and Guardian::UpdateDamagePhysical().

724 {
726  return UNHAPPY;
728  return HAPPY;
729  else
730  return CONTENT;
731 }
Definition: Pet.h:67
Definition: Pet.h:137
uint32 GetPower(Powers power) const
Definition: Unit.h:1096
Definition: Pet.h:65
Definition: Pet.h:66
uint32 Pet::GetLoyaltyLevel ( )

Definition at line 204 of file Pet.h.

References UNIT_FIELD_BYTES_1.

Referenced by GivePetLevel(), WorldSession::HandlePetUnlearnOpcode(), KillLoyaltyBonus(), LoseHappiness(), ModifyLoyalty(), SavePetToDB(), and WorldSession::SendStablePet().

205  {
206  return GetByteValue(UNIT_FIELD_BYTES_1, 1);
207  }
uint8 GetByteValue(uint16 index, uint8 offset) const
Definition: Object.h:252
uint32 Pet::GetMaxLoyaltyPoints ( uint32  level)

Definition at line 824 of file Pet.cpp.

References LevelUpLoyalty.

Referenced by ModifyLoyalty().

825 {
826  if (level < 1) level = 1; // prevent SIGSEGV (out of range)
827  if (level > 7) level = 7; // prevent SIGSEGV (out of range)
828  return LevelUpLoyalty[level - 1];
829 }
uint32 const LevelUpLoyalty[6]
Definition: Pet.cpp:34
PetModeFlags Pet::GetModeFlags ( ) const

Definition at line 224 of file Pet.h.

Referenced by PetAI::CanAttack().

224 { return m_petModeFlags; }
PetModeFlags m_petModeFlags
Definition: Pet.h:305
uint32 Pet::GetPetAutoSpellOnPos ( uint8  pos) const

Reimplemented from Creature.

Definition at line 188 of file Pet.h.

189  {
190  if (pos >= m_autospells.size())
191  return 0;
192  else
193  return m_autospells[pos];
194  }
AutoSpellList m_autospells
Definition: Pet.h:249
uint8 Pet::GetPetAutoSpellSize ( ) const

Reimplemented from Creature.

Definition at line 184 of file Pet.h.

185  {
186  return m_autospells.size();
187  }
AutoSpellList m_autospells
Definition: Pet.h:249
uint32 Pet::GetStartLoyaltyPoints ( uint32  level)

Definition at line 831 of file Pet.cpp.

References LevelStartLoyalty.

Referenced by ModifyLoyalty().

832 {
833  if (level < 1) level = 1; // prevent SIGSEGV (out of range)
834  if (level > 7) level = 7; // prevent SIGSEGV (out of range)
835  return LevelStartLoyalty[level - 1];
836 }
uint32 const LevelStartLoyalty[6]
Definition: Pet.cpp:44
int32 Pet::GetTPForSpell ( uint32  spellid)

Definition at line 782 of file Pet.cpp.

References m_spells, PETSPELL_REMOVED, and sSpellMgr.

Referenced by Spell::EffectLearnPetSpell(), and HasTPForSpell().

783 {
784  uint32 basetrainp = 0;
786  SkillLineAbilityMap::const_iterator lower = sSpellMgr.GetBeginSkillLineAbilityMap(spellid);
787  SkillLineAbilityMap::const_iterator upper = sSpellMgr.GetEndSkillLineAbilityMap(spellid);
788  for (SkillLineAbilityMap::const_iterator _spell_idx = lower; _spell_idx != upper; ++_spell_idx)
789  {
790  if (!_spell_idx->second->reqtrainpoints)
791  return 0;
793  basetrainp = _spell_idx->second->reqtrainpoints;
794  break;
795  }
797  uint32 spenttrainp = 0;
798  uint32 chainstart = sSpellMgr.GetFirstSpellInChain(spellid);
800  for (PetSpellMap::iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr)
801  {
802  if (itr->second.state == PETSPELL_REMOVED)
803  continue;
805  if (sSpellMgr.GetFirstSpellInChain(itr->first) == chainstart)
806  {
807  SkillLineAbilityMap::const_iterator _lower = sSpellMgr.GetBeginSkillLineAbilityMap(itr->first);
808  SkillLineAbilityMap::const_iterator _upper = sSpellMgr.GetEndSkillLineAbilityMap(itr->first);
810  for (SkillLineAbilityMap::const_iterator _spell_idx2 = _lower; _spell_idx2 != _upper; ++_spell_idx2)
811  {
812  if (_spell_idx2->second->reqtrainpoints > spenttrainp)
813  {
814  spenttrainp = _spell_idx2->second->reqtrainpoints;
815  break;
816  }
817  }
818  }
819  }
821  return int32(basetrainp) - int32(spenttrainp);
822 }
ACE_INT32 int32
Definition: Define.h:67
#define sSpellMgr
Definition: SpellMgr.h:1239
PetSpellMap m_spells
Definition: Pet.h:247
ACE_UINT32 uint32
Definition: Define.h:71
void Pet::GivePetLevel ( uint32  level)

Definition at line 897 of file Pet.cpp.

References Unit::getLevel(), GetLoyaltyLevel(), Guardian::InitStatsForLevel(), m_TrainingPoints, and SetTP().

Referenced by Player::GiveLevel(), and GivePetXP().

898 {
899  if (!level || level == getLevel())
900  return;
902  InitStatsForLevel(level);
904 }
uint8 getLevel() const
Definition: Unit.h:1057
bool InitStatsForLevel(uint32 level)
Definition: Pet.cpp:967
int32 m_TrainingPoints
Definition: Pet.h:258
uint32 GetLoyaltyLevel()
Definition: Pet.h:204
void SetTP(int32 TP)
Definition: Pet.cpp:838
void Pet::GivePetXP ( uint32  xp)

Definition at line 859 of file Pet.cpp.

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

860 {
861  if (getPetType() != HUNTER_PET)
862  return;
864  if (xp < 1)
865  return;
867  if (!IsAlive())
868  return;
870  uint32 level = getLevel();
871  uint8 maxlevel = std::min((uint8)sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL), GetOwner()->getLevel());
875  uint32 newXP = curXP + xp;
877  // Don't give pet next level if current pet level = player level.
878  if(newXP >= nextLvlXP && level >= maxlevel)
879  return;
881  while (newXP >= nextLvlXP && level < maxlevel)
882  {
883  newXP -= nextLvlXP;
884  ++level;
886  GivePetLevel(level); // also update UNIT_FIELD_PETNEXTLEVELEXP and UNIT_FIELD_PETEXPERIENCE to level start
889  }
891  SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, level <= maxlevel ? newXP : 0);
893  if (getPetType() == HUNTER_PET)
894  KillLoyaltyBonus(level);
895 }
const uint32 & GetUInt32Value(uint16 index) const
Definition: Object.h:234
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:779
Definition: Pet.h:28
uint8 getLevel() const
Definition: Unit.h:1057
ACE_UINT8 uint8
Definition: Define.h:73
bool IsAlive() const
Definition: Unit.h:1336
Player * GetOwner()
Definition: Pet.h:286
void KillLoyaltyBonus(uint32 level)
Definition: Pet.cpp:713
#define sWorld
Definition: World.h:860
ACE_UINT32 uint32
Definition: Define.h:71
void GivePetLevel(uint32 level)
Definition: Pet.cpp:897
PetType getPetType() const
Definition: Pet.h:155
bool Pet::HasSpell ( uint32  spell) const

Reimplemented from Creature.

Definition at line 1929 of file Pet.cpp.

References m_spells.

Referenced by ChatHandler::HandlePetLearnCommand(), and ChatHandler::HandlePetUnlearnCommand().

1930 {
1931  return (m_spells.find(spell) != m_spells.end());
1932 }
PetSpellMap m_spells
Definition: Pet.h:247
bool Pet::HasTPForSpell ( uint32  spellid)

Definition at line 774 of file Pet.cpp.

References GetTPForSpell(), and m_TrainingPoints.

Referenced by Spell::CheckCast().

775 {
776  int32 neededtrainp = GetTPForSpell(spellid);
777  if ((m_TrainingPoints - neededtrainp < 0 || neededtrainp < 0) && neededtrainp != 0)
778  return false;
779  return true;
780 }
int32 GetTPForSpell(uint32 spellid)
Definition: Pet.cpp:782
ACE_INT32 int32
Definition: Define.h:67
int32 m_TrainingPoints
Definition: Pet.h:258
bool Pet::HaveInDiet ( ItemTemplate const *  item) const

Definition at line 1206 of file Pet.cpp.

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

Referenced by Spell::CheckCast().

1207 {
1208  if (!item || !item->FoodType)
1209  return false;
1211  CreatureInfo const* cInfo = GetCreatureTemplate();
1212  if (!cInfo)
1213  return false;
1215  CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cInfo->family);
1216  if (!cFamily)
1217  return false;
1219  uint32 diet = cFamily->petFoodMask;
1220  uint32 FoodMask = 1 << (item->FoodType - 1);
1221  return diet & FoodMask;
1222 }
DBCStorage< CreatureFamilyEntry > sCreatureFamilyStore(CreatureFamilyfmt)
CreatureInfo const * GetCreatureTemplate() const
Definition: Creature.h:557
ACE_UINT32 uint32
Definition: Define.h:71
CreatureFamily family
Definition: Creature.h:164
void Pet::InitPetAuras ( const uint32  Entry<