|
|
@ -163,39 +163,39 @@ void DedicatedActor::setEquipment()
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
MWWorld::InventoryStore& invStore = ptr.getClass().getInventoryStore(ptr);
|
|
|
|
MWWorld::InventoryStore& invStore = ptr.getClass().getInventoryStore(ptr);
|
|
|
|
|
|
|
|
|
|
|
|
for (int slot = 0; slot < MWWorld::InventoryStore::Slots; ++slot)
|
|
|
|
for (int slot = 0; slot < MWWorld::InventoryStore::Slots; ++slot)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MWWorld::ContainerStoreIterator it = invStore.getSlot(slot);
|
|
|
|
MWWorld::ContainerStoreIterator it = invStore.getSlot(slot);
|
|
|
|
|
|
|
|
|
|
|
|
const string &dedicItem = equipedItems[slot].refId;
|
|
|
|
const string &packetRefId = equipedItems[slot].refId;
|
|
|
|
std::string item = "";
|
|
|
|
int packetCharge = equipedItems[slot].charge;
|
|
|
|
|
|
|
|
std::string storeRefId = "";
|
|
|
|
bool equal = false;
|
|
|
|
bool equal = false;
|
|
|
|
|
|
|
|
|
|
|
|
if (it != invStore.end())
|
|
|
|
if (it != invStore.end())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
item = it->getCellRef().getRefId();
|
|
|
|
storeRefId = it->getCellRef().getRefId();
|
|
|
|
if (!Misc::StringUtils::ciEqual(item, dedicItem)) // if other item equiped
|
|
|
|
|
|
|
|
|
|
|
|
if (!Misc::StringUtils::ciEqual(storeRefId, packetRefId)) // if other item equiped
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MWWorld::ContainerStore &store = ptr.getClass().getContainerStore(ptr);
|
|
|
|
invStore.unequipSlot(slot, ptr);
|
|
|
|
store.remove(item, store.count(item), ptr);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
equal = true;
|
|
|
|
equal = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (dedicItem.empty() || equal)
|
|
|
|
if (packetRefId.empty() || equal)
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
int count = equipedItems[slot].count;
|
|
|
|
int count = equipedItems[slot].count;
|
|
|
|
ptr.getClass().getContainerStore(ptr).add(dedicItem, count, ptr);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (MWWorld::ContainerStoreIterator it2 = invStore.begin(); it2 != invStore.end(); ++it2)
|
|
|
|
if (hasItem(packetRefId, packetCharge))
|
|
|
|
|
|
|
|
equipItem(packetRefId, packetCharge);
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (::Misc::StringUtils::ciEqual(it2->getCellRef().getRefId(), dedicItem)) // equip item
|
|
|
|
ptr.getClass().getContainerStore(ptr).add(packetRefId, count, ptr);
|
|
|
|
{
|
|
|
|
equipItem(packetRefId, packetCharge);
|
|
|
|
boost::shared_ptr<MWWorld::Action> action = it2->getClass().use(*it2);
|
|
|
|
|
|
|
|
action->execute(ptr);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -225,6 +225,36 @@ void DedicatedActor::playSound()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool DedicatedActor::hasItem(std::string refId, int charge)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
MWWorld::InventoryStore& invStore = ptr.getClass().getInventoryStore(ptr);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (MWWorld::ContainerStoreIterator it = invStore.begin(); it != invStore.end(); ++it)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (::Misc::StringUtils::ciEqual(it->getCellRef().getRefId(), refId) && it->getCellRef().getCharge() == charge)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void DedicatedActor::equipItem(std::string refId, int charge)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
MWWorld::InventoryStore& invStore = ptr.getClass().getInventoryStore(ptr);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (MWWorld::ContainerStoreIterator it = invStore.begin(); it != invStore.end(); ++it)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (::Misc::StringUtils::ciEqual(it->getCellRef().getRefId(), refId) && it->getCellRef().getCharge() == charge)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
boost::shared_ptr<MWWorld::Action> action = it->getClass().use(*it);
|
|
|
|
|
|
|
|
action->execute(ptr);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MWWorld::Ptr DedicatedActor::getPtr()
|
|
|
|
MWWorld::Ptr DedicatedActor::getPtr()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return ptr;
|
|
|
|
return ptr;
|
|
|
|