1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-26 18:35:20 +00:00
OpenMW/apps/openmw/mwmechanics/actorutil.cpp
Mads Buvik Sandvei 410e8b100a Elsid comments
2023-05-23 19:30:29 +02:00

45 lines
1.4 KiB
C++

#include "actorutil.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/player.hpp"
#include "../mwmechanics/creaturestats.hpp"
#include "../mwmechanics/magiceffects.hpp"
#include <components/esm3/loadmgef.hpp>
namespace MWMechanics
{
MWWorld::Ptr getPlayer()
{
return MWBase::Environment::get().getWorld()->getPlayerPtr();
}
bool isPlayerInCombat()
{
return MWBase::Environment::get().getWorld()->getPlayer().isInCombat();
}
bool canActorMoveByZAxis(const MWWorld::Ptr& actor)
{
MWBase::World* world = MWBase::Environment::get().getWorld();
return (actor.getClass().canSwim(actor) && world->isSwimming(actor)) || world->isFlying(actor);
}
bool hasWaterWalking(const MWWorld::Ptr& actor)
{
const MWMechanics::MagicEffects& effects = actor.getClass().getCreatureStats(actor).getMagicEffects();
return effects.getOrDefault(ESM::MagicEffect::WaterWalking).getMagnitude() > 0;
}
bool isTargetMagicallyHidden(const MWWorld::Ptr& actor)
{
const MagicEffects& magicEffects = actor.getClass().getCreatureStats(actor).getMagicEffects();
return (magicEffects.getOrDefault(ESM::MagicEffect::Invisibility).getMagnitude() > 0)
|| (magicEffects.getOrDefault(ESM::MagicEffect::Chameleon).getMagnitude() > 75);
}
}