Random snow effect

Nvdm

Member
Hey!

I have seen many threads about adding the snow effect. But it is either on or off. I want it to be more random. So I have made a start with some scripts to make it more random. It will probably need some more work, but I hope you guys want to help finish the script.

Here is what I have so far:

Snowcheck.sqf is executed in your missions init.sqf file.

snowcheck.sqf
Code:
// Script executed every 5 minutes to check random snow effect.
 
snowcheck = true;
 
while {snowcheck} do {
nul = [] execVM "random_snow.sqf";
sleep 300;
};

random_snow.sqf
Code:
// Script to check by a random variable if it should snow or not.
 
snowchance = round(random 100);
 
if (snowchance > 70) then {
snow = [] execVM "spawn_snow.sqf";
}
else
{
terminate snow;
};


spawn_snow.sqf
Code:
// Script to create the snow effect.
 
//Snow Storm
//Modified by Audio Rejectz, all credits go to original creators JW - Snow script / BI - Wind & Dust particles
"filmGrain" ppEffectEnable true;
"filmGrain" ppEffectAdjust [0.02, 1, 1, 0.1, 1, false];
"filmGrain" ppEffectCommit 5;
 
stormchance = (random 100);
 
if (stormchance > 1) then {
setviewdistance 600;
bis_fog = 1;
0 setovercast 1;
}
else {
setviewdistance 1000;
bis_fog = 0.6;
};
 
setviewdistance 900;
0 setovercast 0.9;
0 setrain 1;
0 setfog bis_fog;
 
[] spawn {
    _delay = 3;
    sleep 0.01;
    while {true} do {
        _delay  setovercast 0.9;
        _delay  setrain 1;
        _delay  setfog bis_fog;
        sleep _delay ;
    };
};
 
//--- Wind & Dust
[] spawn {
    waituntil {isplayer player};
    setwind [0.201112,0.204166,true];
    while {true} do {
        _ran = ceil random 5;
        playsound format ["wind_%1",_ran];
        _obj = vehicle player;
        _pos = position _obj;
 
        //--- Dust
            setwind [0.201112*2,0.204166*2,false];
        _velocity = [random 10,random 10,-1];
        _color = [1.0, 0.9, 0.8];
        _alpha = 0.02 + random 0.02;
        _ps = "#particlesource" createVehicleLocal _pos;
        _ps setParticleParams [["\Ca\Data\ParticleEffects\Universal\universal.p3d", 16, 12, 8], "", "Billboard", 1, 3, [0, 0, -6], _velocity, 1, 1.275, 1, 0, [9], [_color + [0], _color + [_alpha], _color + [0]], [1000], 1, 0, "", "", _obj];
        _ps setParticleRandom [3, [30, 30, 0], [0, 0, 0], 1, 0, [0, 0, 0, 0.01], 0, 0];
        _ps setParticleCircle [0.1, [0, 0, 0]];
        _ps setDropInterval 0.01;
 
        sleep (random 1);
        deletevehicle _ps;
        _delay = 10 + random 20;
        sleep _delay;
 
    };
};
 
//Snow script
 
setWind [0, -5, true];
 
_obj = player;
 
_pos = position (vehicle _obj);
 
_d  = 15;
_h  = 12;
_h1 = 8;
_h2 = 4;
_density = 20000;
 
 
 
_fog1 = "#particlesource" createVehicleLocal _pos;
_fog1 setParticleParams [
  ["\Ca\Data\ParticleEffects\Universal\universal.p3d" , 16, 12, 13, 0], "", "Billboard", 1, 10,
  [0, 0, -6], [0, 0, 0], 1, 1.275, 1, 0,
  [7,6], [[1, 1, 1, 0], [1, 1, 1, 0.04], [1, 1, 1, 0]], [1000], 1, 0, "", "", _obj
];
_fog1 setParticleRandom [3, [55, 55, 0.2], [0, 0, -0.1], 2, 0.45, [0, 0, 0, 0.1], 0, 0];
_fog1 setParticleCircle [0.001, [0, 0, -0.12]];
_fog1 setDropInterval 0.01;
 
_fog2 = "#particlesource" createVehicleLocal _pos;
_fog2 setParticleParams [
  ["\Ca\Data\ParticleEffects\Universal\universal.p3d" , 16, 12, 13, 0], "", "Billboard", 1, 10,
  [0, 0, -6], [0, 0, 0], 1, 1.275, 1, 0,
  [7,6], [[1, 1, 1, 0], [1, 1, 1, 0.04], [1, 1, 1, 0]], [1000], 1, 0, "", "", _obj
];
_fog2 setParticleRandom [3, [55, 55, 0.2], [0, 0, -0.1], 2, 0.45, [0, 0, 0, 0.1], 0, 0];
_fog2 setParticleCircle [0.001, [0, 0, -0.12]];
_fog2 setDropInterval 0.01;
 
_fog3 = "#particlesource" createVehicleLocal _pos;
_fog3 setParticleParams [
  ["\Ca\Data\ParticleEffects\Universal\universal.p3d" , 16, 12, 13, 0], "", "Billboard", 1, 10,
  [0, 0, -6], [0, 0, 0], 1, 1.275, 1, 0,
  [7,6], [[1, 1, 1, 0], [1, 1, 1, 0.04], [1, 1, 1, 0]], [1000], 1, 0, "", "", _obj
];
_fog3 setParticleRandom [3, [55, 55, 0.2], [0, 0, -0.1], 2, 0.45, [0, 0, 0, 0.1], 0, 0];
_fog3 setParticleCircle [0.001, [0, 0, -0.12]];
_fog3 setDropInterval 0.01;
 
 
while {true} do
{
_a = 0;
while { _a < _density } do
{
_pos = position player;
_fog1 setpos _pos;
_fog2 setpos _pos;
_fog3 setpos _pos;
0 setRain 0;
 
_dpos = [((_pos select 0) + (_d - (random (2*_d))) + ((velocity vehicle player select 0)*1)),((_pos select 1) + (_d - (random (2*_d))) + ((velocity vehicle player select 0)*1)),((_pos select 2) + _h)];
drop ["\ca\data\cl_water", "", "Billboard", 1, 7, _dpos, [0,0,-1], 1, 0.0000001, 0.000, 0.7, [0.07], [[1,1,1,0], [1,1,1,1], [1,1,1,1], [1,1,1,1]], [0,0], 0.2, 1.2, "", "", ""];    _a = _a + 1;
 
 
_dpos = [((_pos select 0) + (_d - (random (2*_d))) + ((velocity vehicle player select 0)*1)),((_pos select 1) + (_d - (random (2*_d))) + ((velocity vehicle player select 0)*1)),((_pos select 2) + _h1)];
drop ["\ca\data\cl_water", "", "Billboard", 1, 7, _dpos, [0,0,-1], 1, 0.0000001, 0.000, 0.7, [0.07], [[1,1,1,0], [1,1,1,1], [1,1,1,1], [1,1,1,1]], [0,0], 0.2, 1.2, "", "", ""];
 
 
_dpos = [((_pos select 0) + (_d - (random (2*_d))) + ((velocity vehicle player select 0)*1)),((_pos select 1) + (_d - (random (2*_d))) + ((velocity vehicle player select 0)*1)),((_pos select 2) + _h2)];
drop ["\ca\data\cl_water", "", "Billboard", 1, 7, _dpos, [0,0,-1], 1, 0.0000001, 0.000, 0.7, [0.07], [[1,1,1,0], [1,1,1,1], [1,1,1,1], [1,1,1,1]], [0,0], 0.2, 1.2, "", "", ""];
 
};
sleep 0.2;
};
 
cant you just tie it in with dynamic weather script ?


what I mean is,

Ive modded my dynamic weather scripts so it does its normal stuff during daylight hours.
Then it has clear, no overcast skies at night.

I was thinking is it possible to merge the script in with it.
 
If you already have dynamic weather in your mission pbo this should add dynamic snow.

It'll be a 1/4 chance when it rains to snow instead.

Change (line 14ish)
Code:
private ["_minimumFog", "_maximumFog", "_minimumOvercast", "_maximumOvercast", "_minimumRain", "_maximumRain", "_minimumWind", "_maximumWind", "_minRainIntervalTimeMin", "_maxRainIntervalTimeMin", "_forceRainToStopAfterOneRainInterval", "_maxWind"];
to this
Code:
private ["_minimumFog", "_maximumFog", "_minimumOvercast", "_maximumOvercast", "_minimumRain", "_maximumRain", "_minimumWind", "_maximumWind", "_minRainIntervalTimeMin", "_maxRainIntervalTimeMin", "_forceRainToStopAfterOneRainInterval", "_maxWind","_snowCheck"];

Add this
Code:
// Turn snow on or off (on = true, off = false)
_snowCheck = true;
under
Code:
// The following variables can be changed to tweak weather behaviour

Change (around line 472)
Code:
private ["_rainTimeSec"];
to
Code:
private ["_rainTimeSec","_snowDucksArray","_snowGoose"];

Add this:
Code:
_snowDucksArray = ["duck", "duck", "goose", "duck"];
                        _snowGoose = _snowDucksArray select floor random count _snowDucksArray;
                        if ((_snowGoose == "goose") && _snowCheck) then {
                            // It's not raining this time
                            drn_var_DynamicWeather_rain = 0;
                            publicVariable "drn_var_DynamicWeather_rain";
                           
                            // Make it snow instead
                            dynSnow = [] execVM "missionfoldername\snow.sqf";
                           
                        };
Under
Code:
else {
                            drn_var_DynamicWeather_rain = 0;
                            publicVariable "drn_var_DynamicWeather_rain";
                           
                            _forceStop = false;
                        };

And add
Code:
                        // If its snowing, kill it
                        terminate dynSnow;
Under
Code:
                    if (drn_var_DynamicWeather_rain != 0) then {
                        drn_var_DynamicWeather_rain = 0;
                        publicVariable "drn_var_DynamicWeather_rain";

If it is over .75 overcast and it chooses to rain, it has a 1/4 chance of snowing instead.
 
Thinking about it I think this
Code:
// If its snowing, kill it
terminate dynSnow;

Needs to be
Code:
// If its snowing, kill it
if (!(isNil(dynSnow))) then {
terminate dynSnow;
};
 
I've added it to my server, and I'm getting no log errors so far after about 3 hours, but it may not have ran yet, and I haven't been on to see if it ever snowed.
 
I've added it to my server, and I'm getting no log errors so far after about 3 hours, but it may not have ran yet, and I haven't been on to see if it ever snowed.

With my Antihack I can set it to storm. Maybe it has a high chance of snowing then. With lots of overcast.
 
As long as it's over .75 overcast and decides to rain then it has a 1/4 chance to snow instead.
Your antihack might just be turning on rain, which won't make a difference. It has to run from the dynamic script.
You might be able to adjust the dynamic to turn up the chance of rain, but I'll just wait and see for mine.

Reason I'm wondering is because none of my script I added will run unless it rains.
I guess I could ask my players later tonight if it snowed at all.
 
After testing this It needs to be ran from the client side. So the dynamic weather will need to use a global variable to say it's on, and then have a script called from the init wait until its called, and terminate it when it's done.

Working with it now.
 
After testing this It needs to be ran from the client side. So the dynamic weather will need to use a global variable to say it's on, and then have a script called from the init wait until its called, and terminate it when it's done.

Working with it now.

I see. Did the snow script get executed at all? Or was there no snow effect?
 
I never seen the snow effect. Modified my dynamic weather to run it 24/7 and it still never showed up, so I blieve it's an issue with the dynamic weather being executed server side instead of client side (from the init)

I tried to make the dynamic weather throw out a global variable and have the script running from the init catch it, but I don't think they dynamic weather script runs often enough to loop through and keep updating itself.

I'm at a loss on where to go from here. I guess keep working on your script on randomizing the snow until someone can come along and figure out how to correctly execute what I was attempting to do.
 
I never seen the snow effect. Modified my dynamic weather to run it 24/7 and it still never showed up, so I blieve it's an issue with the dynamic weather being executed server side instead of client side (from the init)

I tried to make the dynamic weather throw out a global variable and have the script running from the init catch it, but I don't think they dynamic weather script runs often enough to loop through and keep updating itself.

I'm at a loss on where to go from here. I guess keep working on your script on randomizing the snow until someone can come along and figure out how to correctly execute what I was attempting to do.

I have also created the topic on the epoch forums. Somebody also had an idea how to execute:

http://dayzepoch.com/forum/index.php?/topic/3693-adding-random-snow/
 
Yes he is correct too. You can probably pretty easily use a script like yours to randomize it, but until it is added to the dynamic weather it isn't dynamic. It would be snow or no snow.

Did the script you post work?
 
Yes he is correct too. You can probably pretty easily use a script like yours to randomize it, but until it is added to the dynamic weather it isn't dynamic. It would be snow or no snow.

Did the script you post work?

I havent tested it yet. But I think that could work. Just make it execute it every 15 minutes with a chance on snow. I think the problem lies in stopping the snow.
 
Update:

Code:
snowcheck = true;
issnow = false;
 
while {snowcheck} do {
    _snowchance = random 100;
    if (_snowchance > 10) then {
        // no need to start it again if it's already snowing
        if (!issnow) then {
            issnow = true;
        };
    } else {
        // only terminate if actually running
        if (issnow) then {
            issnow = false;
        };
    };
    sleep 300;
};

Code:
_snowgo = true;
 
while {_snowgo} do {
//Snow Storm
//Modified by Audio Rejectz, all credits go to original creators JW - Snow script / BI - Wind & Dust particles
"filmGrain" ppEffectEnable true;
"filmGrain" ppEffectAdjust [0.02, 1, 1, 0.1, 1, false];
"filmGrain" ppEffectCommit 5;
 
setviewdistance 200;
bis_fog = 1;
 
setviewdistance 200;
0 setovercast 1;
0 setrain 1;
//0 setfog 0.8;
0 setfog bis_fog;
 
while {issnow} do {
    _delay = 3;
    sleep 0.01;
    while {true} do {
        _delay  setovercast 0.9;
        _delay  setrain 1;
        _delay  setfog bis_fog;
        sleep _delay ;
    };
};
 
//--- Wind & Dust
while {issnow} do {
    waituntil {isplayer player};
    setwind [0.201112,0.204166,true];
    while {true} do {
        _ran = ceil random 5;
        playsound format ["wind_%1",_ran];
        _obj = vehicle player;
        _pos = position _obj;
 
        //--- Dust
            setwind [0.201112*2,0.204166*2,false];
        _velocity = [random 10,random 10,-1];
        _color = [1.0, 0.9, 0.8];
        _alpha = 0.02 + random 0.02;
        _ps = "#particlesource" createVehicleLocal _pos;
        _ps setParticleParams [["\Ca\Data\ParticleEffects\Universal\universal.p3d", 16, 12, 8], "", "Billboard", 1, 3, [0, 0, -6], _velocity, 1, 1.275, 1, 0, [9], [_color + [0], _color + [_alpha], _color + [0]], [1000], 1, 0, "", "", _obj];
        _ps setParticleRandom [3, [30, 30, 0], [0, 0, 0], 1, 0, [0, 0, 0, 0.01], 0, 0];
        _ps setParticleCircle [0.1, [0, 0, 0]];
        _ps setDropInterval 0.01;
 
        sleep (random 1);
        deletevehicle _ps;
        _delay = 10 + random 20;
        sleep _delay;
 
    };
};
 
//Snow script
 
setWind [0, -5, true];
 
_obj = player;
 
_pos = position (vehicle _obj);
 
_d  = 15;
_h  = 12;
_h1 = 8;
_h2 = 4;
_density = 20000;
 
 
 
_fog1 = "#particlesource" createVehicleLocal _pos;
_fog1 setParticleParams [
  ["\Ca\Data\ParticleEffects\Universal\universal.p3d" , 16, 12, 13, 0], "", "Billboard", 1, 10,
  [0, 0, -6], [0, 0, 0], 1, 1.275, 1, 0,
  [7,6], [[1, 1, 1, 0], [1, 1, 1, 0.04], [1, 1, 1, 0]], [1000], 1, 0, "", "", _obj
];
_fog1 setParticleRandom [3, [55, 55, 0.2], [0, 0, -0.1], 2, 0.45, [0, 0, 0, 0.1], 0, 0];
_fog1 setParticleCircle [0.001, [0, 0, -0.12]];
_fog1 setDropInterval 0.01;
 
_fog2 = "#particlesource" createVehicleLocal _pos;
_fog2 setParticleParams [
  ["\Ca\Data\ParticleEffects\Universal\universal.p3d" , 16, 12, 13, 0], "", "Billboard", 1, 10,
  [0, 0, -6], [0, 0, 0], 1, 1.275, 1, 0,
  [7,6], [[1, 1, 1, 0], [1, 1, 1, 0.04], [1, 1, 1, 0]], [1000], 1, 0, "", "", _obj
];
_fog2 setParticleRandom [3, [55, 55, 0.2], [0, 0, -0.1], 2, 0.45, [0, 0, 0, 0.1], 0, 0];
_fog2 setParticleCircle [0.001, [0, 0, -0.12]];
_fog2 setDropInterval 0.01;
 
_fog3 = "#particlesource" createVehicleLocal _pos;
_fog3 setParticleParams [
  ["\Ca\Data\ParticleEffects\Universal\universal.p3d" , 16, 12, 13, 0], "", "Billboard", 1, 10,
  [0, 0, -6], [0, 0, 0], 1, 1.275, 1, 0,
  [7,6], [[1, 1, 1, 0], [1, 1, 1, 0.04], [1, 1, 1, 0]], [1000], 1, 0, "", "", _obj
];
_fog3 setParticleRandom [3, [55, 55, 0.2], [0, 0, -0.1], 2, 0.45, [0, 0, 0, 0.1], 0, 0];
_fog3 setParticleCircle [0.001, [0, 0, -0.12]];
_fog3 setDropInterval 0.01;
 
 
while {issnow} do {
{
_a = 0;
while { _a < _density } do
{
_pos = position player;
_fog1 setpos _pos;
_fog2 setpos _pos;
_fog3 setpos _pos;
0 setRain 0;
 
_dpos = [((_pos select 0) + (_d - (random (2*_d))) + ((velocity vehicle player select 0)*1)),((_pos select 1) + (_d - (random (2*_d))) + ((velocity vehicle player select 0)*1)),((_pos select 2) + _h)];
drop ["\ca\data\cl_water", "", "Billboard", 1, 7, _dpos, [0,0,-1], 1, 0.0000001, 0.000, 0.7, [0.07], [[1,1,1,0], [1,1,1,1], [1,1,1,1], [1,1,1,1]], [0,0], 0.2, 1.2, "", "", ""];    _a = _a + 1;
 
 
_dpos = [((_pos select 0) + (_d - (random (2*_d))) + ((velocity vehicle player select 0)*1)),((_pos select 1) + (_d - (random (2*_d))) + ((velocity vehicle player select 0)*1)),((_pos select 2) + _h1)];
drop ["\ca\data\cl_water", "", "Billboard", 1, 7, _dpos, [0,0,-1], 1, 0.0000001, 0.000, 0.7, [0.07], [[1,1,1,0], [1,1,1,1], [1,1,1,1], [1,1,1,1]], [0,0], 0.2, 1.2, "", "", ""];
 
 
_dpos = [((_pos select 0) + (_d - (random (2*_d))) + ((velocity vehicle player select 0)*1)),((_pos select 1) + (_d - (random (2*_d))) + ((velocity vehicle player select 0)*1)),((_pos select 2) + _h2)];
drop ["\ca\data\cl_water", "", "Billboard", 1, 7, _dpos, [0,0,-1], 1, 0.0000001, 0.000, 0.7, [0.07], [[1,1,1,0], [1,1,1,1], [1,1,1,1], [1,1,1,1]], [0,0], 0.2, 1.2, "", "", ""];
 
};
sleep 0.2;
}; };
 
It runs in a loop for testing purposes. You can check the effect on 213.19.146.30:2302.

When it snows:
arma2oa_2013_11_16_13_30_33_24.jpg


After snow:
arma2oa_2013_11_16_13_31_12_94.jpg
 
Back
Top