1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-26 18:35:20 +00:00

Implement MWWorld::InventoryStore::unequipAll()

This commit is contained in:
Emanuel Guevel 2013-08-06 11:20:51 +02:00
parent ddc92d1fbd
commit aa563e947e
2 changed files with 20 additions and 0 deletions

View File

@ -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<int> (mSlots.size()))

View File

@ -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.