#include "Positions.hpp" #include #include #include #include #include #include using namespace std; void PositionFunctions::GetPos(unsigned short pid, float *x, float *y, float *z) noexcept { *x = 0.00; *y = 0.00; *z = 0.00; Player *player; GET_PLAYER(pid, player,); *x = player->position.pos[0]; *y = player->position.pos[1]; *z = player->position.pos[2]; } double PositionFunctions::GetPosX(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0.0f); return player->position.pos[0]; } double PositionFunctions::GetPosY(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0.0f); return player->position.pos[1]; } double PositionFunctions::GetPosZ(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0.0f); return player->position.pos[2]; } void PositionFunctions::GetAngle(unsigned short pid, float *x, float *y, float *z) noexcept { *x = 0.00; *y = 0.00; *z = 0.00; Player *player; GET_PLAYER(pid, player, ); *x = player->position.rot[0]; *y = player->position.rot[1]; *z = player->position.rot[2]; } double PositionFunctions::GetAngleX(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0.0f); return player->position.rot[0]; } double PositionFunctions::GetAngleY(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0.0f); return player->position.rot[1]; } double PositionFunctions::GetAngleZ(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0.0f); return player->position.rot[2]; } void PositionFunctions::SetPos(unsigned short pid, double x, double y, double z) noexcept { Player *player; GET_PLAYER(pid, player,); player->position.pos[0] = x; player->position.pos[1] = y; player->position.pos[2] = z; } void PositionFunctions::SetAngle(unsigned short pid, double x, double y, double z) noexcept { Player *player; GET_PLAYER(pid, player, ); player->position.rot[0] = x; player->position.rot[1] = y; player->position.rot[2] = z; } const char* PositionFunctions::GetCell(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0); return player->cell.mName.c_str(); } void PositionFunctions::SetCell(unsigned short pid, const char *name) noexcept { Player *player; GET_PLAYER(pid, player,); LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Script is moving %s from %s to %s", player->npc.mName.c_str(), player->cell.getDescription().c_str(), name); // If the player is currently in an exterior, turn on the interior flag // from the cell so the player doesn't get teleported to their exterior // grid position (which we haven't changed) if (player->cell.isExterior()) { player->cell.mData.mFlags |= ESM::Cell::Interior; } player->cell.mName = name; } void PositionFunctions::SetExterior(unsigned short pid, int x, int y) noexcept { Player *player; GET_PLAYER(pid, player,); LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Script is moving %s from %s to %i,%i", player->npc.mName.c_str(), player->cell.getDescription().c_str(), x, y); // If the player is currently in an interior, turn off the interior flag // from the cell if (!player->cell.isExterior()) { player->cell.mData.mFlags &= ~ESM::Cell::Interior; } player->cell.mData.mX = x; player->cell.mData.mY = y; } int PositionFunctions::GetExteriorX(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player,0); return player->cell.mData.mX; } int PositionFunctions::GetExteriorY(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player,0); return player->cell.mData.mY; } bool PositionFunctions::IsInExterior(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, false); return player->cell.isExterior(); } void PositionFunctions::SendPos(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, ); mwmp::Networking::get().getPlayerController()->GetPacket(ID_GAME_POS)->Send(player, false); } void PositionFunctions::SendCell(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, ); mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_CELL_CHANGE)->Send(player, false); }