Add unarmed attack selection to chooseBestAttack()

pull/64/head
Allofich 8 years ago
parent 513f754529
commit 04c13ffab3

@ -362,9 +362,9 @@ namespace MWMechanics
}
}
// Original engine behavior seems to be to back up during ranged combat
// according to fCombatDistance or opponent's weapon range, unless opponent
// is also using a ranged weapon
// Below behavior for backing up during ranged combat differs from vanilla.
// Vanilla is observed as backing up only as far as fCombatDistance or
// opponent's weapon range, or not backing up if opponent is also using a ranged weapon
if (isDistantCombat && distToTarget < rangeAttack / 4)
{
mMovement.mPosition[1] = -1;
@ -468,6 +468,8 @@ std::string chooseBestAttack(const ESM::Weapon* weapon)
else
attackType = "chop";
}
else
MWMechanics::CharacterController::setAttackTypeRandomly(attackType);
return attackType;
}

@ -1312,9 +1312,9 @@ bool CharacterController::updateWeaponState()
mAttackType = "shoot";
else
{
if (isWeapon)
if(mPtr == getPlayer())
{
if(mPtr == getPlayer())
if (isWeapon)
{
if (Settings::Manager::getBool("best attack", "Game"))
{
@ -1324,10 +1324,10 @@ bool CharacterController::updateWeaponState()
else
setAttackTypeBasedOnMovement();
}
// else if (mPtr != getPlayer()) use mAttackType already set by AiCombat
else
setAttackTypeRandomly(mAttackType);
}
else
setAttackTypeRandomly();
// else if (mPtr != getPlayer()) use mAttackType set by AiCombat
}
mAnimation->play(mCurrentWeapon, priorityWeapon,
@ -2188,17 +2188,6 @@ void CharacterController::updateMagicEffects()
mAnimation->setLightEffect(light);
}
void CharacterController::setAttackTypeRandomly()
{
float random = Misc::Rng::rollProbability();
if (random >= 2/3.f)
mAttackType = "thrust";
else if (random >= 1/3.f)
mAttackType = "slash";
else
mAttackType = "chop";
}
void CharacterController::setAttackTypeBasedOnMovement()
{
float *move = mPtr.getClass().getMovementSettings(mPtr).mPosition;
@ -2240,6 +2229,17 @@ void CharacterController::setAIAttackType(std::string attackType)
mAttackType = attackType;
}
void CharacterController::setAttackTypeRandomly(std::string& attackType)
{
float random = Misc::Rng::rollProbability();
if (random >= 2/3.f)
attackType = "thrust";
else if (random >= 1/3.f)
attackType = "slash";
else
attackType = "chop";
}
bool CharacterController::readyToPrepareAttack() const
{
return (mHitState == CharState_None || mHitState == CharState_Block)

@ -198,7 +198,6 @@ class CharacterController : public MWRender::Animation::TextKeyListener
bool mAttackingOrSpell;
void setAttackTypeBasedOnMovement();
void setAttackTypeRandomly();
void refreshCurrentAnims(CharacterState idle, CharacterState movement, JumpingState jump, bool force=false);
void refreshHitRecoilAnims();
@ -270,6 +269,7 @@ public:
void setAttackingOrSpell(bool attackingOrSpell);
void setAIAttackType(std::string attackType); // set and used by AiCombat
static void setAttackTypeRandomly(std::string& attackType);
bool readyToPrepareAttack() const;
bool readyToStartAttack() const;

Loading…
Cancel
Save