Jump to content

Scripting help - equipitem from leveled list


SAC020

Recommended Posts

I managed to get a script to add an item from a leveled list to an NPC. However, I am unable to make the NPC equip the said item - the item gets added to their inventory, however it is not equipped.



Not sure how to solve this



LeveledItem Property NooseOutfit Auto ; it exists, it is populated

<..>

target.additem(NooseOutfit) ; this works fine, an item is added
target.equipitem(NooseOutfit) ; this does nothing

I suppose additem should return a reference that I can use for equipitem. Sadly, it does not return any reference, by design.



Thanks!


Edited by ss_kk
Link to comment
Share on other sites

Usually there is no need to use "additem" when you want to equip it. EquipItem does both - adding and equipping. But it won`t work with leveled items.

You can`t equip leveled items. And you can`t get or manipulate any reference while it`s inside a container/inventory.

I think you can create an outfit record with your leveled lists added to it. Then use SetOutfit function for the actor.

Another way is to create a formlist instead of leveled list and use utility.RandomInt function to get a random item from the formlist.

 

Example:

ActorRef.EquipItem(NooseFormlist.GetAt(Utility.RandomInt(0, NooseFormlist.GetSize() - 1)), true, true)

Link to comment
Share on other sites

 

Another way is to create a formlist instead of leveled list and use utility.RandomInt function to get a random item from the formlist.

 

Example:

ActorRef.EquipItem(NooseFormlist.GetAt(Utility.RandomInt(0, NooseFormlist.GetSize() - 1)), true, true)

 

Thank you very much, this is a real eye opener for me. I didn't know form lists existed, so I was (mis)using leveled lists instead. I don't need a leveled list, and I certainly don't want to alter default outfits, because I don't want NPCs to spawn with my outfits (on the contrary, I want the opposite, to never spawn with mine, just to switch them "on event").

 

Can't wait to get home to test this, thank you!!

Link to comment
Share on other sites

 

Another way is to create a formlist instead of leveled list and use utility.RandomInt function to get a random item from the formlist.

 

Example:

ActorRef.EquipItem(NooseFormlist.GetAt(Utility.RandomInt(0, NooseFormlist.GetSize() - 1)), true, true)

 

Yuhooo, works flawlessly!! Thank you very much!!

Edited by ss_kk
Link to comment
Share on other sites

  • Recently Browsing   0 members

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