1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-21 10:23:56 +00:00

Combat AI: use effective cast cost when rate enchanted weapon

This commit is contained in:
Andrei Kortunov 2017-08-29 16:40:55 +04:00
parent e799cbdb51
commit 8003dbee12

View file

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