mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Added ace/module settings for ace_weather:
*enableServerController // weather propagation on the server *useACEWeather // disable ace weather *syncRain *syncWind *syncMisc
This commit is contained in:
parent
b0876ca394
commit
3c91f6abe3
32
addons/weather/ACE_Settings.hpp
Normal file
32
addons/weather/ACE_Settings.hpp
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
class ACE_Settings {
|
||||||
|
class GVAR(enableServerController) {
|
||||||
|
displayName = "Weather propagation";
|
||||||
|
description = "Enables sever side weather propagation";
|
||||||
|
typeName = "BOOL";
|
||||||
|
value = 1;
|
||||||
|
};
|
||||||
|
class GVAR(useACEWeather) {
|
||||||
|
displayName = "ACE Weather";
|
||||||
|
description = "Overrides the default weather (editor, mission settings) with ACE weather (map based)";
|
||||||
|
typeName = "BOOL";
|
||||||
|
value = 1;
|
||||||
|
};
|
||||||
|
class GVAR(syncRain) {
|
||||||
|
displayName = "Sync Rain";
|
||||||
|
description = "Synchronizes rain";
|
||||||
|
typeName = "BOOL";
|
||||||
|
value = 1;
|
||||||
|
};
|
||||||
|
class GVAR(syncWind) {
|
||||||
|
displayName = "Sync Wind";
|
||||||
|
description = "Synchronizes wind";
|
||||||
|
typeName = "BOOL";
|
||||||
|
value = 1;
|
||||||
|
};
|
||||||
|
class GVAR(syncMisc) {
|
||||||
|
displayName = "Sync Misc";
|
||||||
|
description = "Synchronizes lightnings, rainbow, fog, ...";
|
||||||
|
typeName = "BOOL";
|
||||||
|
value = 1;
|
||||||
|
};
|
||||||
|
};
|
46
addons/weather/CfgVehicles.hpp
Normal file
46
addons/weather/CfgVehicles.hpp
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
class CfgVehicles {
|
||||||
|
class ACE_Module;
|
||||||
|
class GVAR(ModuleSettings): ACE_Module {
|
||||||
|
scope = 2;
|
||||||
|
displayName = "Weather";
|
||||||
|
icon = QUOTE(PATHTOF(UI\Icon_Module_Wind_ca.paa));
|
||||||
|
category = "ACE";
|
||||||
|
function = QUOTE(DFUNC(initModuleSettings));
|
||||||
|
functionPriority = 1;
|
||||||
|
isGlobal = 1;
|
||||||
|
isTriggerActivated = 0;
|
||||||
|
author = "$STR_ACE_Common_ACETeam";
|
||||||
|
class Arguments {
|
||||||
|
class enableServerController {
|
||||||
|
displayName = "Weather propagation";
|
||||||
|
description = "Enables sever side weather propagation";
|
||||||
|
typeName = "BOOL";
|
||||||
|
defaultValue = 1;
|
||||||
|
};
|
||||||
|
class useACEWeather {
|
||||||
|
displayName = "ACE Weather";
|
||||||
|
description = "Overrides the default weather (editor, mission settings) with ACE weather (map based)";
|
||||||
|
typeName = "BOOL";
|
||||||
|
defaultValue = 1;
|
||||||
|
};
|
||||||
|
class syncRain {
|
||||||
|
displayName = "Sync Rain";
|
||||||
|
description = "Synchronizes rain";
|
||||||
|
typeName = "BOOL";
|
||||||
|
defaultValue = 1;
|
||||||
|
};
|
||||||
|
class syncWind {
|
||||||
|
displayName = "Sync Wind";
|
||||||
|
description = "Synchronizes wind";
|
||||||
|
typeName = "BOOL";
|
||||||
|
defaultValue = 1;
|
||||||
|
};
|
||||||
|
class syncMisc {
|
||||||
|
displayName = "Sync Misc";
|
||||||
|
description = "Synchronizes lightnings, rainbow, fog, ...";
|
||||||
|
typeName = "BOOL";
|
||||||
|
defaultValue = 1;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
BIN
addons/weather/UI/Icon_Module_Wind_ca.paa
Normal file
BIN
addons/weather/UI/Icon_Module_Wind_ca.paa
Normal file
Binary file not shown.
@ -9,7 +9,6 @@ GVAR(rain_current_range) = -1+(random 2);
|
|||||||
// Wind
|
// Wind
|
||||||
call FUNC(initWind);
|
call FUNC(initWind);
|
||||||
|
|
||||||
GVAR(overcast_multiplier) = 1;
|
|
||||||
GVAR(serverUpdateInterval) = 60;
|
GVAR(serverUpdateInterval) = 60;
|
||||||
|
|
||||||
[FUNC(serverController), GVAR(serverUpdateInterval)] call cba_fnc_addPerFrameHandler;
|
[FUNC(serverController), GVAR(serverUpdateInterval)] call cba_fnc_addPerFrameHandler;
|
||||||
|
@ -8,21 +8,15 @@ PREP(calculateBarometricPressure);
|
|||||||
PREP(displayWindInfo);
|
PREP(displayWindInfo);
|
||||||
PREP(getMapData);
|
PREP(getMapData);
|
||||||
PREP(getWind);
|
PREP(getWind);
|
||||||
|
PREP(initModuleSettings);
|
||||||
PREP(initWind);
|
PREP(initWind);
|
||||||
PREP(serverController);
|
PREP(serverController);
|
||||||
|
PREP(updateAceWeather);
|
||||||
PREP(updateHumidity);
|
PREP(updateHumidity);
|
||||||
PREP(updateRain);
|
PREP(updateRain);
|
||||||
PREP(updateTemperature);
|
PREP(updateTemperature);
|
||||||
PREP(updateWind);
|
PREP(updateWind);
|
||||||
|
|
||||||
// Control server side weather propagation
|
|
||||||
GVAR(enableServerController) = true;
|
|
||||||
|
|
||||||
// Control client side weather effects
|
|
||||||
GVAR(syncRain) = true;
|
|
||||||
GVAR(syncWind) = true; // Wind, Gusts, Waves
|
|
||||||
GVAR(syncMisc) = true; // Lightnings, Rainbow, Fog
|
|
||||||
|
|
||||||
// Make sure this data is read before client/server postInit
|
// Make sure this data is read before client/server postInit
|
||||||
call FUNC(getMapData);
|
call FUNC(getMapData);
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
class CfgPatches {
|
class CfgPatches {
|
||||||
class ADDON {
|
class ADDON {
|
||||||
units[] = {};
|
units[] = {};
|
||||||
weapons[] = {};// "ACE_Kestrel4500" };
|
weapons[] = {};
|
||||||
requiredVersion = REQUIRED_VERSION;
|
requiredVersion = REQUIRED_VERSION;
|
||||||
requiredAddons[] = {"ace_common"};
|
requiredAddons[] = {"ace_common"};
|
||||||
author[] = {"q1184", "Rocko", "esteldunedain","Ruthberg"};
|
author[] = {"q1184", "Rocko", "esteldunedain","Ruthberg"};
|
||||||
@ -14,3 +14,5 @@ class CfgPatches {
|
|||||||
#include "CfgEventhandlers.hpp"
|
#include "CfgEventhandlers.hpp"
|
||||||
#include "CfgWorlds.hpp"
|
#include "CfgWorlds.hpp"
|
||||||
#include "RscTitles.hpp"
|
#include "RscTitles.hpp"
|
||||||
|
#include "CfgVehicles.hpp"
|
||||||
|
#include "ACE_Settings.hpp"
|
34
addons/weather/functions/fnc_initModuleSettings.sqf
Normal file
34
addons/weather/functions/fnc_initModuleSettings.sqf
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Author: Glowbal, Ruthberg
|
||||||
|
* Module for adjusting the wind deflection settings
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: The module logic <LOGIC>
|
||||||
|
* 1: units <ARRAY>
|
||||||
|
* 2: activated <BOOL>
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* None <NIL>
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
private ["_logic", "_units", "_activated"];
|
||||||
|
_logic = _this select 0;
|
||||||
|
_units = _this select 1;
|
||||||
|
_activated = _this select 2;
|
||||||
|
|
||||||
|
if !(_activated) exitWith {};
|
||||||
|
|
||||||
|
// Control server side weather propagation
|
||||||
|
[_logic, QGVAR(enableServerController), "enableServerController"] call EFUNC(common,readSettingFromModule);
|
||||||
|
|
||||||
|
// Overrides the default weather (editor, mission settings) with ACE weather (map based)
|
||||||
|
[_logic, QGVAR(useACEWeather), "useACEWeather"] call EFUNC(common,readSettingFromModule);
|
||||||
|
|
||||||
|
// Control client side weather effects
|
||||||
|
[_logic, QGVAR(syncRain), "syncRain"] call EFUNC(common,readSettingFromModule);
|
||||||
|
[_logic, QGVAR(syncWind), "syncWind"] call EFUNC(common,readSettingFromModule); // Wind, Gusts, Waves
|
||||||
|
[_logic, QGVAR(syncMisc), "syncMisc"] call EFUNC(common,readSettingFromModule); // Lightnings, Rainbow, Fog
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Author: ACE2 Team, esteldunedain, ruthberg
|
* Author: Ruthberg
|
||||||
*
|
*
|
||||||
* Calculate the wind and rain evolution on the server. Broadcasts the current and next values to the clients
|
* Gather weather parameters and broadcast them to the clients
|
||||||
*
|
*
|
||||||
* Argument:
|
* Argument:
|
||||||
* None
|
* None
|
||||||
@ -13,95 +13,21 @@
|
|||||||
|
|
||||||
if (!GVAR(enableServerController)) exitWith {};
|
if (!GVAR(enableServerController)) exitWith {};
|
||||||
|
|
||||||
private ["_lastRain", "_rainOverCast", "_transitionTime", "_windDirectionVariance", "_windSpeed", "_windSpeedChange", "_windMaxDiff", "_windMinDiff", "_windDirection", "_windDirectionChange", "_ratioMin", "_ratioMax"];
|
if (GVAR(useACEWeather)) then {
|
||||||
|
// Use location based real world weather data
|
||||||
// Rain simulation
|
[] call FUNC(updateAceWeather);
|
||||||
if (GVAR(syncRain) && GVAR(rain_period_count) > GVAR(rain_next_period)) then {
|
} else {
|
||||||
|
// Simply replicate the server weather on the clients
|
||||||
GVAR(rain_next_period) = ceil((1 + (random 10)) / GVAR(overcast_multiplier));
|
if (GVAR(syncRain)) then {
|
||||||
GVAR(rain_period_count) = 0;
|
ACE_RAIN_PARAMS = [rain, rain, GVAR(serverUpdateInterval)];
|
||||||
|
publicVariable "ACE_RAIN_PARAMS";
|
||||||
_lastRain = GVAR(current_rain);
|
};
|
||||||
|
if (GVAR(syncWind)) then {
|
||||||
if (overcast >= 0.7) then {
|
ACE_WIND_PARAMS = [wind call CBA_fnc_vectDir, 0, wind, 0, GVAR(serverUpdateInterval)];
|
||||||
_rainOverCast = (overcast - 0.7) / 0.3;
|
publicVariable "ACE_WIND_PARAMS";
|
||||||
if (GVAR(current_rain) == 0) then {
|
};
|
||||||
// Initialize rain with a random strength depending on the current overcast value
|
if (GVAR(syncMisc)) then {
|
||||||
GVAR(current_rain) = 0.25 + (random 0.25) + (random 0.5) * _rainOverCast;
|
ACE_MISC_PARAMS = [lightnings, rainbow, fogParams, GVAR(temperatureShift), GVAR(badWeatherShift), GVAR(humidityShift)];
|
||||||
};
|
publicVariable "ACE_MISC_PARAMS";
|
||||||
|
|
||||||
GVAR(current_rain) = GVAR(current_rain) + GVAR(current_rain) * ((_rainOverCast * GVAR(overcast_multiplier)) / 8) * GVAR(rain_current_range);
|
|
||||||
GVAR(current_rain) = 0.01 max GVAR(current_rain) min 1;
|
|
||||||
|
|
||||||
GVAR(rain_current_range) = -1 + (random 2);
|
|
||||||
} else {
|
|
||||||
_rainOverCast = 1;
|
|
||||||
|
|
||||||
GVAR(current_rain) = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
_transitionTime = 1 + (_rainOverCast * 5) + (random (_rainOverCast * 20));
|
|
||||||
|
|
||||||
ACE_RAIN_PARAMS = [_lastRain, GVAR(current_rain), _transitionTime];
|
|
||||||
TRACE_4("",_lastRain,_rainOverCast,_transitionTime,overcast);
|
|
||||||
|
|
||||||
GVAR(rain_period_start_time) = time;
|
|
||||||
publicVariable "ACE_RAIN_PARAMS";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Wind simulation
|
|
||||||
if (GVAR(syncWind) && GVAR(wind_period_count) > GVAR(wind_next_period)) then {
|
|
||||||
|
|
||||||
GVAR(wind_next_period) = ceil((2 + (random 5)) / GVAR(overcast_multiplier));
|
|
||||||
GVAR(wind_period_count) = 0;
|
|
||||||
|
|
||||||
_windDirectionVariance = (90 - (random 180)) * (overcast ^ 2);
|
|
||||||
_windDirection = (360 + GVAR(wind_direction_reference) + _windDirectionVariance) % 360;
|
|
||||||
_windDirectionChange = _windDirection - GVAR(current_wind_direction);
|
|
||||||
if (_windDirectionChange > 180) then {
|
|
||||||
_windDirectionChange = _windDirectionChange - 360;
|
|
||||||
};
|
|
||||||
if (_windDirectionChange < -180) then {
|
|
||||||
_windDirectionChange = 360 + _windDirectionChange;
|
|
||||||
};
|
|
||||||
|
|
||||||
_windMaxDiff = GVAR(mean_wind_speed) - GVAR(max_wind_speed);
|
|
||||||
_windMinDiff = GVAR(min_wind_speed) - GVAR(mean_wind_speed);
|
|
||||||
|
|
||||||
_ratioMax = (random 1) ^ 2;
|
|
||||||
_ratioMin = (random 1) ^ 2;
|
|
||||||
|
|
||||||
_windSpeed = GVAR(current_wind_speed);
|
|
||||||
_windSpeedChange = 0;
|
|
||||||
if ((random 1) < (0.3 max overcast)) then {
|
|
||||||
_windSpeed = GVAR(mean_wind_speed) + _windMaxDiff * _ratioMax + _windMinDiff * _ratioMin;
|
|
||||||
_windSpeedChange = _windSpeed - GVAR(current_wind_speed);
|
|
||||||
};
|
|
||||||
|
|
||||||
_transitionTime = GVAR(wind_next_period) * GVAR(serverUpdateInterval);
|
|
||||||
|
|
||||||
TRACE_5("dirCur/dirNew/spdCur/spdNew/period",GVAR(current_wind_direction),_windDirection,GVAR(current_wind_speed),_windSpeed,_transitionTime);
|
|
||||||
|
|
||||||
ACE_WIND_PARAMS = [GVAR(current_wind_direction),
|
|
||||||
_windDirectionChange,
|
|
||||||
GVAR(current_wind_speed),
|
|
||||||
_windSpeedChange,
|
|
||||||
_transitionTime];
|
|
||||||
|
|
||||||
GVAR(current_wind_direction) = _windDirection;
|
|
||||||
GVAR(current_wind_speed) = _windSpeed;
|
|
||||||
|
|
||||||
GVAR(wind_period_start_time) = time;
|
|
||||||
publicVariable "ACE_WIND_PARAMS";
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
if (GVAR(syncMisc)) then {
|
|
||||||
ACE_MISC_PARAMS = [lightnings, rainbow, fogParams, GVAR(temperatureShift), GVAR(badWeatherShift), GVAR(humidityShift)];
|
|
||||||
publicVariable "ACE_MISC_PARAMS";
|
|
||||||
};
|
|
||||||
|
|
||||||
GVAR(rain_period_count) = GVAR(rain_period_count) + 1;
|
|
||||||
GVAR(wind_period_count) = GVAR(wind_period_count) + 1;
|
|
||||||
|
|
||||||
GVAR(overcast_multiplier) = 1 max (2* overcast) min 2; // 0 (@ overcast 0), 2 (@ overcast 1)
|
|
105
addons/weather/functions/fnc_updateAceWeather.sqf
Normal file
105
addons/weather/functions/fnc_updateAceWeather.sqf
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
/*
|
||||||
|
* Author: ACE2 Team, esteldunedain, ruthberg
|
||||||
|
*
|
||||||
|
* Updates the wind and rain evolution on the server. Broadcasts the current and next values to the clients
|
||||||
|
*
|
||||||
|
* Argument:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Return value:
|
||||||
|
* None
|
||||||
|
*/
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
private ["_overcastMultiplier", "_lastRain", "_rainOverCast", "_transitionTime", "_windDirectionVariance", "_windSpeed", "_windSpeedChange", "_windMaxDiff", "_windMinDiff", "_windDirection", "_windDirectionChange", "_ratioMin", "_ratioMax"];
|
||||||
|
|
||||||
|
_overcastMultiplier = 1 max (2* overcast) min 2; // 0 (@ overcast 0), 2 (@ overcast 1)
|
||||||
|
|
||||||
|
// Rain simulation
|
||||||
|
if (GVAR(syncRain) && GVAR(rain_period_count) > GVAR(rain_next_period)) then {
|
||||||
|
|
||||||
|
GVAR(rain_next_period) = ceil((1 + (random 10)) / _overcastMultiplier);
|
||||||
|
GVAR(rain_period_count) = 0;
|
||||||
|
|
||||||
|
_lastRain = GVAR(current_rain);
|
||||||
|
|
||||||
|
if (overcast >= 0.7) then {
|
||||||
|
_rainOverCast = (overcast - 0.7) / 0.3;
|
||||||
|
if (GVAR(current_rain) == 0) then {
|
||||||
|
// Initialize rain with a random strength depending on the current overcast value
|
||||||
|
GVAR(current_rain) = 0.25 + (random 0.25) + (random 0.5) * _rainOverCast;
|
||||||
|
};
|
||||||
|
|
||||||
|
GVAR(current_rain) = GVAR(current_rain) + GVAR(current_rain) * ((_rainOverCast * _overcastMultiplier) / 8) * GVAR(rain_current_range);
|
||||||
|
GVAR(current_rain) = 0.01 max GVAR(current_rain) min 1;
|
||||||
|
|
||||||
|
GVAR(rain_current_range) = -1 + (random 2);
|
||||||
|
} else {
|
||||||
|
_rainOverCast = 1;
|
||||||
|
|
||||||
|
GVAR(current_rain) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
_transitionTime = 1 + (_rainOverCast * 5) + (random (_rainOverCast * 20));
|
||||||
|
|
||||||
|
ACE_RAIN_PARAMS = [_lastRain, GVAR(current_rain), _transitionTime];
|
||||||
|
TRACE_4("",_lastRain,_rainOverCast,_transitionTime,overcast);
|
||||||
|
|
||||||
|
GVAR(rain_period_start_time) = time;
|
||||||
|
publicVariable "ACE_RAIN_PARAMS";
|
||||||
|
};
|
||||||
|
|
||||||
|
// Wind simulation
|
||||||
|
if (GVAR(syncWind) && GVAR(wind_period_count) > GVAR(wind_next_period)) then {
|
||||||
|
|
||||||
|
GVAR(wind_next_period) = ceil((2 + (random 5)) / _overcastMultiplier);
|
||||||
|
GVAR(wind_period_count) = 0;
|
||||||
|
|
||||||
|
_windDirectionVariance = (90 - (random 180)) * (overcast ^ 2);
|
||||||
|
_windDirection = (360 + GVAR(wind_direction_reference) + _windDirectionVariance) % 360;
|
||||||
|
_windDirectionChange = _windDirection - GVAR(current_wind_direction);
|
||||||
|
if (_windDirectionChange > 180) then {
|
||||||
|
_windDirectionChange = _windDirectionChange - 360;
|
||||||
|
};
|
||||||
|
if (_windDirectionChange < -180) then {
|
||||||
|
_windDirectionChange = 360 + _windDirectionChange;
|
||||||
|
};
|
||||||
|
|
||||||
|
_windMaxDiff = GVAR(mean_wind_speed) - GVAR(max_wind_speed);
|
||||||
|
_windMinDiff = GVAR(min_wind_speed) - GVAR(mean_wind_speed);
|
||||||
|
|
||||||
|
_ratioMax = (random 1) ^ 2;
|
||||||
|
_ratioMin = (random 1) ^ 2;
|
||||||
|
|
||||||
|
_windSpeed = GVAR(current_wind_speed);
|
||||||
|
_windSpeedChange = 0;
|
||||||
|
if ((random 1) < (0.3 max overcast)) then {
|
||||||
|
_windSpeed = GVAR(mean_wind_speed) + _windMaxDiff * _ratioMax + _windMinDiff * _ratioMin;
|
||||||
|
_windSpeedChange = _windSpeed - GVAR(current_wind_speed);
|
||||||
|
};
|
||||||
|
|
||||||
|
_transitionTime = GVAR(wind_next_period) * GVAR(serverUpdateInterval);
|
||||||
|
|
||||||
|
TRACE_5("dirCur/dirNew/spdCur/spdNew/period",GVAR(current_wind_direction),_windDirection,GVAR(current_wind_speed),_windSpeed,_transitionTime);
|
||||||
|
|
||||||
|
ACE_WIND_PARAMS = [GVAR(current_wind_direction),
|
||||||
|
_windDirectionChange,
|
||||||
|
GVAR(current_wind_speed),
|
||||||
|
_windSpeedChange,
|
||||||
|
_transitionTime];
|
||||||
|
|
||||||
|
GVAR(current_wind_direction) = _windDirection;
|
||||||
|
GVAR(current_wind_speed) = _windSpeed;
|
||||||
|
|
||||||
|
GVAR(wind_period_start_time) = time;
|
||||||
|
publicVariable "ACE_WIND_PARAMS";
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
if (GVAR(syncMisc)) then {
|
||||||
|
ACE_MISC_PARAMS = [lightnings, rainbow, fogParams, GVAR(temperatureShift), GVAR(badWeatherShift), GVAR(humidityShift)];
|
||||||
|
publicVariable "ACE_MISC_PARAMS";
|
||||||
|
};
|
||||||
|
|
||||||
|
GVAR(rain_period_count) = GVAR(rain_period_count) + 1;
|
||||||
|
GVAR(wind_period_count) = GVAR(wind_period_count) + 1;
|
Loading…
Reference in New Issue
Block a user