• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Solved] Question about "SetTimeOfDayScalePercent" and etc.

Status
Not open for further replies.
Level 11
Joined
Oct 11, 2012
Messages
711
Question 1:
What does the number "50" mean in the following call?
JASS:
call SetTimeOfDayScaleBJ(50.)

Question 2:
If I set the number to "50", and I want to set a periodic timer that starts to run at the beginning of the day(for example, at 6 of game time) and to end at night (for example, at 18 of game time), how should I set the "timeout" of the timer?

JASS:
native TimerStart           takes timer whichTimer, real timeout, boolean periodic, code handlerFunc returns nothing

Question 3:
Does the game speed effect the "timeout" setting as mentioned in Question 2?

Thanks a lot.

I do not want to check the time in game by using "GetTimeOfDay" every 5 sec. LOL

Edit: the reason I am asking these questions is that I want to make a hero whose stats double at night.

Edit: May I use something like this?

JASS:
call TriggerRegisterGameStateEvent(gg_trg_Skiptime, GAME_STATE_TIME_OF_DAY, EQUAL, 6.00)
 
Level 13
Joined
Mar 24, 2013
Messages
1,105
If you want to do it the hard way, you can look at the gameplay constants and figure out how often night occurswith some basic math. Then use a periodic trigger for the length of time to change a Boolean of is night from false to true or true to false, then for your night guy, if boolean is true, make him have extra stats or what have you.

Lets just say every 60 seconds it turns to night, so every 60 seconds of game time you switch the Boolean and make necessary changes to your unit.

Sorry I haven't fooled around with times of day, so I can't be more helpful. There is definitely a better way, but incase you don't find it, this makeshift way could work... I guess.
 
Question 1:
50 in SetTimeOfDayScalePercentBJ will make time pass 50% as fast as the standard time. You can reset the scale by putting in 100 into that function (or 1 into the native equivalent).

Question 2:
Yes, you can use:
JASS:
call TriggerRegisterGameStateEvent(gg_trg_Skiptime, GAME_STATE_TIME_OF_DAY, EQUAL, 6.00)
To register when it hits 6.00 A.M. You can use a timer, but if I were you I would use that event set to 18.00. If you use the timeout method, you would have to find out how many seconds are in one game "hour". 18 - 6 = change in hours (12), then you would do 12 * time in hour * GetTimeOfDayScale().

At standard time scale, it is 20 seconds per game hour. At 50% time scale, it is 40 seconds per game hour (tested). So you can do something like this:
JASS:
function HoursTimeout takes real hours returns real
    return hours * (1. / GetTimeOfDayScale()) * 20
endfunction

// input the number of hours (game-time) you want to wait and
// it will return the timer timeout equivalent

Question 3:
Game speed doesn't appear to affect the time scale from my tests.
 
Level 11
Joined
Oct 11, 2012
Messages
711
If you want to do it the hard way, you can look at the gameplay constants and figure out how often night occurswith some basic math. Then use a periodic trigger for the length of time to change a Boolean of is night from false to true or true to false, then for your night guy, if boolean is true, make him have extra stats or what have you.

Lets just say every 60 seconds it turns to night, so every 60 seconds of game time you switch the Boolean and make necessary changes to your unit.

Sorry I haven't fooled around with times of day, so I can't be more helpful. There is definitely a better way, but incase you don't find it, this makeshift way could work... I guess.

Thanks for the method, pOke.

Question 1:
50 in SetTimeOfDayScalePercentBJ will make time pass 50% as fast as the standard time. You can reset the scale by putting in 100 into that function (or 1 into the native equivalent).

Question 2:
Yes, you can use:
JASS:
call TriggerRegisterGameStateEvent(gg_trg_Skiptime, GAME_STATE_TIME_OF_DAY, EQUAL, 6.00)
To register when it hits 6.00 A.M. You can use a timer, but if I were you I would use that event set to 18.00. If you use the timeout method, you would have to find out how many seconds are in one game "hour". 18 - 6 = change in hours (12), then you would do 12 * time in hour * GetTimeOfDayScale().

At standard time scale, it is 20 seconds per game hour. At 50% time scale, it is 40 seconds per game hour (tested). So you can do something like this:
JASS:
function HoursTimeout takes real hours returns real
    return hours * (1. / GetTimeOfDayScale()) * 20
endfunction

// input the number of hours (game-time) you want to wait and
// it will return the timer timeout equivalent

Question 3:
Game speed doesn't appear to affect the time scale from my tests.

Thanks a lot, PurgeandFire. Your answer is comprehensive and detailed. +Rep!!
 
Status
Not open for further replies.
Top