2015-08-25 18:19:16 +12:00
|
|
|
#include "actor.hpp"
|
2015-08-24 19:54:02 +12:00
|
|
|
|
2022-01-22 15:58:41 +01:00
|
|
|
#include <components/esm3/loadmgef.hpp>
|
2015-08-24 19:54:02 +12:00
|
|
|
|
|
|
|
#include "../mwbase/environment.hpp"
|
2023-10-01 11:22:20 +02:00
|
|
|
#include "../mwbase/luamanager.hpp"
|
2015-08-24 19:54:02 +12:00
|
|
|
#include "../mwbase/soundmanager.hpp"
|
|
|
|
#include "../mwbase/world.hpp"
|
|
|
|
|
2020-10-09 21:30:24 +03:00
|
|
|
#include "../mwmechanics/actorutil.hpp"
|
2015-08-24 19:54:02 +12:00
|
|
|
#include "../mwmechanics/creaturestats.hpp"
|
|
|
|
#include "../mwmechanics/magiceffects.hpp"
|
|
|
|
#include "../mwmechanics/movement.hpp"
|
|
|
|
|
|
|
|
#include "../mwphysics/physicssystem.hpp"
|
|
|
|
|
|
|
|
#include "../mwworld/inventorystore.hpp"
|
2023-10-01 11:22:20 +02:00
|
|
|
#include "../mwworld/worldmodel.hpp"
|
2015-08-24 19:54:02 +12:00
|
|
|
|
|
|
|
namespace MWClass
|
|
|
|
{
|
2015-08-25 18:19:16 +12:00
|
|
|
void Actor::adjustPosition(const MWWorld::Ptr& ptr, bool force) const
|
2015-08-24 19:54:02 +12:00
|
|
|
{
|
|
|
|
MWBase::Environment::get().getWorld()->adjustPosition(ptr, force);
|
|
|
|
}
|
|
|
|
|
2021-09-30 22:58:16 +02:00
|
|
|
void Actor::insertObject(const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation,
|
|
|
|
MWPhysics::PhysicsSystem& physics) const
|
2015-08-24 19:54:02 +12:00
|
|
|
{
|
2022-04-03 17:38:33 +00:00
|
|
|
physics.addActor(ptr, model);
|
|
|
|
if (getCreatureStats(ptr).isDead() && getCreatureStats(ptr).isDeathAnimationFinished())
|
|
|
|
MWBase::Environment::get().getWorld()->enableActorCollision(ptr, false);
|
2017-02-20 19:04:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Actor::useAnim() const
|
|
|
|
{
|
|
|
|
return true;
|
2015-08-24 19:54:02 +12:00
|
|
|
}
|
|
|
|
|
2015-08-25 18:19:16 +12:00
|
|
|
osg::Vec3f Actor::getRotationVector(const MWWorld::Ptr& ptr) const
|
2015-08-24 19:54:02 +12:00
|
|
|
{
|
|
|
|
MWMechanics::Movement& movement = getMovementSettings(ptr);
|
|
|
|
osg::Vec3f vec(movement.mRotation[0], movement.mRotation[1], movement.mRotation[2]);
|
|
|
|
movement.mRotation[0] = 0.0f;
|
|
|
|
movement.mRotation[1] = 0.0f;
|
|
|
|
movement.mRotation[2] = 0.0f;
|
|
|
|
return vec;
|
|
|
|
}
|
|
|
|
|
2015-08-25 18:19:16 +12:00
|
|
|
float Actor::getEncumbrance(const MWWorld::Ptr& ptr) const
|
2015-08-24 19:54:02 +12:00
|
|
|
{
|
|
|
|
float weight = getContainerStore(ptr).getWeight();
|
|
|
|
const MWMechanics::MagicEffects& effects = getCreatureStats(ptr).getMagicEffects();
|
2023-05-23 19:06:08 +02:00
|
|
|
weight -= effects.getOrDefault(MWMechanics::EffectKey(ESM::MagicEffect::Feather)).getMagnitude();
|
2020-10-09 21:30:24 +03:00
|
|
|
if (ptr != MWMechanics::getPlayer() || !MWBase::Environment::get().getWorld()->getGodModeState())
|
2023-05-23 19:06:08 +02:00
|
|
|
weight += effects.getOrDefault(MWMechanics::EffectKey(ESM::MagicEffect::Burden)).getMagnitude();
|
2015-08-24 19:54:02 +12:00
|
|
|
return (weight < 0) ? 0.0f : weight;
|
|
|
|
}
|
2016-07-07 00:03:14 +09:00
|
|
|
|
|
|
|
bool Actor::allowTelekinesis(const MWWorld::ConstPtr& ptr) const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2016-09-15 16:47:50 +02:00
|
|
|
|
|
|
|
bool Actor::isActor() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2020-08-27 11:48:59 +00:00
|
|
|
|
|
|
|
float Actor::getCurrentSpeed(const MWWorld::Ptr& ptr) const
|
|
|
|
{
|
|
|
|
const MWMechanics::Movement& movementSettings = ptr.getClass().getMovementSettings(ptr);
|
|
|
|
float moveSpeed = this->getMaxSpeed(ptr) * movementSettings.mSpeedFactor;
|
|
|
|
if (movementSettings.mIsStrafing)
|
|
|
|
moveSpeed *= 0.75f;
|
|
|
|
return moveSpeed;
|
|
|
|
}
|
2023-10-01 11:22:20 +02:00
|
|
|
|
|
|
|
bool Actor::consume(const MWWorld::Ptr& consumable, const MWWorld::Ptr& actor) const
|
|
|
|
{
|
|
|
|
MWMechanics::CastSpell cast(actor, actor);
|
|
|
|
const ESM::RefId& recordId = consumable.getCellRef().getRefId();
|
|
|
|
MWBase::Environment::get().getWorldModel()->registerPtr(consumable);
|
|
|
|
MWBase::Environment::get().getLuaManager()->itemConsumed(consumable, actor);
|
|
|
|
actor.getClass().getContainerStore(actor).remove(consumable, 1);
|
2023-10-30 15:30:01 +03:00
|
|
|
if (cast.cast(recordId))
|
|
|
|
{
|
|
|
|
MWBase::Environment::get().getWorld()->breakInvisibility(actor);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2023-10-01 11:22:20 +02:00
|
|
|
}
|
2015-08-24 19:54:02 +12:00
|
|
|
}
|