Advertisement
dapperstache

fn_initEnvironment.sqf

Oct 27th, 2024 (edited)
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 8.09 KB | None | 0 0
  1.     //Title: NUP_fnc_initEnvironment
  2.     //File:  NUP\NUP_flagCapture\functions\fn_initEnvironment.sqf
  3.     //Author: Dapperstache
  4.     //Purpose: called on mission start to alter mission environment
  5.     //Usage: [] spawn DAP_fnc_initEnvironment;
  6.  
  7.     // Define variables
  8.     private["_OBR_time", "_OBR_weather", "_OBR_fogAmt", "_OBR_rain", "_OBR_windStr", "_OBR_windFrc", "_OBR_windGst", "_OBR_lightnings", "_OBR_waveInt", "_systemTime", "_year", "_month", "_day", "_hour", "_minute"];
  9.  
  10.     // Get values from Description.ext
  11.     _OBR_time = "OBR_timeOfDay" call BIS_fnc_getParamValue;
  12.     _OBR_weather = "OBR_overcast" call BIS_fnc_getParamValue;
  13.     _OBR_fogAmt = "OBR_fog" call BIS_fnc_getParamValue;
  14.     _OBR_rain = "OBR_rain" call BIS_fnc_getParamValue;
  15.     _OBR_windStr = "OBR_windStrength" call BIS_fnc_getParamValue;
  16.     _OBR_windFrc = "OBR_windForce" call BIS_fnc_getParamValue;
  17.     _OBR_windGst = "OBR_windGusts" call BIS_fnc_getParamValue;
  18.     _OBR_lightnings = "OBR_lightning" call BIS_fnc_getParamValue;
  19.     _OBR_waveInt = "OBR_waves" call BIS_fnc_getParamValue;
  20.     diag_log format ["_OBR_weather fetched from description.ext: %1", _OBR_weather];
  21.  
  22.  
  23.     // Get current system time
  24.     _systemTime = systemTime;
  25.     _year = _systemTime select 0;
  26.     _month = _systemTime select 1;
  27.     _day = _systemTime select 2;
  28.     _hour = (_systemTime select 3) + 1;
  29.     _minute = _systemTime select 4;
  30.  
  31.     // Handle Weather parameter
  32.     if (_OBR_weather == 2) then {
  33.         _randomWeather = [0, 0.25, 0.50, 0.75, 1] call BIS_fnc_selectRandom;
  34.         skipTime -24;
  35.         86400 setOvercast _randomWeather;
  36.         skipTime 24;
  37.         0 = [] spawn { sleep 0.1; simulWeatherSync;};
  38.  
  39.         [_randomWeather] call BIS_fnc_paramWeather;
  40.         [_randomWeather] remoteExec ["setOvercast", 0];
  41.     } else {
  42.         [_OBR_weather] call BIS_fnc_paramWeather;
  43.         skipTime -24;
  44.         86400 setOvercast _OBR_weather;
  45.         skipTime 24;
  46.         0 = [] spawn { sleep 0.1; simulWeatherSync;};
  47.         [_OBR_weather] remoteExec ["setOvercast", 0];
  48.     };
  49.  
  50.     // Handle Fog parameter
  51.     if (_OBR_fogAmt == 2) then {
  52.         _randomFog = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.5, 0.10, 0.25, 0.50, 0.65, 0.75] call BIS_fnc_selectRandom;
  53.         0 setFog _randomFog;
  54.         999999 setFog _randomFog;
  55.         [0, [_randomFog]] remoteExec ["setFog", 2];
  56.         [999999, [_randomFog]] remoteExec ["setFog", 2];
  57.     } else {
  58.         0 setFog _OBR_fogAmt;
  59.         999999 setFog _OBR_fogAmt;
  60.         [0, _OBR_fogAmt] remoteExec ["setFog", 2];
  61.         [999999, _OBR_fogAmt] remoteExec ["setFog", 2];
  62.     };
  63.  
  64.     // Handle Rain parameter
  65.     switch (_OBR_rain) do {
  66.         case 2: {
  67.             _randomRain = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.25, 0.50, 0.75, 1] call BIS_fnc_selectRandom;
  68.             0 setRain _randomRain;
  69.             setHumidity _randomRain;
  70.             [0, _randomRain] remoteExec ["setRain", 2];
  71.             [_randomRain] remoteExec ["setHumidity", 2];
  72.             skipTime 1; skipTime -1;
  73.             forceWeatherChange;
  74.         };
  75.         default {
  76.             0 setRain _OBR_rain;
  77.             setHumidity _OBR_rain;
  78.             [0, _OBR_rain] remoteExec ["setRain", 2];
  79.             [_OBR_rain] remoteExec ["setHumidity", 2];
  80.             skipTime 1; skipTime -1;
  81.             skipTime 1; skipTime -1;
  82.             forceWeatherChange;
  83.         };
  84.         case 3: {
  85.             0 setRain 1;
  86.             0 setFog 0.1;
  87.             setHumidity 0.9;
  88.             enableEnvironment [false, true];
  89.             forceWeatherChange;
  90.             [
  91.                 "a3\data_f\snowflake4_ca.paa",
  92.                 4,
  93.                 0.01,
  94.                 25,
  95.                 0.05,
  96.                 2.5,
  97.                 0.5,
  98.                 0.5,
  99.                 0.07,
  100.                 0.07,
  101.                 [1, 1, 1, 0.5],
  102.                 0.0,
  103.                 0.2,
  104.                 0.5,
  105.                 0.5,
  106.                 true,
  107.                 false
  108.             ] call BIS_fnc_setRain;
  109.         };
  110.     };
  111.  
  112.     // Handle Wind Strength parameter
  113.     if (_OBR_windStr == 2) then {
  114.         _randomwindStr = [0, 0, 0, 0, 0.25, 0.50, 0.75, 1] call BIS_fnc_selectRandom;
  115.         0 setWindStr  _randomWindStr;
  116.         [0, _randomWindStr] remoteExec ["setWindStr"];
  117.     } else {
  118.         0 setWindStr  _OBR_windStr;
  119.         [0, _OBR_windStr] remoteExec ["setWindStr"];
  120.     };
  121.  
  122.     // Handle Wind Force parameter
  123.     if (_OBR_windFrc == 2) then {
  124.         _randomWindFrc = [0, 0, 0, 0, 0.25, 0.50, 0.75, 1] call BIS_fnc_selectRandom;
  125.         0 setWindForce _randomWindFrc;
  126.         [0, _randomWindFrc] remoteExec ["setWindForce"];
  127.        
  128.     } else {
  129.         0 setWindForce _OBR_windFrc;
  130.         [0, _OBR_windFrc] remoteExec ["setWindForce"];
  131.     };
  132.  
  133.     // Handle Wind Gusts parameter
  134.     if (_OBR_windGst == 2) then {
  135.         _randomWindGst = [0, 0, 0, 0, 0.25, 0.50, 0.75, 1] call BIS_fnc_selectRandom;
  136.         0 setGusts _randomWindGst;
  137.         [0, _randomWindGst] remoteExec ["setGusts"];
  138.     } else {
  139.         0 setGusts _OBR_windGst;
  140.         [0, _OBR_windGst] remoteExec ["setGusts"];
  141.     };
  142.  
  143.     // Handle Lightnings parameter
  144.     if (_OBR_lightnings == 2) then {
  145.         _randomLightnings = [0, 0, 0, 0, 0.25, 0.50, 0.75, 1] call BIS_fnc_selectRandom;
  146.         0 setLightnings _randomLightnings;
  147.         [0, _randomLightnings] remoteExec ["setLightnings"];
  148.     } else {
  149.         0 setLightnings _OBR_lightnings;
  150.         [0, _OBR_lightnings] remoteExec ["setLightnings"];
  151.     };
  152.  
  153.     // Handle Wave Intensity parameter
  154.     if (_OBR_waveInt == 2) then {
  155.         _randomWaves = [0, 0, 0, 0, 0.25, 0.50, 0.75, 1] call BIS_fnc_selectRandom;
  156.         0 setWaves _randomWaves;
  157.         [0, _randomWaves] remoteExec ["setWaves"];
  158.     } else {
  159.         0 setWaves _OBR_waveInt;
  160.         [0, _OBR_waveInt] remoteExec ["setWaves"];
  161.     };
  162.  
  163.     // Set Time
  164.      switch (_OBR_time) do {
  165.         case 101: {
  166.             setDate [_year, _month, _day, _hour, _minute];
  167.         };
  168.         case 0: {
  169.             _randomTime = [4, 8, 12, 16, 18, 20, 24, 12, 16, 18] call BIS_fnc_selectRandom;
  170.             setDate [_year, _month, _day, _randomTime, 0];
  171.             [[_year, _month, _day, _randomTime, 0]] remoteExec ["setDate"];
  172.         };
  173.         case 4: {
  174.             setDate [_year, _month, _day, 4, 0];
  175.             [[_year, _month, _day, 4, 0]] remoteExec ["setDate"];
  176.         };
  177.         case 8: {
  178.             setDate [_year, _month, _day, 8, 0];
  179.             [[_year, _month, _day, 8, 0]] remoteExec ["setDate"];
  180.         };
  181.         case 12: {
  182.             setDate [_year, _month, _day, 12, 0];
  183.             [[_year, _month, _day, 12, 0]] remoteExec ["setDate"];
  184.         };
  185.         case 16: {
  186.             setDate [_year, _month, _day, 16, 0];
  187.             [[_year, _month, _day, 16, 0]] remoteExec ["setDate"];
  188.         };
  189.         case 18: {
  190.             setDate [_year, _month, _day, 18, 0];
  191.             [[_year, _month, _day, 18, 0]] remoteExec ["setDate"];
  192.         };
  193.         case 20: {
  194.             setDate [_year, _month, _day, 20, 0];
  195.             [[_year, _month, _day, 20, 0]] remoteExec ["setDate"];
  196.         };
  197.             case 24: { setDate [_year, _month, _day, 24, 0];
  198.             [[_year, _month, _day, 24, 0]] remoteExec ["setDate"];
  199.         };
  200.     };
  201.  
  202.     // Log Weather and Time Initialization
  203.    
  204.     diag_log "// === Weather & Time Initialization Complete ===//";
  205.     diag_log "Selected Settings";
  206.     diag_log format ["Overcast: %1 ", _OBR_weather];
  207.     diag_log format ["Fog: %1 ", _OBR_fogAmt];
  208.     diag_log format ["Rain: %1 ", _OBR_rain];
  209.     diag_log format ["Wind Strength: %1 ", _OBR_windStr];
  210.     diag_log format ["Snow: %1", rainparams select 15];
  211.     diag_log format ["Wind Force: %1 ", _OBR_windFrc];
  212.     diag_log format ["Wind Gusts: %1 ", _OBR_windGst];
  213.     diag_log format ["Lightning: %1 ", _OBR_lightnings];
  214.     diag_log format ["Wave Intensity: %1 ", _OBR_waveInt];
  215.     diag_log format ["Time: %1", _OBR_time];
  216.     diag_log "Results:";
  217.     diag_log format ["Overcast: %1 ", overcast];
  218.     diag_log format ["Fog: %1 ", fog];
  219.     diag_log format ["Rain: %1 ", rain];
  220.     diag_log format ["Wind Strength: %1 ", windStr];
  221.     diag_log format ["Snow: %1", rainparams select 15];
  222.     diag_log format ["Wind Force: %1 ", Wind];
  223.     diag_log format ["Wind Gusts: %1 ", gusts];
  224.     diag_log format ["Lightning: %1 ", lightnings];
  225.     diag_log format ["Wave Intensity: %1 ", waves];
  226.     diag_log format ["Time: %1", systemTime];
  227.     diag_log "// ======================================//";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement