mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-31 15:15:40 +00:00
Merge branch 'nevercruelorcowardly' into 'master'
Correct activation behavior for actors in combat (#7794) Closes #7794 See merge request OpenMW/openmw!3822
This commit is contained in:
commit
d36583bdec
4 changed files with 26 additions and 23 deletions
|
@ -139,6 +139,7 @@
|
|||
Bug #7770: Sword of the Perithia: Script execution failure
|
||||
Bug #7780: Non-ASCII texture paths in NIF files don't work
|
||||
Bug #7785: OpenMW-CS initialising Skill and Attribute fields to 0 instead of -1 on non-FortifyStat spells
|
||||
Bug #7794: Fleeing NPCs name tooltip doesn't appear
|
||||
Bug #7796: Absorbed enchantments don't restore magicka
|
||||
Feature #2566: Handle NAM9 records for manual cell references
|
||||
Feature #3537: Shader-based water ripples
|
||||
|
|
|
@ -474,20 +474,17 @@ namespace MWClass
|
|||
}
|
||||
|
||||
const MWMechanics::CreatureStats& stats = getCreatureStats(ptr);
|
||||
const MWMechanics::AiSequence& aiSequence = stats.getAiSequence();
|
||||
|
||||
const bool isInCombat = aiSequence.isInCombat();
|
||||
if (stats.isDead())
|
||||
{
|
||||
// by default user can loot friendly actors during death animation
|
||||
if (Settings::game().mCanLootDuringDeathAnimation && !isInCombat)
|
||||
// by default user can loot non-fighting actors during death animation
|
||||
if (Settings::game().mCanLootDuringDeathAnimation)
|
||||
return std::make_unique<MWWorld::ActionOpen>(ptr);
|
||||
|
||||
// otherwise wait until death animation
|
||||
if (stats.isDeathAnimationFinished())
|
||||
return std::make_unique<MWWorld::ActionOpen>(ptr);
|
||||
}
|
||||
else if ((!isInCombat || aiSequence.isFleeing()) && !stats.getKnockedDown())
|
||||
else if (!stats.getKnockedDown())
|
||||
return std::make_unique<MWWorld::ActionTalk>(ptr);
|
||||
|
||||
// Tribunal and some mod companions oddly enough must use open action as fallback
|
||||
|
|
|
@ -924,35 +924,38 @@ namespace MWClass
|
|||
}
|
||||
|
||||
const MWMechanics::CreatureStats& stats = getCreatureStats(ptr);
|
||||
const MWMechanics::AiSequence& aiSequence = stats.getAiSequence();
|
||||
const bool isPursuing = aiSequence.isInPursuit() && actor == MWMechanics::getPlayer();
|
||||
const bool inCombatWithActor = aiSequence.isInCombat(actor) || isPursuing;
|
||||
|
||||
if (stats.isDead())
|
||||
{
|
||||
// by default user can loot friendly actors during death animation
|
||||
if (Settings::game().mCanLootDuringDeathAnimation && !stats.getAiSequence().isInCombat())
|
||||
// by default user can loot non-fighting actors during death animation
|
||||
if (Settings::game().mCanLootDuringDeathAnimation)
|
||||
return std::make_unique<MWWorld::ActionOpen>(ptr);
|
||||
|
||||
// otherwise wait until death animation
|
||||
if (stats.isDeathAnimationFinished())
|
||||
return std::make_unique<MWWorld::ActionOpen>(ptr);
|
||||
}
|
||||
else if (!stats.getAiSequence().isInCombat())
|
||||
else
|
||||
{
|
||||
if (stats.getKnockedDown() || MWBase::Environment::get().getMechanicsManager()->isSneaking(actor))
|
||||
return std::make_unique<MWWorld::ActionOpen>(ptr); // stealing
|
||||
const bool allowStealingFromKO
|
||||
= Settings::game().mAlwaysAllowStealingFromKnockedOutActors || !inCombatWithActor;
|
||||
if (stats.getKnockedDown() && allowStealingFromKO)
|
||||
return std::make_unique<MWWorld::ActionOpen>(ptr);
|
||||
|
||||
// Can't talk to werewolves
|
||||
if (!getNpcStats(ptr).isWerewolf())
|
||||
const bool allowStealingWhileSneaking = !inCombatWithActor;
|
||||
if (MWBase::Environment::get().getMechanicsManager()->isSneaking(actor) && allowStealingWhileSneaking)
|
||||
return std::make_unique<MWWorld::ActionOpen>(ptr);
|
||||
|
||||
const bool allowTalking = !inCombatWithActor && !getNpcStats(ptr).isWerewolf();
|
||||
if (allowTalking)
|
||||
return std::make_unique<MWWorld::ActionTalk>(ptr);
|
||||
}
|
||||
else // In combat
|
||||
{
|
||||
if (Settings::game().mAlwaysAllowStealingFromKnockedOutActors && stats.getKnockedDown())
|
||||
return std::make_unique<MWWorld::ActionOpen>(ptr); // stealing
|
||||
}
|
||||
|
||||
// Tribunal and some mod companions oddly enough must use open action as fallback
|
||||
if (!getScript(ptr).empty() && ptr.getRefData().getLocals().getIntVar(getScript(ptr), "companion"))
|
||||
return std::make_unique<MWWorld::ActionOpen>(ptr);
|
||||
if (inCombatWithActor)
|
||||
return std::make_unique<MWWorld::FailedAction>("#{sActorInCombat}");
|
||||
|
||||
return std::make_unique<MWWorld::FailedAction>();
|
||||
}
|
||||
|
@ -1086,7 +1089,8 @@ namespace MWClass
|
|||
if (customData.mNpcStats.isDead() && customData.mNpcStats.isDeathAnimationFinished())
|
||||
return true;
|
||||
|
||||
if (!customData.mNpcStats.getAiSequence().isInCombat())
|
||||
const MWMechanics::AiSequence& aiSeq = customData.mNpcStats.getAiSequence();
|
||||
if (!aiSeq.isInCombat() || aiSeq.isFleeing())
|
||||
return true;
|
||||
|
||||
if (Settings::game().mAlwaysAllowStealingFromKnockedOutActors && customData.mNpcStats.getKnockedDown())
|
||||
|
|
|
@ -1309,7 +1309,8 @@ namespace MWMechanics
|
|||
if (inProcessingRange)
|
||||
{
|
||||
MWMechanics::CreatureStats& stats = actor.getPtr().getClass().getCreatureStats(actor.getPtr());
|
||||
if (!stats.isDead() && stats.getAiSequence().isInCombat())
|
||||
bool isDead = stats.isDead() && stats.isDeathAnimationFinished();
|
||||
if (!isDead && stats.getAiSequence().isInCombat())
|
||||
{
|
||||
hasHostiles = true;
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue