From 067c2bc2ec0d67fe3d05afba72d9c7f047944935 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 30 Jan 2014 03:18:34 +0100 Subject: [PATCH] Disable combat movements for creatures without weapons --- apps/openmw/mwmechanics/aicombat.cpp | 7 +++++-- apps/openmw/mwmechanics/character.cpp | 18 ++++++++---------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/apps/openmw/mwmechanics/aicombat.cpp b/apps/openmw/mwmechanics/aicombat.cpp index cf08dabf8..2ff7ec229 100644 --- a/apps/openmw/mwmechanics/aicombat.cpp +++ b/apps/openmw/mwmechanics/aicombat.cpp @@ -204,7 +204,10 @@ namespace MWMechanics { //Melee: stop running and attack mMovement.mPosition[1] = 0; - chooseBestAttack(weapon, mMovement); + + // When attacking with a weapon, choose between slash, thrust or chop + if (actor.getClass().hasInventoryStore(actor)) + chooseBestAttack(weapon, mMovement); if(mMovement.mPosition[0] || mMovement.mPosition[1]) { @@ -365,7 +368,7 @@ void chooseBestAttack(const ESM::Weapon* weapon, MWMechanics::Movement &movement { if (weapon == NULL) { - //hand-to-hand and creatures' attacks deal equal damage for each type + //hand-to-hand deal equal damage for each type float roll = static_cast(rand())/RAND_MAX; if(roll <= 0.333f) //side punch { diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index 63f363045..74cda0a70 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -478,7 +478,14 @@ bool CharacterController::updateCreatureState() { MWBase::Environment::get().getWorld()->breakInvisibility(mPtr); - determineAttackType(); + // These are unique animations and not linked to movement type. Just pick one randomly. + int roll = std::rand()/ (static_cast (RAND_MAX) + 1) * 3; // [0, 2] + if (roll == 0) + mCurrentWeapon = "attack1"; + else if (roll == 1) + mCurrentWeapon = "attack2"; + else + mCurrentWeapon = "attack3"; mAnimation->play(mCurrentWeapon, Priority_Weapon, MWRender::Animation::Group_All, true, @@ -1308,15 +1315,6 @@ void CharacterController::determineAttackType() else mAttackType = "chop"; } - else - { - if (move[0] && !move[1]) //sideway - mCurrentWeapon = "attack2"; - else if (move[1]) //forward - mCurrentWeapon = "attack3"; - else - mCurrentWeapon = "attack1"; - } } }