From 563ae479e879691622e6628606b23bd8452254cd Mon Sep 17 00:00:00 2001 From: Allofich Date: Wed, 21 Sep 2016 23:34:32 +0900 Subject: [PATCH] Give "on touch" spells same range as vanilla MW --- apps/openmw/mwworld/worldimp.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index b5ef7de52..73e0bdf06 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -2642,7 +2642,8 @@ namespace MWWorld // Get the target to use for "on touch" effects, using the facing direction from Head node MWWorld::Ptr target; - float distance = 192.f; // ?? + float distance = getMaxActivationDistance(); + osg::Vec3f hitPosition = actor.getRefData().getPosition().asVec3(); osg::Vec3f origin = getActorHeadTransform(actor).getTrans(); @@ -2680,6 +2681,16 @@ namespace MWWorld hitPosition = result2.mHitPointWorld; } + // When targeting an actor that is in combat with an "on touch" spell, + // compare against the minimum of activation distance and combat distance. + + if (!target.isEmpty() && target.getClass().isActor() && target.getClass().getCreatureStats (target).getAiSequence().isInCombat()) + { + distance = std::min (distance, getStore().get().find("fCombatDistance")->getFloat()); + if (distance < dist1 && distance < dist2) + target = NULL; + } + std::string selectedSpell = stats.getSpells().getSelectedSpell(); MWMechanics::CastSpell cast(actor, target);