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{
66};
67
69{
74};
75
77{
81};
82
84{
85 None = 0,
86 Dead = 1,
87 NoTarget = 2,
88 InvalidTarget = 3,
89 NoPath = 4
90};
91
93{
96};
97
98#define PET_FOLLOW_DIST 1.0f
99#define PET_FOLLOW_ANGLE float(M_PI)
100
102{
103 Ok = 0,
104 InvalidCreature = 1,
105 TooMany = 2,
107 NotTameable = 4,
109 UnitsCantTame = 6,
110 NoPetAvailable = 7,
111 InternalError = 8,
112 TooHighLevel = 9,
113 Dead = 10,
114 NotDead = 11,
116 InvalidSlot = 13,
118};
119
120enum class StableResult : uint8
121{
122 NotEnoughMoney = 1, // "you don't have enough money"
123 InvalidSlot = 3, // "That slot is locked"
124 StableSuccess = 8, // stable success
125 UnstableSuccess = 9, // unstable/swap success
126 BuySlotSuccess = 10, // buy slot success
127 CantControlExotic = 11, // "you are unable to control exotic creatures"
128 InternalError = 12, // "Internal pet error"
129};
130
131constexpr uint32 CALL_PET_SPELL_ID = 883;
133
135{
136public:
137 struct PetInfo
138 {
140
141 std::string Name;
142 std::string ActionBar;
155 bool WasRenamed = false;
156 };
157
158 Optional<uint32> CurrentPetIndex; // index into ActivePets or UnslottedPets if highest bit is set
159 std::array<Optional<PetInfo>, MAX_ACTIVE_PETS> ActivePets; // PET_SAVE_FIRST_ACTIVE_SLOT - PET_SAVE_LAST_ACTIVE_SLOT
160 std::array<Optional<PetInfo>, MAX_PET_STABLES> StabledPets; // PET_SAVE_FIRST_STABLE_SLOT - PET_SAVE_LAST_STABLE_SLOT
161 std::vector<PetInfo> UnslottedPets; // PET_SAVE_NOT_IN_SLOT
162
163 PetInfo* GetCurrentPet() { return const_cast<PetInfo*>(const_cast<PetStable const*>(this)->GetCurrentPet()); }
164 PetInfo const* GetCurrentPet() const
165 {
166 if (!CurrentPetIndex)
167 return nullptr;
168
169 if (Optional<uint32> activePetIndex = GetCurrentActivePetIndex())
170 return ActivePets[*activePetIndex] ? &ActivePets[*activePetIndex].value() : nullptr;
171
172 if (Optional<uint32> unslottedPetIndex = GetCurrentUnslottedPetIndex())
173 return *unslottedPetIndex < UnslottedPets.size() ? &UnslottedPets[*unslottedPetIndex] : nullptr;
174
175 return nullptr;
176 }
177
182
183private:
184 static constexpr uint32 UnslottedPetIndexMask = 0x80000000;
185};
186
187#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:121
PetSpellState
Definition: PetDefines.h:69
@ PETSPELL_NEW
Definition: PetDefines.h:72
@ PETSPELL_UNCHANGED
Definition: PetDefines.h:70
@ PETSPELL_CHANGED
Definition: PetDefines.h:71
@ PETSPELL_REMOVED
Definition: PetDefines.h:73
#define MAX_PET_STABLES
Definition: PetDefines.h:37
constexpr bool IsStabledPetSlot(PetSaveMode slot)
Definition: PetDefines.h:56
PetActionFeedback
Definition: PetDefines.h:84
PetTameResult
Definition: PetDefines.h:102
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:93
@ PET_TALK_SPECIAL_SPELL
Definition: PetDefines.h:94
@ PET_TALK_ATTACK
Definition: PetDefines.h:95
PetSpellType
Definition: PetDefines.h:77
@ PETSPELL_TALENT
Definition: PetDefines.h:80
@ PETSPELL_NORMAL
Definition: PetDefines.h:78
@ PETSPELL_FAMILY
Definition: PetDefines.h:79
constexpr uint32 CALL_PET_SPELL_ID
Definition: PetDefines.h:131
PetStableFlags
Definition: PetDefines.h:62
@ PET_STABLE_INACTIVE
Definition: PetDefines.h:64
@ PET_STABLE_ACTIVE
Definition: PetDefines.h:63
@ PET_STABLE_FAVORITE
Definition: PetDefines.h:65
constexpr uint32 PET_SUMMONING_DISORIENTATION
Definition: PetDefines.h:132
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:536
Optional< uint32 > GetCurrentActivePetIndex() const
Definition: PetDefines.h:178
std::array< Optional< PetInfo >, MAX_ACTIVE_PETS > ActivePets
Definition: PetDefines.h:159
void SetCurrentUnslottedPetIndex(uint32 index)
Definition: PetDefines.h:181
Optional< uint32 > GetCurrentUnslottedPetIndex() const
Definition: PetDefines.h:180
PetInfo const * GetCurrentPet() const
Definition: PetDefines.h:164
std::array< Optional< PetInfo >, MAX_PET_STABLES > StabledPets
Definition: PetDefines.h:160
std::vector< PetInfo > UnslottedPets
Definition: PetDefines.h:161
PetInfo * GetCurrentPet()
Definition: PetDefines.h:163
Optional< uint32 > CurrentPetIndex
Definition: PetDefines.h:158
void SetCurrentActivePetIndex(uint32 index)
Definition: PetDefines.h:179
static constexpr uint32 UnslottedPetIndexMask
Definition: PetDefines.h:184
uint32 CreatedBySpellId
Definition: PetDefines.h:150
ReactStates ReactState
Definition: PetDefines.h:153
std::string Name
Definition: PetDefines.h:141
uint16 SpecializationId
Definition: PetDefines.h:151
std::string ActionBar
Definition: PetDefines.h:142