|
|
|
@ -77,20 +77,25 @@ namespace MWLua
|
|
|
|
|
return &wm->getExterior(ESM::positionToExteriorCellLocation(pos.x(), pos.y(), worldspace));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void teleportPlayer(
|
|
|
|
|
MWWorld::CellStore* destCell, const osg::Vec3f& pos, const osg::Vec3f& rot, bool placeOnGround)
|
|
|
|
|
ESM::Position toPos(const osg::Vec3f& pos, const osg::Vec3f& rot)
|
|
|
|
|
{
|
|
|
|
|
MWBase::World* world = MWBase::Environment::get().getWorld();
|
|
|
|
|
ESM::Position esmPos;
|
|
|
|
|
static_assert(sizeof(esmPos) == sizeof(osg::Vec3f) * 2);
|
|
|
|
|
std::memcpy(esmPos.pos, &pos, sizeof(osg::Vec3f));
|
|
|
|
|
std::memcpy(esmPos.rot, &rot, sizeof(osg::Vec3f));
|
|
|
|
|
return esmPos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void teleportPlayer(
|
|
|
|
|
MWWorld::CellStore* destCell, const osg::Vec3f& pos, const osg::Vec3f& rot, bool placeOnGround)
|
|
|
|
|
{
|
|
|
|
|
MWBase::World* world = MWBase::Environment::get().getWorld();
|
|
|
|
|
MWWorld::Ptr ptr = world->getPlayerPtr();
|
|
|
|
|
auto& stats = ptr.getClass().getCreatureStats(ptr);
|
|
|
|
|
stats.land(true);
|
|
|
|
|
stats.setTeleported(true);
|
|
|
|
|
world->getPlayer().setTeleported(true);
|
|
|
|
|
world->changeToCell(destCell->getCell()->getId(), esmPos, false);
|
|
|
|
|
world->changeToCell(destCell->getCell()->getId(), toPos(pos, rot), false);
|
|
|
|
|
MWWorld::Ptr newPtr = world->getPlayerPtr();
|
|
|
|
|
world->moveObject(newPtr, pos);
|
|
|
|
|
world->rotateObject(newPtr, rot);
|
|
|
|
@ -103,6 +108,7 @@ namespace MWLua
|
|
|
|
|
const osg::Vec3f& rot, bool placeOnGround)
|
|
|
|
|
{
|
|
|
|
|
MWBase::World* world = MWBase::Environment::get().getWorld();
|
|
|
|
|
MWWorld::WorldModel* wm = MWBase::Environment::get().getWorldModel();
|
|
|
|
|
const MWWorld::Class& cls = ptr.getClass();
|
|
|
|
|
if (cls.isActor())
|
|
|
|
|
{
|
|
|
|
@ -110,8 +116,19 @@ namespace MWLua
|
|
|
|
|
stats.land(false);
|
|
|
|
|
stats.setTeleported(true);
|
|
|
|
|
}
|
|
|
|
|
MWWorld::Ptr newPtr = world->moveObject(ptr, destCell, pos);
|
|
|
|
|
world->rotateObject(newPtr, rot, MWBase::RotationFlag_none);
|
|
|
|
|
MWWorld::Ptr newPtr;
|
|
|
|
|
if (ptr.getCell() == &wm->getDraftCell())
|
|
|
|
|
{
|
|
|
|
|
newPtr = world->placeObject(ptr, destCell, toPos(pos, rot));
|
|
|
|
|
ptr.getCellRef().unsetRefNum();
|
|
|
|
|
ptr.getRefData().setLuaScripts(nullptr);
|
|
|
|
|
ptr.getRefData().setCount(0);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
newPtr = world->moveObject(ptr, destCell, pos);
|
|
|
|
|
world->rotateObject(newPtr, rot, MWBase::RotationFlag_none);
|
|
|
|
|
}
|
|
|
|
|
if (placeOnGround)
|
|
|
|
|
world->adjustPosition(newPtr, true);
|
|
|
|
|
if (cls.isDoor())
|
|
|
|
|