Jump to content
meatball

randomWeather2 Script - Dynamic Weather For A3

Recommended Posts

randomWeather2 Script



Completely Rewritten Random and Player Selectable Weather Script for SP/MP Missions

by Meatball

Assistance with snow coding by NeoArmageddon

rw2_main.jpg

rw2_clear.jpgrw2_overcast.jpg

rw2_fog.jpgrw2_rain.jpg

rw2_snow.jpg

Description:

A simple/single script that allows you to add dynamic random weather for any SP/MP mission with the capability for players to choose initial weather settings.

Features:

- Completely rewrote the original randomWeather script from the ground up to make use of functions as opposed to continuously running loops.

- There are Clear, Overcast, Rain and Fog weather templates that the server will use to create dynamic weather forecasts every 20 minutes and then synchronize out to clients.

- Compatibility with parameter setup so players can choose initial weather settings.

- Test Script/Mission available with snow, but there are some bugs/limitations with it.

- Demo Missions available to show weather in action.

Installation:

1) Copy randomWeather2.sqf into the root of your mission folder.

2) Add the following to your init.sqf so it will run on the server and all clients.

execVM "randomWeather2.sqf";

3) If you'd like, you can add a 'parameter' in your description.ext file to the 'class Params' section to allow players to select the initial weather.

class Params
{
      // paramsArray[0]
         class initialWeatherParam {
         title = "Starting Weather";
         values[] = {0,1,2,3,4};
         texts[] = {"Clear","Overcast","Rain","Fog","Random"};
         default = 4;
      };
};

NOTE: If you have multiple parameters in your 'class Params' section and you do not put the initialWeatherParam as the first parameter in that section, you must update the rw2Param number (Line 63) in your randomWeather2.sqf file to match the correct number. Remember that 'selecting' values from the parameter section of your description.ext always starts at 0 for the first defined parameter and goes up from there. So if your initialWeatherParam parameter is first in the class Params section, rw2Param = 0; will work. If it is second in the list of class Params you'd need to change it to rw2Param = 1; and so on.

For more information on Parameters, please see the description.ext biki

Changelog:

v0.90

- I've gone through a major change/update with randomWeather2 and removed snow from the 'default' version. There is a crash to desktop bug that can surface when it is snowing and a player respawns. I believe it's related to the known Physx crash bug and caused by a snow particle being in the players body when they die/respawn.

- While the new v0.9 script does not include snow, I have included a version with snow for anyone that wishes to still use it or wants to experiment with it.

- I will not be supporting or updating the snow based version going forward unless BI fixes the underlying bug.

- Tweaked some settings to ensure that it is actually 'raining' when the mission starts if rain is selected.

- Made a minor adjustment to the initial weather setup to ensure clouds are created properly.

- Tested on stable build v1.12.

v0.85

- Minor fix to code to disable snow underwater.

- Added in 2 additional changes to snow code to allow the disabling of snow based on player altitude & day or night. Both are disabled by default but can be enabled on lines 236 - 240.

v0.8

- Stopped snow from occurring when the player is underwater.

- Found a random crash bug caused by the snow particle effects and revive scripts (think it has to do with the overall Physx Crash Bug). Updated the snow script and it should fix any Crash to Desktop problems you've been having.

v0.7

- First Public Release

Credits & Thanks:

- NeoArmageddon for lot's of help including a lot of the snow related code.

Latest Version:

- Armaholic (Thanks guys!): randomWeather2 Script

Edited by Meatball
  • Like 1

Share this post


Link to post
Share on other sites
Guest

Thanks for sending us the release :cool:

Release frontpaged on the Armaholic homepage.

================================================

We have also "connected" these pages to your account on Armaholic.

This means in the future you will be able to maintain these pages yourself if you wish to do so. Once this new feature is ready we will contact you about it and explain how things work and what options you have.

When you have any questions already feel free to PM or email me!

Share this post


Link to post
Share on other sites

Hey, sounds like a really good script, thanks for the work. Just one Question though, does it affect the way the wind behaves in any way? Because right now things as galz wind ballistics do not make a lot of sense with the way the wind behaves as it is not synchronized between clients and changes around like crazy every 2 seconds.

Share this post


Link to post
Share on other sites

I don't think weather has to be "random". For example aÑcording to the climat of Altis it should be clear weather most of the time with rare light rain. And not a tropic rain every half a hour.

Is this script completly random?

Share this post


Link to post
Share on other sites

Do you plan making it so the snow can collect on the ground simliar to this?

i think one of the ACE guys said it was possible in the new engine.

Edited by Rages123

Share this post


Link to post
Share on other sites
Hey, sounds like a really good script, thanks for the work. Just one Question though, does it affect the way the wind behaves in any way? Because right now things as galz wind ballistics do not make a lot of sense with the way the wind behaves as it is not synchronized between clients and changes around like crazy every 2 seconds.

Yes, wind does update and get synch'd out to everyone with every weather shift.

I don't think weather has to be "random". For example aÑcording to the climat of Altis it should be clear weather most of the time with rare light rain. And not a tropic rain every half a hour.

Is this script completly random?

No, it's not completely random. Here's the basic gist of it. There are 10 pre-set weather 'templates', Clear, Overcast, Light Rain, Medium Rain, Rainstorm, Light Fog, Medium Fog, Dense Fog, Light Snow, Medium Snow and Blizzard. Every 20 minutes the weather has a chance to shift to another one of the weather templates, but it's set so the shifts make sense and each template can only move to other specific templates that make sense. For example, if you are currently at medium rain, you can possibly stay at medium rain, move to light rain, or move to rainstorm. So it's not drastic shifts in weather. Take a look in the script and I think I have it pretty well documented so it makes sense, but let me know if you have any questions.

Do you plan making it so the snow can collect on the ground simliar to this?

i think one of the ACE guys said it was possible in the new engine.

Yeah, I've seen that, and I think it would be awesome, but I believe that actually requires a full mod as opposed to just a script, so right now I really wanted to keep this a simple script. To be honest, snow is somewhat of a kludge, having to use particle effects that 'surround' the player, which is a shame. It'd be really nice if BI just created a new model for snow flakes and used the rain or snow model based on a temperature setting in game :) Other than the noise/model, there's no reason snow couldn't use the same code and behave the same way rain does, just with a different model/sound effect.

Edited by Meatball

Share this post


Link to post
Share on other sites

Is this script really able to synchronize weather conditions between clients? If so, it would be a must have.

Share this post


Link to post
Share on other sites
Is this script really able to synchronize weather conditions between clients? If so, it would be a must have.

Yes...it does :)

Share this post


Link to post
Share on other sites

Great work Meatball n co. Can I make a suggestion? I would like to see a snow only version minus the rain for winter maps. My current mission is using A3MP, Thirsk (Winter), Massi's UK special forces and Russian spetnaz, my custom Arctic Hunter pack(Unreleased) and now your random weather script. Looks great http://i1355.photobucket.com/albums/q706/WinstonSmith81/arma32014-02-0920-48-15-63_zpsff4ef365.png (583 kB)

Edited by WinstonSmith

Share this post


Link to post
Share on other sites

I'm sorry to rain on your parade (excuse the pun) but your script will not sync on clients.

You are not taking into account the nextWeatherChange variable which at present cannot be set by any script you might make.

The skiptime trick only draws the clouds locally and will not enable syncing on jip clients. A 15 minute weather creation will do nothing since nextWeatherChange is hard coded to the engine for 60 minutes in the first instance (independent on all clients) and 30 minutes thereafter.

On a side note, furthermore your script does not take into account the setWaves, setGusts, setWindForce, setWindDir and setLightnings commands.

Please don't take this as a personal attack on your script, it's a nice try, believe me we have spent a lot of time researching the internal weather functionality and no amount of scripting will fix this issue until the BI address the internal commands first. We would all love to see synced weather functionality!.

Please read the following ticket for further information and please vote it up.

Edited by [KH]Jman

Share this post


Link to post
Share on other sites
Great work Meatball n co. Can I make a suggestion? I would like to see a snow only version minus the rain for winter maps.

Without pulling apart the entire script the easiest way I can think of to do that would be to edit the Weather Templates array and remove the rain templates from the Possible Weather Forecasts arrays. So, where Overcast could go to [0,1,2,8], remove the 2, so it can never get to Light Rain, same with Light Fog and Light Snow. You'll also have to tweak the parameter settings to not allow the players to pick Rain as an initial forecast if you do that as well.

Jman;2619122']I'm sorry to rain on your parade (excuse the pun) but your script will not sync on clients.

No offense taken :) I guess it's your definition of what 'synch' means. I've tested this script in missions that last a couple of hours with 4-6 people playing and everyone's weather stays the same. It's may not be exact (someone may see rain ten seconds before someone else), but it's worked great for us. JIP clients will start with the most current weather pattern and will be 'caught up' the next weather cycle that goes out to everyone.

As for setWaves, setGusts, setWindForce, setLightning, I just think that's a lot of additional overhead in the script for something the engine does by default when the conditions are right.

I agree though, and I think any weather script is just a kludge until BI truly synchs weather effects real time. In the meantime we just have use scripts to force every client to certain weather parameters at set intervals.

Have you tested it and found it get really out of synch?

Share this post


Link to post
Share on other sites
Without pulling apart the entire script the easiest way I can think of to do that would be to edit the Weather Templates array and remove the rain templates from the Possible Weather Forecasts arrays. So, where Overcast could go to [0,1,2,8], remove the 2, so it can never get to Light Rain, same with Light Fog and Light Snow. You'll also have to tweak the parameter settings to not allow the players to pick Rain as an initial forecast if you do that as well.

No offense taken :) I guess it's your definition of what 'synch' means. I've tested this script in missions that last a couple of hours with 4-6 people playing and everyone's weather stays the same. It's may not be exact (someone may see rain ten seconds before someone else), but it's worked great for us. JIP clients will start with the most current weather pattern and will be 'caught up' the next weather cycle that goes out to everyone.

As for setWaves, setGusts, setWindForce, setLightning, I just think that's a lot of additional overhead in the script for something the engine does by default when the conditions are right.

I agree though, and I think any weather script is just a kludge until BI truly synchs weather effects real time. In the meantime we just have use scripts to force every client to certain weather parameters at set intervals.

Have you tested it and found it get really out of synch?

Hi,

Jman is right, comrade! The nextWeatherChange value has too much of an impact during syncing of weather and will give the clients inconsist weather behaviours no matter hat you try as a workaround, esp. JIP clients! I really just want to save your time, on trying to find workarounds, i lost too much time myself already!

And if all are happy (or dont feel the differences as disturbing) its also good for me!

Just be aware, that we invested weeks to find a solution on that, and its simply down to the current implementation in RV engine. If you read the feedback tracker ticket, there are many really good coders (like Xeno) in it, that confirmed that stuff.

So in case you get a sync issues reported, quick weatherchanges, etc. it may be related to that thing.

Anyways! Im happy that you took the sour pill of getting a MP synced weather done! Really appreciate your work on that, mate!

Share this post


Link to post
Share on other sites

Hey there,

I am trying to get thisr mod to work on my Altis Life Server

Im having some trouble to get it to work on my server, This is how i have applied the script to init.sqf

Init.sqf

---------------------------------------------

enableSaving [false, false];

execVM "scripts\randomWeather2.sqf";

X_Server = false;

X_Client = false;

X_JIP = false;

StartProgress = false;

if(isServer) then

{

if(!X_Server) then

{

[] call compile PreprocessFileLineNumbers "\life_server\init.sqf";

master_group attachTo[bank_obj,[0,0,0]];

};

X_Server = true;

};

if(!isDedicated) then { X_Client = true;};

if(isNull player) then

{

if(!X_JIP && !isServer) then

{

[] spawn (compile PreprocessFileLineNumbers "core\jip.sqf");

};

X_JIP = true;

};

enableSaving[false,false];

life_versionInfo = "Altis Life v3.0.7";

if(X_Client) then

{

[] execVM "core\init.sqf";

};

[] execVM "briefing.sqf"; //Load Briefing

[] execVM "KRON_Strings.sqf";

if(!StartProgress) then

{

[8,true,false] execFSM "core\fsm\core_time.fsm";

};

StartProgress = true;

---------------------------------------------------------

I got the params to appear on the lobby menu, but its stuck on RANDOM

script folder is in the root of my mission file.

Thank you in advance

Devy

Share this post


Link to post
Share on other sites

If the params are set up correctly, you should be able to see them in lobby and adjust them. That being said, I've found in general, you can't update any parameters unless you are logged into the lobby as Admin. You doing that?

Share this post


Link to post
Share on other sites
If the params are set up correctly, you should be able to see them in lobby and adjust them. That being said, I've found in general, you can't update any parameters unless you are logged into the lobby as Admin. You doing that?

I will try that with admin log in

Did i put execVM "scripts\randomWeather2.sqf"; in the right place?

and secondly, does it work without having the params in the description file?

Thank You In advance.

Im on my server and i dont have any weather change.

Share this post


Link to post
Share on other sites

Not sure about the placing in init, I actually have mine later in my missions, after my isServer loops and closer to the end. Also, it should work without the params in the description file, but it will just start with a random weather pattern.

Share this post


Link to post
Share on other sites

really good work, i like it and will test at our server.

for a later Version maybe you can give the Admin a Possibility for a exact Weather start Condition(i.e. Overcast = 0.4 and so on), a Option for the forecast Time and the Possibility to bypass the random Weather. So it can be THE Weather Engine :) and we have all options we need.

Greetings Thunder

Share this post


Link to post
Share on other sites

I _think_ I might have found a bug with the script and was wondering if anyone else using it can verify. Here's the short of it. If you are using any sort of revive (BTC Revive and A3 wounding system for certain) _and_ it's snowing, there might be an issue with the snow generator causing the A3 client to crash to desktop on respawn.

I think it might be a timing issue with the deletion of the snow generator object on a player's corpse when then die and the creation of the new one on the player once they've respawned, but without a bunch of testing I can't be positive. So, is there anyone out there using this weather script and a revive script that's seeing occasional A3 crashes when the player respawns, particularly when it's snowing?

---------- Post added at 04:35 ---------- Previous post was at 02:44 ----------

Just a quick followup. There most definitely is a bug when using snow with revive/respawn. I'm going to hopefully try to pin it down and fix it over the weekend if I can.

Edited by Meatball

Share this post


Link to post
Share on other sites

Also, since you brought up bugs, it was snowing underwater when SCUBA. Just a heads up...

Other than that it seems to work really good on both SP and MP. Way to go. Awesome stuff!

Share this post


Link to post
Share on other sites

Ah, good catch Goblin. I'll roll that fix into the next version, but in the meantime, it's an quick change if you want to update your script.

Change the if statement in line 223 from:

if (roofOverhead)

to:

if (roofOverhead or (underwater _unit)) 

That should stop it from snowing underwater :)

---------- Post added at 20:17 ---------- Previous post was at 20:17 ----------

[/color]New version Release - v0.8!

Changelog:

- Stopped snow from occurring when the player is underwater.

- Found a random crash bug caused by the snow particle effects and revive scripts (think it has to do with the overall Physx Crash Bug). Updated the snow script and it should fix any Crash to Desktop problems you've been having.

Edited by Meatball

Share this post


Link to post
Share on other sites
Guest

Thanks for sending us the updated release :cool:

Release frontpaged on the Armaholic homepage.

================================================

We have also "connected" these pages to your account on Armaholic.

This means in the future you will be able to maintain these pages yourself if you wish to do so. Once this new feature is ready we will contact you about it and explain how things work and what options you have.

When you have any questions already feel free to PM or email me!

Edited by Guest
mirror updated to latest

Share this post


Link to post
Share on other sites

I haven't tried your latest version yet. I played around with your first release and finally discovered why I couldn't change the time of day in my mission intel... the date and time is dependent on your script! It's easy enough to change there too, so everything is right, but you might want to make a note of that on the first post so mission designers aren't scratching their heads trying to figure it out like I was ;)

This new version, with the "roofOverhead" bit, does this mean we no longer have to choose how the snow is seen in vehicles and buildings anymore?

Share this post


Link to post
Share on other sites

Nope, you can still set it up either way. Just set the value of the 'intSnow' variable on line 60. If it's set to 0, which is default, snow will snow when you go in a building, vehicle or under some sort of roof. Or you can set it to 1 and it will always snow around the player (except when under water...)

Could you elaborate a little bit more about what you mean with the date/time deal? The only impact the script should have on time is to skip ahead 24 hours and then back 24 hours as the weather initializes, but it should jump forward/back from any time you set in your mission. Of course, I've only used it in MP missions and I set the time ways other than using the mission intel, so I could be wrong when it comes to that. Unfortunately bumping the time forward/back is the only way to get the cloud cover to move in at mission start at the moment.

Edited by Meatball

Share this post


Link to post
Share on other sites
Nope, you can still set it up either way. Just set the value of the 'intSnow' variable on line 60. If it's set to 0, which is default, snow will snow when you go in a building, vehicle or under some sort of roof. Or you can set it to 1 and it will always snow around the player (except when under water...)

Could you elaborate a little bit more about what you mean with the date/time deal? The only impact the script should have on time is to skip ahead 24 hours and then back 24 hours as the weather initializes, but it should jump forward/back from any time you set in your mission. Of course, I've only used it in MP missions and I set the time ways other than using the mission intel, so I could be wrong when it comes to that. Unfortunately bumping the time forward/back is the only way to get the cloud cover to move in at mission start at the moment.

Whooops!!!! MY BAD! It's not your script I had that problem with... it was another weather script. :o Sorry about that. I'll be giving your new version a run this weekend for sure! Any possibility of having snow only at night at above a certain elevation? I'm mission building on Clafghan and some snow high up in the mountains would be very atmospheric :)

Share this post


Link to post
Share on other sites

Done and done...sorta. ;)

New Release v0.85

Changelog

- Fixed a small problem with the code to disable snow underwater.

- Added in functionality to allow the disabling of snow based on player altitude & day or night cycle. Both are disabled by default but can be enabled on lines 236 - 240.

Edited by Meatball

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

×