From 59c963b6cc9f21a3486dafe2b1470e4a7ff7e383 Mon Sep 17 00:00:00 2001 From: Emanuel Guevel Date: Thu, 24 Oct 2013 02:14:05 +0200 Subject: [PATCH] Auto-equip items when a clothe or an armor is removed from inventory This fix auto-equip on corpses. --- apps/openmw/mwworld/inventorystore.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwworld/inventorystore.cpp b/apps/openmw/mwworld/inventorystore.cpp index 6057cfcf4..3571f64ba 100644 --- a/apps/openmw/mwworld/inventorystore.cpp +++ b/apps/openmw/mwworld/inventorystore.cpp @@ -321,7 +321,19 @@ int MWWorld::InventoryStore::remove(const Ptr& item, int count, const Ptr& actor } } - return ContainerStore::remove(item, count, actor); + int retCount = ContainerStore::remove(item, count, actor); + + // If an armor/clothing item is removed, try to find a replacement, + // but not for the player nor werewolves. + if ((actor.getRefData().getHandle() != "player") + && !(MWWorld::Class::get(actor).getNpcStats(actor).isWerewolf())) + { + std::string type = item.getTypeName(); + if ((type == typeid(ESM::Armor).name()) || (type == typeid(ESM::Clothing).name())) + autoEquip(actor); + } + + return retCount; } void MWWorld::InventoryStore::unequipSlot(int slot, const MWWorld::Ptr& actor)