TrinityCore
PetDefines.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef TRINITYCORE_PET_DEFINES_H
19#define TRINITYCORE_PET_DEFINES_H
20
21#include "Define.h"
22#include "Optional.h"
23#include <array>
24#include <string>
25#include <vector>
26
27enum ReactStates : uint8;
28
30{
33 MAX_PET_TYPE = 4
34};
35
36#define MAX_ACTIVE_PETS 5
37#define MAX_PET_STABLES 200
38
39// stored in character_pet.slot
41{
42 PET_SAVE_AS_DELETED = -2, // not saved in fact
43 PET_SAVE_AS_CURRENT = -3, // in current slot (with player)
48 PET_SAVE_NOT_IN_SLOT = -1 // for avoid conflict with stable size grow will use negative value
49};
50
51constexpr bool IsActivePetSlot(PetSaveMode slot)
52{
54}
55
56constexpr bool IsStabledPetSlot(PetSaveMode slot)
57{
59}
60
62{
65};
66
68{
73};
74
76{
80};
81
83{
84 None = 0,
85 Dead = 1,
86 NoTarget = 2,
87 InvalidTarget = 3,
88 NoPath = 4
89};
90
92{
95};
96
97#define PET_FOLLOW_DIST 1.0f
98#define PET_FOLLOW_ANGLE float(M_PI)
99
101{
102 Ok = 0,
103 InvalidCreature = 1,
104 TooMany = 2,
106 NotTameable = 4,
108 UnitsCantTame = 6,
109 NoPetAvailable = 7,
110 InternalError = 8,
111 TooHighLevel = 9,
112 Dead = 10,
113 NotDead = 11,
115 InvalidSlot = 13,
117};
118
119enum class StableResult : uint8
120{
121 NotEnoughMoney = 1, // "you don't have enough money"
122 InvalidSlot = 3, // "That slot is locked"
123 StableSuccess = 8, // stable success
124 UnstableSuccess = 9, // unstable/swap success
125 BuySlotSuccess = 10, // buy slot success
126 CantControlExotic = 11, // "you are unable to control exotic creatures"
127 InternalError = 12, // "Internal pet error"
128};
129
130constexpr uint32 CALL_PET_SPELL_ID = 883;
132
134{
135public:
136 struct PetInfo
137 {
139
140 std::string Name;
141 std::string ActionBar;
154 bool WasRenamed = false;
155 };
156
157 Optional<uint32> CurrentPetIndex; // index into ActivePets or UnslottedPets if highest bit is set
158 std::array<Optional<PetInfo>, MAX_ACTIVE_PETS> ActivePets; // PET_SAVE_FIRST_ACTIVE_SLOT - PET_SAVE_LAST_ACTIVE_SLOT
159 std::array<Optional<PetInfo>, MAX_PET_STABLES> StabledPets; // PET_SAVE_FIRST_STABLE_SLOT - PET_SAVE_LAST_STABLE_SLOT
160 std::vector<PetInfo> UnslottedPets; // PET_SAVE_NOT_IN_SLOT
161
162 PetInfo* GetCurrentPet() { return const_cast<PetInfo*>(const_cast<PetStable const*>(this)->GetCurrentPet()); }
163 PetInfo const* GetCurrentPet() const
164 {
165 if (!CurrentPetIndex)
166 return nullptr;
167
168 if (Optional<uint32> activePetIndex = GetCurrentActivePetIndex())
169 return ActivePets[*activePetIndex] ? &ActivePets[*activePetIndex].value() : nullptr;
170
171 if (Optional<uint32> unslottedPetIndex = GetCurrentUnslottedPetIndex())
172 return *unslottedPetIndex < UnslottedPets.size() ? &UnslottedPets[*unslottedPetIndex] : nullptr;
173
174 return nullptr;
175 }
176
181
182private:
183 static constexpr uint32 UnslottedPetIndexMask = 0x80000000;
184};
185
186#endif
uint8_t uint8
Definition: Define.h:144
int16_t int16
Definition: Define.h:139
uint16_t uint16
Definition: Define.h:143
uint32_t uint32
Definition: Define.h:142
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition: Optional.h:25
#define MAX_ACTIVE_PETS
Definition: PetDefines.h:36
StableResult
Definition: PetDefines.h:120
PetSpellState
Definition: PetDefines.h:68
@ PETSPELL_NEW
Definition: PetDefines.h:71
@ PETSPELL_UNCHANGED
Definition: PetDefines.h:69
@ PETSPELL_CHANGED
Definition: PetDefines.h:70
@ PETSPELL_REMOVED
Definition: PetDefines.h:72
#define MAX_PET_STABLES
Definition: PetDefines.h:37
constexpr bool IsStabledPetSlot(PetSaveMode slot)
Definition: PetDefines.h:56
PetActionFeedback
Definition: PetDefines.h:83
PetTameResult
Definition: PetDefines.h:101
constexpr bool IsActivePetSlot(PetSaveMode slot)
Definition: PetDefines.h:51
PetType
Definition: PetDefines.h:30
@ SUMMON_PET
Definition: PetDefines.h:31
@ HUNTER_PET
Definition: PetDefines.h:32
@ MAX_PET_TYPE
Definition: PetDefines.h:33
PetTalk
Definition: PetDefines.h:92
@ PET_TALK_SPECIAL_SPELL
Definition: PetDefines.h:93
@ PET_TALK_ATTACK
Definition: PetDefines.h:94
PetSpellType
Definition: PetDefines.h:76
@ PETSPELL_TALENT
Definition: PetDefines.h:79
@ PETSPELL_NORMAL
Definition: PetDefines.h:77
@ PETSPELL_FAMILY
Definition: PetDefines.h:78
constexpr uint32 CALL_PET_SPELL_ID
Definition: PetDefines.h:130
PetStableFlags
Definition: PetDefines.h:62
@ PET_STABLE_INACTIVE
Definition: PetDefines.h:64
@ PET_STABLE_ACTIVE
Definition: PetDefines.h:63
constexpr uint32 PET_SUMMONING_DISORIENTATION
Definition: PetDefines.h:131
PetSaveMode
Definition: PetDefines.h:41
@ PET_SAVE_FIRST_STABLE_SLOT
Definition: PetDefines.h:46
@ PET_SAVE_LAST_STABLE_SLOT
Definition: PetDefines.h:47
@ PET_SAVE_LAST_ACTIVE_SLOT
Definition: PetDefines.h:45
@ PET_SAVE_FIRST_ACTIVE_SLOT
Definition: PetDefines.h:44
@ PET_SAVE_AS_DELETED
Definition: PetDefines.h:42
@ PET_SAVE_NOT_IN_SLOT
Definition: PetDefines.h:48
@ PET_SAVE_AS_CURRENT
Definition: PetDefines.h:43
ReactStates
Definition: UnitDefines.h:505
Optional< uint32 > GetCurrentActivePetIndex() const
Definition: PetDefines.h:177
std::array< Optional< PetInfo >, MAX_ACTIVE_PETS > ActivePets
Definition: PetDefines.h:158
void SetCurrentUnslottedPetIndex(uint32 index)
Definition: PetDefines.h:180
Optional< uint32 > GetCurrentUnslottedPetIndex() const
Definition: PetDefines.h:179
PetInfo const * GetCurrentPet() const
Definition: PetDefines.h:163
std::array< Optional< PetInfo >, MAX_PET_STABLES > StabledPets
Definition: PetDefines.h:159
std::vector< PetInfo > UnslottedPets
Definition: PetDefines.h:160
PetInfo * GetCurrentPet()
Definition: PetDefines.h:162
Optional< uint32 > CurrentPetIndex
Definition: PetDefines.h:157
void SetCurrentActivePetIndex(uint32 index)
Definition: PetDefines.h:178
static constexpr uint32 UnslottedPetIndexMask
Definition: PetDefines.h:183
uint32 CreatedBySpellId
Definition: PetDefines.h:149
ReactStates ReactState
Definition: PetDefines.h:152
std::string Name
Definition: PetDefines.h:140
uint16 SpecializationId
Definition: PetDefines.h:150
std::string ActionBar
Definition: PetDefines.h:141