From 2b2f9a8714a4506c766dfdef105d6c34d4898431 Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Thu, 25 Jun 2020 15:44:40 +0300 Subject: [PATCH] Redistribute hits to carried left slot when possible (#5490) --- CHANGELOG.md | 1 + apps/openmw/mwclass/npc.cpp | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9542926332..7b90509448 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ Bug #5441: Enemies can't push a player character when in critical strike stance Bug #5451: Magic projectiles don't disappear with the caster Bug #5452: Autowalk is being included in savegames + Bug #5490: Hits to carried left slot aren't redistributed if there's no shield equipped Feature #390: 3rd person look "over the shoulder" Feature #2386: Distant Statics in the form of Object Paging Feature #5297: Add a search function to the "Datafiles" tab of the OpenMW launcher diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index b7084aff04..edf0709db7 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -784,7 +784,22 @@ namespace MWClass MWWorld::InventoryStore &inv = getInventoryStore(ptr); MWWorld::ContainerStoreIterator armorslot = inv.getSlot(hitslot); MWWorld::Ptr armor = ((armorslot != inv.end()) ? *armorslot : MWWorld::Ptr()); - if(!armor.isEmpty() && armor.getTypeName() == typeid(ESM::Armor).name()) + bool hasArmor = !armor.isEmpty() && armor.getTypeName() == typeid(ESM::Armor).name(); + // If there's no item in the carried left slot or if it is not a shield redistribute the hit. + if (!hasArmor && hitslot == MWWorld::InventoryStore::Slot_CarriedLeft) + { + if (Misc::Rng::rollDice(2) == 0) + hitslot = MWWorld::InventoryStore::Slot_Cuirass; + else + hitslot = MWWorld::InventoryStore::Slot_LeftPauldron; + armorslot = inv.getSlot(hitslot); + if (armorslot != inv.end()) + { + armor = *armorslot; + hasArmor = !armor.isEmpty() && armor.getTypeName() == typeid(ESM::Armor).name(); + } + } + if (hasArmor) { if (!object.isEmpty() || attacker.isEmpty() || attacker.getClass().isNpc()) // Unarmed creature attacks don't affect armor condition {