feat(Core/Pets): Management refactoring (#9712)

* feat(Core/Pets): rework managment

* 1

* 2

* 3

* 4

* 5

* cs pet

* check before ressurect

* pet DECLINED_NAMES

* display

- https://github.com/azerothcore/azerothcore-wotlk/issues/9297

* ArenaSpectator

* 1
This commit is contained in:
Kargatum
2021-12-31 04:45:13 +07:00
committed by GitHub
parent 24ab99919a
commit e12494d993
24 changed files with 1173 additions and 1208 deletions

View File

@@ -18,17 +18,25 @@
#ifndef AZEROTHCORE_PET_DEFINES_H
#define AZEROTHCORE_PET_DEFINES_H
enum PetType
#include "Define.h"
#include "Optional.h"
#include <array>
#include <string>
#include <vector>
enum ReactStates : uint8;
enum PetType : uint8
{
SUMMON_PET = 0,
HUNTER_PET = 1,
MAX_PET_TYPE = 4
};
#define MAX_PET_STABLES 4
constexpr auto MAX_PET_STABLES = 4;
// stored in character_pet.slot
enum PetSaveMode
enum PetSaveMode : int8
{
PET_SAVE_AS_DELETED = -1, // not saved in fact
PET_SAVE_AS_CURRENT = 0, // in current slot (with player)
@@ -73,24 +81,6 @@ enum PetTalk
PET_TALK_ATTACK = 1
};
// used at pet loading query list preparing, and later result selection
enum PetLoadQueryIndex
{
PET_LOAD_QUERY_LOADAURAS = 0,
PET_LOAD_QUERY_LOADSPELLS = 1,
PET_LOAD_QUERY_LOADSPELLCOOLDOWN = 2,
MAX_PET_LOAD_QUERY,
};
enum PetLoadStage
{
PET_LOAD_DEFAULT = 0,
PET_LOAD_HANDLE_UNSTABLE_CALLBACK = 1, // used also in HandleStableSwapPetCallback, uses same error / ok messages
PET_LOAD_BG_RESURRECT = 2,
PET_LOAD_SUMMON_PET = 3,
PET_LOAD_SUMMON_DEAD_PET = 4
};
enum PetLoadState
{
PET_LOAD_OK = 0,
@@ -202,4 +192,39 @@ enum PetScalingSpells
#define PET_FOLLOW_DIST 1.0f
#define PET_FOLLOW_ANGLE (M_PI/2)
class PetStable
{
public:
struct PetInfo
{
PetInfo() { }
std::string Name;
std::string ActionBar;
uint32 PetNumber = 0;
uint32 CreatureId = 0;
uint32 DisplayId = 0;
uint32 Experience = 0;
uint32 Health = 0;
uint32 Mana = 0;
uint32 Happiness = 0;
uint32 LastSaveTime = 0;
uint32 CreatedBySpellId = 0;
uint8 Level = 0;
ReactStates ReactState = ReactStates(0);
PetType Type = MAX_PET_TYPE;
bool WasRenamed = false;
};
Optional<PetInfo> CurrentPet; // PET_SAVE_AS_CURRENT
std::array<Optional<PetInfo>, MAX_PET_STABLES> StabledPets; // PET_SAVE_FIRST_STABLE_SLOT - PET_SAVE_LAST_STABLE_SLOT
uint32 MaxStabledPets = 0;
std::vector<PetInfo> UnslottedPets; // PET_SAVE_NOT_IN_SLOT
PetInfo const* GetUnslottedHunterPet() const
{
return UnslottedPets.size() == 1 && UnslottedPets[0].Type == HUNTER_PET ? &UnslottedPets[0] : nullptr;
}
};
#endif