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:
parent
0b306bc1ea
commit
127366a948
1 changed files with 14 additions and 13 deletions
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue