Jump to content
meatball

randomWeather2 Script - Dynamic Weather For A3

Recommended Posts

This new Weather System is great. Thank You! much better than v1. :bounce3: Love It!!!

Once in a while in MP we'll not be in sync, but it seems to be a network/lag/excess addon/standard kinds of things.

Most of the time we're all matched up as close as the game engine will allow (ie basic cloud randomness,etc built in).

I think I may have asked this in the first one. Can't remember... I was wondering if I change/add more Templates,

if we can "stack-the-deck" of sorts so the Randomness is still there, but more realistic other than all the dynamic

updates every few minutes. Guessing you have to keep checking/sending so we stay in sync... But would like to

modify so its mostly Clear and Overcast a good chuck of the time. Is this possible? What if I added alot more Clear

Templates, more Overcast, and maybe a couple more Light Rain.? Would the code below work or break this Script?

weatherTemplates = [
       ["Clear",[0,1,5],[0.30,0,0,1,1]],
	["Clear",[0,1,5],[0.30,0,0,1,1]],
	["Clear",[0,1,5],[0.30,0,0,1,1]],
	["Clear",[0,1,5],[0.30,0,0,1,1]],
	["Clear",[0,1,5],[0.30,0,0,1,1]],
	["Clear",[0,1,5],[0.30,0,0,1,1]],
	["Clear",[0,1,5],[0.30,0,0,1,1]],
	["Clear",[0,1,5],[0.30,0,0,1,1]],
	["Clear",[0,1,5],[0.30,0,0,1,1]],
	["Clear",[0,1,5],[0.30,0,0,1,1]],
	["Overcast",[0,1,2,8],[0.50,0,0,2,2]],
	["Overcast",[0,1,2,8],[0.50,0,0,2,2]],
	["Overcast",[0,1,2,8],[0.50,0,0,2,2]],
	["Overcast",[0,1,2,8],[0.50,0,0,2,2]],
       ["Overcast",[0,1,2,8],[0.50,0,0,2,2]],
       ["Light Rain",[1,2,3,5,8],[0.60,0.3,0.05,3,3]],
	["Light Rain",[1,2,3,5,8],[0.60,0.3,0.05,3,3]],
	["Light Rain",[1,2,3,5,8],[0.60,0.3,0.05,3,3]],
       ["Medium Rain",[2,3,4],[0.70,0.5,0.05,4,4]],
       ["Rainstorm",[3],[0.80,0.9,0.1,5,5]],
       ["Light Fog",[0,2,5,6],[0.4,0,[0.2,0.01,10],0,0]],
       ["Medium Fog",[5,6,7],[0.4,0,[0.4,0.005,20],0,0]],
       ["Dense Fog",[6],[0.5,0,[0.4,0.0025,30],0,0]],
       ["Light Snow",[1,2,8,9],[0.60,0,[0.15,0.01,10],2,2]],
       ["Medium Snow",[8,9,10],[0.70,0,[0.2,0.01,10],3,3]],
       ["Blizzard",[9],[0.80,0,[0.25,0.01,10],4,4]]
];

That way its mostly going to be Clear or Overcast a large chuck of time but still Update/Sync every X minutes?

Share this post


Link to post
Share on other sites

Well, the way the script works is that every 20 minutes, the server picks one of the possible templates from the 'forecasts' array (the first array after the name). For example:

["Clear",[0,1,5],[0.30,0,0,1,1]],
...

That means when the weather is currently set to Clear weather template, when the server goes to make the first weather change it will randomly pick one of the weather templates from Clear's forecast array [0,1,5] as the next weather pattern. The numbers in that forecast array represent the weather patterns themselves, so 0 is Clear again, 1 is Overcast, and 5 is Light Fog. So for Clear, there's a 33% chance the next weather pattern will be one of those. To do what you want you could simply stack the deck. So say you want Clear to stay Clear most of the time you could simply chance the one forecast array for Clear to have more '0's' so it's more likely stay clear as the next weather pattern. Something like this:

["Clear",[0,0,0,0,0,0,0,0,1,5],[0.30,0,0,1,1]],

That means when it's clear and it goes to pick the next weather forecast, it will randomly pick from that new array, with eight 0's, one 1 and one 5, you'd have an 80% of clear weather being picked again (the 0's) for the next forecast, and 10% chance each of Overcast (the 1) and Light Fog (the 5). This is a simpler way to get at what you wanted to do. So you can do what you wanted to do by changing the whole weatherTemplates array to the following:

weatherTemplates = [
       ["Clear",[0,0,0,0,0,0,0,0,0,0,1,5],[0.30,0,0,1,1]],
       ["Overcast",[0,1,1,1,1,2,8],[0.50,0,0,2,2]],
       ["Light Rain",[1,2,2,2,3,5,8],[0.60,0.3,0.05,3,3]],
       ["Medium Rain",[2,3,4],[0.70,0.5,0.05,4,4]],
       ["Rainstorm",[3],[0.80,0.9,0.1,5,5]],
       ["Light Fog",[0,2,5,6],[0.4,0,[0.2,0.01,10],0,0]],
       ["Medium Fog",[5,6,7],[0.4,0,[0.4,0.005,20],0,0]],
       ["Dense Fog",[6],[0.5,0,[0.4,0.0025,30],0,0]],
       ["Light Snow",[1,2,8,9],[0.60,0,[0.15,0.01,10],2,2]],
       ["Medium Snow",[8,9,10],[0.70,0,[0.2,0.01,10],3,3]],
       ["Blizzard",[9],[0.80,0,[0.25,0.01,10],4,4]]
];

As for weather not staying exactly the same on every client...you will see that at times. With the current weather engine there is no way for weather to stay exactly in synch across clients, so what this script (and most of the others) are doing is just telling the client what to set it's weather settings to and where it should move towards, but the client itself actually handles the transition from point A to point B, so weather will not be exact across all the clients. Especially with JIP players, it can be a bit more out of synch because they will often connect and get default settings of the 'current' weather, but everyone else has been moving from the current weather to the new forcecasted weather already for some time.

Imagine it like this. Weather is like a delivery truck. It has to start at point A, and drive to point B in a set amount of time. Say you have 10 delivery trucks (10 connected clients) that all start at the same point (initial weather) with the same final location (forecast weather) in mind, they may not take the exact same route to get to the final location, but they should all arrive there at the same time. :)

I wish there was a way to truly keep client/server weather completely in synch, but unless BI changes weather code so changes are not handed off to be handled by each client as they see fit (or someone can think of a better way), this seems to do the trick for me.

Edited by Meatball

Share this post


Link to post
Share on other sites

Awe man, thats Fantastic! Makes more sense. If I thought about it more I should of saw it. Big thumbs up. :thumb:

Way cool that you can customize that now to match the Map you're on for Weather. Thanks for the detailed explanation.

Went through your code line-by-line quick; very professional and organized. Impressive...

As for the sync. I was aware of the issues. But for anyone who is newer that would really clear-up some things and to

reduce everyone from nit-picking the exact raindrops were off by a minute or two, or the cloud percentage was off

by a few percent or so from each client... I think we had only one or two missions where the weather was completely off.

One had full sun, and the other a rainstorm. No biggie, and it only happened once or twice from other unrelated issues.

Thanks again, and will be always checking in. Great stuff! Over & Out o7

Share this post


Link to post
Share on other sites

Happy you like it. :) Did some more testing tonight, and there still might be some occasional issues with snow causing a crash to desktop on player respawn, but I'm not sure. (Happened twice out of like 100 respawns).

'Snow' is not really real weather, and it's all particle effects, so it's been a bear to work with. Just keep in mind that snow may act a little 'strange' on occasion :)

Share this post


Link to post
Share on other sites

Thanks for the snow tweak! Makes me wonder what it would require to see a visible cloud of steam when breathing? :D

Share this post


Link to post
Share on other sites

I'm sure it's possible, and I recall seeing someone do something like that on some Winter Test over on Steam Workshop, but to be honest, I'm somewhat adverse to doing too much more with Snow primarily because it's such a kludge and particle effects cause so many issues and are so hard to work with.

All this could easily be fixed if BI would just duplicate the rain code for snow and swap out the rain graphics for snow flakes :)

Share this post


Link to post
Share on other sites

Hey, I found a small tweak to the snow effects that I don't think is worth releasing a new version, but folks might be interested in changing in their scripts. If you are leaving the snow disabled indoors you might want to change line 232 from:

roofOverhead = lineIntersects [_unitPos,[_unitPos select 0,_unitPos select 1,(_unitPos select 2)+35]];

to

roofOverhead = lineIntersects [eyePos _unit,[_unitPos select 0,_unitPos select 1,(_unitPos select 2)+35]];

The original one would disable snow _any time_ the player intersected with something. So if you were standing in a corpse, or even bumped into someone, while you were outside it would turn off. The new one at least goes from eye level and up, so it should keep snowing unless you bury your head in something. :)

One other thing, the 'lineIntersects' doesn't recognize glass overhead as actually anything intersecting, so if you sit in the front seat of a hatchback..it'll snow. :)

Sorry for the kludge with Snow, but if someone has a better idea on how to handle it, I'm all ears.

Share this post


Link to post
Share on other sites

New Release v 0.90

Note: the new version is not 'plug and play' if you are using the old version. You will need to update your description.ext file if you are using parameters to allow players to choose weather. See the update information below and installation instructions.

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.

Latest Version:

- Armaholic (Thanks guys!): randomWeather2 Script

Share this post


Link to post
Share on other sites

Hi there!

I think I found a small issue with this script - it's more a glitch on BI's end rather than a fault in your script though.

It took me some time to figure it out, but it seems that a repeated use of the "setWind" command causes some strange things sound-wise. After some time, the wind sfx always starts to behave oddly (especially after loading a saved game); you can hear some kind of static noise coming in & out every x minutes. It is especially noticeable on the right stereo channel - and most of the wind sounds are a bit panned to the right in the stereo range (weird choice, IMO). This also happens with the dynamic weather script for A2 - wich also makes use of the "setWind" command. Might be several audio files playing at the same time.

I disabled all the wind changes on my current mission, and it seems to fix the audio problem.

Just a heads up; that little thing apart, this script is very usefull - I love how easy it is to set your own weather templates!

Thanks for this man!

Share this post


Link to post
Share on other sites

Thanks! I've not run into that, maybe because I've not played super long missions and run into it. Right now I'm really waiting to see what BI does with their 'Client/Server' weather synch setup. I believe I'll be able to just rip out all the client synch pieces and just have this script run and rotate weather on the server if they ever get it working.

Share this post


Link to post
Share on other sites

More details about that audio issue : I did more tests and it seems to happen when a large amount of sound sources are set in the audio options.

For me it occurs at 128 audio sources - switching to 32 sources fixes the problem.

So it's definitely an issue with the way Arma handles sounds.

...Damn, so many broken features in such a good game... T_T

Share this post


Link to post
Share on other sites

Dear Meatball or NeoArmageddon,

Any chance one of you guys might want to put out a simple snow script? No dynamic change, no indoor effects, just swicht it on and enjoy. As far as I understand as long as you don't respawn the snow should work, right?

Cheers,

Surfer

Edited by Surfer

Share this post


Link to post
Share on other sites

+1 for surfers idea, I'm having trouble tweaking the Namalsk weather to be just shitty enough :)

i'd settle for someone pointing me towards a thread for specifically setting the weather through script.

Gav

Share this post


Link to post
Share on other sites

@surf - Neo wrote the bulk of the snow scripting and I just made some tweaks to it. Unfortunately the snow is a bear to deal with because it uses particle effects as opposed to regular weather commands. You should be able to use the version of the script with snow it it to just make it snow continuously by just setting the initial weather pattern to snow and disabling all the code related to updating weather and sending that info out. Though to be honest, after all the work, I just never really felt the snow worked right, there were too many caveats and things that didn't work right (including the crashes) that just really killed the immersion of snow.

@gavC - This whole thread and my script is specifically for setting the weather through script :) Try it out, and it might do what you need.

Share this post


Link to post
Share on other sites

I keep running into an issue with this script, I am sure I am doing something wrong but whenever I run it in a few various missions I have saved off all the variables output "Any"

even with the debug on it just shows "Any" as all the values. Obviously the sample mission you have works just fine and I know its something I have in these but was wondering if you had any ideas as to where to start looking.

p.s. ive tried googling it but the word "any" is really hard to search for

Edited by mckooter

Share this post


Link to post
Share on other sites
I keep running into an issue with this script, I am sure I am doing something wrong but whenever I run it in a few various missions I have saved off all the variables output "Any"

even with the debug on it just shows "Any" as all the values. Obviously the sample mission you have works just fine and I know its something I have in these but was wondering if you had any ideas as to where to start looking.

p.s. ive tried googling it but the word "any" is really hard to search for

Okay, I have finally determined that "Any" means that the variable isnt defined, which is weird, cause it even does it with no modifications (i made a few small tweaks).

My guess is that its not setting the inital weather so somehow its not getting to the update. I am trying to run some tests but so far no luck, i got something wrong

Share this post


Link to post
Share on other sites

Hey mck. Sorry for the delay in responding. I'd almost bet that it has to do with the 'rw2Param' value in the main script and that it does not have the correct parameter number to match your parameters array. Unless you have the class initialWeatherParam as your first parameter in your class Params in your description.ext, you need to change that value in the weather script so it matches the correct one.

---------- Post added at 03:46 ---------- Previous post was at 03:44 ----------

For those of you that are following this thread I'd appreciate your support in my "Altis on Fire" entry to the Make Arma, Not War contest. If you wouldn't mind, head on over to the contest page and support it if you like it!

Thanks!

Share this post


Link to post
Share on other sites

How can I add a parameter specifically telling it to be Dense or Heavy Fog? At the moment when you select Fog it randomly selects one of the possible Fog forecasts whereas I want something more specific if possible? Am a coding noob so help very much appreciated :)

Share this post


Link to post
Share on other sites

Really depends on what you want to do. If you want it to just be Heavy Fog through the entire mission, then I'd probably just not use the script and use the built in weather controls in the mission editor. If you do use the script, regardless what the initial weather is, it will update every so often. If you don't mind it changing, but always want it to start with Dense Fog when that's chosen, just change the "case 3:" line on line 130 to read:

case 3: {rw2_Current_Weather = 7;};

Share this post


Link to post
Share on other sites

No I definitely want the choice of different weather for my mission here. I just think racing in dense fog is a funny challenge. Ideally to give the options of light, moderate or dense fog to race in ;)

But I will try this change, thank you :)

Edit: Tried the change and added in additional cases to give separate fog choices (and made dense fog denser :D). Thanks again for your help :)

Edited by ange1u5

Share this post


Link to post
Share on other sites

Haha, you're back in weather business. I am as well and interesting to see, like you, I am making my old script (which was a derivate of your old cycling between min and max idea) easier and smaller, all prior ideas were too sophisticated, ArmA weather is by far not as flexible as I hoped. But things work out pretty well, I've implanted it in Pilgrimage mission and it's nice. But you see weather related things only after longer play time :)

I'm currently unclear about length of cycles. 30 minutes? 60 minutes? Will a cycle timer restart after forceWeatherChange? nextWeatherChange returns crap values here. Will happily look at your script when I find the time.

Share this post


Link to post
Share on other sites

Cycle time for weather is a possible change every 20 minutes, and if you'd like, you can adjust that by tweaking the sleep values in the 'while {true} loop at the end of the script. Every 20 minutes a weather pattern will be chosen to move to from the current. Each weather pattern has specific patterns that it can move to. For example, if you look at the weather templates, say the current weather pattern is "Partly Cloudy", there's 3 possible patterns it can change to from that, Partly Sunny, Partly Cloudy (Again), and Mostly Cloudy.

Share this post


Link to post
Share on other sites

Is the transition from one weather pattern to another smooth? The reason I ask is that there is nothing more game breaking that seeing the clouds suddenly jerk into a new position.

Share this post


Link to post
Share on other sites

Yes, it's set to transition from the current weather to the new weather over 20 minutes and it doesn't switch all of a sudden. I've been using it in all my missions (check out my sig and try any of the Altis on Fire missions to see them in action) and they work pretty good in my mind. :)

Share this post


Link to post
Share on other sites

Meatball: and does it change the clouds dynamically as well, or only the distant sky colour?

I am lost in A3's weather system. :)

For me it won't change anything sooner than 90 minutes, but it won't change more than 0.1 overcast in less than 30 mins. Or something like this...

Edited by zapat

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

×