fix(Core/Spells): Fixed Revive Pet. (#10324)

Fixed #10267
This commit is contained in:
UltraNix
2022-01-24 01:19:52 +01:00
committed by GitHub
parent 22ec66566c
commit 1cbf52fb3d
5 changed files with 48 additions and 42 deletions

View File

@@ -202,7 +202,7 @@ std::pair<PetStable::PetInfo const*, PetSaveMode> Pet::GetLoadPetInfo(PetStable
return { nullptr, PET_SAVE_AS_DELETED };
}
bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool current)
bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool current, uint32 healthPct /*= 0*/)
{
m_loading = true;
@@ -408,7 +408,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool c
owner->ToPlayer()->SetLastPetNumber(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]
.AfterComplete([this, owner, session = owner->GetSession(), isTemporarySummon, current, lastSaveTime = petInfo->LastSaveTime, savedhealth = petInfo->Health, savedmana = petInfo->Mana, healthPct]
(SQLQueryHolderBase const& holder)
{
if (session->GetPlayer() != owner || owner->GetPet() != this)
@@ -458,6 +458,12 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool c
}
}
uint32 curHealth = savedhealth;
if (healthPct)
{
curHealth = CountPctFromMaxHealth(healthPct);
}
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));
@@ -465,11 +471,11 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool c
}
else
{
if (!savedhealth && getPetType() == HUNTER_PET)
if (!curHealth && getPetType() == HUNTER_PET)
setDeathState(JUST_DIED);
else
{
SetHealth(savedhealth > GetMaxHealth() ? GetMaxHealth() : savedhealth);
SetHealth(curHealth > GetMaxHealth() ? GetMaxHealth() : curHealth);
SetPower(POWER_MANA, savedmana > GetMaxPower(POWER_MANA) ? GetMaxPower(POWER_MANA) : savedmana);
}
}