diff --git a/apps/openmw/mwlua/objectbindings.cpp b/apps/openmw/mwlua/objectbindings.cpp index 6ab6776d7a..0906c44a53 100644 --- a/apps/openmw/mwlua/objectbindings.cpp +++ b/apps/openmw/mwlua/objectbindings.cpp @@ -74,7 +74,9 @@ namespace MWLua std::memcpy(esmPos.pos, &pos, sizeof(osg::Vec3f)); std::memcpy(esmPos.rot, &rot, sizeof(osg::Vec3f)); MWWorld::Ptr ptr = world->getPlayerPtr(); - ptr.getClass().getCreatureStats(ptr).land(false); + auto& stats = ptr.getClass().getCreatureStats(ptr); + stats.land(true); + stats.setTeleported(true); world->getPlayer().setTeleported(true); world->changeToCell(destCell->getCell()->getId(), esmPos, true); } @@ -85,7 +87,11 @@ namespace MWLua MWBase::World* world = MWBase::Environment::get().getWorld(); const MWWorld::Class& cls = ptr.getClass(); if (cls.isActor()) - cls.getCreatureStats(ptr).land(false); + { + auto& stats = ptr.getClass().getCreatureStats(ptr); + stats.land(false); + stats.setTeleported(true); + } MWWorld::Ptr newPtr = world->moveObject(ptr, destCell, pos); world->rotateObject(newPtr, rot, MWBase::RotationFlag_none); if (!newPtr.getRefData().isEnabled()) diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index b7a28241a3..f891a5ab72 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -1862,7 +1862,7 @@ namespace MWMechanics float scale = mPtr.getCellRef().getScale(); static const bool normalizeSpeed = Settings::Manager::getBool("normalise race speed", "Game"); - if (!normalizeSpeed && mPtr.getClass().isNpc()) + if (!normalizeSpeed && cls.isNpc()) { const ESM::NPC* npc = mPtr.get()->mBase; const ESM::Race* race = world->getStore().get().find(npc->mRace); @@ -1870,6 +1870,12 @@ namespace MWMechanics scale *= weight; } + if (cls.isActor() && cls.getCreatureStats(mPtr).wasTeleported()) + { + mSmoothedSpeed = osg::Vec2f(); + cls.getCreatureStats(mPtr).setTeleported(false); + } + if (!cls.isActor()) updateAnimQueue(); else if (!cls.getCreatureStats(mPtr).isDead()) diff --git a/apps/openmw/mwmechanics/creaturestats.hpp b/apps/openmw/mwmechanics/creaturestats.hpp index 0ded000469..9d1830fe03 100644 --- a/apps/openmw/mwmechanics/creaturestats.hpp +++ b/apps/openmw/mwmechanics/creaturestats.hpp @@ -85,6 +85,8 @@ namespace MWMechanics // The difference between view direction and lower body direction. float mSideMovementAngle; + bool mTeleported = false; + private: std::multimap mSummonedCreatures; // @@ -288,6 +290,9 @@ namespace MWMechanics float getSideMovementAngle() const { return mSideMovementAngle; } void setSideMovementAngle(float angle) { mSideMovementAngle = angle; } + + bool wasTeleported() const { return mTeleported; } + void setTeleported(bool v) { mTeleported = v; } }; } diff --git a/apps/openmw/mwscript/transformationextensions.cpp b/apps/openmw/mwscript/transformationextensions.cpp index fd091711c8..bf9fe14298 100644 --- a/apps/openmw/mwscript/transformationextensions.cpp +++ b/apps/openmw/mwscript/transformationextensions.cpp @@ -21,6 +21,7 @@ #include "../mwworld/worldmodel.hpp" #include "../mwmechanics/actorutil.hpp" +#include "../mwmechanics/creaturestats.hpp" #include "interpretercontext.hpp" #include "ref.hpp" @@ -389,10 +390,10 @@ namespace MWScript bool isPlayer = ptr == MWMechanics::getPlayer(); auto world = MWBase::Environment::get().getWorld(); auto worldModel = MWBase::Environment::get().getWorldModel(); + if (ptr.getClass().isActor()) + ptr.getClass().getCreatureStats(ptr).setTeleported(true); if (isPlayer) - { world->getPlayer().setTeleported(true); - } MWWorld::CellStore* store = nullptr; try @@ -463,10 +464,10 @@ namespace MWScript bool isPlayer = ptr == MWMechanics::getPlayer(); auto world = MWBase::Environment::get().getWorld(); + if (ptr.getClass().isActor()) + ptr.getClass().getCreatureStats(ptr).setTeleported(true); if (isPlayer) - { world->getPlayer().setTeleported(true); - } const ESM::ExteriorCellLocation cellIndex = ESM::positionToCellIndex(x, y, ESM::Cell::sDefaultWorldspaceId); diff --git a/apps/openmw/mwworld/actionteleport.cpp b/apps/openmw/mwworld/actionteleport.cpp index 926e958e95..2aaa16cd0b 100644 --- a/apps/openmw/mwworld/actionteleport.cpp +++ b/apps/openmw/mwworld/actionteleport.cpp @@ -47,7 +47,9 @@ namespace MWWorld { MWBase::World* world = MWBase::Environment::get().getWorld(); MWWorld::WorldModel* worldModel = MWBase::Environment::get().getWorldModel(); - actor.getClass().getCreatureStats(actor).land(actor == world->getPlayerPtr()); + auto& stats = actor.getClass().getCreatureStats(actor); + stats.land(actor == world->getPlayerPtr()); + stats.setTeleported(true); Ptr teleported; if (actor == world->getPlayerPtr())