From 89a0b2d2d4a29265107b9e0005778e033e758b4f Mon Sep 17 00:00:00 2001 From: Alexei Dobrohotov Date: Wed, 17 Apr 2019 13:22:03 +0000 Subject: [PATCH] Merge branch 'issue-4805' into 'master' Bug #4805: NPC movement speed calculations do not take race Weight into account See merge request OpenMW/openmw!89 (cherry picked from commit 98f52fa8ad8d8746786c529373db81f8602135df) 61682570 Bug #4805: NPC movement speed calculations do not take race Weight into account 0c8308bc Revert "Bug #4805: NPC movement speed calculations do not take race Weight into account" 4b43e91f Change to only affect movement speed and not animation speed a66ae118 Use adjustScale() to adjust movement calculation instead of using race weight 6295eadc Make sure height is also factored into movement speed fde0ca8b Remove height from movement calculation and factor in cell reference scale --- AUTHORS.md | 1 + CHANGELOG.md | 1 + apps/openmw/mwmechanics/character.cpp | 13 +++++++++++++ 3 files changed, 15 insertions(+) diff --git a/AUTHORS.md b/AUTHORS.md index c3a27dea2..c806a96d0 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -135,6 +135,7 @@ Programmers Mitchell Schwitzer (schwitzerm) naclander Narmo + Nat Meo (Utopium) Nathan Jeffords (blunted2night) NeveHanter Nialsy diff --git a/CHANGELOG.md b/CHANGELOG.md index b344edcca..d05942952 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ Bug #4800: Standing collisions are not updated immediately when an object is teleported without a cell change Bug #4803: Stray special characters before begin statement break script compilation Bug #4804: Particle system with the "Has Sizes = false" causes an exception + Bug #4805: NPC movement speed calculations do not take race Weight into account Bug #4810: Raki creature broken in OpenMW Bug #4813: Creatures with known file but no "Sound Gen Creature" assigned use default sounds Bug #4815: "Finished" journal entry with lower index doesn't close journal, SetJournalIndex closes journal diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index 8dd5c4297..c8a99174b 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -2368,6 +2368,19 @@ void CharacterController::update(float duration, bool animationOnly) else moved = osg::Vec3f(0.f, 0.f, 0.f); + float scale = mPtr.getCellRef().getScale(); + moved.x() *= scale; + moved.y() *= scale; + + if(mPtr.getClass().isNpc()) + { + const ESM::NPC* npc = mPtr.get()->mBase; + const ESM::Race* race = world->getStore().get().find(npc->mRace); + float weight = npc->isMale() ? race->mData.mWeight.mMale : race->mData.mWeight.mFemale; + moved.x() *= weight; + moved.y() *= weight; + } + // Ensure we're moving in generally the right direction... if(speed > 0.f) {