OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Resources Beta Testing & Submission => Topic started by: olseric on 14 Aug 2004, 13:35:53
-
I finally got mad that there isn't a simple way to find out whether it is daylight or not in OFP, so, here it is. :)
Basically, this baby will determine whether it's past sunrise/sunset or not.
I'm sure it has 1000 uses, but I made it because I have a SAR mission that I need the pilot to be rescued and he needs to launch a flare at night, or smoke in day.
Some of the days may need to be tweaked so that it fits OFP better, but assuming my calculations are right, 6AM/6PM Sunrise/Sunset on the Equinoxes with 2:30 total (1:15 each side of sunrise/sunset) during the Solstaces.
Enjoy!
;Header Information
_days = 0
_month = missionStart select 2
_day = missionStart select 3
_hour = daytime
_month = _month - 1
;Determine Day of the Year
#MonthLoop
?(_month == 0):goto "LoopEnd"
_dayssofar = _days
;30 days has SEP, APR, JUN, & NOV :)
?(_month == 2):_days = _days + 28
?(_month == 9) OR (_month == 4) OR (_month == 6) OR (_month == 11):_days = _days + 30
?(_dayssofar == _days):_days = _days + 31
_month = _month - 1
goto "MonthLoop"
#LoopEnd
;Day of the Year Calculation
_dayofyear = _days + _day
;Calculate days from an equinox
_equinox = 0
?(_dayofyear < 80):_equinox = _dayofyear - 80
?(_dayofyear > 80):_equinox = _dayofyear - 80
?(_dayofyear > 172):_equinox = 265 - _dayofyear
?(_dayofyear > 265):_equinox = 265 - _dayofyear
?(_dayofyear > 356):_equinox = _dayofyear - 445
;Calculate Sunrise/Sunset
_sunrise = ((_equinox * -.013889) + 6)
_sunset = ((_equinox * .013889) + 18)
;Change stuff below to suit...examples listed.
if (_hour < _sunrise) OR (_hour > _sunset) then {hint "It's Dark!"} else {hint "It's Light!"}
-
Hallo,
no joke, but i am really searching such a script for my mission. I ended up with a rough estimation. But that was rather unstatisfying.
Many Thanks
-
Anytime. :)
-
to find out if its day light or not use this
_DayTime = _daytime
? Daytime <= 24 and Daytime >= 18 : _Night = True
? Daytime < 18 and Daytime >= 6 : _Night = False
? Daytime < 6 and Daytime >= 0 : _Night = True
See 3 lines
but its not exact like the one above
anyway if you need a short one then there it is, if you dont mind a long one then use the one above
-
That's a good idea Nuke, but the problem is...
The sunrise and sunset times vary by an hour and fifteen each way between the solstaces. Thus, on March 22nd, your idea will work great. But on Jun 22nd, or Dec 22nd, it won't.
-
also, missionstart is multiplayer compatible only, doesn't work in single player mode...
-
yes, bedges. your daylight finding troubles still persist. :P i know youve been chasing this one for a while now.
-
i dont really see the need for an annual dalylight calculation here
most missions run for a couple of days at most
and therefore a
tx_sunrise = 5.6
tx_sunset = 18.6
or whatever value is consistent for the actual mission sunrise sunset times
eg
if((daytime > tx_sunrise)&&(daytime < tx_sunset))then {hint "Its daylight"}else{hint "Its dark"}
in addition to this, monitoring any skiptime values or using the "time" function you will be able to accurately track whether its dark or light.
Reference the Flare problem.
Fire it whether its dark or light, you wont be able to see it in daylight anyway
me personally, i create all my missions to start at midnight and then use the param1 values to skiptime to whatever daytime setting the admin selects. Makes any daytime calcs much easier
-
i think the reason that's it does annual calculation is so that the editor doesn't have to figure all of that stuff out himself, and can devote more time to making his mission more immersive :).