Advertisement
Guest User

Untitled

a guest
Jan 2nd, 2014
449
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.87 KB | None | 0 0
  1. /*
  2. Author: TeeTime
  3.  
  4. Does: Manages the body temperatur of a Player
  5.  
  6. Possible Problems:
  7. => Balancing
  8.  
  9. Missing:
  10. Save Functions
  11.  
  12. Should Effects Sum Up?
  13.  
  14. Math Functions for Water
  15.  
  16. Player Update GUI Colours need to be checked
  17.  
  18. Shivering Function need improments
  19. */
  20.  
  21.  
  22. private ["_looptime","_sun_factor","_building_factor","_vehicle_factor","_fire_factor","_water_factor","_rain_factor","_night_factor","_wind_factor","_height_mod","_difference","_isinbuilding","_isinvehicle","_raining","_sunrise","_building","_fireplaces","_daytime","_temp","_moving_factor"];
  23.  
  24. _looptime = _this;
  25.  
  26. //Factors are equal to win/loss of factor*basic value
  27. //All Values can be seen as x of 100: 100 / x = minutes from min temperetaure to max temperature (without other effects)
  28. _vehicle_factor = 4;
  29. _moving_factor = 3;
  30. _fire_factor = 15; //Should be always: _rain_factor + _night_factor + _wind_factor OR higher !
  31. _building_factor = 3;
  32. _sun_factor = 3; //max sunfactor linear over the day. highest value in the middle of the day
  33. _warm_clothes = 15;
  34.  
  35.  
  36. _water_factor = -35;
  37. _rain_factor = -8;
  38. _night_factor = -4.5;
  39. _wind_factor = -1;
  40. _snow_factor = -20;
  41.  
  42. _difference = 0;
  43. // _hasfireffect = false;
  44. _isinbuilding = false;
  45. _isinvehicle = false;
  46.  
  47. _raining = if(rain > 0) then {true} else {false};
  48. _sunrise = call world_sunRise;
  49.  
  50. //POSITIV EFFECTS
  51.  
  52. //vehicle
  53. if((vehicle player) != player) then {
  54. _difference = _difference + _vehicle_factor;
  55. _isinvehicle = true;
  56. } else {
  57. //speed factor
  58. private["_vel","_speed"];
  59. _vel = velocity player;
  60. _speed = round((_vel distance [0,0,0]) * 3.5);
  61. _difference = (_moving_factor * (_speed / 20)) min 7;
  62. };
  63.  
  64. if (((typeOf player) == "Skin_Sniper1W_DZN")) then {
  65. _difference= _difference + _warm_clothes;
  66. };
  67.  
  68. if (((typeOf player) == "Skin_CamoWinterW_DZN")) then {
  69. _difference= _difference + _warm_clothes;
  70. };
  71.  
  72. if (((typeOf player) == "Skin_CamoWinter_DZN")) then {
  73. _difference= _difference + _warm_clothes;
  74. };
  75.  
  76. //fire
  77. private ["_fireplaces"];
  78. _fireplaces = nearestObjects [player, ["Land_Fire","Land_Campfire"], 8];
  79. if(({inflamed _x} count _fireplaces) > 0 && !_isinvehicle ) then {
  80. //Math: factor * 1 / (0.5*(distance max 1)^2) 0.5 = 12.5% of the factor effect in a distance o 4 meters
  81. _difference = _difference + (_fire_factor /(0.5*((player distance (_fireplaces select 0)) max 1)^2));
  82. //_hasfireffect = true;
  83. };
  84.  
  85. //building
  86. _building = nearestObject [player, "HouseBase"];
  87. if(!isNull _building) then {
  88. if([player,_building] call fnc_isInsideBuilding) then {
  89. //Make sure thate Fire and Building Effect can only appear single Not used at the moment
  90. //if(!_hasfireffect && _fire_factor > _building_factor) then {
  91. _difference = _difference + _building_factor;
  92. //};
  93. _isinbuilding = true;
  94. dayz_inside = true;
  95. } else {
  96. dayz_inside = false;
  97. };
  98. } else {
  99. dayz_inside = false;
  100. };
  101.  
  102.  
  103. //sun
  104. if(daytime > _sunrise && daytime < (24 - _sunrise) && !_raining && overcast <= 0.6 && !_isinbuilding) then {
  105.  
  106. /*Mathematic Basic
  107.  
  108. t = temperature effect
  109.  
  110. a = calcfactor
  111. f = sunfactor
  112. s = sunrise
  113. d = daytime
  114.  
  115. I: a = f / (12 - s)�
  116. II: t = -a * (d - 12)� + f
  117.  
  118. I + II =>
  119.  
  120. t = -(f / (12 - s)�) * (d - 12)� + f
  121.  
  122. Parabel with highest Point( greatest Effect == _sun_factor) always at 12.00
  123. Zero Points are always at sunrise and sunset -> Only Positiv Values Possible
  124. */
  125.  
  126. _difference = _difference + (-((_sun_factor / (12 - _sunrise)^2)) * ((daytime - 12)^2) + _sun_factor);
  127. };
  128.  
  129.  
  130.  
  131.  
  132. //NEGATIVE EFFECTS
  133.  
  134. //water
  135. if(surfaceIsWater getPosATL player || dayz_isSwimming) then {
  136. _difference = _difference + _water_factor;
  137. };
  138.  
  139. //rain
  140. if(_raining && !_isinvehicle && !_isinbuilding) then {
  141. _difference = _difference + (rain * _rain_factor);
  142. };
  143.  
  144. //snow
  145. if (!isNil "snow" && !_isinvehicle && !_isinbuilding) then {
  146. _difference = _difference + _snow_factor;
  147. };
  148.  
  149. //night
  150. private ["_daytime"];
  151. if((daytime < _sunrise || daytime > (24 - _sunrise)) && !_isinvehicle) then {
  152. _daytime = if(daytime < 12) then {daytime + 24} else {daytime};
  153. if(_isinbuilding) then {
  154. _difference = _difference + ((((_night_factor * -1) / (_sunrise^2)) * ((_daytime - 24)^2) + _night_factor)) / 2;
  155. } else {
  156. _difference = _difference + (((_night_factor * -1) / (_sunrise^2)) * ((_daytime - 24)^2) + _night_factor);
  157. };
  158. };
  159.  
  160. //wind
  161. if(((wind select 0) > 4 || (wind select 1) > 4) && !_isinvehicle && !_isinbuilding ) then {
  162. _difference = _difference + _wind_factor;
  163. };
  164.  
  165. //height
  166. if (!_isinvehicle && overcast >= 0.6) then {
  167. _height_mod = ((getPosASL player select 2) / 100) / 2;
  168. _difference = _difference - _height_mod;
  169. };
  170.  
  171. //Calculate Change Value Basic Factor Looptime Correction Adjust Value to current used temperatur scala
  172. _difference = _difference * SleepTemperatur / (60 / _looptime) * ((dayz_temperaturmax - dayz_temperaturmin) / 100);
  173.  
  174. //Change Temperatur Should be moved in a own Function to allow adding of Items which increase the Temp like "hot tea"
  175. dayz_temperatur = (((dayz_temperatur + _difference) max dayz_temperaturmin) min dayz_temperaturmax);
  176.  
  177. //Add Shivering
  178. // Percent when the Shivering will start
  179. if(dayz_temperatur <= (0.125 * (dayz_temperaturmax - dayz_temperaturmin) + dayz_temperaturmin)) then {
  180. //CamShake as linear Function Maximum reached when Temp is at temp minimum. First Entry = Max Value
  181. _temp = 0.6 * (dayz_temperaturmin / dayz_temperatur );
  182. addCamShake [_temp,(_looptime + 1),30]; //[0.5,looptime,6] -> Maximum is 25% of the Pain Effect
  183. } else {
  184. addCamShake [0,0,0]; //Not needed at the Moment, but will be necesarry for possible Items
  185. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement