Jump to content

Recommended Posts

Posted

Lets imagine I've given a ring to an NPC ,I know the base form of the ring.  But the ring has a script attached with a property I need to access.  This property is set when the ring is given using the OnContainerChanged event.

How do I get the refid of the particular instance of the ring in the NPCs inventory?  I wish to know this so that I can get the property from the script instance.

 

diziet

Posted

Vanilla papyrus and skse won't let you get a reference to an inventory item unless either (1) you drop it first, or (2) keep that reference in memory as a script variable, script property or quest alias.

There could be skse plugins that do give you inventory references, but your milage may vary... inventories don't necessarily keep track of all references, only special ones.  For others, the inventory only keeps a count of not-special item instances.

I'm guessing that having a script attached makes the reference "special" though.

Posted

Hmm, this is annoying:)  Would there be mileage in  having the ring script add a magiceffect to it's bearer and keep a copy of the script variable on that script?  Don't NPC magic effects get reset on cell change or something?

 

diziet

Posted

It would have to be on some other script, like a quest script.

That works well for a unique ring, or if you have a finite supply of such rings.

Otherwise, I can't think of anything short of putting rings in an array (referenced from a quest script), and then looping through the array to find which ring is in the inventory you are interested in.  Somewhat inconvenient and with potential performance implications if you have more than 1 or 2 dozens.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...