Post reserved so I can post a bunch of info. Stay tuned.
Edit: Creation Kit wiki is throwing an SQL error when trying to view pages. That's not very helpful.
Edit 2: I would do something like this.
Scriptname getSnowyQuestScript extends QuestSpell property _Treb_PlayerSnowSpell autoGlobalVariable property _Treb_Debug autoimport debugEvent OnInit() RegisterForSingleUpdateGameTime(0.25)endEventEvent OnUpdateGameTime() Actor pPlayer = Game.GetPlayer() float myDebug = _Treb_Debug.GetValue() Weather currentWeather = Weather.GetCurrentWeather() if currentWeather != none int wClass = currentWeather.GetClassification() if wClass == 3 ;Snow pPlayer.AddSpell(_Treb_PlayerSnowSpell, false) if myDebug == 1.0 notification("Added snow shader spell to player") endif else pPlayer.RemoveSpell(_Treb_PlayerSnowSpell) if myDebug == 1.0 notification("Removed snow shader spell from player") endif endif endif RegisterForSingleUpdateGameTime(0.25)endEvent
I simplified the weather logic; we only care about it either being snowy, or not. If it is; add the spell. If it's not, remove it.
I use RegisterFor
SingleUpdateGameTime() to avoid any possibility of stacking scripts on top of one another. I use GameTIme updates to run the script less frequently (once every 10 in-game minutes). On the default 20:1 timescale this translates to every 30 seconds. It would be fine to run this as an OnUpdate, but still use RegisterForSingleUpdate() and chain it at the bottom of the OnUpdate() event. 4 seconds on the update time is a bit quick; I'd think you'd need time for that snow to build up. Every 15-30 seconds I think would be fine (and perhaps more immersive / realistic). Not to mention, this is an aesthetic behavior script that should be given relatively lower priority than some others, so should probably be given fewer updates over time so that other scripts that need to run on a faster loop, have more of a CPU time slice to do it in without this trying to get in the way. Always strive to update as infrequently as possible without compromising the functionality of your mod.
I implement a new global variable that can be set at runtime using the developer console for debugging.
I use a spell instead of playing the shader effect directly. I don't know if this is the better way to do it, I've always just done it this way.
Make sure that the magic effect tied to the spell (if you go that route) has "FX Persist" checked. Also be sure to clear out any keywords the spell may have (if you duplicate another one to use as a template). Use the Ability type so that once it's applied it never goes away (duration is meaningless).
How to make this better:
- Replace the OnInit() event with a Papyrus fragment that kicks off this script when a new quest stage is set. This is good for being able to start up / shut down this mod on the fly. While this script is fairly simple, if something ever goes "off the rails" for a user it's handy to have a way to be able to restart it.
- Provide a configuration option to shut the mod down. A global variable would be sufficient.
- Hook up new logic at the bottom of the OnUpdate event to facilitate shutting down the mod by bypassing registering for the next update.
You can look at my magic effect in Frostfall to see what parameters I use, they should be fine for your purposes. The visual effect is a slightly modified frost damage shader, with a less intense (almost non-existent) edge glow and slightly increased alpha. You are free to copy the parameters of this shader and tweak it to your own use.
I hope this was helpful. Good luck!