Send ID_OBJECT_ROTATE from ingame scripts

pull/112/merge
David Cernat 8 years ago
parent 385b5f39e3
commit b1051255e0

@ -569,6 +569,20 @@ namespace MWScript
float ay = ptr.getRefData().getPosition().rot[1];
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")
MWBase::Environment::get().getWorld()->rotateObject(ptr,ax+rotation,ay,az);
else if (axis == "y")
@ -600,6 +614,20 @@ namespace MWScript
float ay = objRot[1];
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")
{
MWBase::Environment::get().getWorld()->rotateObject(ptr,ax+rotation,ay,az);
@ -638,9 +666,8 @@ namespace MWScript
event->cell = *ptr.getCell()->getCell();
event->cellRef.mRefID = ptr.getCellRef().getRefId();
event->cellRef.mRefNum = ptr.getCellRef().getRefNum();
event->pos.pos[0] = ptr.getCellRef().getPosition().pos[0];
event->pos.pos[1] = ptr.getCellRef().getPosition().pos[1];
event->pos.pos[2] = ptr.getCellRef().getPosition().pos[2];
event->pos = ptr.getCellRef().getPosition();
mwmp::Main::get().getNetworking()->GetWorldPacket(ID_OBJECT_ROTATE)->Send(event);
mwmp::Main::get().getNetworking()->GetWorldPacket(ID_OBJECT_MOVE)->Send(event);
MWBase::Environment::get().getWorld()->rotateObject(ptr, xr, yr, zr);
@ -729,6 +756,20 @@ namespace MWScript
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;
if (axis == "x")
{
@ -744,20 +785,6 @@ namespace MWScript
}
else
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…
Cancel
Save