Core/Players: Repop players at instance entrance when they release spirit

Port From (https://github.com/TrinityCore/TrinityCore/commit/9e9f67d6bd6dcaabbf52f5c6809ca69440736f47)
This commit is contained in:
hondacrx
2023-07-01 09:33:56 -04:00
parent 0a997ceb69
commit c81213e591
+16 -9
View File
@@ -4213,34 +4213,41 @@ namespace Game.Entities
SpawnCorpseBones(); SpawnCorpseBones();
} }
WorldSafeLocsEntry ClosestGrave; WorldSafeLocsEntry closestGrave = null;
// Special handle for Battlegroundmaps // Special handle for Battlegroundmaps
Battleground bg = GetBattleground(); Battleground bg = GetBattleground();
if (bg) if (bg)
ClosestGrave = bg.GetClosestGraveyard(this); closestGrave = bg.GetClosestGraveyard(this);
else else
{ {
BattleField bf = BattleFieldMgr.GetBattlefieldToZoneId(GetMap(), GetZoneId()); var bf = BattleFieldMgr.GetBattlefieldToZoneId(GetMap(), GetZoneId());
if (bf != null) if (bf != null)
ClosestGrave = bf.GetClosestGraveyard(this); closestGrave = bf.GetClosestGraveyard(this);
else else
ClosestGrave = ObjectMgr.GetClosestGraveyard(this, GetTeam(), this); {
InstanceScript instance = GetInstanceScript();
if (instance != null)
closestGrave = ObjectMgr.GetWorldSafeLoc(instance.GetEntranceLocation());
}
} }
if (closestGrave == null)
closestGrave = ObjectMgr.GetClosestGraveyard(this, GetTeam(), this);
// stop countdown until repop // stop countdown until repop
m_deathTimer = 0; m_deathTimer = 0;
// if no grave found, stay at the current location // if no grave found, stay at the current location
// and don't show spirit healer location // and don't show spirit healer location
if (ClosestGrave != null) if (closestGrave != null)
{ {
TeleportTo(ClosestGrave.Loc, shouldResurrect ? TeleportToOptions.ReviveAtTeleport : 0); TeleportTo(closestGrave.Loc, shouldResurrect ? TeleportToOptions.ReviveAtTeleport : 0);
if (IsDead()) // not send if alive, because it used in TeleportTo() if (IsDead()) // not send if alive, because it used in TeleportTo()
{ {
DeathReleaseLoc packet = new(); DeathReleaseLoc packet = new();
packet.MapID = (int)ClosestGrave.Loc.GetMapId(); packet.MapID = (int)closestGrave.Loc.GetMapId();
packet.Loc = ClosestGrave.Loc; packet.Loc = closestGrave.Loc;
SendPacket(packet); SendPacket(packet);
} }
} }