diff --git a/apps/openmw/mwworld/actionequip.cpp b/apps/openmw/mwworld/actionequip.cpp index c519a3ee5..2b238ead9 100644 --- a/apps/openmw/mwworld/actionequip.cpp +++ b/apps/openmw/mwworld/actionequip.cpp @@ -109,11 +109,28 @@ namespace MWWorld } } - /* 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"); + std::string script = MWWorld::Class::get(*it).getScript(*it); + + /* Set OnPCEquip Variable on item's script, if the player is equipping it, and it has a script with that variable declared */ + if(equipped && actor == MWBase::Environment::get().getWorld()->getPlayer().getPlayer() && script != "") + { + Compiler::Locals locals = MWBase::Environment::get().getScriptManager()->getLocals(script); + int index = locals.getIndex("onpcequip"); + char type = locals.getType("onpcequip"); if(index != -1) - (*it).mRefData->getLocals().mShorts.at (index) = 1; + { + switch(type) + { + case 's': + (*it).mRefData->getLocals().mShorts.at (index) = 1; break; + + case 'l': + (*it).mRefData->getLocals().mLongs.at (index) = 1; break; + + case 'f': + (*it).mRefData->getLocals().mFloats.at (index) = 1.0; break; + } + } } } }