Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
BattlePetMgr.h
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6#ifndef BATTLE_PET_MGR_H
7#define BATTLE_PET_MGR_H
8
9#include "BattlePet.h"
11#include "Common.h"
12#include "TemporarySummon.h"
13
14#include <vector>
15
16typedef std::set<BattlePet*> BattlePetSet;
17
18class Player;
19class Creature;
20
21#define BATTLE_PET_MAX_JOURNAL_SPECIES 3 // client modifications required to increase
22#define BATTLE_PET_MAX_JOURNAL_PETS 500 // sent to client as 25 bits (theoretical max 33,554,431)
23#define BATTLE_PET_MAX_LOADOUT_SLOTS 3
24
32
33// custom flags used in 'account_battle_pet_slots' db table
45
53
59
66
83
85{
86 switch (achievementId)
87 {
92 default:
94 }
95}
96
103
105{
106 struct BattlePetFinalRound;
108}
109
111{
112public:
116
118
119 Player* GetOwner() const { return m_owner; }
120 BattlePet* GetBattlePet(uint64 id) const;
122 uint8 GetBattlePetCount(uint16 speciesId) const;
123 std::string GetBattlePetSpeciesName(BattlePet const* battlePet) const;
124 std::vector<BattlePet*> FindBattlePetNameMatches(std::string const& name) const;
126
129 void SetCurrentSummonId(uint64 summonId) { m_summonId = summonId; }
130 void SetCurrentSummon(TempSummon* summon) { m_summon = summon; }
131
132 void UnSummonCurrentBattlePet(bool temporary);
134
135 void LoadFromDb(PreparedQueryResult result);
137 void SaveToDb();
138 void SaveToDb(SQLTransaction& trans);
139 void SaveSlotsToDb(SQLTransaction& trans);
140
141 void UnlockLoadoutSlot(uint8 slot);
142 bool HasLoadoutSlot(uint8 slot) const;
143 bool HasLoadoutBattlePet() const;
145 uint64 GetLoadoutSlot(uint8 slot) const;
146 void SetLoadoutSlot(uint8 slot, uint64 id, bool save = false);
147
148 bool HasLoadoutFlag(uint8 flag) const { return (m_loadoutFlags & flag) != 0; };
150 void SetLoadoutFlag(uint8 flag);
151 uint32 GetTrapAbility() const;
152 void OnAchievementEarned(uint32 achievementId);
153
154 BattlePet* Create(uint16 speciesId);
155 BattlePet* Create(uint16 speciesId, uint8 level, uint8 quality, bool notification = true);
156 BattlePet* Create(uint16 speciesId, uint8 level, uint8 quality, uint8 breed, bool notification = true);
157 bool CanCreateBattlePet(uint16 speciesId) const;
158 void Delete(BattlePet* battlePet);
159 void HealBattlePets(uint8 percent);
160 void StartWildPetBattle(uint64 enemyGuid, uint64 allyPetId, uint32 allyMaxHealth, uint32 allyHealth,
161 uint64 enemyPetId, uint32 enemyMaxHealth, uint32 enemyHealth,
162 uint16 enemySpecies = 0, uint8 enemyLevel = 0, uint8 enemyQuality = 0,
163 uint8 enemyBreed = 0, uint8 allyFrontPet = 0);
164 void StartPvpPetBattle(uint64 opponentGuid, uint64 allyPetId, uint32 allyMaxHealth, uint32 allyHealth,
165 uint64 enemyPetId, uint32 enemyMaxHealth, uint32 enemyHealth,
166 uint16 enemySpecies = 0, uint8 enemyLevel = 0, uint8 enemyQuality = 0,
167 uint8 allyFrontPet = 0, uint8 enemyFrontPet = 3,
174 void ApplyActivePetBattlePlayerState(float faceX, float faceY);
176 bool HasActivePetBattle() const { return m_activePetBattle.IsActive(); }
178 void SetPetBattlePvpQueued(bool queued) { m_petBattlePvpQueued = queued; }
181 bool SetActivePetBattleAllyPet(uint8 petIndex, uint64 petId, uint32 maxHealth, uint32 health);
183 bool ApplyEnemyBattlePetDamage(uint32 damage, uint32 abilityEffectId,
185 bool ApplyBattlePetAbilityInput(uint32 roundId, uint32 damage, uint32 abilityEffectId,
186 uint8 abilitySlot, uint32 abilityId, uint16 abilityCooldown,
190 uint32 allyDamage, uint32 allyAbilityEffectId,
191 uint8 allyAbilitySlot, uint32 allyAbilityId, uint16 allyAbilityCooldown,
192 uint32 enemyDamage, uint32 enemyAbilityEffectId,
193 uint32 allyIncomingDamageReduction, uint8 allyIncomingDamageReductionRounds,
194 uint32 enemyIncomingDamageReduction, uint8 enemyIncomingDamageReductionRounds,
197 bool ApplyBattlePetSwapInput(uint32 roundId, uint8 newFrontPet,
200 bool ApplyBattlePetTrapInput(uint32 roundId, uint32 trapAbilityEffectId,
201 uint32 enemyDamage, uint32 enemyAbilityEffectId,
204 void FinishActivePetBattle(uint8 winner);
206 bool captured = false);
208 uint16 speciesId, uint8 quality, bool won, bool captured) const;
209
213 void SendBattlePetSlotUpdate(uint8 slot, bool notification, uint64 id = 0);
214 void SendBattlePetUpdate(BattlePet* battlePet, bool notification);
216 void UpdateBattlePetLevelAchievement(BattlePet const& battlePet, uint8 initialLevel, uint8 finalLevel);
217
218private:
219 bool ApplyAchievementLoadoutReward(uint32 achievementId);
226 uint16 RewardActivePetBattlePet(BattlePet* battlePet, bool awardExperience);
228 void UpdateBattlePetCollectionAchievements(BattlePet const* battlePet = NULL);
229 void UpdateCapturedBattlePetAchievements(BattlePet const& battlePet);
231
234
238
247};
248
250{
258 uint32 LocationResult; // name dumped from client, use unknown
259
260 G3D::Vector3 Origin;
261 G3D::Vector3 Positions[2];
263
264 // Data for creation of pet battle
268};
269
270
271#endif
BattlePetAchievementSource
Definition BattlePet.h:19
@ BATTLE_PET_ACHIEVEMENT_SOURCE_PVP_DUEL
Definition BattlePet.h:21
PetBattleRequestFailedReason
@ PET_BATTLE_REQUEST_FAILED_INVALID_TARGET
@ PET_BATTLE_REQUEST_FAILED_NO_PETS
@ PET_BATTLE_REQUEST_FAILED_ALL_PETS_DEAD
uint8 BattlePetLoadoutSlotForAchievement(uint32 achievementId)
BattlePetTrapAbilities
@ BATTLE_PET_ABILITY_STRONG_TRAP
@ BATTLE_PET_ABILITY_GM_TRAP
@ BATTLE_PET_ABILITY_TRAP
@ BATTLE_PET_ABILITY_PRISTINE_TRAP
BattlePetSpells
@ SPELL_REVIVE_BATTLE_PETS
@ SPELL_BATTLE_PET_TRAINING_PASSIVE
@ SPELL_TRACK_PETS
BattlePetAchievementIds
@ BATTLE_PET_ACHIEVEMENT_JUST_A_PUP
@ BATTLE_PET_ACHIEVEMENT_NEWBIE
#define BATTLE_PET_MAX_LOADOUT_SLOTS
BattlePetLoadoutSlots
@ BATTLE_PET_LOADOUT_SLOT_NONE
@ BATTLE_PET_LOADOUT_SLOT_1
@ BATTLE_PET_LOADOUT_SLOT_3
@ BATTLE_PET_LOADOUT_SLOT_2
std::set< BattlePet * > BattlePetSet
BattlePetLoadoutFlags
@ BATTLE_PET_LOADOUT_SLOT_FLAG_SLOT_1
@ BATTLE_PET_LOADOUT_SLOT_FLAG_SLOT_2
@ BATTLE_PET_LOADOUT_SLOT_FLAG_SLOT_3
@ BATTLE_PET_LOADOUT_STRONG_TRAP
@ BATTLE_PET_LOADOUT_PRISTINE_TRAP
@ BATTLE_PET_LOADOUT_SLOT_FLAG_NONE
@ BATTLE_PET_LOADOUT_GM_TRAP
@ BATTLE_PET_LOADOUT_TRAP
uint32 BattlePetTrapAbilityForLoadoutFlags(uint8 flags)
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
std::uint64_t uint64
Definition Define.h:76
std::uint16_t uint16
Definition Define.h:78
Skyfire::AutoPtr< PreparedResultSet, Skyfire::Mutex > PreparedQueryResult
Definition QueryResult.h:94
Skyfire::AutoPtr< Transaction, Skyfire::Mutex > SQLTransaction
Definition Transaction.h:42
bool SetActivePetBattleAllyPet(uint8 petIndex, uint64 petId, uint32 maxHealth, uint32 health)
void ClearActivePetBattleWorldObjectState()
uint8 GetLoadoutFlags() const
bool IsPetBattlePvpQueued() const
uint16 RewardActivePetBattlePet(BattlePet *battlePet, bool awardExperience)
void OnAchievementEarned(uint32 achievementId)
TempSummon * GetCurrentSummon() const
void StartPvpPetBattle(uint64 opponentGuid, uint64 allyPetId, uint32 allyMaxHealth, uint32 allyHealth, uint64 enemyPetId, uint32 enemyMaxHealth, uint32 enemyHealth, uint16 enemySpecies=0, uint8 enemyLevel=0, uint8 enemyQuality=0, uint8 allyFrontPet=0, uint8 enemyFrontPet=3, BattlePetAchievementSource source=BATTLE_PET_ACHIEVEMENT_SOURCE_PVP_DUEL)
bool ApplyBattlePetAbilityInput(uint32 roundId, uint32 damage, uint32 abilityEffectId, uint8 abilitySlot, uint32 abilityId, uint16 abilityCooldown, Skyfire::BattlePetPackets::BattlePetRoundResult &round, Skyfire::BattlePetPackets::BattlePetFinalRound *finalRound=NULL)
uint8 GetActivePetBattleTrapStatus() const
void ClearActivePetBattlePlayerState()
uint32 GetTrapAbility() const
void HideActivePetBattleWorldObject(Creature *creature)
uint32 GetBattlePetCount() const
void SetLoadoutFlag(uint8 flag)
void SetCurrentSummon(TempSummon *summon)
void SendBattlePetJournal()
void Delete(BattlePet *battlePet)
ActivePetBattle const & GetActivePetBattle() const
bool HasLoadoutFlag(uint8 flag) const
void ClearActivePetBattle()
BattlePet * GetFirstAliveLoadoutBattlePet() const
bool m_petBattlePvpQueued
void ResummonLastBattlePet()
void UpdateCapturedBattlePetAchievements(BattlePet const &battlePet)
bool ApplyBattlePetAbilityExchangeInput(uint32 roundId, uint32 allyDamage, uint32 allyAbilityEffectId, uint8 allyAbilitySlot, uint32 allyAbilityId, uint16 allyAbilityCooldown, uint32 enemyDamage, uint32 enemyAbilityEffectId, uint32 allyIncomingDamageReduction, uint8 allyIncomingDamageReductionRounds, uint32 enemyIncomingDamageReduction, uint8 enemyIncomingDamageReductionRounds, Skyfire::BattlePetPackets::BattlePetRoundResult &round, Skyfire::BattlePetPackets::BattlePetFinalRound *finalRound=NULL)
void PersistActivePetBattleHealth()
void SyncAchievementLoadoutRewards()
std::string GetBattlePetSpeciesName(BattlePet const *battlePet) const
uint64 m_activePetBattleWorldObjectGuid
void SendBattlePetSlotUpdate(uint8 slot, bool notification, uint64 id=0)
uint32 GetUniqueBattlePetSpeciesCount() const
bool m_activePetBattleWorldObjectHidden
void UpdateFinishedPetBattleAchievements()
void FinishActivePetBattle(uint8 winner)
uint8 m_loadoutFlags
bool ApplyBattlePetTrapInput(uint32 roundId, uint32 trapAbilityEffectId, uint32 enemyDamage, uint32 enemyAbilityEffectId, Skyfire::BattlePetPackets::BattlePetRoundResult &round, Skyfire::BattlePetPackets::BattlePetFinalRound &finalRound)
BattlePet * Create(uint16 speciesId)
BattlePetSet m_battlePetSet
void SetCurrentSummonId(uint64 summonId)
uint64 m_loadout[BATTLE_PET_MAX_LOADOUT_SLOTS]
bool ApplyEnemyBattlePetDamage(uint32 damage, uint32 abilityEffectId, Skyfire::BattlePetPackets::BattlePetRoundResult &round)
bool ApplyBattlePetSwapInput(uint32 roundId, uint8 newFrontPet, Skyfire::BattlePetPackets::BattlePetRoundResult &round)
void SendBattlePetJournalLock()
ActivePetBattle m_activePetBattle
bool ApplyAchievementLoadoutReward(uint32 achievementId)
void LoadSlotsFromDb(PreparedQueryResult result)
uint64 GetLoadoutSlot(uint8 slot) const
uint64 GetCurrentSummonId() const
BattlePetAchievementContext BuildActivePetBattleAchievementContext(uint16 speciesId, uint8 quality, bool won, bool captured) const
uint8 GetLoadoutSlotForBattlePet(uint64 id) const
Player * GetOwner() const
bool HasLoadoutSlot(uint8 slot) const
void ApplyActivePetBattleRoundState(Skyfire::BattlePetPackets::BattlePetRoundResult &round) const
uint64 m_summonLastId
void LoadFromDb(PreparedQueryResult result)
BattlePetMgr(Player *owner)
void StartWildPetBattle(uint64 enemyGuid, uint64 allyPetId, uint32 allyMaxHealth, uint32 allyHealth, uint64 enemyPetId, uint32 enemyMaxHealth, uint32 enemyHealth, uint16 enemySpecies=0, uint8 enemyLevel=0, uint8 enemyQuality=0, uint8 enemyBreed=0, uint8 allyFrontPet=0)
void DespawnResolvedWildPetBattleWorldObject()
void SetPetBattlePvpQueued(bool queued)
bool ApplyBattlePetForfeitInput(uint32 roundId, Skyfire::BattlePetPackets::BattlePetFinalRound &finalRound)
void SaveSlotsToDb(SQLTransaction &trans)
BattlePet * GetBattlePet(uint64 id) const
void UpdateBattlePetLevelAchievement(BattlePet const &battlePet, uint8 initialLevel, uint8 finalLevel)
void SetLoadoutSlot(uint8 slot, uint64 id, bool save=false)
void SendBattlePetUpdate(BattlePet *battlePet, bool notification)
bool BuildActivePetBattleFinalRound(bool abandoned, Skyfire::BattlePetPackets::BattlePetFinalRound &finalRound, bool captured=false)
Player * m_owner
bool CanCreateBattlePet(uint16 speciesId) const
TempSummon * m_summon
void SendBattlePetDeleted(uint64 id)
bool m_activePetBattlePlayerStateApplied
void UnSummonCurrentBattlePet(bool temporary)
void ApplyActivePetBattlePlayerState(float faceX, float faceY)
void SendPetBattleRequestFailed(uint8 reason)
std::vector< BattlePet * > FindBattlePetNameMatches(std::string const &name) const
bool HasActivePetBattle() const
bool ShouldHideActivePetBattleWorldObject(uint64 guid) const
void HealBattlePets(uint8 percent)
bool HasLoadoutBattlePet() const
void UpdateBattlePetCollectionAchievements(BattlePet const *battlePet=NULL)
uint64 m_summonId
bool SelectActivePetBattleFrontPet(uint8 frontPet)
void UnlockLoadoutSlot(uint8 slot)
Definition Unit.h:1367
G3D::Vector3 Origin
PetBattleType Type
G3D::Vector3 Positions[2]