Merge pull request #2464 from Capostrophic/enchant

Ignore on-strike enchanted projectile charge (#5104)
pull/541/head
Andrei Kortunov 5 years ago committed by GitHub
commit ad8b10c8db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -116,6 +116,7 @@
Bug #5092: NPCs with enchanted weapons play sound when out of charges
Bug #5093: Hand to hand sound plays on knocked out enemies
Bug #5099: Non-swimming enemies will enter water if player is water walking
Bug #5104: Black Dart's enchantment doesn't trigger at low Enchant levels
Bug #5105: NPCs start combat with werewolves from any distance
Bug #5110: ModRegion with a redundant numerical argument breaks script execution
Feature #1774: Handle AvoidNode

@ -823,18 +823,22 @@ namespace MWMechanics
mStack = false;
bool godmode = mCaster == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState();
bool isProjectile = false;
if (item.getTypeName() == typeid(ESM::Weapon).name())
{
const ESM::Weapon* ref = item.get<ESM::Weapon>()->mBase;
isProjectile = ref->mData.mType >= ESM::Weapon::MarksmanThrown;
}
int type = enchantment->mData.mType;
// Check if there's enough charge left
if (enchantment->mData.mType == ESM::Enchantment::WhenUsed || enchantment->mData.mType == ESM::Enchantment::WhenStrikes)
if (!godmode && (type == ESM::Enchantment::WhenUsed || (!isProjectile && type == ESM::Enchantment::WhenStrikes)))
{
int castCost = getEffectiveEnchantmentCastCost(static_cast<float>(enchantment->mData.mCost), mCaster);
if (item.getCellRef().getEnchantmentCharge() == -1)
item.getCellRef().setEnchantmentCharge(static_cast<float>(enchantment->mData.mCharge));
if (godmode)
castCost = 0;
if (item.getCellRef().getEnchantmentCharge() < castCost)
{
if (mCaster == getPlayer())
@ -862,17 +866,17 @@ namespace MWMechanics
item.getCellRef().setEnchantmentCharge(item.getCellRef().getEnchantmentCharge() - castCost);
}
if (enchantment->mData.mType == ESM::Enchantment::WhenUsed)
if (type == ESM::Enchantment::WhenUsed)
{
if (mCaster == getPlayer())
mCaster.getClass().skillUsageSucceeded (mCaster, ESM::Skill::Enchant, 1);
}
else if (enchantment->mData.mType == ESM::Enchantment::CastOnce)
else if (type == ESM::Enchantment::CastOnce)
{
if (!godmode)
item.getContainerStore()->remove(item, 1, mCaster);
}
else if (enchantment->mData.mType == ESM::Enchantment::WhenStrikes)
else if (type == ESM::Enchantment::WhenStrikes)
{
if (mCaster == getPlayer())
mCaster.getClass().skillUsageSucceeded (mCaster, ESM::Skill::Enchant, 3);
@ -880,13 +884,6 @@ namespace MWMechanics
inflict(mCaster, mCaster, enchantment->mEffects, ESM::RT_Self);
bool isProjectile = false;
if (item.getTypeName() == typeid(ESM::Weapon).name())
{
const MWWorld::LiveCellRef<ESM::Weapon> *ref = item.get<ESM::Weapon>();
isProjectile = ref->mBase->mData.mType == ESM::Weapon::Arrow || ref->mBase->mData.mType == ESM::Weapon::Bolt || ref->mBase->mData.mType == ESM::Weapon::MarksmanThrown;
}
if (isProjectile || !mTarget.isEmpty())
inflict(mTarget, mCaster, enchantment->mEffects, ESM::RT_Touch);

@ -102,8 +102,9 @@ namespace MWMechanics
if (enchantment->mData.mType == ESM::Enchantment::WhenStrikes)
{
int castCost = getEffectiveEnchantmentCastCost(static_cast<float>(enchantment->mData.mCost), actor);
float charge = item.getCellRef().getEnchantmentCharge();
if (item.getCellRef().getEnchantmentCharge() == -1 || item.getCellRef().getEnchantmentCharge() >= castCost)
if (charge == -1 || charge >= castCost || weapon->mData.mType >= ESM::Weapon::MarksmanThrown)
rating += rateEffects(enchantment->mEffects, actor, enemy);
}
}

Loading…
Cancel
Save