How to Run a Global Script

Post » Sun Jun 17, 2012 4:41 pm

alright, I've just been working on a script to tie werewolf transformations to the phases of the moon instead of the beast form power. For the past three hours, and its finally compiling. Now I've run into a problem namely that it doesn't seem to work in game, and I'm not sure why. There are no compile errors, its attached to a startgame enabled quest, and its printed below. If anyone can be of help to figuring out how to make this work, I'd be very gracious for their help.


scriptname cohTransformTiming extends Quest{Controls the Timing for transformation.};calling properties, spells, globals, and importing the maths.        import Math    float property cohGetMoonPhase auto    float property cohPhaseDay auto    bool property cohCanTransform auto    bool property cohbmvar auto    bool property NotFirstChange auto    Spell property WerewolfChangeEffect auto    GlobalVariable Property TimeOfDayGlobalProperty auto    GlobalVariable Property GameDaysPassed auto    GlobalVariable Property PlayerIsWerewolf auto    GlobalVariable Property PlayerWerewolfShiftbacktime auto    MagicEffect Property Werewolf auto    ; The script should run once every in game minute in this state, otherwise the flavor texts could be desychronized.Event OnUpdateGameTime()RegisterForUpdateGameTime(1.0); Determining Moon Phase Below...Not yet implimented.    float timeOfDay = TimeOfDayGlobalProperty.GetValue()    float DaysPassed = GameDaysPassed.GetValue()    cohGetMoonPhase = 0; Ignore PhaseDay, not functioning in this iteration of the script.;/List of moon phases returned by cohGetMoonPhase.0 = full moon1 = 3/4 waning2 = half waning3 = 1/4 waning4 = new moon5 = 1/4 waxing6 = half waxing7 = 3/4 waxing/;;Not sure what cohPhaseDay should return, though one is an adequete placeholder.    If TimeOfDay >= 20 || TimeOfDay < 6    cohCanTransform == true    elseif TimeOfDay < 20 || TimeOfDay >= 6    cohCanTransform == falseendif; Hell, it's morphing time!        if PlayerIsWerewolf.GetValue() == 1 && cohCanTransform == true && NotFirstChange == true && game.getplayer().HasMagicEffect(Werewolf) == 0    PlayerWerewolfShiftbacktime.SetValue(10000)    WerewolfChangeEffect.Cast(Game.GetPlayer(), Game.GetPlayer())    Utility.WaitGameTime ( 0.05 )    Debug.Notification ("Generic Flavor Text")        elseif PlayerIsWerewolf.GetValue() == 1 && cohCanTransform == true && NotFirstChange == false && game.getplayer().HasMagicEffect(Werewolf) == 0    PlayerWerewolfShiftbacktime.SetValue(10000)    WerewolfChangeEffect.Cast(Game.GetPlayer(), Game.GetPlayer())    Utility.WaitGameTime ( 0.05 )    Debug.MessageBox ("First Post Transform Flavor Text")    elseif PlayerIsWerewolf.GetValue() == 1 && game.getplayer().HasMagicEffect(Werewolf) == 1 && cohCanTransform == false    PlayerWerewolfShiftbacktime.SetValue(1)    game.getplayer().DispelSpell(WerewolfChangeEffect)endifEndEvent
User avatar
sarah simon-rogaume
 
Posts: 3383
Joined: Thu Mar 15, 2007 4:41 am

Post » Sun Jun 17, 2012 8:56 pm

Hmm I cannot see any error here right now, sorry (I'm new to this aswell). Only guess I have is that tieing the script to the quest is the problem. In order to test the script I'd use the same method as the Hello World Tutorial in the wiki, namely tying the script to an actor and run the code upon using this actor.

Also if you haven't figured it out yourself yet: Moonphases are contolled in the climatezone objects. For each moon seperatly it is controlled if the moon is visible at all in that zone and how long each phase lasts. I have not figured out yet how to get the currently active climatezone ingame and acquire it's moonphase data in order to calculate the current phase. If you make any progress there please share, because I need the moonphase info in order to create a "fix" for the Lunar Forge.
User avatar
Alisia Lisha
 
Posts: 3480
Joined: Tue Dec 05, 2006 8:52 pm

Post » Mon Jun 18, 2012 2:13 am

No point in calling RegisterForUpdate inside the OnUpdate event - the update event is only sent to scripts who have already registered for update.

If this is in a quest which is enabled on start, very simple solution is to create a startup stage (stage which has "Start Up Stage" checked, which means it is set when the quest starts), and put your RegisterForUpdate call in there.
User avatar
Danial Zachery
 
Posts: 3451
Joined: Fri Aug 24, 2007 5:41 am

Post » Mon Jun 18, 2012 12:09 am

Ah, makes sense, gonna do that now.


I'd do that by adding a Papyrus fragment to the Starup Quest stage which reads

RegisterForUpdateGameTime(5.0)


and has the cohTransformationTiming script as its kmyquest correct?
User avatar
Andrea Pratt
 
Posts: 3396
Joined: Mon Jul 31, 2006 4:49 am

Post » Mon Jun 18, 2012 6:35 am

Hmm...For whatever reason, the script isn't initializing, I put a debug.notification before and after the

RegisterforUpdate(60)

(do I need to reference the script/event that its supposed to activate?)
User avatar
lolly13
 
Posts: 3349
Joined: Tue Jul 25, 2006 11:36 am

Post » Mon Jun 18, 2012 7:34 am

If I remember correctly, that registers the scripted instance of the form (the quest or reference or whatever) to receive updates. While it's receiving updates, all scripts attached to it will effectively receive updates.

Cipscis
User avatar
Kate Norris
 
Posts: 3373
Joined: Mon Nov 27, 2006 6:12 pm

Post » Mon Jun 18, 2012 6:11 am

Agh...Well, I'm pretty positive that the meat of the script isn't the problem, but I'm at a loss as to how to trigger it. I've looked in both quest and scripting tutorials, but I can't find an adequate explanation of how to write a papyrus fragment script in such a way as to make it trigger a quest script. Or the quest is wrong, or something else.

The notifications would actually appear on the screen if they were working, correct? Certainly not in the console or in some weird place?

edit 2: Is it possible something's wrong with my Creation Kit? Say scripts aren't compiling properly?
User avatar
Bambi
 
Posts: 3380
Joined: Tue Jan 30, 2007 1:20 pm


Return to V - Skyrim