I want to add a script to the Player. If he picks up a piece of armor, that particular armor is removed from the inventory and is replaced with a different armor. This is applied to every single piece of playable armor, excluding accessories and circlets
Okay, so I'm planning on adding an OnItemAdded Event to player. Then I'll cycle through theFormList and compare the added item argument with each object in the FormList. Is it good enough? n order to maximize efficiency, I add InventoryFilter with that FormList as the argument
Here's the piece of code:
Scriptname RaestlozArmorChangerPlayerScript extends ReferenceAlias{Script that runs on Player.Changes the instance of armor that player gets}FormList Property VanillaArmorList AutoFormList Property CustomArmorList Autoint TempIndex = 0Event OnInit() AddInventoryEventFilter(VanillaArmorList)endEventEvent OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) TempIndex = GetFormIndex(VanillaArmorList, akBaseItem) if ( TempIndex > -1 ) Game.GetPlayer().removeItem(akBaseItem, aiItemCount,true); Game.GetPlayer().addItem(CustomArmorList.GetAt(TempIndex), aiItemCount,true); endifendEventint Function GetFormIndex(FormList List, Form Member) global{Gets the index of Member in List. Returns -1 if not found} if (!List.HasForm(Member)) Return -1 endifint Index = 0 While (List.GetAt(Index) != Member) Index += 1 EndWhile Return IndexEndFunctionWhat I need to know is, will this bog down script performance? For reference, Daedric Armor set alone consists of at least 100 items (the enchantment variant is to blame). I expect the total to be at least 700-900 items, perhaps more. This check will be performed everytime the player obtains an armor.
Should I opt with something else instead? Like, say, OnContainerChanged?
How do I use it? I know it says I can pass a FormList as an argument, but what exactly does it do?
If I want each item in the FormList to be treated differently, should I even use a FormList?
If I do use a FormList, it will contain at least 100 entries. Is it possible to see at which index of FormList A an item is and pick an item in FormList B at the same index?
EDIT: I just found out about FormList.GetAt(). It certainly helps, but that alone won't exactly help me for the core operations



