Jump to content

Photo
- - - - -

Random weather & Dynamic weahter.


  • Please log in to reply
10 replies to this topic
Thread Starter
splatsh
splatsh

    Sergeant

  • Members
  • 123 posts

#1

Posted 26 February 2010 - 21:42

Where do I find any good script with random weather, like random fog, and random rain, and random time. (Everytime I start mission it should not be the same weather & time.)


Where do I find dynamic weather change, example that weather cheange every hour or so... start to rain, more fog, less rain, less fog and so on.

Would nice if there is something like that.

Thanks.

ProfTournesol
ProfTournesol

    Lieutenant Colonel

  • Members
  • 8447 posts
  • LocationParis, France

#2

Posted 26 February 2010 - 22:25

Hi,

that's quite easy, as rain and fog intensity are values between 0 and 1, all you have to do is generate a random value between 0 and 1 thanks to the "random" command, such as :

60 setRain random 1

where "60" is the number of seconds of the transition.

See also setfog and setOvercast.

Then, a very simple script to launch these parameters again every hour for example for dynamic weather.

Thread Starter
splatsh
splatsh

    Sergeant

  • Members
  • 123 posts

#3

Posted 26 February 2010 - 22:33

Yeah, that looks easy, thanks =)

This is what I got in my init.sqf now:

skipTime (random 24);
60 setRain random 1;
60 setFog random 1;

Edited by splatsh, 26 February 2010 - 22:47.


Imutep
Imutep

    Master Gunnery Sergeant

  • Members
  • 1365 posts

#4

Posted 27 February 2010 - 12:05

Clayman wrote a great weather script. Have a look here or download it from here. You can set different parameters like daytime, nighttime and weather type.
Posted Image
Assault Mission Studio - German Mission Editing && Scripting Website

Thread Starter
splatsh
splatsh

    Sergeant

  • Members
  • 123 posts

#5

Posted 27 February 2010 - 13:52

Clayman wrote a great weather script. Have a look here or download it from here. You can set different parameters like daytime, nighttime and weather type.


Thanks, that looks cool and heavy.
How do I use it?
Copy & paste to my init.sqf file?
And how do I run it with diffrent settings?
(My german is not that good, and I did not find any read me.)

I found something....

Is this right?

I have paste this code into my init.sqf file:

[6, 8, 20, "Mixed"] execVM "weather.sqf";

Edited by splatsh, 27 February 2010 - 13:59.


swtx
swtx

    Staff Sergeant

  • Members
  • 266 posts

#6

Posted 28 February 2010 - 06:15

Try this..it's very easy to use and you get some great weather FX's.


http://www.armaholic...age.php?id=7658



:cool::D
Posted Image

hydral1k
hydral1k

    Rookie

  • Members
  • 7 posts

#7

Posted 09 September 2010 - 23:02

Try this..it's very easy to use and you get some great weather FX's.


http://www.armaholic...age.php?id=7658



:cool::D


That script does not work with Arrowhead sadly..

CarlGustaffa
CarlGustaffa

    Captain

  • Members
  • 6397 posts

#8

Posted 09 September 2010 - 23:42

If you do it yourself, the biggest two gotcha's are:
1) The commands setFog and setOvercast can't be used simultaneously. You have to do them "in steps" or wait for one to finish before doing the other.
2) The command setRain will immediately be overrun by whatever the engine thinks is suitable. That makes it hard to get steady rain, light rain at heavy overcast, or heavy rain a low overcast. Luckily setRain can be used whenever you feel like it (while setFog or setOvercast is adjusting), so you can set a quick loop to hold whatever rain level you want.

Fully random weather scripts has never been good to me. I typically need i.e. weather on the nice side, where rain and fog is quite rare. Also I have to this date never found max fog level to be playable at all, which is what most weather scripts tend to use.

Finally, wind can be set using setWind [10,3,true] instead of relying on overcast (which seems to be the normal driving force), where 10 and 3 are the wind vectors.

If you download external script, make sure the mission is playable with whatever extreme values the script allows. Experiment with how bad weather you can allow while still having a playable mission, and put those values in the script as the extreme values. Keep in mind that normally, 50% fog (which is a lot in the game) is far above "normal" levels of fog. Consider a squared (as a minimum) distribution of the randomness, instead of linear chances.
Regards
Carl Gustaffa - left this game due becoming Steam Exclusive :(

BadgerDK
BadgerDK

    Sergeant

  • Members
  • 100 posts

#9

Posted 30 January 2011 - 13:35

Thanks, that looks cool and heavy.
How do I use it?
Copy & paste to my init.sqf file?
And how do I run it with diffrent settings?
(My german is not that good, and I did not find any read me.)

I found something....

Is this right?

I have paste this code into my init.sqf file:

[6, 8, 20, "Mixed"] execVM "weather.sqf";


Doesn't work for me, did you find a fix?
Slow is smooth and smooth is fast.

Clayman
Clayman

    Staff Sergeant

  • Members
  • 217 posts

#10

Posted 30 January 2011 - 15:25

English Version^^

Wetterscript V1.3:
With this script you can create random weather.
There are several optional parameters to adjust the weather settings.



_initial: If set to true, random settings for weather will be generated at mission start. If you want specific weather at the beginn of the mission, and random weather to start later, set this to false. (Default: true)

_startDawn: Determines the daytime when dawn beginns. Value from 0 to 24. (Default: 05:00)

_endDawn: Determines the daytime when dawn ends. Value from 0 to 24. (Default: 07:00)

_nightTime: Determines the daytime when night beginns. Value from 0 to 24. (Default: 20:00)

_weatherType: Here you can select the kind of weather. (Default: "Mixed") Possible values (See header of script for details):
"Good"
"Average"
"Bad"
"Mixed"
"MediumGood"
"MediumBad"
"Custom"


The following parameters are only required for _weatherType "Custom":
_customMinOvercast:
_customMaxOvercast:
You can pass values for min and max overcast, e.g. best and worst possible weather. Values must be between 0 and 1, where 0 is clear sky and 1 is heavy rain / storm.

_customMinFog:
_customMaxFog:
Same as above, only for the fog. 0 is no fog, 1 is thick fog.



There are four different ways to call the script. Examples:
Call without parameter:
0 = [] execVM "randomWeather.sqf"




Call with only one parameter:
0 = [false] execVM "randomWeather.sqf"




Call with five parameters:
0 = [true, 4.5, 6.5, 19.5, "Average"] execVM "randomWeather.sqf";




Call for "Custom" weathertype with nine parameters:
0 = [false, 6, 8, 18, "Custom", [0.4, 0.6], [0.2, 0.5]] execVM "randomWeather.sqf";





And here is the script:
randomWeather.sqf
/********************************************************************************

   randomWeather.sqf

   Script by Clayman

   Version 1.3


   Optional Parameters:

   [<_initial | Bool>, <_startDawn | Number>, <_endDawn | Number>, <_nightTime | Number>, <_weatherType | String>, [<_customMinOvercast | Number>, <_customMaxOvercast | Number>], [<_customMinFog | Number>, <_customMaxFog | Number>]]

   _initial:   Should random weather be set initially.
         If you want specific weather at mission start and the random weather to start later, set this to false.
         If you start script at mission start, set this to true, so random values for starting weather will be used.

   _startDawn:    Sets the time (0-24) when dawn beginns (default: 05:00)
   _endDawn:    Sets the time (0-24) when dawn ends (default: 07:00)
   _nightTime:    Sets the time (0-24) when the night starts (default: 20:00)
   _weatherType:   Sets what kind of weather there will be: (default: "Mixed")

               "Good":
            Clear sky to light clouds
            None to light fog during day and night
            Medium to thick fog during dawn
            No rain

               "Average":
            Cloudy sky
            Light to medium fog during day
            Light fog during night
            Light to medium fog during dawn
            No rain

               "Bad":
            Dark clouds
            Medium to thick fog during day
            Light to medium fog during night
            No fog during heavy rain / storm
            Light rain to storm

               "Mixed":
            All of the above can be possible

               "MediumGood":
            Mix of 'Good' and 'Average' weather types

               "MediumBad":
            Mix of 'Average' and 'Bad' weather types

               "Custom":
            Set values for min and max overcast
            Set values for min and max fog
            Slightly more fog during dawn
            Slightly less fog during night
            No fog during heavy rain / storm

   _customMinOvercast:
   _customMaxOvercast:
         Additional parameters for "Custom" weather.
         Sets the minimum and maximum overcast values (0 = clear sky, 1 = storm)

   _customMinFog:
   _customMaxFog:
         Additional parameters for "Custom" weather.
         Sets the minimum and maximum fog values (0 = no fog, 1 = thick fog)


   Examples:

   No parameters - default settings will be used:

      0 = [] execVM "randomWeather.sqf";

   Only parameter for initial setting:

      0 = [false] execVM "randomWeather.sqf";

   Parameters for preset weather types:

      0 = [true, 4.5, 6.5, 19.5, "Average"] execVM "randomWeather.sqf";

   Parameters for custom weather settings:

      0 = [false, 6, 8, 18, "Custom", [0.4, 0.6], [0.2, 0.5]] execVM "randomWeather.sqf";



   To end the script, set global variable 'CLAY_Weather' to false

*********************************************************************************/




private ["_initial", "_startDawn", "_endDawn", "_nightTime", "_weatherType", "_minOvercast", "_maxOvercast", "_overcastAdd", "_minFog", "_maxFog", "_fogAdd"];

If (count _this > 0) Then
{
   _initial = _this select 0;

   If (count _this > 1) Then
   {
      _startDawn = _this select 1;
      _endDawn = _this select 2;
      _nightTime = _this select 3;
      _weatherType = _this select 4;

      If (_weatherType == "Custom") Then
      {
         _minOvercast = (_this select 5) select 0;
         _maxOvercast = (_this select 5) select 1;
         _overcastAdd = _maxOvercast - _minOvercast;

         _minFog = (_this select 6) select 0;
         _maxFog = (_this select 6) select 1;
         _fogAdd = _maxFog - _minFog;
      };
   };
}
Else
{
   _initial = true;
   _startDawn = 5;
   _endDawn = 7;
   _nightTime = 20;
   _weatherType = "Mixed";
};



CLAY_Weather = true;
private ["_f", "_fog"];

switch (_weatherType) do
{
   case "Good":
   {
      If (_initial) Then
      {
         _o = random 0.35;
         If (dayTime > _startDawn && dayTime < _endDawn) Then
         {
            _f = (0.3 + random 0.5);
         }
         Else
         {
            _f = random 0.3;
         };

         0 setOvercast _o;
         0 setFog _f;
      };

      while {CLAY_Weather} do
      {
         _overcast = random 0.4;
         _change = (180 + random 120);
         _delay = (300 + random 300);

         If (dayTime > _startDawn && dayTime < _endDawn) Then
         {
            _fog = (0.2 + random 0.6);
         }
         Else
         {
            _fog = random 0.3;
         };

         _oChange = _overcast - overcast;
         _oStep = _oChange / 300;

         _fChange = _fog - fog;
         _fStep = _fChange / 300;

         _cStep = _change / 300;

         for "_i" from 0 to _change step _cStep do
         {
            _cStep setOvercast (overcast + _oStep);
            sleep _cStep;
            _cStep setFog (fog + _fStep);
            sleep _cStep;
         };

         sleep _delay;
      };
   };
   case "MediumGood":
   {
      If (_initial) Then
      {
         _o = random 0.6;
         If (dayTime > _startDawn && dayTime < _endDawn) Then
         {
            If (_o < 0.4) Then
            {
               _f = (0.3 + random 0.5);
            }
            Else
            {
               _f = (0.2 + random 0.4);
            };
         }
         Else
         {
            _f = random 0.4;
         };

         0 setOvercast _o;
         0 setFog _f;
      };

      while {CLAY_Weather} do
      {
         _overcast = random 0.6;
         _change = (180 + random 120);
         _delay = (300 + random 300);

         If (dayTime > _startDawn && dayTime < _endDawn) Then
         {
            If (_o < 0.4) Then
            {
               _f = (0.3 + random 0.5);
            }
            Else
            {
               _f = (0.2 + random 0.4);
            };
         }
         Else
         {
            _fog = random 0.5;
         };

         _oChange = _overcast - overcast;
         _oStep = _oChange / 300;

         _fChange = _fog - fog;
         _fStep = _fChange / 300;

         _cStep = _change / 300;

         for "_i" from 0 to _change step _cStep do
         {
            _cStep setOvercast (overcast + _oStep);
            sleep _cStep;
            _cStep setFog (fog + _fStep);
            sleep _cStep;
         };

         sleep _delay;
      };
   };
   case "Average":
   {
      If (_initial) Then
      {
         _o = (0.3 + random 0.3);
         If (dayTime > _startDawn && dayTime < _endDawn) Then
         {
            _f = (0.2 + random 0.4);
         }
         Else
         {
            _f = random 0.4;
         };

         0 setOvercast _o;
         0 setFog _f;
      };

      while {CLAY_Weather} do
      {
         _overcast = (0.3 + random 0.3);
         _change = (180 + random 120);
         _delay = (300 + random 300);

         If (dayTime > _startDawn && dayTime < _endDawn) Then
         {
            _fog = (0.2 + random 0.5);
         }
         Else
         {
            If (dayTime < _nightTime) Then
            {
               _fog = random 0.4;
               If (_overcast > 0.5) Then {_fog = (0.2 + random 0.4)};
            }
            Else
            {
               _fog = random 0.3;
            };
         };

         _oChange = _overcast - overcast;
         _oStep = _oChange / 300;

         _fChange = _fog - fog;
         _fStep = _fChange / 300;

         _cStep = _change / 300;

         for "_i" from 0 to _change step _cStep do
         {
            _cStep setOvercast (overcast + _oStep);
            sleep _cStep;
            _cStep setFog (fog + _fStep);
            sleep _cStep;
         };

         sleep _delay;
      };
   };
   case "MediumBad":
   {
      If (_initial) Then
      {
         _o = (0.4 + random 0.6);
         _f = (0.2 + random 0.4);
         If (_o > 0.9) Then {_f = random 0.3};

         0 setOvercast _o;
         0 setFog _f;
      };

      while {CLAY_Weather} do
      {
         _overcast = (0.4 + random 0.6);
         _change = (180 + random 120);
         _delay = (300 + random 300);

         If (dayTime > _endDawn && dayTime < _nightTime) Then
         {
            _fog = (0.35 + random 0.35);
            If (_overcast > 0.8) Then {_fog = (0.3 + random 0.25)};
            If (_overcast > 0.9) Then {_fog = random 0.35};
         }
         Else
         {
            _fog = (0.3 + random 0.5);
            If (_overcast > 0.9) Then {_fog = random 0.2};
         };

         _oChange = _overcast - overcast;
         _oStep = _oChange / 300;

         _fChange = _fog - fog;
         _fStep = _fChange / 300;

         _cStep = _change / 300;

         for "_i" from 0 to _change step _cStep do
         {
            _cStep setOvercast (overcast + _oStep);
            sleep _cStep;
            _cStep setFog (fog + _fStep);
            sleep _cStep;
         };

         sleep _delay;
      };
   };
   case "Bad":
   {
      If (_initial) Then
      {
         _o = (0.65 + random 0.35);
         _f = (0.3 + random 0.4);
         If (_o > 0.9) Then {_f = random 0.3};

         0 setOvercast _o;
         0 setFog _f;
      };

      while {CLAY_Weather} do
      {
         _overcast = (0.6 + random 0.4);
         _change = (180 + random 120);
         _delay = (300 + random 300);

         If (dayTime > _endDawn && dayTime < _nightTime) Then
         {
            _fog = (0.4 + random 0.4);
            If (_overcast > 0.8) Then {_fog = (0.3 + random 0.2)};
            If (_overcast > 0.9) Then {_fog = random 0.3};
         }
         Else
         {
            _fog = (0.2 + random 0.3);
            If (_overcast > 0.9) Then {_fog = random 0.2};
         };

         _oChange = _overcast - overcast;
         _oStep = _oChange / 300;

         _fChange = _fog - fog;
         _fStep = _fChange / 300;

         _cStep = _change / 300;

         for "_i" from 0 to _change step _cStep do
         {
            _cStep setOvercast (overcast + _oStep);
            sleep _cStep;
            _cStep setFog (fog + _fStep);
            sleep _cStep;
         };

         sleep _delay;
      };
   };
   case "Mixed":
   {
      If (_initial) Then
      {
         _o  = random 1;
         If (dayTime > _startDawn && dayTime < _endDawn) Then
         {
            _f = (0.2 + random 0.3);
            If (_o > 0.4) Then {_f = (0.2 + random 0.4)};
            If (_o > 0.6) Then {_f = (0.3 + random 0.3)};
            If (_o > 0.8) Then {_f = (0.4 + random 0.3)};
            If (_o > 0.9) Then {_f = random 0.3};
         }
         Else
         {
            If (dayTime < _nightTime) Then
            {
               _f = random 0.2;
               If (_o > 0.5) Then {_f = (0.2 + random 0.2)};
               If (_o > 0.7) Then {_f = (0.3 + random 0.3)};
               If (_o > 0.9) Then {_f = random 0.3};
            }
            Else
            {
               _f = random 0.2;
               If (_o > 0.5) Then {_f = random 0.3};
               If (_o > 0.7) Then {_f = random 0.4};
            };
         };

         0 setOvercast _o;
         0 setFog _f;
      };

      while {CLAY_Weather} do
      {
         _overcast = random 1;
         _change = (180 + random 120);
         _delay = (300 + random 300);
   
         If (dayTime > _startDawn && dayTime < _endDawn) Then
         {
            _fog = (0.2 + random 0.4);
            If (_overcast > 0.4) Then {_fog = (0.2 + random 0.4)};
            If (_overcast > 0.6) Then {_fog = (0.3 + random 0.3)};
            If (_overcast > 0.8) Then {_fog = (0.4 + random 0.3)};
            If (_overcast > 0.9) Then {_fog = random 0.3};
         }
         Else
         {
            If (dayTime < _nightTime) Then
            {
               _fog = random 0.2;
               If (_overcast > 0.5) Then {_fog = (0.2 + random 0.2)};
               If (_overcast > 0.7) Then {_fog = (0.3 + random 0.3)};
               If (_overcast > 0.9) Then {_fog = random 0.3};
            }
            Else
            {
               _fog = random 0.2;
               If (_overcast > 0.5) Then {_fog = random 0.3};
               If (_overcast > 0.7) Then {_fog = random 0.4};
            };
         };

         _oChange = _overcast - overcast;
         _oStep = _oChange / 300;

         _fChange = _fog - fog;
         _fStep = _fChange / 300;

         _cStep = _change / 300;

         for "_i" from 0 to _change step _cStep do
         {
            _cStep setOvercast (overcast + _oStep);
            sleep _cStep;
            _cStep setFog (fog + _fStep);
            sleep _cStep;
         };

         sleep _delay;
      };
   };
   case "Custom":
   {
      If (_initial) Then
      {
         _o  = (_minOvercast + random _overcastAdd);
         If (dayTime > _startDawn && dayTime < _endDawn) Then
         {
            _f = (_minFog + random _fogAdd);
            If (_o > 0.6) Then {_f = _f + random 0.1};
            If (_o > 0.8) Then {_f = _f + random 0.2};
            If (_o > 0.9) Then {_f = _minFog};
         }
         Else
         {
            If (dayTime < _nightTime) Then
            {
               _f = (_minFog + random _fogAdd);
               If (_o > 0.9) Then {_f = _minFog};
            }
            Else
            {
               _f = (_minFog + random _fogAdd);
               If (_o < 0.4) Then {_f = _f - random 0.2};
               If (_o > 0.9) Then {_f = _minFog};
            };
         };

         0 setOvercast _o;
         0 setFog _f;
      };

      while {CLAY_Weather} do
      {
         _overcast = (_minOvercast + random _overcastAdd);
         _change = (180 + random 120);
         _delay = (300 + random 300);
   
         If (dayTime > _startDawn && dayTime < _endDawn) Then
         {
            _fog = (_minFog + random _fogAdd);
            If (_overcast > 0.6) Then {_fog = _fog + random 0.1};
            If (_overcast > 0.8) Then {_fog = _fog + random 0.2};
            If (_overcast > 0.9) Then {_fog = _minFog};
         }
         Else
         {
            If (dayTime < _nightTime) Then
            {
               _fog = (_minFog + random _fogAdd);
            }
            Else
            {
               _fog = (_minFog + random _fogAdd);
               If (_overcast < 0.4) Then {_fog = _fog - random 0.2};
               If (_overcast > 0.9) Then {_fog = _minFog};
            };
         };

         _oChange = _overcast - overcast;
         _oStep = _oChange / 300;

         _fChange = _fog - fog;
         _fStep = _fChange / 300;

         _cStep = _change / 300;

         for "_i" from 0 to _change step _cStep do
         {
            _cStep setOvercast (overcast + _oStep);
            sleep _cStep;
            _cStep setFog (fog + _fStep);
            sleep _cStep;
         };

         sleep _delay;
      };
   };
};


BadgerDK
BadgerDK

    Sergeant

  • Members
  • 100 posts

#11

Posted 30 January 2011 - 16:06

That's fantastic! Thank you very much. This gives so much to immersion I don't know why anyone would not use it.

I guess this is related to the engine and its inner workings, but shouldn't it become a lot darker when i rains? I mean really dark?

Thanks again, two thumbs up!
Slow is smooth and smooth is fast.