Advertisement
Guest User

player_spawn_2.sqf updated for 1.7.5.1

a guest
Feb 23rd, 2013
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.09 KB | None | 0 0
  1. private["_refObj","_size","_vel","_speed","_hunger","_thirst","_array","_unsaved","_timeOut","_result","_lastSave"];
  2. disableSerialization;
  3. _timeOut = 0;
  4. _messTimer = 0;
  5. _lastSave = 0;
  6. _lastTemp = dayz_temperatur;
  7. _debug = getMarkerpos "respawn_west";
  8. _isBandit = false;
  9. _isHero = false;
  10.  
  11. player setVariable ["temperature",dayz_temperatur,true];
  12.  
  13. dayz_myLoad = (((count dayz_myBackpackMags) * 0.2) + (count dayz_myBackpackWpns)) + (((count dayz_myMagazines) * 0.1) + (count dayz_myWeapons * 0.5));
  14.  
  15. //player addMagazine "Hatchet_swing";
  16. //player addWeapon "MeleeHatchet";
  17.  
  18. while {true} do {
  19. //Initialize
  20. _refObj = vehicle player;
  21. _size = (sizeOf typeOf _refObj) * 0.6;
  22. _vel = velocity player;
  23. _speed = round((_vel distance [0,0,0]) * 3.5);
  24. _saveTime = (playersNumber west * 2) + 10;
  25.  
  26. //reset position
  27. _randomSpot = true;
  28. _tempPos = getPosATL player;
  29. _distance = _debug distance _tempPos;
  30. if (_distance < 2000) then {
  31. _randomSpot = false;
  32. };
  33. _distance = [0,0,0] distance _tempPos;
  34. if (_distance < 500) then {
  35. _randomSpot = false;
  36. };
  37. _distance = _mylastPos distance _tempPos;
  38. if (_distance > 400) then {
  39. _randomSpot = false;
  40. };
  41.  
  42. if (_randomSpot) then {
  43. _mylastPos = _tempPos;
  44. };
  45.  
  46. dayz_mylastPos = _mylastPos;
  47. dayz_areaAffect = _size;
  48.  
  49. //CheckVehicle
  50. /*
  51. if (_refObj != player) then {
  52. _isSync =_refObj getVariable ["ObjectID",0] > 0;
  53. if (!_isSync) then {
  54. _veh allowDamage true;
  55. _veh setDamage 1;
  56. player setDamage 1;
  57. };
  58. };
  59. */
  60.  
  61. if (_speed > 0.1) then {
  62. _timeOut = _timeOut + 1;
  63. };
  64.  
  65. _humanity = player getVariable ["humanity",0];
  66. if (_timeOut > 150) then {
  67. _timeOut = 0;
  68. if (_humanity < 2500) then {
  69. _humanity = _humanity + 150;
  70. _humanity = _humanity min 2500;
  71. player setVariable ["humanity",_humanity,true];
  72. };
  73. };
  74.  
  75. if (_humanity < -2000 and !_isBandit) then {
  76. _isBandit = true;
  77. _model = typeOf player;
  78. if (_model == "Survivor2_DZ") then {
  79. [dayz_playerUID,dayz_characterID,"Bandit1_DZ"] spawn player_humanityMorph;
  80. };
  81. if (_model == "SurvivorW2_DZ") then {
  82. [dayz_playerUID,dayz_characterID,"BanditW1_DZ"] spawn player_humanityMorph;
  83. };
  84. };
  85.  
  86. if (_humanity > 0 and _isBandit) then {
  87. _isBandit = false;
  88. _model = typeOf player;
  89. if (_model == "Bandit1_DZ") then {
  90. [dayz_playerUID,dayz_characterID,"Survivor2_DZ"] spawn player_humanityMorph;
  91. };
  92. if (_model == "BanditW1_DZ") then {
  93. [dayz_playerUID,dayz_characterID,"SurvivorW2_DZ"] spawn player_humanityMorph;
  94. };
  95. };
  96.  
  97. if (_humanity > 5000 and !_isHero) then {
  98. _isBandit = false;
  99. _model = typeOf player;
  100. if (_model == "Survivor2_DZ") then {
  101. [dayz_playerUID,dayz_characterID,"Survivor3_DZ"] spawn player_humanityMorph;
  102. };
  103. };
  104.  
  105. //Has infection?
  106. if (r_player_infected) then {
  107. [player,"cough",8,false] call dayz_zombieSpeak;
  108. };
  109.  
  110. //Record Check
  111. _lastUpdate = time - dayZ_lastPlayerUpdate;
  112. if (_lastUpdate > 8) then {
  113. //POSITION?
  114. _distance = dayz_myPosition distance player;
  115. if (_distance > 10) then {
  116. //Player has moved
  117. dayz_myPosition = getPosATL player;
  118. player setVariable["posForceUpdate",true,true];
  119. dayz_unsaved = true;
  120. dayZ_lastPlayerUpdate = time;
  121. };
  122. };
  123.  
  124. //Hunger
  125. _hunger = +((((r_player_bloodTotal - r_player_blood) / r_player_bloodTotal) * 5) + _speed + dayz_myLoad) * 3;
  126. if (time - dayz_panicCooldown < 120) then {
  127. _hunger = _hunger * 2;
  128. };
  129. dayz_hunger = dayz_hunger + (_hunger / 60);
  130.  
  131. //Thirst
  132. _thirst = 2;
  133. if (_refObj == player) then {
  134. _thirst = (_speed + 4) * 3;
  135. };
  136. dayz_thirst = dayz_thirst + (_thirst / 60) * (dayz_temperatur / dayz_temperaturnormal); //TeeChange Temperatur effects added Max Effects: -25% and + 16.6% waterloss
  137.  
  138. //Temperatur
  139. 2 call player_temp_calculation; //2 = sleep time of this loop //TeeChange
  140. if ((_lastTemp - dayz_temperatur) > 0.75 or (_lastTemp - dayz_temperatur) < -0.75 ) then {
  141. player setVariable ["temperature",dayz_temperatur,true];
  142. _lastTemp = dayz_temperatur;
  143. };
  144.  
  145. //can get nearby infection
  146. if (!r_player_infected) then {
  147. // Infectionriskstart
  148. if (dayz_temperatur < ((80 / 100) * (dayz_temperaturnormal - dayz_temperaturmin) + dayz_temperaturmin)) then { //TeeChange
  149. _listTalk = _mylastPos nearEntities ["CAManBase",8];
  150. {
  151. if (_x getVariable["USEC_infected",false]) then {
  152. _rnd = (random 1) * (((dayz_temperaturnormal - dayz_temperatur) * (100 /(dayz_temperaturnormal - dayz_temperaturmin)))/ 50); //TeeChange
  153. if (_rnd < 0.1) then {
  154. _rnd = random 1;
  155. if (_rnd > 0.7) then {
  156. r_player_infected = true;
  157. player setVariable["USEC_infected",true];
  158. };
  159. };
  160. };
  161. } forEach _listTalk;
  162. if (dayz_temperatur < ((50 / 100) * (dayz_temperaturnormal - dayz_temperaturmin) + dayz_temperaturmin)) then { //TeeChange
  163. _rnd = (random 1) * (((dayz_temperaturnormal - dayz_temperatur) * (100 /(dayz_temperaturnormal - dayz_temperaturmin)))/ 25); //TeeChange
  164. if (_rnd < 0.05) then {
  165. _rnd = random 1;
  166. if (_rnd > 0.95) then {
  167. r_player_infected = true;
  168. player setVariable["USEC_infected",true];
  169. };
  170. };
  171. };
  172. };
  173. };
  174.  
  175. //If has infection reduce blood
  176. if (r_player_infected) then {
  177. if (r_player_blood > 6000) then {
  178. r_player_blood = r_player_blood - 3;
  179. };
  180. };
  181.  
  182. //Hunger Effect
  183. _foodVal = dayz_statusArray select 0;
  184. _thirstVal = dayz_statusArray select 1;
  185. if (_thirstVal <= 0) then {
  186. _result = r_player_blood - 10;
  187. if (_result < 0) then {
  188. _id = [player,"dehyd"] spawn player_death;
  189. } else {
  190. r_player_blood = _result;
  191. };
  192. };
  193. if (_foodVal <= 0) then {
  194. _result = r_player_blood - 10;
  195. if (_result < 0) then {
  196. _id = [player,"starve"] spawn player_death;
  197. } else {
  198. r_player_blood = _result;
  199. };
  200. };
  201.  
  202. //Record low bloow
  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. ["dayzDiscoRem",getPlayerUID player] call callRpcProcedure;
  221.  
  222. //Ensure Control is hidden
  223. _display = uiNamespace getVariable 'DAYZ_GUI_display';
  224. _control = _display displayCtrl 1204;
  225. _control ctrlShow false;
  226. };
  227. };
  228. };
  229.  
  230. //Save Checker
  231. if (dayz_unsaved) then {
  232. if ((time - dayz_lastSave) > _saveTime) then {
  233. ["dayzPlayerSave",[player,dayz_Magazines,false]] call callRpcProcedure;
  234.  
  235. dayz_lastSave = time;
  236. dayz_Magazines = [];
  237. };
  238. _lastSave = _lastSave + 2;
  239. } else {
  240. dayz_lastSave = time;
  241. _lastSave = 0;
  242. };
  243.  
  244. if (!dayz_unsaved) then {
  245. dayz_lastSave = time;
  246. };
  247.  
  248. //Attach Trigger Current Object
  249. //dayz_playerTrigger attachTo [_refObj,[0,0,0]];
  250. //dayz_playerTrigger setTriggerArea [_size,_size,0,false];
  251.  
  252. //Debug Info
  253. _headShots = player getVariable["headShots",0];
  254. _kills = player getVariable["zombieKills",0];
  255. _killsH = player getVariable["humanKills",0];
  256. _killsB = player getVariable["banditKills",0];
  257. _humanity = player getVariable["humanity",0];
  258. _zombies = count entities "zZombie_Base";
  259. _zombiesA = {alive _x} count entities "zZombie_Base";
  260. _average = diag_fps;
  261. //_groups = count allGroups;
  262. //_dead = count allDead;
  263. //dayz_zombiesLocal = {local _x} count entities "zZombie_Base";
  264. //_loot = count allMissionObjects "WeaponHolder";
  265. //_wrecks = count allMissionObjects "Wreck_Base";
  266. //_lootL = {local _x} count allMissionObjects "WeaponHolder";
  267. //_speed = (_vel distance [0,0,0]);
  268.  
  269. hintSilent parseText format["<t size='1.5' font='Bitstream' align='center'><t color='#FFCC00'>Aus<t color='#006600'>Titan</t><t color='#FFCC00'>Gaming</t><br /><br /><t size='1.2' font='Bitstream' align='center'><t color='#006600'>Debug Monitor</t><br /><br /><t size='1.3' color='#FFCC00' font='Bitstream' >%14<br /><br /></t><t size='1' font='Bitstream' align='left' ><t color='#FFFFFF'>Blood: </t><t size='1' font='Bitstream' align='right' >%4</t><t size='1' font='Bitstream' align='left' ><br /><t color='#FFFFFF'>Humanity: </t><t size='1' font='Bitstream' align='right' >%11</t><t size='1' font='Bitstream' align='left' ><br /><br /><t color='#FFFFFF'>Headshots: </t><t size='1' font='Bitstream' align='right' >%2</t><t size='1' font='Bitstream' align='left' ><br /><t color='#ff0000'>FPS: </t><t size='1' font='Bitstream' align='right' >%16</t><t size='1' font='Bitstream' align='left' ><br /><br /><t color='#FFFFFF'>Murders: </t><t size='1' font='Bitstream' align='right' >%10</t><t size='1' font='Bitstream' align='left' ><br /><t color='#FFFFFF'>Bandits Killed: </t><t size='1' font='Bitstream' align='right' >%12</t><t size='1' font='Bitstream' align='left' ><br /><t color='#FFFFFF'>Zombies (alive/total):<t color='#FFCC00'><t size='1' font='Bitstream' align='right' >%15/%8</t>",_kills,_headShots,_speed,r_player_blood,round(dayz_temperatur),r_player_infected,dayz_inside,_zombies,_lastSave,_killsH,round(_humanity),_killsB,_freeTarget,dayz_playerName,_zombiesA,_average];
  270.  
  271.  
  272. // If in combat, display counter and restrict logout
  273. _startcombattimer = player getVariable["startcombattimer",0];
  274. if (_startcombattimer == 1) then {
  275. player setVariable["combattimeout", time + 30, true];
  276. player setVariable["startcombattimer", 0, true];
  277. dayz_combat = 1;
  278. };
  279.  
  280. _combattimeout = player getVariable["combattimeout",0];
  281. if (_combattimeout > 0) then {
  282. _timeleft = _combattimeout - time;
  283. if (_timeleft > 0) then {
  284. //hintSilent format["In Combat: %1",round(_timeleft)];
  285. } else {
  286. //hintSilent "Not in Combat";
  287. player setVariable["combattimeout", 0, true];
  288. dayz_combat = 0;
  289. _combatdisplay = uiNamespace getVariable 'DAYZ_GUI_display';
  290. _combatcontrol = _combatdisplay displayCtrl 1307;
  291. _combatcontrol ctrlShow true;
  292. };
  293. } else {
  294. //hintSilent "Not in Combat";
  295. dayz_combat = 0;
  296. _combatdisplay = uiNamespace getVariable 'DAYZ_GUI_display';
  297. _combatcontrol = _combatdisplay displayCtrl 1307;
  298. _combatcontrol ctrlShow true;
  299. };
  300.  
  301. /*
  302. setGroupIconsVisible [false,false];
  303. clearGroupIcons group player;
  304. */
  305. "colorCorrections" ppEffectAdjust [1, 1, 0, [1, 1, 1, 0.0], [1, 1, 1, (r_player_blood/r_player_bloodTotal)], [1, 1, 1, 0.0]];
  306. "colorCorrections" ppEffectCommit 0;
  307. sleep 2;
  308.  
  309. _myPos = player getVariable["lastPos",[]];
  310. if (count _myPos > 0) then {
  311. player setVariable["lastPos",_mylastPos, true];
  312. player setVariable["lastPos",[]];
  313. };
  314.  
  315. _lastPos = getPosATL player;
  316. if (player == vehicle player) then {
  317. if (_mylastPos distance _lastPos > 200) then {
  318. if (alive player) then {
  319. player setPosATL _mylastPos;
  320. };
  321. };
  322. } else {
  323. if (_mylastPos distance _lastPos > 800) then {
  324. if (alive player) then {
  325. player setPosATL _mylastPos;
  326. };
  327. };
  328. };
  329.  
  330. //Hatchet ammo fix
  331. //"MeleeHatchet" call dayz_meleeMagazineCheck;
  332.  
  333. //Crowbar ammo fix
  334. //"MeleeCrowbar" call dayz_meleeMagazineCheck;
  335. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement