Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
Pet.h
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6#ifndef SKYFIRESERVER_PET_H
7#define SKYFIRESERVER_PET_H
8
9#include "PetDefines.h"
10#include "TemporarySummon.h"
11
12#define PET_FOCUS_REGEN_INTERVAL 4 * IN_MILLISECONDS
13#define HAPPINESS_LEVEL_SIZE 333000
14
21
23typedef std::vector<uint32> AutoSpellList;
24
25class Player;
26
27class Pet : public Guardian
28{
29public:
30 explicit Pet(Player* owner, PetType type = PetType::MAX_PET_TYPE);
31 virtual ~Pet();
32
33 void AddToWorld();
34 void RemoveFromWorld();
35
36 void SetDisplayId(uint32 modelId);
37
38 PetType getPetType() const { return m_petType; }
39 void setPetType(PetType type) { m_petType = type; }
40 bool isControlled() const;
41 bool isTemporarySummoned() const { return m_duration > 0; }
42
43 bool IsPermanentPetFor(Player* owner) const; // pet have tab in character windows and set UNIT_FIELD_PET_NUMBER
44
45 bool Create(uint32 guidlow, Map* map, /*uint32 phaseMask,*/ uint32 Entry, uint32 pet_number);
46 bool CreateBaseAtCreature(Creature* creature);
47 bool CreateBaseAtCreatureInfo(CreatureTemplate const* cinfo, Unit* owner);
48 bool CreateBaseAtTamed(CreatureTemplate const* cinfo, Map* map/*, uint32 phaseMask*/);
49 bool LoadPetFromDB(Player* owner, uint32 petentry = 0, uint32 petnumber = 0, bool current = false);
50 bool isBeingLoaded() const { return m_loading; }
51 void SavePetToDB(PetSaveMode mode);
52 void Remove(PetSaveMode mode, bool returnreagent = false);
53 static void DeleteFromDB(uint32 guidlow);
54
55 void setDeathState(DeathState s); // overwrite virtual Creature::setDeathState and Unit::setDeathState
56 void Update(uint32 diff); // overwrite virtual Creature::Update and Unit::Update
57 void StartTransportExitGrace(uint32 duration);
60
61 uint8 GetPetAutoSpellSize() const { return m_autospells.size(); }
63 {
64 if (pos >= m_autospells.size())
65 return 0;
66 else
67 return m_autospells[pos];
68 }
69
70 void GivePetXP(uint32 xp);
71 void GivePetLevel(uint8 level);
73 bool HaveInDiet(ItemTemplate const* item) const;
75 void SetDuration(int32 dur) { m_duration = dur; }
76 int32 GetDuration() const { return m_duration; }
77
78 /*
79 bool UpdateStats(Stats stat);
80 bool UpdateAllStats();
81 void UpdateResistances(uint32 school);
82 void UpdateArmor();
83 void UpdateMaxHealth();
84 void UpdateMaxPower(Powers power);
85 void UpdateAttackPowerAndDamage(bool ranged = false);
86 void UpdateDamagePhysical(WeaponAttackType attType);
87 */
88
89 void ToggleAutocast(SpellInfo const* spellInfo, bool apply);
90
91 bool HasSpell(uint32 spell) const;
92
93 void LearnPetPassives();
94 void CastPetAuras(bool current);
95 void CastPetAura(PetAura const* aura);
96 bool IsPetAura(Aura const* aura);
97
100 void _LoadAuras(uint32 timediff);
101 void _SaveAuras(SQLTransaction& trans);
102 void _LoadSpells();
103 void _SaveSpells(SQLTransaction& trans);
104
105
109
110 void SetSpec(uint16 spec);
113
115 bool learnSpell(uint32 spell_id);
116 void learnSpellHighRank(uint32 spellid);
118 bool unlearnSpell(uint32 spell_id, bool learn_prev, bool clear_ab = true);
119 bool removeSpell(uint32 spell_id, bool learn_prev, bool clear_ab = true);
120 void CleanupActionBar();
121 virtual void ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs);
122
125
126 void InitPetCreateSpells();
127
128 bool resetTalents();
129 static void resetTalentsForAllPetsOf(Player* owner, Pet* online_pet = NULL);
130 void InitTalentForLevel();
131
135
137
141
143
144 bool m_removed; // prevent overwrite pet state in DB at next Pet::Update if pet already removed(saved)
145
146 Player* GetOwner() const;
147
148protected:
150 int32 m_duration; // time until unsummon (used mostly for summoned guardians and not used for controlled pets)
155
157
158private:
159 void SaveToDB(uint32, uint32) // override of Creature::SaveToDB - must not be called
160 {
161 ASSERT(false);
162 }
163 void DeleteFromDB() // override of Creature::DeleteFromDB - must not be called
164 {
165 ASSERT(false);
166 }
167};
168#endif
std::int32_t int32
Definition Define.h:73
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
std::uint64_t uint64
Definition Define.h:76
std::uint16_t uint16
Definition Define.h:78
#define ASSERT
Definition Errors.h:29
std::vector< uint32 > AutoSpellList
Definition Pet.h:23
UNORDERED_MAP< uint32, PetSpell > PetSpellMap
Definition Pet.h:22
PetSaveMode
Definition PetDefines.h:20
PetSpellState
Definition PetDefines.h:29
@ PETSPELL_NEW
Definition PetDefines.h:32
PetType
Definition PetDefines.h:10
@ MAX_PET_TYPE
Definition PetDefines.h:13
PetSpellType
Definition PetDefines.h:37
@ PETSPELL_NORMAL
Definition PetDefines.h:38
SpellSchoolMask
Skyfire::AutoPtr< Transaction, Skyfire::Mutex > SQLTransaction
Definition Transaction.h:42
DeathState
Definition Unit.h:502
ActiveStates
Definition Unit.h:1144
@ ACT_DECIDE
Definition Unit.h:1151
#define UNORDERED_MAP
@ UNIT_FIELD_ANIM_TIER
Guardian(SummonPropertiesEntry const *properties, Unit *owner, bool isWorldObject)
Definition Map.h:238
uint8 GetByteValue(uint16 index, uint8 offset) const
Definition Object.cpp:343
void SetByteValue(uint16 index, uint8 offset, uint8 value)
Definition Object.cpp:1158
uint16 GetSpecialization() const
Definition Pet.h:108
void _SaveAuras(SQLTransaction &trans)
Definition Pet.cpp:1353
void LearnPetPassives()
Definition Pet.cpp:1949
PetType m_petType
Definition Pet.h:149
void RemoveFromWorld()
Definition Pet.cpp:75
void _LoadSpells()
Definition Pet.cpp:1214
void ResetAuraUpdateMaskForRaid()
Definition Pet.h:140
uint8 GetFreeTalentPoints() const
Definition Pet.h:133
void GivePetLevel(uint8 level)
Definition Pet.cpp:739
void SetDuration(int32 dur)
Definition Pet.h:75
bool m_loading
Definition Pet.h:152
void _SaveSpellCooldowns(SQLTransaction &trans)
Definition Pet.cpp:1188
Player * GetOwner() const
Definition Pet.cpp:2117
uint32 m_transportExitGraceTimer
Definition Pet.h:154
bool IsPetAura(Aura const *aura)
Definition Pet.cpp:2006
bool unlearnSpell(uint32 spell_id, bool learn_prev, bool clear_ab=true)
Definition Pet.cpp:1586
void UnlearnSpecializationSpells()
Definition Pet.cpp:2163
void AddToWorld()
Definition Pet.cpp:52
DeclinedName * m_declinedname
Definition Pet.h:156
void _LoadAuras(uint32 timediff)
Definition Pet.cpp:1280
uint32 m_usedTalentCount
Definition Pet.h:136
void Update(uint32 diff)
Definition Pet.cpp:541
void ToggleAutocast(SpellInfo const *spellInfo, bool apply)
Definition Pet.cpp:1852
virtual void ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs)
Definition Pet.cpp:2054
void ClearTransportExitGrace()
Definition Pet.h:58
void setDeathState(DeathState s)
Definition Pet.cpp:521
void _LoadSpellCooldowns()
Definition Pet.cpp:1118
uint32 GetPetAutoSpellOnPos(uint8 pos) const
Definition Pet.h:62
void StartTransportExitGrace(uint32 duration)
Definition Pet.cpp:86
void InitTalentForLevel()
Definition Pet.cpp:1828
void CastPetAuras(bool current)
Definition Pet.cpp:1970
void setPetType(PetType type)
Definition Pet.h:39
void SavePetToDB(PetSaveMode mode)
Definition Pet.cpp:365
void SetDisplayId(uint32 modelId)
Definition Pet.cpp:2122
PetType getPetType() const
Definition Pet.h:38
void SynchronizeLevelWithOwner()
Definition Pet.cpp:2030
uint8 GetPetAutoSpellSize() const
Definition Pet.h:61
uint32 m_regenTimer
Definition Pet.h:153
void learnSpellHighRank(uint32 spellid)
Definition Pet.cpp:2022
bool IsPermanentPetFor(Player *owner) const
Definition Pet.cpp:1899
bool HaveInDiet(ItemTemplate const *item) const
Definition Pet.cpp:1084
bool addSpell(uint32 spellId, ActiveStates active=ACT_DECIDE, PetSpellState state=PETSPELL_NEW, PetSpellType type=PETSPELL_NORMAL)
Definition Pet.cpp:1414
AutoSpellList m_autospells
Definition Pet.h:124
uint16 GetPetSpecByTalentTab(uint16 talenttab)
Definition Pet.cpp:2143
bool CreateBaseAtTamed(CreatureTemplate const *cinfo, Map *map)
Definition Pet.cpp:801
bool Create(uint32 guidlow, Map *map, uint32 Entry, uint32 pet_number)
Definition Pet.cpp:1922
uint64 GetAuraUpdateMaskForRaid() const
Definition Pet.h:138
bool CreateBaseAtCreatureInfo(CreatureTemplate const *cinfo, Unit *owner)
Definition Pet.cpp:788
bool LoadPetFromDB(Player *owner, uint32 petentry=0, uint32 petnumber=0, bool current=false)
Definition Pet.cpp:91
void SaveToDB(uint32, uint32)
Definition Pet.h:159
DeclinedName const * GetDeclinedNames() const
Definition Pet.h:142
bool removeSpell(uint32 spell_id, bool learn_prev, bool clear_ab=true)
Definition Pet.cpp:1601
void SetSpec(uint16 spec)
Definition Pet.cpp:2194
bool CreateBaseAtCreature(Creature *creature)
Definition Pet.cpp:755
void CleanupActionBar()
Definition Pet.cpp:1652
bool isTemporarySummoned() const
Definition Pet.h:41
void CastPetAura(PetAura const *aura)
Definition Pet.cpp:1991
int32 GetDuration() const
Definition Pet.h:76
bool isControlled() const
Definition Pet.cpp:2135
virtual ~Pet()
Definition Pet.cpp:47
bool HasTransportExitGrace() const
Definition Pet.h:59
void _SaveSpells(SQLTransaction &trans)
Definition Pet.cpp:1231
bool m_removed
Definition Pet.h:144
bool HasSpell(uint32 spell) const
Definition Pet.cpp:1942
void SetFreeTalentPoints(uint8 points)
Definition Pet.h:134
void Remove(PetSaveMode mode, bool returnreagent=false)
Definition Pet.cpp:697
uint8 GetMaxTalentPointsForLevel(uint8 level)
Definition Pet.cpp:1843
bool isBeingLoaded() const
Definition Pet.h:50
void InitPetCreateSpells()
Definition Pet.cpp:1668
void LearnSpecializationSpells()
Definition Pet.cpp:2178
uint64 m_auraRaidUpdateMask
Definition Pet.h:151
uint32 GetCurrentFoodBenefitLevel(uint32 itemlevel) const
Definition Pet.cpp:1102
static void resetTalentsForAllPetsOf(Player *owner, Pet *online_pet=NULL)
Definition Pet.cpp:1752
bool resetTalents()
Definition Pet.cpp:1679
PetSpellMap m_spells
Definition Pet.h:123
uint16 m_petSpec
Definition Pet.h:106
Pet(Player *owner, PetType type=PetType::MAX_PET_TYPE)
Definition Pet.cpp:27
void GivePetXP(uint32 xp)
Definition Pet.cpp:702
void SetAuraUpdateMaskForRaid(uint8 slot)
Definition Pet.h:139
bool learnSpell(uint32 spell_id)
Definition Pet.cpp:1528
int32 m_duration
Definition Pet.h:150
void InitLevelupSpellsForLevel()
Definition Pet.cpp:1544
void DeleteFromDB()
Definition Pet.h:163
Definition Unit.h:1367
Definition Pet.h:16
PetSpellState state
Definition Pet.h:18
PetSpellType type
Definition Pet.h:19
ActiveStates active
Definition Pet.h:17