mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-27 12:35:46 +00:00
Take into account hit recovery, knockdown and other animations for AiCombat attack timing
This commit is contained in:
parent
520a832a9a
commit
d07b176b36
@ -300,10 +300,6 @@ namespace MWMechanics
|
|||||||
currentCell = actor.getCell();
|
currentCell = actor.getCell();
|
||||||
}
|
}
|
||||||
|
|
||||||
MWRender::Animation* anim = MWBase::Environment::get().getWorld()->getAnimation(actor);
|
|
||||||
if (!anim) // shouldn't happen
|
|
||||||
return false;
|
|
||||||
|
|
||||||
actorClass.getCreatureStats(actor).setMovementFlag(CreatureStats::Flag_Run, true);
|
actorClass.getCreatureStats(actor).setMovementFlag(CreatureStats::Flag_Run, true);
|
||||||
|
|
||||||
if (actionCooldown > 0)
|
if (actionCooldown > 0)
|
||||||
@ -312,11 +308,7 @@ namespace MWMechanics
|
|||||||
float rangeAttack = 0;
|
float rangeAttack = 0;
|
||||||
float rangeFollow = 0;
|
float rangeFollow = 0;
|
||||||
boost::shared_ptr<Action>& currentAction = storage.mCurrentAction;
|
boost::shared_ptr<Action>& currentAction = storage.mCurrentAction;
|
||||||
// TODO: upperBodyReady() works fine for checking if we can start an attack,
|
if (characterController.readyToPrepareAttack())
|
||||||
// but doesn't work properly for checking if the attack is finished (as things like hit recovery or knockdown also play on the upper body)
|
|
||||||
// Only a minor problem, but can mess with the actionCooldown timer.
|
|
||||||
// To fix this the AI needs to be brought closer to the CharacterController, so we can simply check if a weapon animation is playing.
|
|
||||||
if (anim->upperBodyReady())
|
|
||||||
{
|
{
|
||||||
currentAction = prepareNextAction(actor, target);
|
currentAction = prepareNextAction(actor, target);
|
||||||
actionCooldown = currentAction->getActionCooldown();
|
actionCooldown = currentAction->getActionCooldown();
|
||||||
|
@ -2047,6 +2047,11 @@ void CharacterController::setAttackingOrSpell(bool attackingOrSpell)
|
|||||||
mAttackingOrSpell = attackingOrSpell;
|
mAttackingOrSpell = attackingOrSpell;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CharacterController::readyToPrepareAttack() const
|
||||||
|
{
|
||||||
|
return mHitState == CharState_None && mUpperBodyState <= UpperCharState_WeapEquiped;
|
||||||
|
}
|
||||||
|
|
||||||
void CharacterController::setActive(bool active)
|
void CharacterController::setActive(bool active)
|
||||||
{
|
{
|
||||||
mAnimation->setActive(active);
|
mAnimation->setActive(active);
|
||||||
|
@ -240,6 +240,8 @@ public:
|
|||||||
|
|
||||||
void setAttackingOrSpell(bool attackingOrSpell);
|
void setAttackingOrSpell(bool attackingOrSpell);
|
||||||
|
|
||||||
|
bool readyToPrepareAttack() const;
|
||||||
|
|
||||||
/// @see Animation::setActive
|
/// @see Animation::setActive
|
||||||
void setActive(bool active);
|
void setActive(bool active);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user