mirror of
https://github.com/TES3MP/TES3MP.git
synced 2025-10-02 09:31:12 -04:00
Split adjustBoundItem()
This commit is contained in:
parent
d1b1cb748d
commit
4de9d9fa77
@ -235,13 +235,11 @@ namespace MWMechanics
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void Actors::adjustBoundItem (const std::string& itemId, bool bound, const MWWorld::Ptr& actor)
|
void Actors::addBoundItem (const std::string& itemId, const MWWorld::Ptr& actor)
|
||||||
{
|
{
|
||||||
MWWorld::InventoryStore& store = actor.getClass().getInventoryStore(actor);
|
MWWorld::InventoryStore& store = actor.getClass().getInventoryStore(actor);
|
||||||
int slot = getBoundItemSlot(itemId);
|
int slot = getBoundItemSlot(itemId);
|
||||||
|
|
||||||
if (bound)
|
|
||||||
{
|
|
||||||
if (actor.getClass().getContainerStore(actor).count(itemId) != 0)
|
if (actor.getClass().getContainerStore(actor).count(itemId) != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -266,8 +264,12 @@ namespace MWMechanics
|
|||||||
if (prevItem != store.end())
|
if (prevItem != store.end())
|
||||||
mPreviousItems[itemId] = *prevItem;
|
mPreviousItems[itemId] = *prevItem;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
void Actors::removeBoundItem (const std::string& itemId, const MWWorld::Ptr& actor)
|
||||||
{
|
{
|
||||||
|
MWWorld::InventoryStore& store = actor.getClass().getInventoryStore(actor);
|
||||||
|
int slot = getBoundItemSlot(itemId);
|
||||||
|
|
||||||
MWWorld::ContainerStoreIterator currentItem = store.getSlot(slot);
|
MWWorld::ContainerStoreIterator currentItem = store.getSlot(slot);
|
||||||
|
|
||||||
bool wasEquipped = currentItem != store.end() && Misc::StringUtils::ciEqual((*currentItem).getCellRef().getRefId(), itemId);
|
bool wasEquipped = currentItem != store.end() && Misc::StringUtils::ciEqual((*currentItem).getCellRef().getRefId(), itemId);
|
||||||
@ -299,7 +301,6 @@ namespace MWMechanics
|
|||||||
MWWorld::ActionEquip action(prevItem);
|
MWWorld::ActionEquip action(prevItem);
|
||||||
action.execute(actor);
|
action.execute(actor);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void Actors::updateActor (const MWWorld::Ptr& ptr, float duration)
|
void Actors::updateActor (const MWWorld::Ptr& ptr, float duration)
|
||||||
{
|
{
|
||||||
@ -839,17 +840,14 @@ namespace MWMechanics
|
|||||||
std::string item = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find(
|
std::string item = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find(
|
||||||
itemGmst)->getString();
|
itemGmst)->getString();
|
||||||
|
|
||||||
|
magnitude > 0 ? addBoundItem(item, ptr) : removeBoundItem(item, ptr);
|
||||||
|
|
||||||
if (it->first == ESM::MagicEffect::BoundGloves)
|
if (it->first == ESM::MagicEffect::BoundGloves)
|
||||||
{
|
{
|
||||||
item = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find(
|
|
||||||
"sMagicBoundLeftGauntletID")->getString();
|
|
||||||
adjustBoundItem(item, magnitude > 0, ptr);
|
|
||||||
item = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find(
|
item = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find(
|
||||||
"sMagicBoundRightGauntletID")->getString();
|
"sMagicBoundRightGauntletID")->getString();
|
||||||
adjustBoundItem(item, magnitude > 0, ptr);
|
magnitude > 0 ? addBoundItem(item, ptr) : removeBoundItem(item, ptr);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
adjustBoundItem(item, magnitude > 0, ptr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,8 @@ namespace MWMechanics
|
|||||||
typedef std::map<std::string, MWWorld::Ptr> PreviousItems;
|
typedef std::map<std::string, MWWorld::Ptr> PreviousItems;
|
||||||
PreviousItems mPreviousItems;
|
PreviousItems mPreviousItems;
|
||||||
|
|
||||||
void adjustBoundItem (const std::string& itemId, bool bound, const MWWorld::Ptr& actor);
|
void addBoundItem (const std::string& itemId, const MWWorld::Ptr& actor);
|
||||||
|
void removeBoundItem (const std::string& itemId, const MWWorld::Ptr& actor);
|
||||||
|
|
||||||
void updateNpc(const MWWorld::Ptr &ptr, float duration);
|
void updateNpc(const MWWorld::Ptr &ptr, float duration);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user