diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 538f63dc9..67533cf4b 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -50,7 +50,7 @@ add_openmw_dir (mwsound add_openmw_dir (mwworld refdata worldimp physicssystem scene globals class action nullaction actionteleport - containerstore actiontalk actiontake manualref player cellfunctors + containerstore actiontalk actiontake manualref player cellfunctors failedaction cells localscripts customdata weather inventorystore ptr actionopen actionread actionequip timestamp actionalchemy cellstore actionapply actioneat ) diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index 237f451f3..0ebf6491d 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -8,7 +8,7 @@ #include "../mwbase/windowmanager.hpp" #include "../mwworld/ptr.hpp" -#include "../mwworld/nullaction.hpp" +#include "../mwworld/failedaction.hpp" #include "../mwworld/containerstore.hpp" #include "../mwworld/customdata.hpp" #include "../mwworld/cellstore.hpp" @@ -130,7 +130,7 @@ namespace MWClass { // Trap activation goes here std::cout << "Activated trap: " << ptr.getCellRef().mTrap << std::endl; - boost::shared_ptr action(new MWWorld::NullAction); + boost::shared_ptr action(new MWWorld::FailedAction()); action->setSound(trapActivationSound); ptr.getCellRef().mTrap = ""; return action; @@ -138,7 +138,7 @@ namespace MWClass } else { - boost::shared_ptr action(new MWWorld::NullAction); + boost::shared_ptr action(new MWWorld::FailedAction()); action->setSound(lockedSound); return action; } diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index f944391e1..63bd8fba0 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -10,6 +10,7 @@ #include "../mwworld/player.hpp" #include "../mwworld/ptr.hpp" #include "../mwworld/nullaction.hpp" +#include "../mwworld/failedaction.hpp" #include "../mwworld/actionteleport.hpp" #include "../mwworld/cellstore.hpp" #include "../mwworld/physicssystem.hpp" @@ -111,8 +112,7 @@ namespace MWClass // Trap activation std::cout << "Activated trap: " << ptr.getCellRef().mTrap << std::endl; - boost::shared_ptr action(new MWWorld::NullAction); - + boost::shared_ptr action(new MWWorld::FailedAction()); action->setSound(trapActivationSound); ptr.getCellRef().mTrap = ""; @@ -134,7 +134,7 @@ namespace MWClass else { // another NPC or a creature is using the door - return boost::shared_ptr (new MWWorld::NullAction); + return boost::shared_ptr (new MWWorld::FailedAction()); } } else @@ -153,7 +153,7 @@ namespace MWClass else { // locked, and we can't open. - boost::shared_ptr action(new MWWorld::NullAction); + boost::shared_ptr action(new MWWorld::FailedAction()); action->setSound(lockedSound); return action; } diff --git a/apps/openmw/mwclass/light.cpp b/apps/openmw/mwclass/light.cpp index 6ae9ed661..7af31cc2c 100644 --- a/apps/openmw/mwclass/light.cpp +++ b/apps/openmw/mwclass/light.cpp @@ -12,6 +12,7 @@ #include "../mwworld/actiontake.hpp" #include "../mwworld/actionequip.hpp" #include "../mwworld/nullaction.hpp" +#include "../mwworld/failedaction.hpp" #include "../mwworld/inventorystore.hpp" #include "../mwworld/cellstore.hpp" #include "../mwworld/physicssystem.hpp" @@ -92,7 +93,7 @@ namespace MWClass ptr.get(); if (!(ref->base->mData.mFlags & ESM::Light::Carry)) - return boost::shared_ptr (new MWWorld::NullAction); + return boost::shared_ptr (new MWWorld::FailedAction()); boost::shared_ptr action(new MWWorld::ActionTake (ptr)); diff --git a/apps/openmw/mwworld/failedaction.cpp b/apps/openmw/mwworld/failedaction.cpp new file mode 100644 index 000000000..78842820b --- /dev/null +++ b/apps/openmw/mwworld/failedaction.cpp @@ -0,0 +1,24 @@ +#include "failedaction.hpp" +#include "../mwbase/world.hpp" + + +namespace MWWorld +{ + FailedAction::FailedAction (const std::string& msg) : Action (false) + { + message = msg; + } + + FailedAction::FailedAction () : Action (false) + { + + } + + void FailedAction::executeImp (const Ptr& actor) + { + if ( actor.getRefData().getHandle()=="player" and not(message.empty())) + { + //return a message here + } + } +} diff --git a/apps/openmw/mwworld/failedaction.hpp b/apps/openmw/mwworld/failedaction.hpp new file mode 100644 index 000000000..21df65c48 --- /dev/null +++ b/apps/openmw/mwworld/failedaction.hpp @@ -0,0 +1,21 @@ +#ifndef GAME_MWWORLD_FAILEDACTION_H +#define GAME_MWWORLD_FAILEDACTION_H + +#include "action.hpp" +#include "ptr.hpp" + +namespace MWWorld +{ + class FailedAction : public Action + { + std::string message; + + virtual void executeImp (const Ptr& actor); + + public: + FailedAction (const std::string& message); + FailedAction (); + }; +} + +#endif \ No newline at end of file