1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-03 17:37:18 +00:00
OpenMW/apps/openmw/mwmechanics/aibreathe.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

40 lines
1.2 KiB
C++
Raw Normal View History

#include "aibreathe.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/esmstore.hpp"
#include "npcstats.hpp"
#include "movement.hpp"
#include "steering.hpp"
bool MWMechanics::AiBreathe::execute(
const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration)
{
2018-08-29 15:38:12 +00:00
static const float fHoldBreathTime = MWBase::Environment::get()
.getWorld()
->getStore()
.get<ESM::GameSetting>()
.find("fHoldBreathTime")
->mValue.getFloat();
const MWWorld::Class& actorClass = actor.getClass();
if (actorClass.isNpc())
{
if (actorClass.getNpcStats(actor).getTimeToStartDrowning() < fHoldBreathTime / 2)
{
2018-11-02 11:24:43 +00:00
actorClass.getCreatureStats(actor).setMovementFlag(CreatureStats::Flag_Run, true);
2018-11-02 11:24:43 +00:00
actorClass.getMovementSettings(actor).mPosition[1] = 1;
smoothTurn(actor, static_cast<float>(-osg::PI_2), 0);
return false;
}
}
return true;
}