Jump to content

Need help developing a script


icecreamassassin

Recommended Posts

Alrighty, so I have this massive museum mod (Dragonborn Gallery) and I have activators for the displays where it looks to see if A the display is not enabled, and B you have the specified item. If both are true, it moves the item from you to a hidden chest (thus preserving enchantments vs just removing it and adding a new ref of the item when you take the display back). When you activate the display that is in place, the script does the reverse; checks the chest for the item and that the display is enabled, then it moves it back from the chest to you and disables the display. That's all working just skippy

 

What I'd like to do is have a function to remove all displays from the museum (disabling the display static) and place them in a chest the player can grab the items from. And also be able to put items into the chest and have a function to place all the items on display from inside the chest (moving them to the hidden chest) and enabling the display static.

 

I figured I would have an accessible container, and then have two dialog options with my NPC museum curator to facilitate the transfer. I am having trouble wrapping my head around an efficient way of doing it short of manually entering every single display and every single item as separate properties, which is just insane and would undoubtedly not work right and possibly crash the game as well :tongue:

 

Really what I need is an effective way to have the script automatically identify the item in the chest and enable the correct associated display by somehow referring to the properties of the individual activators.

 

So anyone have any ideas? Thanks in advance

Edited by icecreamassassin
Link to comment
Share on other sites

You could use either Arrays or FormLists to list your display case activators and the items that go with them. In both cases it would be a 1 to 1 ratio. If you have 10 displays, you would have 10 items.

 

FormLists might be easier as you can have them both open side by side and ensure that each index matches up correctly. The FormLists would be put into properties on the script. Whatever event you have triggering the displays could call a function similar to this:

 

 

FormList Property DisplayActivators Auto
FormList Property DisplayItems Auto
ObjectReference Property HoldingContainer Auto

Function ActivateValidDisplays()
	Int DASize = DisplayActivators.GetSize()
	Int index = 0
	While index < DASize
		If HoldingContainer.GetItemCount(DisplayItems.GetAt(index)) > 0
			(DisplayActivators.GetAt(index)).Enable()
		Else
			(DisplayActivators.GetAt(index)).Disable()
		EndIf
		index += 1
	EndWhile
EndFunction 

 

You could probably put the function and properties on the quest script and have the NPC's dialog call the function rather than trying to shove it all into the dialog script fragment.

Link to comment
Share on other sites

a bit more advanced than I'm used to yet, but it gives me some good ideas, so if I am understanding the jist here, instead of a single item and activator being set up as a script property, you set the property as a form list for each and you basically code it to keep checking the list for items until the item count hits 0, is that about right?

Link to comment
Share on other sites

hmm... no. Nothing in there about item count other than to make sure that there was at least one or more of the target item. The loop is used to cycle through the form lists that will have ALL your display activators and required items.

 

Example:

Ten total displays with one item required by each.

 

display #1 @ index 0 of DisplayActivators

item #1 @ index 0 of DisplayItems

 

display #2 @ index 1 of DisplayActivators

item #2 @ index 1 of DisplayItems

 

....

 

display #9 @ index 8 of DisplayActivators

item #9 @ index 8 of DisplayItems

 

display #10 @ index 9 of DisplayActivators

item #10 @ index 9 of DisplayItems

 

So, the player can put in two or three required items. Ask the NPC to put up displays. The function gets called and as many displays that have valid items become enabled.

 

Your other choice is to apply a script to each activator that checks the container for the required item using the OnCellAttach event. That may be a better route if you are going to have displays that require more than one item.

Link to comment
Share on other sites

Ok so I have tried placing the code on the display holding chest and stuck a OnItemAdded function set up form lists with the item to display and the list of display reference ID's which should get enabled as well as set the properties inside the script and it all compiles right, but does nothing in game. Here's what I have:

Scriptname DBM_DisplaySortScript extends ObjectReference  

FormList Property DisplayActivators Auto
FormList Property DisplayItems Auto
ObjectReference Property HoldingContainer Auto

Function ActivateValidDisplays()
    Int DASize = DisplayActivators.GetSize()
    Int index = 0
    While index < DASize
        If HoldingContainer.GetItemCount(DisplayItems.GetAt(index)) > 0
            enable(DisplayActivators.GetAt(index))
        Else
            disable(DisplayActivators.GetAt(index))
        EndIf
        index += 1
    EndWhile
EndFunction

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
    ActivateValidDisplays()
endevent

what am I missing?

Edited by icecreamassassin
Link to comment
Share on other sites

It was actually my mistake in the example code posted earlier. I forgot that forms stored in a formlist are pulled out as Form rather than the type you actually want. They need to be cast appropriately. In this case, since the display activators are all pre-placed in the cell ObjectReference is what they need to be.

 

Updated script based on your code, see if it works.

 

 

Scriptname DBM_DisplaySortScript extends ObjectReference  

FormList Property DisplayActivators Auto
FormList Property DisplayItems Auto
ObjectReference Property HoldingContainer Auto

Function ActivateValidDisplays()
    Int DASize = DisplayActivators.GetSize()
    Int index = 0
    While index < DASize
        If HoldingContainer.GetItemCount(DisplayItems.GetAt(index)) > 0
            (DisplayActivators.GetAt(index) as ObjectReference).Enable()
        Else
            (DisplayActivators.GetAt(index) as ObjectReference).Disable()
        EndIf
        index += 1
    EndWhile
EndFunction

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
    ActivateValidDisplays()
endevent 

 

 

Link to comment
Share on other sites

One issue I'm having is that some item displays are set up to accept any of the leveled versions of relics, so I can put each leveled item into the DisplayItem formlist but I can't put the display reference into the DisplayActivator formlist more than once. Any ideas on a workaround?

 

would it work to add all the items with multiple versions into their own formlist and load that formlist across from the corresponding activator?

Edited by icecreamassassin
Link to comment
Share on other sites

  • Recently Browsing   0 members

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