forked from mirror/openmw-tes3mp
Cleanups and fixes
parent
199607423b
commit
c02695e56d
@ -1,40 +1,36 @@
|
|||||||
#include "actiontrap.hpp"
|
#include "actiontrap.hpp"
|
||||||
|
|
||||||
#include "../mwmechanics/spellcasting.hpp"
|
#include "../mwmechanics/spellcasting.hpp"
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
|
|
||||||
namespace MWWorld
|
namespace MWWorld
|
||||||
{
|
{
|
||||||
|
|
||||||
void ActionTrap::executeImp(const Ptr &actor, float distance)
|
void ActionTrap::executeImp(const Ptr &actor, float distance)
|
||||||
{
|
{
|
||||||
osg::Vec3f actorPosition(actor.getRefData().getPosition().asVec3());
|
osg::Vec3f actorPosition(actor.getRefData().getPosition().asVec3());
|
||||||
osg::Vec3f trapPosition(mTrapSource.getRefData().getPosition().asVec3());
|
osg::Vec3f trapPosition(mTrapSource.getRefData().getPosition().asVec3());
|
||||||
float activationDistance = MWBase::Environment::get().getWorld()->getMaxActivationDistance();
|
float activationDistance = MWBase::Environment::get().getWorld()->getMaxActivationDistance();
|
||||||
|
|
||||||
// GUI calcs if object in activation distance include object and player geometry
|
// Note: can't just detonate the trap at the trapped object's location and use the blast
|
||||||
//const float fudgeFactor = 1.25f;
|
|
||||||
|
|
||||||
// Hack: if actor is beyond activation range, then assume actor is using telekinesis
|
|
||||||
// to open door/container.
|
|
||||||
// Note, can't just detonate the trap at the trapped object's location and use the blast
|
|
||||||
// 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 the activation distance as the trap range.
|
||||||
|
|
||||||
if (distance < activationDistance)
|
if (distance < activationDistance)
|
||||||
{
|
{
|
||||||
// assume actor touched trap
|
// actor activated object within range of trap
|
||||||
MWMechanics::CastSpell cast(mTrapSource, actor);
|
MWMechanics::CastSpell cast(mTrapSource, actor);
|
||||||
cast.mHitPosition = actorPosition;
|
cast.mHitPosition = actorPosition;
|
||||||
cast.cast(mSpellId);
|
cast.cast(mSpellId);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// assume telekinesis used
|
// actor 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);
|
||||||
}
|
}
|
||||||
mTrapSource.getCellRef().setTrap("");
|
mTrapSource.getCellRef().setTrap("");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue