1. void Player::RepopAtGraveyard()
  2. {
  3. bool NotBG = false;
  4. // note: this can be called also when the player is alive
  5. // for example from WorldSession::HandleMovementOpcodes
  6. AreaTableEntry const* zone = GetAreaEntryByAreaID(GetAreaId());
  7. // Such zones are considered unreachable as a ghost and the player must be automatically revived
  8. if ((!isAlive() && zone && zone->flags & AREA_FLAG_NEED_FLY) || GetTransport() || GetPositionZ() < -500.0f)
  9. {
  10. ResurrectPlayer(0.5f);
  11. SpawnCorpseBones();
  12. }
  13. WorldSafeLocsEntry const* ClosestGrave = NULL;
  14. // Special handle for battleground maps
  15. if (Battleground* bg = GetBattleground())
  16. ClosestGrave = bg->GetClosestGraveYard(this);
  17. else
  18. {
  19. if (Battlefield* bf = sBattlefieldMgr->GetBattlefieldToZoneId(GetZoneId()))
  20. {
  21. ClosestGrave = bf->GetClosestGraveYard(this);
  22. NotBG = false;
  23. }
  24. else
  25. NotBG = true;
  26. }
  27. // stop countdown until repop
  28. m_deathTimer = 0;
  29. // if no grave found, stay at the current location
  30. // and don't show spirit healer location
  31. if (ClosestGrave)
  32. {
  33. TeleportTo(ClosestGrave->map_id, ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, GetOrientation());
  34. if (isDead()) // not send if alive, because it used in TeleportTo()
  35. {
  36. WorldPacket data(SMSG_DEATH_RELEASE_LOC, 4*4); // show spirit healer position on minimap
  37. data << ClosestGrave->map_id;
  38. data << ClosestGrave->x;
  39. data << ClosestGrave->y;
  40. data << ClosestGrave->z;
  41. GetSession()->SendPacket(&data);
  42. }
  43. }
  44. if (NotBG)
  45. {
  46. TeleportTo(GetMapId(), GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation());
  47. if (isDead())
  48. {
  49. WorldPacket data(SMSG_DEATH_RELEASE_LOC, 4*4); // show spirit healer position on minimap
  50. data << GetMapId();
  51. data << GetPositionX();
  52. data << GetPositionY();
  53. data << GetPositionZ();
  54. GetSession()->SendPacket(&data);
  55. }
  56. }
  57. else if (GetPositionZ() < -500.0f)
  58. TeleportTo(m_homebindMapId, m_homebindX, m_homebindY, m_homebindZ, GetOrientation());
  59. }

instant release