From eecf412b853c2fcdd436bb45c9b54fd4067a207b Mon Sep 17 00:00:00 2001 From: Allofich Date: Fri, 23 Sep 2016 00:16:51 +0900 Subject: [PATCH] Recreate vanilla-like behavior for telekinesis and touch spells --- apps/openmw/mwworld/worldimp.cpp | 25 ++++++++++++++++++------- apps/openmw/mwworld/worldimp.hpp | 1 + 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 9b371b69f..c6a94a48e 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1020,12 +1020,7 @@ namespace MWWorld facedObject = getFacedObject(getMaxActivationDistance() * 50, false); else { - float telekinesisRangeBonus = - mPlayer->getPlayer().getClass().getCreatureStats(mPlayer->getPlayer()).getMagicEffects() - .get(ESM::MagicEffect::Telekinesis).getMagnitude(); - telekinesisRangeBonus = feetToGameUnits(telekinesisRangeBonus); - - float activationDistance = getMaxActivationDistance() + telekinesisRangeBonus; + float activationDistance = getActivationDistancePlusTelekinesis(); facedObject = getFacedObject(activationDistance, true); @@ -2642,7 +2637,7 @@ namespace MWWorld // Get the target to use for "on touch" effects, using the facing direction from Head node MWWorld::Ptr target; - float distance = getMaxActivationDistance(); + float distance = getActivationDistancePlusTelekinesis(); osg::Vec3f hitPosition = actor.getRefData().getPosition().asVec3(); osg::Vec3f origin = getActorHeadTransform(actor).getTrans(); @@ -2674,11 +2669,15 @@ namespace MWWorld { target = result1.mHitObject; hitPosition = result1.mHitPos; + if (!target.isEmpty() && dist1 > getMaxActivationDistance() && !target.getClass().allowTelekinesis(target)) + target = NULL; } else if (result2.mHit) { target = result2.mHitObject; hitPosition = result2.mHitPointWorld; + if (!target.isEmpty() && dist2 > getMaxActivationDistance() && !target.getClass().allowTelekinesis(target)) + target = NULL; } // When targeting an actor that is in combat with an "on touch" spell, @@ -3011,6 +3010,18 @@ namespace MWWorld return feet * 22; } + float World::getActivationDistancePlusTelekinesis() + { + float telekinesisRangeBonus = + mPlayer->getPlayer().getClass().getCreatureStats(mPlayer->getPlayer()).getMagicEffects() + .get(ESM::MagicEffect::Telekinesis).getMagnitude(); + telekinesisRangeBonus = feetToGameUnits(telekinesisRangeBonus); + + float activationDistance = getMaxActivationDistance() + telekinesisRangeBonus; + + return activationDistance; + } + MWWorld::Ptr World::getPlayerPtr() { return mPlayer->getPlayer(); diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index 8774e549f..3508c0b46 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -168,6 +168,7 @@ namespace MWWorld int mDaysInPrison; float feetToGameUnits(float feet); + float getActivationDistancePlusTelekinesis(); MWWorld::ConstPtr getClosestMarker( const MWWorld::Ptr &ptr, const std::string &id ); MWWorld::ConstPtr getClosestMarkerFromExteriorPosition( const osg::Vec3f& worldPos, const std::string &id );