mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-09-08 03:41:11 -04:00
Merge branch 'combatparalysis' into 'master'
Put combat actions on hold when the actor is incapacitated (#7979) Closes #7979 See merge request OpenMW/openmw!4597
This commit is contained in:
commit
7aeff7e473
@ -178,11 +178,16 @@ namespace MWMechanics
|
|||||||
currentCell = actor.getCell();
|
currentCell = actor.getCell();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const MWWorld::Class& actorClass = actor.getClass();
|
||||||
|
MWMechanics::CreatureStats& stats = actorClass.getCreatureStats(actor);
|
||||||
|
if (stats.isParalyzed() || stats.getKnockedDown())
|
||||||
|
return false;
|
||||||
|
|
||||||
bool forceFlee = false;
|
bool forceFlee = false;
|
||||||
if (!canFight(actor, target))
|
if (!canFight(actor, target))
|
||||||
{
|
{
|
||||||
storage.stopAttack();
|
storage.stopAttack();
|
||||||
actor.getClass().getCreatureStats(actor).setAttackingOrSpell(false);
|
stats.setAttackingOrSpell(false);
|
||||||
storage.mActionCooldown = 0.f;
|
storage.mActionCooldown = 0.f;
|
||||||
// Continue combat if target is player or player follower/escorter and an attack has been attempted
|
// Continue combat if target is player or player follower/escorter and an attack has been attempted
|
||||||
const auto& playerFollowersAndEscorters
|
const auto& playerFollowersAndEscorters
|
||||||
@ -191,18 +196,14 @@ namespace MWMechanics
|
|||||||
= (std::find(playerFollowersAndEscorters.begin(), playerFollowersAndEscorters.end(), target)
|
= (std::find(playerFollowersAndEscorters.begin(), playerFollowersAndEscorters.end(), target)
|
||||||
!= playerFollowersAndEscorters.end());
|
!= playerFollowersAndEscorters.end());
|
||||||
if ((target == MWMechanics::getPlayer() || targetSidesWithPlayer)
|
if ((target == MWMechanics::getPlayer() || targetSidesWithPlayer)
|
||||||
&& ((actor.getClass().getCreatureStats(actor).getHitAttemptActorId()
|
&& ((stats.getHitAttemptActorId() == target.getClass().getCreatureStats(target).getActorId())
|
||||||
== target.getClass().getCreatureStats(target).getActorId())
|
|| (target.getClass().getCreatureStats(target).getHitAttemptActorId() == stats.getActorId())))
|
||||||
|| (target.getClass().getCreatureStats(target).getHitAttemptActorId()
|
|
||||||
== actor.getClass().getCreatureStats(actor).getActorId())))
|
|
||||||
forceFlee = true;
|
forceFlee = true;
|
||||||
else // Otherwise end combat
|
else // Otherwise end combat
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const MWWorld::Class& actorClass = actor.getClass();
|
stats.setMovementFlag(CreatureStats::Flag_Run, true);
|
||||||
actorClass.getCreatureStats(actor).setMovementFlag(CreatureStats::Flag_Run, true);
|
|
||||||
|
|
||||||
float& actionCooldown = storage.mActionCooldown;
|
float& actionCooldown = storage.mActionCooldown;
|
||||||
std::unique_ptr<Action>& currentAction = storage.mCurrentAction;
|
std::unique_ptr<Action>& currentAction = storage.mCurrentAction;
|
||||||
|
|
||||||
@ -330,7 +331,7 @@ namespace MWMechanics
|
|||||||
{
|
{
|
||||||
storage.mUseCustomDestination = false;
|
storage.mUseCustomDestination = false;
|
||||||
storage.stopAttack();
|
storage.stopAttack();
|
||||||
actor.getClass().getCreatureStats(actor).setAttackingOrSpell(false);
|
stats.setAttackingOrSpell(false);
|
||||||
currentAction = std::make_unique<ActionFlee>();
|
currentAction = std::make_unique<ActionFlee>();
|
||||||
actionCooldown = currentAction->getActionCooldown();
|
actionCooldown = currentAction->getActionCooldown();
|
||||||
storage.startFleeing();
|
storage.startFleeing();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user