MorePrinniesDood Posted August 12, 2017 Posted August 12, 2017 So i'm calling this function 4 times, to replace an NPC's boots, gloves, body armor, and helmet with Nise's bikini armors: function bikinify(actor caster, form oldarmor, formlist replacements) form newarmor = getrandompiece(replacements) if(newarmor != none) caster.unequipitem(oldarmor,false,true) caster.additem(newarmor,1,true) caster.equipitemex(newarmor,0,false,false) caster.removeitem(oldarmor,1,true) endif endfunction The expected result it that the NPC ends up with a piece of bikini armor for each old armor the function's called on. The actual result is that the NPC ends up naked save for 1 piece of bikini armor, with the rest in inventory unequipped. Any thoughts on why this is?
yatol Posted August 13, 2017 Posted August 13, 2017 no idea that one give and equip an item on npc without problem function OnEffectStart(Actor akTarget, Actor akCaster) ((ShowPoseMenu as form) as uilistmenu).OnInit() armor gnd int max = armorlist.getsize() as int Int i = 0 while i < max gnd=armorlist.Getat(i) as armor ((ShowPoseMenu as form) as uilistmenu).AddEntryItem(gnd.GetModelPath(true) as string, -1, -1, true) i += 1 endWhile Int ret = ((ShowPoseMenu as form) as uilistmenu).OpenMenu(ClientForm, ClientForm) trace ("ret " +ret) int resultInt = ((ShowPoseMenu as form) as uilistmenu).GetResultInt() trace("resultint " + resultint) aktarget.additem(armorlist.getat(resultInt)) aktarget.equipitem(armorlist.getat(resultInt)) trace (armorlist.getat(resultInt))endFunction
Varithina Posted August 13, 2017 Posted August 13, 2017 Not too sure, but I think you may need to specify which armour piece on each call of it, so it would do boots on the first call, helm on the second, etc, though to be honest the last significant coding I did was 20 years ago and was assembly code. Though my nasty side of thinking on this makes me think you would need separate functions for each armour piece, and call them 1 by 1.
Andy14 Posted August 13, 2017 Posted August 13, 2017 I think it is a logic error - no thing of programming. Where and when is variavle oldamor set? 4x Call the function and oldarmor is the armor of the last call - for example. Only speculation. For more help, the whole code would be important - not just a function.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.