- void Player::RepopAtGraveyard()
- {
- bool NotBG = false;
- // note: this can be called also when the player is alive
- // for example from WorldSession::HandleMovementOpcodes
- AreaTableEntry const* zone = GetAreaEntryByAreaID(GetAreaId());
- // Such zones are considered unreachable as a ghost and the player must be automatically revived
- if ((!isAlive() && zone && zone->flags & AREA_FLAG_NEED_FLY) || GetTransport() || GetPositionZ() < -500.0f)
- {
- ResurrectPlayer(0.5f);
- SpawnCorpseBones();
- }
- WorldSafeLocsEntry const* ClosestGrave = NULL;
- // Special handle for battleground maps
- if (Battleground* bg = GetBattleground())
- ClosestGrave = bg->GetClosestGraveYard(this);
- else
- {
- if (Battlefield* bf = sBattlefieldMgr->GetBattlefieldToZoneId(GetZoneId()))
- {
- ClosestGrave = bf->GetClosestGraveYard(this);
- NotBG = false;
- }
- else
- NotBG = true;
- }
- // stop countdown until repop
- m_deathTimer = 0;
- // if no grave found, stay at the current location
- // and don't show spirit healer location
- if (ClosestGrave)
- {
- TeleportTo(ClosestGrave->map_id, ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, GetOrientation());
- if (isDead()) // not send if alive, because it used in TeleportTo()
- {
- WorldPacket data(SMSG_DEATH_RELEASE_LOC, 4*4); // show spirit healer position on minimap
- data << ClosestGrave->map_id;
- data << ClosestGrave->x;
- data << ClosestGrave->y;
- data << ClosestGrave->z;
- GetSession()->SendPacket(&data);
- }
- }
- if (NotBG)
- {
- TeleportTo(GetMapId(), GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation());
- if (isDead())
- {
- WorldPacket data(SMSG_DEATH_RELEASE_LOC, 4*4); // show spirit healer position on minimap
- data << GetMapId();
- data << GetPositionX();
- data << GetPositionY();
- data << GetPositionZ();
- GetSession()->SendPacket(&data);
- }
- }
- else if (GetPositionZ() < -500.0f)
- TeleportTo(m_homebindMapId, m_homebindX, m_homebindY, m_homebindZ, GetOrientation());
- }
instant release