Jump to content

[LE] How to set LeveledItem whith StorageUtil?


pxd2050

Recommended Posts

It sounds like you're trying to add the ability to customize gear for NPCs? If so, the method you are using won't work, because you've only defined one outfit and one leveled item in the script. If you're going to use that method, you have to make or duplicate the outfit and leveled item forms in the creation kit for each new outfit. Papyrus can't create new forms, other than object references. Another method to consider if you want an NPC to use specific gear, is instead of setting outfit, to re-equip their gear and prevent unEquip in the script. So you could use a function like:

Function SetGear(Actor ActorRef)
   
    int i = 31
    while i >= 0
        form ItemRef = ActorRef.GetEquippedArmorInSlot(i+30)
        ActorRef.UnEquipItem(ItemRef) 
        ActorRef.EquipItem(ItemRef, True) ;Equip and prevent removal.
        i -= 1
    endwhile
  
EndFunction

Function UnSetGear(Actor ActorRef)
    int i = 31
    while i >= 0
        form ItemRef = ActorRef.GetEquippedArmorInSlot(i+30)
        ActorRef.UnEquipItem(ItemRef) 
        ActorRef.EquipItem(ItemRef, false) ;Equip and allow removal.
        i -= 1
    endwhile
EndFunction  
Edited by dylbill
Link to comment
Share on other sites

Hey, so I did some testing and it appears there needs to be a wait to work correctly. Also using Papyrus Extender: https://www.nexusmods.com/skyrim/mods/95017 to get equipped gear is pretty fast. Here's the updated functions that worked for me:

Function SetGear(Actor ActorRef)
    Form[] EquippedItems = PO3_SKSEfunctions.AddAllEquippedItemsToArray(ActorRef)
    Int M =  EquippedItems.Length
    While M > 0 
        M -= 1
        If EquippedItems[M] as Armor
            ActorRef.UnEquipItem(EquippedItems[M], False, True)
            Utility.Wait(0.1)
            ActorRef.EquipItem(EquippedItems[M], True, True) ;Equip and prevent removal.
        Endif
    EndWhile
    
    Debug.Notification("Gear Set")
EndFunction

Function UnSetGear(Actor ActorRef)
    Form[] EquippedItems = PO3_SKSEfunctions.AddAllEquippedItemsToArray(ActorRef)
    Int M =  EquippedItems.Length
    While M > 0 
        M -= 1
        If EquippedItems[M] as Armor
            ActorRef.UnEquipItem(EquippedItems[M], False, True)
            Utility.Wait(0.1)
            ActorRef.EquipItem(EquippedItems[M], False, True) ;Equip and allow removal.
        Endif
    EndWhile
    
    Debug.Notification("Gear UnSet")
EndFunction 
Edited by dylbill
Link to comment
Share on other sites

  • Recently Browsing   0 members

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