TrinityCore
Loading...
Searching...
No Matches
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
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
67
75
82
84{
85 None = 0,
86 Dead = 1,
87 NoTarget = 2,
88 InvalidTarget = 3,
89 NoPath = 4
90};
91
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 MaxSlots = 0,
123 InsufficientFunds = 1, // "you don't have enough money"
124 NotStableMaster = 2,
125 InvalidSlot = 3, // "That slot is locked"
126 NoPet = 4,
127 AlreadyStabled = 5,
128 AlreadySummoned = 6,
129 NotFound = 7,
130 StableSuccess = 8, // stable success
131 UnstableSuccess = 9, // unstable/swap success
132 ReviveSuccess = 10,
133 CantControlExotic = 11, // "you are unable to control exotic creatures"
134 InternalError = 12, // "Internal pet error"
135 CheckForLuaHack = 13,
136 BuySlotSuccess = 14,
137 FavoriteToggle = 15,
138 PetRenamed = 16
139};
140
141constexpr uint32 CALL_PET_SPELL_ID = 883;
143
145{
146public:
167
168 Optional<uint32> CurrentPetIndex; // index into ActivePets or UnslottedPets if highest bit is set
169 std::array<Optional<PetInfo>, MAX_ACTIVE_PETS> ActivePets; // PET_SAVE_FIRST_ACTIVE_SLOT - PET_SAVE_LAST_ACTIVE_SLOT
170 std::array<Optional<PetInfo>, MAX_PET_STABLES> StabledPets; // PET_SAVE_FIRST_STABLE_SLOT - PET_SAVE_LAST_STABLE_SLOT
171 std::vector<PetInfo> UnslottedPets; // PET_SAVE_NOT_IN_SLOT
172
173 PetInfo* GetCurrentPet() { return const_cast<PetInfo*>(const_cast<PetStable const*>(this)->GetCurrentPet()); }
174 PetInfo const* GetCurrentPet() const
175 {
176 if (!CurrentPetIndex)
177 return nullptr;
178
179 if (Optional<uint32> activePetIndex = GetCurrentActivePetIndex())
180 return ActivePets[*activePetIndex] ? &ActivePets[*activePetIndex].value() : nullptr;
181
182 if (Optional<uint32> unslottedPetIndex = GetCurrentUnslottedPetIndex())
183 return *unslottedPetIndex < UnslottedPets.size() ? &UnslottedPets[*unslottedPetIndex] : nullptr;
184
185 return nullptr;
186 }
187
192
193private:
194 static constexpr uint32 UnslottedPetIndexMask = 0x80000000;
195};
196
197#endif
uint8_t uint8
Definition Define.h:156
int16_t int16
Definition Define.h:151
uint16_t uint16
Definition Define.h:155
uint32_t uint32
Definition Define.h:154
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:141
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:142
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
Optional< uint32 > GetCurrentActivePetIndex() const
Definition PetDefines.h:188
std::array< Optional< PetInfo >, MAX_ACTIVE_PETS > ActivePets
Definition PetDefines.h:169
void SetCurrentUnslottedPetIndex(uint32 index)
Definition PetDefines.h:191
Optional< uint32 > GetCurrentUnslottedPetIndex() const
Definition PetDefines.h:190
PetInfo const * GetCurrentPet() const
Definition PetDefines.h:174
std::array< Optional< PetInfo >, MAX_PET_STABLES > StabledPets
Definition PetDefines.h:170
std::vector< PetInfo > UnslottedPets
Definition PetDefines.h:171
PetInfo * GetCurrentPet()
Definition PetDefines.h:173
Optional< uint32 > CurrentPetIndex
Definition PetDefines.h:168
void SetCurrentActivePetIndex(uint32 index)
Definition PetDefines.h:189
static constexpr uint32 UnslottedPetIndexMask
Definition PetDefines.h:194
ReactStates ReactState
Definition PetDefines.h:163
std::string Name
Definition PetDefines.h:151
std::string ActionBar
Definition PetDefines.h:152