Jump to content

Adding random snow


AceOfSpades

Recommended Posts

Hey guys,

 

I have seen many topics about adding a random snow effect. The script to make is snow it already there. But it is always snowing or not snowing. There isn't a script to make it more random. So I have tried something but it does not seem to work.

 

I dont know how I can make sure this script keeps getting executed.

 

I have come up with something like this:

snowingchance = 2;

while {snowingchance > 1} do {
snowchance = round(random 100);
diag_log (""THE SNOWCHANCE IS"" + (snowchance));
if (snowchance > 1) then {
diag_log (""THE SNOWCHANCE IS TRUE"");
};
sleep 5;
};

while {snowchance > 1} 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;

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;
};
};

Maybe there is a problem with the while loops. It works because if starts snowing. But it does not stop snowing.

 

Anyone could help me to find out where the problem is?

Link to comment
Share on other sites

I guess the while-loop with "//Snow Storm" is the actual snow script, right?

I would suggest to do a background daemon to run the script and check in regular intervals if it should stop snowing or start again (only every 5+ minutes not to often of course).

You could just stop the script execution with "terminate" (http://community.bistudio.com/wiki/terminate).

I am no arma scriping expert but it looks like you would like to run the 2 while loops at the same time, thats doesn't work in the same thread, you could also start one with "spawn" (http://community.bistudio.com/wiki/spawn)! :D

Just some ideas, I didn't test anything xD

 

One problem might be that the snow script already spawns some background threads.. so I don't know if terminate would also kill those or you have to do it yourself.

To me it doesn't look like the script is made to be stopped in that way, I guess it can be redone to be stoppable but not without changing the code of the original snow script.

Edited by Axe Cop
Link to comment
Share on other sites

I guess the while-loop with "//Snow Storm" is the actual snow script, right?

I would suggest to do a background daemon to run the script and check in regular intervals if it should stop snowing or start again (only every 5+ minutes not to often of course).

You could just stop the script execution with "terminate" (http://community.bistudio.com/wiki/terminate).

I am no arma scriping expert but it looks like you would like to run the 2 while loops at the same time, thats doesn't work in the same thread, you could also start one with "spawn" (http://community.bistudio.com/wiki/spawn)! :D

Just some ideas, I didn't test anything xD

 

One problem might be that the snow script already spawns some background threads.. so I don't know if terminate would also kill those or you have to do it yourself.

To me it doesn't look like the script is made to be stopped in that way, I guess it can be redone to be stoppable but not without changing the code of the original snow script.

 

Thx for your reply. I noticed that the dynamicweather.sqf keeps running regardless of the snow script. So I think I only have to find a way to kill the snowflakes and restore the viewdistance.

 

I can create a script with a while loop which is executed on server start. While true execute snow.sqf.

 

In snow.sqf is can create an if statement checking of the value is still true if it is then execute spawn_snow.sqf with the snow script. else terminate spawn_snow.sqf.

And I hope nothing is spawned on the background for this. And of course the background daemon which keeps executing this script every 5 minutes or so.

 

Could this in theory work?

 

--- Update:

 

Something like this.

 

snowcheck.sqf

// 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

// 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

// 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;
};
Link to comment
Share on other sites

Looks a little weird, I guess that will need some modifications :P

 

first: a single loop would be sufficient for this I guess, why are you using 2 files to just start the script? :D

I changed it a little to combine your first 2 scripts to this (not tested):

snowcheck = true;
_snow = nil;
while {snowcheck} do {
	_snowchance = random 100;
	if (_snowchance > 70) then {
		// no need to start it again if it's already snowing
		if (isNil "_snow") then {
			_snow = [] execVM "spawn_snow.sqf";
		};
	} else {
		// only terminate if actually running
		if (!isNil "_snow") then {
			terminate _snow;
			_snow = nil;
		};
	};
	sleep 300;
};

That should be better, with your solution you might start multiple snow script at once, because you never check if it is already running, so you can't terminate the scripts again!

 

second: spawn_snow.sqf spawns some threads itself (look where is says "spawn" in the file), I don't know if that terminate command will also kill those backgrounds threads within the script, maybe not, so you have to do that yourself..

 

I don't think this is a good script to start learning ArmA Scripting or programming in general, just saying you need to understand some of the concepts first. 

 

And I give you this advice, NEVER assign anything to "nil" or "null", that will break the whole server and lots of other mods will produce errors or crash becaus of that! :D

You didn't do that actually but look very close here: "nul = [] execVM "random_snow.sqf";". Some scripts do "_nil = .." thats ok, all variables that start with "_" are private to that script only in ArmA so you cannot damage other scripts with that.. if your just use variables names like "ok = ..." they will be global and you might override something in other scripts or other scripts override your values and then good luck finding that error!  :D

Link to comment
Share on other sites

Looks a little weird, I guess that will need some modifications :P

 

first: a single loop would be sufficient for this I guess, why are you using 2 files to just start the script? :D

I changed it a little to combine your first 2 scripts to this (not tested):

snowcheck = true;
_snow = nil;
while {snowcheck} do {
	_snowchance = random 100;
	if (_snowchance > 70) then {
		// no need to start it again if it's already snowing
		if (isNil "_snow") then {
			_snow = [] execVM "spawn_snow.sqf";
		};
	} else {
		// only terminate if actually running
		if (!isNil "_snow") then {
			terminate _snow;
			_snow = nil;
		};
	};
	sleep 300;
};

That should be better, with your solution you might start multiple snow script at once, because you never check if it is already running, so you can't terminate the scripts again!

 

second: spawn_snow.sqf spawns some threads itself (look where is says "spawn" in the file), I don't know if that terminate command will also kill those backgrounds threads within the script, maybe not, so you have to do that yourself..

 

I don't think this is a good script to start learning ArmA Scripting or programming in general, just saying you need to understand some of the concepts first. 

 

And I give you this advice, NEVER assign anything to "nil" or "null", that will break the whole server and lots of other mods will produce errors or crash becaus of that! :D

You didn't do that actually but look very close here: "nul = [] execVM "random_snow.sqf";". Some scripts do "_nil = .." thats ok, all variables that start with "_" are private to that script only in ArmA so you cannot damage other scripts with that.. if your just use variables names like "ok = ..." they will be global and you might override something in other scripts or other scripts override your values and then good luck finding that error!  :D

 

Thanks for your reply. Learned some more about the variables :D. Well I would first like to make it snow randomly, then I will try to make it stop snowing :D. But what command is used to kill a spawned thread? I did a quick look at the bistudio website but could not find anything useful yet.

Link to comment
Share on other sites

Maybe don't use "terminate" at all, it is better to exit  threads with a global trigger variable like "StopSnow = true" and you just exit all threads with that.

There are infinite while-loops in the spawned threads, so instead of "while {true}", change it to "while {!StopSnow}" or something like that and they will all exit after the delay/sleep at least, that should be a better solution and no need for terminate at all (terminating threads is bad, don't know how that is handled in ArmA scriping but usually you don't want to do that.  :)

Link to comment
Share on other sites

Maybe don't use "terminate" at all, it is better to exit  threads with a global trigger variable like "StopSnow = true" and you just exit all threads with that.

There are infinite while-loops in the spawned threads, so instead of "while {true}", change it to "while {!StopSnow}" or something like that and they will all exit after the delay/sleep at least, that should be a better solution and no need for terminate at all (terminating threads is bad, don't know how that is handled in ArmA scriping but usually you don't want to do that.  :)

 

You mean in the snow script itself? So generating a publicvariable in the execute script and a while loop checking the value of that public variable in the while loop in the spawn script?

Link to comment
Share on other sites

You mean in the snow script itself? So generating a publicvariable in the execute script and a while loop checking the value of that public variable in the while loop in the spawn script?

Yeah, that is one of the good parts of ArmA scriping, global variables are known in every script! :D

so all variables not starting with "_" are usually global and can be accessed and changed in any script!

http://community.bistudio.com/wiki/Variables

The wiki is pretty good, but it doesn't teach you anything about programming, so it is just a good reference to all functions and ArmA scriping

Link to comment
Share on other sites

Yeah, that is one of the good parts of ArmA scriping, global variables are known in every script! :D

so all variables not starting with "_" are usually global and can be accessed and changed in any script!

http://community.bistudio.com/wiki/Variables

The wiki is pretty good, but it doesn't teach you anything about programming, so it is just a good reference to all functions and ArmA scriping

 

I have worked out something really fast. I do not know if the while loops in the snow script will work.

snowcheck = true;
issnow = false;

while {snowcheck} do {
	_snowchance = random 100;
	if (_snowchance > 70) 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;
};
_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;
};
};
Link to comment
Share on other sites

Random snow V1

 

This is the first release of the random snow script.

 

Create a file called snow.sqf in the directory custom in your missions.pbo.

_snowrun = true;
snow = nil;
 
while {_snowrun} do {
        _snowchance = random 100;
        if (_snowchance > 75) then {
                if (isNil "snow") then {
                        snow = [] execvm "custom\spawn_snow.sqf";
                };
        }
        else {
                if (!isNil "snow") then {
                        terminate snow;
                        snow = nil;
                        sleep 20;
                        setviewdistance 1600;
                        0 setfog 0.3;
                        0 setovercast 0.6;
                };
        };
sleep 900;
};

 

Copy the following file and rename it to spawn_snow.sqf and place it in the same folder.

Not created by me, credits: Audio Rejectz

 

http://opendayz.net/threads/adding-snow-to-your-server.12523/

 

//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 900;
bis_fog = 0.8;
 
setviewdistance 900;
0 setovercast 0.9;
0 setrain 1;
//0 setfog 0.8;
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;
};

 

In your init.sqf add to following to the bottom of the file:

if (!isDedicated) then {
[] execvm "custom\snow.sqf";
};

 

Now copy the fn_temperatur.sqf from your dayz_code.pbo into the custom folder. Edit your compiles.sqf to make it execute "custom\fn_temperatur.sqf".

 

Add the following to your fn_temperatur.sqf.

 

After

        _water_factor          =      -35;
        _rain_factor            =      -8;
        _night_factor          =      -4.5;
        _wind_factor            =      -1;

 

Add

        _snow_factor            =      -20;

 

And after

        //rain
        if(_raining && !_isinvehicle && !_isinbuilding) then {
                _difference = _difference + (rain * _rain_factor);
        };

 

Add

        //snow
        if (!isNil "snow" && !_isinvehicle && !_isinbuilding) then {
                _difference = _difference + _snow_factor;
        };

 

This way every 15 minutes there is a 25% chance of snow. When it snows the temperature will drop fast. If the player is inside a house of a car, the regular values are used. When outside the snow_factor is used.

 

Goodluck clear.png.

Link to comment
Share on other sites

Am so glad you added the inBuilding and inVehicle part :) I remember the original of this would snow inside a house..

 

It still does. This is only for the temperature. I am now working on disabling snow in in houses and cars.

 

But this is just V1, and other people can play around with it now. :)

Link to comment
Share on other sites

Nice work! :)

Just one note: since this script is only client side, every player will have different snow effects! some players may see the snow while others don't, just to clarify this is bad for the balance of a PvP server or just might look weird if you run around with a group and only some are in a snow storm :D

 

So you should at least sync WHEN it's snowing on the server, so it's the same for everyone, maybe not exactely the same but at least better than completely random for every player?

Link to comment
Share on other sites

Nice work! :)

Just one note: since this script is only client side, every player will have different snow effects! some players may see the snow while others don't, just to clarify this is bad for the balance of a PvP server or just might look weird if you run around with a group and only some are in a snow storm :D

 

So you should at least sync WHEN it's snowing on the server, so it's the same for everyone, maybe not exactely the same but at least better than completely random for every player?

 

Good thinking! How is the syncing done?

 

Maybe the server can set the snowchance (random 100) and send this value to the clients. Then all clients have the same digit to check against the script?

 

if(isServer)then{

snowchance = random 100;

};

Link to comment
Share on other sites

Well to make it easy at first I would say let the snow.sqf script run on the server and send "snowBegin" and "snowStop" events or something like that to the clients, so all clients know when it should be snowing..

to make it better your should generate all random values on the server and send it them to all clients but since you have many random values in the scripts thats not so easy I guess.. but then it would be the same snow effects on all clients.

 

You can use pulicVariable to send a message to all clients from the server: http://community.bistudio.com/wiki/publicVariable

Link to comment
Share on other sites

Well to make it easy at first I would say let the snow.sqf script run on the server and send "snowBegin" and "snowStop" events or something like that to the clients, so all clients know when it should be snowing..

to make it better your should generate all random values on the server and send it them to all clients but since you have many random values in the scripts thats not so easy I guess.. but then it would be the same snow effects on all clients.

 

You can use pulicVariable to send a message to all clients from the server: http://community.bistudio.com/wiki/publicVariable

 

Thank you for your reply. I am think if something like this:

_snowrun = true;
snow = nil;
 
while {_snowrun} do {
        If (isServer) then {
        snowchance = random 100;
        };
        if (snowchance > 75) then {
                if (isNil "snow") then {
                        snow = [] execvm "custom\spawn_snow.sqf";
                };
        }
        else {
                if (!isNil "snow") then {
                        terminate snow;
                        snow = nil;
                        sleep 20;
                        setviewdistance 1600;
                        0 setfog 0.3;
                        0 setovercast 0.6;
                };
        };
sleep 900;
};

Is this the what you mean?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×
×
  • Create New...