1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-06-05 08:41:32 +00:00

Only allow trap distance check to apply to player

This commit is contained in:
Allofich 2016-07-07 22:10:38 +09:00
parent 7de3afaa7d
commit 0e5c3f781f

View file

@ -1,6 +1,7 @@
#include "actiontrap.hpp" #include "actiontrap.hpp"
#include "../mwmechanics/spellcasting.hpp" #include "../mwmechanics/spellcasting.hpp"
#include "../mwmechanics/actorutil.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
@ -17,13 +18,13 @@ namespace MWWorld
// radius, because for most trap spells this is 1 foot, much less than the activation distance. // radius, because for most trap spells this is 1 foot, much less than the activation distance.
// Using activation distance as the trap range. // Using activation distance as the trap range.
if (distance > trapRange) // actor activated object outside range of trap if (distance > trapRange && actor == MWMechanics::getPlayer()) // player activated object outside range of trap
{ {
MWMechanics::CastSpell cast(mTrapSource, mTrapSource); MWMechanics::CastSpell cast(mTrapSource, mTrapSource);
cast.mHitPosition = trapPosition; cast.mHitPosition = trapPosition;
cast.cast(mSpellId); cast.cast(mSpellId);
} }
else // actor activated object within range of trap else // player activated object within range of trap, or NPC activated trap
{ {
MWMechanics::CastSpell cast(mTrapSource, actor); MWMechanics::CastSpell cast(mTrapSource, actor);
cast.mHitPosition = actorPosition; cast.mHitPosition = actorPosition;