Skyrim Scripting 3: OnLevelUp

Created:

Updated:

,

Last Time we made a basic MCM menu, in this tutorial we will laying the foundation for adding some functionality to it. Every time the player levels up a notification will trigger. With this knowledge you can then trigger nearly any function on level up. You can view the official documentation for the event here: https://www.creationkit.com/index.php?title=OnStoryIncreaseLevel_-_Quest

  1. First we open the creation kit, ensuring that the correct file is set to active file.
  2. We then create a new quest object, ill be naming mine “BLUpQ_kx”. You can name it whatever you want tho.
  3. Under the dropdown menu Event, select Increase level.
  4. Ensure start game enabled is unticked, while allow repeated stages is ticked.
  5. Head to the Scripts tab and click “Add”. This will be the script that actually does stuff, based on the settings defined in our MCM script/menu. Ill be calling mine “BLLevelUpS_kx“.
  6. Open the new script
  7. First we need to create a quest property. You can name it anything, but ill be naming it the same as our quest LevelUpQuest.
  8. We need to use the event OnStoryIncreaseLevel(int aiNewLevel). Which executes when this quest is triggered by the “increase level” story manager event, which we will set up later.
  9. Inside that, we are going to write a simple message letting us know when this executes in game, so we can make sure everything is set up correctly so far.
  10. Debug.notification(“BLLevelUpS_kx has detected the player has leveled up to level: ” + aiNewLevel + “!”) anything in quotes is a string of characters, by adding the aiNewLevel Variable, it’s value will be displayed directly after the string.
  11. Below that we need to write a function to end the quest, so it’s ready to run again when the player next levels up.
  12. LevelUpQ.stop() don’t forget the EndEvent at the bottom.
  13. Then save the script ensuring it compiles without error.
  14. Next we need to add our script to the Story Manager Event Node “Increase Level”. SM Event Nodes are found within the quest category.
  15. Open Increase Level, right click “Stacked Event Node: Increase Level” and select New Quest Node.
  16. Click on our new quest node and under node properties in the bottom left tick “Shares Event”.
  17. Right click this new quest node and select “Add Quests”, selecting our custom quest MCMQuestBl.
  18. Click OK in the top right and save the mod.
  19. Boot up the game and give it a test.
  20. The notification should show up after choosing a stat in the level up menu and leaving all menus. If it doesn’t you’ve probably messed up somewhere.

So now any functions you put within the on level up event will trigger when leveling up. In the next tutorial, i will show you how to edit actor values, nameley health, magicka and stamina. Though the concepts work for all actor values. Ill also go over using script functions and variables in other scripts, namely getting the variables from our mcm script and using them in our levelup script.

The completed level up script:

Scriptname BLLevelUpS_kx extends Quest  

quest Property LevelUpQuest Auto

Event OnStoryIncreaseLevel(int aiNewLevel)
	Debug.notification("BLLevelUpS_kx has detected the player has leveled up to level: " + aiNewLevel + "!")
	LevelUpQuest.stop()
endEvent