First what we will want to do is open up the Creation Kit, and goto Characters -> Quest
Now we will want to fill in the window, lets call our new quest form ZZ_TestController
Select the following options
- [x] Run at Start-up
- [x] Repeat States
From here we place a check at [x] Start Up Stage right click and also select New in the Log Entry, now the Papyrus Fragment should be greyed out from here we will continue and click OK at the dialog box to close it out
Now goto Gameplay -> Papyrus Manager right click and select New
We will name this script ZZ_VersionHandler and have it extend Quest
Now right click on our new Script and select Open External Editor
Spoiler
ScriptName ZZ_VersionHandler Extends Quest ;These are variables that will pretty much tell us if we should update or not;Current Version (New Version if any);Installed Version (is the one that is found in the saved-game variable listGlobalVariable Property Ver_Current AutoGlobalVariable Property Ver_Installed AutoBook Property ManualBook Autofloat fUpdateInterval = 5.0bool bKeepAlive = TrueBool Function IsVersionOk() If Ver_Current.GetValueInt() != Ver_Installed.GetValueInt() Return False EndIf Return TrueEndFunctionFunction CheckUpdate() RegisterForSingleUpdate(fUpdateInterval)EndFunctionFunction AddManual() Actor player = Game.GetPlayer() If player.GetItemCount(ManualBook) > 0 player.RemoveItem(ManualBook,player.GetItemCount(ManualBook),False) EndIf player.AddItem(ManualBook,1)EndFunctionEvent OnUpdate() If !IsVersionOk() AddManual() Ver_Installed.SetValueInt(Ver_Current.GetValueInt()) Debug.Notification("Please check Arcane Assassin Manual for updates") EndIf If bKeepAlive RegisterForSingleUpdate(fUpdateInterval) EndIfEndEventIf you have followed the instructions and using the Notepad++ from the Creation Kit Wiki, press CTRL+F5 to compile the script
Lets create a second script and name this script ZZ_VersionHandler and have it extend ObjectReference
Now right click on our new Script and select Open External Editor
Spoiler
ScriptName ZZ_OurModManual Extends ObjectReference Perk Property MyPerk AutoFormList Property MyPerkSpellsList AutoActor playerEvent OnRead() player = Game.GetPlayer() AddSpellsForPerk(MyPerk, MyPerkSpellsList) ;Repeat if more perks are availableEndEventFunction AddSpellsForPerk(Perk prk, FormList list) If list != None If player.HasPerk(prk) Int i = 0 Int size = list.GetSize() While i < size If (list.GetAt(i) As Spell) Spell i_spell = (list.GetAt(i) As Spell) If !player.HasSpell(i_spell) player.AddSpell(i_spell) EndIf ElseIf (list.GetAt(i) As Shout) Shout i_shout = (list.GetAt(i) As Shout) If !player.HasSpell(i_shout) player.AddShout(i_shout) EndIf ElseIf (list.GetAt(i) As WordOfPower) WordOfPower i_word = (list.GetAt(i) As WordOfPower) If !Game.IsWordUnlocked(i_word) Game.UnlockWord(i_word) Game.TeachWord(i_word) EndIf EndIf i += 1 EndWhile EndIf EndIfEndFunction
Also Compile this script
Ok lets go to the Object Window
- Miscellaneous -> Global
- Right Click in the Form List, select New
- First Global Variable name it ZZ_VersionCurrent and select Short for the integer type 101 (new version number) and select Constant
- Second Variable ZZ_VersionInstalled and select Short for the integer type 100 (this is the old version) and dont select Constant, because this number will always change depending if the developer has updated, this will be compared with the first variable we created
Double click our book, and attach the ZZ_OurModManual to it, and fill in the properties that hold our Perk and Perk Spells contained in a Form List
=================================================
Why use this method? Well first of all if you plan to add perks that give player spells / abilities or etc. Then your going to need a way to update your players spell list if he already has the perk (in-case we added to the spell list). A Book is great not only can it run a script when it is read, but it can contain version history and important information for the player to read.
Example: When a player downloads a update of your mod, and has a perk that gave spells already from his previous journey in his saved-game. It will no longer continue to give the new spells in the Form List, this is why this method is important. The quest will detect the MOD version number, and the SAVED-GAME version number of the previous mod. If the version number is different from the saved-game version it will remove the book and re-add the book.
So why remove / re-add the book? Well the book is a saved reference that contains all the property configurations from the previous mod, lets say the new mod added more FORM LISTS, then the old book wont contain these, so its important to remove the old book then add the new book so the player can have the updated features when he reads the book, because the script i gave allows you to add / remove perk and form lists as needed to keep the player updated
=================================================
Ok lets go back to the quest we created open that up and...
Select Script tab, and add the new script we created ZZ_VersionHandler
Fill in the Variables we created in the Properties
Go back to Quest Stages and in the Papyrus Fragment area select ZZ_VersionHandler as our kmyQuest handler
Spoiler
kmyQuest.CheckUpdate()
Thats it, from here at the very first tap select "Compile All Scripts" and you should be set

