From aa563e947e0d012acc24a15456ae76aaa9ef84d9 Mon Sep 17 00:00:00 2001 From: Emanuel Guevel Date: Tue, 6 Aug 2013 11:20:51 +0200 Subject: [PATCH] Implement MWWorld::InventoryStore::unequipAll() --- apps/openmw/mwworld/inventorystore.cpp | 17 +++++++++++++++++ apps/openmw/mwworld/inventorystore.hpp | 3 +++ 2 files changed, 20 insertions(+) diff --git a/apps/openmw/mwworld/inventorystore.cpp b/apps/openmw/mwworld/inventorystore.cpp index 9d07ecb76..6867c71ce 100644 --- a/apps/openmw/mwworld/inventorystore.cpp +++ b/apps/openmw/mwworld/inventorystore.cpp @@ -110,6 +110,23 @@ void MWWorld::InventoryStore::equip (int slot, const ContainerStoreIterator& ite flagAsModified(); } +void MWWorld::InventoryStore::unequipAll() +{ + for (int slot=0; slot < MWWorld::InventoryStore::Slots; ++slot) + { + MWWorld::ContainerStoreIterator it = getSlot(slot); + if (it != end()) + { + equip(slot, end()); + std::string script = MWWorld::Class::get(*it).getScript(*it); + + // Unset OnPCEquip Variable on item's script, if it has a script with that variable declared + if(script != "") + (*it).mRefData->getLocals().setVarByInt(script, "onpcequip", 0); + } + } +} + MWWorld::ContainerStoreIterator MWWorld::InventoryStore::getSlot (int slot) { if (slot<0 || slot>=static_cast (mSlots.size())) diff --git a/apps/openmw/mwworld/inventorystore.hpp b/apps/openmw/mwworld/inventorystore.hpp index 0801e04bc..07d5f321e 100644 --- a/apps/openmw/mwworld/inventorystore.hpp +++ b/apps/openmw/mwworld/inventorystore.hpp @@ -78,6 +78,9 @@ namespace MWWorld ContainerStoreIterator getSlot (int slot); + void unequipAll(); + ///< Unequip all currently equipped items. + void autoEquip (const MWWorld::Ptr& npc); ///< Auto equip items according to stats and item value.