From 4058f59688cb33510a136590b68238cabbbf78b1 Mon Sep 17 00:00:00 2001 From: A Man Date: Mon, 16 Dec 2019 15:41:59 +0100 Subject: [PATCH] Add warm clothes and shivering Warm Clothes can be adjusted in the configvariables with DZE_WarmClothes. Shivering can be enabled or disabled with the last value in the DZE_TempVars array. A temperature effect for snow was added too. --- SQF/dayz_code/compile/fn_temperatur.sqf | 161 +++++++++++------- SQF/dayz_code/configVariables.sqf | 6 +- SQF/dayz_code/init/variables.sqf | 1 - .../system/DynamicWeatherEffectsSnow.sqf | 2 + .../custom/compiles.sqf | 3 - .../custom/fn_temperatur.sqf | 158 ----------------- 6 files changed, 102 insertions(+), 229 deletions(-) delete mode 100644 Server Files/MPMissions/DayZ_Epoch_26.sauerland_winter/custom/compiles.sqf delete mode 100644 Server Files/MPMissions/DayZ_Epoch_26.sauerland_winter/custom/fn_temperatur.sqf diff --git a/SQF/dayz_code/compile/fn_temperatur.sqf b/SQF/dayz_code/compile/fn_temperatur.sqf index 70a97c293..83712cdac 100644 --- a/SQF/dayz_code/compile/fn_temperatur.sqf +++ b/SQF/dayz_code/compile/fn_temperatur.sqf @@ -17,7 +17,7 @@ Missing: Shivering Function need improments */ -private ["_difference","_isinvehicle","_isinbuilding","_daytime","_height_mod","_temp","_looptime","_vehicle_factor","_moving_factor","_fire_factor","_building_factor","_sun_factor","_water_factor","_rain_factor","_night_factor","_wind_factor","_raining","_sunrise","_fireplaces","_building"]; +private ["_difference","_isinvehicle","_isinbuilding","_daytime","_height_mod","_temp","_looptime","_vehicle_factor","_moving_factor","_fire_factor","_building_factor","_sun_factor","_water_factor","_rain_factor","_night_factor","_wind_factor","_raining","_sunrise","_fireplaces","_building","_heatpack_factor","_warm_clothes","_stand_factor","_snow_factor","_pPos","_sleepTemperatur","_shivering"]; _looptime = _this; //Factors are equal to win/loss of factor*basic value @@ -25,20 +25,25 @@ _looptime = _this; //Positive effects _vehicle_factor = DZE_TempVars select 0; - _fire_factor = DZE_TempVars select 1; + _fire_factor = DZE_TempVars select 1; _building_factor = DZE_TempVars select 2; _moving_factor = DZE_TempVars select 3; _sun_factor = DZE_TempVars select 4; _heatpack_factor = DZE_TempVars select 5; - -//Negative effects - _water_factor = DZE_TempVars select 6; - _stand_factor = DZE_TempVars select 7; - _rain_factor = DZE_TempVars select 8; - _wind_factor = DZE_TempVars select 9; - _night_factor = DZE_TempVars select 10; + _warm_clothes = DZE_TempVars select 6; -_difference = 0; +//Negative effects + _water_factor = DZE_TempVars select 7; + _stand_factor = DZE_TempVars select 8; + _rain_factor = DZE_TempVars select 9; + _wind_factor = DZE_TempVars select 10; + _night_factor = DZE_TempVars select 11; + _snow_factor = DZE_TempVars select 12; + +//Shivering +_shivering = DZE_TempVars select 13; //Set this to 26 to disabled shivering + +_difference = 0; //_hasfireffect = false; _isinbuilding = false; _isinvehicle = false; @@ -61,19 +66,21 @@ if((vehicle player) != player) then { //diag_log format["Moving - %1",_difference]; //fire -_pPos = [player] call FNC_GetPos; -_fireplaces = nearestObjects [_pPos, ["flamable_DZ","Land_Fire","Land_Campfire"], 8]; -if(({inflamed _x} count _fireplaces) > 0 && !_isinvehicle ) then { - //Math: factor * 1 / (0.5*(distance max 1)^2) 0.5 = 12.5% of the factor effect in a distance o 4 meters - _difference = _difference + (_fire_factor /(0.5*((player distance (_fireplaces select 0)) max 1)^2)); - //_hasfireffect = true; - - //diag_log format["fire - %1",_difference]; +if !(_isinvehicle) then { + _pPos = [player] call FNC_GetPos; + _fireplaces = nearestObjects [_pPos, ["flamable_DZ","Land_Fire","Land_Campfire"], 8]; + if (({inflamed _x} count _fireplaces) > 0) then { + //Math: factor * 1 / (0.5*(distance max 1)^2) 0.5 = 12.5% of the factor effect in a distance o 4 meters + _difference = _difference + (_fire_factor /(0.5*((player distance (_fireplaces select 0)) max 1)^2)); + //_hasfireffect = true; + + //diag_log format["fire - %1",_difference]; + }; }; //building _building = nearestObject [player, "HouseBase"]; -if(!isNull _building) then { +if (!isNull _building) then { if([player,_building] call fnc_isInsideBuilding) then { //Make sure thate Fire and Building Effect can only appear single Not used at the moment //if(!_hasfireffect && _fire_factor > _building_factor) then { @@ -89,7 +96,7 @@ if(!isNull _building) then { }; //sun -if(daytime > _sunrise && daytime < (24 - _sunrise) && !_raining && overcast <= 0.6 && !_isinbuilding) then { +if (daytime > _sunrise && {daytime < (24 - _sunrise)} && {!_raining} && {overcast <= 0.6} && {!_isinbuilding}) then { /*Mathematic Basic t = temperature effect @@ -111,73 +118,97 @@ if(daytime > _sunrise && daytime < (24 - _sunrise) && !_raining && overcast <= 0 */ _difference = _difference + (-((_sun_factor / (12 - _sunrise)^2)) * ((daytime - 12)^2) + _sun_factor); - + //diag_log format["sun - %1",_difference]; }; //heatpack -if(r_player_warming_heatpack select 0) then { +if (r_player_warming_heatpack select 0) then { _difference = _difference + _heatpack_factor; if ((diag_tickTime - (r_player_warming_heatpack select 1)) >= r_player_warming_heatpack_time) then { r_player_warming_heatpack = [false,0]; }; }; + +//warm clothes +if ((typeOf player) in DZE_WarmClothes) then { + if (DZE_SnowFall) then {_warm_clothes = _warm_clothes + 14;}; + _difference = _difference + _warm_clothes; +}; + //NEGATIVE EFFECTS -//water -if((surfaceIsWater getPosATL player || dayz_isSwimming) && !_isinvehicle) then { - _difference = _difference - _water_factor; - - //diag_log format["water - %1",_difference]; -}; +if !(_isinvehicle) then { -//rain -if(_raining && !_isinvehicle && !_isinbuilding) then { - _difference = _difference - (rain * _rain_factor); - - //diag_log format["night - %1",_difference]; -}; + //water + if ((surfaceIsWater getPosATL player) || dayz_isSwimming) then { + _difference = _difference - _water_factor; -//night -if((daytime < _sunrise || daytime > (24 - _sunrise)) && !_isinvehicle) then { - _daytime = if(daytime < 12) then {daytime + 24} else {daytime}; - if(_isinbuilding) then { - _difference = _difference - ((((_night_factor * -1) / (_sunrise^2)) * ((_daytime - 24)^2) + _night_factor)) / 2; - } else { - _difference = _difference - (((_night_factor * -1) / (_sunrise^2)) * ((_daytime - 24)^2) + _night_factor); + //diag_log format["water - %1",_difference]; }; - - //diag_log format["night - %1",_difference]; -}; -//wind -if(((wind select 0) > 4 || (wind select 1) > 4) && !_isinvehicle && !_isinbuilding ) then { - _difference = _difference - _wind_factor; - - //diag_log format["Wind - %1",_difference]; -}; + //night + if((daytime < _sunrise || daytime > (24 - _sunrise)) ) then { + _daytime = if(daytime < 12) then {daytime + 24} else {daytime}; + if(_isinbuilding) then { + _difference = _difference - ((((_night_factor * -1) / (_sunrise^2)) * ((_daytime - 24)^2) + _night_factor)) / 2; + } else { + _difference = _difference - (((_night_factor * -1) / (_sunrise^2)) * ((_daytime - 24)^2) + _night_factor); + }; -//height -if (!_isinvehicle && overcast >= 0.6) then { - _height_mod = ((getPosASL player select 2) / 100) / 2; - _difference = _difference - _height_mod; - - //diag_log format["height - %1",_difference]; -}; + //diag_log format["night - %1",_difference]; + }; -//Standing cooldown. -if ((speed player == 0) && !_isinvehicle && !_isinvehicle && !_isinbuilding) then { - _difference = _difference - _stand_factor; - - //diag_log format["Standing - %1",_difference]; -}; + //height + if (overcast >= 0.6) then { + _height_mod = ((getPosASL player select 2) / 100) / 2; + _difference = _difference - _height_mod; + //diag_log format["height - %1",_difference]; + }; + + if !(_isinbuilding) then { + //rain + if(_raining) then { + _difference = _difference - (rain * _rain_factor); + + //diag_log format["night - %1",_difference]; + }; + //wind + if ((wind select 0) > 4 || (wind select 1) > 4) then { + _difference = _difference - _wind_factor; + + //diag_log format["Wind - %1",_difference]; + }; + //Standing cooldown. + if (speed player == 0) then { + _difference = _difference - _stand_factor; + + //diag_log format["Standing - %1",_difference]; + }; + //Snow fall + if (!isNil "snow") then { + _difference = _difference - _snow_factor; + }; + }; +}; //Calculate Change Value Basic Factor Looptime Correction Adjust Value to current used temperatur scala -_difference = _difference * SleepTemperatur / (60 / _looptime) * ((dayz_temperaturmax - dayz_temperaturmin) / 100); +_sleepTemperatur = 90 / 100; //First value = Minutes until player reaches the coldest point at night (without other effects! night factor expected to be -1) //TeeChange +_difference = _difference * _sleepTemperatur / (60 / _looptime) * ((dayz_temperaturmax - dayz_temperaturmin) / 100); if (dayz_temperature_override) then { _difference = 0; if (dayz_temperatur < 37) then { dayz_temperatur = 37; } }; //Change Temperatur Should be moved in a own Function to allow adding of Items which increase the Temp like "hot tea" r_player_temp_factor = _difference; -dayz_temperatur = (((dayz_temperatur + _difference) max dayz_temperaturmin) min dayz_temperaturmax); \ No newline at end of file +dayz_temperatur = (((dayz_temperatur + _difference) max dayz_temperaturmin) min dayz_temperaturmax); + +//Add Shivering +// Percent when the Shivering will start +if (dayz_temperatur <= _shivering) then { // if the current players temperature is under 34, to disabled set _shivering to 26. + //CamShake as linear Function Maximum reached when Temp is at temp minimum. First Entry = Max Value + _temp = 0.6 * (dayz_temperaturmin / dayz_temperatur ); + addCamShake [_temp,(_looptime + 1),30]; //[0.5,looptime,6] -> Maximum is 25% of the Pain Effect +} else { + addCamShake [0,0,0]; //Not needed at the Moment, but will be necesarry for possible Items +}; diff --git a/SQF/dayz_code/configVariables.sqf b/SQF/dayz_code/configVariables.sqf index e7b34df79..0938b0cd0 100644 --- a/SQF/dayz_code/configVariables.sqf +++ b/SQF/dayz_code/configVariables.sqf @@ -10,8 +10,10 @@ dayz_waterBottleBreaking = false; // Water bottles have a chance to break when b dayz_tameDogs = false; // Allow taming dogs with raw meat. Note dog behavior is experimental and buggy. dayz_townGenerator = false; // Spawn vanilla map junk instead of Epoch DynamicDebris. Currently only compatible with Chernarus. Also enables comfrey plant spawner which negatively impacts performance. dayz_townGeneratorBlackList = []; // If townGenerator is enabled it will not spawn junk within 150m of these positions. Example for Chernarus traders: [[4053,11668,0],[11463,11349,0],[6344,7806,0],[1606,7803,0],[12944,12766,0],[5075,9733,0],[12060,12638,0]] -DZE_TempVars = [7, 15, 4, 4, 2, 6, 3, 2, 0.25, 0.75, 0.5]; //[vehicle, fire, building, moving, sun, heatpack, water, standing, rain, wind, night] water, standing, rain, wind and night factors have a negative impact on temperature. The greater they are the quicker the player gets cold. -DZE_WeatherVariables = [10, 20, 5, 10, 0, 0.2, 0, 0.7, 0, 0.6, 0, 8, 25, 30, 0, false]; //See DynamicWeatherEffects.sqf for info on these values. +DZE_SnowFall = false; //Enables snowfall for Dynamic Weather Effects. Default: false, on all non winter maps. Enabled on all winter maps. _maximumOvercast in DZE_WeatherVariables must be over 0.75. This is set already for all winter maps. +DZE_WarmClothes = []; //Array of warm clothes, type of player model must be added: E.g. ["MVD_Soldier_DZ","GUE_Soldier_2_DZ"]; +DZE_TempVars = [7, 15, 4, 4, 2, 6, 8, 3, 2, 0.25, 0.75, 0.5, 12, 33]; //[vehicle, fire, building, moving, sun, heatpack, warm clothes, water, standing, rain, wind, night, snow, shivering] water, standing, rain, wind and night factors have a negative impact on temperature. The greater they are the quicker the player gets cold. To disable shivering set it to 26. +DZE_WeatherVariables = [10, 20, 5, 10, 0, 0.2, 0, 0.7, 0, 0.6, 0, 8, 25, 30, 0, false, 0.8, 1, 100]; //See DynamicWeatherEffects.sqf for info on these values. DZE_TwoPrimaries = 2; // 0 do not allow primary weapon on back. 1 allow primary weapon on back, but not when holding a primary weapon in hand. 2 allow player to hold two primary weapons, one on back and one in their hands. DZE_AntiWallLimit = 3; // Number of activations before player_antiWall kills player for glitching attempt. Lower is stricter, but may result in false positives. DZE_DamageBeforeMaint = 0.09; // Min damage built items must have before they can be maintained diff --git a/SQF/dayz_code/init/variables.sqf b/SQF/dayz_code/init/variables.sqf index 663a3c2bd..c469157f7 100644 --- a/SQF/dayz_code/init/variables.sqf +++ b/SQF/dayz_code/init/variables.sqf @@ -526,7 +526,6 @@ if (!isDedicated) then { // Survival Variables SleepFood = 2160; //minutes (48 hours) SleepWater = 1440; //minutes (24 hours) - SleepTemperatur = 90 / 100; //First value = Minutes until player reaches the coldest point at night (without other effects! night factor expected to be -1) //TeeChange // GUI Dayz_GUI_R = 0.38; // 0.7 .38 diff --git a/SQF/dayz_code/system/DynamicWeatherEffectsSnow.sqf b/SQF/dayz_code/system/DynamicWeatherEffectsSnow.sqf index 979a99e15..bb223708f 100644 --- a/SQF/dayz_code/system/DynamicWeatherEffectsSnow.sqf +++ b/SQF/dayz_code/system/DynamicWeatherEffectsSnow.sqf @@ -21,6 +21,8 @@ _initialWind = [-1, -1]; _initialSnow = 1; _debug = false; +//Snowfall example: DZE_WeatherVariables = [10, 20, 5, 10, 0, 0.2, 0.5, 1, 0, 0.6, 0, 8, 25, 30, 0, false, 0.8, 1, 100]; + /////////////////////////////////////////////////////////////////////////////////////////////////////////////// // The following variables can be changed to tweak weather behaviour diff --git a/Server Files/MPMissions/DayZ_Epoch_26.sauerland_winter/custom/compiles.sqf b/Server Files/MPMissions/DayZ_Epoch_26.sauerland_winter/custom/compiles.sqf deleted file mode 100644 index 51d2e7631..000000000 --- a/Server Files/MPMissions/DayZ_Epoch_26.sauerland_winter/custom/compiles.sqf +++ /dev/null @@ -1,3 +0,0 @@ -//cold -player_temp_calculation = compile preprocessFileLineNumbers "custom\fn_temperatur.sqf"; - diff --git a/Server Files/MPMissions/DayZ_Epoch_26.sauerland_winter/custom/fn_temperatur.sqf b/Server Files/MPMissions/DayZ_Epoch_26.sauerland_winter/custom/fn_temperatur.sqf deleted file mode 100644 index 27af7da93..000000000 --- a/Server Files/MPMissions/DayZ_Epoch_26.sauerland_winter/custom/fn_temperatur.sqf +++ /dev/null @@ -1,158 +0,0 @@ - -private["_looptime","_pos","_vehicle_factor","_moving_factor","_fire_factor","_rain_factor","_night_factor","_wind_factor","_building_factor","_sun_factor","_water_factor","_difference","_hasfireffect","_isinbuilding","_isinvehicle","_raining","_sunrise","_vel","_speed","_fireplaces","_building","_daytime","_height_mod","_temp"]; - -_looptime = _this; - -//Factors are equal to win/loss of factor*basic value -//All Values can be seen as x of 100: 100 / x = minutes from min temperetaure to max temperature (without other effects) -_vehicle_factor = 4; -_moving_factor = 7; -_fire_factor = 15; //Should be always: _rain_factor + _night_factor + _wind_factor OR higher ! -_building_factor = 7; -_sun_factor = 4; //max sunfactor linear over the day. highest value in the middle of the day -_warm_clothes = 22; - -_water_factor = -8; -_rain_factor = -3; -_night_factor = -1.5; -_wind_factor = -1; -_snow_factor = -12; - -_difference = 0; -_hasfireffect = false; -_isinbuilding = false; -_isinvehicle = false; - -_raining = (rain > 0); -_sunrise = call world_sunRise; - -//POSITIV EFFECTS - -//vehicle -if((vehicle player) != player) then { - _difference = _difference + _vehicle_factor; - _isinvehicle = true; -} else { - //speed factor - private["_vel","_speed"]; - _vel = velocity player; - _speed = round((_vel distance [0,0,0]) * 3.5); - _difference = (_moving_factor * (_speed / 20)) min 7; -}; - -//fire -_pos = [player] call FNC_GetPos; -_fireplaces = nearestObjects [_pos, ["Land_Fire","Land_Campfire"], 8]; -if(({inflamed _x} count _fireplaces) > 0 && !_isinvehicle ) then { - //Math: factor * 1 / (0.5*(distance max 1)^2) 0.5 = 12.5% of the factor effect in a distance o 4 meters - _difference = _difference + (_fire_factor /(0.5*((_pos distance (_fireplaces select 0)) max 1)^2)); - _hasfireffect = true; -}; - -//building -_building = nearestObject [_pos, "HouseBase"]; -if(!isNull _building) then { - if([player,_building] call fnc_isInsideBuilding) then { - //Make sure thate Fire and Building Effect can only appear single Not used at the moment - //if(!_hasfireffect && _fire_factor > _building_factor) then { - _difference = _difference + _building_factor; - //}; - _isinbuilding = true; - dayz_inside = true; - } else { - dayz_inside = false; - }; -} else { - dayz_inside = false; -}; - -//sun -if(daytime > _sunrise && daytime < (24 - _sunrise) && !_raining && overcast <= 0.6 && !_isinbuilding) then { - /*Mathematic Basic - - t = temperature effect - - a = calcfactor - f = sunfactor - s = sunrise - d = daytime - - I: a = f / (12 - s)² - II: t = -a * (d - 12)² + f - - I + II => - - t = -(f / (12 - s)²) * (d - 12)² + f - - Parabel with highest Point( greatest Effect == _sun_factor) always at 12.00 - Zero Points are always at sunrise and sunset -> Only Positiv Values Possible - */ - - _difference = _difference + (-((_sun_factor / (12 - _sunrise)^2)) * ((daytime - 12)^2) + _sun_factor); -}; - -if ((typeOf player) == "Sniper1W_DZN") then { - _difference= _difference + _warm_clothes; - }; - - if ((typeOf player) == "CamoWinterW_DZN") then { - _difference= _difference + _warm_clothes; - }; - - if ((typeOf player) == "CamoWinter_DZN") then { - _difference= _difference + _warm_clothes; - }; - -//NEGATIVE EFFECTS - -//water -if(surfaceIsWater getPosATL player || dayz_isSwimming) then { - _difference = _difference + _water_factor; -}; - -//rain -if(_raining && !_isinvehicle && !_isinbuilding) then { - _difference = _difference + (rain * _rain_factor); -}; - -//snow -if (!isNil "snow" && !_isinvehicle && !_isinbuilding) then { -_difference = _difference + _snow_factor; -}; - -//night -if((daytime < _sunrise || daytime > (24 - _sunrise)) && !_isinvehicle) then { - _daytime = if(daytime < 12) then {daytime + 24} else {daytime}; - if(_isinbuilding) then { - _difference = _difference + ((((_night_factor * -1) / (_sunrise^2)) * ((_daytime - 24)^2) + _night_factor)) / 2; - } else { - _difference = _difference + (((_night_factor * -1) / (_sunrise^2)) * ((_daytime - 24)^2) + _night_factor); - }; -}; - -//wind -if(((wind select 0) > 4 || (wind select 1) > 4) && !_isinvehicle && !_isinbuilding ) then { - _difference = _difference + _wind_factor; -}; - -//height -if (!_isinvehicle && overcast >= 0.6) then { - _height_mod = ((getPosASL player select 2) / 100) / 2; - _difference = _difference - _height_mod; -}; - -//Calculate Change Value Basic Factor Looptime Correction Adjust Value to current used temperatur scala -_difference = _difference * SleepTemperatur / (60 / _looptime) * ((dayz_temperaturmax - dayz_temperaturmin) / 100); - -//Change Temperatur Should be moved in a own Function to allow adding of Items which increase the Temp like "hot tea" -dayz_temperatur = (((dayz_temperatur + _difference) max dayz_temperaturmin) min dayz_temperaturmax); - -//Add Shivering -// Percent when the Shivering will start -if(dayz_temperatur <= (0.600 * (dayz_temperaturmax - dayz_temperaturmin) + dayz_temperaturmin)) then { - //CamShake as linear Function Maximum reached when Temp is at temp minimum. First Entry = Max Value - _temp = 0.6 * (dayz_temperaturmin / dayz_temperatur ); - addCamShake [_temp,(_looptime + 1),30]; //[0.5,looptime,6] -> Maximum is 25% of the Pain Effect -} else { - addCamShake [0,0,0]; //Not needed at the Moment, but will be necesarry for possible Items -}; \ No newline at end of file