Merge pull request #197 from OpenMW/master

Add OpenMW commits up to 14 Apr 2017
0.6.1
David Cernat 8 years ago committed by GitHub
commit 11a9e3bdb1

@ -73,6 +73,8 @@ namespace MWMechanics
MWMechanics::CreatureStats& creatureStats = ptr.getClass().getCreatureStats (ptr);
MWMechanics::NpcStats& npcStats = ptr.getClass().getNpcStats (ptr);
npcStats.setNeedRecalcDynamicStats(true);
const ESM::NPC *player = ptr.get<ESM::NPC>()->mBase;
// reset

@ -158,7 +158,8 @@ namespace MWScript
if (::Misc::StringUtils::ciEqual(iter->getCellRef().getRefId(), item))
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)
if ((numRemoved > 0)
@ -213,7 +214,8 @@ namespace MWScript
else
{
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() {}
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())
MWBase::Environment::get().getSoundManager()->playSound(mSoundId, 1.0, 1.0,

@ -37,7 +37,7 @@ namespace MWWorld
virtual bool isNullAction() { return 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 setSoundOffset(float offset);

@ -398,13 +398,13 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::addNewStack (const Cons
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;
for (ContainerStoreIterator iter(begin()); iter != end() && toRemove > 0; ++iter)
if (Misc::StringUtils::ciEqual(iter->getCellRef().getRefId(), itemId))
toRemove -= remove(*iter, toRemove, actor);
toRemove -= remove(*iter, toRemove, actor, equipReplacement);
flagAsModified();
@ -412,7 +412,7 @@ int MWWorld::ContainerStore::remove(const std::string& itemId, int count, const
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());

@ -142,12 +142,12 @@ namespace MWWorld
ContainerStoreIterator add(const std::string& id, int count, const 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, bool equipReplacement = true);
///< Remove \a count item(s) designated by \a itemId from this container.
///
/// @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.
///
/// @return the number of items actually removed

@ -660,7 +660,7 @@ MWWorld::ContainerStoreIterator MWWorld::InventoryStore::getSelectedEnchantItem(
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);
@ -682,8 +682,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,
// but not for the player nor werewolves.
if (wasEquipped && (actor != MWMechanics::getPlayer())
// but not for the player nor werewolves, and not if the RemoveItem script command
// was used (equipReplacement is false)
if (equipReplacement && wasEquipped && (actor != MWMechanics::getPlayer())
&& actor.getClass().isNpc() && !actor.getClass().getNpcStats(actor).isWerewolf())
{
std::string type = item.getTypeName();

@ -177,7 +177,7 @@ namespace MWWorld
virtual bool stacks (const ConstPtr& ptr1, const ConstPtr& ptr2) const;
///< @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.
///
/// @return the number of items actually removed

Loading…
Cancel
Save