Jump to content
Sign in to follow this  
meatball

randomWeather Script

Recommended Posts

randomWeather Script



Random and Player Selectable Weather for SP/MP Missions

by Meatball

randomWeather.jpg

Description:

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

Features:

- Server will create random and dynamic weather forecasts every 15 minutes and synchronize with clients.

- Parameters available to change initial weather settings.

- Demo Mission available to show weather in action.

Installation:

1) Copy the 'randomWeather.sqf' file 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 "randomWeather.sqf";

3) Add a 'parameter' in your description.ext file to the 'class Params' section:

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

NOTE: If you have multiple parameters in your class Params section and you do not put initialWeather as the first parameter, you must update Line 33 in your randomWeather.sqf file "initialWeather = (paramsArray select 0);" to 'select' the correct parameter number. Remember that 'selecting' from the paramsArray always starts at 0 for the first defined parameter and goes up from there. So if your initialWeather parameter is first in the class Params section, the default "initialWeather = (paramsArray select 0);" will work. If it is second in the list of class Params you'd need to change it "initialWeather = (paramsArray select 1);" and so on. For more information on Parameters, please see the description.ext biki

Changelog:

v0.8

- Public Release

Credits & Thanks:

- Everyone here on the forums for the support and encouragement to figure out the A3 weather.

Latest Version:

- Armaholic Link (Thanks Big!): randomWeather Script

Edited by Meatball

Share this post


Link to post
Share on other sites

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

Congrats on your release. I have a few suggestions.. is it to possible to add in some more types of weather to make the transition between types less dramatic? Although i havent tested your specific script, im sure its similar to how it is currently within our mission edit as this uses the 24 skiptime. With that the biggest bind is that the changes are way to dramatic and noticable, almost light switching a light on and off again.

Would you be able to add cases in such as light cloud, medium cloud,lots of dark clouds and then skip into the rain etc?? So it can be possibly doubled up?

Theory...

sun/ sun /light cloud/ light cloud/dark clouds/ light cloud/ dark cloud/ heavy rain/light rain / light cloud / sun /sun--- and repeat

Thus giving you a typical rainy day and the possibility to create a 24hr weather system??

Please dont take this as a knock, just hoping you can crack this weather system thing as im sure people would like proper weather in any arma mission

Champy_UK

Share this post


Link to post
Share on other sites

There are no drastic transitions that I've seen at all in mine. The only time I use skipTime at all is at mission start and the players don't see any changes, they just start with the proper starting weather. Check out the script and see if it fits what you need. During missions everything just transitions slowly over time and I've played 4+ hour missions and never noticed any choppiness or drastic changes.

Share this post


Link to post
Share on other sites

nice , I' ll add this to my mission :)

I would love this combined to a script for selecting the time of the day :)

are you planning to make one for time of the day too ? :)

Edited by HaZZarD

Share this post


Link to post
Share on other sites

That's actually not that difficult to do and I have it in all my missions. Simply add another parameter to your description.ext class Params section:

   // paramsArray[1]
       class TimeofDayHour {
          title = "Time of Day Hour";
          values[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24};
          texts[] = {"00:00","01:00","02:00","03:00","04:00","05:00","06:00","07:00","08:00","09:00","10:00","11:00",
          "12:00","13:00","14:00","15:00","16:00","17:00","18:00","19:00","20:00","21:00","22:00","23:00","Random"};
          default = 7;

Then in your init.sqf add the following code:

curTimeHour = (paramsArray select 1); //---Read the selected time from the time parameter
if (curTimeHour == 24) then {
curTimeHour = floor(random 24)};
setDate [2035, 7, 4, curTimeHour, 00];

That's it, and you'll have selectable times. The only thing to be wary of is that you only want that to only run for players that are originally connected and not JIP (Join in Progress), if you also run that init.sqf code for JIP players, they'll be out of synch because their time will get reset to the one set in the parameters while the mission may have progressed a few hours since the other players started. Search the forums for JIP/nonJIP code in init.sqf or just rip apart the pbo's for one of my missions and see how I do it :)

Edited by Meatball

Share this post


Link to post
Share on other sites

@Meatball yeah that's the problem , I already have one similar to the one you have but mine too not compatible with JIP

Share this post


Link to post
Share on other sites

Here's some really basic scripts you can use for init.sqf to handle both JIP/Non JIP for time (assuming you have the info for selection of time in your class Params in description.ext) that has been working fine for me.

// JIP Check (This code should be placed first line of init.sqf file)
if (!isServer && isNull player) then {isJIP=1;} else {isJIP=0;};

if(isJIP == 0) then {
//Non JIP players code
curTimeHour = (paramsArray select 2); //---Read the Time
if (curTimeHour == 24) then {
curTimeHour = floor(random 24)};
setDate [2035, 7, 4, curTimeHour, floor(random(30))];
} else {
//JIP players code
waituntil {!isnull player};

};

JIP players will just synch naturally on connect with the server time.

Share this post


Link to post
Share on other sites

your first code works great

description.ext

briefingName="COOP/PvP Capture The Officer";
author="HaZZarD";  //appears as author in overview and loading screen
overviewText="A Persian officer is somewhere in the city of Kavala. Capture him and bring him back for the interrogation."; //appears in overview and loading screen
onLoadName="*Capture The Officer*"; //mission name for loading screen only
overviewPicture="manhunt.jpg"; //mission picture for loading screen only
onLoadMission = "Good training and Have Fun !";
onLoadMissionTime = True;
loadScreen = "manhunt.jpg";
enableDebugConsole = 2;




respawn = "BASE";
respawnDelay = 90;
disabledAI = 1 ;
respawnTemplatesWest[] = {,"MenuPosition","Spectator"};





class Header
{
 gameType = COOP;
 minPlayers = 1;
 maxPlayers = 16;
};

class CfgMusic
{
tracks[]={};
class music1
{ name = "ACDC"; sound[] = {"\music\introz.ogg", db+10, 1.0};
};
class music2
{ name = "MiamiVice"; sound[] = {"\music\mid.ogg", db+10, 1.0};
};
class music3
{ name = "Rock"; sound[] = {"\music\theend.ogg", db+10, 1.0};

};
}; 



class CfgIdentities
{
class Wardak

{
	name="Wardak";
               nameSound = "Wardak"; 
	face="PersianHead_A3_02";
	glasses="G_Aviator";
	speaker="Male01PER";
	pitch=1.1;
};

class Habibi

{
	name="Habibi";
               nameSound = "Habibi"; 
	face="PersianHead_A3_03";
	glasses="G_Aviator";
	speaker="Male02PER";
	pitch=1.1;
};


};

debriefing =1;
class CfgDebriefing
{

class End1
{
	title = "Mission canceled";
	subtitle = "officer KIA";
	description = "The officer has been killed in action , our mission is revoked";
               pictureBackground = "kia.jpg";
	picture = "b_inf";
	pictureColor[] = {0.0,0.3,0.6,1};
};

class End2
{
	title = "Mission Completed";
	subtitle = "";

               pictureBackground = "officer1.jpg";
	picture = "b_inf";
	pictureColor[] = {0.0,0.3,0.6,1};description = "The officer is captured and secured by NATO forces , our allies will proceed with the interrogation";
};

};

class Params
{

class TimeofDayHour {
          title = "Time of Day Hour";
          values[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24};
          texts[] = {"00:00","01:00","02:00","03:00","04:00","05:00","06:00","07:00","08:00","09:00","10:00","11:00",
          "12:00","13:00","14:00","15:00","16:00","17:00","18:00","19:00","20:00","21:00","22:00","23:00","Random"};
          default = 4;  
 };




   class initialWeather {
       title = "initialWeather";
       values[] = {1,2,3,4,5,6,7};
       texts[] = {"Clear","Overcast","Light Rain","Heavy Rain","Light Fog","Heavy Fog","Random"};
       default = 1;

};

class MapUpdate
   {
       title = "officer marker refresh time";
       values[] = {0, 10, 30, 60, 120, 300, 300000};
       texts[] = {"Constant", "10 Seconds", "30 Seconds", "1 Minute", "2 Minutes", "5 Minutes", "Never"};
       default = 10;
   };

};



#include "taw_vd\dialog.hpp"
#include "ATM_airdrop\dialog.hpp"
#include "VAS\menu.hpp"
#include "VVS\menu.h"

class CfgFunctions
{

#include "VAS\cfgfunctions.hpp"
#include "VVS\Functions.h"
#include "taw_vd\CfgFunctions.hpp"


class new
{
	class loadout
	{
		class loadout { file = "loadout.sqf" };
	};
};

};


	class RscPicture 
{
type = CT_STATIC;
idc = -1;
style = 48;
colorBackground[] = {0, 0, 0, 0};
colorText[] = {1, 1, 1, 1};
font = "PuristaMedium"; //Typeface
sizeEx = 0;
};

class RscTitles 
{
#include "=BTC=_Logistic\=BTC=_Lift\=BTC=_Hud.h"
};



init.sqf (with this init it works)

curTimeHour = (paramsArray select 0); //---Read the selected time from the time parameter
if (curTimeHour == 24) then {
curTimeHour = floor(random 24)};
setDate [2035, 7, 4, curTimeHour, 00];  

;  


execVM "randomWeather.sqf";


titleText [" *C A P T U R E   T H E   O F F I C E R*   \n\n\n\n mission made by HaZZarD", "BLACK FADED", 0.5];


call compileFinal preprocessFileLineNumbers "FAR_revive\FAR_revive_init.sqf";

_logistic = execVM "=BTC=_Logistic\=BTC=_logistic_Init.sqf";

but the last code , the one about JIP wont work for me , maybe I made some mistake . description is same as above while the init is :

init.sqf (not working)

// JIP Check (This code should be placed first line of init.sqf file)
if (!isServer && isNull player) then {isJIP=1;} else {isJIP=0;};

if(isJIP == 0) then {
//Non JIP players code
curTimeHour = (paramsArray select 0); //---Read the Time
if (curTimeHour == 24) then {
curTimeHour = floor(random 24)};
setDate [2035, 7, 4, curTimeHour, floor(random(30))];
} else {
//JIP players code
waituntil {!isnull player};

};  



execVM "randomWeather.sqf";


titleText [" *C A P T U R E   T H E   O F F I C E R*   \n\n\n\n mission made by HaZZarD", "BLACK FADED", 0.5];


call compileFinal preprocessFileLineNumbers "FAR_revive\FAR_revive_init.sqf";

_logistic = execVM "=BTC=_Logistic\=BTC=_logistic_Init.sqf";



Share this post


Link to post
Share on other sites

Thank Meatball, i have been waiting for a proper weatherscript for a while now. Will go ahead and test this straight away :)

Blue skies: be gone!

:)

Share this post


Link to post
Share on other sites

So i'm running with this now, and tested twice (only me in a dedicated server)

- random weather works great on start-up

- however after that i get stuck with rain for at least 2 hours ?

Share this post


Link to post
Share on other sites

yea i tested this earlier as well. Same as kamaradski. The initial startup weather works fine, its just it does not seem to want to change off that. I tried to run the debug as well and it does not show hints either.

this was tested locally on the multiplayer editor. I have not tried it on our dedicated yet.

Share this post


Link to post
Share on other sites

Let me explain a little bit what the code is doing and then I'll dive into some of the questions. When you choose a starting weather in your parameters the code will pick some default starting values for all the primary weather settings including Overcast, Rain, Fog and Wind. All the values range from 0 to 1, with 0 being 0% of that weather setting and 1 being 100% of that weather setting. The exception is Wind. Wind has two variables, EW and NS wind. A negative value will blow one direction for that wind and positive the opposite. Those numbers are also in meters/second of windspeed, so they are not limited to the 0-1 range like the others. A 5,5 wind will create a wind that blows 5 m/s in a NE direction while a -5,-5 will blow 5 m/s in a SW direction.

I've experimented a bit and tried to pick what I think are good starting values for all these based on my testing, but you can easily tweak the values in the switch section in lines 35-41 if you'd like to lower or raise any of starting values for them.

Once those default values are set, every 15 minutes the server will set a forecast target for each of those values up or down from the current value. For Overcast and Rain at most it can change is up or down .1 (10%) every 15 minute. Fog is up or down .05 (5%) and wind is up or down .5 (.5 m/s). The game will then set that value for the server and then synch that to the clients and over the next 15 minutes the weather should transition to that new number.

Here's the rub though. A3's weather is still a bit wonky. First, no matter what you do with the rain value, the engine may still force it to rain anytime the overcast gets above .5 (50%). To be honest, I probably shouldn't even try to adjust rain levels other than at game start and just let the engine handle it based on overcast levels. I'll experiment a bit with things for the next version.

The second problem is what I think is the major culprit of the rain that doesn't seem to stop. For reason Arma 3 will transition weather values to a higher value _much_ faster than it will transition to a lower value. If you start with an overcast value of 0 (0%) and set it to change to 1 (100%), it will transition up approximately .01169 per minute, or 1.17%. So, you can theoretically push the engine to go up from 0% to 100% overcast in about 85.5 minutes. On the other hand, if you start with a value of 1 (100%) and set to to change to 0 (0%), the transition occurs at a much slower rate along the lines of .005025 per minute, or 0.502%. This means the fastest you can theoretically push the engine down from 1 to 0 is in a 199 minutes. So it takes almost 2.5x as long to lower overcast as it does to to lower it.

I have seen rain stop on occasion, but I think the primary reason we see rain that usually doesn't let up is just due to the fact that the engine won't transition the overcast value down fast enough. So with my script, and the max of 40% up or down change in overcast over an hour, the engine will ramp the overcast up 40% in an hour without a problem, but going down the most it could do is 30%. Both of those assume that all four random numbers generated in an hour are their max value, which there's no way they are. It's probably more likely in an hour that you don't really see any changes due to the fact that a random value could just as easily be .0001 as it could be .1 and the next random one could be a negative .0001 to .1 that offsets it.

I may be able to set something up so it will double the rate of drop when it's going down, but in the meantime I'm somewhat at the whim of A3's crazy weather. :)

---------- Post added at 01:25 ---------- Previous post was at 01:21 ----------

Oh, and as for the debug hints not showing up. You will not see the server hints on a dedicated server, as you're not the server :) The only time you can see the server hints is if you are hosting a game yourself. On the other hand if you uncomment the client debug hint, you should see that as a client connected to a dedicated server or someone else's hosted server. If you really want to watch what's going on, copy/paste the proper debug hint (Server if your hosting it on your machine, client hint if your doing it on a dedicated or someone else's hosted machine) into a repeatable radio Trigger in the mission. Then you can check the exacts of what's going on as much as you want with the radio hint.

Edited by Meatball

Share this post


Link to post
Share on other sites

good on you mate for this post. this clarifies a lot of what my curiosities were. Thanks much!

Share this post


Link to post
Share on other sites

Indeed this clarifies a lot, specially since i have followed your other thread in the past.

Weather in Arma is a bit of a nightmare, and i am very surprised that BIS is not addressing this issue so far. For know we can only be happy that people like Meatball and Engima are taking this task upon themselves and give us some good weather :) So thanks for that already !!

As for the debug-hints 3djoker, you might be able to add the content of each debug hint in a string, (str), sync this over the network (publicVariable) and add a little !isserver script with a event handler to display the hints.

Share this post


Link to post
Share on other sites

One other thing I forgot to mention is in the code every time there's an 'update' to the forecast, there is a 50/50 chance of whether Overcast or Rain is updated during that update. Reason being, another little 'strangeness' to the A3 weather is that you can't update both Rain and Overcast in the same update. Why? I don't know, but apparently it was this way in A2 as well.

Appreciate the feedback, questions and comments. Certainly hope to get some time in the next week or so to dig into the code again and see what I can do to clean stuff up and tweak it a bit.

Share this post


Link to post
Share on other sites

Would be kinda neat to see this change, based on the METAR data of Limnos Int'l, much in the style FSX does it. I don;t know enough about the weather scripting to know if that's feasible, but it's something I've been mulling over so I thought I'd throw it out there. Maybe someone smarter than I am can run with it. Tsk tsk!

Edit: Looking into it, not a whole lot of data is shared by the METAR for Lemnos. Be good for clouds and wind, that's about it.

Edited by Adombom

Share this post


Link to post
Share on other sites
Indeed this clarifies a lot, specially since i have followed your other thread in the past.

Weather in Arma is a bit of a nightmare, and i am very surprised that BIS is not addressing this issue so far. For know we can only be happy that people like Meatball and Engima are taking this task upon themselves and give us some good weather :) So thanks for that already !!

As for the debug-hints 3djoker, you might be able to add the content of each debug hint in a string, (str), sync this over the network (publicVariable) and add a little !isserver script with a event handler to display the hints.

Not addressing it? They are working on the 30+ weather related simul scripting commands.

---------- Post added at 06:48 ---------- Previous post was at 06:39 ----------

Arma 3 uses Truesky weather simulation software:

ttp://www.youtube.com/watch?v=pnvBF5Nu5gw

I would not say Arma 3 weather is bad. Just that it is not finished yet and will likely look like the video when completely done.

---------- Post added at 06:56 ---------- Previous post was at 06:48 ----------

Wanna play with the highly WIP simul weather scripting commands?

Caution, the simul commands are all still local like all the other weather is.

Here is either most of or just few of the scripting commands:

simulCloudDensity	 simulCloudOcclusion	 simulInClouds
simulSetAlphaSharpness	 simulSetAmbientLightResponse	 simulSetAtmosphereThickness
simulSetCentreX	 simulSetCentreY	 simulSetCloudBaseZ
simulSetCloudHeight	 simulSetCloudLength	 simulSetCloudWidth
simulSetDiffusivity	 simulSetExtinction	 simulSetFog
simulSetFractalAmplitude	 simulSetFractalWavelength	 simulSetGridHeight
simulSetGridLength	 simulSetGridWidth	 simulSetHaze
simulSetHazeBaseHeightKm	 simulSetHazeScaleHeightKm	 simulSetHelperDetail
simulSetHelperGrid	 simulSetHelperNearCloudFade	 simulSetHumidity
simulSetLightDetail	 simulSetLightResponse	 simulSetMieAsymmetry
simulSetMieEccentricity	 simulSetMinimumLightElevationDegrees	 simulSetNoiseOctaves
simulSetNoisePeriod	 simulSetNoisePersistence	 simulSetNoiseResolution
simulSetOpticalDensity	 simulSetOvercast	 simulSetOvercastBaseKm
simulSetOvercastRangeKm	 simulSetRandomSeed	 simulSetSecondaryLightResponse
simulSetSelfShadowScale	 simulSetThinLayer	 simulSetWrap
simulWeatherSync    setsimulweatherrendermode    Simulloadseq

And you said Arma 3's weather was bad and the developers weren't doing enough?

Edit: More info and possibly some scripting commands I missed: http://forums.bistudio.com/showthread.php?162909-Secret-SimulWeather-commands/page3

---------- Post added at 07:05 ---------- Previous post was at 06:56 ----------

Other scripting commands related to weather:

setRainbow    rainbow    setWindDir    setWindStr    setWindForce    setWaves   
setLightnings     lightnings    setFog    setGusts    gusts    humidity    setHumidity

Believe me when I say there is a 100% chance that I have not listed all weather related commands.

Edited by ProGamer

Share this post


Link to post
Share on other sites
Not addressing it? They are working on the 30+ weather related simul scripting commands.

To be honest, almost all the simulSet commands are relatively useless from the perspective of a us trying to develop weather scripts to create and synchronize weather patterns between machines. There's very little documentation on the simul commands and they actually do. I'm sure they're used to great effect in the back end for things like cloudHeight, thicknees, diffusion, etc., but none of those are things that really matter when all we want is to 'fill the sky with x% of clouds and make everyone's machine do that."

As for the other commands, some of them are useful and are being used by the weather scripts I've made and I've seen others make. Waves, Lightning and Rainbow are relatively unneeded for scripts because the engine handles those on the backend, setHumidity doesn't exist anymore, and the replacement simulSetHumidity has been removed. So basically all scripts are working with just setWind, setOvercast, setRain and setFog and that's about it. Those all work great with the major caveat that weather between clients and servers will not be synchronized.

I think Arma has awesome looking weather, but the fact that it's not synchronized between servers/clients and we need to come up with scripts is a mistake that should have been fixed back in Arma or Arma 2. But since it's not, we have to try to figure out how weather works and come up with the scripts ourselves, and they won't be perfect.

Edited by Meatball

Share this post


Link to post
Share on other sites

Yeah sure the weather looks nice but usualy its like this : "sneaking thru a forest with your platoon... Oh no it started raining with fog says one person, oh well i guess u wont see anything in this engagement couse we all have sunshine and 2km clear view"

How good it looks dosent really matter couse all you can play is either full on rain the entire time or full sunshine all the time to use changeing weather in your mission is just a big no no.

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  

×