jucoking Posted December 11, 2018 Share Posted December 11, 2018 (edited) Hi all, I have created a new disease which works perfectly fine, but I need to display a message at 6am and 6pm everyday along with a music track change at that time (only in exterior cells). I figured it would be best to just tack it on to my disease because to get rid of the disease you have to complete the mod (which then wouldn't require day/night notifications and music changes). I have tried a lot of things and very basic scripting which obviously didn't work, but then I came across the following script on the creation kit website. Is there a way to modify this to attach it to my disease, or perhaps something else in my modded world so that it would reliably denote a day/night change? I have already attempted to modify it on my own but it never compiles. Any help is appreciated. ScriptName YourScript Extends ObjectReference ; in my case, it extends an ActiveMagicEffect Actor Property PlayerREF Auto ; <-- Imperative for expedience Bool Property bEnableStuff Auto ; Leave as default or 'False' Float Property fHourToDisable Auto ; Desired enable time/18.0 for example's sake Float Property fHourToEnable Auto ; Desired enable time/6.0 for example's sake Float Property fUpdateInterval Auto ; 15.0 works well and isn't too frantic. GlobalVariable Property GameHour Auto ; Pointed to engine maintained, special GlobalVariable ObjectReference Property kYourObject Auto ; Pointed to your statue or object that is to enable Event OnInit() RegisterForSingleLOSGain(PlayerREF, Self) bEnableStuff = !kYourObject.IsDisabled() ToggleEnableStateIfApplicable() EndEvent Event OnGainLOS(Actor akViewer, ObjectReference akTarget) RegisterForSingleLOSLost(PlayerREF, Self) RegisterForSingleUpdate(fUpdateInterval) ToggleEnableStateIfApplicable() EndEvent Event OnLostLOS(Actor akViewer, ObjectReference akTarget) RegisterForSingleLOSGain(PlayerREF, Self) UnregisterForUpdate() ; Stop polling ToggleEnableStateIfApplicable() EndEvent Event OnUpdate() ToggleEnableStateIfApplicable() RegisterForSingleUpdate(fUpdateInterval) EndEvent Function ToggleEnableStateIfApplicable() Float fTime = GameHour.GetValue() If bEnableStuff != (fTime > fHourToEnable && fTime < fHourToDisable) bEnableStuff = !bEnableStuff If bEnableStuff kYourObject.Enable() Else kYourObject.Disable() EndIf EndIf EndFunction Edited December 16, 2018 by jucoking Link to comment Share on other sites More sharing options...
Evangela Posted December 12, 2018 Share Posted December 12, 2018 (edited) Easiest way, I think, is to attach an ability to the player with the conditions: GameHour == 6.00 ORGameHour == 18.00 OR Then in the script for the magic effect: Event OnEffectStart(Actor akTarget, Actor akCaster) myMessage.Show() EndEven Conditions are checked every second. The example script you looked at is for more complex logic. In your case though, this should do. Edited December 12, 2018 by Rasikko Link to comment Share on other sites More sharing options...
jucoking Posted December 12, 2018 Author Share Posted December 12, 2018 (edited) So, if I have 2 different messages (1 for daylight and 1 for night time) this should work as well? Or should I add something like this along with the aforementioned conditions: Event OnEffectStart (Actor akTarget, Actor akCaster) If GameHour == 6.00 mymessage1.Show() If GameHour == 18.00 mymessage2.Show() EndIfEndEvent (Sorry this isnt posting correctly, I'm currently using my phone. Imagine the indentations in the script) Edited December 12, 2018 by jucoking Link to comment Share on other sites More sharing options...
Evangela Posted December 13, 2018 Share Posted December 13, 2018 (edited) Yeah but that wont compile because too many ifs without the matching number of endifs. Also for that you can use this: if statement == something ; do something elseif statement == something ; do something endif The problem is, if there is no kind of polling, the effect will check only once and never again. This is why I mentioned conditions, and why that example script and many others require polling of some kind to handle game time checking. Edited December 13, 2018 by Rasikko Link to comment Share on other sites More sharing options...
jucoking Posted December 14, 2018 Author Share Posted December 14, 2018 (edited) Yeah but that wont compile because too many ifs without the matching number of endifs. Also for that you can use this: if statement == something ; do something elseif statement == something ; do something endif The problem is, if there is no kind of polling, the effect will check only once and never again. This is why I mentioned conditions, and why that example script and many others require polling of some kind to handle game time checking.Okay, so I've had some time to work on this and I got the script to compile successfully. Here's what it looks like: Scriptname DayNightMesg extends activemagiceffect Event OnEffectStart(Actor akTarget, Actor akCaster) If GameHour.GetValueInt() == 6 Debug.MessageBox("THE MORNING SUN HAS VANQUISHED THE HORRIBLE NIGHT") CV2_MUSTransylvania.Add() CV2_MUSTransylvaniaNIGHT.Remove() ElseIf GameHour.GetValueInt() == 18 Debug.MessageBox("WHAT A HORRIBLE NIGHT TO HAVE A CURSE...") CV2_MUSTransylvaniaNIGHT.Add() CV2_MUSTransylvania.Remove() EndIf EndEvent GlobalVariable Property Gamehour Auto GlobalVariable Property GameDaysPassed Auto MusicType Property CV2_MUSTransylvania Auto MusicType Property CV2_MUSTransylvaniaNIGHT AutoMy conditions for the magic effect are:1) GetCurrentTime == 6.00 OR (runs on subject)2) GetCurrentTime == 18.00 OR (runs on subject) However, the messages will not display in-game and the music won't change. I know how the music types work and have set them to higher priority than anything else that should be currently playing (they are at priority 3). Do I need to change the conditions to run on the player? OR, am I messing with the wrong conditions...because there are conditions for spells and individual magic effects. Edited December 16, 2018 by jucoking Link to comment Share on other sites More sharing options...
jucoking Posted December 16, 2018 Author Share Posted December 16, 2018 (edited) Here is the modified script that I am currently working with, I don't think conditions are necessary as long as updates are scripted in: Scriptname DayNightMsg extends activemagiceffect Event OnUpdateGameTime() If GameHour.GetValueInt() == 6 Debug.MessageBox("THE MORNING SUN HAS VANQUISHED THE HORRIBLE NIGHT") CV2_MUSTransylvaniaNIGHT.Remove() CV2_MUSTransylvania.Add() ElseIf GameHour.GetValueInt() == 18 Debug.MessageBox("WHAT A HORRIBLE NIGHT TO HAVE A CURSE...") CV2_MUSTransylvania.Remove() CV2_MUSTransylvaniaNIGHT.Add() EndIf EndEvent Event OnEffectStart(Actor akTarget, Actor akCaster) If akTarget == Game.GetPlayer() RegisterForUpdateGameTime(1.0) EndIf EndEvent MusicType Property CV2_MUSTransylvania Auto MusicType Property CV2_MUSTransylvaniaNIGHT Auto GlobalVariable Property Gamehour Auto GlobalVariable Property GameDaysPassed AutoSTILL no luck getting it to call in-game, though. I have no idea what I'm missing, but I feel like I'm getting closer. If anyone has suggestions, I'm all ears, otherwise I will keep trying to mess with the scripts/conditions/effects to see what I can do. I will post updates here if I make any progress. Also, I need to make sure the script doesn't call unless the player is OUTSIDE. If anyone knows the script for making sure the player is in an exterior cell, please let me know! Thanks. Edited December 16, 2018 by jucoking Link to comment Share on other sites More sharing options...
jucoking Posted December 16, 2018 Author Share Posted December 16, 2018 I figured it out myself. Leaving this here for my self for future reference. Scriptname DayNightMsg extends activemagiceffect Event OnUpdate() If GameHour.GetValueInt() == 6 Debug.MessageBox("THE MORNING SUN HAS VANQUISHED THE HORRIBLE NIGHT") CV2_MUSTransylvaniaNIGHT.Remove() CV2_MUSTransylvania.Add() UnRegisterForUpdate() RegisterForUpdate(15.0) ElseIf GameHour.GetValueInt() == 18 Debug.MessageBox("WHAT A HORRIBLE NIGHT TO HAVE A CURSE...") CV2_MUSTransylvania.Remove() CV2_MUSTransylvaniaNIGHT.Add() UnRegisterForUpdate() RegisterForUpdate(15.0) EndIf EndEvent Event OnEffectStart(Actor akTarget, Actor akCaster) If akTarget == Game.GetPlayer() RegisterForUpdate(15.0) EndIf EndEvent MusicType Property CV2_MUSTransylvania Auto MusicType Property CV2_MUSTransylvaniaNIGHT Auto GlobalVariable Property Gamehour Auto GlobalVariable Property GameDaysPassed AutoAgain, if anyone can help, I need this script to call ONLY if the player is outdoors (in an exterior cell). I have looked in a lot of places but can't find anything on it. Will keep looking in the mean time. Link to comment Share on other sites More sharing options...
Evangela Posted December 17, 2018 Share Posted December 17, 2018 I need this script to call ONLY if the player is outdoors (in an exterior cell). Event OnEffectStart(Actor akTarget, Actor akCaster) If akTarget == Game.GetPlayer() if akTarget.IsInInterior() == FALSE RegisterForUpdate(15.0) endif EndIf EndEvent Link to comment Share on other sites More sharing options...
jucoking Posted December 19, 2018 Author Share Posted December 19, 2018 I need this script to call ONLY if the player is outdoors (in an exterior cell). Event OnEffectStart(Actor akTarget, Actor akCaster) If akTarget == Game.GetPlayer() if akTarget.IsInInterior() == FALSE RegisterForUpdate(15.0) endif EndIf EndEvent Thanks again, Rasikko! Much appreciated. Link to comment Share on other sites More sharing options...
Recommended Posts