2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2015-04-21 18:20:05 +00:00
|
|
|
/*
|
|
|
|
* Author: Ruthberg
|
2017-11-10 14:44:15 +00:00
|
|
|
* Inits the wind variables on the server (on mission start)
|
2015-04-21 18:20:05 +00:00
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Arguments:
|
2015-04-21 18:20:05 +00:00
|
|
|
* None
|
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Return Value:
|
2015-04-21 18:20:05 +00:00
|
|
|
* None
|
2016-01-05 07:39:29 +00:00
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [] call ace_weather_fnc_initWind
|
|
|
|
*
|
|
|
|
* Public: No
|
2015-04-21 18:20:05 +00:00
|
|
|
*/
|
|
|
|
|
2016-01-05 07:39:29 +00:00
|
|
|
private _month = date select 1;
|
|
|
|
private _windDirectionProbabilities = GVAR(WindDirectionProbabilities) select (_month - 1);
|
2015-04-21 18:20:05 +00:00
|
|
|
|
|
|
|
GVAR(wind_direction_reference) = random 360;
|
2016-01-05 07:39:29 +00:00
|
|
|
private _sum = 0;
|
2015-04-22 17:46:09 +00:00
|
|
|
for "_i" from 0 to 7 do {
|
|
|
|
_sum = _sum + (_windDirectionProbabilities select _i);
|
|
|
|
};
|
2016-01-05 07:39:29 +00:00
|
|
|
private _rand = random _sum;
|
|
|
|
private _csum = [0, 0, 0, 0, 0, 0, 0, 0];
|
2015-04-22 17:46:09 +00:00
|
|
|
for "_i" from 0 to 7 do {
|
|
|
|
for "_j" from 0 to _i do {
|
|
|
|
_csum set [_i, (_csum select _i) + (_windDirectionProbabilities select _j)];
|
|
|
|
};
|
|
|
|
};
|
2016-01-05 07:39:29 +00:00
|
|
|
private _index = 0;
|
2015-04-22 17:46:09 +00:00
|
|
|
for "_i" from 0 to 7 do {
|
|
|
|
if (_rand > (_csum select _i)) then {
|
|
|
|
_index = _index + 1;
|
2015-04-21 18:20:05 +00:00
|
|
|
};
|
|
|
|
};
|
2015-04-22 17:46:09 +00:00
|
|
|
GVAR(wind_direction_reference) = 45 * _index;
|
|
|
|
|
2015-04-21 18:20:05 +00:00
|
|
|
GVAR(wind_mean_dir) = GVAR(wind_direction_reference);
|
|
|
|
GVAR(wind_direction_reference) = GVAR(wind_direction_reference) + (random 22.5) - (random 22.5);
|
2015-04-22 10:56:07 +00:00
|
|
|
GVAR(wind_direction_reference) = (360 + GVAR(wind_direction_reference)) % 360;
|
2015-04-21 18:20:05 +00:00
|
|
|
|
|
|
|
GVAR(min_wind_speed) = GVAR(WindSpeedMin) select (_month - 1);
|
|
|
|
GVAR(min_wind_speed) = (GVAR(min_wind_speed) select 0) + (random (GVAR(min_wind_speed) select 1)) - (random (GVAR(min_wind_speed) select 1));
|
|
|
|
GVAR(min_wind_speed) = 0 max GVAR(min_wind_speed);
|
2015-04-22 10:56:07 +00:00
|
|
|
GVAR(mean_wind_speed) = GVAR(WindSpeedMean) select (_month - 1);
|
2015-04-21 18:20:05 +00:00
|
|
|
GVAR(max_wind_speed) = GVAR(WindSpeedMax) select (_month - 1);
|
|
|
|
GVAR(max_wind_speed) = (GVAR(max_wind_speed) select 0) + (random (GVAR(max_wind_speed) select 1)) - (random (GVAR(max_wind_speed) select 1));
|
|
|
|
GVAR(max_wind_speed) = 0 max GVAR(max_wind_speed);
|
|
|
|
|
2017-11-10 14:44:15 +00:00
|
|
|
GVAR(wind_upper_span) = GVAR(max_wind_speed) - GVAR(mean_wind_speed);
|
|
|
|
GVAR(wind_lower_span) = GVAR(min_wind_speed) - GVAR(mean_wind_speed);
|
|
|
|
|
2015-04-22 10:56:07 +00:00
|
|
|
GVAR(current_wind_direction) = GVAR(wind_direction_reference);
|
2017-11-10 14:44:15 +00:00
|
|
|
GVAR(next_wind_direction) = GVAR(current_wind_direction);
|
2015-04-21 18:20:05 +00:00
|
|
|
|
2017-11-10 14:44:15 +00:00
|
|
|
GVAR(current_wind_speed) = GVAR(min_wind_speed) + (GVAR(max_wind_speed) - GVAR(min_wind_speed)) * (random 1);
|
|
|
|
GVAR(next_wind_speed) = GVAR(current_wind_speed);
|
2015-04-21 18:20:05 +00:00
|
|
|
|
2017-11-10 14:44:15 +00:00
|
|
|
GVAR(last_wind_update) = 0;
|
|
|
|
GVAR(next_wind_udpate) = 0;
|