Scripting Handout 4
Change time of day and weather

;WeatherMachine.sqs
;this script changes the time of day and the weather of a scenario
;it takes in two arguments
;_timeofday:  the time, in hours, from 0 to 24
;_weatherlevel: a number from 0 to 100. 0 is dismal, 100 is sunny

_timeofday = _this select 0
_weatherlevel = _this select 1

;change time of day
skiptime _timeofday


;change weather
0 setovercast (_weatherlevel / 100)

;Tone down fog a bit
_fogreducer = 0.75
_foglevel = ( (_weatherlevel * _fogreducer) / 100)
0 setfog _foglevel / 100

;Rain only occurs if weather is worse than 70 percent
;modify the scale so rain level is a value of 0 to 100
_rainlevel = _weatherlevel - 70
?_rainlevel < 0:_rainlevel = 0
_rainlevel = (_rainlevel / 30)

0 setrain _rainlevel

exit


