1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-04-01 00:36:46 +00:00

Use fCombatDelayCreature, fCombatDelayNpc for random delays between aicombat attacks (Bug #1876)

This commit is contained in:
scrawl 2015-07-04 05:19:05 +02:00
parent a7bd050928
commit 6bcea21e14

View file

@ -81,6 +81,7 @@ namespace MWMechanics
/// \brief This class holds the variables AiCombat needs which are deleted if the package becomes inactive. /// \brief This class holds the variables AiCombat needs which are deleted if the package becomes inactive.
struct AiCombatStorage : AiTemporaryBase struct AiCombatStorage : AiTemporaryBase
{ {
float mAttackCooldown;
float mTimerReact; float mTimerReact;
float mTimerCombatMove; float mTimerCombatMove;
bool mReadyToAttack; bool mReadyToAttack;
@ -98,6 +99,7 @@ namespace MWMechanics
MWMechanics::Movement mMovement; MWMechanics::Movement mMovement;
AiCombatStorage(): AiCombatStorage():
mAttackCooldown(0),
mTimerReact(0), mTimerReact(0),
mTimerCombatMove(0), mTimerCombatMove(0),
mReadyToAttack(false), mReadyToAttack(false),
@ -340,24 +342,34 @@ namespace MWMechanics
// start new attack // start new attack
if(readyToAttack && characterController.readyToStartAttack()) if(readyToAttack && characterController.readyToStartAttack())
{ {
attack = true; // attack starts just now if (storage.mAttackCooldown <= 0)
characterController.setAttackingOrSpell(attack);
if (!distantCombat)
chooseBestAttack(weapon, movement);
strength = Misc::Rng::rollClosedProbability();
//say a provoking combat phrase
if (actor.getClass().isNpc())
{ {
attack = true; // attack starts just now
characterController.setAttackingOrSpell(attack);
if (!distantCombat)
chooseBestAttack(weapon, movement);
strength = Misc::Rng::rollClosedProbability();
const MWWorld::ESMStore &store = world->getStore(); const MWWorld::ESMStore &store = world->getStore();
int chance = store.get<ESM::GameSetting>().find("iVoiceAttackOdds")->getInt();
if (Misc::Rng::roll0to99() < chance) //say a provoking combat phrase
if (actor.getClass().isNpc())
{ {
MWBase::Environment::get().getDialogueManager()->say(actor, "attack"); int chance = store.get<ESM::GameSetting>().find("iVoiceAttackOdds")->getInt();
if (Misc::Rng::roll0to99() < chance)
{
MWBase::Environment::get().getDialogueManager()->say(actor, "attack");
}
} }
float baseDelay = store.get<ESM::GameSetting>().find("fCombatDelayCreature")->getFloat();
if (actor.getClass().isNpc())
baseDelay = store.get<ESM::GameSetting>().find("fCombatDelayNPC")->getFloat();
storage.mAttackCooldown = std::min(baseDelay + 0.01 * Misc::Rng::roll0to99(), baseDelay + 0.9);
} }
else
storage.mAttackCooldown -= tReaction;
} }