1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-19 22:23:51 +00:00

Combat AI: do not use range weapons under water

This commit is contained in:
Andrei Kortunov 2017-06-16 12:20:31 +04:00
parent 3356fb81ce
commit 62b24eb078
2 changed files with 16 additions and 0 deletions

View file

@ -535,6 +535,10 @@ namespace MWMechanics
// opponent's weapon range, or not backing up if opponent is also using a ranged weapon
if (isDistantCombat && distToTarget < rangeAttack / 4)
{
// actor should not back up into water
if (MWBase::Environment::get().getWorld()->isUnderwater(MWWorld::ConstPtr(actor), 0.5f))
return;
mMovement.mPosition[1] = -1;
}
}

View file

@ -118,7 +118,19 @@ namespace MWMechanics
float bonus=0.f;
if (weapon->mData.mType >= ESM::Weapon::MarksmanBow && weapon->mData.mType <= ESM::Weapon::MarksmanThrown)
{
// Range weapon is useless under water
if (MWBase::Environment::get().getWorld()->isUnderwater(MWWorld::ConstPtr(actor), 0.75f))
return 0.f;
if (enemy.isEmpty())
return 0.f;
if (MWBase::Environment::get().getWorld()->isUnderwater(MWWorld::ConstPtr(enemy), 0.75f))
return 0.f;
bonus+=1.5f;
}
if (weapon->mData.mType >= ESM::Weapon::MarksmanBow)
{