Jump to content
Sign in to follow this  
meatball

Weather/Time and JIP?

Recommended Posts

Man, is it me, or is it way more difficult than it should be to keep the weather and time synch'd up between a server and clients (original join and JIP's)? If 3 hours have passed in mission, it should synch that up with clients joining later, and if it's raining on the server, it should be raining on all the clients. I see posts about this going back over 10 years and it's still seems difficult to do.

Am I missing something somewhere?

Share this post


Link to post
Share on other sites

Not that I'm a scripting genius or anything, but I've yet to see or make it work as one might think it should. There have been systems made by various users over the years that have at some points "mostly worked". But currently it is fairly immersion breaking with the rain specifically, in the MP environment.

I've read elsewhere that there are extended issues currently in that you can't adjust the overCast values over short periods of time. Which I would assume will make things more challenging in addressing via scripting (perhaps not?).

To answer your question specifically, no you're not missing anything. :)

Share this post


Link to post
Share on other sites

Yeah, just seems strange. In a game where something like Time of Day/Weather has such a huge impact on not only immersion, but on fairness between people on other teams (imagine one person logging in as JIP and not getting rain or darkness while another person has rain and/or darkness) I would have thought this would be simple. I know client/server/JIP can be complicated, but yeesh.

Share this post


Link to post
Share on other sites

Probably got your semi-solution here with BIS_fnc_MP:

fn_changedate = 
{
_date = _this select 0;
setdate [_date];
};

then call it from a loop after that is initalized:

while {true} do {
[[2013,5,5,5,5],"fn_changedate",nil,true] call BIS_fnc_MP;
sleep 60*5;
};

Share this post


Link to post
Share on other sites

Alright, I think I'm getting there. It appears that you need a combination of both setOvercast and simulSetHumidity to get the rain going. Overcast just seems to 'dim' the sun, but doesn't actually create the clouds, the SetHumidity brings out the clouds and rain. I've got it so I can configure the weather through parameters and it seems to be reflected on everyone's machines correctly. The only problem I'm having is getting the weather to randomly change over time. Here's the script I'm using so far. I _know_ my scripting is awful, so any suggestions on how to clean things up or make it more efficient is much appreciated.

So in description.ext I have the following block of code in the parameters.

class Params
{
// paramsArray[0]
         class initialWeather {
         title = "Initial Weather";
         values[] = {0,1,2,3,4,5,6};
         texts[] = {"Clear","Overcast","Light Rain","Heavy Rain","Light Fog","Heavy Fog","Random"};
         default = 0;
      }; 
};

This gives the players the option to choose the starting weather in the setup screen. Then I've created a script that I call in the init.sqf for everyone, server and client.



// JIP Check
if (!isServer && isNull player) then {isJIP=1;} else {isJIP=0;};

// Wait until player is initialized
if (!isDedicated) then {waitUntil {!isNull player && isPlayer player};};

if(isServer) then {
initialWeather = (paramsArray select 0);
switch (initialWeather) do{
// Clear
case 0: {cloudSet = 0;rainSet = 0;fogSet = 0;};
// Overcast
case 1: {cloudSet = 0.7;rainSet = 0.5;fogSet = 0;};
// Light Rain
case 2: {cloudSet = 0.85;rainSet = 0.8;fogSet = 0.05;};
// Heavy Rain
case 3: {cloudSet = 1;rainSet = 1;fogSet = .05;};
// Light Fog
case 4: {cloudSet = 0.25;rainSet = 0.25;fogSet = 0.25;};
// Heavy Fog
case 5: {cloudSet = 0.5;rainSet = 0.5;fogSet = 0.75;};
// Random
case 6: {cloudSet = random(1);rainSet = random(1);fogSet = random(.75);};
};
publicVariable "cloudSet";
publicVariable "rainSet";
publicVariable "fogSet";
};

waitUntil {!isnil "cloudSet"};

if (isServer) then {
	publicVariable "cloudSet";
	publicVariable "rainSet";
	publicVariable "fogSet";
};

if (isServer or isJIP == 0) then {
//Set up initial Weather for Server/non JIP Players, but keep on same date.
skipTime -24;
86400 setOvercast cloudSet;
86400 setFog fogSet;
simulSetHumidity rainSet;
skipTime 24;
} else { // Set Weather for JIP Players
599 setOvercast cloudSet;
599 setFog fogSet;
simulSetHumidity rainSet;
};

// Set up weather changes and weather update loop.

while {isServer} do
{	_randTFC = random(0.2)-0.1;
	_randTFR = random(0.2)-0.1;
	_randTFF = random(0.2)-0.1;
	cloudSet = cloudSet + _randTFC;
	if (cloudSet > 1) then {cloudSet = cloudSet - (2*_randTFC)};
	if (cloudSet < 0) then {cloudSet = cloudSet + (abs(2*_randTFC))};
	rainSet = rainSet + _randTFR;
	if (rainSet > 1) then {rainSet = rainSet - (2*_randTFR)};
	if (rainSet < 0) then {rainSet = rainSet + (abs(2*_randTFR))};
	fogSet = fogSet + _randTFF;
	if (fogSet > 1) then {fogSet = fogSet - (2*_randTFF)};
	if (fogSet < 0) then {fogSet = fogSet + (abs(2*_randTFF))};
	publicVariable "cloudSet";
	publicVariable "rainSet";
	publicVariable "fogSet";

	sleep 600;
};

while {!isServer} do
{	599 setOvercast cloudSet;
	599 setFog fogSet;
	simulSetHumidity rainSet;
	sleep 600;
};

Like I said, seems to set the weather correctly for everyone on mission startup, just having a problem with the loops to randomly change/update the weather for everyone. I also bet I've got things a bit bass akward in my attempt to be able to handle server only, clients and JIP's all in the same script and may have stuff completely wrong that I didn't catch with my little bit of testing.

Any thoughts/suggestions?

Edited by Meatball

Share this post


Link to post
Share on other sites

is the "time" variable public? does it get transmitted to JIPs or is it local?

Share this post


Link to post
Share on other sites

It's just silly that you need scripts for this though. I really don't understand why weather and time isn't synced by default. I'm still trying to figure out why some things work as they do in the Armaverse and I just can't come up with any logical reason for weather not to be synced.

Share this post


Link to post
Share on other sites

Agreed, I can't think of any logical reason either you would ever want weather and time not to be exactly synched across servers/clients. The only explanation I can even think of would be that there's some technical issue it's not set up to synch due to bandwidth issues, or something of the sort.

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  

×