• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

How do you change Night/Day speed

Status
Not open for further replies.
Level 14
Joined
Jul 26, 2008
Messages
1,009
Alright so I wanted to put a trigger in my map where night goes slower and day goes faster depending on how easy of the mode you have it in. I might even include something like time stopping or clock slowing as an ability/ult.

However I can't seem to figure out the right function to use. At first I was told to use Game - Set Game Speed (AKA SetGameSpeed).

Then I was told to use SetTimeOfDayScale() But that crashes the game :\ Dunno why, but it just does. Here's an example of the code I'm using:

JASS:
function Trig_Skiptime_Actions takes nothing returns nothing
    if udg_EasyMode == 1 then
        call SetFloatGameState(GAME_STATE_TIME_OF_DAY, 7.10)
        call SetTimeOfDayScale(1.15)
    else
        call SetFloatGameState(GAME_STATE_TIME_OF_DAY, 8.10)
        call SetTimeOfDayScale(1.45)
    endif
endfunction

//===========================================================================
function InitTrig_Skiptime takes nothing returns nothing
    set gg_trg_Skiptime = CreateTrigger(  )
    call TriggerRegisterGameStateEvent(gg_trg_Skiptime, GAME_STATE_TIME_OF_DAY, EQUAL, 6.10)
    call TriggerAddAction( gg_trg_Skiptime, function Trig_Skiptime_Actions )
endfunction

Dunno why, but it just crashes the game. :\
 
Level 9
Joined
Nov 4, 2007
Messages
931
Err your function worked fine for me, though instead of using your Easymode variable comparison i simply did and if comparison of 1 == 1 then 1 == 2.
 
Best thing to do is to put BJDebugMsgs.

Try out different things:
JASS:
function Trig_Skiptime_Actions takes nothing returns nothing
    if udg_EasyMode == 1 then
        call BJDebugMsg("Easymode = 1")
//        call SetFloatGameState(GAME_STATE_TIME_OF_DAY, 7.10)
        call SetTimeOfDayScale(1.15)
    else
        call BJDebugMsg("Easymode != 1")
//        call SetFloatGameState(GAME_STATE_TIME_OF_DAY, 8.10)
        call SetTimeOfDayScale(1.45)
    endif
endfunction

//===========================================================================
function InitTrig_Skiptime takes nothing returns nothing
    set gg_trg_Skiptime = CreateTrigger( )
    call TriggerRegisterGameStateEvent(gg_trg_Skiptime, GAME_STATE_TIME_OF_DAY, EQUAL, 6.10)
    call TriggerAddAction( gg_trg_Skiptime, function Trig_Skiptime_Actions )
endfunction

Try that. If it crashes, then do the "//" comment lines for the time of day scale. This might help you identify the problem.. At the moment, it works fine for me.
 
Level 14
Joined
Jul 26, 2008
Messages
1,009
It's definently related to the SetTimeOfDayScale() function for me. I remove it, no crash. I add it, crash. I put BJDebug messages between the ifs, I see the BJDebugMessage.

I'll have to create the trigger on a seperate map to see if it's my compiler or if it's the map.

Does anyone know what would make that function crash the game? Maybe doing it with other libraries like TimerUtils or GroupUtils in the map? Is there reasons why it could be doing this?
 
Level 14
Joined
Jul 26, 2008
Messages
1,009
Well the exact map it's in is the 11th. However when I tested it in another map, it crashed. BOOM! Well the night one did. The day one seemed fine. So what's up with it? Compiler? Conflict with TimerUtils? ??? D:

I'll provide both maps. Just a warning the 11th is FULL of triggers. It's in the SkipTime folder.

The other map has 4 triggers. The problem trigger is once again in the SkipTime folder.
 

Attachments

  • 11th Vampire.w3x
    1.9 MB · Views: 82
  • Timer404.w3x
    25.8 KB · Views: 46
Level 9
Joined
Nov 4, 2007
Messages
931
JASS:
private function RemoveDamned takes nothing returns boolean
    if GetUnitTypeId(GetEnumUnit()) == 'uC02' then
        call KillUnit(GetEnumUnit())
    endif
return false
endfunction

private function Actions takes nothing returns nothing
 local integer i = 0
 local group g = CreateGroup()
    call GroupEnumUnitsInRect(g, GetPlayableMapRect(), function RemoveDamned)
//...
endfunction
Shouldn't the GetEnumUnit() be GetFilterUnit()? I can't look into the map for some reason, any change I make to the script at all causes it unable to load.
 
Level 14
Joined
Jul 26, 2008
Messages
1,009
Which map?

And I'm using JNGP with projecthorus TESH and updated JASSHelper. I've recently disabled UMSWE and Reinventing the craft, but enabled them again once they stopped causing errors. It works for me. Hmm :\

Oh and the GetFilterUnit() fixed the removal of the units on the map. Thanks! I guess while I was typing in the right unit, I typed GetEnum, and didn't think twice about it.
 
Level 14
Joined
Jul 26, 2008
Messages
1,009
Ah the simpler one?

Maybe I disabled the trigger for the version of the 11th vampire I uploaded.

Would you like me to change the map and upload it so it's more nonJNGP Friendly? I'll go ahead and do it anyways, see what happens.

(Edit: Still crashes. Try it out, take a look. It's been compiled in WorldEditor regular too this time, and is compatible with it, so I KNOW it's not my compiler.)
 

Attachments

  • Timer404.w3x
    17.6 KB · Views: 97
Last edited:
For some reason, without:
JASS:
        call SetFloatGameState(GAME_STATE_TIME_OF_DAY, 7.10)
It crashes. With it, though, it doesn't. At least for me. I'll do more tests later...

EDIT: I tested it a bit and it has something to do with the actual event itself.
JASS:
    call TriggerRegisterGameStateEvent(gg_trg_Skiptime, GAME_STATE_TIME_OF_DAY, EQUAL, 6.10)

This crash can be worked around by using:
JASS:
    call SetFloatGameState(GAME_STATE_TIME_OF_DAY, 6.11)

I don't know why it crashes without it though. Maybe it is doing some infinite loop or something weird such as that.
 
Level 14
Joined
Jul 26, 2008
Messages
1,009
It is trully a mystery to behold. I could always ask in the Triggers and Scripts forum why this is, but since it's resolved with a simple enough trigger I'm not too worried about.

The combo of that event and that native doesn't seem too unusual. :\ Someone else has likely come across it. Thanks for the help! ^^
 
Level 9
Joined
Nov 4, 2007
Messages
931
Haha, yea there is definitely an infinite loop going on, you can make it slow down just enough to see the game slow down to an incredible degree but just under the amount that would cause it to crash, tried it by using thr Turn off trigger action before chaning game speed, and turning it back on after changing, game slowed down a huge amount but didn't crash.
Edit: Figured it out, this is as rational an explanation I could come up with for this dilemma, OK so you understand that when it registers the time of day to be 6.00, the event will fire off the actions. Now when it fires the action that alters the speed at which the day progresses in the game via call SetTimeOfDayScale(real) it has to take the current time, modify it, then place it back in to motion in the game, and because it puts it back in the game, modified as it is, it still counts as another instance of the game's time of day being at 6.00 hence the event will register it again. Hope this clears it up for you.
 
Last edited:
Status
Not open for further replies.
Top