Home   Help Search Login Register  

Author Topic: Daylight?  (Read 2697 times)

0 Members and 1 Guest are viewing this topic.

olseric

  • Guest
Daylight?
« 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!

Code: [Select]
;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!"}

Offline Kuro

  • Former Staff
  • ****
  • 2./FschJgBtl 251 Green Devils
    • VBS2 Mission Download Site
Re:Daylight?
« Reply #1 on: 16 Aug 2004, 03:29:53 »
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


olseric

  • Guest
Re:Daylight?
« Reply #2 on: 07 Sep 2004, 13:13:09 »
Anytime. :)

Nulear_Man

  • Guest
Re:Daylight?
« Reply #3 on: 08 Sep 2004, 23:55:03 »
to find out if its day light or not use this

Code: [Select]
_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
« Last Edit: 09 Sep 2004, 00:01:26 by Nuclear_Man »

olseric

  • Guest
Re:Daylight?
« Reply #4 on: 09 Sep 2004, 08:40:36 »
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.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:Daylight?
« Reply #5 on: 13 Sep 2005, 08:01:06 »
also, missionstart is multiplayer compatible only, doesn't work in single player mode...

bored_onion

  • Guest
Re:Daylight?
« Reply #6 on: 13 Sep 2005, 19:14:25 »
yes, bedges. your daylight finding troubles still persist.  :P i know youve been chasing this one for a while now.
« Last Edit: 13 Sep 2005, 19:15:36 by bored_onion »

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:Daylight?
« Reply #7 on: 13 Sep 2005, 23:00:52 »
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
« Last Edit: 13 Sep 2005, 23:04:43 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline Morglor9

  • Members
  • *
Re:Daylight?
« Reply #8 on: 19 Sep 2005, 03:47:29 »
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  :).
Cymbaline