From fc7b4d73a8cb5ed2c1eb94ed3d22796eb269e768 Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Sun, 20 Oct 2019 13:30:52 +0300 Subject: [PATCH] Remove on-strike enchantment support for ranged weapon types (bug #5190) --- CHANGELOG.md | 1 + apps/openmw/mwmechanics/combat.cpp | 6 ++---- apps/openmw/mwmechanics/enchanting.cpp | 17 ++++++++++------- apps/openmw/mwmechanics/enchanting.hpp | 1 + 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd8bf9f48..c5795c208 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -163,6 +163,7 @@ Bug #5177: Editor: Unexplored map tiles get corrupted after a file with terrain is saved Bug #5182: OnPCEquip doesn't trigger on skipped beast race attempts to equip something not equippable by beasts Bug #5186: Equipped item enchantments don't affect creatures + Bug #5190: On-strike enchantments can be applied to and used with non-projectile ranged weapons Feature #1774: Handle AvoidNode Feature #2229: Improve pathfinding AI Feature #3025: Analogue gamepad movement controls diff --git a/apps/openmw/mwmechanics/combat.cpp b/apps/openmw/mwmechanics/combat.cpp index 9258c6b2d..a6d542935 100644 --- a/apps/openmw/mwmechanics/combat.cpp +++ b/apps/openmw/mwmechanics/combat.cpp @@ -245,10 +245,8 @@ namespace MWMechanics reduceWeaponCondition(damage, validVictim, weapon, attacker); - // Apply "On hit" effect of the weapon & projectile - bool appliedEnchantment = applyOnStrikeEnchantment(attacker, victim, weapon, hitPosition, true); - if (weapon != projectile) - appliedEnchantment = applyOnStrikeEnchantment(attacker, victim, projectile, hitPosition, true); + // Apply "On hit" effect of the projectile + bool appliedEnchantment = applyOnStrikeEnchantment(attacker, victim, projectile, hitPosition, true); if (validVictim) { diff --git a/apps/openmw/mwmechanics/enchanting.cpp b/apps/openmw/mwmechanics/enchanting.cpp index 20ba99825..e9ae64337 100644 --- a/apps/openmw/mwmechanics/enchanting.cpp +++ b/apps/openmw/mwmechanics/enchanting.cpp @@ -14,6 +14,7 @@ #include "creaturestats.hpp" #include "spellcasting.hpp" #include "actorutil.hpp" +#include "weapontype.hpp" namespace MWMechanics { @@ -25,13 +26,13 @@ namespace MWMechanics void Enchanting::setOldItem(const MWWorld::Ptr& oldItem) { mOldItemPtr=oldItem; + mWeaponType = -1; + mObjectType.clear(); if(!itemEmpty()) { mObjectType = mOldItemPtr.getTypeName(); - } - else - { - mObjectType=""; + if (mObjectType == typeid(ESM::Weapon).name()) + mWeaponType = mOldItemPtr.get()->mBase->mData.mType; } } @@ -119,7 +120,7 @@ namespace MWMechanics return; } } - else if(mObjectType == typeid(ESM::Weapon).name()) + else if (mWeaponType != -1) { // Weapon switch(mCastStyle) { @@ -129,11 +130,13 @@ namespace MWMechanics case ESM::Enchantment::WhenUsed: if (powerfulSoul) mCastStyle = ESM::Enchantment::ConstantEffect; - else + else if (getWeaponType(mWeaponType)->mWeaponClass != ESM::WeaponType::Ranged) mCastStyle = ESM::Enchantment::WhenStrikes; return; default: // takes care of Constant effect too - mCastStyle = ESM::Enchantment::WhenStrikes; + mCastStyle = ESM::Enchantment::WhenUsed; + if (getWeaponType(mWeaponType)->mWeaponClass != ESM::WeaponType::Ranged) + mCastStyle = ESM::Enchantment::WhenStrikes; return; } } diff --git a/apps/openmw/mwmechanics/enchanting.hpp b/apps/openmw/mwmechanics/enchanting.hpp index 6f72d96a8..6996fa24d 100644 --- a/apps/openmw/mwmechanics/enchanting.hpp +++ b/apps/openmw/mwmechanics/enchanting.hpp @@ -23,6 +23,7 @@ namespace MWMechanics std::string mNewItemName; std::string mObjectType; + int mWeaponType; public: Enchanting();