mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-01 13:45:34 +00:00
extracted function stopAttack().
This commit is contained in:
parent
0884a3796f
commit
2b9e22f593
1 changed files with 12 additions and 7 deletions
|
@ -117,6 +117,7 @@ namespace MWMechanics
|
|||
void startAttackIfReady(const MWWorld::Ptr& actor, CharacterController& characterController,
|
||||
const ESM::Weapon* weapon, bool distantCombat);
|
||||
void updateAttack(CharacterController& characterController);
|
||||
void stopAttack();
|
||||
};
|
||||
|
||||
AiCombat::AiCombat(const MWWorld::Ptr& actor) :
|
||||
|
@ -221,10 +222,9 @@ namespace MWMechanics
|
|||
{
|
||||
MWMechanics::Movement& movement = storage.mMovement;
|
||||
|
||||
// Stop attacking if target is not seen
|
||||
if (isTargetMagicallyHidden(target))
|
||||
{
|
||||
movement.mPosition[1] = movement.mPosition[0] = 0;
|
||||
storage.stopAttack();
|
||||
return false; // TODO: run away instead of doing nothing
|
||||
}
|
||||
|
||||
|
@ -368,11 +368,7 @@ namespace MWMechanics
|
|||
&& !actorClass.isNpc() && !MWMechanics::isEnvironmentCompatible(actor, target))
|
||||
{
|
||||
// TODO: start fleeing?
|
||||
movement.mPosition[0] = 0;
|
||||
movement.mPosition[1] = 0;
|
||||
movement.mPosition[2] = 0;
|
||||
readyToAttack = false;
|
||||
characterController.setAttackingOrSpell(false);
|
||||
storage.stopAttack();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -686,6 +682,15 @@ namespace MWMechanics
|
|||
}
|
||||
characterController.setAttackingOrSpell(mAttack);
|
||||
}
|
||||
|
||||
void AiCombatStorage::stopAttack()
|
||||
{
|
||||
mMovement.mPosition[0] = 0;
|
||||
mMovement.mPosition[1] = 0;
|
||||
mMovement.mPosition[2] = 0;
|
||||
mReadyToAttack = false;
|
||||
mAttack = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue