TrinityCore
BattlePets::BattlePet Struct Reference

#include <BattlePetMgr.h>

Public Member Functions

void CalculateStats ()
 

Public Attributes

WorldPackets::BattlePet::BattlePet PacketInfo
 
time_t NameTimestamp = time_t(0)
 
std::unique_ptr<::DeclinedNameDeclinedName
 
BattlePetSaveInfo SaveInfo = BATTLE_PET_UNCHANGED
 

Member Function Documentation

◆ CalculateStats()

void BattlePets::BattlePet::CalculateStats ( )
48 {
49  float health = 0.0f;
50  float power = 0.0f;
51  float speed = 0.0f;
52 
53  // get base breed stats
54  auto breedState = _battlePetBreedStates.find(PacketInfo.Breed);
55  if (breedState == _battlePetBreedStates.end()) // non existing breed id
56  return;
57 
58  health = breedState->second[STATE_STAT_STAMINA];
59  power = breedState->second[STATE_STAT_POWER];
60  speed = breedState->second[STATE_STAT_SPEED];
61 
62  // modify stats depending on species - not all pets have this
63  auto speciesState = _battlePetSpeciesStates.find(PacketInfo.Species);
64  if (speciesState != _battlePetSpeciesStates.end())
65  {
66  health += speciesState->second[STATE_STAT_STAMINA];
67  power += speciesState->second[STATE_STAT_POWER];
68  speed += speciesState->second[STATE_STAT_SPEED];
69  }
70 
71  // modify stats by quality
72  for (BattlePetBreedQualityEntry const* battlePetBreedQuality : sBattlePetBreedQualityStore)
73  {
74  if (battlePetBreedQuality->QualityEnum == PacketInfo.Quality)
75  {
76  health *= battlePetBreedQuality->StateMultiplier;
77  power *= battlePetBreedQuality->StateMultiplier;
78  speed *= battlePetBreedQuality->StateMultiplier;
79  break;
80  }
81  // TOOD: add check if pet has existing quality
82  }
83 
84  // scale stats depending on level
85  health *= PacketInfo.Level;
86  power *= PacketInfo.Level;
87  speed *= PacketInfo.Level;
88 
89  // set stats
90  // round, ceil or floor? verify this
91  PacketInfo.MaxHealth = uint32((round(health / 20) + 100));
92  PacketInfo.Power = uint32(round(power / 100));
93  PacketInfo.Speed = uint32(round(speed / 100));
94 }
uint8 Quality
Definition: BattlePetPackets.h:53
Definition: BattlePetMgr.h:112
uint32 Speed
Definition: BattlePetPackets.h:52
WorldPackets::BattlePet::BattlePet PacketInfo
Definition: BattlePetMgr.h:141
Definition: BattlePetMgr.h:110
Definition: DB2Structure.h:453
uint32 Power
Definition: BattlePetPackets.h:49
uint16 Level
Definition: BattlePetPackets.h:46
DB2Storage< BattlePetBreedQualityEntry > sBattlePetBreedQualityStore("BattlePetBreedQuality.db2", BattlePetBreedQualityLoadInfo::Instance())
uint32_t uint32
Definition: Define.h:143
Definition: BattlePetMgr.h:111
uint32 MaxHealth
Definition: BattlePetPackets.h:51
uint16 Breed
Definition: BattlePetPackets.h:45
uint32 Species
Definition: BattlePetPackets.h:42
+ Here is the caller graph for this function:

Member Data Documentation

◆ DeclinedName

std::unique_ptr<::DeclinedName> BattlePets::BattlePet::DeclinedName

◆ NameTimestamp

time_t BattlePets::BattlePet::NameTimestamp = time_t(0)

◆ PacketInfo

WorldPackets::BattlePet::BattlePet BattlePets::BattlePet::PacketInfo

◆ SaveInfo

BattlePetSaveInfo BattlePets::BattlePet::SaveInfo = BATTLE_PET_UNCHANGED

The documentation for this struct was generated from the following files: