EDIT: Wrong parts, I'll remake it.
Ok, i managed how to open the npc inventory, now I'm starting to make a function that allow to equip an armor part to a specific armor slot by taking from my inventory just like a mannequine or by add the object to npc inventory:
Scriptname Billyequiparmor extends Actor
Form Property ArmorSlot40 auto hidden
Form Property EmptySlot auto hidden
Actor Property NewProperty Auto ;actor property ref
Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
;Trace("DARYL - " + self + " Adding " + akBaseItem + " to Billy")
if (akBaseItem as Armor)
;Trace("DARYL - " + self + " Form " + akBaseItem + " is armor!")
AddToArmorSlot(akBaseItem)
self.EquipItem(akBaseItem)
endif
EndEvent
Event OnObjectUnequipped(Form akBaseObject, ObjectReference akReference)
;Trace("DARYL - " + self + akBaseObject + " was unequipped by Billy")
if (akBaseObject as Armor)
;Trace("DARYL - " + self + " Form " + akBaseObject + " is armor!")
RemoveFromArmorSlot(akBaseObject)
endif
Endevent
Function EquipCurrentArmor()
;Trace("DARYL - " + self + " Attempting to equip current armor")
if (ArmorSlot40 != EmptySlot)
;Trace("DARYL - " + self + " Equipping " + ArmorSlot40 + " from Slot 40")
self.EquipItem(ArmorSlot40)
endif
endfunction
Function AddToArmorSlot(Form akBaseItem)
;Trace("DARYL - " + self + " Running the AddToArmorSlot Function")
bool FoundEmptySlot = FALSE
if (ArmorSlot40 == EmptySlot) && (FoundEmptySlot == FALSE)
;Trace("DARYL - " + self + " Placing " + akBaseItem + " in armor slot 40")
ArmorSlot40 = akBaseItem
FoundEmptySlot = TRUE
endif
endfunction
Function RemoveFromArmorSlot(Form akBaseItem)
;Trace("DARYL - " + self + " Running the RemoveFromArmorSlot Function")
bool FoundMatchingSlot = FALSE
if (ArmorSlot40 == akBaseItem) && (FoundMatchingSlot == FALSE)
;Trace("DARYL - " + self + " Match Found, Removing " + akBaseItem + " from armor slot 40")
ArmorSlot40 = EmptySlot
FoundMatchingSlot = TRUE
endif
endfunction
Debugging didn't reveal any problem, so it's compiled, but dosen't work, or better, nothing happen ingame test, the script it's attached to the actor of course, don't know, what i'm missing?