2015-08-21 21:12:39 +12:00
|
|
|
#include "actorutil.hpp"
|
|
|
|
|
|
|
|
#include "../mwbase/environment.hpp"
|
|
|
|
#include "../mwbase/world.hpp"
|
|
|
|
|
2019-06-05 11:40:38 +03:00
|
|
|
#include "../mwworld/class.hpp"
|
2015-09-10 18:48:34 +12:00
|
|
|
#include "../mwworld/player.hpp"
|
|
|
|
|
2022-07-16 16:37:31 +02:00
|
|
|
#include "../mwmechanics/creaturestats.hpp"
|
|
|
|
#include "../mwmechanics/magiceffects.hpp"
|
|
|
|
|
2022-06-26 16:42:29 +02:00
|
|
|
#include <components/esm3/loadmgef.hpp>
|
|
|
|
|
2015-08-21 21:12:39 +12:00
|
|
|
namespace MWMechanics
|
|
|
|
{
|
|
|
|
MWWorld::Ptr getPlayer()
|
|
|
|
{
|
|
|
|
return MWBase::Environment::get().getWorld()->getPlayerPtr();
|
|
|
|
}
|
2015-09-10 18:48:34 +12:00
|
|
|
|
|
|
|
bool isPlayerInCombat()
|
|
|
|
{
|
|
|
|
return MWBase::Environment::get().getWorld()->getPlayer().isInCombat();
|
|
|
|
}
|
2019-06-05 11:40:38 +03:00
|
|
|
|
|
|
|
bool canActorMoveByZAxis(const MWWorld::Ptr& actor)
|
|
|
|
{
|
|
|
|
MWBase::World* world = MWBase::Environment::get().getWorld();
|
|
|
|
return (actor.getClass().canSwim(actor) && world->isSwimming(actor)) || world->isFlying(actor);
|
|
|
|
}
|
2021-04-11 19:17:23 +02:00
|
|
|
|
|
|
|
bool hasWaterWalking(const MWWorld::Ptr& actor)
|
|
|
|
{
|
|
|
|
const MWMechanics::MagicEffects& effects = actor.getClass().getCreatureStats(actor).getMagicEffects();
|
2023-05-23 19:06:08 +02:00
|
|
|
return effects.getOrDefault(ESM::MagicEffect::WaterWalking).getMagnitude() > 0;
|
2021-04-11 19:17:23 +02:00
|
|
|
}
|
2022-07-29 10:47:50 +03:00
|
|
|
|
|
|
|
bool isTargetMagicallyHidden(const MWWorld::Ptr& actor)
|
|
|
|
{
|
|
|
|
const MagicEffects& magicEffects = actor.getClass().getCreatureStats(actor).getMagicEffects();
|
2023-05-23 19:06:08 +02:00
|
|
|
return (magicEffects.getOrDefault(ESM::MagicEffect::Invisibility).getMagnitude() > 0)
|
2023-11-07 02:59:37 +00:00
|
|
|
|| (magicEffects.getOrDefault(ESM::MagicEffect::Chameleon).getMagnitude() >= 75);
|
2022-07-29 10:47:50 +03:00
|
|
|
}
|
2015-08-21 21:12:39 +12:00
|
|
|
}
|