diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index b55287cac2..210b296390 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -480,6 +480,10 @@ namespace MWScript { boost::shared_ptr action = (ptr.getClass().activate(ptr, actor)); action->execute (actor); + if (action->getTarget() != MWWorld::Ptr() && action->getTarget() != ptr) + { + updatePtr(ptr, action->getTarget()); + } } float InterpreterContext::getSecondsPassed() const diff --git a/apps/openmw/mwworld/action.cpp b/apps/openmw/mwworld/action.cpp index c29377ecb3..5663ba38f3 100644 --- a/apps/openmw/mwworld/action.cpp +++ b/apps/openmw/mwworld/action.cpp @@ -12,6 +12,11 @@ const MWWorld::Ptr& MWWorld::Action::getTarget() const return mTarget; } +void MWWorld::Action::setTarget(const MWWorld::Ptr& target) +{ + mTarget = target; +} + MWWorld::Action::Action (bool keepSound, const Ptr& target) : mKeepSound (keepSound), mSoundOffset(0), mTarget (target) {} diff --git a/apps/openmw/mwworld/action.hpp b/apps/openmw/mwworld/action.hpp index 38907cf442..6b4dff6aa8 100644 --- a/apps/openmw/mwworld/action.hpp +++ b/apps/openmw/mwworld/action.hpp @@ -23,10 +23,12 @@ namespace MWWorld protected: - const Ptr& getTarget() const; + void setTarget(const Ptr&); public: + const Ptr& getTarget() const; + Action (bool keepSound = false, const Ptr& target = Ptr()); ///< \param keepSound Keep playing the sound even if the object the sound is played on is removed. diff --git a/apps/openmw/mwworld/actiontake.cpp b/apps/openmw/mwworld/actiontake.cpp index 4e61357642..d858859a69 100644 --- a/apps/openmw/mwworld/actiontake.cpp +++ b/apps/openmw/mwworld/actiontake.cpp @@ -16,7 +16,8 @@ namespace MWWorld { MWBase::Environment::get().getMechanicsManager()->itemTaken( actor, getTarget(), MWWorld::Ptr(), getTarget().getRefData().getCount()); - actor.getClass().getContainerStore (actor).add (getTarget(), getTarget().getRefData().getCount(), actor); + MWWorld::Ptr newitem = *actor.getClass().getContainerStore (actor).add (getTarget(), getTarget().getRefData().getCount(), actor); MWBase::Environment::get().getWorld()->deleteObject (getTarget()); + setTarget(newitem); } }