mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-13 19:52:38 +03:00
Add files via upload
New weather functions.
This commit is contained in:
45
SQF/dayz_code/system/weather/blizzard.sqf
Normal file
45
SQF/dayz_code/system/weather/blizzard.sqf
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
DayZ Epoch blizzard script by JasonTM
|
||||
Credit to Sentinel for NIM Weather Effects.
|
||||
*/
|
||||
|
||||
private [ "_i","_pos","_dpos","_windX","_windY","_windZ","_fogOriginal","_windspd","_winddir","_vel","_t"];
|
||||
|
||||
_fogOriginal = _this;
|
||||
_windspd = 15;
|
||||
_winddir = random 360;
|
||||
_windX = _windspd * (sin _winddir);
|
||||
_windY = _windspd * (cos _winddir);
|
||||
_windZ = 5 - (random 10);
|
||||
snow = 1;
|
||||
_t = diag_tickTime;
|
||||
playSound "blizzard";
|
||||
|
||||
if !(isNil "DZE_WeatherDebugTime") then {diag_log format ["Blizzard started at %1",(diag_tickTime - DZE_WeatherDebugTime)];};
|
||||
|
||||
while {!DZE_WeatherEndThread} do {
|
||||
_pos = getPos vehicle player;
|
||||
_vel = velocity vehicle player;
|
||||
_i = 0;
|
||||
|
||||
if (!dayz_inside) then {
|
||||
if (diag_tickTime - _t >= 10) then {
|
||||
playSound "blizzard"; // Blizzard sound is a 10 second clip.
|
||||
_t = diag_tickTime;
|
||||
};
|
||||
while {_i < 25} do {
|
||||
_dpos = [((_pos select 0) + (25 - (random (2*25))) + ((_vel select 0)*6)) - (_windX),((_pos select 1) + (25 - (random (2*25))) + ((_vel select 1)*6)) - (_windY),((_pos select 2) + 3)];
|
||||
// Snow Particles
|
||||
drop ["\ca\data\cl_water", "", "Billboard", 1, 6, _dpos, [_windX/2,_windY/2,-1], 1, 1.275, 1, (random .01), [0.05], [[1,1,1,1]], [0,0], 0.2, 1.2, "", "", ""];
|
||||
_i = _i + 1;
|
||||
};
|
||||
// Cloud particles
|
||||
drop ["\ca\data\cl_basic", "", "Billboard", 0.2, 5, [(_pos select 0) + (75 - (random (2*75))) + (_vel select 0)*4 - _windX,(_pos select 1) + (75 - (random (2*75))) + (_vel select 1)*4 - _windY,(_pos select 2) + 10], [_windX,_windY,_windZ], 10, 1.275, 1, (random .01), [35,60], [[0.95,0.95,0.95,0],[0.95,0.95,0.95,0.4],[0.95,0.95,0.95,0.4],[0.95,0.95,0.95,0.4],[0.95,0.95,0.95,0]], [0,0], 0, 0, "", "",""];
|
||||
};
|
||||
uiSleep 0.001;
|
||||
};
|
||||
|
||||
0 setFog _fogOriginal; // Reset fog to original.
|
||||
snow = 0;
|
||||
|
||||
if !(isNil "DZE_WeatherDebugTime") then {diag_log format ["Blizzard ended at %1",(diag_tickTime - DZE_WeatherDebugTime)];};
|
||||
33
SQF/dayz_code/system/weather/breathFog.sqf
Normal file
33
SQF/dayz_code/system/weather/breathFog.sqf
Normal file
@@ -0,0 +1,33 @@
|
||||
// DayZ Epoch Breath Fog by JasonTM
|
||||
// Credit to tpw for Simple Breath Fog: http://www.armaholic.com/page.php?id=13307
|
||||
// Credit to Sumrak for DZN Breath Fog.
|
||||
|
||||
private ["_int","_pos","_b","_arr"];
|
||||
|
||||
_int = .04; // intensity of breath fog (0 to 1). The higher the number the less transparent.
|
||||
|
||||
if !(isNil "DZE_WeatherDebugTime") then {diag_log format ["Breath fog started at %1",(diag_tickTime - DZE_WeatherDebugTime)];};
|
||||
|
||||
while {!DZE_WeatherEndThread} do {
|
||||
_arr = [];
|
||||
{
|
||||
if (isPlayer _x) then {
|
||||
_pos = _x selectionposition "neck";
|
||||
_b = "#particlesource" createVehicleLocal (getPos _x);
|
||||
_b setparticleparams [["\ca\data\particleeffects\universal\universal.p3d", 16, 12, 13, 0], "", "Billboard", 0.5, 0.5, [_pos select 0, (_pos select 1) + 0.15, _pos select 2], [0, 0.2, -0.2], 1, 1.275, 1, 0.2, [0, 0.2, 0], [[1, 1, 1, _int], [1, 1, 1, 0.01], [1, 1, 1, 0]], [1000], 1, 0.04, "", "", _x];
|
||||
_b setparticlerandom [2, [0, 0, 0], [0.25, 0.25, 0.25], 0, 0.5, [0, 0, 0, 0.1], 0, 0, 10];
|
||||
_b setdropinterval 0.001;
|
||||
_arr = _arr + [_b];
|
||||
};
|
||||
} count (player nearEntities ["CAManBase",300]); // It's better for performance to have each client use createVehicleLocal on nearby player objects.
|
||||
|
||||
uiSleep 0.5;
|
||||
|
||||
{
|
||||
deletevehicle _x; // delete the particle sources.
|
||||
} count _arr;
|
||||
|
||||
uiSleep (2 + random 1);
|
||||
};
|
||||
|
||||
if !(isNil "DZE_WeatherDebugTime") then {format ["Breath fog ended at %1",(diag_tickTime - DZE_WeatherDebugTime)];};
|
||||
76
SQF/dayz_code/system/weather/groundFog.sqf
Normal file
76
SQF/dayz_code/system/weather/groundFog.sqf
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
DayZ Epoch Ground Fog Effects by JasonTM
|
||||
Credit to Yac for the particle array definitions: http://www.armaholic.com/page.php?id=7122
|
||||
*/
|
||||
|
||||
private ["_dist","_pos","_list","_option","_isOK","_i","_sp","_sl","_size","_col","_CC","_angle","_radius","_minRadius","_maxRadius","_type","_count","_num","_veh"];
|
||||
|
||||
_option = _this select 0;
|
||||
_dist = _this select 1;
|
||||
_height = -0.4;
|
||||
|
||||
if !(isNil "DZE_WeatherDebugTime") then {diag_log format ["Ground fog started at %1",(diag_tickTime - DZE_WeatherDebugTime)];};
|
||||
|
||||
// Fog spawns on nearby buildings
|
||||
while {!DZE_WeatherEndThread} do {
|
||||
_isOK = true;
|
||||
_veh = vehicle player;
|
||||
_pos = getPos _veh;
|
||||
if (_option in [3,4]) then {_isOK = count (nearestLocations [_pos, ["NameCityCapital","NameCity","NameVillage","NameLocal"],_dist]) > 0;};
|
||||
if (_veh != player && (speed _veh > 30 || {(_pos select 2) > 30})) then {_isOK = false;}; // Player is driving a vehicle or airborne.
|
||||
if (_isOK) then {
|
||||
_list = nearestObjects [_pos, ["House"], _dist];
|
||||
_count = 0;
|
||||
{
|
||||
if (_count == 15) exitWith {}; // Only spawn fog on the nearest 15 buildings.
|
||||
_type = typeOf _x;
|
||||
_maxRadius = sizeOf _type;
|
||||
// Skip small objects like dog houses. Add specific objects to blacklist like power lines and runway lights.
|
||||
if (_maxRadius > 10 && {!(_type in ["Land_sloup_vn_dratZ","Land_sloup_vn_drat","Land_sloup_vn","Land_NavigLight"])}) then {
|
||||
_pos = getPos _x;
|
||||
_minRadius = _maxRadius / 2.5;
|
||||
_num = round (_maxRadius * 1.25) min 75; // Adjust the number of ground fog spawns based on the size of the building.
|
||||
//diag_log text format ["DEBUG Number of fog particles to spawn: %1, for building type %2.",_num,_type];
|
||||
_i = 0;
|
||||
while {_i < _num} do {
|
||||
_radius = _minRadius + random (_maxRadius - _minRadius);
|
||||
_angle = random 360;
|
||||
_size = 3 + random 2;
|
||||
drop ["\ca\data\cl_basic" , "", "Billboard", 8 + random 1, 8 + random 1, [(_pos select 0)+_radius*(sin(_angle)),(_pos select 1)+_radius*(cos(_angle)),_height],[0,0,0],5 , 0.2, 0.1568, 0,[_size], [[1,1,1,0.3],[1,1,1,.7],[1,1,1,.7],[1,1,1,.7],[1,1,1,.7],[1,1,1,.7],[1,1,1,.7],[1,1,1,0.3]], [0],0,0,"", "",""];
|
||||
_i = _i + 1;
|
||||
};
|
||||
_count = _count + 1;
|
||||
};
|
||||
} count _list;
|
||||
};
|
||||
uiSleep .5;
|
||||
};
|
||||
|
||||
/*
|
||||
// Fog spawns on player object
|
||||
_height = -0.4;
|
||||
_isOK = true;
|
||||
_pvar = 50;
|
||||
|
||||
while {!DZE_WeatherEndThread} do {
|
||||
_i = 0;
|
||||
_sp = speed vehicle player;
|
||||
_pos = getPos vehicle player;
|
||||
if (_option in [3,4]) then {_isOK = count (nearestLocations [_pos, ["NameCityCapital","NameCity","NameVillage","NameLocal"],500]) > 0;}; // Count check of locations within 500 meters.};
|
||||
if (_sp < 25 && _isOK) then { // No fog if a player is in a moving vehicle or not near a city if "near locations" is enabled.
|
||||
_sl = [.001,.005] select (_sp < 3); // If the player is moving slowly, then sleep for longer between particle spawns.
|
||||
while {_i < 500} do {
|
||||
_pos = getPos vehicle player; // It's important to keep an accurate position on the player if he is running full speed.
|
||||
_size = 4 + random 2;
|
||||
_col = .7 + random .3;
|
||||
_CC=[_col,_col,_col,.3];
|
||||
drop ["\ca\data\cl_basic" , "", "Billboard", 5 + random 2,5 + random 2, [(_pos select 0) - _pvar + random (_pvar * 2),(_pos select 1) - _pvar + random (_pvar * 2),random (_height)],[0,0,0],5 , 0.2, 0.1565, 0.001,[_size], [[_col,_col,_col,0],_CC,_CC,_CC,[_col,_col,_col,0]], [0],0,0,"", "",""];
|
||||
_i = _i + 1;
|
||||
uiSleep _sl;
|
||||
};
|
||||
};
|
||||
uiSleep 1;
|
||||
};
|
||||
*/
|
||||
|
||||
if !(isNil "DZE_WeatherDebugTime") then {diag_log format ["Ground fog ended at %1",(diag_tickTime - DZE_WeatherDebugTime)];};
|
||||
100
SQF/dayz_code/system/weather/setWeather.sqf
Normal file
100
SQF/dayz_code/system/weather/setWeather.sqf
Normal file
@@ -0,0 +1,100 @@
|
||||
private ["_groundFogAllow","_groundFogDist","_groundFog","_currentSnow","_blizzard","_currentFog","_currentOvercast","_currentRain","_currentWindX","_currentWindY","_changeType","_breathFog"];
|
||||
|
||||
#define DEBUG_MESSAGE false
|
||||
//if (isNil "DZE_WeatherDebugTime") then {DZE_WeatherDebugTime = diag_tickTime;};
|
||||
|
||||
_currentOvercast = _this select 0;
|
||||
_currentFog = _this select 1;
|
||||
_currentRain = _this select 2;
|
||||
_currentWindX = _this select 3;
|
||||
_currentWindY = _this select 4;
|
||||
_currentSnow = _this select 5;
|
||||
_changeType = _this select 6;
|
||||
_blizzard = _this select 7;
|
||||
_groundFog = DZE_WeatherVariables select 15;
|
||||
_groundFogDist = DZE_WeatherVariables select 16;
|
||||
_groundFogAllow = DZE_WeatherVariables select 17;
|
||||
_breathFog = DZE_WeatherVariables select 18;
|
||||
DZE_WeatherEndThread = false; // Used by the server as a thread kill switch to keep JIP clients in sync. Easier than trying to sync time.
|
||||
|
||||
// Set current weather values
|
||||
call {
|
||||
if (_blizzard) exitWith {0 setOvercast _currentOvercast; 10 setFog 0.95;}; // Fog is set at 95% for the blizzard script.
|
||||
if (_changeType == "OVERCAST") exitWith {0 setFog _currentFog; 15 setOvercast _currentOvercast;};
|
||||
if (_changeType == "FOG") exitWith {0 setOvercast _currentOvercast; 30 setFog _currentFog;};
|
||||
/* _changeType == "NONE" */ 0 setOvercast _currentOvercast; 0 setFog _currentFog;
|
||||
};
|
||||
setWind [_currentWindX, _currentWindY, true];
|
||||
|
||||
// Ground fog
|
||||
if (_groundFog != 0 && !_blizzard) then { // Prevent ground fog when a blizzard is in progress.
|
||||
if (_groundFogAllow || (!_groundFogAllow && {_currentOvercast <= .70})) then { // Checks for allowing ground fog if it's raining or snowing.
|
||||
if (_groundFog in [1,3]) then {
|
||||
if ((date select 3) in [20,21,22,23,24,0,1,2,3,4]) then { // ground fog at evening, night, and morning hours.
|
||||
if (DEBUG_MESSAGE) then {"Ground fog is starting" call dayz_rollingMessages;};
|
||||
[_groundFog,_groundFogDist] spawn fnc_groundFog;
|
||||
};
|
||||
} else { // options 2,4 default
|
||||
if (DEBUG_MESSAGE) then {"Ground fog is starting" call dayz_rollingMessages;};
|
||||
[_groundFog,_groundFogDist] spawn fnc_groundFog;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
// Breath fog
|
||||
if (DZE_Weather in [3,4] && {_breathFog in [1,2]}) then {
|
||||
if (_breathFog == 1) then {
|
||||
if (DEBUG_MESSAGE) then {"Breath fog is starting" call dayz_rollingMessages;};
|
||||
[] spawn fnc_breathFog;
|
||||
} else {
|
||||
if (_currentSnow > 0) then {
|
||||
if (DEBUG_MESSAGE) then {"Breath fog is starting" call dayz_rollingMessages;};
|
||||
[] spawn fnc_breathFog;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
// Set current rain or snow if overcast is above 70%.
|
||||
if (_currentOvercast > .70) then {
|
||||
if (DZE_Weather in [3,4]) then {
|
||||
if (_currentSnow > 0) then {
|
||||
if (_blizzard) then {
|
||||
if (DEBUG_MESSAGE) then {"A blizzard is starting" call dayz_rollingMessages;};
|
||||
_currentFog spawn fnc_blizzard;
|
||||
} else {
|
||||
if (DEBUG_MESSAGE) then {"It's starting to snow" call dayz_rollingMessages;};
|
||||
_currentSnow spawn fnc_snowfall;
|
||||
};
|
||||
};
|
||||
} else {
|
||||
if (_currentRain > 0) then {
|
||||
_currentRain spawn {
|
||||
if (DEBUG_MESSAGE) then {"The rain is starting" call dayz_rollingMessages;};
|
||||
if !(isNil "DZE_WeatherDebugTime") then {diag_log format ["Rain started at %1",(diag_tickTime - DZE_WeatherDebugTime)];};
|
||||
while {!DZE_WeatherEndThread} do {
|
||||
uiSleep 3;
|
||||
3 setRain _this;
|
||||
};
|
||||
if !(isNil "DZE_WeatherDebugTime") then {diag_log format ["Rain ended at %1",(diag_tickTime - DZE_WeatherDebugTime)];};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
// Set rain to zero if winter weather enabled, overcast is 70% or less, or rain is set to zero.
|
||||
if (_currentRain == 0 || {_currentOvercast <= .70} || {DZE_Weather in [3,4]}) then {
|
||||
// This might look a little funky, but it's necessary to get the rain to stop in Arma 2.
|
||||
[] spawn {
|
||||
if (DEBUG_MESSAGE) then {"Setting the rain to zero" call dayz_rollingMessages;};
|
||||
if !(isNil "DZE_WeatherDebugTime") then {diag_log format ["Rain set to zero at %1",(diag_tickTime - DZE_WeatherDebugTime)];};
|
||||
3 setRain 0;
|
||||
uiSleep 3;
|
||||
3 setRain 0;
|
||||
uiSleep 3;
|
||||
99999 setRain 0;
|
||||
};
|
||||
};
|
||||
|
||||
if (DEBUG_MESSAGE) then {"The Weather Has Changed" call dayz_rollingMessages;};
|
||||
|
||||
diag_log format ["Weather Forecast: Overcast: %1, Fog: %2, Rain: %3, WindX: %4, WindY: %5, Snow: %6, Blizzard: %7, Change Type: %8.",_currentOvercast,_currentFog,_currentRain,_currentWindX,_currentWindY,_currentSnow,_blizzard,_changeType];
|
||||
35
SQF/dayz_code/system/weather/snowfall.sqf
Normal file
35
SQF/dayz_code/system/weather/snowfall.sqf
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
DayZ Epoch snowfall script by JasonTM
|
||||
Credit to Sumrak for DZN snowfall script.
|
||||
Credit to Karel Moricky for particle array definitions in "modules_e/Weather/data/fsms/particle.fsm"
|
||||
*/
|
||||
|
||||
private ["_density","_i","_d","_h","_pos","_dpos","_vel"];
|
||||
|
||||
_density = _this;
|
||||
if (_density > 1) then {_density = 1;};
|
||||
_density = round (25 * _density);
|
||||
_d = 35;
|
||||
_h = 15;
|
||||
snow = 1;
|
||||
|
||||
if !(isNil "DZE_WeatherDebugTime") then {diag_log format ["Snowfall started at %1",(diag_tickTime - DZE_WeatherDebugTime)];};
|
||||
|
||||
while {!DZE_WeatherEndThread} do {
|
||||
uiSleep .01;
|
||||
_pos = getPos vehicle player;
|
||||
_vel = velocity vehicle player;
|
||||
_i = 0;
|
||||
|
||||
if !(dayz_inside) then {
|
||||
while {_i < _density} do {
|
||||
_dpos = [((_pos select 0) + (_d - (random (2 * _d))) + ((_vel select 0) * 6)), ((_pos select 1) + (_d - (random (2 * _d))) + ((_vel select 1) * 6)), ((_pos select 2) + 15)];
|
||||
drop [["\Ca\Data\ParticleEffects\Universal\Universal", 16, 12, 8, 1],"","Billboard",1,10,_dpos,[0,0,0],1,0.000001,0,1.1,[0.09,0.09],[[1,1,1,1]],[0,1],0.2,1.2,"","",""];
|
||||
_i = _i + 1;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
snow = 0;
|
||||
|
||||
if !(isNil "DZE_WeatherDebugTime") then {diag_log format ["Snowfall ended at %1",(diag_tickTime - DZE_WeatherDebugTime)];};
|
||||
Reference in New Issue
Block a user