Set CharacterController::mSmoothedSpeed to zero after teleporting.

simplify_debugging
Petr Mikheev 2 years ago
parent ab17d0947a
commit e53f907a53

@ -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())

@ -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<ESM::NPC>()->mBase;
const ESM::Race* race = world->getStore().get<ESM::Race>().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())

@ -85,6 +85,8 @@ namespace MWMechanics
// The difference between view direction and lower body direction.
float mSideMovementAngle;
bool mTeleported = false;
private:
std::multimap<int, int> mSummonedCreatures; // <Effect, ActorId>
@ -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; }
};
}

@ -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);

@ -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())

Loading…
Cancel
Save