Merge pull request #1423 from akortunov/spellpriority

Combat AI: use effective cast cost when rate enchanted weapon
pull/280/head
scrawl 7 years ago committed by GitHub
commit 43fda6cf07

@ -13,6 +13,7 @@
#include "combat.hpp" #include "combat.hpp"
#include "aicombataction.hpp" #include "aicombataction.hpp"
#include "spellpriority.hpp" #include "spellpriority.hpp"
#include "spellcasting.hpp"
namespace MWMechanics namespace MWMechanics
{ {
@ -90,10 +91,13 @@ namespace MWMechanics
if (!weapon->mEnchant.empty()) if (!weapon->mEnchant.empty())
{ {
const ESM::Enchantment* enchantment = MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>().find(weapon->mEnchant); const ESM::Enchantment* enchantment = MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>().find(weapon->mEnchant);
if (enchantment->mData.mType == ESM::Enchantment::WhenStrikes if (enchantment->mData.mType == ESM::Enchantment::WhenStrikes)
&& (item.getCellRef().getEnchantmentCharge() == -1 {
|| item.getCellRef().getEnchantmentCharge() >= enchantment->mData.mCost)) int castCost = getEffectiveEnchantmentCastCost(static_cast<float>(enchantment->mData.mCost), actor);
rating += rateEffects(enchantment->mEffects, actor, enemy);
if (item.getCellRef().getEnchantmentCharge() == -1 || item.getCellRef().getEnchantmentCharge() >= castCost)
rating += rateEffects(enchantment->mEffects, actor, enemy);
}
} }
int skill = item.getClass().getEquipmentSkill(item); int skill = item.getClass().getEquipmentSkill(item);

Loading…
Cancel
Save