mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 19:49:41 +00:00
parent
8d8f293a65
commit
6e405aed8c
7 changed files with 17 additions and 14 deletions
|
@ -144,7 +144,8 @@ namespace MWScript
|
||||||
if (::Misc::StringUtils::ciEqual(iter->getCellRef().getRefId(), item))
|
if (::Misc::StringUtils::ciEqual(iter->getCellRef().getRefId(), item))
|
||||||
itemName = iter->getClass().getName(*iter);
|
itemName = iter->getClass().getName(*iter);
|
||||||
|
|
||||||
int numRemoved = store.remove(item, count, ptr);
|
// Actors should not equip a replacement when items are removed with RemoveItem
|
||||||
|
int numRemoved = store.remove(item, count, ptr, false);
|
||||||
|
|
||||||
// Spawn a messagebox (only for items removed from player's inventory)
|
// Spawn a messagebox (only for items removed from player's inventory)
|
||||||
if ((numRemoved > 0)
|
if ((numRemoved > 0)
|
||||||
|
@ -199,7 +200,8 @@ namespace MWScript
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
boost::shared_ptr<MWWorld::Action> action = it->getClass().use(*it);
|
boost::shared_ptr<MWWorld::Action> action = it->getClass().use(*it);
|
||||||
action->execute(ptr);
|
// No equip sound for actors other than the player
|
||||||
|
action->execute(ptr, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -22,9 +22,9 @@ MWWorld::Action::Action (bool keepSound, const Ptr& target) : mKeepSound (keepSo
|
||||||
|
|
||||||
MWWorld::Action::~Action() {}
|
MWWorld::Action::~Action() {}
|
||||||
|
|
||||||
void MWWorld::Action::execute (const Ptr& actor)
|
void MWWorld::Action::execute (const Ptr& actor, bool noSound)
|
||||||
{
|
{
|
||||||
if(!mSoundId.empty())
|
if(!mSoundId.empty() && !noSound)
|
||||||
{
|
{
|
||||||
if(mKeepSound && actor == MWMechanics::getPlayer())
|
if(mKeepSound && actor == MWMechanics::getPlayer())
|
||||||
MWBase::Environment::get().getSoundManager()->playSound(mSoundId, 1.0, 1.0,
|
MWBase::Environment::get().getSoundManager()->playSound(mSoundId, 1.0, 1.0,
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace MWWorld
|
||||||
virtual bool isNullAction() { return false; }
|
virtual bool isNullAction() { return false; }
|
||||||
///< Is running this action a no-op? (default false)
|
///< Is running this action a no-op? (default false)
|
||||||
|
|
||||||
void execute (const Ptr& actor);
|
void execute (const Ptr& actor, bool noSound = false);
|
||||||
|
|
||||||
void setSound (const std::string& id);
|
void setSound (const std::string& id);
|
||||||
void setSoundOffset(float offset);
|
void setSoundOffset(float offset);
|
||||||
|
|
|
@ -398,13 +398,13 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::addNewStack (const Cons
|
||||||
return it;
|
return it;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MWWorld::ContainerStore::remove(const std::string& itemId, int count, const Ptr& actor)
|
int MWWorld::ContainerStore::remove(const std::string& itemId, int count, const Ptr& actor, bool equipReplacement)
|
||||||
{
|
{
|
||||||
int toRemove = count;
|
int toRemove = count;
|
||||||
|
|
||||||
for (ContainerStoreIterator iter(begin()); iter != end() && toRemove > 0; ++iter)
|
for (ContainerStoreIterator iter(begin()); iter != end() && toRemove > 0; ++iter)
|
||||||
if (Misc::StringUtils::ciEqual(iter->getCellRef().getRefId(), itemId))
|
if (Misc::StringUtils::ciEqual(iter->getCellRef().getRefId(), itemId))
|
||||||
toRemove -= remove(*iter, toRemove, actor);
|
toRemove -= remove(*iter, toRemove, actor, equipReplacement);
|
||||||
|
|
||||||
flagAsModified();
|
flagAsModified();
|
||||||
|
|
||||||
|
@ -412,7 +412,7 @@ int MWWorld::ContainerStore::remove(const std::string& itemId, int count, const
|
||||||
return count - toRemove;
|
return count - toRemove;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MWWorld::ContainerStore::remove(const Ptr& item, int count, const Ptr& actor)
|
int MWWorld::ContainerStore::remove(const Ptr& item, int count, const Ptr& actor, bool equipReplacement)
|
||||||
{
|
{
|
||||||
assert(this == item.getContainerStore());
|
assert(this == item.getContainerStore());
|
||||||
|
|
||||||
|
|
|
@ -142,12 +142,12 @@ namespace MWWorld
|
||||||
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, count, actorPtr, true)
|
///< 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, bool equipReplacement = true);
|
||||||
///< Remove \a count item(s) designated by \a itemId from this container.
|
///< Remove \a count item(s) designated by \a itemId from this container.
|
||||||
///
|
///
|
||||||
/// @return the number of items actually removed
|
/// @return the number of items actually removed
|
||||||
|
|
||||||
virtual int remove(const Ptr& item, int count, const Ptr& actor);
|
virtual int remove(const Ptr& item, int count, const Ptr& actor, bool equipReplacement = true);
|
||||||
///< Remove \a count item(s) designated by \a item from this inventory.
|
///< Remove \a count item(s) designated by \a item from this inventory.
|
||||||
///
|
///
|
||||||
/// @return the number of items actually removed
|
/// @return the number of items actually removed
|
||||||
|
|
|
@ -654,7 +654,7 @@ MWWorld::ContainerStoreIterator MWWorld::InventoryStore::getSelectedEnchantItem(
|
||||||
return mSelectedEnchantItem;
|
return mSelectedEnchantItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MWWorld::InventoryStore::remove(const Ptr& item, int count, const Ptr& actor)
|
int MWWorld::InventoryStore::remove(const Ptr& item, int count, const Ptr& actor, bool equipReplacement)
|
||||||
{
|
{
|
||||||
int retCount = ContainerStore::remove(item, count, actor);
|
int retCount = ContainerStore::remove(item, count, actor);
|
||||||
|
|
||||||
|
@ -676,8 +676,9 @@ int MWWorld::InventoryStore::remove(const Ptr& item, int count, const Ptr& actor
|
||||||
}
|
}
|
||||||
|
|
||||||
// If an armor/clothing item is removed, try to find a replacement,
|
// If an armor/clothing item is removed, try to find a replacement,
|
||||||
// but not for the player nor werewolves.
|
// but not for the player nor werewolves, and not if the RemoveItem script command
|
||||||
if (wasEquipped && (actor != MWMechanics::getPlayer())
|
// was used (equipReplacement is false)
|
||||||
|
if (equipReplacement && wasEquipped && (actor != MWMechanics::getPlayer())
|
||||||
&& actor.getClass().isNpc() && !actor.getClass().getNpcStats(actor).isWerewolf())
|
&& actor.getClass().isNpc() && !actor.getClass().getNpcStats(actor).isWerewolf())
|
||||||
{
|
{
|
||||||
std::string type = item.getTypeName();
|
std::string type = item.getTypeName();
|
||||||
|
|
|
@ -177,7 +177,7 @@ namespace MWWorld
|
||||||
virtual bool stacks (const ConstPtr& ptr1, const ConstPtr& ptr2) const;
|
virtual bool stacks (const ConstPtr& ptr1, const ConstPtr& ptr2) const;
|
||||||
///< @return true if the two specified objects can stack with each other
|
///< @return true if the two specified objects can stack with each other
|
||||||
|
|
||||||
virtual int remove(const Ptr& item, int count, const Ptr& actor);
|
virtual int remove(const Ptr& item, int count, const Ptr& actor, bool equipReplacement = true);
|
||||||
///< Remove \a count item(s) designated by \a item from this inventory.
|
///< Remove \a count item(s) designated by \a item from this inventory.
|
||||||
///
|
///
|
||||||
/// @return the number of items actually removed
|
/// @return the number of items actually removed
|
||||||
|
|
Loading…
Reference in a new issue