Combat AI: do not use range weapons under water

pull/258/head
Andrei Kortunov 8 years ago
parent 3356fb81ce
commit 62b24eb078

@ -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;
}
}

@ -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)
{

Loading…
Cancel
Save