Backing up distance is now dependent on opponents's weapon range; don't back up from ranged oponents

pull/335/head^2
rexelion 7 years ago
parent a1d9f11b04
commit cab0002461

@ -489,14 +489,6 @@ namespace MWMechanics
}
void AiCombatStorage::startCombatMove(bool isDistantCombat, float distToTarget, float rangeAttack, const MWWorld::Ptr& actor, const MWWorld::Ptr& target)
{
if (mMovement.mPosition[0] || mMovement.mPosition[1])
{
mTimerCombatMove = 0.1f + 0.1f * Misc::Rng::rollClosedProbability();
mCombatMove = true;
}
// dodge movements (for NPCs and bipedal creatures)
else if (actor.getClass().isBipedal(actor))
{
// get the range of the target's weapon
float rangeAttackOfTarget = 0.f;
@ -514,12 +506,20 @@ namespace MWMechanics
std::shared_ptr<Action> targetWeaponAction(new ActionWeapon(targetWeapon));
bool isRangedCombat = false;
if (targetWeaponAction.get())
{
bool isRangedCombat = false;
rangeAttackOfTarget = targetWeaponAction->getCombatRange(isRangedCombat);
}
if (mMovement.mPosition[0] || mMovement.mPosition[1])
{
mTimerCombatMove = 0.1f + 0.1f * Misc::Rng::rollClosedProbability();
mCombatMove = true;
}
// dodge movements (for NPCs and bipedal creatures)
else if (actor.getClass().isBipedal(actor))
{
// apply sideway movement (kind of dodging) with some probability
// if actor is within range of target's weapon
if (distToTarget <= rangeAttackOfTarget && Misc::Rng::rollClosedProbability() < 0.25)
@ -533,12 +533,13 @@ namespace MWMechanics
// 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)
if (isDistantCombat)
{
// actor should not back up into water
if (MWBase::Environment::get().getWorld()->isUnderwater(MWWorld::ConstPtr(actor), 0.5f))
return;
if (!isRangedCombat && distToTarget <= rangeAttackOfTarget*1.5) // Don't back up if the target is wielding ranged weapon
mMovement.mPosition[1] = -1;
}
}

Loading…
Cancel
Save