Sil Carmikas 45 Posted February 24, 2017 Sil's Simple Random Weather Script "A very simple approach to generating random weather patterns in Arma 3." by Sil Carmikas Version: 1.0 Final setRandomWeather.sqf Description: This is a bit of a mashup using manage_weather.sqf files from the original Liberation 0.924 mission from [GREUH]zBug and [GREUH]McKeewa. The below code will execute within the mission to add random weather pattern generation making use of the newer selectRandom command (Arma 3 Version: 1.56) This does not offer parameter selection for servers, the only customization that can be done is within the SQF file. This is a very basic script I am working with to learn scripting for Arma 3. Anyone is welcome to use this as they see fit. Instructions: Instructions: 1) Place anywhere you see fit, preferably in the root directory of your mission. 2) In your init.sqf, make sure to type in the following: [] spawn compileFinal proprocessFileLineNumbers "setRandomWeather.sqf"; 3) Save your init.sqf, load Arma 3, load the mission and test using setTimeMultiplier. You can decrease the "sleep 900;" command to observe the random changes more frequently for debugging and testing. Download: https://www.mediafire.com/?8mapw7zpwiwspc5 Here is the code below: if (!isServer) exitWith {}; _setRandom = [0,0.1,0.15,0.2,0.25,0.3,0.35,0.4,0.45,0.5,0.55,0.6,0.65,0.7,0.75,0.8,0.85,0.9,0.95,1.0]; // Initial Weather skipTime -24; 0 setOvercast selectRandom _setRandom; // Initial Weather Set Values: 0 = Sunny, clear skies 1 = Stormy, complete overcast skipTime 24; sleep 0.1; // Keep this at or above 0.1, or else simulWeatherSync command will not work properly. simulWeatherSync; // This command will sync the selected weather pattern to appear as it should right away instead of having to wait. // Random Weather while { true } do { 300 setOvercast selectRandom _setRandom; // selectRandom is the new engine solution to BIS_fnc_selectRandom. This will select a random weather pattern from the array in variable _setRandom. Values: 0 = Sunny, clear skies 1 = Stormy, complete overcast. sleep 0.1; }; sleep 900; // Rests for 15 minutes real-life time before selecting new weather pattern. For 24 hour day cycles (1 in-game second = 1 real life second) or whichever you prefer, you will want to update this to make sure weather shifts as appropriate. Changelog: v. 1.0 Final: -Made a variable for the values for the Initial Weather and Random Weather sections = _setRandom -Made both setRain and setFog options available now. Refer to the setRandomWeather.sqf file for instructions on how to add for FPS control. v. 0.3 Beta: -Made setRain entries optional. The script will now automatically select the appropriate rain amounts without any restriction. If you want the restriction still for FPS purposes, then use the "If Then" statements provided in the script comments within the SQF file itself. -Added more options to the setOvercast arrays. This gives an increased range of options for selectRandom to be able to use. v. 0.2 Beta: -Removed setFog entry from Initial Weather section -Changed setFog settings in Random Weather to the following ----> 0 setFog [0, 0, 0]. This update ensures that the fog level is zeroed out, it's intent being to help with FPS issues. -Added selectRandom command to Initial Weather settings to make a more randomized starting weather pattern. Please feel free to do with it as you wish and how you see fit. Tweak it, mod it, break it, anything. I am open to constructive feedback. If there is a better way to do this, please share. I'd like to get as much info available out there for others learning to script as well too for this same type of thing. 2 Share this post Link to post Share on other sites
Guest Posted February 24, 2017 Release frontpaged on the Armaholic homepage. Sil's Simple Random Weather Script v0.1 Share this post Link to post Share on other sites
Jnr4817 215 Posted February 24, 2017 What different fog settings can there be if you wanted to just play an editor mission, like the array for 600 setOvercast selectRandom [0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0]; Currently, it is just zero'd out 300 setFog [0, 0, 0]; Thanks Share this post Link to post Share on other sites
Sil Carmikas 45 Posted February 24, 2017 8 hours ago, Jnr4817 said: What different fog settings can there be if you wanted to just play an editor mission, like the array for 600 setOvercast selectRandom [0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0]; Currently, it is just zero'd out 300 setFog [0, 0, 0]; Thanks Hey there! What you can do is erase this line altogether if you want random fog, i just threw this in to help with FPS issues. The [0, 0, 0] is as follows: FogValue, FogDecay, FogBase. Use these to set your desired fog, using setFog wiki entry for reference. I will be posting an update for this script once i am home from work tonight! EDIT: Sorry i forgot to mention that the 300 part of the '300 setFog [0, 0, 0] tells the game how long it will take the fog to "spawn" in. This will be addressed in my update tonight. Share this post Link to post Share on other sites
Sil Carmikas 45 Posted February 25, 2017 Sil's Simple Random Weather Script v. 0.2 Beta is now available for download. Changelog: v0.2 Beta: -Removed setFog entry from Initial Weather section -Changed setFog settings in Random Weather to the following ----> 0 setFog [0, 0, 0]. This update ensures that the fog level is zeroed out, it's intent being to help with FPS issues. -Added selectRandom command to Initial Weather settings to make a more randomized starting weather pattern. NOTE: If you still want the random fog without any restrictions, just simply remove the setFog line altogether from the script. Anytime random weather pattern is selected, fog level will be selected as well. I have updated the link to download most current version on OP, and am including a link here too. As always, I am open to constructive feedback. If there is a better way to do this, please share! http://www.filedropper.com/fsetrandomweather_1 Share this post Link to post Share on other sites
Guest Posted February 25, 2017 Updated version frontpaged on the Armaholic homepage. Sil's Simple Random Weather Script v0.2 beta Share this post Link to post Share on other sites
Sil Carmikas 45 Posted February 27, 2017 Sil's Simple Random Weather Script v0.3 Beta has been uploaded for distribution. Download Link: Sil's Simple Random Weather Script v0.3 Beta v. 0.3 Beta: -Made setRain entries optional. The script will now automatically select the appropriate rain amounts without any restriction. If you want the restriction still for FPS purposes, then use the "If Then" statements provided in the script comments within the SQF file itself. -Added more options to the setOvercast arrays. This gives an increased range of options for selectRandom to be able to use. OP has been updated as well as changelog. As always, I am open to constructive feedback. If there is a better way to do this, please share! Share this post Link to post Share on other sites
Guest Posted February 27, 2017 Updated version frontpaged on the Armaholic homepage. Sil's Simple Random Weather Script v0.3 beta Share this post Link to post Share on other sites
Sil Carmikas 45 Posted March 1, 2017 Sil's Simple Random Weather Script v1.0 Final has been uploaded for distribution. Download link: Sil's Simple Random Weather Script v1.0 Final v. 1.0 Final: -Made a variable for the values for the Initial Weather and Random Weather sections = _setRandom -Made both setRain and setFog options available now. Refer to the setRandomWeather.sqf file for instructions on how to add for FPS control OP has been updated as well as changelog. As always, I am open to constructive feedback. If there is a better way to do this, please share! Share this post Link to post Share on other sites
Guest Posted March 1, 2017 Updated version frontpaged on the Armaholic homepage. Sil's Simple Random Weather Script v1.0 Final Share this post Link to post Share on other sites
kMaN175 34 Posted March 1, 2017 (edited) Awesome! I've already added your script to a mission I was working on. Thanks for sharing! Hey Sil Carmikas, love the script! Do you know if the 64-bit ArmA going to break it? Edited March 19, 2017 by kman_(kya) Ask about 64-bit ArmA Share this post Link to post Share on other sites
tortuosit 486 Posted April 23, 2017 Hey, thanks for your effort, but the code surprises me ;) - what are you doing? I see you could simply use "random 1" and I see an endless loop in 0.1s steps. !!!???!!! You probably wanted to have the "sleep 900" inside the while loop?! EDIT: Ah you wrote you learn ArmA scripting. Welcome to the world of pain mate mate! Best regards tort Share this post Link to post Share on other sites
Sil Carmikas 45 Posted April 23, 2017 10 hours ago, tortuosit said: Hey, thanks for your effort, but the code surprises me ;) - what are you doing? I see you could simply use "random 1" and I see an endless loop in 0.1s steps. !!!???!!! You probably wanted to have the "sleep 900" inside the while loop?! EDIT: Ah you wrote you learn ArmA scripting. Welcome to the world of pain mate mate! Best regards tort Hey tort! Thank you for the suggestions, this is exactly what I look for! :) So you're saying to take the sleep 900 command and stick it WITHIN the while do loop, right? I'll play with it and see what happens, thanks for the tips! I've been taking a bit of a sabbatical from Arma due to life reasons... but will be returning shortly! ;) ~Sil~ Share this post Link to post Share on other sites
tortuosit 486 Posted April 23, 2017 Yes, you cannot do 0.1 sec. random overcast changes. And your script stays inside the while loop and never meets the sleel 900. But you may rethink all this. Overcast change is very slow. Maybe like 90 minutes from 0 to 1. Don't know exactly. Depending on wind I reckon. No matter what n you set in "n setovercast x", the cloud change needs its time. So: You either force it (forceweatherchange) or your random changes are basically ineffective. Forcing it mid mission is ugly, because abrupt plus fps drop. You can look at my mod, but it's rather complicated. Share this post Link to post Share on other sites
Spiretail 0 Posted June 25, 2023 For anyone trying to get this to work and getting an error at the very beginning, it is because there is a spelling mistake in the init.sqf statement: [] spawn compileFinal proprocessFileLineNumbers "setRandomWeather.sqf"; Try this and it will work. [] spawn compileFinal preprocessFileLineNumbers "setRandomWeather.sqf"; Share this post Link to post Share on other sites