Advertisement
Guest User

player_spawn_2.sqf

a guest
Oct 19th, 2013
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.51 KB | None | 0 0
  1. private ["_refObj","_size","_vel","_speed","_hunger","_thirst","_timeOut","_result","_factor","_randomSpot","_mylastPos","_distance","_lastTemp","_rnd","_listTalk","_bloodChanged","_id","_messTimer","_display","_control","_combatdisplay","_combatcontrol","_timeleft","_inVehicle","_tempPos","_lastUpdate","_foodVal","_thirstVal","_lowBlood","_startcombattimer","_combattimeout","_myPos","_lastPos","_debug","_saveTime","_maxDistanceTravel","_maxDistanceDebug","_maxDistanceZeroPos","_maxDistancePlayer","_maxDistanceVehicle"];
  2. disableSerialization;
  3. _timeOut = 0;
  4. _messTimer = 0;
  5. _lastTemp = dayz_temperatur;
  6. _debug = getMarkerpos "respawn_west";
  7.  
  8. _isPZombie = player isKindOf "PZombie_VB";
  9.  
  10. // override vars
  11. _maxDistanceTravel = DZE_teleport select 0;
  12. _maxDistanceDebug = DZE_teleport select 1;
  13. _maxDistanceZeroPos = DZE_teleport select 2;
  14. _maxDistancePlayer = DZE_teleport select 3;
  15. _maxDistanceVehicle = DZE_teleport select 4;
  16.  
  17. player setVariable ["temperature",dayz_temperatur,true];
  18.  
  19. dayz_myLoad = (((count dayz_myBackpackMags) * 0.2) + (count dayz_myBackpackWpns)) + (((count dayz_myMagazines) * 0.1) + (count dayz_myWeapons * 0.5));
  20.  
  21. while {true} do {
  22.  
  23. //Initialize
  24. _refObj = vehicle player;
  25. _factor = 0.6;
  26. _inVehicle = (_refObj != player);
  27.  
  28. if(_inVehicle) then {
  29. _factor = 1;
  30. };
  31.  
  32. _bloodChanged = false;
  33.  
  34. _size = (sizeOf typeOf _refObj) * _factor;
  35. _vel = velocity player;
  36. _speed = round((_vel distance [0,0,0]) * 3.5);
  37.  
  38. _saveTime = (playersNumber west * 2) + 10;
  39.  
  40. //reset position
  41. _randomSpot = true;
  42. _tempPos = getPosATL _refObj;
  43. _distance = _debug distance _tempPos;
  44.  
  45. if (_distance < _maxDistanceDebug) then {
  46. _randomSpot = false;
  47. };
  48.  
  49. _distance = [0,0,0] distance _tempPos;
  50. if (_distance < _maxDistanceZeroPos) then {
  51. _randomSpot = false;
  52. };
  53.  
  54. if (!isNil "_mylastPos") then {
  55. _distance = _mylastPos distance _tempPos;
  56. if (_distance > _maxDistanceTravel) then {
  57. _randomSpot = false;
  58. };
  59. };
  60.  
  61. if (_randomSpot) then {
  62. _mylastPos = _tempPos;
  63. };
  64.  
  65. /* not used
  66. if (!isNil "_mylastPos") then {
  67. dayz_mylastPos = _mylastPos;
  68. };
  69. */
  70.  
  71. dayz_areaAffect = _size;
  72.  
  73. /* not used
  74. if (_speed > 0.1) then {
  75. _timeOut = _timeOut + 1;
  76. };
  77. */
  78.  
  79. //Record Check
  80. _lastUpdate = time - dayZ_lastPlayerUpdate;
  81. if (_lastUpdate > 8) then {
  82. //POSITION?
  83. _distance = dayz_myPosition distance _refObj;
  84. if (_distance > 10) then {
  85. //Player has moved
  86. dayz_myPosition = getPosATL _refObj;
  87. player setVariable["posForceUpdate",true,true];
  88. dayz_unsaved = true;
  89. dayZ_lastPlayerUpdate = time;
  90. };
  91. };
  92.  
  93. //Hunger
  94. _hunger = +((((r_player_bloodTotal - r_player_blood) / r_player_bloodTotal) * 5) + _speed + dayz_myLoad) * 3;
  95. if (time - dayz_panicCooldown < 120) then {
  96. _hunger = _hunger * 2;
  97. };
  98. dayz_hunger = dayz_hunger + (_hunger / 60);
  99.  
  100. //Thirst
  101. _thirst = 2;
  102. if (!_inVehicle) then {
  103. _thirst = (_speed + 4) * 3;
  104. };
  105. dayz_thirst = dayz_thirst + (_thirst / 60) * (dayz_temperatur / dayz_temperaturnormal); //TeeChange Temperatur effects added Max Effects: -25% and + 16.6% waterloss
  106.  
  107. //Temperatur
  108. 2 call player_temp_calculation; //2 = sleep time of this loop //TeeChange
  109. if ((_lastTemp - dayz_temperatur) > 0.75 or (_lastTemp - dayz_temperatur) < -0.75 ) then {
  110. player setVariable ["temperature",dayz_temperatur,true];
  111. _lastTemp = dayz_temperatur;
  112. };
  113.  
  114. //can get nearby infection
  115. if (!r_player_infected and !_isPZombie) then {
  116. //Infectionriskstart
  117. if (dayz_temperatur < ((80 / 100) * (dayz_temperaturnormal - dayz_temperaturmin) + dayz_temperaturmin)) then { //TeeChange
  118. _listTalk = _mylastPos nearEntities ["CAManBase",8];
  119. {
  120. if (_x getVariable["USEC_infected",false]) then {
  121. _rnd = (random 1) * (((dayz_temperaturnormal - dayz_temperatur) * (100 /(dayz_temperaturnormal - dayz_temperaturmin)))/ 50); //TeeChange
  122. if (_rnd < 0.1) then {
  123. _rnd = random 1;
  124. if (_rnd > 0.7) then {
  125. r_player_infected = true;
  126. //player setVariable["USEC_infected",true];
  127. };
  128. };
  129. };
  130. } forEach _listTalk;
  131. if (dayz_temperatur < ((50 / 100) * (dayz_temperaturnormal - dayz_temperaturmin) + dayz_temperaturmin)) then { //TeeChange
  132. _rnd = (random 1) * (((dayz_temperaturnormal - dayz_temperatur) * (100 /(dayz_temperaturnormal - dayz_temperaturmin)))/ 25); //TeeChange
  133. if (_rnd < 0.05) then {
  134. _rnd = random 1;
  135. if (_rnd > 0.95) then {
  136. r_player_infected = true;
  137. //player setVariable["USEC_infected",true];
  138. };
  139. };
  140. };
  141. };
  142. };
  143.  
  144. //If has infection reduce blood cough and add shake
  145. if (r_player_infected) then {
  146. if !(player getVariable["USEC_infected",false]) then {
  147. player setVariable["USEC_infected",true,true];
  148. };
  149.  
  150. _rnd = ceil (random 8);
  151. [player,"cough",_rnd,false,9] call dayz_zombieSpeak;
  152.  
  153. if (_rnd < 3) then {
  154. addCamShake [2, 1, 25];
  155. };
  156. if (r_player_blood > 3000) then {
  157. r_player_blood = r_player_blood - 3;
  158. _bloodChanged = true;
  159. };
  160. };
  161.  
  162. //Pain Shake Effects
  163. if (r_player_inpain and !r_player_unconscious) then {
  164. playSound "breath_1";
  165. addCamShake [2, 1, 25];
  166. };
  167.  
  168. //Hunger Effect
  169. _foodVal = dayz_statusArray select 0;
  170. _thirstVal = dayz_statusArray select 1;
  171. if (_thirstVal <= 0) then {
  172. _result = r_player_blood - 10;
  173. if (_result < 0) then {
  174. _id = [player,"dehyd"] spawn player_death;
  175. } else {
  176. r_player_blood = _result;
  177. _bloodChanged = true;
  178. };
  179. };
  180. if (_foodVal <= 0) then {
  181. _result = r_player_blood - 10;
  182. if (_result < 0) then {
  183. _id = [player,"starve"] spawn player_death;
  184. } else {
  185. r_player_blood = _result;
  186. _bloodChanged = true;
  187. };
  188. };
  189.  
  190. if (_foodVal >= 0.9 and _thirstVal >= 0.9) then {
  191. if (!r_player_infected and !r_player_inpain and !r_player_injured) then {
  192. _result = r_player_blood + 10;
  193. if (_result >= r_player_bloodTotal) then {
  194. r_player_blood = r_player_bloodTotal;
  195. } else {
  196. r_player_blood = _result;
  197. };
  198. _bloodChanged = true;
  199. };
  200. };
  201.  
  202. //Record low blood
  203. _lowBlood = player getVariable ["USEC_lowBlood", false];
  204. if ((r_player_blood < r_player_bloodTotal) and !_lowBlood) then {
  205. player setVariable["USEC_lowBlood",true,true];
  206. };
  207.  
  208. //Broadcast Hunger/Thirst
  209. _messTimer = _messTimer + 1;
  210. if (_messTimer > 15) then {
  211. _messTimer = 0;
  212. player setVariable ["messing",[dayz_hunger,dayz_thirst],true];
  213. };
  214.  
  215. //check if can disconnect
  216. if (!dayz_canDisconnect) then {
  217. if ((time - dayz_damageCounter) > 180) then {
  218. if (!r_player_unconscious) then {
  219. dayz_canDisconnect = true;
  220. //["PVDZE_plr_DiscRem",getPlayerUID player] call callRpcProcedure;
  221. PVDZE_plr_DiscRem = getPlayerUID player;
  222. publicVariableServer "PVDZE_plr_DiscRem";
  223.  
  224. //Ensure Control is hidden
  225. _display = uiNamespace getVariable 'DAYZ_GUI_display';
  226. _control = _display displayCtrl 1204;
  227. _control ctrlShow false;
  228. };
  229. };
  230. };
  231.  
  232. if(_bloodChanged) then {
  233. player setVariable["USEC_BloodQty",r_player_blood];
  234. };
  235.  
  236. //Save Checker
  237. if (dayz_unsaved) then {
  238. if ((time - dayz_lastSave) > _saveTime) then {
  239. PVDZE_plr_Save = [player,dayz_Magazines,false,false];
  240. publicVariableServer "PVDZE_plr_Save";
  241.  
  242. dayz_unsaved = false;
  243.  
  244. //diag_log format["Save Checker: %1", PVDZE_plr_Save];
  245.  
  246. if (isServer) then {
  247. PVDZE_plr_Save call server_playerSync;
  248. };
  249.  
  250. dayz_lastSave = time;
  251. dayz_Magazines = [];
  252. };
  253. };
  254.  
  255. //Attach Trigger Current Object
  256. //dayz_playerTrigger attachTo [_refObj,[0,0,0]];
  257. //dayz_playerTrigger setTriggerArea [_size,_size,0,false];
  258.  
  259. // If in combat, display counter and restrict logout
  260. _startcombattimer = player getVariable["startcombattimer",0];
  261. if (_startcombattimer == 1) then {
  262. player setVariable["combattimeout", time + 30, true];
  263. player setVariable["startcombattimer", 0, true];
  264. dayz_combat = 1;
  265. };
  266.  
  267. _combattimeout = player getVariable["combattimeout",0];
  268. if (_combattimeout > 0) then {
  269. _timeleft = _combattimeout - time;
  270. if (_timeleft > 0) then {
  271. //hintSilent format["In Combat: %1",round(_timeleft)];
  272. } else {
  273. //hintSilent "Not in Combat";
  274. player setVariable["combattimeout", 0, true];
  275. dayz_combat = 0;
  276. _combatdisplay = uiNamespace getVariable 'DAYZ_GUI_display';
  277. _combatcontrol = _combatdisplay displayCtrl 1307;
  278. _combatcontrol ctrlShow true;
  279. };
  280. } else {
  281. //hintSilent "Not in Combat";
  282. dayz_combat = 0;
  283. _combatdisplay = uiNamespace getVariable 'DAYZ_GUI_display';
  284. _combatcontrol = _combatdisplay displayCtrl 1307;
  285. _combatcontrol ctrlShow true;
  286. };
  287.  
  288. /*
  289. setGroupIconsVisible [false,false];
  290. clearGroupIcons group player;
  291. */
  292. "colorCorrections" ppEffectAdjust [1, 1, 0, [1, 1, 1, 0.0], [1, 1, 1, (r_player_blood/r_player_bloodTotal)], [1, 1, 1, 0.0]];
  293. "colorCorrections" ppEffectCommit 0;
  294. sleep 2;
  295.  
  296. _myPos = player getVariable["lastPos",[]];
  297. if (count _myPos > 0) then {
  298. player setVariable["lastPos",_mylastPos, true];
  299. player setVariable["lastPos",[]];
  300. };
  301.  
  302. if (!isNil "_mylastPos") then {
  303. _lastPos = getPosATL _refObj;
  304. if (!_inVehicle) then {
  305. if (_mylastPos distance _lastPos > _maxDistancePlayer) then {
  306. if (alive player) then {
  307. player setPosATL _mylastPos;
  308. diag_log ("Player Teleport Revert : "+ str(_mylastPos distance _lastPos));
  309. };
  310. };
  311. } else {
  312. if (_mylastPos distance _lastPos > _maxDistanceVehicle) then {
  313. if (alive player) then {
  314. player setPosATL _mylastPos;
  315. diag_log ("Vehicle Teleport Revert : "+ str(_mylastPos distance _lastPos));
  316. };
  317. };
  318. };
  319. };
  320.  
  321. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement