WhiteWolf424242 Posted December 15, 2020 Share Posted December 15, 2020 (edited) Hello, I'm trying to create a method where the player can put together a list of objects that at a later point is set as an outfit for an NPC.The way for the player is to select a dialogue option, then a container is shown into which he can put objects (that can be cast as Armor, so are some piece of armor, jewelry, etc.), and then the contents of the container are used as the new Outfit. In the CK, I have the following objects:- An empty FormList: WW42WeddingDressFormList- A LeveledItem: WW42WeddingDressLeveledItem- An Outfit: WW42WeddingDressOutfit , which in the CK, contains the previous LeveledItem.- A container: DressContainer. Here's the code attached on the container. The idea is that if an object castable as Armor is placed into the container, it is recorded into the FormList. Scriptname WW42WeddingDressContainerScript extends ObjectReference FormList Property WW42WeddingDressFormList Auto Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) If (akBaseItem as Armor != None) WW42WeddingDressFormList.AddForm(akBaseItem) Else RemoveItem(akBaseItem, aiItemCount, True, akSourceContainer) debug.notification("You can't use that in an outfit.") Endif EndEvent Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer) if (self.GetItemCount(akBaseItem) == 0) WW42WeddingDressFormList.RemoveAddedForm(akBaseItem) endif EndEvent Here's the script that happens when at the dialogue end to set the npc's Outfit (Note: we are not changing the outfit for akSpeaker! You talk to akSpeaker, but the Outfit change will be happening to a different NPC, who is stored in a quest alias.)The point of this fragment is to open the container, allow the player to put the pieces of clothing he wants to be included, and when it's closed, it will copy the contents of the FormList (set up in the container's code) into the LeveledItem. (GetOwningQuest() as WW42WeddingDressQuestScript).SetWeddingOutfit(akSpeaker) DressContainer.Activate(PlayerRef) Utility.Wait(1.0) WW42WeddingDressLeveledItem.Revert() ; the action is repeatable by the player - so revert any previous changes Int i = WW42WeddingDressFormList.GetSize() While( i > 0 ) i -= 1 Form currentItem = WW42WeddingDressFormList.GetAt(i) WW42WeddingDressLeveledItem.AddForm(currentItem, 1, 1) EndWhile akspeaker.AddItem(Gold001, 0) ; just for a sound effect The (GetOwningQuest() as WW42WeddingDressQuestScript).SetWeddingOutfit(akSpeaker) is a call for a quest script that uses the aliases of the quest to record the to-be-changed NPC's current Outfit for later changeback, sets some stages and quest variable stuff - that all works fine. Finally, when the time comes, a quest stage fragment script is the one that actually does the Outfit change. This is just: If( kmyQuest.OutfitSet == 1) ; (note: set by the quest script call described above) Alias_LoveInterest.GetActorReference().SetOutfit(WW42WeddingDressOutfit) else SetObjectiveDisplayed(10, false) Endif My problem with the whole thing: only one item is actually equipped into the new Outfit. Always only one, no matter how many the player puts into the container.If I willingly only put in one object - that shows up correctly. Be it an armor piece, a necklace or even a modded cape, it all works fine, regardless of the actual armor object type.But as soon as I try to put multiple items (say an armor and a necklace and a shoe) into the container, still only one gets equipped by the npc. It seems random - sometimes it's just the shoe, sometimes just the necklace, sometimes just the armor. I'm guessing that the randomness is involved because in the container code's WW42WeddingDressFormList.AddForm(akBaseItem), as far as I know, the exact index where the new form is inserted into the list is not definite.Therefore my guess is that only the first item of the FormList (and thus the first item of the LeveledItem) is inserted into the Outfit, but it's random which item is actually the first in the list, and that's why I see a random pattern. But I just can't figure out what I'm doing wrong. Why is only the first item/only one item in the Outfit?If someone could help by pointing out the problem, that would be greatly appreciated :smile: Edited December 15, 2020 by WhiteWolf424242 Link to comment Share on other sites More sharing options...
dylbill Posted December 15, 2020 Share Posted December 15, 2020 In your Levelled Item make sure the Use All box is ticked. Link to comment Share on other sites More sharing options...
foamyesque Posted December 15, 2020 Share Posted December 15, 2020 As described the issue sounds very much like the LeveledItem is set to only generate one (randomized) item. Make sure it's set up correctly, like @dylbill suggested. Link to comment Share on other sites More sharing options...
WhiteWolf424242 Posted December 15, 2020 Author Share Posted December 15, 2020 (edited) Oh, I guess that was painfully obvious, wasn't it.Thanks for pointing it out :D Works as expected now :) Edited December 15, 2020 by WhiteWolf424242 Link to comment Share on other sites More sharing options...
Recommended Posts