1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-04 03:40:14 +00:00

Merge branch 'ificialintelligence' into 'master'

Minor AI priority changes

See merge request OpenMW/openmw!2558
This commit is contained in:
psi29a 2022-12-29 21:27:55 +00:00
commit ae1b3083b5
3 changed files with 17 additions and 8 deletions

View File

@ -544,6 +544,7 @@ namespace MWMechanics
break;
}
case ESM::MagicEffect::AbsorbAttribute:
case ESM::MagicEffect::DamageAttribute:
case ESM::MagicEffect::DrainAttribute:
if (!enemy.isEmpty()
@ -567,6 +568,7 @@ namespace MWMechanics
}
break;
case ESM::MagicEffect::AbsorbSkill:
case ESM::MagicEffect::DamageSkill:
case ESM::MagicEffect::DrainSkill:
if (enemy.isEmpty() || !enemy.getClass().isNpc())
@ -656,23 +658,29 @@ namespace MWMechanics
return rating;
}
float rateEffects(const ESM::EffectList& list, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy)
float rateEffects(
const ESM::EffectList& list, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy, bool useSpellMult)
{
// NOTE: enemy may be empty
float rating = 0.f;
float ratingMult = 1.f; // NB: this multiplier is applied to the effect rating, not the final rating
const MWWorld::Store<ESM::GameSetting>& gmst
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
static const float fAIMagicSpellMult = gmst.find("fAIMagicSpellMult")->mValue.getFloat();
static const float fAIRangeMagicSpellMult = gmst.find("fAIRangeMagicSpellMult")->mValue.getFloat();
for (std::vector<ESM::ENAMstruct>::const_iterator it = list.mList.begin(); it != list.mList.end(); ++it)
for (const ESM::ENAMstruct& effect : list.mList)
{
ratingMult = (it->mRange == ESM::RT_Target) ? fAIRangeMagicSpellMult : fAIMagicSpellMult;
rating += rateEffect(*it, actor, enemy) * ratingMult;
float effectRating = rateEffect(effect, actor, enemy);
if (useSpellMult)
{
if (effect.mRange == ESM::RT_Target)
effectRating *= fAIRangeMagicSpellMult;
else
effectRating *= fAIMagicSpellMult;
}
rating += effectRating;
}
return rating;
}

View File

@ -32,7 +32,8 @@ namespace MWMechanics
/// @note target may be empty
float rateEffect(const ESM::ENAMstruct& effect, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy);
/// @note target may be empty
float rateEffects(const ESM::EffectList& list, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy);
float rateEffects(
const ESM::EffectList& list, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy, bool useSpellMult = true);
float vanillaRateSpell(const ESM::Spell* spell, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy);
}

View File

@ -113,7 +113,7 @@ namespace MWMechanics
if (charge == -1 || charge >= castCost || weapclass == ESM::WeaponType::Thrown
|| weapclass == ESM::WeaponType::Ammo)
rating += rateEffects(enchantment->mEffects, actor, enemy);
rating += rateEffects(enchantment->mEffects, actor, enemy, false);
}
}