TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
BattlePetMgr::BattlePet Struct Reference

#include <BattlePetMgr.h>

Public Member Functions

void CalculateStats ()
 

Public Attributes

WorldPackets::BattlePet::BattlePet PacketInfo
 
BattlePetSaveInfo SaveInfo
 

Member Function Documentation

void BattlePetMgr::BattlePet::CalculateStats ( )
26 {
27  float health = 0.0f;
28  float power = 0.0f;
29  float speed = 0.0f;
30 
31  // get base breed stats
32  auto breedState = _battlePetBreedStates.find(PacketInfo.Breed);
33  if (breedState == _battlePetBreedStates.end()) // non existing breed id
34  return;
35 
36  health = breedState->second[STATE_STAT_STAMINA];
37  power = breedState->second[STATE_STAT_POWER];
38  speed = breedState->second[STATE_STAT_SPEED];
39 
40  // modify stats depending on species - not all pets have this
41  auto speciesState = _battlePetSpeciesStates.find(PacketInfo.Species);
42  if (speciesState != _battlePetSpeciesStates.end())
43  {
44  health += speciesState->second[STATE_STAT_STAMINA];
45  power += speciesState->second[STATE_STAT_POWER];
46  speed += speciesState->second[STATE_STAT_SPEED];
47  }
48 
49  // modify stats by quality
50  for (auto itr : sBattlePetBreedQualityStore)
51  {
52  if (itr->Quality == PacketInfo.Quality)
53  {
54  health *= itr->Modifier;
55  power *= itr->Modifier;
56  speed *= itr->Modifier;
57  break;
58  }
59  // TOOD: add check if pet has existing quality
60  }
61 
62  // scale stats depending on level
63  health *= PacketInfo.Level;
64  power *= PacketInfo.Level;
65  speed *= PacketInfo.Level;
66 
67  // set stats
68  // round, ceil or floor? verify this
69  PacketInfo.MaxHealth = uint32((round(health / 20) + 100));
70  PacketInfo.Power = uint32(round(power / 100));
71  PacketInfo.Speed = uint32(round(speed / 100));
72 }
Definition: BattlePetMgr.h:56
uint8 Quality
Definition: BattlePetPackets.h:43
WorldPackets::BattlePet::BattlePet PacketInfo
Definition: BattlePetMgr.h:90
Definition: BattlePetMgr.h:57
uint32 Speed
Definition: BattlePetPackets.h:42
double round(double f)
Definition: g3dmath.h:214
uint32 Power
Definition: BattlePetPackets.h:39
static std::unordered_map< uint32, std::unordered_map< BattlePetState, int32, std::hash< std::underlying_type< BattlePetState >::type > > > _battlePetSpeciesStates
Definition: BattlePetMgr.h:138
uint16 Level
Definition: BattlePetPackets.h:36
uint32 MaxHealth
Definition: BattlePetPackets.h:41
static std::unordered_map< uint16, std::unordered_map< BattlePetState, int32, std::hash< std::underlying_type< BattlePetState >::type > > > _battlePetBreedStates
Definition: BattlePetMgr.h:137
uint16 Breed
Definition: BattlePetPackets.h:35
uint32_t uint32
Definition: g3dmath.h:168
uint32 Species
Definition: BattlePetPackets.h:32
Definition: BattlePetMgr.h:58
DB2Storage< BattlePetBreedQualityEntry > sBattlePetBreedQualityStore("BattlePetBreedQuality.db2", BattlePetBreedQualityFormat, HOTFIX_SEL_BATTLE_PET_BREED_QUALITY)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

WorldPackets::BattlePet::BattlePet BattlePetMgr::BattlePet::PacketInfo
BattlePetSaveInfo BattlePetMgr::BattlePet::SaveInfo

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