mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-31 10:06:41 +00:00
Implemented OnPCEquip special variable
This commit is contained in:
parent
dc91211b12
commit
09f9557ecb
1 changed files with 14 additions and 0 deletions
|
@ -3,6 +3,9 @@
|
|||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
#include "../mwbase/windowmanager.hpp"
|
||||
#include "../mwbase/scriptmanager.hpp"
|
||||
|
||||
#include <components/compiler/locals.hpp>
|
||||
|
||||
#include "inventorystore.hpp"
|
||||
#include "player.hpp"
|
||||
|
@ -35,6 +38,8 @@ namespace MWWorld
|
|||
|
||||
std::string npcRace = actor.get<ESM::NPC>()->mBase->mRace;
|
||||
|
||||
bool equipped = false;
|
||||
|
||||
// equip the item in the first free slot
|
||||
for (std::vector<int>::const_iterator slot=slots.first.begin();
|
||||
slot!=slots.first.end(); ++slot)
|
||||
|
@ -91,6 +96,7 @@ namespace MWWorld
|
|||
if (slot == --slots.first.end())
|
||||
{
|
||||
invStore.equip(*slot, it);
|
||||
equipped = true;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -98,8 +104,16 @@ namespace MWWorld
|
|||
{
|
||||
// slot is not occupied
|
||||
invStore.equip(*slot, it);
|
||||
equipped = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set OnPCEquip Variable on item's script, if it has a script with that variable declared */
|
||||
if(equipped && actor == MWBase::Environment::get().getWorld()->getPlayer().getPlayer() && MWWorld::Class::get(*it).getScript(*it) != ""){
|
||||
int index = MWBase::Environment::get().getScriptManager()->getLocals(MWWorld::Class::get(*it).getScript(*it)).getIndex("onpcequip");
|
||||
if(index != -1)
|
||||
(*it).mRefData->getLocals().mShorts.at (index) = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue