Merge pull request #2534 from akortunov/toggleview

Improve resurrection handling
pull/2453/head
Alexei Dobrohotov 5 years ago committed by GitHub
commit ac5491b5c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -225,7 +225,7 @@ namespace MWBase
virtual bool isAggressive (const MWWorld::Ptr& ptr, const MWWorld::Ptr& target) = 0;
/// Resurrects the player if necessary
virtual void keepPlayerAlive() = 0;
virtual void resurrect(const MWWorld::Ptr& ptr) = 0;
virtual bool isCastingSpell (const MWWorld::Ptr& ptr) const = 0;
virtual bool isReadyToBlock (const MWWorld::Ptr& ptr) const = 0;

@ -1637,6 +1637,20 @@ namespace MWMechanics
++mDeathCount[Misc::StringUtils::lowerCase(actor.getCellRef().getRefId())];
}
void Actors::resurrect(const MWWorld::Ptr &ptr)
{
PtrActorMap::iterator iter = mActors.find(ptr);
if(iter != mActors.end())
{
if(iter->second->getCharacterController()->isDead())
{
// Actor has been resurrected. Notify the CharacterController and re-enable collision.
MWBase::Environment::get().getWorld()->enableActorCollision(iter->first, true);
iter->second->getCharacterController()->resurrect();
}
}
}
void Actors::killDeadActors()
{
for(PtrActorMap::iterator iter(mActors.begin()); iter != mActors.end(); ++iter)
@ -1645,17 +1659,7 @@ namespace MWMechanics
CreatureStats &stats = cls.getCreatureStats(iter->first);
if(!stats.isDead())
{
if(iter->second->getCharacterController()->isDead())
{
// Actor has been resurrected. Notify the CharacterController and re-enable collision.
MWBase::Environment::get().getWorld()->enableActorCollision(iter->first, true);
iter->second->getCharacterController()->resurrect();
}
if(!stats.isDead())
continue;
}
continue;
MWBase::Environment::get().getWorld()->removeActorPath(iter->first);
CharacterController::KillResult killResult = iter->second->getCharacterController()->kill();

@ -94,6 +94,8 @@ namespace MWMechanics
///
/// \note Ignored, if \a ptr is not a registered actor.
void resurrect (const MWWorld::Ptr& ptr);
void castSpell(const MWWorld::Ptr& ptr, const std::string spellId, bool manualSpell=false);
void updateActor(const MWWorld::Ptr &old, const MWWorld::Ptr& ptr);

@ -198,9 +198,6 @@ namespace MWMechanics
mDynamic[index].setModifier(0);
mDynamic[index].setCurrentModifier(0);
mDynamic[index].setCurrent(0);
if (MWBase::Environment::get().getWorld()->getGodModeState())
MWBase::Environment::get().getMechanicsManager()->keepPlayerAlive();
}
}

@ -1820,12 +1820,14 @@ namespace MWMechanics
return (fight >= 100);
}
void MechanicsManager::keepPlayerAlive()
void MechanicsManager::resurrect(const MWWorld::Ptr &ptr)
{
MWWorld::Ptr player = getPlayer();
CreatureStats& stats = player.getClass().getCreatureStats(player);
CreatureStats& stats = ptr.getClass().getCreatureStats(ptr);
if (stats.isDead())
{
stats.resurrect();
mActors.resurrect(ptr);
}
}
bool MechanicsManager::isCastingSpell(const MWWorld::Ptr &ptr) const

@ -197,7 +197,7 @@ namespace MWMechanics
virtual bool isAggressive (const MWWorld::Ptr& ptr, const MWWorld::Ptr& target) override;
virtual void keepPlayerAlive() override;
virtual void resurrect(const MWWorld::Ptr& ptr) override;
virtual bool isCastingSpell (const MWWorld::Ptr& ptr) const override;

@ -1184,7 +1184,7 @@ namespace MWScript
if (ptr == MWMechanics::getPlayer())
{
ptr.getClass().getCreatureStats(ptr).resurrect();
MWBase::Environment::get().getMechanicsManager()->resurrect(ptr);
if (MWBase::Environment::get().getStateManager()->getState() == MWBase::StateManager::State_Ended)
MWBase::Environment::get().getStateManager()->resumeGame();
}

Loading…
Cancel
Save