From 411c71062ccc836944eccb9bc5485bbbe270191c Mon Sep 17 00:00:00 2001 From: Alexei Dobrohotov Date: Tue, 11 Jul 2023 09:53:56 +0300 Subject: [PATCH] Resist failed normal weapon hits (bug #7284) --- CHANGELOG.md | 1 + apps/openmw/mwclass/npc.cpp | 7 ++++--- apps/openmw/mwmechanics/combat.cpp | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc302430fe..a0550dcbbc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,7 @@ Bug #7172: Current music playlist continues playing indefinitely if next playlist is empty Bug #7229: Error marker loading failure is not handled Bug #7243: Supporting loading external files from VFS from esm files + Bug #7284: "Your weapon has no effect." message doesn't always show when the player character attempts to attack Bug #7298: Water ripples from projectiles sometimes are not spawned Bug #7307: Alchemy "Magic Effect" search string does not match on tool tip for effects related to attributes Bug #7322: Shadows don't cover groundcover depending on the view angle and perspective with compute scene bounds = primitives diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 59aefc715f..a9ae2fba32 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -614,15 +614,16 @@ namespace MWClass if (ptr == MWMechanics::getPlayer()) MWBase::Environment::get().getWindowManager()->setEnemy(victim); + float damage = 0.0f; if (!success) { - othercls.onHit(victim, 0.0f, false, weapon, ptr, osg::Vec3f(), false); - MWMechanics::reduceWeaponCondition(0.f, false, weapon, ptr); + othercls.onHit(victim, damage, false, weapon, ptr, osg::Vec3f(), false); + MWMechanics::reduceWeaponCondition(damage, false, weapon, ptr); + MWMechanics::resistNormalWeapon(victim, ptr, weapon, damage); return; } bool healthdmg; - float damage = 0.0f; if (!weapon.isEmpty()) { const unsigned char* attack = nullptr; diff --git a/apps/openmw/mwmechanics/combat.cpp b/apps/openmw/mwmechanics/combat.cpp index b20a3ed2fb..ef870b1edf 100644 --- a/apps/openmw/mwmechanics/combat.cpp +++ b/apps/openmw/mwmechanics/combat.cpp @@ -180,7 +180,7 @@ namespace MWMechanics void resistNormalWeapon( const MWWorld::Ptr& actor, const MWWorld::Ptr& attacker, const MWWorld::Ptr& weapon, float& damage) { - if (damage == 0 || weapon.isEmpty() || !isNormalWeapon(weapon)) + if (weapon.isEmpty() || !isNormalWeapon(weapon)) return; const MWMechanics::MagicEffects& effects = actor.getClass().getCreatureStats(actor).getMagicEffects(); @@ -189,7 +189,7 @@ namespace MWMechanics damage *= 1.f - std::min(1.f, resistance - weakness); - if (damage == 0 && attacker == getPlayer()) + if (resistance - weakness >= 1.f && attacker == getPlayer()) MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicTargetResistsWeapons}"); }