forked from teamnwah/openmw-tes3coop
more attack logic moved into AiCombatStorage.
This commit is contained in:
parent
0735e3e06e
commit
50ddcd1953
1 changed files with 11 additions and 6 deletions
|
@ -116,6 +116,7 @@ namespace MWMechanics
|
||||||
void stopCombatMove();
|
void stopCombatMove();
|
||||||
void startAttackIfReady(const MWWorld::Ptr& actor, CharacterController& characterController,
|
void startAttackIfReady(const MWWorld::Ptr& actor, CharacterController& characterController,
|
||||||
const ESM::Weapon* weapon, bool distantCombat);
|
const ESM::Weapon* weapon, bool distantCombat);
|
||||||
|
void updateAttack(CharacterController& characterController);
|
||||||
};
|
};
|
||||||
|
|
||||||
AiCombat::AiCombat(const MWWorld::Ptr& actor) :
|
AiCombat::AiCombat(const MWWorld::Ptr& actor) :
|
||||||
|
@ -201,12 +202,7 @@ namespace MWMechanics
|
||||||
MWMechanics::Movement& movement = storage.mMovement;
|
MWMechanics::Movement& movement = storage.mMovement;
|
||||||
|
|
||||||
UpdateActorsMovement(actor, movement);
|
UpdateActorsMovement(actor, movement);
|
||||||
|
storage.updateAttack(characterController);
|
||||||
bool& attack = storage.mAttack;
|
|
||||||
if (attack && (characterController.getAttackStrength() >= storage.mStrength || characterController.readyToPrepareAttack()))
|
|
||||||
attack = false;
|
|
||||||
|
|
||||||
characterController.setAttackingOrSpell(attack);
|
|
||||||
|
|
||||||
float& actionCooldown = storage.mActionCooldown;
|
float& actionCooldown = storage.mActionCooldown;
|
||||||
actionCooldown -= duration;
|
actionCooldown -= duration;
|
||||||
|
@ -686,6 +682,15 @@ namespace MWMechanics
|
||||||
mAttackCooldown -= REACTION_INTERVAL;
|
mAttackCooldown -= REACTION_INTERVAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AiCombatStorage::updateAttack(CharacterController& characterController)
|
||||||
|
{
|
||||||
|
if (mAttack && (characterController.getAttackStrength() >= mStrength || characterController.readyToPrepareAttack()))
|
||||||
|
{
|
||||||
|
mAttack = false;
|
||||||
|
}
|
||||||
|
characterController.setAttackingOrSpell(mAttack);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue