From b918135b4b0906934a8c0ada8e5947b8f253e5e3 Mon Sep 17 00:00:00 2001 From: Alexei Dobrohotov Date: Sat, 13 Nov 2021 00:23:16 +0300 Subject: [PATCH] Factor race weight into magic projectile speed (bug #6343) --- CHANGELOG.md | 1 + apps/openmw/mwworld/projectilemanager.cpp | 13 +++++++++++-- docs/source/reference/modding/settings/game.rst | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6017f62db4..34ab40098e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -69,6 +69,7 @@ Bug #6323: Wyrmhaven: Alboin doesn't follower the player character out of his house Bug #6326: Detect Enchantment/Key should detect items in unresolved containers Bug #6327: Blocking roots the character in place + Bug #6343: Magic projectile speed doesn't take race weight into account Bug #6347: PlaceItem/PlaceItemCell/PlaceAt should work with levelled creatures Bug #6354: SFX abruptly cut off after crossing max distance; implement soft fading of sound effects Bug #6363: Some scripts in Morrowland fail to work diff --git a/apps/openmw/mwworld/projectilemanager.cpp b/apps/openmw/mwworld/projectilemanager.cpp index e6a7195f5a..3bff1854a6 100644 --- a/apps/openmw/mwworld/projectilemanager.cpp +++ b/apps/openmw/mwworld/projectilemanager.cpp @@ -22,6 +22,8 @@ #include #include +#include + #include "../mwworld/manualref.hpp" #include "../mwworld/class.hpp" #include "../mwworld/esmstore.hpp" @@ -407,6 +409,7 @@ namespace MWWorld void ProjectileManager::moveMagicBolts(float duration) { + static const bool normaliseRaceSpeed = Settings::Manager::getBool("normalise race speed", "Game"); for (auto& magicBoltState : mMagicBolts) { if (magicBoltState.mToDelete) @@ -426,10 +429,16 @@ namespace MWWorld } } + const auto& store = MWBase::Environment::get().getWorld()->getStore(); osg::Quat orient = magicBoltState.mNode->getAttitude(); - static float fTargetSpellMaxSpeed = MWBase::Environment::get().getWorld()->getStore().get() - .find("fTargetSpellMaxSpeed")->mValue.getFloat(); + static float fTargetSpellMaxSpeed = store.get().find("fTargetSpellMaxSpeed")->mValue.getFloat(); float speed = fTargetSpellMaxSpeed * magicBoltState.mSpeed; + if (!normaliseRaceSpeed && !caster.isEmpty() && caster.getClass().isNpc()) + { + const auto npc = caster.get()->mBase; + const auto race = store.get().find(npc->mRace); + speed *= npc->isMale() ? race->mData.mWeight.mMale : race->mData.mWeight.mFemale; + } osg::Vec3f direction = orient * osg::Vec3f(0,1,0); direction.normalize(); projectile->setVelocity(direction * speed); diff --git a/docs/source/reference/modding/settings/game.rst b/docs/source/reference/modding/settings/game.rst index 58d5345f65..605be3f6af 100644 --- a/docs/source/reference/modding/settings/game.rst +++ b/docs/source/reference/modding/settings/game.rst @@ -275,7 +275,7 @@ normalise race speed :Range: True/False :Default: False -By default race weight is factored into horizontal movement speed like in Morrowind. +By default race weight is factored into horizontal movement and magic projectile speed like in Morrowind. For example, an NPC which has 1.2 race weight is faster than an NPC with the exact same stats and weight 1.0 by a factor of 120%. If this setting is true, race weight is ignored in the calculations which allows for a movement behavior equivalent to the one introduced by the equivalent Morrowind Code Patch feature.