2016-01-12 03:41:44 +00:00
|
|
|
//
|
|
|
|
// Created by koncord on 29.02.16.
|
|
|
|
//
|
2016-08-30 04:19:49 +00:00
|
|
|
#include "Translocations.hpp"
|
2016-01-12 03:41:44 +00:00
|
|
|
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
|
|
|
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
|
|
|
#include <apps/openmw-mp/Player.hpp>
|
|
|
|
#include <apps/openmw-mp/Networking.hpp>
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
using namespace std;
|
|
|
|
|
2016-08-30 04:19:49 +00:00
|
|
|
void TranslocationFunctions::GetPos(unsigned short pid, float *x, float *y, float *z) noexcept
|
2016-01-12 03:41:44 +00:00
|
|
|
{
|
|
|
|
*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];
|
|
|
|
}
|
|
|
|
|
2016-08-30 04:19:49 +00:00
|
|
|
double TranslocationFunctions::GetPosX(unsigned short pid) noexcept
|
2016-07-16 08:19:35 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, 0.0f);
|
|
|
|
|
|
|
|
return player->Position()->pos[0];
|
|
|
|
}
|
|
|
|
|
2016-08-30 04:19:49 +00:00
|
|
|
double TranslocationFunctions::GetPosY(unsigned short pid) noexcept
|
2016-07-16 08:19:35 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, 0.0f);
|
|
|
|
|
|
|
|
return player->Position()->pos[1];
|
|
|
|
}
|
|
|
|
|
2016-08-30 04:19:49 +00:00
|
|
|
double TranslocationFunctions::GetPosZ(unsigned short pid) noexcept
|
2016-07-16 08:19:35 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, 0.0f);
|
|
|
|
|
|
|
|
return player->Position()->pos[2];
|
|
|
|
}
|
|
|
|
|
2016-08-30 04:19:49 +00:00
|
|
|
void TranslocationFunctions::SetPos(unsigned short pid, double x, double y, double z) noexcept
|
2016-01-12 03:41:44 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player,);
|
|
|
|
|
|
|
|
player->Position()->pos[0] = x;
|
|
|
|
player->Position()->pos[1] = y;
|
|
|
|
player->Position()->pos[2] = z;
|
|
|
|
|
|
|
|
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_UPDATE_POS)->Send(player, false);
|
|
|
|
}
|
|
|
|
|
2016-08-30 04:19:49 +00:00
|
|
|
void TranslocationFunctions::SetCell(unsigned short pid, const char *name) noexcept
|
2016-01-12 03:41:44 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player,);
|
|
|
|
|
2016-08-17 15:20:36 +00:00
|
|
|
/*if (player->GetCell()->mName == name)
|
2016-01-12 03:41:44 +00:00
|
|
|
return;*/
|
|
|
|
|
|
|
|
cout << "attempt to move player (pid: " << pid << " name: " << player->Npc()->mName << ") from ";
|
2016-08-17 15:04:35 +00:00
|
|
|
if (!player->GetCell()->isExterior())
|
2016-01-12 03:41:44 +00:00
|
|
|
cout << "\"" << player->GetCell()->mName << "\"";
|
|
|
|
else
|
|
|
|
cout << "exterior";
|
|
|
|
|
|
|
|
player->GetCell()->mName = name;
|
|
|
|
|
|
|
|
cout << " in to cell \"" << player->GetCell()->mName << "\"" << endl;
|
|
|
|
|
|
|
|
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_CELL)->Send(player, false);
|
|
|
|
}
|
|
|
|
|
2016-08-30 04:19:49 +00:00
|
|
|
const char* TranslocationFunctions::GetCell(unsigned short pid) noexcept
|
2016-01-12 03:41:44 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, 0);
|
|
|
|
|
|
|
|
return player->GetCell()->mName.c_str();
|
|
|
|
}
|
|
|
|
|
2016-08-30 04:19:49 +00:00
|
|
|
void TranslocationFunctions::SetExterior(unsigned short pid, int x, int y) noexcept
|
2016-07-29 17:33:28 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player,);
|
|
|
|
|
|
|
|
cout << "attempt to move player (pid: " << pid << " name: " << player->Npc()->mName << ") from ";
|
2016-08-17 15:04:35 +00:00
|
|
|
if (!player->GetCell()->isExterior())
|
2016-07-29 17:33:28 +00:00
|
|
|
cout << "\"" << player->GetCell()->mName << "\"";
|
|
|
|
else
|
|
|
|
cout << "exterior: " << player->GetCell()->mCellId.mIndex.mX << ", " << player->GetCell()->mCellId.mIndex.mY;
|
|
|
|
cout << " in to exterior cell \"" << x << ", " << y << "\"" << endl;
|
|
|
|
|
2016-08-03 19:07:49 +00:00
|
|
|
player->GetCell()->mName = "";
|
2016-07-29 17:33:28 +00:00
|
|
|
player->GetCell()->mCellId.mIndex.mX = x;
|
|
|
|
player->GetCell()->mCellId.mIndex.mY = y;
|
|
|
|
|
|
|
|
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_CELL)->Send(player, false);
|
|
|
|
}
|
|
|
|
|
2016-08-30 04:19:49 +00:00
|
|
|
int TranslocationFunctions::GetExteriorX(unsigned short pid) noexcept
|
2016-07-29 17:33:28 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player,0);
|
|
|
|
return player->GetCell()->mCellId.mIndex.mX;
|
|
|
|
}
|
|
|
|
|
2016-08-30 04:19:49 +00:00
|
|
|
int TranslocationFunctions::GetExteriorY(unsigned short pid) noexcept
|
2016-07-29 17:33:28 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player,0);
|
|
|
|
return player->GetCell()->mCellId.mIndex.mY;
|
|
|
|
}
|
|
|
|
|
2016-08-30 04:19:49 +00:00
|
|
|
bool TranslocationFunctions::IsInInterior(unsigned short pid) noexcept
|
2016-01-12 03:41:44 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, false);
|
|
|
|
|
|
|
|
return !player->GetCell()->isExterior();
|
|
|
|
}
|
|
|
|
|
2016-08-30 04:19:49 +00:00
|
|
|
void TranslocationFunctions::GetAngle(unsigned short pid, float *x, float *y, float *z) noexcept
|
2016-01-12 03:41:44 +00:00
|
|
|
{
|
|
|
|
*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];
|
|
|
|
}
|
|
|
|
|
2016-08-30 04:19:49 +00:00
|
|
|
double TranslocationFunctions::GetAngleX(unsigned short pid) noexcept
|
2016-07-16 08:19:35 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, 0.0f);
|
|
|
|
|
|
|
|
return player->Position()->rot[0];
|
|
|
|
}
|
|
|
|
|
2016-08-30 04:19:49 +00:00
|
|
|
double TranslocationFunctions::GetAngleY(unsigned short pid) noexcept
|
2016-07-16 08:19:35 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, 0.0f);
|
|
|
|
|
|
|
|
return player->Position()->rot[1];
|
|
|
|
}
|
|
|
|
|
2016-08-30 04:19:49 +00:00
|
|
|
double TranslocationFunctions::GetAngleZ(unsigned short pid) noexcept
|
2016-07-16 08:19:35 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, 0.0f);
|
|
|
|
|
|
|
|
return player->Position()->rot[2];
|
|
|
|
}
|
|
|
|
|
2016-08-30 04:19:49 +00:00
|
|
|
void TranslocationFunctions::SetAngle(unsigned short pid, double x, double y, double z) noexcept
|
2016-01-12 03:41:44 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player,);
|
|
|
|
|
|
|
|
player->Position()->rot[0] = x;
|
|
|
|
player->Position()->rot[1] = y;
|
|
|
|
player->Position()->rot[2] = z;
|
|
|
|
|
|
|
|
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_UPDATE_POS)->Send(player, false);
|
|
|
|
}
|