mirror of
https://github.com/TES3MP/TES3MP.git
synced 2025-09-29 16:11:37 -04:00
Unequipping items will reset OnPCEquip variable
This commit is contained in:
parent
9ad08520fd
commit
0f58e03343
@ -7,10 +7,13 @@
|
|||||||
|
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
|
#include <components/compiler/locals.hpp>
|
||||||
|
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwbase/soundmanager.hpp"
|
#include "../mwbase/soundmanager.hpp"
|
||||||
#include "../mwbase/windowmanager.hpp"
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
#include "../mwbase/scriptmanager.hpp"
|
||||||
|
|
||||||
#include "../mwworld/containerstore.hpp"
|
#include "../mwworld/containerstore.hpp"
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/class.hpp"
|
||||||
@ -240,6 +243,29 @@ namespace MWGui
|
|||||||
if (it != invStore.end() && *it == item)
|
if (it != invStore.end() && *it == item)
|
||||||
{
|
{
|
||||||
invStore.equip(slot, invStore.end());
|
invStore.equip(slot, invStore.end());
|
||||||
|
std::string script = MWWorld::Class::get(*it).getScript(*it);
|
||||||
|
|
||||||
|
/* Unset OnPCEquip Variable on item's script, if it has a script with that variable declared */
|
||||||
|
if(script != "")
|
||||||
|
{
|
||||||
|
Compiler::Locals locals = MWBase::Environment::get().getScriptManager()->getLocals(script);
|
||||||
|
int index = locals.getIndex("onpcequip");
|
||||||
|
char type = locals.getType("onpcequip");
|
||||||
|
if(index != -1)
|
||||||
|
{
|
||||||
|
switch(type)
|
||||||
|
{
|
||||||
|
case 's':
|
||||||
|
(*it).mRefData->getLocals().mShorts.at (index) = 0; break;
|
||||||
|
|
||||||
|
case 'l':
|
||||||
|
(*it).mRefData->getLocals().mLongs.at (index) = 0; break;
|
||||||
|
|
||||||
|
case 'f':
|
||||||
|
(*it).mRefData->getLocals().mFloats.at (index) = 0.0; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user