Merge branch 'protec' into 'master'

Switch torches to shields for hostile NPCs

Closes #5300

See merge request OpenMW/openmw!501
pull/593/head
Alexei Dobrohotov 4 years ago
commit cdf0bc1d8d

@ -33,6 +33,7 @@
Bug #5101: Hostile followers travel with the player
Bug #5108: Savegame bloating due to inefficient fog textures format
Bug #5165: Active spells should use real time intead of timestamps
Bug #5300: NPCs don't switch from torch to shield when starting combat
Bug #5358: ForceGreeting always resets the dialogue window completely
Bug #5363: Enchantment autocalc not always 0/1
Bug #5364: Script fails/stops if trying to startscript an unknown script

@ -1430,6 +1430,13 @@ namespace MWMechanics
if (heldIter != inventoryStore.end() && heldIter->getTypeName() != typeid(ESM::Light).name())
inventoryStore.unequipItem(*heldIter, ptr);
}
else if (heldIter == inventoryStore.end() || heldIter->getTypeName() == typeid(ESM::Light).name())
{
// For hostile NPCs, see if they have anything better to equip first
auto shield = inventoryStore.getPreferredShield(ptr);
if(shield != inventoryStore.end())
inventoryStore.equip(MWWorld::InventoryStore::Slot_CarriedLeft, shield, ptr);
}
heldIter = inventoryStore.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);

@ -556,6 +556,14 @@ void MWWorld::InventoryStore::autoEquip (const MWWorld::Ptr& actor)
}
}
MWWorld::ContainerStoreIterator MWWorld::InventoryStore::getPreferredShield(const MWWorld::Ptr& actor)
{
TSlots slots;
initSlots (slots);
autoEquipArmor(actor, slots);
return slots[Slot_CarriedLeft];
}
const MWMechanics::MagicEffects& MWWorld::InventoryStore::getMagicEffects() const
{
return mMagicEffects;

@ -153,6 +153,8 @@ namespace MWWorld
ContainerStoreIterator getSlot (int slot);
ConstContainerStoreIterator getSlot(int slot) const;
ContainerStoreIterator getPreferredShield(const MWWorld::Ptr& actor);
void unequipAll(const MWWorld::Ptr& actor);
///< Unequip all currently equipped items.

Loading…
Cancel
Save