2017-04-28 13:33:58 +00:00
|
|
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
|
|
|
#include <components/openmw-mp/Base/BaseActor.hpp>
|
2017-04-09 09:24:33 +00:00
|
|
|
|
2017-04-28 13:33:58 +00:00
|
|
|
#include <apps/openmw-mp/Networking.hpp>
|
2017-04-09 09:24:33 +00:00
|
|
|
#include <apps/openmw-mp/Player.hpp>
|
2017-04-28 13:33:58 +00:00
|
|
|
#include <apps/openmw-mp/Utils.hpp>
|
2017-04-09 09:24:33 +00:00
|
|
|
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
|
2017-04-28 13:33:58 +00:00
|
|
|
|
2017-04-09 09:24:33 +00:00
|
|
|
#include "Actors.hpp"
|
|
|
|
|
|
|
|
using namespace mwmp;
|
|
|
|
|
2017-04-09 13:32:44 +00:00
|
|
|
BaseActorList scriptActorList;
|
2017-04-10 03:15:03 +00:00
|
|
|
|
2017-04-09 09:24:33 +00:00
|
|
|
BaseActor tempActor;
|
2017-04-10 03:15:03 +00:00
|
|
|
const BaseActor emptyActor = {};
|
2017-04-09 09:24:33 +00:00
|
|
|
|
2017-04-28 17:31:02 +00:00
|
|
|
static std::string tempCellDescription;
|
|
|
|
|
2017-04-10 03:15:03 +00:00
|
|
|
void ActorFunctions::InitScriptActorList(unsigned short pid) noexcept
|
2017-04-09 09:24:33 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, );
|
|
|
|
|
2017-04-09 13:32:44 +00:00
|
|
|
scriptActorList.cell.blank();
|
|
|
|
scriptActorList.baseActors.clear();
|
|
|
|
scriptActorList.guid = player->guid;
|
2017-04-09 09:24:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int ActorFunctions::GetActorListSize() noexcept
|
|
|
|
{
|
2017-04-10 03:15:03 +00:00
|
|
|
return mwmp::Networking::getPtr()->getLastActorList()->count;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned char ActorFunctions::GetLastActorListAction() noexcept
|
|
|
|
{
|
|
|
|
return mwmp::Networking::getPtr()->getLastActorList()->action;
|
|
|
|
}
|
|
|
|
|
2017-04-27 11:59:49 +00:00
|
|
|
const char *ActorFunctions::GetActorCell(unsigned int i) noexcept
|
|
|
|
{
|
2017-04-28 17:31:02 +00:00
|
|
|
tempCellDescription = mwmp::Networking::getPtr()->getLastActorList()->baseActors.at(i).cell.getDescription();
|
|
|
|
return tempCellDescription.c_str();
|
2017-04-27 11:59:49 +00:00
|
|
|
}
|
|
|
|
|
2017-04-10 03:15:03 +00:00
|
|
|
const char *ActorFunctions::GetActorRefId(unsigned int i) noexcept
|
|
|
|
{
|
|
|
|
return mwmp::Networking::getPtr()->getLastActorList()->baseActors.at(i).refId.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
int ActorFunctions::GetActorRefNumIndex(unsigned int i) noexcept
|
|
|
|
{
|
|
|
|
return mwmp::Networking::getPtr()->getLastActorList()->baseActors.at(i).refNumIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ActorFunctions::GetActorMpNum(unsigned int i) noexcept
|
|
|
|
{
|
|
|
|
return mwmp::Networking::getPtr()->getLastActorList()->baseActors.at(i).mpNum;
|
|
|
|
}
|
|
|
|
|
2017-04-27 21:05:12 +00:00
|
|
|
double ActorFunctions::GetActorPosX(unsigned int i) noexcept
|
|
|
|
{
|
|
|
|
return mwmp::Networking::getPtr()->getLastActorList()->baseActors.at(i).position.pos[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
double ActorFunctions::GetActorPosY(unsigned int i) noexcept
|
|
|
|
{
|
|
|
|
return mwmp::Networking::getPtr()->getLastActorList()->baseActors.at(i).position.pos[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
double ActorFunctions::GetActorPosZ(unsigned int i) noexcept
|
|
|
|
{
|
|
|
|
return mwmp::Networking::getPtr()->getLastActorList()->baseActors.at(i).position.pos[2];
|
|
|
|
}
|
|
|
|
|
|
|
|
double ActorFunctions::GetActorRotX(unsigned int i) noexcept
|
|
|
|
{
|
|
|
|
return mwmp::Networking::getPtr()->getLastActorList()->baseActors.at(i).position.rot[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
double ActorFunctions::GetActorRotY(unsigned int i) noexcept
|
|
|
|
{
|
|
|
|
return mwmp::Networking::getPtr()->getLastActorList()->baseActors.at(i).position.rot[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
double ActorFunctions::GetActorRotZ(unsigned int i) noexcept
|
|
|
|
{
|
|
|
|
return mwmp::Networking::getPtr()->getLastActorList()->baseActors.at(i).position.rot[2];
|
|
|
|
}
|
|
|
|
|
2017-04-10 03:15:03 +00:00
|
|
|
void ActorFunctions::SetScriptActorListCell(const char* cellDescription) noexcept
|
|
|
|
{
|
2017-04-28 13:33:58 +00:00
|
|
|
scriptActorList.cell = Utils::getCellFromDescription(cellDescription);
|
2017-04-10 03:15:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ActorFunctions::SetScriptActorListAction(unsigned char action) noexcept
|
|
|
|
{
|
|
|
|
scriptActorList.action = action;
|
|
|
|
}
|
|
|
|
|
2017-04-28 15:44:01 +00:00
|
|
|
void ActorFunctions::SetActorCell(const char* cellDescription) noexcept
|
|
|
|
{
|
|
|
|
tempActor.cell = Utils::getCellFromDescription(cellDescription);
|
|
|
|
}
|
|
|
|
|
2017-04-10 03:15:03 +00:00
|
|
|
void ActorFunctions::SetActorRefId(const char* refId) noexcept
|
|
|
|
{
|
|
|
|
tempActor.refId = refId;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActorFunctions::SetActorRefNumIndex(int refNumIndex) noexcept
|
|
|
|
{
|
|
|
|
tempActor.refNumIndex = refNumIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActorFunctions::SetActorMpNum(int mpNum) noexcept
|
|
|
|
{
|
|
|
|
tempActor.mpNum = mpNum;
|
|
|
|
}
|
|
|
|
|
2017-04-28 15:44:01 +00:00
|
|
|
void ActorFunctions::SetActorPosition(double x, double y, double z) noexcept
|
|
|
|
{
|
|
|
|
tempActor.position.pos[0] = x;
|
|
|
|
tempActor.position.pos[1] = y;
|
|
|
|
tempActor.position.pos[2] = z;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActorFunctions::SetActorRotation(double x, double y, double z) noexcept
|
|
|
|
{
|
|
|
|
tempActor.position.rot[0] = x;
|
|
|
|
tempActor.position.rot[1] = y;
|
|
|
|
tempActor.position.rot[2] = z;
|
|
|
|
}
|
|
|
|
|
2017-04-10 03:15:03 +00:00
|
|
|
void ActorFunctions::AddActor() noexcept
|
|
|
|
{
|
|
|
|
scriptActorList.baseActors.push_back(tempActor);
|
|
|
|
|
|
|
|
tempActor = emptyActor;
|
2017-04-09 09:24:33 +00:00
|
|
|
}
|
2017-04-09 13:32:44 +00:00
|
|
|
|
|
|
|
void ActorFunctions::SendActorList() noexcept
|
|
|
|
{
|
|
|
|
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_LIST)->setActorList(&scriptActorList);
|
|
|
|
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_LIST)->Send(scriptActorList.guid);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActorFunctions::SendActorAuthority() noexcept
|
|
|
|
{
|
|
|
|
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_AUTHORITY)->setActorList(&scriptActorList);
|
|
|
|
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_AUTHORITY)->Send(scriptActorList.guid);
|
|
|
|
}
|
|
|
|
|
2017-04-28 15:44:01 +00:00
|
|
|
void ActorFunctions::SendActorCellChange() noexcept
|
|
|
|
{
|
|
|
|
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_CELL_CHANGE)->setActorList(&scriptActorList);
|
|
|
|
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_CELL_CHANGE)->Send(scriptActorList.guid);
|
|
|
|
}
|
|
|
|
|