Jump to content
Sign in to follow this  
tortuosit

Dynamic weather script and addon: tort_DynamicWeather

Recommended Posts

Plagued by bugs. Something (and its not my script or another addon) always sets wind to values I didn't set. My impression is that ArmA engine lets wind level return to overcast level. If I say "10 setwindstr 1" wind climbs up to 1 and immediately turns to exactly the currently measured overcast level, wtf. Wind is completely weird and tends to abruptly switch to overcast value. Resign for today. Needs some proper investigation.

Edited by tortuosit

Share this post


Link to post
Share on other sites

The only way to force set wind reliably is to execute "setWind[x, y, true]" in a loop.

I have been toying around with setWind a while ago, but discarded my outcomes:

[] spawn {
WindSimulationRunning = true;
// Source: https://weatherspark.com/averages/32194/Lemnos-Limnos-North-Aegean-Islands-Greece
_AB_Wind_Speed_Max = [[8.8, 5.5], [8.8, 5], [8.6, 4.8], [7.6, 3.4], [7.0, 3.0], [7.1, 3.0], [7.5, 3.1], [8.0, 3.2], [7.6, 3.5], [7.8, 4.6], [7.9, 5.0], [8.2, 5.5]];
_AB_Wind_Speed_Mean = [4.8, 4.9, 4.6, 4.1, 3.5, 3.5, 4.3, 4.4, 4.1, 4.5, 4.5, 5.0];
_AB_Wind_Speed_Min = [[0.2, 5.0], [0.1, 5.0], [0.2, 4.3], [0.0, 3.0], [0.0, 2.1], [0.0, 2.0], [0.1, 3.1], [0.3, 3.1], [0.0, 3.6], [0.0, 4.2], [0.1, 5.0], [0.2, 5.5]];
_AB_Wind_Direction_Probabilities = [[0.06, 0.32, 0.05, 0.04, 0.15, 0.06, 0.02, 0.02], // January
                                           [0.08, 0.32, 0.04, 0.04, 0.18, 0.06, 0.02, 0.02], // February
                                           [0.09, 0.30, 0.04, 0.04, 0.20, 0.06, 0.02, 0.03], // March
                                           [0.10, 0.25, 0.03, 0.04, 0.22, 0.06, 0.02, 0.04], // April
                                           [0.18, 0.25, 0.03, 0.04, 0.18, 0.04, 0.01, 0.05], // May
                                           [0.25, 0.25, 0.03, 0.03, 0.15, 0.03, 0.00, 0.08], // June
                                           [0.32, 0.30, 0.02, 0.02, 0.10, 0.01, 0.00, 0.09], // July
                                           [0.28, 0.35, 0.02, 0.01, 0.08, 0.01, 0.00, 0.08], // August
                                           [0.20, 0.37, 0.03, 0.01, 0.11, 0.01, 0.01, 0.05], // September
                                           [0.10, 0.39, 0.04, 0.02, 0.15, 0.02, 0.01, 0.03], // October
                                           [0.08, 0.38, 0.06, 0.04, 0.19, 0.03, 0.02, 0.02], // November
                                           [0.06, 0.37, 0.05, 0.03, 0.18, 0.04, 0.02, 0.02]];// December

_PI = 3.14159265;
_c1 = 0.2 + random 0.2;
_c2 = 0.3 + random 0.2;
_c3 = 0.5 + random 0.2;
_c4 = 0.7 + random 0.2;

_month = date select 1;
_windDirectionProbabilities = _AB_Wind_Direction_Probabilities select (_month - 1);
_windDirection = 270;
_random = random 1;
for "_i" from 0 to 7 do {
	if (_random < (_windDirectionProbabilities select _i)) exitWith {
		_windDirection = 45 * _i;
	};
};
_windDirection = _windDirection + (random 22.5) - (random 22.5);

_min = _AB_Wind_Speed_Min select (_month - 1);
_min = (_min select 0) + (random (_min select 1)) - (random (_min select 1));
_min = 0 max _min;
_max = _AB_Wind_Speed_Max select (_month - 1);
_max = (_max select 0) + (random (_max select 1)) - (random (_max select 1));
_max = 0 max _max;

systemChat format["%1, %2, %3", _min, _max, _windDirection];
_windSpeed = vectorMagnitude wind;
for "_i" from 0 to 10 do {
	hintSilent format["%1, %2, %3", _windSpeed, vectorMagnitude wind, abs(_windSpeed - (vectorMagnitude wind))];
	_x = time * 180 / _PI;
	_ratio = 0 max ((1 + _c1 * sin(_x/1.5) + _c2 * sin(_x/3) + _c3 * sin(_x/12) + _c4 * sin(_x/18)) / (1 + _c1 + _c2 + _c3 + _c4));
	_windSpeed = _min + (_max - _min) * _ratio;
	setWind [-1 * sin(_windDirection) * _windSpeed, -1 * cos(_windDirection) * _windSpeed, true];
	sleep 1;
};
WindSimulationRunning = false;
};

Edited by Ruthberg

Share this post


Link to post
Share on other sites

Thanks Ruthberg; I just changed from setwind array to setwindstr because of laziness - values [0-1] are easier to handle than vector maths, which I learned >20 yrs. ago. Your code will remind me, thanks for this. Same as setwindstr, setwind[,,false] behaves weird and does abruptly change to whatever wind level... A lot is broken when it comes to weather.

Share this post


Link to post
Share on other sites
Cool, so your resignation is gone hopefully? Looking forward to the update :)

Yes no more resignation :D, but RL, wedding anniversary... also want to do some proper testing plus complete rewrite of the wind part... not too difficult but however, update probably end of week/weekend.

So what I always saw coming, but didn't want to touch because script was not built for this (and became über complicated)...: it's having every weather aspect (overcast|fog|wind|rain) in an independent thread. Some major rework is necessary.

Share this post


Link to post
Share on other sites

Thx, anniversary is tomorrow :)

setwind[] is not as difficult as I thought, only simple trigonomy, no new maths course necessary for me :D. A first test of new cycling wind thread worked fine. Plus it's pretty good that setwind[] changes wind direction/strength softly and not abrupt. Also it is very static, i.e. all changes have to be done by script. Internally I still use wind strength 0 to 1; but with 0=0m/s and 1=35 m/s which is ~12 on the beaufort scale. So there's more wind possible than with the "n setwind x" command. Tbh, setwind has no limts, but 3d objects go crazy then.

- Wind and rain code will be new and simple and maybe unbalanced first. But control can be precise now.

- Also I want to have all initial arrays (for script start, for random arrays) adaptive with 4 or 8 arguments. 4 args = fixed values, 8 args = [min, max, min, max ...].

- Plus I want to allow the user to create his own presets which appear in the mods menu via some include technique.

- Plus give more control over wind direction etc. via menu, which is interesting for the snipers.

The random events, this is not yet clear for ppl, will be cool. They already are, but not too clear and documented. In words: You define overall weather, and you can optionally define a set of <n> specific weather situations (exceptions) which can occur, according to the probability of random events.

Edited by tortuosit

Share this post


Link to post
Share on other sites

Need to think more about it. The concept as mentioned above:

"You define overall weather, and you can optionally define a set of <n> specific weather situations (exceptions) which can occur, according to the probability of random events."

does not work well with independent threads for wind|rain (and fog following later I guess). Crisis, Chaos!111!!"i2u44(/&E%§. Fortunately I'm not a coder in RL. ;)

Share this post


Link to post
Share on other sites

Not much free time currently. Just if anyone is interested. I changed wind code; I use internally and later maybe externally beaufort ranges and m/s speed (btw maximum Beaufort: 12.999 <=> 37m/s - more than possible with setwindstr), I want the script/addon to be more usable for snipers in the future. This also goes in line with using setwind array, which also uses m/s. Wind code works pretty well, but I need to implement some dynamic wind range adjustment (its the subrange in which wind moves for a specific time, i.e. that range is somewhere inside the user defined range); same goes for wind direction, which range also can be controlled.

Also rain code needs to be changed, also with reasonable and dynamic range adjustments.

Simple Beaufort conversion:

/* Simple Beaufort to m/s calculator by Tortuosit
  In:  wind speed in Beaufort (fractional values 0<n<13)
  Out: wind speed in m/s
  Beaufort scale: [url]http://en.wikipedia.org/wiki/Beaufort_scale[/url] */

bft2ms = {
  private "_out";
  switch (floor(_this select 0)) do {
     case 0:  {_out =        ((_this select 0) - floor(_this select 0)) * 0.3;};
     case 1:  {_out =  0.3 + ((_this select 0) - floor(_this select 0)) * 1.3;};
     case 2:  {_out =  1.6 + ((_this select 0) - floor(_this select 0)) * 1.8;};
     case 3:  {_out =  3.4 + ((_this select 0) - floor(_this select 0)) * 2.1;};
     case 4:  {_out =  5.5 + ((_this select 0) - floor(_this select 0)) * 2.5;};
     case 5:  {_out =  8.0 + ((_this select 0) - floor(_this select 0)) * 2.8;};
     case 6:  {_out = 10.8 + ((_this select 0) - floor(_this select 0)) * 3.1;};
     case 7:  {_out = 13.9 + ((_this select 0) - floor(_this select 0)) * 3.3;};
     case 8:  {_out = 17.2 + ((_this select 0) - floor(_this select 0)) * 3.6;};
     case 9:  {_out = 20.8 + ((_this select 0) - floor(_this select 0)) * 3.7;};
     case 10: {_out = 24.5 + ((_this select 0) - floor(_this select 0)) * 4;};
     case 11: {_out = 28.5 + ((_this select 0) - floor(_this select 0)) * 4.2;};
     case 12: {_out = 32.7 + ((_this select 0) - floor(_this select 0)) * 4.4;};
     default  {_out = 0;};
  };
  _out
};

Edited by tortuosit

Share this post


Link to post
Share on other sites

Release delay.

I rewrite some parts. Every weather aspect gets its own thread/script, maybe own pbo for the mod, not sure. Every script can run standalone. All have arguments which go like:

[[initial array], [borders array], weighting ...]

I added a weighting probability for the move to next weather, i.e.:

1 = always better, -1 = always worse, 0=50/50, 0.5=75/25 better, -0.5=25/75 better, you get the idea.

Share this post


Link to post
Share on other sites

Test version.

No release. Just for testing. Overall, it works, but it is unfinished pretty much. I changed a lot from the ground up, some arguments may not work any more. Main script is a code mess. tort_wind/tort_rain are newly built and independent threads (and still a playground for balancing). They can run independent without main script or mod (see into tort_rain.sqf/tort_wind.sqf for the command line) and have fancy parameters, but I don't make use of them yet in the main script... WIP. You should not use it :D

Also, pbo is just a loader, I opened all code. It is in the "\script" folder. You must keep "@tort_DynamicWeather" in ArmA 3 dir, if you rename it, it will not work.

delay :( Looking forward to the release :)

Please have a look if your "Postapocalyptic" setting works (no rain, wind less than 2.4 m/s). Its in 0-8,"Templates"

Edited by tortuosit

Share this post


Link to post
Share on other sites

Sorry, I can not afford doing things for ArmA currently.

Not a release. Unfinished... A lot is not doing what it should. Just fixed some CTD bugs and obvious script errors due to menu calls. Userconfig is obsolete. All code is in @tort dir. Also, have a look into new config folder. Wind direction is currently broken.

https://www.dropbox.com/s/njnqf7thqsw4h4e/%40tort_DynamicWeather.7z?dl=0

Share this post


Link to post
Share on other sites

Can anybody confirm that this works on a dedicated server (aside from Escape missions) with multiple (preferably >10) clients and remains synchronized? Anybody use this with Dedicated ALiVE Missions?

Share this post


Link to post
Share on other sites

I cannot tell you, because I have not much knowledge about ArmA server things... What I can say is, in the beginning it does 1 x simulweathersync/forceweatherchange. Then it only does n setovercast x / n setfog x / n setwinstr x/n setwinddir x /setwind[x,y,true]

Share this post


Link to post
Share on other sites

Just a dev build, not a release. Some code reorg. Config options are self explanatory... You can adjust the options menu now. Also you can manually set (and fix) wind speed and direction via menu. It's done in a way that those do not change instantly. E.g. may take a minute for wind to do a full turn. Main script needs a major overhaul.

https://www.dropbox.com/s/njnqf7thqsw4h4e/%40tort_DynamicWeather.7z?dl=0

Share this post


Link to post
Share on other sites

Hi tortuosit :)

can i run your mod together with Ruthberg's Advanced Ballistics & Kestrel 4500?

and how does your mod actually work? will the weather change automatically or i gotta set it up?

Share this post


Link to post
Share on other sites

Yes you can, but using it with Ruthberg makes more sense with my latest dev build... It has wind speed and direction menu and uses setwind[] array, which is important.

https://www.dropbox.com/s/m922x1b7t1jm4md/%40tort_DynamicWeather_dev.zip?dl=0

Press key 0, then 8 for the mods menus in order to control it.

Default behaviour: Yes weather changes automatically and is moving inside defined borders. Currently the mod is in a massive change, so especially the automatic weather transitions may not behave as expected. Very WIP.

See options in script\config\ folder. It uses the island defined weather presets you see there.

You can also run the wind script standalone without running the mod.

/* tort_wind by Tortuosit
  Args: [[initWindStrength, initDirection],[minWindStrength, maxWindStrength, DirBetweenA, DirBetweenB], weighting, turbulence]
  call example: tort_windthread = [[5, 280],[0, 8, 270, 60], 0, 0.2] execVM "\@tort_DynamicWeather\script\tort_wind.sqf";
  Enter wind strengths in Beaufort (0.0 - 12.9)
  Weighting (fractional values -1 to 1): probability for low wind. -1: go straight to minimum wind, +1 go straight to maximum wind, 0=equal probability
    -0.5 = 75% probability of decreasing wind... see?
  Turbulence: 0..1 stable..unstable
  http://en.wikipedia.org/wiki/Beaufort_scale
*/

The arguments may change depending on my ideas. I think initial wind array is pretty useless. If you change direction via menu it pretty quickly moves to this direction (random decision if cw or ccw) and stays in that specific range. You can see whats happening, theres an information screen in 0-8-1-1.

What I want to have is reasonable independent modules and an overall script which controls them.

Edited by tortuosit

Share this post


Link to post
Share on other sites

alright, thanks tortuosit :) i'm gonna try it with Advanced Ballistics...

so through the menus, i can change the weather anyway i want, right?

Share this post


Link to post
Share on other sites

Not any way, but as defined in all settings you find in the menu. "c:\Program Files (x86)\Steam\SteamApps\common\Arma 3\@tort_DynamicWeather\script\supportmenu.sqf"

Press 0-8 while playing and have a look what you can do.

Share this post


Link to post
Share on other sites

Just to let you know. Development and even my whole ArmA playing is halted. I'm suffering from hardware problems and don't know what it is plus not so much time to investigate. My computer either BSODs (STOP: 0x0000007), freezes, reboots or insta turns of. Can even freeze on BIOS level, but more likely when playing 3D games. No idea what is the cause but it sucks because my computer is pretty full of stuff. Already put all unnecessary (sound)cards and hard disks out, still happens. Because of job things I really have no energy to investigate further - as for gaming I am currently mainly active with www.chaos-reborn.com, which I can play on my notebook. Missing ArmA, but starting it up, playing it 2 minutes and then seing an insta reboot just makes me rage.

I also compensate by watching/commenting Twitch/Youtube ArmA channels. Addict :D

Edited by tortuosit

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×