mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-29 22:45:34 +00:00
OnActivate is triggered when the item is picked up
This commit is contained in:
parent
e8743f3f79
commit
a9e5e19482
4 changed files with 10 additions and 25 deletions
|
@ -1,7 +1,6 @@
|
|||
#include "inventorywindow.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <algorithm>
|
||||
|
||||
#include <MyGUI_Window.h>
|
||||
#include <MyGUI_ImageBox.h>
|
||||
|
@ -150,15 +149,6 @@ namespace MWGui
|
|||
mItemView->setModel(NULL);
|
||||
}
|
||||
|
||||
void InventoryWindow::activateItems()
|
||||
{
|
||||
for (std::vector<MWWorld::Ptr>::iterator it = mItemsToActivate.begin(); it != mItemsToActivate.end(); it++)
|
||||
{
|
||||
it->getRefData().activate();
|
||||
}
|
||||
mItemsToActivate.clear();
|
||||
}
|
||||
|
||||
void InventoryWindow::setGuiMode(GuiMode mode)
|
||||
{
|
||||
std::string setting = "inventory";
|
||||
|
@ -663,15 +653,6 @@ namespace MWGui
|
|||
if (object.getClass().getName(object) == "") // objects without name presented to user can never be picked up
|
||||
return;
|
||||
|
||||
if (object.getRefData().hasSuppressActivate()) // if Flag_SuppressActivate is set, script that contains OnActivate is attached to the item
|
||||
{
|
||||
if (std::find(mItemsToActivate.begin(), mItemsToActivate.end(), object) == mItemsToActivate.end())
|
||||
{
|
||||
mItemsToActivate.push_back(object);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int count = object.getRefData().getCount();
|
||||
|
||||
MWWorld::Ptr player = MWMechanics::getPlayer();
|
||||
|
@ -682,6 +663,13 @@ namespace MWGui
|
|||
// add to player inventory
|
||||
// can't use ActionTake here because we need an MWWorld::Ptr to the newly inserted object
|
||||
MWWorld::Ptr newObject = *player.getClass().getContainerStore (player).add (object, object.getRefData().getCount(), player);
|
||||
|
||||
if (object.getRefData().hasSuppressActivate()) // if Flag_SuppressActivate is set, script that contains OnActivate is attached to the item
|
||||
{
|
||||
newObject.getRefData().onActivate(); // set the flag_SuppressActivate flag for the new item
|
||||
newObject.getRefData().activate();
|
||||
}
|
||||
|
||||
// remove from world
|
||||
MWBase::Environment::get().getWorld()->deleteObject (object);
|
||||
|
||||
|
|
|
@ -58,8 +58,6 @@ namespace MWGui
|
|||
|
||||
void clear();
|
||||
|
||||
void activateItems();
|
||||
|
||||
void useItem(const MWWorld::Ptr& ptr);
|
||||
|
||||
void setGuiMode(GuiMode mode);
|
||||
|
@ -72,8 +70,6 @@ namespace MWGui
|
|||
|
||||
int mSelectedItem;
|
||||
|
||||
std::vector<MWWorld::Ptr> mItemsToActivate;
|
||||
|
||||
MWWorld::Ptr mPtr;
|
||||
|
||||
MWGui::ItemView* mItemView;
|
||||
|
|
|
@ -1171,8 +1171,6 @@ namespace MWGui
|
|||
mGuiModeStates[mode].update(false);
|
||||
if (!noSound)
|
||||
playSound(mGuiModeStates[mode].mCloseSound);
|
||||
if (mode == GM_Inventory)
|
||||
mInventoryWindow->activateItems(); // Activate cursed items when inventory is closed
|
||||
}
|
||||
|
||||
if (!mGuiModes.empty())
|
||||
|
|
|
@ -14,6 +14,9 @@ namespace MWWorld
|
|||
|
||||
void ActionTake::executeImp (const Ptr& actor)
|
||||
{
|
||||
//No need to do anything if moving items from the player's inventory back into player's inventory
|
||||
if (actor == MWBase::Environment::get().getWorld()->getPlayerPtr() && getTarget().getCell() == 0)
|
||||
return;
|
||||
MWBase::Environment::get().getMechanicsManager()->itemTaken(
|
||||
actor, getTarget(), MWWorld::Ptr(), getTarget().getRefData().getCount());
|
||||
MWWorld::Ptr newitem = *actor.getClass().getContainerStore (actor).add (getTarget(), getTarget().getRefData().getCount(), actor);
|
||||
|
|
Loading…
Reference in a new issue