1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-05-06 10:11:24 +00:00

Restructure function updateDrowning

This commit is contained in:
ζeh Matt 2022-03-28 16:38:39 +03:00
parent 0b306bc1ea
commit 127366a948
No known key found for this signature in database
GPG key ID: 18CE582C71A225B0

View file

@ -801,7 +801,8 @@ namespace MWMechanics
void Actors::updateDrowning(const MWWorld::Ptr& ptr, float duration, bool isKnockedOut, bool isPlayer)
{
NpcStats &stats = ptr.getClass().getNpcStats(ptr);
auto& actorClass = ptr.getClass();
NpcStats& stats = actorClass.getNpcStats(ptr);
// When npc stats are just initialized, mTimeToStartDrowning == -1 and we should get value from GMST
static const float fHoldBreathTime = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fHoldBreathTime")->mValue.getFloat();
@ -810,7 +811,7 @@ namespace MWMechanics
if (!isPlayer && stats.getTimeToStartDrowning() < fHoldBreathTime / 2)
{
AiSequence& seq = ptr.getClass().getCreatureStats(ptr).getAiSequence();
AiSequence& seq = actorClass.getCreatureStats(ptr).getAiSequence();
if (seq.getTypeId() != AiPackageTypeId::Breathe) //Only add it once
seq.stack(AiBreathe(), ptr);
}
@ -831,7 +832,7 @@ namespace MWMechanics
stats.setTimeToStartDrowning(timeLeft);
}
bool godmode = isPlayer && MWBase::Environment::get().getWorld()->getGodModeState();
bool godmode = isPlayer && world->getGodModeState();
if (timeLeft == 0.0f && !godmode)
{