mirror of
https://github.com/TES3MP/TES3MP.git
synced 2025-09-27 15:11:36 -04:00
Backing up distance is now dependent on opponents's weapon range; don't back up from ranged oponents
This commit is contained in:
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)
|
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
|
// get the range of the target's weapon
|
||||||
float rangeAttackOfTarget = 0.f;
|
float rangeAttackOfTarget = 0.f;
|
||||||
@ -512,14 +504,22 @@ namespace MWMechanics
|
|||||||
targetWeapon = *weaponSlot;
|
targetWeapon = *weaponSlot;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Action> targetWeaponAction (new ActionWeapon(targetWeapon));
|
std::shared_ptr<Action> targetWeaponAction(new ActionWeapon(targetWeapon));
|
||||||
|
|
||||||
|
bool isRangedCombat = false;
|
||||||
if (targetWeaponAction.get())
|
if (targetWeaponAction.get())
|
||||||
{
|
{
|
||||||
bool isRangedCombat = false;
|
|
||||||
rangeAttackOfTarget = targetWeaponAction->getCombatRange(isRangedCombat);
|
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
|
// apply sideway movement (kind of dodging) with some probability
|
||||||
// if actor is within range of target's weapon
|
// if actor is within range of target's weapon
|
||||||
if (distToTarget <= rangeAttackOfTarget && Misc::Rng::rollClosedProbability() < 0.25)
|
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.
|
// Below behavior for backing up during ranged combat differs from vanilla.
|
||||||
// Vanilla is observed as backing up only as far as fCombatDistance or
|
// 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
|
// 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
|
// actor should not back up into water
|
||||||
if (MWBase::Environment::get().getWorld()->isUnderwater(MWWorld::ConstPtr(actor), 0.5f))
|
if (MWBase::Environment::get().getWorld()->isUnderwater(MWWorld::ConstPtr(actor), 0.5f))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!isRangedCombat && distToTarget <= rangeAttackOfTarget*1.5) // Don't back up if the target is wielding ranged weapon
|
||||||
mMovement.mPosition[1] = -1;
|
mMovement.mPosition[1] = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user