Jump to content

Recommended Posts

Hi, I have working weather script that is used with mission params to change the weather. The only problem is weather changes after the mission start and is quite immersion breaking for the players.
Can somehow pre-init the script, so weather change before players can see the changes? 


The script itself (very primitive but works):
 

//initServer.sqf

private _weather = "Weather" call BIS_fnc_getParamValue;
if (_weather == 1) then {
sleep 3;
0 setOvercast 0; 
0 setRain 0;
0 setFog 0; 
forceWeatherChange;
["weather", []] call BIS_fnc_showNotification;};
if (_weather == 2) then {
sleep 3;
0 setOvercast 0.5; 
0 setRain 0;
0 setFog 0; 
forceWeatherChange;
["weather", []] call BIS_fnc_showNotification;};
if (_weather == 3) then {
sleep 3;
0 setOvercast 0.6; 
0 setRain 0;
0 setFog 0.1; 
forceWeatherChange;
["weather", []] call BIS_fnc_showNotification;}; 
if (_weather == 4) then {
sleep 3;
0 setOvercast 1;
0 setRain 0.5; 
forceWeatherChange;
["weather", []] call BIS_fnc_showNotification;};

Mission parameters: 
 

class Params
{
	class Weather
	{
		title = "Choose weather conditions for the mission";
		texts[] = { "Clear", "Cloudy", "Fog", "Rain" };
		values[] = { 1, 2, 3, 4 };
		default = 4;
	};
};

 

Share this post


Link to post
Share on other sites

Making 

sleep = 0.5;

completely blends the weather change at the beginning. Not fancy but effective. :ftvsmilie2:

Share this post


Link to post
Share on other sites
_weather = ["Weather", -1] call BIS_fnc_getParamValue;

if (_weather == -1) exitWith {
    hint "Weather parameter not found!";
};

switch (_weather) do {

	case 0: {
		
		skipTime -24; 
		0 setOvercast 0; //clear sky
		skipTime 24;
		[0,0] remoteExec ["setOvercast", -2, true]; //remoteExec for JIP
		0 setRain 0;
		0 setFog 0; 
		forceWeatherChange;
		[1] remoteExec ["skipTime", -2, true]; //remoteExec for JIP
		[-1] remoteExec ["skipTime", -2, true]; //remoteExec for JIP
		999999 setRain 0;
		999999 setFog 0; 
		0 = [] spawn { sleep 0.1; simulWeatherSync; }; //To force instant cloud cover
		
	};
	
	case 1: {
	
		skipTime -24;
		86400 setOvercast 0.5;
		skipTime 24;
		[0,0.5] remoteExec ["setOvercast", -2, true];
		0 setRain 0;
		0 setFog 0;
		forceWeatherChange;
		[1] remoteExec ["skipTime", -2, true];
		[-1] remoteExec ["skipTime", -2, true];
		999999 setRain 0;
		999999 setFog 0; 
		0 = [] spawn { sleep 0.1; simulWeatherSync; };
		
	};
	
	case 2: {
	
		skipTime -24;
		86400 setOvercast 0.6;
		skipTime 24;
		[0,0.6] remoteExec ["setOvercast", -2, true];
		0 setRain 0;
		0 setFog 0.1;
		forceWeatherChange;
		[1] remoteExec ["skipTime", -2, true];
		[-1] remoteExec ["skipTime", -2, true];
		999999 setRain 0;
		999999 setFog 0.1; 
		0 = [] spawn { sleep 0.1; simulWeatherSync; };
	
	};
	
	case 3: {
	
		skipTime -24;
		86400 setOvercast 1;
		skipTime 24;
		[0,1] remoteExec ["setOvercast", -2, true];
		0 setRain 0.5;
		0 setFog 0;
		forceWeatherChange;
		[1] remoteExec ["skipTime", -2, true];
		[-1] remoteExec ["skipTime", -2, true];
		999999 setFog 0; 
		0 = [] spawn { sleep 0.1; simulWeatherSync; };
	};
	
};

The above seems to work instantly for me. Haven't tested in dedicated.
 

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

×