mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-21 10:23:52 +00:00
Send ID_OBJECT_ROTATE from ingame scripts
This commit is contained in:
parent
385b5f39e3
commit
b1051255e0
1 changed files with 44 additions and 17 deletions
|
@ -569,6 +569,20 @@ namespace MWScript
|
||||||
float ay = ptr.getRefData().getPosition().rot[1];
|
float ay = ptr.getRefData().getPosition().rot[1];
|
||||||
float az = ptr.getRefData().getPosition().rot[2];
|
float az = ptr.getRefData().getPosition().rot[2];
|
||||||
|
|
||||||
|
// Added by tes3mp
|
||||||
|
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent();
|
||||||
|
event->cell = *ptr.getCell()->getCell();
|
||||||
|
event->cellRef.mRefID = ptr.getCellRef().getRefId();
|
||||||
|
event->cellRef.mRefNum = ptr.getCellRef().getRefNum();
|
||||||
|
event->pos.rot[0] = axis == "x" ? ax + rotation : ax;
|
||||||
|
event->pos.rot[1] = axis == "y" ? ay + rotation : ay;
|
||||||
|
event->pos.rot[2] = axis == "z" ? az + rotation : az;
|
||||||
|
mwmp::Main::get().getNetworking()->GetWorldPacket(ID_OBJECT_ROTATE)->Send(event);
|
||||||
|
|
||||||
|
printf("Sending ID_OBJECT_ROTATE about %s\n%i\n",
|
||||||
|
event->cellRef.mRefID.c_str(),
|
||||||
|
event->cellRef.mRefNum.mIndex);
|
||||||
|
|
||||||
if (axis == "x")
|
if (axis == "x")
|
||||||
MWBase::Environment::get().getWorld()->rotateObject(ptr,ax+rotation,ay,az);
|
MWBase::Environment::get().getWorld()->rotateObject(ptr,ax+rotation,ay,az);
|
||||||
else if (axis == "y")
|
else if (axis == "y")
|
||||||
|
@ -600,6 +614,20 @@ namespace MWScript
|
||||||
float ay = objRot[1];
|
float ay = objRot[1];
|
||||||
float az = objRot[2];
|
float az = objRot[2];
|
||||||
|
|
||||||
|
// Added by tes3mp
|
||||||
|
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent();
|
||||||
|
event->cell = *ptr.getCell()->getCell();
|
||||||
|
event->cellRef.mRefID = ptr.getCellRef().getRefId();
|
||||||
|
event->cellRef.mRefNum = ptr.getCellRef().getRefNum();
|
||||||
|
event->pos.rot[0] = axis == "x" ? ax + rotation : ax;
|
||||||
|
event->pos.rot[1] = axis == "y" ? ay + rotation : ay;
|
||||||
|
event->pos.rot[2] = axis == "z" ? az + rotation : az;
|
||||||
|
mwmp::Main::get().getNetworking()->GetWorldPacket(ID_OBJECT_ROTATE)->Send(event);
|
||||||
|
|
||||||
|
printf("Sending ID_OBJECT_ROTATE about %s\n%i\n",
|
||||||
|
event->cellRef.mRefID.c_str(),
|
||||||
|
event->cellRef.mRefNum.mIndex);
|
||||||
|
|
||||||
if (axis == "x")
|
if (axis == "x")
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getWorld()->rotateObject(ptr,ax+rotation,ay,az);
|
MWBase::Environment::get().getWorld()->rotateObject(ptr,ax+rotation,ay,az);
|
||||||
|
@ -638,9 +666,8 @@ namespace MWScript
|
||||||
event->cell = *ptr.getCell()->getCell();
|
event->cell = *ptr.getCell()->getCell();
|
||||||
event->cellRef.mRefID = ptr.getCellRef().getRefId();
|
event->cellRef.mRefID = ptr.getCellRef().getRefId();
|
||||||
event->cellRef.mRefNum = ptr.getCellRef().getRefNum();
|
event->cellRef.mRefNum = ptr.getCellRef().getRefNum();
|
||||||
event->pos.pos[0] = ptr.getCellRef().getPosition().pos[0];
|
event->pos = ptr.getCellRef().getPosition();
|
||||||
event->pos.pos[1] = ptr.getCellRef().getPosition().pos[1];
|
mwmp::Main::get().getNetworking()->GetWorldPacket(ID_OBJECT_ROTATE)->Send(event);
|
||||||
event->pos.pos[2] = ptr.getCellRef().getPosition().pos[2];
|
|
||||||
mwmp::Main::get().getNetworking()->GetWorldPacket(ID_OBJECT_MOVE)->Send(event);
|
mwmp::Main::get().getNetworking()->GetWorldPacket(ID_OBJECT_MOVE)->Send(event);
|
||||||
|
|
||||||
MWBase::Environment::get().getWorld()->rotateObject(ptr, xr, yr, zr);
|
MWBase::Environment::get().getWorld()->rotateObject(ptr, xr, yr, zr);
|
||||||
|
@ -729,6 +756,20 @@ namespace MWScript
|
||||||
|
|
||||||
const float *objPos = ptr.getRefData().getPosition().pos;
|
const float *objPos = ptr.getRefData().getPosition().pos;
|
||||||
|
|
||||||
|
// Added by tes3mp
|
||||||
|
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent();
|
||||||
|
event->cell = *ptr.getCell()->getCell();
|
||||||
|
event->cellRef.mRefID = ptr.getCellRef().getRefId();
|
||||||
|
event->cellRef.mRefNum = ptr.getCellRef().getRefNum();
|
||||||
|
event->pos.pos[0] = axis == "x" ? objPos[0] + movement : objPos[0];
|
||||||
|
event->pos.pos[1] = axis == "y" ? objPos[1] + movement : objPos[1];
|
||||||
|
event->pos.pos[2] = axis == "z" ? objPos[2] + movement : objPos[2];
|
||||||
|
mwmp::Main::get().getNetworking()->GetWorldPacket(ID_OBJECT_MOVE)->Send(event);
|
||||||
|
|
||||||
|
printf("Sending ID_OBJECT_MOVE about %s\n%i\n",
|
||||||
|
event->cellRef.mRefID.c_str(),
|
||||||
|
event->cellRef.mRefNum.mIndex);
|
||||||
|
|
||||||
MWWorld::Ptr updated;
|
MWWorld::Ptr updated;
|
||||||
if (axis == "x")
|
if (axis == "x")
|
||||||
{
|
{
|
||||||
|
@ -744,20 +785,6 @@ namespace MWScript
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw std::runtime_error ("invalid movement axis: " + axis);
|
throw std::runtime_error ("invalid movement axis: " + axis);
|
||||||
|
|
||||||
// Added by tes3mp
|
|
||||||
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent();
|
|
||||||
event->cell = *ptr.getCell()->getCell();
|
|
||||||
event->cellRef.mRefID = ptr.getCellRef().getRefId();
|
|
||||||
event->cellRef.mRefNum = ptr.getCellRef().getRefNum();
|
|
||||||
event->pos.pos[0] = updated.getRefData().getPosition().pos[0];
|
|
||||||
event->pos.pos[1] = updated.getRefData().getPosition().pos[1];
|
|
||||||
event->pos.pos[2] = updated.getRefData().getPosition().pos[2];
|
|
||||||
mwmp::Main::get().getNetworking()->GetWorldPacket(ID_OBJECT_MOVE)->Send(event);
|
|
||||||
|
|
||||||
printf("Sending ID_OBJECT_MOVE about %s\n%i\n",
|
|
||||||
event->cellRef.mRefID.c_str(),
|
|
||||||
event->cellRef.mRefNum.mIndex);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue