diff --git a/CHANGELOG.md b/CHANGELOG.md index 8017a253f..16c49c6a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,7 @@ Bug #4457: Item without CanCarry flag prevents shield autoequipping in dark areas Bug #4458: AiWander console command handles idle chances incorrectly Bug #4459: NotCell dialogue condition doesn't support partial matches + Bug #4460: Script function "Equip" doesn't bypass beast restrictions Bug #4461: "Open" spell from non-player caster isn't a crime Bug #4464: OpenMW keeps AiState cached storages even after we cancel AI packages Bug #4469: Abot Silt Striders – Model turn 90 degrees on horizontal diff --git a/apps/openmw/mwbase/windowmanager.hpp b/apps/openmw/mwbase/windowmanager.hpp index d454067c8..39eed5537 100644 --- a/apps/openmw/mwbase/windowmanager.hpp +++ b/apps/openmw/mwbase/windowmanager.hpp @@ -146,7 +146,7 @@ namespace MWBase virtual MWGui::TradeWindow* getTradeWindow() = 0; /// Make the player use an item, while updating GUI state accordingly - virtual void useItem(const MWWorld::Ptr& item) = 0; + virtual void useItem(const MWWorld::Ptr& item, bool force=false) = 0; virtual void updateSpellWindow() = 0; diff --git a/apps/openmw/mwclass/apparatus.cpp b/apps/openmw/mwclass/apparatus.cpp index a271dc5e9..e151e39c5 100644 --- a/apps/openmw/mwclass/apparatus.cpp +++ b/apps/openmw/mwclass/apparatus.cpp @@ -124,10 +124,9 @@ namespace MWClass return info; } - - std::shared_ptr Apparatus::use (const MWWorld::Ptr& ptr) const + std::shared_ptr Apparatus::use (const MWWorld::Ptr& ptr, bool force) const { - return std::shared_ptr(new MWWorld::ActionAlchemy()); + return std::shared_ptr(new MWWorld::ActionAlchemy(force)); } MWWorld::Ptr Apparatus::copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const diff --git a/apps/openmw/mwclass/apparatus.hpp b/apps/openmw/mwclass/apparatus.hpp index 539c1068b..e9b645763 100644 --- a/apps/openmw/mwclass/apparatus.hpp +++ b/apps/openmw/mwclass/apparatus.hpp @@ -50,8 +50,7 @@ namespace MWClass virtual std::string getInventoryIcon (const MWWorld::ConstPtr& ptr) const; ///< Return name of inventory icon. - virtual std::shared_ptr use (const MWWorld::Ptr& ptr) - const; + virtual std::shared_ptr use (const MWWorld::Ptr& ptr, bool force=false) const; ///< Generate action for using via inventory menu virtual std::string getModel(const MWWorld::ConstPtr &ptr) const; diff --git a/apps/openmw/mwclass/armor.cpp b/apps/openmw/mwclass/armor.cpp index 460cd517a..0d267046f 100644 --- a/apps/openmw/mwclass/armor.cpp +++ b/apps/openmw/mwclass/armor.cpp @@ -354,9 +354,9 @@ namespace MWClass return std::make_pair(1,""); } - std::shared_ptr Armor::use (const MWWorld::Ptr& ptr) const + std::shared_ptr Armor::use (const MWWorld::Ptr& ptr, bool force) const { - std::shared_ptr action(new MWWorld::ActionEquip(ptr)); + std::shared_ptr action(new MWWorld::ActionEquip(ptr, force)); action->setSound(getUpSoundId(ptr)); diff --git a/apps/openmw/mwclass/armor.hpp b/apps/openmw/mwclass/armor.hpp index 628ac1b88..6b098fa9a 100644 --- a/apps/openmw/mwclass/armor.hpp +++ b/apps/openmw/mwclass/armor.hpp @@ -73,8 +73,7 @@ namespace MWClass ///< Return 0 if player cannot equip item. 1 if can equip. 2 if it's twohanded weapon. 3 if twohanded weapon conflicts with that. \n /// Second item in the pair specifies the error message - virtual std::shared_ptr use (const MWWorld::Ptr& ptr) - const; + virtual std::shared_ptr use (const MWWorld::Ptr& ptr, bool force=false) const; ///< Generate action for using via inventory menu virtual std::string getModel(const MWWorld::ConstPtr &ptr) const; diff --git a/apps/openmw/mwclass/book.cpp b/apps/openmw/mwclass/book.cpp index 3d6455dc6..4b5ca2ee7 100644 --- a/apps/openmw/mwclass/book.cpp +++ b/apps/openmw/mwclass/book.cpp @@ -162,7 +162,7 @@ namespace MWClass return record->mId; } - std::shared_ptr Book::use (const MWWorld::Ptr& ptr) const + std::shared_ptr Book::use (const MWWorld::Ptr& ptr, bool force) const { return std::shared_ptr(new MWWorld::ActionRead(ptr)); } diff --git a/apps/openmw/mwclass/book.hpp b/apps/openmw/mwclass/book.hpp index 82ca08a4d..4cb51ff58 100644 --- a/apps/openmw/mwclass/book.hpp +++ b/apps/openmw/mwclass/book.hpp @@ -53,7 +53,7 @@ namespace MWClass virtual std::string applyEnchantment(const MWWorld::ConstPtr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const; ///< Creates a new record using \a ptr as template, with the given name and the given enchantment applied to it. - virtual std::shared_ptr use (const MWWorld::Ptr& ptr) const; + virtual std::shared_ptr use (const MWWorld::Ptr& ptr, bool force=false) const; ///< Generate action for using via inventory menu virtual std::string getModel(const MWWorld::ConstPtr &ptr) const; diff --git a/apps/openmw/mwclass/clothing.cpp b/apps/openmw/mwclass/clothing.cpp index b37d1e90b..027882304 100644 --- a/apps/openmw/mwclass/clothing.cpp +++ b/apps/openmw/mwclass/clothing.cpp @@ -243,9 +243,9 @@ namespace MWClass return std::make_pair (1, ""); } - std::shared_ptr Clothing::use (const MWWorld::Ptr& ptr) const + std::shared_ptr Clothing::use (const MWWorld::Ptr& ptr, bool force) const { - std::shared_ptr action(new MWWorld::ActionEquip(ptr)); + std::shared_ptr action(new MWWorld::ActionEquip(ptr, force)); action->setSound(getUpSoundId(ptr)); diff --git a/apps/openmw/mwclass/clothing.hpp b/apps/openmw/mwclass/clothing.hpp index 202b6596e..81b5c2ef4 100644 --- a/apps/openmw/mwclass/clothing.hpp +++ b/apps/openmw/mwclass/clothing.hpp @@ -65,8 +65,7 @@ namespace MWClass ///< Return 0 if player cannot equip item. 1 if can equip. 2 if it's twohanded weapon. 3 if twohanded weapon conflicts with that. /// Second item in the pair specifies the error message - virtual std::shared_ptr use (const MWWorld::Ptr& ptr) - const; + virtual std::shared_ptr use (const MWWorld::Ptr& ptr, bool force=false) const; ///< Generate action for using via inventory menu virtual std::string getModel(const MWWorld::ConstPtr &ptr) const; diff --git a/apps/openmw/mwclass/ingredient.cpp b/apps/openmw/mwclass/ingredient.cpp index 09d149331..df7c61ebf 100644 --- a/apps/openmw/mwclass/ingredient.cpp +++ b/apps/openmw/mwclass/ingredient.cpp @@ -75,7 +75,7 @@ namespace MWClass } - std::shared_ptr Ingredient::use (const MWWorld::Ptr& ptr) const + std::shared_ptr Ingredient::use (const MWWorld::Ptr& ptr, bool force) const { std::shared_ptr action (new MWWorld::ActionEat (ptr)); diff --git a/apps/openmw/mwclass/ingredient.hpp b/apps/openmw/mwclass/ingredient.hpp index 1136eb50f..668fea29a 100644 --- a/apps/openmw/mwclass/ingredient.hpp +++ b/apps/openmw/mwclass/ingredient.hpp @@ -36,8 +36,7 @@ namespace MWClass virtual int getValue (const MWWorld::ConstPtr& ptr) const; ///< Return trade value of the object. Throws an exception, if the object can't be traded. - virtual std::shared_ptr use (const MWWorld::Ptr& ptr) - const; + virtual std::shared_ptr use (const MWWorld::Ptr& ptr, bool force=false) const; ///< Generate action for using via inventory menu static void registerSelf(); diff --git a/apps/openmw/mwclass/light.cpp b/apps/openmw/mwclass/light.cpp index aeeb89a72..27a9f3f2b 100644 --- a/apps/openmw/mwclass/light.cpp +++ b/apps/openmw/mwclass/light.cpp @@ -186,9 +186,9 @@ namespace MWClass return Class::showsInInventory(ptr); } - std::shared_ptr Light::use (const MWWorld::Ptr& ptr) const + std::shared_ptr Light::use (const MWWorld::Ptr& ptr, bool force) const { - std::shared_ptr action(new MWWorld::ActionEquip(ptr)); + std::shared_ptr action(new MWWorld::ActionEquip(ptr, force)); action->setSound(getUpSoundId(ptr)); diff --git a/apps/openmw/mwclass/light.hpp b/apps/openmw/mwclass/light.hpp index 59085d97e..013b9eee3 100644 --- a/apps/openmw/mwclass/light.hpp +++ b/apps/openmw/mwclass/light.hpp @@ -55,8 +55,7 @@ namespace MWClass virtual std::string getInventoryIcon (const MWWorld::ConstPtr& ptr) const; ///< Return name of inventory icon. - virtual std::shared_ptr use (const MWWorld::Ptr& ptr) - const; + virtual std::shared_ptr use (const MWWorld::Ptr& ptr, bool force=false) const; ///< Generate action for using via inventory menu virtual void setRemainingUsageTime (const MWWorld::Ptr& ptr, float duration) const; diff --git a/apps/openmw/mwclass/lockpick.cpp b/apps/openmw/mwclass/lockpick.cpp index 15499c1a8..5673465a0 100644 --- a/apps/openmw/mwclass/lockpick.cpp +++ b/apps/openmw/mwclass/lockpick.cpp @@ -140,9 +140,9 @@ namespace MWClass return info; } - std::shared_ptr Lockpick::use (const MWWorld::Ptr& ptr) const + std::shared_ptr Lockpick::use (const MWWorld::Ptr& ptr, bool force) const { - std::shared_ptr action(new MWWorld::ActionEquip(ptr)); + std::shared_ptr action(new MWWorld::ActionEquip(ptr, force)); action->setSound(getUpSoundId(ptr)); diff --git a/apps/openmw/mwclass/lockpick.hpp b/apps/openmw/mwclass/lockpick.hpp index 1bcf7fb85..c8df860f6 100644 --- a/apps/openmw/mwclass/lockpick.hpp +++ b/apps/openmw/mwclass/lockpick.hpp @@ -53,8 +53,7 @@ namespace MWClass virtual std::pair canBeEquipped(const MWWorld::ConstPtr &ptr, const MWWorld::Ptr &npc) const; - virtual std::shared_ptr use (const MWWorld::Ptr& ptr) - const; + virtual std::shared_ptr use (const MWWorld::Ptr& ptr, bool force=false) const; ///< Generate action for using via inventory menu virtual std::string getModel(const MWWorld::ConstPtr &ptr) const; diff --git a/apps/openmw/mwclass/misc.cpp b/apps/openmw/mwclass/misc.cpp index 62b15bc86..40ec2b34b 100644 --- a/apps/openmw/mwclass/misc.cpp +++ b/apps/openmw/mwclass/misc.cpp @@ -226,7 +226,7 @@ namespace MWClass return newPtr; } - std::shared_ptr Miscellaneous::use (const MWWorld::Ptr& ptr) const + std::shared_ptr Miscellaneous::use (const MWWorld::Ptr& ptr, bool force) const { if (ptr.getCellRef().getSoul().empty() || !MWBase::Environment::get().getWorld()->getStore().get().search(ptr.getCellRef().getSoul())) return std::shared_ptr(new MWWorld::NullAction()); diff --git a/apps/openmw/mwclass/misc.hpp b/apps/openmw/mwclass/misc.hpp index 37e77860b..77e7d105b 100644 --- a/apps/openmw/mwclass/misc.hpp +++ b/apps/openmw/mwclass/misc.hpp @@ -49,8 +49,7 @@ namespace MWClass virtual std::string getModel(const MWWorld::ConstPtr &ptr) const; - virtual std::shared_ptr use (const MWWorld::Ptr& ptr) - const; + virtual std::shared_ptr use (const MWWorld::Ptr& ptr, bool force=false) const; ///< Generate action for using via inventory menu virtual float getWeight (const MWWorld::ConstPtr& ptr) const; diff --git a/apps/openmw/mwclass/potion.cpp b/apps/openmw/mwclass/potion.cpp index ffdccf438..39b1cc6c2 100644 --- a/apps/openmw/mwclass/potion.cpp +++ b/apps/openmw/mwclass/potion.cpp @@ -139,7 +139,7 @@ namespace MWClass return info; } - std::shared_ptr Potion::use (const MWWorld::Ptr& ptr) const + std::shared_ptr Potion::use (const MWWorld::Ptr& ptr, bool force) const { MWWorld::LiveCellRef *ref = ptr.get(); diff --git a/apps/openmw/mwclass/potion.hpp b/apps/openmw/mwclass/potion.hpp index ad9a329c0..90dbe5281 100644 --- a/apps/openmw/mwclass/potion.hpp +++ b/apps/openmw/mwclass/potion.hpp @@ -36,7 +36,7 @@ namespace MWClass virtual int getValue (const MWWorld::ConstPtr& ptr) const; ///< Return trade value of the object. Throws an exception, if the object can't be traded. - virtual std::shared_ptr use (const MWWorld::Ptr& ptr) const; + virtual std::shared_ptr use (const MWWorld::Ptr& ptr, bool force=false) const; ///< Generate action for using via inventory menu static void registerSelf(); diff --git a/apps/openmw/mwclass/probe.cpp b/apps/openmw/mwclass/probe.cpp index 030ee3f8b..734b6b1fd 100644 --- a/apps/openmw/mwclass/probe.cpp +++ b/apps/openmw/mwclass/probe.cpp @@ -140,9 +140,9 @@ namespace MWClass return info; } - std::shared_ptr Probe::use (const MWWorld::Ptr& ptr) const + std::shared_ptr Probe::use (const MWWorld::Ptr& ptr, bool force) const { - std::shared_ptr action(new MWWorld::ActionEquip(ptr)); + std::shared_ptr action(new MWWorld::ActionEquip(ptr, force)); action->setSound(getUpSoundId(ptr)); diff --git a/apps/openmw/mwclass/probe.hpp b/apps/openmw/mwclass/probe.hpp index 9ac3ab0c9..86f6f677a 100644 --- a/apps/openmw/mwclass/probe.hpp +++ b/apps/openmw/mwclass/probe.hpp @@ -53,8 +53,7 @@ namespace MWClass virtual std::pair canBeEquipped(const MWWorld::ConstPtr &ptr, const MWWorld::Ptr &npc) const; - virtual std::shared_ptr use (const MWWorld::Ptr& ptr) - const; + virtual std::shared_ptr use (const MWWorld::Ptr& ptr, bool force=false) const; ///< Generate action for using via inventory menu virtual std::string getModel(const MWWorld::ConstPtr &ptr) const; diff --git a/apps/openmw/mwclass/repair.cpp b/apps/openmw/mwclass/repair.cpp index 566d16106..7cd7ef10d 100644 --- a/apps/openmw/mwclass/repair.cpp +++ b/apps/openmw/mwclass/repair.cpp @@ -149,9 +149,9 @@ namespace MWClass return MWWorld::Ptr(cell.insert(ref), &cell); } - std::shared_ptr Repair::use (const MWWorld::Ptr& ptr) const + std::shared_ptr Repair::use (const MWWorld::Ptr& ptr, bool force) const { - return std::shared_ptr(new MWWorld::ActionRepair(ptr)); + return std::shared_ptr(new MWWorld::ActionRepair(ptr, force)); } bool Repair::canSell (const MWWorld::ConstPtr& item, int npcServices) const diff --git a/apps/openmw/mwclass/repair.hpp b/apps/openmw/mwclass/repair.hpp index 34ba4035b..f60dbad90 100644 --- a/apps/openmw/mwclass/repair.hpp +++ b/apps/openmw/mwclass/repair.hpp @@ -49,7 +49,7 @@ namespace MWClass virtual std::string getModel(const MWWorld::ConstPtr &ptr) const; - virtual std::shared_ptr use (const MWWorld::Ptr& ptr) + virtual std::shared_ptr use (const MWWorld::Ptr& ptr, bool force=false) const; ///< Generate action for using via inventory menu (default implementation: return a /// null action). diff --git a/apps/openmw/mwclass/weapon.cpp b/apps/openmw/mwclass/weapon.cpp index e59567aac..bb1ca09a3 100644 --- a/apps/openmw/mwclass/weapon.cpp +++ b/apps/openmw/mwclass/weapon.cpp @@ -401,9 +401,9 @@ namespace MWClass return std::make_pair(1, ""); } - std::shared_ptr Weapon::use (const MWWorld::Ptr& ptr) const + std::shared_ptr Weapon::use (const MWWorld::Ptr& ptr, bool force) const { - std::shared_ptr action(new MWWorld::ActionEquip(ptr)); + std::shared_ptr action(new MWWorld::ActionEquip(ptr, force)); action->setSound(getUpSoundId(ptr)); diff --git a/apps/openmw/mwclass/weapon.hpp b/apps/openmw/mwclass/weapon.hpp index c14847363..423ba0dd2 100644 --- a/apps/openmw/mwclass/weapon.hpp +++ b/apps/openmw/mwclass/weapon.hpp @@ -72,8 +72,7 @@ namespace MWClass ///< Return 0 if player cannot equip item. 1 if can equip. 2 if it's twohanded weapon. 3 if twohanded weapon conflicts with that. /// Second item in the pair specifies the error message - virtual std::shared_ptr use (const MWWorld::Ptr& ptr) - const; + virtual std::shared_ptr use (const MWWorld::Ptr& ptr, bool force=false) const; ///< Generate action for using via inventory menu virtual std::string getModel(const MWWorld::ConstPtr &ptr) const; diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index 4acf61d93..e909ecbba 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -25,7 +25,7 @@ #include "../mwworld/inventorystore.hpp" #include "../mwworld/class.hpp" -#include "../mwworld/action.hpp" +#include "../mwworld/actionequip.hpp" #include "../mwscript/interpretercontext.hpp" #include "../mwmechanics/actorutil.hpp" @@ -474,7 +474,7 @@ namespace MWGui MWBase::Environment::get().getWindowManager()->toggleVisible(GW_Inventory); } - void InventoryWindow::useItem(const MWWorld::Ptr &ptr) + void InventoryWindow::useItem(const MWWorld::Ptr &ptr, bool force) { const std::string& script = ptr.getClass().getScript(ptr); @@ -483,13 +483,24 @@ namespace MWGui // early-out for items that need to be equipped, but can't be equipped: we don't want to set OnPcEquip in that case if (!ptr.getClass().getEquipmentSlots(ptr).first.empty()) { - std::pair canEquip = ptr.getClass().canBeEquipped(ptr, player); - if (canEquip.first == 0) + if (ptr.getClass().hasItemHealth(ptr) && ptr.getCellRef().getCharge() == 0) { - MWBase::Environment::get().getWindowManager()->messageBox(canEquip.second); + MWBase::Environment::get().getWindowManager()->messageBox("#{sInventoryMessage1}"); updateItemView(); return; } + + if (!force) + { + std::pair canEquip = ptr.getClass().canBeEquipped(ptr, player); + + if (canEquip.first == 0) + { + MWBase::Environment::get().getWindowManager()->messageBox(canEquip.second); + updateItemView(); + return; + } + } } // If the item has a script, set its OnPcEquip to 1 @@ -512,9 +523,8 @@ namespace MWGui { if (script.empty() || ptr.getRefData().getLocals().getIntVar(script, "pcskipequip") == 0) { - std::shared_ptr action = ptr.getClass().use(ptr); - - action->execute (player); + std::shared_ptr action = ptr.getClass().use(ptr, force); + action->execute(player); } else mSkippedToEquip = ptr; diff --git a/apps/openmw/mwgui/inventorywindow.hpp b/apps/openmw/mwgui/inventorywindow.hpp index 5576b52ed..124fe7b0e 100644 --- a/apps/openmw/mwgui/inventorywindow.hpp +++ b/apps/openmw/mwgui/inventorywindow.hpp @@ -58,7 +58,7 @@ namespace MWGui void clear(); - void useItem(const MWWorld::Ptr& ptr); + void useItem(const MWWorld::Ptr& ptr, bool force=false); void setGuiMode(GuiMode mode); diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 927bee88b..df2d5ed6d 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -1328,10 +1328,10 @@ namespace MWGui MWGui::ConfirmationDialog* WindowManager::getConfirmationDialog() { return mConfirmationDialog; } MWGui::TradeWindow* WindowManager::getTradeWindow() { return mTradeWindow; } - void WindowManager::useItem(const MWWorld::Ptr &item) + void WindowManager::useItem(const MWWorld::Ptr &item, bool bypassBeastRestrictions) { if (mInventoryWindow) - mInventoryWindow->useItem(item); + mInventoryWindow->useItem(item, bypassBeastRestrictions); } bool WindowManager::isAllowed (GuiWindow wnd) const diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index 1d250f6d4..657548397 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -185,7 +185,7 @@ namespace MWGui virtual MWGui::TradeWindow* getTradeWindow(); /// Make the player use an item, while updating GUI state accordingly - virtual void useItem(const MWWorld::Ptr& item); + virtual void useItem(const MWWorld::Ptr& item, bool bypassBeastRestrictions=false); virtual void updateSpellWindow(); diff --git a/apps/openmw/mwscript/containerextensions.cpp b/apps/openmw/mwscript/containerextensions.cpp index 8457b33cb..0feadaa59 100644 --- a/apps/openmw/mwscript/containerextensions.cpp +++ b/apps/openmw/mwscript/containerextensions.cpp @@ -20,6 +20,7 @@ #include "../mwbase/windowmanager.hpp" #include "../mwbase/world.hpp" +#include "../mwworld/actionequip.hpp" #include "../mwworld/class.hpp" #include "../mwworld/containerstore.hpp" #include "../mwworld/inventorystore.hpp" @@ -193,12 +194,11 @@ namespace MWScript "to fulfil requirements of Equip instruction" << std::endl; } - if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr()) - MWBase::Environment::get().getWindowManager()->useItem(*it); + if (ptr == MWMechanics::getPlayer()) + MWBase::Environment::get().getWindowManager()->useItem(*it, true); else { - std::shared_ptr action = it->getClass().use(*it); - // No equip sound for actors other than the player + std::shared_ptr action = it->getClass().use(*it, true); action->execute(ptr, true); } } diff --git a/apps/openmw/mwworld/actionalchemy.cpp b/apps/openmw/mwworld/actionalchemy.cpp index 53ed1ad84..37d811eb6 100644 --- a/apps/openmw/mwworld/actionalchemy.cpp +++ b/apps/openmw/mwworld/actionalchemy.cpp @@ -9,12 +9,19 @@ namespace MWWorld { + ActionAlchemy::ActionAlchemy(bool force) + : Action (false) + , mForce(force) + { + } + void ActionAlchemy::executeImp (const Ptr& actor) { if (actor != MWMechanics::getPlayer()) return; - if(MWMechanics::isPlayerInCombat()) { //Ensure we're not in combat + if(!mForce && MWMechanics::isPlayerInCombat()) + { //Ensure we're not in combat MWBase::Environment::get().getWindowManager()->messageBox("#{sInventoryMessage3}"); return; } diff --git a/apps/openmw/mwworld/actionalchemy.hpp b/apps/openmw/mwworld/actionalchemy.hpp index e6d1a7976..0f79d5c2d 100644 --- a/apps/openmw/mwworld/actionalchemy.hpp +++ b/apps/openmw/mwworld/actionalchemy.hpp @@ -7,7 +7,11 @@ namespace MWWorld { class ActionAlchemy : public Action { - virtual void executeImp (const Ptr& actor); + bool mForce; + virtual void executeImp (const Ptr& actor); + + public: + ActionAlchemy(bool force=false); }; } diff --git a/apps/openmw/mwworld/actionequip.cpp b/apps/openmw/mwworld/actionequip.cpp index a6d6eef2b..da794bcd2 100644 --- a/apps/openmw/mwworld/actionequip.cpp +++ b/apps/openmw/mwworld/actionequip.cpp @@ -14,7 +14,9 @@ namespace MWWorld { - ActionEquip::ActionEquip (const MWWorld::Ptr& object) : Action (false, object) + ActionEquip::ActionEquip (const MWWorld::Ptr& object, bool force) + : Action (false, object) + , mForce(force) { } @@ -23,18 +25,29 @@ namespace MWWorld MWWorld::Ptr object = getTarget(); MWWorld::InventoryStore& invStore = actor.getClass().getInventoryStore(actor); - std::pair result = object.getClass().canBeEquipped (object, actor); + if (object.getClass().hasItemHealth(object) && object.getCellRef().getCharge() == 0) + { + if (actor == MWMechanics::getPlayer()) + MWBase::Environment::get().getWindowManager()->messageBox("#{sInventoryMessage1}"); - // display error message if the player tried to equip something - if (!result.second.empty() && actor == MWMechanics::getPlayer()) - MWBase::Environment::get().getWindowManager()->messageBox(result.second); + return; + } - switch(result.first) + if (!mForce) { - case 0: - return; - default: - break; + std::pair result = object.getClass().canBeEquipped (object, actor); + + // display error message if the player tried to equip something + if (!result.second.empty() && actor == MWMechanics::getPlayer()) + MWBase::Environment::get().getWindowManager()->messageBox(result.second); + + switch(result.first) + { + case 0: + return; + default: + break; + } } // slots that this item can be equipped in diff --git a/apps/openmw/mwworld/actionequip.hpp b/apps/openmw/mwworld/actionequip.hpp index 3b56c7402..1b5e52dd8 100644 --- a/apps/openmw/mwworld/actionequip.hpp +++ b/apps/openmw/mwworld/actionequip.hpp @@ -2,17 +2,18 @@ #define GAME_MWWORLD_ACTIONEQUIP_H #include "action.hpp" -#include "ptr.hpp" namespace MWWorld { class ActionEquip : public Action { - virtual void executeImp (const Ptr& actor); + bool mForce; - public: - /// @param item to equip - ActionEquip (const Ptr& object); + virtual void executeImp (const Ptr& actor); + + public: + /// @param item to equip + ActionEquip (const Ptr& object, bool force=false); }; } diff --git a/apps/openmw/mwworld/actionrepair.cpp b/apps/openmw/mwworld/actionrepair.cpp index 191cf2063..4fb7f7ada 100644 --- a/apps/openmw/mwworld/actionrepair.cpp +++ b/apps/openmw/mwworld/actionrepair.cpp @@ -8,8 +8,9 @@ namespace MWWorld { - ActionRepair::ActionRepair(const Ptr &item) - : Action(false, item) + ActionRepair::ActionRepair(const Ptr& item, bool force) + : Action (false, item) + , mForce(force) { } @@ -18,7 +19,8 @@ namespace MWWorld if (actor != MWMechanics::getPlayer()) return; - if(MWMechanics::isPlayerInCombat()) { + if(!mForce && MWMechanics::isPlayerInCombat()) + { MWBase::Environment::get().getWindowManager()->messageBox("#{sInventoryMessage2}"); return; } diff --git a/apps/openmw/mwworld/actionrepair.hpp b/apps/openmw/mwworld/actionrepair.hpp index 1d3ef2bc1..fc64522d8 100644 --- a/apps/openmw/mwworld/actionrepair.hpp +++ b/apps/openmw/mwworld/actionrepair.hpp @@ -7,10 +7,13 @@ namespace MWWorld { class ActionRepair : public Action { - virtual void executeImp (const Ptr& actor); + bool mForce; + + virtual void executeImp (const Ptr& actor); public: - ActionRepair(const MWWorld::Ptr& item); + /// @param item repair hammer + ActionRepair(const Ptr& item, bool force=false); }; } diff --git a/apps/openmw/mwworld/class.cpp b/apps/openmw/mwworld/class.cpp index 5425c2bd3..68d5998ac 100644 --- a/apps/openmw/mwworld/class.cpp +++ b/apps/openmw/mwworld/class.cpp @@ -113,7 +113,7 @@ namespace MWWorld return std::shared_ptr (new NullAction); } - std::shared_ptr Class::use (const Ptr& ptr) const + std::shared_ptr Class::use (const Ptr& ptr, bool force) const { return std::shared_ptr (new NullAction); } diff --git a/apps/openmw/mwworld/class.hpp b/apps/openmw/mwworld/class.hpp index 097ec0faa..132b7e9e8 100644 --- a/apps/openmw/mwworld/class.hpp +++ b/apps/openmw/mwworld/class.hpp @@ -141,7 +141,7 @@ namespace MWWorld virtual std::shared_ptr activate (const Ptr& ptr, const Ptr& actor) const; ///< Generate action for activation (default implementation: return a null action). - virtual std::shared_ptr use (const Ptr& ptr) + virtual std::shared_ptr use (const Ptr& ptr, bool force=false) const; ///< Generate action for using via inventory menu (default implementation: return a /// null action).