diff --git a/AUTHORS.md b/AUTHORS.md index 204d45258..2a43168e6 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -17,7 +17,7 @@ Programmers aegis Aleksandar Jovanov Alex Haddad (rainChu) - Alex McKibben (WeirdSexy) + Alex McKibben alexanderkjall Alexander Nadeau (wareya) Alexander Olofsson (Ace) @@ -159,7 +159,6 @@ Packagers Public Relations and Translations --------------------------------- - Alex McKibben (WeirdSexy) - Podcaster Artem Kotsynyak (greye) - Russian News Writer Jim Clauwaert (Zedd) - Public Outreach Julien Voisin (jvoisin/ap0) - French News Writer diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 8d7a7a652..e67cbf8e7 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1030,12 +1030,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); @@ -2663,7 +2658,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 = getActivationDistancePlusTelekinesis(); + osg::Vec3f hitPosition = actor.getRefData().getPosition().asVec3(); osg::Vec3f origin = getActorHeadTransform(actor).getTrans(); @@ -2694,11 +2690,25 @@ namespace MWWorld { target = result1.mHitObject; hitPosition = result1.mHitPos; + if (dist1 > getMaxActivationDistance() && !target.isEmpty() && (target.getClass().isActor() || !target.getClass().canBeActivated(target))) + target = NULL; } else if (result2.mHit) { target = result2.mHitObject; hitPosition = result2.mHitPointWorld; + if (dist2 > getMaxActivationDistance() && !target.isEmpty() && (target.getClass().isActor() || !target.getClass().canBeActivated(target))) + target = NULL; + } + + // 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(); @@ -3021,6 +3031,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(); @@ -3186,6 +3208,9 @@ namespace MWWorld if (effectIt->mRange != rangeType || (effectIt->mArea <= 0 && !ignore.isEmpty() && ignore.getClass().isActor())) continue; // Not right range type, or not area effect and hit an actor + if (effectIt->mRange == ESM::RT_Touch && (!ignore.isEmpty()) && (!ignore.getClass().isActor() && !ignore.getClass().canBeActivated(ignore))) + continue; // Don't play explosion for touch spells on non-activatable objects + // Spawn the explosion orb effect const ESM::Static* areaStatic; if (!effect->mArea.empty()) @@ -3197,7 +3222,8 @@ namespace MWWorld if (effectIt->mArea <= 0) { - mRendering->spawnEffect("meshes\\" + areaStatic->mModel, texture, origin, 1.0f); + if (effectIt->mRange == ESM::RT_Target) + mRendering->spawnEffect("meshes\\" + areaStatic->mModel, texture, origin, 1.0f); continue; } else 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 );