bladie Posted June 30, 2012 Share Posted June 30, 2012 For the mod I'm working on, I want a script to run everytime the player levels up. I can't get this to work however :wallbash: Since I'm new to modding, the solution may be much simpler than I think it is. This is what I tried: In the CK, under 'Character' --> 'SM Event Node' I created a new quest node for the 'Increase Level' event. For the node conditions I chose to check the player level, and if it is equal to or higher than 1 the quest should run (atleast I think so, please correct me if I'm wrong).In the 'Quest Data' tab of the quest, I set event to 'Increase Level'. For quick testing I added a script at the 'Script' tab of the quest. This script contains an 'Event OnInit()' and should print a message to the screen via 'Debug.MessageBox' and 'Debug.Notification'. I also know there is a OnStoryIncreaseLevel event for Papyrus, is this maybe what I need, and if so, how would I implement this? If you know anything of help, please post :wink: Link to comment Share on other sites More sharing options...
gasti89 Posted June 30, 2012 Share Posted June 30, 2012 I think for what you want is better to set something like the PlayerSleep quest. It is start game enabled and it just registers the sleep ends from the player, adding the magic effects needed. it works with the "register" fragment + a quest script set as kmyquest that contains all. But i think for you it's better to set the player as an alias and script it. Try looking at it, in the while i'll try to find some functions that may work. Link to comment Share on other sites More sharing options...
bladie Posted June 30, 2012 Author Share Posted June 30, 2012 Thanks for the help gasti89. I've looked at the PlayerSleep quest and I still don't really get how the fragment and the kmyQuest work. But when I look at the quest and the two scripts at the 'Scripts' tab of the quest I see an 'OnSleepStop' event in the PlayerSleepQuestScript. Is this the actual check to make sure the script only runs when the player sleeps (or rather stops sleeping)? And if I would make my mod similar (with a script attached to a player alias like you suggested), can I then use the 'OnStoryIncreaseLevel' event for that? Or would that somehow give problems with the story manager? Link to comment Share on other sites More sharing options...
gasti89 Posted July 1, 2012 Share Posted July 1, 2012 (edited) Uhm i was thinking there was a level increase event for an actor, but there isn't :( So i think you'll have to do like you originally posted. But instead of using OnInit() you'd use OnStoryIncreaseLevel. But i'm not entirely sure on how this works. Let's do like this: - Set the quest with two stages: 0 marked as "startup stage", without a fragment, and stage 10 with just "Stop()" in the fragment. - make the quest start through the Increase Level Node - create a quest script with something like this Event OnStoryIncreaseLevel(Int AiNewLevel) Debug.MessageBox("This Message will be replaced with the effects if the script works") Utility.Wait(1) GetOwningQuest().SetStage(10) EndEvent I think the quest stage will trigger the quest stopping, so it can restart on the next level increase. The utility.wait is just to give the script time to actually display the message. Edit: of course, unmark "do once" in the Quest data tab Edited July 1, 2012 by gasti89 Link to comment Share on other sites More sharing options...
bladie Posted July 1, 2012 Author Share Posted July 1, 2012 (edited) I've tried it again the way I described in my original post and with gasti89's tips, but it still doesn't work. For the node condition, I now compare the player level to a global, just like the node conditions do that are originally in the game. Here is the script I used: ScriptName bladie_PlayerResetStatsAtLevelUp_test Extends Scene ;GetOwningQuest needs this {Test script} Event OnStoryIncreaseLevel(Int AiNewLevel) Debug.MessageBox("This Message will be replaced with the effects if the script works") Debug.Notification("Debug Notification successfull") Utility.Wait(100) ;should give plenty of time to see the messages Utility.WaitMenuMode(100) GetOwningQuest().SetStage(10) EndEvent And in the Papyrus Fragment box in the quest page, there is also an option to pick a kmyQuest. Should I pick something here or can I leave it to 'NONE'? But the script doesn't start anyway. So I think the possibilities are:1) Something went wrong with my quest node in the Story Manager so the quest does not start2) The quest does start but does not launch the script3) The script does start but the OnStoryIncreaseLevel event prevents it from running Is there any way I can see if a quest is running ingame? Edited July 1, 2012 by bladie Link to comment Share on other sites More sharing options...
Sjogga Posted July 1, 2012 Share Posted July 1, 2012 You need to set the quest to "start game enabled" as well as adding the "Increase Level"-event. Navigate to SM Event Node->Increase Level and add a new Quest Node. Link it to your quest. Add this script to your quest:: Scriptname levelTrack extends Quest import Game Event OnStoryIncreaseLevel(int aiNewLevel) ;do stuff self.reset() endEvent At least this is how I did it for this mod. Link to comment Share on other sites More sharing options...
bladie Posted July 1, 2012 Author Share Posted July 1, 2012 (edited) You need to set the quest to "start game enabled" as well as adding the "Increase Level"-event. Navigate to SM Event Node->Increase Level and add a new Quest Node. Link it to your quest. Already did this. Not the "start game enabled" though since that grays out when I selecht the "Increase Level"-event. Add this script to your quest:: Scriptname levelTrack extends Quest import Game Event OnStoryIncreaseLevel(int aiNewLevel) ;do stuff self.reset() endEvent But I did not do this, and this does the trick :laugh: Thank you Sjogga, that really helped. But I wonder, what is the function of "import Game" in your script? And is the self.reset() used to reset the quest, so it can run again when you level up again? Edit: Just thought of the fact that the script does not really launch when I want it too. It now runs right after you excited the level up screen. In my mod I would like to reset the stats (health, magicka and stamina) of the player when he/she levels up, so that they do not refill anymore like in vanilla. I need to have the script run at the moment just before you click 'Health', 'Magicka' or 'Stamina' in the level up screen. This is the same moment when the Level up tutorial appears, so I think it's somehow possible to run a script at that time. I tried to look in the CK at how the turorials where done, but could not really find anything useful. Any ideas? Edited July 1, 2012 by bladie Link to comment Share on other sites More sharing options...
Sjogga Posted July 1, 2012 Share Posted July 1, 2012 But I wonder, what is the function of "import Game" in your script? And is the self.reset() used to reset the quest, so it can run again when you level up again?import Game doesn't do anything in that piece of code (I forgot to remove it). However, importing Game allows you to use the game-functions without typing "game.<function name>". function someFunction() Actor player = getPlayer() ; <- only works if you import game ;Actor player = game.getPlayer() ;<- Always works endFunction You can do the same for utility, math, SKSE and a few more.Exactly, self.reset() resets the quest so it can be run again. I need to have the script run at the moment just before you click 'Health', 'Magicka' or 'Stamina' in the level up screen. This is the same moment when the Level up tutorial appears, so I think it's somehow possible to run a script at that time. I tried to look in the CK at how the turorials where done, but could not really find anything useful. Any ideas?Well, you can't use OnStoryIncreaselevel then, as it doesn't trigger until the player actually chooses attribute. I'm afraid I can't help you any further :confused: Link to comment Share on other sites More sharing options...
Recommended Posts