Jump to content

Adding random snow


AceOfSpades

Recommended Posts

Untested:

if (isServer) then {
	_snowrun = true;
	letItSnow = false; // public variable
 
	while {_snowrun} do {
		snowchance = random 100;
		if (snowchance > 10) then {
			if (!letItSnow) then {
				letItSnow = true;
				publicVariable "letItSnow"; // sends variable to all clients
			};
		}
		else {
			if (letItSnow) then {
				letItSnow = false;
				publicVariable "letItSnow"; // sends variable to all clients
			};
		};
		sleep 300;
	};
};
 
if (!is_Dedicated) then { //change it to !isDedicated like in the init.sqf, maybe better but should not matter for DayZ servers since you can't host them in the game!?
	_snow = nil;
	"letItSnow" addPublicVariableEventHandler {
		_letItSnow = _this select 1; // variable value send from the server
		diag_log format ["SNOW_DEBUG _letItSnow = %1", _letItSnow];
	​	if (_letItSnow) then {
			_snow =  "xmas\effects.sqf";
		} else {
			terminate _snow;
			sleep 300;
			setviewdistance 800;
			0 setfog 0.3;
			0 setovercast 0.6;
		};
	};
};

Might have to make an exception for the pubV (!"letItSnow" ?)

Il ltry to test it later today

 

 

tested it, WORKS GREAT!  really good job!

Link to comment
Share on other sites

85.214.66.54:2302 come and look :D

 

have much much scripts running and do my best to optimize the scripts.

posted some solution for current probs i figured out :D

 

but. i have a problem.... or 3. all the same prob.

 

the snow, safe-zone and adminmenu go away if someone change its skin. (snow at a relog too, cause its a timeboundet trigger) has someone a solution for this? 

i havent found one now.... :(

Link to comment
Share on other sites

85.214.66.54:2302 come and look :D

 

have much much scripts running and do my best to optimize the scripts.

posted some solution for current probs i figured out :D

 

but. i have a problem.... or 3. all the same prob.

 

the snow, safe-zone and adminmenu go away if someone change its skin. (snow at a relog too, cause its a timeboundet trigger) has someone a solution for this? 

i havent found one now.... :(

everything bound to the player will be lost if you change the skin, because what actually happens when you change skin is your characters gets killed and replaced by another one with the new skin, so all your gear is copied over to the new character. i know that is cruel, if anyone knows the movie the The Prestige I think it was in that film... :P

 

anyway actiosn bound to the player will be lost because of that (like admin menu and other permanent actions etc), so you have to re-add them to the "new" player,

Link to comment
Share on other sites

custom\snow.sqf

if (isServer) then {

_snowrun = true;

letItSnow = false; // public variable

while {_snowrun} do {

snowchance = random 100;

if (snowchance > 10) then {

if (!letItSnow) then {

letItSnow = true;

publicVariable "letItSnow"; // sends variable to all clients

};

}

else {

if (letItSnow) then {

letItSnow = false;

publicVariable "letItSnow"; // sends variable to all clients

};

};

sleep 300;

};

};

if (!is_Dedicated) then { //change it to !isDedicated like in the init.sqf, maybe better but should not matter for DayZ servers since you can't host them in the game!?

_snow = nil;

"letItSnow" addPublicVariableEventHandler {

_letItSnow = _this select 1; // variable value send from the server

diag_log format ["SNOW_DEBUG _letItSnow = %1", _letItSnow];

if (_letItSnow) then {

_snow = "custom\spawn_snow.sqf";

} else {

terminate _snow;

sleep 300;

setviewdistance 800;

0 setfog 0.3;

0 setovercast 0.6;

};

};

};

custom\spwan_snow.sqf

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

};

init.sqf add to following to the bottom

//#include "\z\addons\dayz_code\system\REsec.sqf"

//Start Dynamic Weather

execVM "\z\addons\dayz_code\external\DynamicWeatherEffects.sqf";

#include "\z\addons\dayz_code\system\BIS_Effects\init.sqf"

if (!isDedicated) then {

[] execvm "custom\snow.sqf";

};

Thank you for snow scripts.

I've tried like above. No error in rpt. No kicked by battleye.

but snow was not falling.

What is wrong? help me plz...

Link to comment
Share on other sites

  • 3 weeks later...

i got this installed properly, but my people were noticing that even people in the same geographical area were getting different weather effects. For instance, 4 people standing at the same base, one was foggy, another raining, another snowing, another clear.

 

Not sure if it was just my installation, or if this is intended.

Link to comment
Share on other sites

i got this installed properly, but my people were noticing that even people in the same geographical area were getting different weather effects. For instance, 4 people standing at the same base, one was foggy, another raining, another snowing, another clear.

 

Not sure if it was just my installation, or if this is intended.

It not your fault, the script just generates random snow effects on every client. that's what I said the author month ago.. but it's not that easy to fix that :D

Link to comment
Share on other sites

  • 3 weeks later...
  • 6 months later...

Sorry to tag on to this post so late, i have added the random snow to my Server fine but having a slight issue trying to locate the 

fn_temperatur.sqf from your dayz_code.pbo

 

I have even checked my compiles etc but have mention of this file.

 

Please any ideas on this?

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...
  • 4 weeks later...
  • 2 weeks later...

The problem with the one that Fr1nk linked is that it isn't the same density as the script from above or that we are currently posting on. Fr1nks linked one is a couple of snow flakes while this one is an actual storm. Nice to see that it would be synced across all clients.

 

Edit: I am also very interested in this script for our server so a final easy to find link and it being synced for all clients would be heavenly.

Link to comment
Share on other sites

The problem with the one that Fr1nk linked is that it isn't the same density as the script from above or that we are currently posting on. Fr1nks linked one is a couple of snow flakes while this one is an actual storm. Nice to see that it would be synced across all clients.

 

Edit: I am also very interested in this script for our server so a final easy to find link and it being synced for all clients would be heavenly.

 

The same effects might be achieved by changing a few settings in the version I linked...snow density, fog levels, etc. Maybe someone could take a look at that.

Link to comment
Share on other sites

I don't know if this is useful to anyone, but its my attempt at making it snow outside but not inside (for example looking out doors/windows etc).

 

The script is a WIP and I only post this as I've recently started work so I don't have as much free time lately and Christmas is near I would like to see proper snow on servers =)

 

drawbacks/bugs

1: arma 2 glass materials are broken and you cannot see any particles through the windows until you smash the window (same goes with flares) with the exception of one of the offices which works fine, hospitals don't seen to allow view particles even after you break the glass (maybe execute a script to damage all building glass at server start),

 

2: arma 2 bounding boxes are "very" bad, the main one is the cowsheds, these are generally made of 2/3 maybe 4 separate models so it still currently snows inside those until i implement some kind of special case, also some cowshed bounding boxes fall within the actual building, and some buildings bounding boxes are very large compared to the buildings.

 

3: wind factor needs properly managed locally to help prevent snow clipping through the walls in windy conditions or ray projection needs implemented but that might be a bit overkill and cause lag (so better just to manage the wind).

 

/**********************************************/

 

to start snow simply call (method will change in future/final version)

execVM "custom\weather\fn_snowfall.sqf";

to stop snow 

snow = 0;

currently intensity always 1 (range 0-1), this is easy to change if you want to random its intensity, as i said its a WIP and I've not implemented a lot of stuff while testing.

 

Anyway please give feedback if you try it on your server/lan, lag hasn't been an issue for me as its more cpu rather then gpu.

/* 
	snow script v.0.1 (WIP)
	author: toe jam aka diezil
	currently no permissions are granted to hosting companies one click installs etc


	TODOS
	add missing houses/tents/castle/POI....
	custom bounding box's/special case bounding box's - important!!! (General store/"Cowshed's" mainly)
	check if player ontop of an object - 50% (need bounding boxes to determine if we are actually ontop)
	check wind factor... flake ray projection (shift bounding box maybe?)
*/

scriptName "fn_snowfall.sqf";
private["_shelter", "_epoch_shelter", "_density", "_area", "_area_c", "_intensity", "_hight_m", "_flake_s"];

_shelter = [ "C130J_wreck_EP1", "MASH_EP1", "Land_tent_east", "Camp", "CampEast", "CampEast_EP1", "Land_A_BuildingWIP", "Land_A_FuelStation_Build", "Land_A_FuelStation_Shed", "Land_A_GeneralStore_01", "Land_A_GeneralStore_01a", "Land_A_Hospital", "Land_A_MunicipalOffice", "Land_A_Office01", "Land_A_Office02", "Land_A_Pub_01", "Land_a_stationhouse", "Land_Barn_Metal", "Land_Barn_W_01", "Land_Barn_W_02", "Land_Church_03", "Land_Farm_Cowshed_a", "Land_Farm_Cowshed_b", "Land_Farm_Cowshed_c", "Land_Hangar_2", "Land_Hlidac_budka", "Land_HouseB_Tenement", "Land_HouseBlock_A1", "Land_HouseBlock_A1_1", "Land_HouseBlock_A3", "Land_HouseBlock_B6", 
			 "Land_HouseV_1I4", "Land_HouseV_1L2", "Land_HouseV2_02_Interier", "Land_HouseV2_04_interier", "Land_hut06", "Land_Ind_Expedice_3", "Land_Ind_Garage01", "Land_Ind_Pec_01", "Land_Ind_SawMillPen", "Land_Ind_Shed_01_end", "Land_Ind_Shed_01_main", "Land_Ind_Shed_02_main", "Land_Ind_Vysypka", "Land_Ind_Workshop01_01", "Land_Ind_Workshop01_02", "Land_Ind_Workshop01_04", "Land_Ind_Workshop01_L", "Land_kulna", "Land_Mil_Barracks_i", "Land_Mil_ControlTower", "Land_Mil_Guardhouse", "Land_Mil_House", "Land_Panelak", "Land_Panelak2","Land_Panelak3", "Land_Shed_Ind02", "Land_Shed_W01", "Land_SS_hangar", "Land_stodola_old_open", "Land_Tovarna2", 
			 "Land_NAV_Lighthouse", "Land_NAV_Lighthouse2", "Land_Ind_MalyKomin Land_komin", "Land_telek1", "Land_A_TVTower_Base", "Land_Vysilac_FM", "Land_Ind_IlluminantTower", "Land_Nav_Boathouse", "Land_Dam_ConcP_20", "Land_Dam_Conc_20", "Land_A_Castle_Gate", "Land_A_Castle_Stairs_A", "Land_A_Castle_Bastion", "Land_A_Castle_Wall1_End", "Land_A_Castle_Wall1_20", "Land_A_Castle_Wall2_30", "Land_A_Castle_Donjon", "Land_A_Castle_Bergfrit", "DesertCamoNet_DZ", "ForestCamoNet_DZ", "DesertLargeCamoNet_DZ", "ForestLargeCamoNet_DZ", "CanvasHut_DZ", "Barrack2","Land_Mil_Barracks", "Land_HouseV_3I3", "US_WarfareBFieldhHospital_Base_EP1", "Land_Ind_Pec_03a", 
			 "Barrack2", "Land_sara_domek_zluty", "Land_A_Villa_EP1" ];

// BEGIN DEBUG
//0 setOvercast (((random 15) + 75)/100);
//0 setFog (((random 37) + 45)/100);
//setWind [8, 8, true];
//0 setRain 0;
// END DEBUG



// default
_area = 80;	
_area_c = _area/2;

//_intensity = _this select 0;
_intensity = 1;
_density = ceil (_area * _intensity);
snow = _intensity;	// use to calc temp

_flake_s = 0.07;

if (!isDedicated) then {
	_hight_m = 10;
	// set local wind to help prevent snow clipping through walls
	setWind [(wind select 0)*0.15, (wind select 1)*0.15, true];	// limit 1.2 (if max = 8)

	_rotate_point = {
		// TODO account for neg dir
		private[ "_return", "_point", "_s", "_c", "_rx", "_ry", "_newx", "_newy" ];
		_point = _this select 1;

		_rx =	_point select 0;
		_ry =	_point select 1;

		_s = sin (_this select 0);
	  	_c = cos (_this select 0);

		_newx = ( _rx * _c ) + ( _ry * _s );
		_newy = ( (-_rx) * _s ) + ( _ry * _c );

		_return = [ _newx, _newy, _point select 2];
		_return
	};

	_draw_snow = {
		private[ "__pos", "_myX", "_myY", "_dpos", "_counter" ];
		__pos = _this select 0;
		_counter = 0;
		while {(_counter < _density)} do
		{
			_myX =  (random _area) + (__pos select 0) - _area_c;
			_myY =  (random _area) + (__pos select 1) - _area_c;

			_dpos = [(_myX), (_myY), (__pos select 2) + _hight_m];
			drop ["\ca\data\cl_water", "", "Billboard", 1, 8, _dpos, wind, 1, 0.0001, 0.0, 0.5, [_flake_s, _flake_s, _flake_s], [[1, 1, 1, 0], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]], [0, 0], 0.2, 1.2, "", "", ""];

			_counter = _counter +1;
		};
	};

	_draw_snow_outside = {
		private["__bp", "__dir", "__bx1", "__bx2", "__by1", "__by2", "_myX", "_myY", "_mod", "_sxy", "_sx", "_sy", "_inside", "_counter", "__pz" ];
		__bp  = _this select 0;
		__dir = _this select 1;
		__pz = _this select 6;

		_mod = 6;
		__bx1 = (_this select 2) - _mod;
		__bx2 = (_this select 3) + _mod;
		__by1 = (_this select 4) - _mod;
		__by2 = (_this select 5) + _mod;

		_counter = 0;
		while {(_counter < _density)} do
		{
			_inside = false;
			_myX =  (random _area) - _area_c;
			_myY =  (random _area) - _area_c;

			_sxy = [__dir, [_myX, _myY, 0]] call _rotate_point;
			_sx = _sxy select 0;
			_sy = _sxy select 1;

			if ((_sx > (__bx1)) && (_sx < (__bx2))) then {
				if ((_sy > (__by1)) and {_sy < (__by2)}) then {
					_inside = true;
				};
			};

			if (!_inside) then {
				_dpos = [(_myX + (__bp select 0)), (_myY + (__bp select 1)), __pz + _hight_m];
				drop ["\ca\data\cl_water", "", "Billboard", 1, 8, _dpos, wind, 1, 0.0001, 0.0, 0.5, [_flake_s, _flake_s, _flake_s], [[1, 1, 1, 0], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]], [0, 0], 0.2, 1.2, "", "", ""];
			};

			_counter = _counter +1;
		};
	};

	while {snow > 0} do {
		private["_inside", "_obj", "_pos", /*"_vel",*/ "_speed", "_buildings", "_count", "_building", "_bp", "_dir", "_boundingBox", "_min", "_max", "_bx1", "_bx2", "_by1", "_by2", "_pxy", "_px", "_py", "_pz", "_mod" ];
		0 setRain 0;	// prevent rain while snowing (local)
		
		_inside = false;
		_obj = vehicle player;
		_pos = getPos  _obj;
		_pz = (_pos select 2);
		
		_speed = speed (vehicle player);
		if (_speed < 80) then {
			_area = 100;
			_hight_m = 10;
		} else {
			if (_speed < 120) then { _area = 120; _hight_m = 7; } else { _area = 160; _hight_m = 5; }
		};
		_area_c = _area/2;
		_density = ceil (_area * _intensity);
		
		_buildings = nearestObjects [_obj, _shelter, 40];
		_count = count _buildings;
		if ( _count < 1 ) then {
			// player outside
			[_pos] call _draw_snow;
		}
		else
		{
			// check if player inside
			_building = _buildings select 0;
			_bp = getPos _building;
			_dir = getDir _building;

			_boundingBox = boundingBox _building;
			_min = _boundingBox select 0;
			_max = _boundingBox select 1;

			_bx1 = (_min select 0);
			_bx2 = (_max select 0);
			_by1 = (_min select 1);
			_by2 = (_max select 1);

			_pxy = [ _dir, [(_pos select 0) - (_bp select 0), (_pos select 1) - (_bp select 1), 0] ] call _rotate_point;
			_px = _pxy select 0;
			_py = _pxy select 1;

			_mod = 6; // 3
			if ((_px > (_bx1 - _mod)) && (_px < (_bx2 + _mod))) then {
				if ((_py > (_by1 - _mod)) and {_py < (_by2 + _mod)}) then {
					_inside = true;
					_pz = ( (getPosASL _obj) select 2 ) - ( (getPosASL _building) select 2 );
				};
			};

			if (_inside) then {
				// player is under/inside shelter
				[_bp, _dir, _bx1, _bx2, _by1, _by2, _pz] call _draw_snow_outside;
			}
			else {
				// player outside
				[_pos] call _draw_snow;
			};
		};
		sleep 0.1;
	};
	snow = 0;
};

Again I must state its a WIP and I have an idea of where I want it to go in regards to some of the bugs, but building my own bounding box array for the shelters will take a lot of time I don't have at the minute so I post for anyone who might make use of it =)

Link to comment
Share on other sites

  • 1 month later...

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