mirror of
https://github.com/TES3MP/TES3MP.git
synced 2025-09-28 07:32:00 -04:00
Implemented OnPCEquip special variable
This commit is contained in:
parent
dc91211b12
commit
09f9557ecb
@ -3,6 +3,9 @@
|
|||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
#include "../mwbase/windowmanager.hpp"
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
#include "../mwbase/scriptmanager.hpp"
|
||||||
|
|
||||||
|
#include <components/compiler/locals.hpp>
|
||||||
|
|
||||||
#include "inventorystore.hpp"
|
#include "inventorystore.hpp"
|
||||||
#include "player.hpp"
|
#include "player.hpp"
|
||||||
@ -35,6 +38,8 @@ namespace MWWorld
|
|||||||
|
|
||||||
std::string npcRace = actor.get<ESM::NPC>()->mBase->mRace;
|
std::string npcRace = actor.get<ESM::NPC>()->mBase->mRace;
|
||||||
|
|
||||||
|
bool equipped = false;
|
||||||
|
|
||||||
// equip the item in the first free slot
|
// equip the item in the first free slot
|
||||||
for (std::vector<int>::const_iterator slot=slots.first.begin();
|
for (std::vector<int>::const_iterator slot=slots.first.begin();
|
||||||
slot!=slots.first.end(); ++slot)
|
slot!=slots.first.end(); ++slot)
|
||||||
@ -91,6 +96,7 @@ namespace MWWorld
|
|||||||
if (slot == --slots.first.end())
|
if (slot == --slots.first.end())
|
||||||
{
|
{
|
||||||
invStore.equip(*slot, it);
|
invStore.equip(*slot, it);
|
||||||
|
equipped = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,8 +104,16 @@ namespace MWWorld
|
|||||||
{
|
{
|
||||||
// slot is not occupied
|
// slot is not occupied
|
||||||
invStore.equip(*slot, it);
|
invStore.equip(*slot, it);
|
||||||
|
equipped = true;
|
||||||
break;
|
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…
x
Reference in New Issue
Block a user