From 28185e20174b994b28cbc52cb636219781eff654 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 25 Jan 2014 15:54:24 +0100 Subject: [PATCH] Death/godmode fixes: Revive player *after* character update, since there might be fall damage. --- apps/openmw/engine.cpp | 12 ++++---- apps/openmw/mwmechanics/actors.cpp | 40 ++++++++++++++------------- apps/openmw/mwmechanics/character.cpp | 1 - 3 files changed, 28 insertions(+), 25 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index b2c0c1968d..66dea4f1d0 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -89,6 +89,8 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt) if (mUseSound) MWBase::Environment::get().getSoundManager()->update(frametime); + bool paused = MWBase::Environment::get().getWindowManager()->isGuiMode(); + if (MWBase::Environment::get().getStateManager()->getState()== MWBase::StateManager::State_Running) { @@ -105,7 +107,7 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt) if (changed) // keep change flag for another frame, if cell changed happened in local script MWBase::Environment::get().getWorld()->markCellAsUnchanged(); - if (!MWBase::Environment::get().getWindowManager()->isGuiMode()) + if (!paused) MWBase::Environment::get().getWorld()->advanceTime( frametime*MWBase::Environment::get().getWorld()->getTimeScaleFactor()/3600); @@ -116,18 +118,18 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt) // update actors MWBase::Environment::get().getMechanicsManager()->update(frametime, - MWBase::Environment::get().getWindowManager()->isGuiMode()); + paused); if (MWBase::Environment::get().getStateManager()->getState()== MWBase::StateManager::State_Running) { - MWWorld::Ptr player = mEnvironment.getWorld()->getPlayer().getPlayer(); - if(MWWorld::Class::get(player).getCreatureStats(player).isDead()) + MWWorld::Ptr player = mEnvironment.getWorld()->getPlayerPtr(); + if(!paused && player.getClass().getCreatureStats(player).isDead()) MWBase::Environment::get().getStateManager()->endGame(); } // update world - MWBase::Environment::get().getWorld()->update(frametime, MWBase::Environment::get().getWindowManager()->isGuiMode()); + MWBase::Environment::get().getWorld()->update(frametime, paused); // update GUI Ogre::RenderWindow* window = mOgre->getWindow(); diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 51e91a9546..34cfe16fa2 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -771,6 +771,24 @@ namespace MWMechanics void Actors::update (float duration, bool paused) { + if(!paused) + { + // Note: we need to do this before any of the animations are updated. + // Reaching the text keys may trigger Hit / Spellcast (and as such, particles), + // so updating VFX immediately after that would just remove the particle effects instantly. + // There needs to be a magic effect update in between. + for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();++iter) + iter->second->updateContinuousVfx(); + + for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();++iter) + { + if (iter->first.getClass().getCreatureStats(iter->first).getMagicEffects().get( + ESM::MagicEffect::Paralyze).mMagnitude > 0) + iter->second->skipAnim(); + iter->second->update(duration); + } + } + if (!paused) { for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();iter++) @@ -804,7 +822,6 @@ namespace MWMechanics stat.setModified(1, 0); stats.setHealth(stat); } - stats.resurrect(); continue; } @@ -818,6 +835,9 @@ namespace MWMechanics spells.purge(iter->first.getRefData().getHandle()); } + // FIXME: see http://bugs.openmw.org/issues/869 + MWBase::Environment::get().getWorld()->enableActorCollision(iter->first, false); + if (iter->second->kill()) { ++mDeathCount[cls.getId(iter->first)]; @@ -839,24 +859,6 @@ namespace MWMechanics } } } - - if(!paused) - { - // Note: we need to do this before any of the animations are updated. - // Reaching the text keys may trigger Hit / Spellcast (and as such, particles), - // so updating VFX immediately after that would just remove the particle effects instantly. - // There needs to be a magic effect update in between. - for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();++iter) - iter->second->updateContinuousVfx(); - - for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();++iter) - { - if (iter->first.getClass().getCreatureStats(iter->first).getMagicEffects().get( - ESM::MagicEffect::Paralyze).mMagnitude > 0) - iter->second->skipAnim(); - iter->second->update(duration); - } - } } void Actors::restoreDynamicStats(bool sleep) { diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index ee0d077317..40e6cde69b 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -1153,7 +1153,6 @@ void CharacterController::update(float duration) } else if(cls.getCreatureStats(mPtr).isDead()) { - MWBase::Environment::get().getWorld()->enableActorCollision(mPtr, false); world->queueMovement(mPtr, Ogre::Vector3(0.0f)); }