mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-29 22:15:32 +00:00
Implement drowning when knocked out underwater (Fixes #1228)
This commit is contained in:
parent
d034a079e6
commit
60aa209144
3 changed files with 16 additions and 4 deletions
|
@ -869,13 +869,19 @@ namespace MWMechanics
|
|||
|
||||
void Actors::updateDrowning(const MWWorld::Ptr& ptr, float duration)
|
||||
{
|
||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||
PtrControllerMap::iterator it = mActors.find(ptr);
|
||||
if (it == mActors.end())
|
||||
return;
|
||||
CharacterController* ctrl = it->second;
|
||||
|
||||
NpcStats &stats = ptr.getClass().getNpcStats(ptr);
|
||||
if(world->isSubmerged(ptr) &&
|
||||
stats.getMagicEffects().get(ESM::MagicEffect::WaterBreathing).getMagnitude() == 0)
|
||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||
bool knockedOutUnderwater = (ctrl->isKnockedOut() && world->isUnderwater(ptr.getCell(), Ogre::Vector3(ptr.getRefData().getPosition().pos)));
|
||||
if((world->isSubmerged(ptr) || knockedOutUnderwater)
|
||||
&& stats.getMagicEffects().get(ESM::MagicEffect::WaterBreathing).getMagnitude() == 0)
|
||||
{
|
||||
float timeLeft = 0.0f;
|
||||
if(stats.getFatigue().getCurrent() == 0)
|
||||
if(knockedOutUnderwater)
|
||||
stats.setTimeToStartDrowning(0);
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1840,4 +1840,9 @@ bool CharacterController::isReadyToBlock() const
|
|||
return updateCarriedLeftVisible(mWeaponType);
|
||||
}
|
||||
|
||||
bool CharacterController::isKnockedOut() const
|
||||
{
|
||||
return mHitState == CharState_KnockOut;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -228,6 +228,7 @@ public:
|
|||
AiState& getAiState() { return mAiState; }
|
||||
|
||||
bool isReadyToBlock() const;
|
||||
bool isKnockedOut() const;
|
||||
};
|
||||
|
||||
void getWeaponGroup(WeaponType weaptype, std::string &group);
|
||||
|
|
Loading…
Reference in a new issue