mirror of
https://github.com/liyunfan1223/azerothcore-wotlk.git
synced 2026-08-08 15:58:04 +00:00
fix(Core/Pets): Add option to revive pets with full mana (#19383)
* fix(Scripts/Spells): Revive pets with full mana in bgs * Pets were incorrectly revived without restoring its mana * Closes #15894 * ready for merge --------- Co-authored-by: Saqra1 <> Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>
This commit is contained in:
@@ -211,7 +211,7 @@ std::pair<PetStable::PetInfo const*, PetSaveMode> Pet::GetLoadPetInfo(PetStable
|
|||||||
return { nullptr, PET_SAVE_AS_DELETED };
|
return { nullptr, PET_SAVE_AS_DELETED };
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool current, uint32 healthPct /*= 0*/)
|
bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool current, uint32 healthPct /*= 0*/, bool fullMana /*= false*/)
|
||||||
{
|
{
|
||||||
m_loading = true;
|
m_loading = true;
|
||||||
|
|
||||||
@@ -418,7 +418,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool c
|
|||||||
owner->ToPlayer()->SetLastPetNumber(petInfo->PetNumber);
|
owner->ToPlayer()->SetLastPetNumber(petInfo->PetNumber);
|
||||||
|
|
||||||
owner->GetSession()->AddQueryHolderCallback(CharacterDatabase.DelayQueryHolder(std::make_shared<PetLoadQueryHolder>(ownerid, petInfo->PetNumber)))
|
owner->GetSession()->AddQueryHolderCallback(CharacterDatabase.DelayQueryHolder(std::make_shared<PetLoadQueryHolder>(ownerid, petInfo->PetNumber)))
|
||||||
.AfterComplete([this, owner, session = owner->GetSession(), isTemporarySummon, current, lastSaveTime = petInfo->LastSaveTime, savedhealth = petInfo->Health, savedmana = petInfo->Mana, healthPct]
|
.AfterComplete([this, owner, session = owner->GetSession(), isTemporarySummon, current, lastSaveTime = petInfo->LastSaveTime, savedhealth = petInfo->Health, savedmana = petInfo->Mana, healthPct, fullMana]
|
||||||
(SQLQueryHolderBase const& holder)
|
(SQLQueryHolderBase const& holder)
|
||||||
{
|
{
|
||||||
if (session->GetPlayer() != owner || owner->GetPet() != this)
|
if (session->GetPlayer() != owner || owner->GetPet() != this)
|
||||||
@@ -474,6 +474,10 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool c
|
|||||||
curHealth = CountPctFromMaxHealth(healthPct);
|
curHealth = CountPctFromMaxHealth(healthPct);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32 curMana = savedmana;
|
||||||
|
if (fullMana)
|
||||||
|
curMana = GetMaxPower(POWER_MANA);
|
||||||
|
|
||||||
if (getPetType() == SUMMON_PET && !current) //all (?) summon pets come with full health when called, but not when they are current
|
if (getPetType() == SUMMON_PET && !current) //all (?) summon pets come with full health when called, but not when they are current
|
||||||
{
|
{
|
||||||
SetPower(POWER_MANA, GetMaxPower(POWER_MANA));
|
SetPower(POWER_MANA, GetMaxPower(POWER_MANA));
|
||||||
@@ -486,7 +490,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool c
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetHealth(curHealth > GetMaxHealth() ? GetMaxHealth() : curHealth);
|
SetHealth(curHealth > GetMaxHealth() ? GetMaxHealth() : curHealth);
|
||||||
SetPower(POWER_MANA, savedmana > GetMaxPower(POWER_MANA) ? GetMaxPower(POWER_MANA) : savedmana);
|
SetPower(POWER_MANA, curMana > GetMaxPower(POWER_MANA) ? GetMaxPower(POWER_MANA) : curMana);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public:
|
|||||||
bool CreateBaseAtCreatureInfo(CreatureTemplate const* cinfo, Unit* owner);
|
bool CreateBaseAtCreatureInfo(CreatureTemplate const* cinfo, Unit* owner);
|
||||||
bool CreateBaseAtTamed(CreatureTemplate const* cinfo, Map* map, uint32 phaseMask);
|
bool CreateBaseAtTamed(CreatureTemplate const* cinfo, Map* map, uint32 phaseMask);
|
||||||
static std::pair<PetStable::PetInfo const*, PetSaveMode> GetLoadPetInfo(PetStable const& stable, uint32 petEntry, uint32 petnumber, bool current);
|
static std::pair<PetStable::PetInfo const*, PetSaveMode> GetLoadPetInfo(PetStable const& stable, uint32 petEntry, uint32 petnumber, bool current);
|
||||||
bool LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool current, uint32 healthPct = 0);
|
bool LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool current, uint32 healthPct = 0, bool fullMana = false);
|
||||||
bool isBeingLoaded() const override { return m_loading; }
|
bool isBeingLoaded() const override { return m_loading; }
|
||||||
void SavePetToDB(PetSaveMode mode);
|
void SavePetToDB(PetSaveMode mode);
|
||||||
void FillPetInfo(PetStable::PetInfo* petInfo) const;
|
void FillPetInfo(PetStable::PetInfo* petInfo) const;
|
||||||
|
|||||||
@@ -1702,10 +1702,8 @@ class spell_gen_pet_summoned : public SpellScript
|
|||||||
{
|
{
|
||||||
PetType newPetType = (player->IsClass(CLASS_HUNTER, CLASS_CONTEXT_PET)) ? HUNTER_PET : SUMMON_PET;
|
PetType newPetType = (player->IsClass(CLASS_HUNTER, CLASS_CONTEXT_PET)) ? HUNTER_PET : SUMMON_PET;
|
||||||
Pet* newPet = new Pet(player, newPetType);
|
Pet* newPet = new Pet(player, newPetType);
|
||||||
if (newPet->LoadPetFromDB(player, 0, player->GetLastPetNumber(), true, 100))
|
if (newPet->LoadPetFromDB(player, 0, player->GetLastPetNumber(), true, 100, true))
|
||||||
{
|
{
|
||||||
newPet->SetPower(newPet->getPowerType(), newPet->GetMaxPower(newPet->getPowerType()));
|
|
||||||
|
|
||||||
switch (newPet->GetEntry())
|
switch (newPet->GetEntry())
|
||||||
{
|
{
|
||||||
case NPC_DOOMGUARD:
|
case NPC_DOOMGUARD:
|
||||||
|
|||||||
Reference in New Issue
Block a user