1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-04 21:40:03 +00:00

Merge pull request #1072 from Allofich/range

Give "on touch" spells same range as vanilla MW
This commit is contained in:
scrawl 2016-09-21 17:39:44 +02:00 committed by GitHub
commit 8379291f70

View File

@ -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<ESM::GameSetting>().find("fCombatDistance")->getFloat());
if (distance < dist1 && distance < dist2)
target = NULL;
}
std::string selectedSpell = stats.getSpells().getSelectedSpell();
MWMechanics::CastSpell cast(actor, target);