mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-27 03:35:27 +00:00
Stop merchants from autoequipping items sold to them
This commit is contained in:
parent
dde2cd5d5a
commit
2f35e5a04e
@ -123,10 +123,10 @@ bool MWWorld::ContainerStore::stacks(const Ptr& ptr1, const Ptr& ptr2)
|
|||||||
MWWorld::ContainerStoreIterator MWWorld::ContainerStore::add(const std::string &id, int count, const Ptr &actorPtr)
|
MWWorld::ContainerStoreIterator MWWorld::ContainerStore::add(const std::string &id, int count, const Ptr &actorPtr)
|
||||||
{
|
{
|
||||||
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), id, count);
|
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), id, count);
|
||||||
return add(ref.getPtr(), count, actorPtr);
|
return add(ref.getPtr(), count, actorPtr, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
MWWorld::ContainerStoreIterator MWWorld::ContainerStore::add (const Ptr& itemPtr, int count, const Ptr& actorPtr)
|
MWWorld::ContainerStoreIterator MWWorld::ContainerStore::add (const Ptr& itemPtr, int count, const Ptr& actorPtr, bool setOwner)
|
||||||
{
|
{
|
||||||
MWWorld::ContainerStoreIterator it = addImp(itemPtr, count);
|
MWWorld::ContainerStoreIterator it = addImp(itemPtr, count);
|
||||||
MWWorld::Ptr item = *it;
|
MWWorld::Ptr item = *it;
|
||||||
@ -140,6 +140,9 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::add (const Ptr& itemPtr
|
|||||||
item.getCellRef().mPos.pos[1] = 0;
|
item.getCellRef().mPos.pos[1] = 0;
|
||||||
item.getCellRef().mPos.pos[2] = 0;
|
item.getCellRef().mPos.pos[2] = 0;
|
||||||
|
|
||||||
|
if (setOwner)
|
||||||
|
item.getCellRef().mOwner = actorPtr.getCellRef().mRefID;
|
||||||
|
|
||||||
std::string script = MWWorld::Class::get(item).getScript(item);
|
std::string script = MWWorld::Class::get(item).getScript(item);
|
||||||
if(script != "")
|
if(script != "")
|
||||||
{
|
{
|
||||||
|
@ -64,7 +64,7 @@ namespace MWWorld
|
|||||||
|
|
||||||
ContainerStoreIterator end();
|
ContainerStoreIterator end();
|
||||||
|
|
||||||
virtual ContainerStoreIterator add (const Ptr& itemPtr, int count, const Ptr& actorPtr);
|
virtual ContainerStoreIterator add (const Ptr& itemPtr, int count, const Ptr& actorPtr, bool setOwner=false);
|
||||||
///< Add the item pointed to by \a ptr to this container. (Stacks automatically if needed)
|
///< Add the item pointed to by \a ptr to this container. (Stacks automatically if needed)
|
||||||
///
|
///
|
||||||
/// \note The item pointed to is not required to exist beyond this function call.
|
/// \note The item pointed to is not required to exist beyond this function call.
|
||||||
@ -72,10 +72,12 @@ namespace MWWorld
|
|||||||
/// \attention Do not add items to an existing stack by increasing the count instead of
|
/// \attention Do not add items to an existing stack by increasing the count instead of
|
||||||
/// calling this function!
|
/// calling this function!
|
||||||
///
|
///
|
||||||
|
/// @param setOwner Set the owner of the added item to \a actorPtr?
|
||||||
|
///
|
||||||
/// @return if stacking happened, return iterator to the item that was stacked against, otherwise iterator to the newly inserted item.
|
/// @return if stacking happened, return iterator to the item that was stacked against, otherwise iterator to the newly inserted item.
|
||||||
|
|
||||||
ContainerStoreIterator add(const std::string& id, int count, const Ptr& actorPtr);
|
ContainerStoreIterator add(const std::string& id, int count, const Ptr& actorPtr);
|
||||||
///< Utility to construct a ManualRef and call add(ptr, actorPtr)
|
///< Utility to construct a ManualRef and call add(ptr, count, actorPtr, true)
|
||||||
|
|
||||||
int remove(const std::string& itemId, int count, const Ptr& actor);
|
int remove(const std::string& itemId, int count, const Ptr& actor);
|
||||||
///< Remove \a count item(s) designated by \a itemId from this container.
|
///< Remove \a count item(s) designated by \a itemId from this container.
|
||||||
|
@ -75,9 +75,9 @@ MWWorld::InventoryStore& MWWorld::InventoryStore::operator= (const InventoryStor
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
MWWorld::ContainerStoreIterator MWWorld::InventoryStore::add(const Ptr& itemPtr, int count, const Ptr& actorPtr)
|
MWWorld::ContainerStoreIterator MWWorld::InventoryStore::add(const Ptr& itemPtr, int count, const Ptr& actorPtr, bool setOwner)
|
||||||
{
|
{
|
||||||
const MWWorld::ContainerStoreIterator& retVal = MWWorld::ContainerStore::add(itemPtr, count, actorPtr);
|
const MWWorld::ContainerStoreIterator& retVal = MWWorld::ContainerStore::add(itemPtr, count, actorPtr, setOwner);
|
||||||
|
|
||||||
// Auto-equip items if an armor/clothing item is added, but not for the player nor werewolves
|
// Auto-equip items if an armor/clothing item is added, but not for the player nor werewolves
|
||||||
if ((actorPtr.getRefData().getHandle() != "player")
|
if ((actorPtr.getRefData().getHandle() != "player")
|
||||||
@ -183,6 +183,11 @@ void MWWorld::InventoryStore::autoEquip (const MWWorld::Ptr& actor)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Only autoEquip if we are the original owner of the item.
|
||||||
|
// This stops merchants from auto equipping anything you sell to them.
|
||||||
|
if (!Misc::StringUtils::ciEqual(test.getCellRef().mOwner, actor.getCellRef().mRefID))
|
||||||
|
continue;
|
||||||
|
|
||||||
int testSkill = MWWorld::Class::get (test).getEquipmentSkill (test);
|
int testSkill = MWWorld::Class::get (test).getEquipmentSkill (test);
|
||||||
|
|
||||||
std::pair<std::vector<int>, bool> itemsSlots =
|
std::pair<std::vector<int>, bool> itemsSlots =
|
||||||
|
@ -113,7 +113,7 @@ namespace MWWorld
|
|||||||
|
|
||||||
InventoryStore& operator= (const InventoryStore& store);
|
InventoryStore& operator= (const InventoryStore& store);
|
||||||
|
|
||||||
virtual ContainerStoreIterator add (const Ptr& itemPtr, int count, const Ptr& actorPtr);
|
virtual ContainerStoreIterator add (const Ptr& itemPtr, int count, const Ptr& actorPtr, bool setOwner=false);
|
||||||
///< Add the item pointed to by \a ptr to this container. (Stacks automatically if needed)
|
///< Add the item pointed to by \a ptr to this container. (Stacks automatically if needed)
|
||||||
/// Auto-equip items if specific conditions are fulfilled (see the implementation).
|
/// Auto-equip items if specific conditions are fulfilled (see the implementation).
|
||||||
///
|
///
|
||||||
@ -122,6 +122,8 @@ namespace MWWorld
|
|||||||
/// \attention Do not add items to an existing stack by increasing the count instead of
|
/// \attention Do not add items to an existing stack by increasing the count instead of
|
||||||
/// calling this function!
|
/// calling this function!
|
||||||
///
|
///
|
||||||
|
/// @param setOwner Set the owner of the added item to \a actorPtr?
|
||||||
|
///
|
||||||
/// @return if stacking happened, return iterator to the item that was stacked against, otherwise iterator to the newly inserted item.
|
/// @return if stacking happened, return iterator to the item that was stacked against, otherwise iterator to the newly inserted item.
|
||||||
|
|
||||||
void equip (int slot, const ContainerStoreIterator& iterator, const Ptr& actor);
|
void equip (int slot, const ContainerStoreIterator& iterator, const Ptr& actor);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user