forked from mirror/openmw-tes3mp
Call ContainerStore::remove() to remove items from inventory
Make placeObject() and dropObjectOnGround() in MWWorld to copy objects (and indicate it clearly). Enchanting an item now unequips it.
This commit is contained in:
parent
23b8206bdc
commit
10abb9d297
17 changed files with 101 additions and 163 deletions
|
@ -309,14 +309,19 @@ namespace MWBase
|
|||
|
||||
virtual void update (float duration, bool paused) = 0;
|
||||
|
||||
virtual bool placeObject(const MWWorld::Ptr& object, float cursorX, float cursorY) = 0;
|
||||
///< place an object into the gameworld at the specified cursor position
|
||||
virtual bool placeObject (const MWWorld::Ptr& object, float cursorX, float cursorY, int amount) = 0;
|
||||
///< copy and place an object into the gameworld at the specified cursor position
|
||||
/// @param object
|
||||
/// @param cursor X (relative 0-1)
|
||||
/// @param cursor Y (relative 0-1)
|
||||
/// @param number of objects to place
|
||||
/// @return true if the object was placed, or false if it was rejected because the position is too far away
|
||||
|
||||
virtual void dropObjectOnGround (const MWWorld::Ptr& actor, const MWWorld::Ptr& object) = 0;
|
||||
virtual void dropObjectOnGround (const MWWorld::Ptr& actor, const MWWorld::Ptr& object, int amount) = 0;
|
||||
///< copy and place an object into the gameworld at the given actor's position
|
||||
/// @param actor giving the dropped object position
|
||||
/// @param object
|
||||
/// @param number of objects to place
|
||||
|
||||
virtual bool canPlaceObject (float cursorX, float cursorY) = 0;
|
||||
///< @return true if it is possible to place on object at specified cursor location
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "../mwworld/actiontake.hpp"
|
||||
#include "../mwworld/actionapply.hpp"
|
||||
#include "../mwworld/cellstore.hpp"
|
||||
#include "../mwworld/containerstore.hpp"
|
||||
#include "../mwworld/physicssystem.hpp"
|
||||
#include "../mwworld/player.hpp"
|
||||
#include "../mwworld/nullaction.hpp"
|
||||
|
@ -164,10 +165,11 @@ namespace MWClass
|
|||
MWWorld::LiveCellRef<ESM::Potion> *ref =
|
||||
ptr.get<ESM::Potion>();
|
||||
|
||||
ptr.getRefData().setCount (ptr.getRefData().getCount()-1);
|
||||
|
||||
MWWorld::Ptr actor = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||
|
||||
// remove used potion (assume it is present in inventory)
|
||||
ptr.getContainerStore()->remove(ptr, 1, actor);
|
||||
|
||||
boost::shared_ptr<MWWorld::Action> action (
|
||||
new MWWorld::ActionApply (actor, ref->mBase->mId));
|
||||
|
||||
|
|
|
@ -94,9 +94,7 @@ void ContainerItemModel::removeItem (const ItemStack& item, size_t count)
|
|||
{
|
||||
if (stacks(*it, item.mBase))
|
||||
{
|
||||
int refCount = it->getRefData().getCount();
|
||||
it->getRefData().setCount(std::max(0, refCount - toRemove));
|
||||
toRemove -= refCount;
|
||||
toRemove -= store.remove(*it, toRemove, *source);
|
||||
if (toRemove <= 0)
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -243,21 +243,16 @@ namespace MWGui
|
|||
float mouseX = cursorPosition.left / float(viewSize.width);
|
||||
float mouseY = cursorPosition.top / float(viewSize.height);
|
||||
|
||||
int origCount = object.getRefData().getCount();
|
||||
object.getRefData().setCount(mDragAndDrop->mDraggedCount);
|
||||
|
||||
if (world->canPlaceObject(mouseX, mouseY))
|
||||
world->placeObject(object, mouseX, mouseY);
|
||||
world->placeObject(object, mouseX, mouseY, mDragAndDrop->mDraggedCount);
|
||||
else
|
||||
world->dropObjectOnGround(world->getPlayer().getPlayer(), object);
|
||||
world->dropObjectOnGround(world->getPlayer().getPlayer(), object, mDragAndDrop->mDraggedCount);
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->changePointer("arrow");
|
||||
|
||||
std::string sound = MWWorld::Class::get(object).getDownSoundId(object);
|
||||
MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0);
|
||||
|
||||
object.getRefData().setCount(origCount);
|
||||
|
||||
// remove object from the container it was coming from
|
||||
mDragAndDrop->mSourceModel->removeItem(mDragAndDrop->mItem, mDragAndDrop->mDraggedCount);
|
||||
mDragAndDrop->finish();
|
||||
|
|
|
@ -52,18 +52,12 @@ void InventoryItemModel::copyItem (const ItemStack& item, size_t count)
|
|||
void InventoryItemModel::removeItem (const ItemStack& item, size_t count)
|
||||
{
|
||||
MWWorld::ContainerStore& store = MWWorld::Class::get(mActor).getContainerStore(mActor);
|
||||
int removed = store.remove(item.mBase, count, mActor);
|
||||
|
||||
for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it)
|
||||
{
|
||||
if (*it == item.mBase)
|
||||
{
|
||||
if (it->getRefData().getCount() < static_cast<int>(count))
|
||||
throw std::runtime_error("Not enough items in the stack to remove");
|
||||
it->getRefData().setCount(it->getRefData().getCount() - count);
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw std::runtime_error("Item to remove not found in container store");
|
||||
if (removed == 0)
|
||||
throw std::runtime_error("Item to remove not found in container store");
|
||||
else if (removed < count)
|
||||
throw std::runtime_error("Not enough items in the stack to remove");
|
||||
}
|
||||
|
||||
void InventoryItemModel::update()
|
||||
|
|
|
@ -202,31 +202,19 @@ namespace MWGui
|
|||
|
||||
void TradeWindow::addOrRemoveGold(int amount)
|
||||
{
|
||||
bool goldFound = false;
|
||||
MWWorld::Ptr gold;
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||
MWWorld::ContainerStore& playerStore = MWWorld::Class::get(player).getContainerStore(player);
|
||||
|
||||
for (MWWorld::ContainerStoreIterator it = playerStore.begin();
|
||||
it != playerStore.end(); ++it)
|
||||
if (amount > 0)
|
||||
{
|
||||
if (Misc::StringUtils::ciEqual(it->getCellRef().mRefID, "gold_001"))
|
||||
{
|
||||
goldFound = true;
|
||||
gold = *it;
|
||||
}
|
||||
}
|
||||
if (goldFound)
|
||||
{
|
||||
gold.getRefData().setCount(gold.getRefData().getCount() + amount);
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(amount > 0);
|
||||
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), "Gold_001");
|
||||
ref.getPtr().getRefData().setCount(amount);
|
||||
playerStore.add(ref.getPtr(), player);
|
||||
}
|
||||
else
|
||||
{
|
||||
playerStore.remove("gold_001", - amount, player);
|
||||
}
|
||||
}
|
||||
|
||||
void TradeWindow::onFrame(float frameDuration)
|
||||
|
|
|
@ -244,7 +244,7 @@ namespace MWMechanics
|
|||
heldIter->getClass().setRemainingUsageTime(*heldIter, timeRemaining);
|
||||
else
|
||||
{
|
||||
heldIter->getRefData().setCount(0); // remove it
|
||||
inventoryStore.remove(*heldIter, 1, ptr); // remove it
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ namespace MWMechanics
|
|||
// Both NPC and player lights extinguish in water.
|
||||
if(MWBase::Environment::get().getWorld()->isSwimming(ptr))
|
||||
{
|
||||
heldIter->getRefData().setCount(0); // remove it
|
||||
inventoryStore.remove(*heldIter, 1, ptr); // remove it
|
||||
|
||||
// ...But, only the player makes a sound.
|
||||
if(isPlayer)
|
||||
|
|
|
@ -240,7 +240,8 @@ void MWMechanics::Alchemy::removeIngredients()
|
|||
for (TIngredientsContainer::iterator iter (mIngredients.begin()); iter!=mIngredients.end(); ++iter)
|
||||
if (!iter->isEmpty())
|
||||
{
|
||||
iter->getRefData().setCount (iter->getRefData().getCount()-1);
|
||||
iter->getContainerStore()->remove(*iter, 1, mAlchemist);
|
||||
|
||||
if (iter->getRefData().getCount()<1)
|
||||
{
|
||||
needsUpdate = true;
|
||||
|
|
|
@ -14,7 +14,6 @@ namespace MWMechanics
|
|||
Enchanting::Enchanting()
|
||||
: mCastStyle(ESM::Enchantment::CastOnce)
|
||||
, mSelfEnchanting(false)
|
||||
, mOldItemCount(0)
|
||||
{}
|
||||
|
||||
void Enchanting::setOldItem(MWWorld::Ptr oldItem)
|
||||
|
@ -24,7 +23,6 @@ namespace MWMechanics
|
|||
{
|
||||
mObjectType = mOldItemPtr.getTypeName();
|
||||
mOldItemId = mOldItemPtr.getCellRef().mRefID;
|
||||
mOldItemCount = mOldItemPtr.getRefData().getCount();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -55,17 +53,18 @@ namespace MWMechanics
|
|||
|
||||
bool Enchanting::create()
|
||||
{
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||
const MWWorld::Ptr& player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||
MWWorld::ContainerStore& store = MWWorld::Class::get(player).getContainerStore(player);
|
||||
ESM::Enchantment enchantment;
|
||||
enchantment.mData.mCharge = getGemCharge();
|
||||
|
||||
mSoulGemPtr.getRefData().setCount (mSoulGemPtr.getRefData().getCount()-1);
|
||||
store.remove(mSoulGemPtr, 1, player);
|
||||
|
||||
//Exception for Azura Star, new one will be added after enchanting
|
||||
if(boost::iequals(mSoulGemPtr.get<ESM::Miscellaneous>()->mBase->mId, "Misc_SoulGem_Azura"))
|
||||
{
|
||||
MWWorld::ManualRef azura (MWBase::Environment::get().getWorld()->getStore(), "Misc_SoulGem_Azura");
|
||||
MWWorld::Class::get (player).getContainerStore (player).add (azura.getPtr(), player);
|
||||
store.add(azura.getPtr(), player);
|
||||
}
|
||||
|
||||
if(mSelfEnchanting)
|
||||
|
@ -84,16 +83,19 @@ namespace MWMechanics
|
|||
enchantment.mData.mCost = getEnchantPoints();
|
||||
enchantment.mEffects = mEffectList;
|
||||
|
||||
const ESM::Enchantment *enchantmentPtr = MWBase::Environment::get().getWorld()->createRecord (enchantment);
|
||||
|
||||
MWWorld::Class::get(mOldItemPtr).applyEnchantment(mOldItemPtr, enchantmentPtr->mId, getGemCharge(), mNewItemName);
|
||||
|
||||
mOldItemPtr.getRefData().setCount(1);
|
||||
|
||||
// Create a new item
|
||||
MWWorld::ManualRef ref (MWBase::Environment::get().getWorld()->getStore(), mOldItemId);
|
||||
ref.getPtr().getRefData().setCount (mOldItemCount-1);
|
||||
const MWWorld::Ptr& newItemPtr = ref.getPtr();
|
||||
newItemPtr.getRefData().setCount(1);
|
||||
|
||||
// Apply the enchantment
|
||||
const ESM::Enchantment *enchantmentPtr = MWBase::Environment::get().getWorld()->createRecord (enchantment);
|
||||
MWWorld::Class::get(newItemPtr).applyEnchantment(newItemPtr, enchantmentPtr->mId, getGemCharge(), mNewItemName);
|
||||
|
||||
// Add the new item to player inventory and remove the old one
|
||||
store.add(newItemPtr, player);
|
||||
store.remove(mOldItemPtr, 1, player);
|
||||
|
||||
MWWorld::Class::get (player).getContainerStore (player).add (ref.getPtr(), player);
|
||||
if(!mSelfEnchanting)
|
||||
payForEnchantment();
|
||||
|
||||
|
@ -299,20 +301,9 @@ namespace MWMechanics
|
|||
|
||||
void Enchanting::payForEnchantment() const
|
||||
{
|
||||
MWWorld::Ptr gold;
|
||||
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||
const MWWorld::Ptr& player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||
MWWorld::ContainerStore& store = MWWorld::Class::get(player).getContainerStore(player);
|
||||
|
||||
for (MWWorld::ContainerStoreIterator it = store.begin();
|
||||
it != store.end(); ++it)
|
||||
{
|
||||
if (Misc::StringUtils::ciEqual(it->getCellRef().mRefID, "gold_001"))
|
||||
{
|
||||
gold = *it;
|
||||
}
|
||||
}
|
||||
|
||||
gold.getRefData().setCount(gold.getRefData().getCount() - getEnchantPrice());
|
||||
store.remove("gold_001", getEnchantPrice(), player);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ namespace MWMechanics
|
|||
std::string mNewItemName;
|
||||
std::string mObjectType;
|
||||
std::string mOldItemId;
|
||||
int mOldItemCount;
|
||||
|
||||
public:
|
||||
Enchanting();
|
||||
|
|
|
@ -85,7 +85,10 @@ void Repair::repair(const MWWorld::Ptr &itemToRepair)
|
|||
// tool used up?
|
||||
if (mTool.getCellRef().mCharge == 0)
|
||||
{
|
||||
mTool.getRefData().setCount(0);
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||
MWWorld::ContainerStore& store = MWWorld::Class::get(player).getContainerStore(player);
|
||||
|
||||
store.remove(mTool, 1, player);
|
||||
|
||||
std::string message = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>()
|
||||
.find("sNotifyMessage51")->getString();
|
||||
|
@ -93,8 +96,6 @@ void Repair::repair(const MWWorld::Ptr &itemToRepair)
|
|||
MWBase::Environment::get().getWindowManager()->messageBox((boost::format(message) % MWWorld::Class::get(mTool).getName(mTool)).str());
|
||||
|
||||
// try to find a new tool of the same ID
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||
MWWorld::ContainerStore& store = MWWorld::Class::get(player).getContainerStore(player);
|
||||
for (MWWorld::ContainerStoreIterator iter (store.begin());
|
||||
iter!=store.end(); ++iter)
|
||||
{
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwworld/player.hpp"
|
||||
#include "../mwworld/containerstore.hpp"
|
||||
|
||||
#include "../mwbase/world.hpp"
|
||||
#include "../mwbase/environment.hpp"
|
||||
|
@ -61,7 +62,7 @@ namespace MWMechanics
|
|||
lockpick.getCellRef().mCharge = lockpick.get<ESM::Lockpick>()->mBase->mData.mUses;
|
||||
--lockpick.getCellRef().mCharge;
|
||||
if (!lockpick.getCellRef().mCharge)
|
||||
lockpick.getRefData().setCount(0);
|
||||
lockpick.getContainerStore()->remove(lockpick, 1, mActor);
|
||||
}
|
||||
|
||||
void Security::probeTrap(const MWWorld::Ptr &trap, const MWWorld::Ptr &probe,
|
||||
|
@ -103,7 +104,7 @@ namespace MWMechanics
|
|||
probe.getCellRef().mCharge = probe.get<ESM::Probe>()->mBase->mData.mUses;
|
||||
--probe.getCellRef().mCharge;
|
||||
if (!probe.getCellRef().mCharge)
|
||||
probe.getRefData().setCount(0);
|
||||
probe.getContainerStore()->remove(probe, 1, mActor);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -139,37 +139,14 @@ namespace MWScript
|
|||
|
||||
std::string itemName = "";
|
||||
|
||||
// originalCount holds the total number of items to remove, count holds the remaining number of items to remove
|
||||
Interpreter::Type_Integer originalCount = count;
|
||||
|
||||
for (MWWorld::ContainerStoreIterator iter (store.begin()); iter!=store.end() && count;
|
||||
++iter)
|
||||
{
|
||||
if (Misc::StringUtils::ciEqual(iter->getCellRef().mRefID, item))
|
||||
{
|
||||
itemName = MWWorld::Class::get(*iter).getName(*iter);
|
||||
|
||||
if (iter->getRefData().getCount()<=count)
|
||||
{
|
||||
count -= iter->getRefData().getCount();
|
||||
iter->getRefData().setCount (0);
|
||||
}
|
||||
else
|
||||
{
|
||||
iter->getRefData().setCount (iter->getRefData().getCount()-count);
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
int numRemoved = store.remove(item, count, ptr);
|
||||
|
||||
// Spawn a messagebox (only for items removed from player's inventory)
|
||||
if (ptr == MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer())
|
||||
if ((numRemoved > 0)
|
||||
&& (ptr == MWBase::Environment::get().getWorld()->getPlayer().getPlayer()))
|
||||
{
|
||||
// The two GMST entries below expand to strings informing the player of what, and how many of it has been removed from their inventory
|
||||
std::string msgBox;
|
||||
int numRemoved = (originalCount - count);
|
||||
if (numRemoved == 0)
|
||||
return;
|
||||
|
||||
if(numRemoved > 1)
|
||||
{
|
||||
|
|
|
@ -374,18 +374,7 @@ namespace MWScript
|
|||
|
||||
MWWorld::ContainerStore& store = MWWorld::Class::get (ptr).getContainerStore (ptr);
|
||||
|
||||
|
||||
for (MWWorld::ContainerStoreIterator iter (store.begin()); iter!=store.end(); ++iter)
|
||||
{
|
||||
if (::Misc::StringUtils::ciEqual(iter->getCellRef().mSoul, soul))
|
||||
{
|
||||
if (iter->getRefData().getCount() <= 1)
|
||||
iter->getRefData().setCount (0);
|
||||
else
|
||||
iter->getRefData().setCount (iter->getRefData().getCount() - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
store.remove(soul, 1, ptr);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -415,24 +404,18 @@ namespace MWScript
|
|||
MWWorld::ContainerStore& store = MWWorld::Class::get (ptr).getContainerStore (ptr);
|
||||
|
||||
|
||||
int toRemove = amount;
|
||||
for (MWWorld::ContainerStoreIterator iter (store.begin()); iter!=store.end(); ++iter)
|
||||
{
|
||||
if (::Misc::StringUtils::ciEqual(iter->getCellRef().mRefID, item))
|
||||
{
|
||||
if(iter->getRefData().getCount() <= amount)
|
||||
{
|
||||
MWBase::Environment::get().getWorld()->dropObjectOnGround(ptr, *iter);
|
||||
iter->getRefData().setCount(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
int original = iter->getRefData().getCount();
|
||||
iter->getRefData().setCount(amount);
|
||||
MWBase::Environment::get().getWorld()->dropObjectOnGround(ptr, *iter);
|
||||
iter->getRefData().setCount(original - amount);
|
||||
}
|
||||
int removed = store.remove(*iter, toRemove, ptr);
|
||||
MWBase::Environment::get().getWorld()->dropObjectOnGround(ptr, *iter, removed);
|
||||
|
||||
break;
|
||||
toRemove -= removed;
|
||||
|
||||
if (toRemove <= 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -458,20 +441,8 @@ namespace MWScript
|
|||
{
|
||||
if (::Misc::StringUtils::ciEqual(iter->getCellRef().mSoul, soul))
|
||||
{
|
||||
|
||||
if(iter->getRefData().getCount() <= 1)
|
||||
{
|
||||
MWBase::Environment::get().getWorld()->dropObjectOnGround(ptr, *iter);
|
||||
iter->getRefData().setCount(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
int original = iter->getRefData().getCount();
|
||||
iter->getRefData().setCount(1);
|
||||
MWBase::Environment::get().getWorld()->dropObjectOnGround(ptr, *iter);
|
||||
iter->getRefData().setCount(original - 1);
|
||||
}
|
||||
|
||||
MWBase::Environment::get().getWorld()->dropObjectOnGround(ptr, *iter, 1);
|
||||
store.remove(*iter, 1, ptr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -545,7 +516,13 @@ namespace MWScript
|
|||
if (ptr.isInCell())
|
||||
MWBase::Environment::get().getWorld()->deleteObject (ptr);
|
||||
else
|
||||
ptr.getRefData().setCount(0);
|
||||
{
|
||||
MWWorld::ContainerStore* store = ptr.getContainerStore();
|
||||
if (store != NULL)
|
||||
store->remove(ptr, ptr.getRefData().getCount(), ptr);
|
||||
else
|
||||
ptr.getRefData().setCount(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#include "../mwmechanics/creaturestats.hpp"
|
||||
#include "../mwmechanics/npcstats.hpp"
|
||||
|
||||
#include "../mwworld/containerstore.hpp"
|
||||
|
||||
#include "esmstore.hpp"
|
||||
#include "class.hpp"
|
||||
|
||||
|
@ -18,8 +20,8 @@ namespace MWWorld
|
|||
{
|
||||
void ActionEat::executeImp (const Ptr& actor)
|
||||
{
|
||||
// remove used item
|
||||
getTarget().getRefData().setCount (getTarget().getRefData().getCount()-1);
|
||||
// remove used item (assume the item is present in inventory)
|
||||
getTarget().getContainerStore()->remove(getTarget(), 1, actor);
|
||||
|
||||
// check for success
|
||||
const MWMechanics::CreatureStats& creatureStats = MWWorld::Class::get (actor).getCreatureStats (actor);
|
||||
|
|
|
@ -1477,7 +1477,7 @@ namespace MWWorld
|
|||
item.getRefData().getLocals().setVarByInt(script, "onpcdrop", 1);
|
||||
}
|
||||
|
||||
bool World::placeObject (const Ptr& object, float cursorX, float cursorY)
|
||||
bool World::placeObject (const MWWorld::Ptr& object, float cursorX, float cursorY, int amount)
|
||||
{
|
||||
std::pair<bool, Ogre::Vector3> result = mPhysics->castRay(cursorX, cursorY);
|
||||
|
||||
|
@ -1502,9 +1502,14 @@ namespace MWWorld
|
|||
pos.rot[0] = 0;
|
||||
pos.rot[1] = 0;
|
||||
|
||||
// copy the object and set its count
|
||||
int origCount = object.getRefData().getCount();
|
||||
object.getRefData().setCount(amount);
|
||||
Ptr dropped = copyObjectToCell(object, *cell, pos);
|
||||
object.getRefData().setCount(origCount);
|
||||
|
||||
// only the player place items in the world, so no need to check actor
|
||||
PCDropped(dropped);
|
||||
object.getRefData().setCount(0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1549,7 +1554,7 @@ namespace MWWorld
|
|||
return dropped;
|
||||
}
|
||||
|
||||
void World::dropObjectOnGround (const Ptr& actor, const Ptr& object)
|
||||
void World::dropObjectOnGround (const Ptr& actor, const Ptr& object, int amount)
|
||||
{
|
||||
MWWorld::Ptr::CellStore* cell = actor.getCell();
|
||||
|
||||
|
@ -1570,10 +1575,14 @@ namespace MWWorld
|
|||
mPhysics->castRay(orig, dir, len);
|
||||
pos.pos[2] = hit.second.z;
|
||||
|
||||
// copy the object and set its count
|
||||
int origCount = object.getRefData().getCount();
|
||||
object.getRefData().setCount(amount);
|
||||
Ptr dropped = copyObjectToCell(object, *cell, pos);
|
||||
object.getRefData().setCount(origCount);
|
||||
|
||||
if(actor == mPlayer->getPlayer()) // Only call if dropped by player
|
||||
PCDropped(dropped);
|
||||
object.getRefData().setCount(0);
|
||||
}
|
||||
|
||||
void World::processChangedSettings(const Settings::CategorySettingVector& settings)
|
||||
|
@ -1955,14 +1964,7 @@ namespace MWWorld
|
|||
}
|
||||
else
|
||||
{
|
||||
ContainerStore &store = Class::get(actor).getContainerStore(actor);
|
||||
|
||||
const std::string item = "WerewolfRobe";
|
||||
for(ContainerStoreIterator iter(store.begin());iter != store.end();++iter)
|
||||
{
|
||||
if(Misc::StringUtils::ciEqual(iter->getCellRef().mRefID, item))
|
||||
iter->getRefData().setCount(0);
|
||||
}
|
||||
Class::get(actor).getContainerStore(actor).remove("WerewolfRobe", 1, actor);
|
||||
}
|
||||
|
||||
if(actor.getRefData().getHandle() == "player")
|
||||
|
|
|
@ -354,14 +354,19 @@ namespace MWWorld
|
|||
|
||||
virtual void update (float duration, bool paused);
|
||||
|
||||
virtual bool placeObject (const Ptr& object, float cursorX, float cursorY);
|
||||
///< place an object into the gameworld at the specified cursor position
|
||||
virtual bool placeObject (const MWWorld::Ptr& object, float cursorX, float cursorY, int amount);
|
||||
///< copy and place an object into the gameworld at the specified cursor position
|
||||
/// @param object
|
||||
/// @param cursor X (relative 0-1)
|
||||
/// @param cursor Y (relative 0-1)
|
||||
/// @param number of objects to place
|
||||
/// @return true if the object was placed, or false if it was rejected because the position is too far away
|
||||
|
||||
virtual void dropObjectOnGround (const Ptr& actor, const Ptr& object);
|
||||
virtual void dropObjectOnGround (const MWWorld::Ptr& actor, const MWWorld::Ptr& object, int amount);
|
||||
///< copy and place an object into the gameworld at the given actor's position
|
||||
/// @param actor giving the dropped object position
|
||||
/// @param object
|
||||
/// @param number of objects to place
|
||||
|
||||
virtual bool canPlaceObject(float cursorX, float cursorY);
|
||||
///< @return true if it is possible to place on object at specified cursor location
|
||||
|
|
Loading…
Reference in a new issue