1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-03-01 18:09:40 +00:00

Clarify logic

This commit is contained in:
Evil Eye 2021-11-08 17:28:54 +01:00
parent 11ed594910
commit 1a2fde04bb

View file

@ -369,25 +369,22 @@ namespace MWMechanics
break; break;
case ESM::MagicEffect::BoundShield: case ESM::MagicEffect::BoundShield:
if(actor.getClass().hasInventoryStore(actor)) if(!actor.getClass().hasInventoryStore(actor))
return 0.f;
else if(!actor.getClass().isNpc())
{ {
// If the actor is an NPC they can benefit from the armor rating, otherwise check if we've got a one-handed weapon to use with the shield // If the actor is an NPC they can benefit from the armor rating, otherwise check if we've got a one-handed weapon to use with the shield
if(!actor.getClass().isNpc()) const auto& store = actor.getClass().getInventoryStore(actor);
auto oneHanded = std::find_if(store.cbegin(MWWorld::ContainerStore::Type_Weapon), store.cend(), [](const MWWorld::ConstPtr& weapon)
{ {
const auto& store = actor.getClass().getInventoryStore(actor); if(weapon.getClass().getItemHealth(weapon) <= 0.f)
auto oneHanded = std::find_if(store.cbegin(MWWorld::ContainerStore::Type_Weapon), store.cend(), [](const MWWorld::ConstPtr& weapon) return false;
{ short type = weapon.get<ESM::Weapon>()->mBase->mData.mType;
if(weapon.getClass().getItemHealth(weapon) <= 0.f) return !(MWMechanics::getWeaponType(type)->mFlags & ESM::WeaponType::TwoHanded);
return false; });
auto type = weapon.get<ESM::Weapon>()->mBase->mData.mType; if(oneHanded == store.cend())
return !(MWMechanics::getWeaponType(type)->mFlags & ESM::WeaponType::TwoHanded); return 0.f;
});
if(oneHanded == store.cend())
return 0.f;
}
} }
else
return 0.f;
break; break;
// Creatures can not wear armor // Creatures can not wear armor
case ESM::MagicEffect::BoundCuirass: case ESM::MagicEffect::BoundCuirass: