I would rename it to .gy (graveyard)
Syntax would just be .gy and the result would be:
1. Check if player is dead and is in a battleground. If not, do nothing and give user feedback.
2. Teleport player to nearest graveyard.
I've tested the command handler below locally, and it works according to what I wrote above.
Code: Select all
static bool HandleGraveyardCommand(ChatHandler* handler, char const* /* args */ )
{
Player* player = handler->GetSession()->GetPlayer();
if (!player)
return false;
if (!player->InBattleground()) {
handler->SendSysMessage("Graveyard can only be used in battlegrounds.");
handler->SetSentErrorMessage(true);
return false;
}
if (!player->isDead()) {
handler->SendSysMessage("Graveyard can only be used while dead.");
handler->SetSentErrorMessage(true);
return false;
}
if (Battleground * bg = player->GetBattleground()) {
if (WorldSafeLocsEntry const* closestGrave = bg->GetClosestGraveYard(player)) {
player->TeleportTo(bg->GetMapId(), closestGrave->x, closestGrave->y, closestGrave->z, player->GetOrientation());
}
}
return true;
}