mirror of
https://github.com/OpenMW/openmw.git
synced 2025-05-06 09:11:24 +00:00
Fix running AI for dead actors
This commit is contained in:
parent
f11ec653d0
commit
2ac4a74a34
2 changed files with 15 additions and 8 deletions
|
@ -42,6 +42,12 @@
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
|
bool isConscious(const MWWorld::Ptr& ptr)
|
||||||
|
{
|
||||||
|
const MWMechanics::CreatureStats& stats = ptr.getClass().getCreatureStats(ptr);
|
||||||
|
return !stats.isDead() && !stats.getKnockedDown();
|
||||||
|
}
|
||||||
|
|
||||||
void adjustBoundItem (const std::string& item, bool bound, const MWWorld::Ptr& actor)
|
void adjustBoundItem (const std::string& item, bool bound, const MWWorld::Ptr& actor)
|
||||||
{
|
{
|
||||||
if (bound)
|
if (bound)
|
||||||
|
@ -1101,12 +1107,12 @@ namespace MWMechanics
|
||||||
updateCrimePersuit(iter->first, duration);
|
updateCrimePersuit(iter->first, duration);
|
||||||
|
|
||||||
if (iter->first != player)
|
if (iter->first != player)
|
||||||
iter->first.getClass().getCreatureStats(iter->first).getAiSequence().execute(iter->first,iter->second->getAiState(), duration);
|
|
||||||
|
|
||||||
CreatureStats &stats = iter->first.getClass().getCreatureStats(iter->first);
|
|
||||||
if(!stats.isDead())
|
|
||||||
{
|
{
|
||||||
if (stats.getAiSequence().isInCombat()) hostilesCount++;
|
CreatureStats &stats = iter->first.getClass().getCreatureStats(iter->first);
|
||||||
|
if (isConscious(iter->first))
|
||||||
|
stats.getAiSequence().execute(iter->first,iter->second->getAiState(), duration);
|
||||||
|
|
||||||
|
if (stats.getAiSequence().isInCombat() && !stats.isDead()) hostilesCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1515,7 +1521,9 @@ namespace MWMechanics
|
||||||
for (PtrActorMap::iterator it = map.begin(); it != map.end(); ++it)
|
for (PtrActorMap::iterator it = map.begin(); it != map.end(); ++it)
|
||||||
{
|
{
|
||||||
MWWorld::Ptr ptr = it->first;
|
MWWorld::Ptr ptr = it->first;
|
||||||
if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr()
|
||||||
|
|| !isConscious(ptr)
|
||||||
|
|| ptr.getClass().getCreatureStats(ptr).getMagicEffects().get(ESM::MagicEffect::Paralyze).getMagnitude() > 0)
|
||||||
continue;
|
continue;
|
||||||
MWMechanics::AiSequence& seq = ptr.getClass().getCreatureStats(ptr).getAiSequence();
|
MWMechanics::AiSequence& seq = ptr.getClass().getCreatureStats(ptr).getAiSequence();
|
||||||
seq.fastForward(ptr, it->second->getAiState());
|
seq.fastForward(ptr, it->second->getAiState());
|
||||||
|
|
|
@ -152,8 +152,7 @@ bool AiSequence::isPackageDone() const
|
||||||
|
|
||||||
void AiSequence::execute (const MWWorld::Ptr& actor, AiState& state,float duration)
|
void AiSequence::execute (const MWWorld::Ptr& actor, AiState& state,float duration)
|
||||||
{
|
{
|
||||||
if(actor != MWBase::Environment::get().getWorld()->getPlayerPtr()
|
if(actor != MWBase::Environment::get().getWorld()->getPlayerPtr())
|
||||||
&& !actor.getClass().getCreatureStats(actor).getKnockedDown())
|
|
||||||
{
|
{
|
||||||
if (!mPackages.empty())
|
if (!mPackages.empty())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue