From 782d417d5bd17a45ed202756f9dac795dd6f446a Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 13 Jul 2012 13:09:22 +0200 Subject: [PATCH] Issue #314: potion usage --- apps/openmw/mwclass/potion.cpp | 12 ++++++++++++ apps/openmw/mwclass/potion.hpp | 3 +++ 2 files changed, 15 insertions(+) diff --git a/apps/openmw/mwclass/potion.cpp b/apps/openmw/mwclass/potion.cpp index 5b446fbe9..d3d615262 100644 --- a/apps/openmw/mwclass/potion.cpp +++ b/apps/openmw/mwclass/potion.cpp @@ -8,6 +8,7 @@ #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" +#include "../mwworld/actionapply.hpp" #include "../mwworld/cellstore.hpp" #include "../mwworld/physicssystem.hpp" @@ -144,4 +145,15 @@ namespace MWClass return info; } + + boost::shared_ptr Potion::use (const MWWorld::Ptr& ptr) const + { + MWWorld::LiveCellRef *ref = + ptr.get(); + + ptr.getRefData().setCount (ptr.getRefData().getCount()-1); + + return boost::shared_ptr ( + new MWWorld::ActionApply (ptr, ref->base->mId, ptr)); + } } diff --git a/apps/openmw/mwclass/potion.hpp b/apps/openmw/mwclass/potion.hpp index 74779864a..ac5d85f23 100644 --- a/apps/openmw/mwclass/potion.hpp +++ b/apps/openmw/mwclass/potion.hpp @@ -34,6 +34,9 @@ namespace MWClass virtual int getValue (const MWWorld::Ptr& ptr) const; ///< Return trade value of the object. Throws an exception, if the object can't be traded. + virtual boost::shared_ptr use (const MWWorld::Ptr& ptr) const; + ///< Generate action for using via inventory menu + static void registerSelf(); virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const;