Jump to content

[LE] Adding Items to Levelled Lists


Recommended Posts

Thanks folks, I've got it working now. One more question, although it's straying a bit from my original query - is a LeveledItem a collection of Forms, then? As you mention, a Form property's drop-down doesn't show everything you would expect (I'd expect the same contents as the "Object" drop-down when editing a LeveledItem, but it instead just has CommandingActorPersistenceForm and PapyrusPersistenceForm). Is there a type which both LeveledItems and ordinary Items extend from, other than Forms? Also, is what is the 'superclass' of all (regular, non-leveled) Items (if there is one other than Form)?

Thanks

Edited by NationalSpearmint
Link to comment
Share on other sites

Thanks folks, I've got it working now. One more question, although it's straying a bit from my original query - is a LeveledItem a collection of Forms, then? As you mention, a Form property's drop-down doesn't show everything you would expect (I'd expect the same contents as the "Object" drop-down when editing a LeveledItem, but it instead just has CommandingActorPersistenceForm and PapyrusPersistenceForm). Is there a type which both LeveledItems and ordinary Items extend from, other than Forms? Also, is what is the 'superclass' of all (regular, non-leveled) Items (if there is one other than Form)?

Thanks

 

Almost everything is a Form (the two major exceptions are Aliases and ActiveMagicEffects), but to fill a Property in the Properties menu you need to specify its subtype. This isn't a problem because there's nothing you'd want to refer to that doesn't have a subtype of some kind.

 

You can treat it as a generic form thereafter, including putting it into variables or properties of the type Form without needing to explicitly cast it, so you could have, say, an array of type Form[] that you use to hold a list of both weapons and armour. You don't need to be concerned about how a LeveledItem internally stores its lists of forms because, as it is a script object, it provides the functions to find and manipulate those items itself (particularly if you're using SKSE).

Edited by foamyesque
Link to comment
Share on other sites

Just to (hopefully) be of use to people who want to have custom items added to levelled lists in future, who may stumble across this post, here's the process I used:

 

0. Set up Creation Kit for Papyrus scripting by extracting the Scripts.rar file in Skyrim/Data .

1. Create a new Quest. Set this to Start Game Enabled and Run Once.

2. Close and re-open the Quest window (not entirely sure this is necessary, but I recall other tutorials mentioning it).

3. In the Scripts tab of the Quest, Add a new script. I'd recommend naming the script something like "AddBooksToLeveledItems" (if the item you want to add are books).

4. Right-click on this script and click "Edit Source".

5. Because of the issue Myst42 mentioned (the Forms drop-down not populating correctly), you'll need a seperate script for each type of Form you want to add to a LeveledItem. For the script text, enter as follows:

Scriptname <ScriptName> extends Quest  

LeveledItem[] Property LevelledListToUpdateArray  Auto

<ItemType>[] Property ItemToAddArray Auto

Int[] Property MinimumLevelArray Auto


Function AddLevelledListToLevelledList(LeveledItem LevelledList,  Form FormToAdd, Int MinimumLevel, Int NumberToAdd)
	LevelledList.AddForm(FormToAdd,MinimumLevel,NumberToAdd)
EndFunction

Event OnInit()
	Int iElement = LevelledListToUpdateArray.Length
	While iElement
		iElement-=1
		AddLevelledListToLevelledList(LevelledListToUpdateArray[iElement],ItemToAddArray[iElement],MinimumLevelArray[iElement],1)
	EndWhile
EndEvent

Replace the <ScriptName> with the name of your script and <ItemType> with the type of Form your script is adding to a LevelledItem, respectively. (For the names of Forms, check the link TestTiger2 shared: https://www.creationkit.com/index.php?title=Category:Script_Objects .)After doing this, you should be able to save and compile without error.

 

6. Double-click the script to edit its properties; the LevelledListToUpdateArray property is an array of levelled lists to update. The ItemToAddArray property is an array of the Form you want to add to the levelled list at the same array index. The MinimumLevelArray property is an array of Integers representing the minimum level the player must be for the Form at the same index to appear in the levelled list at the same index.

 

For example, if you want to add custom spell tomes SpellTomeCust1 and SpellTomeCust2 to LItemSpellTomes25AllConjuration, and SpellTomeCust3 to LItemSpellTomes50AllConjuration, ignoring player level, then:

  • The above code's <ItemType> should be replaced with Book
  • LevelledListToUpdateArray should contain LItemSpellTomes25AllConjuration, LItemSpellTomes25AllConjuration and LItemSpellTomes50AllConjuration in that order
  • ItemToAddArray should contain SpellTomeCust1, SpellTomeCust2 and SpellTomeCust3 in that order
  • MinimumLevelArray should contain 1, 1 and 1

It's important that all the arrays have the same number of records (or at least, that the LevelledListToUpdateArray has no more elements than the other two arrays).

 

7. Ok this and save. The script should then run on startup and populate the levelled lists specified with the forms specified. If you want to make sure the script runs, you can include a Debug.MessageBox("Hello") in the Event OnInit part of the script (although make sure you remove this before publishing).

 

8. Repeat steps 3-6 for each different type of Form you want to add to a LeveledItem. When you're happy with your script(s), go to File -> Create Archive to collate your scripts into a .bsa file which can be distributed with your esp.

 

 

Thanks again for everyone's help with this. please let me know if these instructions are incorrect, insufficient, misleading etc. or if there's a more suitable place to post them.

Link to comment
Share on other sites

Yeah, I was considering that, but that would mean I'd have an additional LeveledItem for each LeveledItem I want to insert into (in my scenario, I only needed one item to be inserted into each LeveledItem - if I needed more items inserted this probably would've been the better option). If I have several scripts I don't have any requirement for storing that additional data.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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