Home   Help Search Login Register  

Author Topic: setovercast problem...  (Read 837 times)

0 Members and 2 Guests are viewing this topic.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
setovercast problem...
« on: 12 Oct 2005, 18:38:59 »
as in it doesn't seem to work both ways. i can get the weather to go from sunny to thunderstorm no problem, but asking it to go back to sunny doesn't appear to work.

anyone have experience of this 'feature'?

Offline nominesine

  • Former Staff
  • ****
  • I'm NOT back!
    • The IKB Forum
Re:setovercast problem...
« Reply #1 on: 12 Oct 2005, 18:44:54 »
I have had similar experinces with setOvercast and setFog. I can make them change both ways (from sunny to clouded and vice versa, from clear to foggy and vice versa), but only once in every mission.
OFPEC | Intel Depot
RETARDED Ooops... Retired!

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:setovercast problem...
« Reply #2 on: 13 Oct 2005, 22:09:40 »
Strange.  In Abandoned Armies I cycle overcast and fog.  It works for several hours - I am begining to suspect that it stops eventually (>~ 10 hours or so) but I have not checked specifically.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:setovercast problem...
« Reply #3 on: 13 Oct 2005, 22:43:29 »
hmmm. now see i was sort of waiting for your response, having seen the fog used with such control in that very mission (THEE mission we should call it ;) ). the fog i have no problem with. it's the sky. i'll do some more playing around, but i suspect it may have something to do with initial settings... no idea.  :-\


Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:setovercast problem...
« Reply #4 on: 14 Oct 2005, 00:00:44 »
You are too kind. :-*

I have initial values of:
minimum fog; and
minimum overcast.  

This is so I can debug it all in broad daylight.  The code I use for controlling the overcast and rain is shown below (the code for the fog is similar).  Note there are a few complications:

1. DeBug is a global variable that I set to true when debugging but is set to false in the released versions.

2. weatherNdFog is a global variable that I set to false when I want the script to stop (This is when the mission is complete and the final scene is to play)

3. I have set it so the maximum intensity of overcast reduces as the smallest army gets smaller - this is so the weather gets better as the player makes progress.  (NB East_loons and West_loons are arrays that contain the enemy soldiers)

4.  I have also set it so there is minimum overcast and minimum fog (trust me the fog script does this also) at 16:00.  This is when the sun is setting so it should be quite pretty. :)

5. RainLevel is deliberately a global variable so I can use it elsewhere (in the script that deal with the wolves in fact)

Note that OFP will move the weather towards the settings that you set as forecast.  That is why I re-set everything every 60 seconds

Code: [Select]
;weather.sqs by THObson

; After a delay the overcast level follows the cycle set by  y = 0.5*(Max + Min) + 0.5*(Max - Min) * sin(k*time)
; In other words it cycles between Min and Max with a frequency given by k

; use sin so the overcast level increases from the initial level (if it not already at maximum)

;Note also that the maximum level of overcast falls dependent on the number of enemy loons still alive.
;This should result in the weather being less bad towards the end of the misison.
; The method used is something that approximates to:  
;            current max level = Smallest Max + (Initial Max - Smallest Max) * Loon count/Initial Loon count


; _maxlevel is the maximum level of overcast in a cycle
; _minlevel is the minmum level of overcast in a cycle
; _startlevel is the starting overcast level (in the range 0 to 1)
; _delay is the time before any change begins (in hours)
; _period is the time for one complete cycle of overcast level (in hours)


;_delay is chosen randomly; _period is chosen so that overcast is a minimum at around 16:00

;RainLevel is a global variable so that other scripts can check the level of rain


_maxlevel = 1
_minlevel = 0.25
_startlevel = 1
_delay = 1.5 + random 0.25
_period = (9.75-_delay)/3.5



; error trapping
if (_maxlevel > 1) then {_maxlevel = 1}
if (_minlevel < 0) then {_minlevel = 0}
if (_startlevel > _maxlevel) then {_startlevel = _maxlevel}
if (_startlevel < _minlevel) then {_startlevel = _minlevel}


_startdegrees = asin ((2*_startlevel - (_maxlevel + _minlevel))/(_maxlevel - _minlevel))


0 setOvercast _startlevel
RainLevel = 0
if (_startlevel > 0.7) then {0 setRain 1;RainLevel = 1}

~ random 7

_i = 0
#Wait

~60
if not weatherNdFog then {exit}
; Keep re-setting the overcast and rain level during the initial wait
60 setOvercast _startlevel
if (_startlevel > 0.7) then {60 setRain 1}
_i = _i + 1
if (_i < _delay*60) then {goto"Wait"}
 
;destroy variables no longer needed
_startlevel = nil
_delay = nil

;Now start cycling the weather

;The main loop is a 60 second loop:
;The number of degrees advaced in 60 seconds = 360/(_period*60)
;                                            = 6/_period

_currentMax = _maxlevel
_i = 0
#loop
~ 60
if not weatherNdFog then {exit}
_i = _i + 1

_overcast = (0.5*(_currentMax + _minlevel) + 0.5*(_currentMax - _minlevel) * sin(_startdegrees + _i*6/_period))
60 setOvercast _overcast
RainLevel = 0
;if (_overcast >= 0.9) then {RainLevel = 0.5;60 setRain RainLevel}
if (_overcast >= 0.7) then {RainLevel = 0.25}
if (_overcast >= 0.8) then {RainLevel = 0.5}
60 setRain RainLevel

if DeBug then {player sidechat format["overcast level = %1; max. level = %2  rain level = %3",_overcast,_currentMax,RainLevel]}

if ((_i % 5) > 0) then {goto"loop"}

if ({alive _x} count East_loons > {alive _x} count West_loons) then {_currentMax = 0.80 + (_maxlevel - 0.80)*({alive _x} count West_loons)/250} else {_currentMax = 0.80 + (_maxlevel - 0.80)*({alive _x} count East_loons)/250}

if (_currentMax > _maxlevel) then {_currentMax = _maxlevel}
if (_currentMax < _minlevel) then {_currentMax = _minlevel}

goto"loop"

« Last Edit: 14 Oct 2005, 00:06:40 by THobson »

Offline rado1265

  • Members
  • *
Re:setovercast problem...
« Reply #5 on: 14 Oct 2005, 18:53:08 »
Bah, those academics! ;D

I'm also working on a mission, where I want the weather to change more than once during the mission, so I worked on it, but I couldn't find the solution.  Then I stumbled on discovery, that some delay must be betwen the weather cycles, for next cycle to start.

You can help yourself with the little script I made for my mission, you can freely modify him to your likings of course.

The weather changing in this script is random, so if you want a specific change, there should be no problem, the key is a delay between the cycles.
« Last Edit: 14 Oct 2005, 20:30:37 by karantan »

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:setovercast problem...
« Reply #6 on: 14 Oct 2005, 19:14:54 »
cool, i shall give this a go :)

Offline rado1265

  • Members
  • *
Re:setovercast problem...
« Reply #7 on: 14 Oct 2005, 20:33:22 »
bedges, you may figure out, that the script doesn't work.  That's because the fog cycle must be infont weather cycle.   ???

EDIT: I've also add a time between the cycles, because I have a sudden fear, that maybe only the first cycle is implemented.

Anyway, experiment with it (as I must obviously, but I'm more in the mission now, this can wait), and here's new script, that should work.
« Last Edit: 14 Oct 2005, 22:05:36 by karantan »

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:setovercast problem...
« Reply #8 on: 17 Oct 2005, 20:59:19 »
right, well i've done some research and have discovered flashpoint has a problem doing the weather all at once. to that in a moment...

@karantan - thanks for the script. if i may humbly make some suggestions... ;)

you call the script using [time for weather to change, delay until the next change] exec "weather.sqs". that's fine. however, in the script you don't rely on time exactly, rather using an incrementing counter to decide how long the change takes and what the delay is.

a better way is as follows -

Code: [Select]
_cycle = _this select 0
_delay = _this select 1

#loop
_limit = _time

_cycle setFog random 1
~0.1
_cycle SetOvercast random 1

@(_time >= (_limit + _delay))
goto "loop"

that way the loop becomes time-based rather than counter-based, which is how the weather works.

anyway, i set up a test missionette with two repeating triggers. one trigger set fog, overcast and rain to 1 instantly. the other set them all to 0 instantly. they both worked, repeatedly, and instantly.

however, when i introduced a time-delay of 30 seconds, only the overcast would become active. no fog, no rain. i suspect in the case of rain, overcast has to be at least 0.7...

so then i activated the 'bad weather' trigger again, and lo, the rain would start pouring. the fog would still not get to 1 though, staying at what looks like around 0.75...

bearing in mind that the weather moves towards the forecast settings, that explains the fog i suppose.

the 'good weather' trigger works fine, with overcast, fog and rain all being set perfectly over the 30 seconds.

the script above works just fine, and yet it needs another fog command afterwards to get the fog right up to 1, and it begins receding almost immediately - due to the forecast.

so, in summary, full control of the weather requires repetition of the commands, staggered over time, in a loop to keep them at a constant level away from the forecast values - which i think is pretty much exactly what THobson explained earlier...  ::)
« Last Edit: 17 Oct 2005, 21:03:11 by bedges »

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:setovercast problem...
« Reply #9 on: 18 Oct 2005, 10:46:48 »
Rain does require a minimum overcast.
Plenty of reviewed ArmA missions for you to play

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:setovercast problem...
« Reply #10 on: 18 Oct 2005, 15:53:26 »
0.7 if I recall correctly

Offline rado1265

  • Members
  • *
Re:setovercast problem...
« Reply #11 on: 18 Oct 2005, 16:34:34 »
It now works just fine?  Great!  Thanks, mate. :D

Quote
0.7 if I recall correctly

And that's the information I just need, because I want as wider range of weather change as possible in my mission, but with no rain; it's a winter mission.