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

@@ -5379,35 +5379,31 @@ void Spell::EffectResurrectPet(SpellEffIndex /*effIndex*/)
Player* player = m_caster->ToPlayer();
if (!player)
{
return;
}
// Maybe player dismissed dead pet or pet despawned?
bool hadPet = true;
if (!player->GetPet())
Pet* pet = player->GetPet();
if (!pet)
{
// Position passed to SummonPet is irrelevant with current implementation,
// pet will be relocated without using these coords in Pet::LoadPetFromDB
player->SummonPet(0, 0.0f, 0.0f, 0.0f, 0.0f, SUMMON_PET);
hadPet = false;
player->SummonPet(0, 0.0f, 0.0f, 0.0f, 0.0f, SUMMON_PET, 0s, damage);
return;
}
// TODO: Better to fail Hunter's "Revive Pet" at cast instead of here when casting ends
Pet* pet = player->GetPet(); // Attempt to get current pet
if (!pet || pet->IsAlive())
return;
// If player did have a pet before reviving, teleport it
if (hadPet)
if (pet->IsAlive())
{
// Reposition the pet's corpse before reviving so as not to grab aggro
// We can use a different, more accurate version of GetClosePoint() since we have a pet
float x, y, z; // Will be used later to reposition the pet if we have one
player->GetClosePoint(x, y, z, pet->GetCombatReach(), PET_FOLLOW_DIST, pet->GetFollowAngle());
pet->NearTeleportTo(x, y, z, player->GetOrientation());
pet->Relocate(x, y, z, player->GetOrientation()); // This is needed so SaveStayPosition() will get the proper coords.
return;
}
// Reposition the pet's corpse before reviving so as not to grab aggro
// We can use a different, more accurate version of GetClosePoint() since we have a pet
float x, y, z; // Will be used later to reposition the pet if we have one
player->GetClosePoint(x, y, z, pet->GetCombatReach(), PET_FOLLOW_DIST, pet->GetFollowAngle());
pet->NearTeleportTo(x, y, z, player->GetOrientation());
pet->Relocate(x, y, z, player->GetOrientation()); // This is needed so SaveStayPosition() will get the proper coords.
pet->SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_NONE);
pet->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE);
pet->setDeathState(ALIVE);