Guest User

Untitled

a guest
Aug 18th, 2014
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 28.72 KB | None | 0 0
  1. [] spawn {[] execVM "infiSTAR\AH.sqf";};
  2. waituntil {!isnil "bis_fnc_init"};
  3.  
  4. BIS_MPF_remoteExecutionServer = {
  5. if ((_this select 1) select 2 == "JIPrequest") then {
  6. [nil,(_this select 1) select 0,"loc",rJIPEXEC,[any,any,"per","execVM","ca\Modules\Functions\init.sqf"]] call RE;
  7. };
  8. };
  9.  
  10. BIS_Effects_Burn = {};
  11. server_playerLogin = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_playerLogin.sqf";
  12. server_playerSetup = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_playerSetup.sqf";
  13. server_onPlayerDisconnect = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_onPlayerDisconnect.sqf";
  14. server_updateObject = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_updateObject.sqf";
  15. server_playerDied = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_playerDied.sqf";
  16. server_publishObj = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_publishObject.sqf";
  17. server_deleteObj = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_deleteObj.sqf";
  18. server_swapObject = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_swapObject.sqf";
  19. server_publishVeh = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_publishVehicle.sqf";
  20. server_publishVeh2 = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_publishVehicle2.sqf";
  21. server_publishVeh3 = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_publishVehicle3.sqf";
  22. server_tradeObj = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_tradeObject.sqf";
  23. server_traders = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_traders.sqf";
  24. server_playerSync = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_playerSync.sqf";
  25. server_spawnCrashSite = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_spawnCrashSite.sqf";
  26. server_spawnEvents = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_spawnEvent.sqf";
  27. //server_weather = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_weather.sqf";
  28. fnc_plyrHit = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\fnc_plyrHit.sqf";
  29. server_deaths = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_playerDeaths.sqf";
  30. server_maintainArea = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_maintainArea.sqf";
  31.  
  32. /* PVS/PVC - Skaronator */
  33. server_sendToClient = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_sendToClient.sqf";
  34.  
  35. //onPlayerConnected {[_uid,_name] call server_onPlayerConnect;};
  36. onPlayerDisconnected {[_uid,_name] call server_onPlayerDisconnect;};
  37.  
  38. server_updateNearbyObjects = {
  39. private["_pos"];
  40. _pos = _this select 0;
  41. {
  42. [_x, "gear"] call server_updateObject;
  43. } count nearestObjects [_pos, dayz_updateObjects, 10];
  44. };
  45.  
  46. server_handleZedSpawn = {
  47. private["_zed"];
  48. _zed = _this select 0;
  49. _zed enableSimulation false;
  50. };
  51.  
  52. zombie_findOwner = {
  53. private["_unit"];
  54. _unit = _this select 0;
  55. #ifdef DZE_SERVER_DEBUG
  56. diag_log ("CLEANUP: DELETE UNCONTROLLED ZOMBIE: " + (typeOf _unit) + " OF: " + str(_unit) );
  57. #endif
  58. deleteVehicle _unit;
  59. };
  60.  
  61. vehicle_handleInteract = {
  62. private["_object"];
  63. _object = _this select 0;
  64. needUpdate_objects = needUpdate_objects - [_object];
  65. [_object, "all"] call server_updateObject;
  66. };
  67.  
  68. array_reduceSizeReverse = {
  69. private["_array","_count","_num","_newarray","_startnum","_index"];
  70. _array = _this select 0;
  71. _newarray = [];
  72. _count = _this select 1;
  73. _num = count _array;
  74. if (_num > _count) then {
  75. _startnum = _num - 1;
  76. _index = _count - 1;
  77. for "_i" from 0 to _index do {
  78. _newarray set [(_index-_i),_array select (_startnum - _i)];
  79. };
  80. _array = _newarray;
  81. };
  82. _array
  83. };
  84.  
  85. array_reduceSize = {
  86. private ["_array1","_array","_count","_num"];
  87. _array1 = _this select 0;
  88. _array = _array1 - ["Hatchet_Swing","Machete_Swing","Fishing_Swing","sledge_swing","crowbar_swing","CSGAS"];
  89. _count = _this select 1;
  90. _num = count _array;
  91. if (_num > _count) then {
  92. _array resize _count;
  93. };
  94. _array
  95. };
  96.  
  97. object_handleServerKilled = {
  98. private["_unit","_objectID","_objectUID","_killer"];
  99. _unit = _this select 0;
  100. _killer = _this select 1;
  101.  
  102. _objectID = _unit getVariable ["ObjectID","0"];
  103. _objectUID = _unit getVariable ["ObjectUID","0"];
  104.  
  105. [_objectID,_objectUID,_killer] call server_deleteObj;
  106.  
  107. _unit removeAllMPEventHandlers "MPKilled";
  108. _unit removeAllEventHandlers "Killed";
  109. _unit removeAllEventHandlers "HandleDamage";
  110. _unit removeAllEventHandlers "GetIn";
  111. _unit removeAllEventHandlers "GetOut";
  112. };
  113.  
  114. check_publishobject = {
  115. private["_allowed","_object","_playername"];
  116.  
  117. _object = _this select 0;
  118. _playername = _this select 1;
  119. _allowed = false;
  120.  
  121. if ((typeOf _object) in dayz_allowedObjects) then {
  122. //diag_log format ["DEBUG: Object: %1 published by %2 is Safe",_object, _playername];
  123. _allowed = true;
  124. };
  125. _allowed
  126. };
  127.  
  128. //event Handlers
  129. eh_localCleanup = {
  130. private ["_object"];
  131. _object = _this select 0;
  132. _object addEventHandler ["local", {
  133. if(_this select 1) then {
  134. private["_type","_unit"];
  135. _unit = _this select 0;
  136. _type = typeOf _unit;
  137. _myGroupUnit = group _unit;
  138. _unit removeAllMPEventHandlers "mpkilled";
  139. _unit removeAllMPEventHandlers "mphit";
  140. _unit removeAllMPEventHandlers "mprespawn";
  141. _unit removeAllEventHandlers "FiredNear";
  142. _unit removeAllEventHandlers "HandleDamage";
  143. _unit removeAllEventHandlers "Killed";
  144. _unit removeAllEventHandlers "Fired";
  145. _unit removeAllEventHandlers "GetOut";
  146. _unit removeAllEventHandlers "GetIn";
  147. _unit removeAllEventHandlers "Local";
  148. clearVehicleInit _unit;
  149. deleteVehicle _unit;
  150. if ((count (units _myGroupUnit) == 0) && (_myGroupUnit != grpNull)) then {
  151. deleteGroup _myGroupUnit;
  152. };
  153. //_unit = nil;
  154. // diag_log ("CLEANUP: DELETED A " + str(_type) );
  155. };
  156. }];
  157. };
  158.  
  159. server_hiveWrite = {
  160. private["_data"];
  161. _data = "HiveExt" callExtension _this;
  162. };
  163.  
  164. server_hiveReadWrite = {
  165. private["_key","_resultArray","_data"];
  166. _key = _this;
  167. _data = "HiveExt" callExtension _key;
  168. _resultArray = call compile format ["%1",_data];
  169. _resultArray
  170. };
  171.  
  172. server_hiveReadWriteLarge = {
  173. private["_key","_resultArray","_data"];
  174. _key = _this;
  175. _data = "HiveExt" callExtension _key;
  176. _resultArray = call compile _data;
  177. _resultArray
  178. };
  179.  
  180. server_checkIfTowed = {
  181. private ["_vehicle","_player","_attached"];
  182. if (DZE_HeliLift) then {
  183. _vehicle = _this select 0;
  184. _player = _this select 2;
  185. _attached = _vehicle getVariable["attached",false];
  186. if (typeName _attached == "OBJECT") then {
  187. _player action ["eject", _vehicle];
  188. detach _vehicle;
  189. _vehicle setVariable["attached",false,true];
  190. _attached setVariable["hasAttached",false,true];
  191. };
  192. };
  193. };
  194.  
  195. server_characterSync = {
  196. private ["_characterID","_playerPos","_playerGear","_playerBackp","_medical","_currentState","_currentModel","_key"];
  197. _characterID = _this select 0;
  198. _playerPos = _this select 1;
  199. _playerGear = _this select 2;
  200. _playerBackp = _this select 3;
  201. _medical = _this select 4;
  202. _currentState = _this select 5;
  203. _currentModel = _this select 6;
  204.  
  205. _key = format["CHILD:201:%1:%2:%3:%4:%5:%6:%7:%8:%9:%10:%11:%12:%13:%14:%15:%16:",_characterID,_playerPos,_playerGear,_playerBackp,_medical,false,false,0,0,0,0,_currentState,0,0,_currentModel,0];
  206. _key call server_hiveWrite;
  207. };
  208.  
  209. if(isnil "dayz_MapArea") then {
  210. dayz_MapArea = 10000;
  211. };
  212. if(isnil "DynamicVehicleArea") then {
  213. DynamicVehicleArea = dayz_MapArea / 2;
  214. };
  215.  
  216. // Get all buildings && roads only once TODO: set variables to nil after done if nessicary
  217. MarkerPosition = getMarkerPos "center";
  218. RoadList = MarkerPosition nearRoads DynamicVehicleArea;
  219.  
  220. // Very taxing !!! but only on first startup
  221. BuildingList = [];
  222. {
  223. if (DZE_MissionLootTable) then {
  224. if (isClass (missionConfigFile >> "CfgBuildingLoot" >> (typeOf _x))) then
  225. {
  226. BuildingList set [count BuildingList,_x];
  227. };
  228. } else {
  229. if (isClass (configFile >> "CfgBuildingLoot" >> (typeOf _x))) then
  230. {
  231. BuildingList set [count BuildingList,_x];
  232. };
  233. };
  234.  
  235.  
  236. } count (MarkerPosition nearObjects ["building",DynamicVehicleArea]);
  237.  
  238. spawn_vehicles = {
  239. private ["_random","_lastIndex","_weights","_index","_vehicle","_velimit","_qty","_isAir","_isShip","_position","_dir","_istoomany","_veh","_objPosition","_marker","_iClass","_itemTypes","_cntWeights","_itemType","_num","_allCfgLoots"];
  240.  
  241. if (!isDedicated) exitWith { }; //Be sure the run this
  242.  
  243. while {count AllowedVehiclesList > 0} do {
  244. // BIS_fnc_selectRandom replaced because the index may be needed to remove the element
  245. _index = floor random count AllowedVehiclesList;
  246. _random = AllowedVehiclesList select _index;
  247.  
  248. _vehicle = _random select 0;
  249. _velimit = _random select 1;
  250.  
  251. _qty = {_x == _vehicle} count serverVehicleCounter;
  252.  
  253. // If under limit allow to proceed
  254. if (_qty <= _velimit) exitWith {};
  255.  
  256. // vehicle limit reached, remove vehicle from list
  257. // since elements cannot be removed from an array, overwrite it with the last element && cut the last element of (as long as order is not important)
  258. _lastIndex = (count AllowedVehiclesList) - 1;
  259. if (_lastIndex != _index) then {
  260. AllowedVehiclesList set [_index, AllowedVehiclesList select _lastIndex];
  261. };
  262. AllowedVehiclesList resize _lastIndex;
  263. };
  264.  
  265. if (count AllowedVehiclesList == 0) then {
  266. diag_log("DEBUG: unable to find suitable vehicle to spawn");
  267. } else {
  268.  
  269. // add vehicle to counter for next pass
  270. serverVehicleCounter set [count serverVehicleCounter,_vehicle];
  271.  
  272. // Find Vehicle Type to better control spawns
  273. _isAir = _vehicle isKindOf "Air";
  274. _isShip = _vehicle isKindOf "Ship";
  275.  
  276. if(_isShip || _isAir) then {
  277. if(_isShip) then {
  278. // Spawn anywhere on coast on water
  279. waitUntil{!isNil "BIS_fnc_findSafePos"};
  280. _position = [MarkerPosition,0,DynamicVehicleArea,10,1,2000,1] call BIS_fnc_findSafePos;
  281. //diag_log("DEBUG: spawning boat near coast " + str(_position));
  282. } else {
  283. // Spawn air anywhere that is flat
  284. waitUntil{!isNil "BIS_fnc_findSafePos"};
  285. _position = [MarkerPosition,0,DynamicVehicleArea,10,0,2000,0] call BIS_fnc_findSafePos;
  286. //diag_log("DEBUG: spawning air anywhere flat " + str(_position));
  287. };
  288.  
  289.  
  290. } else {
  291. // Spawn around buildings && 50% near roads
  292. if((random 1) > 0.5) then {
  293.  
  294. waitUntil{!isNil "BIS_fnc_selectRandom"};
  295. _position = RoadList call BIS_fnc_selectRandom;
  296.  
  297. _position = _position modelToWorld [0,0,0];
  298.  
  299. waitUntil{!isNil "BIS_fnc_findSafePos"};
  300. _position = [_position,0,10,10,0,2000,0] call BIS_fnc_findSafePos;
  301.  
  302. //diag_log("DEBUG: spawning near road " + str(_position));
  303.  
  304. } else {
  305.  
  306. waitUntil{!isNil "BIS_fnc_selectRandom"};
  307. _position = BuildingList call BIS_fnc_selectRandom;
  308.  
  309. _position = _position modelToWorld [0,0,0];
  310.  
  311. waitUntil{!isNil "BIS_fnc_findSafePos"};
  312. _position = [_position,0,40,5,0,2000,0] call BIS_fnc_findSafePos;
  313.  
  314. //diag_log("DEBUG: spawning around buildings " + str(_position));
  315.  
  316. };
  317. };
  318. // only proceed if two params otherwise BIS_fnc_findSafePos failed && may spawn in air
  319. if ((count _position) == 2) then {
  320.  
  321. _dir = round(random 180);
  322.  
  323. _istoomany = _position nearObjects ["AllVehicles",50];
  324. if((count _istoomany) > 0) exitWith { diag_log("DEBUG: Too many vehicles at " + str(_position)); };
  325.  
  326. //place vehicle
  327. _veh = createVehicle [_vehicle, _position, [], 0, "CAN_COLLIDE"];
  328. _veh setdir _dir;
  329. _veh setpos _position;
  330.  
  331. if(DZEdebug) then {
  332. _marker = createMarker [str(_position) , _position];
  333. _marker setMarkerShape "ICON";
  334. _marker setMarkerType "DOT";
  335. _marker setMarkerText _vehicle;
  336. };
  337.  
  338. // Get position with ground
  339. _objPosition = getPosATL _veh;
  340.  
  341. clearWeaponCargoGlobal _veh;
  342. clearMagazineCargoGlobal _veh;
  343. // _veh setVehicleAmmo DZE_vehicleAmmo;
  344.  
  345. // Add 0-3 loots to vehicle using random cfgloots
  346. _num = floor(random 4);
  347. _allCfgLoots = ["trash","civilian","food","generic","medical","military","policeman","hunter","worker","clothes","militaryclothes","specialclothes","trash"];
  348.  
  349. for "_x" from 1 to _num do {
  350. _iClass = _allCfgLoots call BIS_fnc_selectRandom;
  351.  
  352. _itemTypes = [];
  353. if (DZE_MissionLootTable) then{
  354. {
  355. _itemTypes set[count _itemTypes, _x select 0]
  356. } count getArray(missionConfigFile >> "cfgLoot" >> _iClass);
  357. }
  358. else {
  359. {
  360. _itemTypes set[count _itemTypes, _x select 0]
  361. } count getArray(configFile >> "cfgLoot" >> _iClass);
  362. };
  363.  
  364. _index = dayz_CLBase find _iClass;
  365. _weights = dayz_CLChances select _index;
  366. _cntWeights = count _weights;
  367.  
  368. _index = floor(random _cntWeights);
  369. _index = _weights select _index;
  370. _itemType = _itemTypes select _index;
  371. _veh addMagazineCargoGlobal [_itemType,1];
  372. //diag_log("DEBUG: spawed loot inside vehicle " + str(_itemType));
  373. };
  374.  
  375. [_veh,[_dir,_objPosition],_vehicle,true,"0"] call server_publishVeh;
  376. };
  377. };
  378. };
  379.  
  380. spawn_ammosupply = {
  381. private ["_position","_veh","_istoomany","_marker","_spawnveh","_WreckList"];
  382. if (isDedicated) then {
  383. _WreckList = ["Supply_Crate_DZE"];
  384. waitUntil{!isNil "BIS_fnc_selectRandom"};
  385. _position = RoadList call BIS_fnc_selectRandom;
  386. _position = _position modelToWorld [0,0,0];
  387. waitUntil{!isNil "BIS_fnc_findSafePos"};
  388. _position = [_position,5,20,5,0,2000,0] call BIS_fnc_findSafePos;
  389. if ((count _position) == 2) then {
  390.  
  391. _istoomany = _position nearObjects ["All",5];
  392.  
  393. if((count _istoomany) > 0) exitWith { diag_log("DEBUG VEIN: Too many at " + str(_position)); };
  394.  
  395. _spawnveh = _WreckList call BIS_fnc_selectRandom;
  396.  
  397. if(DZEdebug) then {
  398. _marker = createMarker [str(_position) , _position];
  399. _marker setMarkerShape "ICON";
  400. _marker setMarkerType "DOT";
  401. _marker setMarkerText str(_spawnveh);
  402. };
  403.  
  404. _veh = createVehicle [_spawnveh,_position, [], 0, "CAN_COLLIDE"];
  405. _veh enableSimulation false;
  406. _veh setDir round(random 360);
  407. _veh setpos _position;
  408. _veh setVariable ["ObjectID","1",true];
  409. };
  410. };
  411. };
  412.  
  413. DZE_LocalRoadBlocks = [];
  414.  
  415. spawn_roadblocks = {
  416. private ["_position","_veh","_istoomany","_marker","_spawnveh","_WreckList"];
  417. _WreckList = ["SKODAWreck","HMMWVWreck","UralWreck","datsun01Wreck","hiluxWreck","datsun02Wreck","UAZWreck","Land_Misc_Garb_Heap_EP1","Fort_Barricade_EP1","Rubbish2"];
  418.  
  419. waitUntil{!isNil "BIS_fnc_selectRandom"};
  420. if (isDedicated) then {
  421.  
  422. _position = RoadList call BIS_fnc_selectRandom;
  423.  
  424. _position = _position modelToWorld [0,0,0];
  425.  
  426. waitUntil{!isNil "BIS_fnc_findSafePos"};
  427. _position = [_position,0,10,5,0,2000,0] call BIS_fnc_findSafePos;
  428.  
  429. if ((count _position) == 2) then {
  430. // Get position with ground
  431.  
  432. _istoomany = _position nearObjects ["All",5];
  433.  
  434. if((count _istoomany) > 0) exitWith { diag_log("DEBUG: Too many at " + str(_position)); };
  435.  
  436. waitUntil{!isNil "BIS_fnc_selectRandom"};
  437. _spawnveh = _WreckList call BIS_fnc_selectRandom;
  438.  
  439. if(DZEdebug) then {
  440. _marker = createMarker [str(_position) , _position];
  441. _marker setMarkerShape "ICON";
  442. _marker setMarkerType "DOT";
  443. _marker setMarkerText str(_spawnveh);
  444. };
  445.  
  446. _veh = createVehicle [_spawnveh,_position, [], 0, "CAN_COLLIDE"];
  447. _veh enableSimulation false;
  448.  
  449. _veh setDir round(random 360); // Randomize placement a bit
  450. _veh setpos _position;
  451.  
  452. _veh setVariable ["ObjectID","1",true];
  453. };
  454.  
  455. };
  456.  
  457. };
  458.  
  459. spawn_mineveins = {
  460. private ["_position","_veh","_istoomany","_marker","_spawnveh","_positions"];
  461.  
  462. if (isDedicated) then {
  463.  
  464. _position = [getMarkerPos "center",0,(HeliCrashArea*0.75),10,0,2000,0] call BIS_fnc_findSafePos;
  465.  
  466. if ((count _position) == 2) then {
  467.  
  468. _positions = selectBestPlaces [_position, 500, "(1 + forest) * (1 + hills) * (1 - houses) * (1 - sea)", 10, 5];
  469.  
  470. _position = (_positions call BIS_fnc_selectRandom) select 0;
  471.  
  472. // Get position with ground
  473. _istoomany = _position nearObjects ["All",10];
  474.  
  475. if((count _istoomany) > 0) exitWith { diag_log("DEBUG VEIN: Too many objects at " + str(_position)); };
  476.  
  477. if(isOnRoad _position) exitWith { diag_log("DEBUG VEIN: on road " + str(_position)); };
  478.  
  479. _spawnveh = ["Iron_Vein_DZE","Iron_Vein_DZE","Iron_Vein_DZE","Iron_Vein_DZE","Iron_Vein_DZE","Silver_Vein_DZE","Silver_Vein_DZE","Silver_Vein_DZE","Gold_Vein_DZE","Gold_Vein_DZE"] call BIS_fnc_selectRandom;
  480.  
  481. if(DZEdebug) then {
  482. _marker = createMarker [str(_position) , _position];
  483. _marker setMarkerShape "ICON";
  484. _marker setMarkerType "DOT";
  485. _marker setMarkerText str(_spawnveh);
  486. };
  487.  
  488. //diag_log("DEBUG: Spawning a crashed " + _spawnveh + " with " + _spawnloot + " at " + str(_position));
  489. _veh = createVehicle [_spawnveh,_position, [], 0, "CAN_COLLIDE"];
  490. _veh enableSimulation false;
  491.  
  492. // Randomize placement a bit
  493. _veh setDir round(random 360);
  494. _veh setpos _position;
  495.  
  496. _veh setVariable ["ObjectID","1",true];
  497.  
  498.  
  499. };
  500. };
  501. };
  502.  
  503. if(isnil "DynamicVehicleDamageLow") then {
  504. DynamicVehicleDamageLow = 0;
  505. };
  506. if(isnil "DynamicVehicleDamageHigh") then {
  507. DynamicVehicleDamageHigh = 100;
  508. };
  509.  
  510. if(isnil "DynamicVehicleFuelLow") then {
  511. DynamicVehicleFuelLow = 0;
  512. };
  513. if(isnil "DynamicVehicleFuelHigh") then {
  514. DynamicVehicleFuelHigh = 100;
  515. };
  516.  
  517. if(isnil "DZE_DiagFpsSlow") then {
  518. DZE_DiagFpsSlow = false;
  519. };
  520. if(isnil "DZE_DiagFpsFast") then {
  521. DZE_DiagFpsFast = false;
  522. };
  523. if(isnil "DZE_DiagVerbose") then {
  524. DZE_DiagVerbose = false;
  525. };
  526.  
  527. dze_diag_fps = {
  528. if(DZE_DiagVerbose) then {
  529. diag_log format["DEBUG FPS : %1 OBJECTS: %2 : PLAYERS: %3", diag_fps,(count (allMissionObjects "")),(playersNumber west)];
  530. } else {
  531. diag_log format["DEBUG FPS : %1", diag_fps];
  532. };
  533. };
  534.  
  535. // Damage generator function
  536. generate_new_damage = {
  537. private ["_damage"];
  538. _damage = ((random(DynamicVehicleDamageHigh-DynamicVehicleDamageLow))+DynamicVehicleDamageLow) / 100;
  539. _damage;
  540. };
  541.  
  542. // Damage generator fuction
  543. generate_exp_damage = {
  544. private ["_damage"];
  545. _damage = ((random(DynamicVehicleDamageHigh-DynamicVehicleDamageLow))+DynamicVehicleDamageLow) / 100;
  546.  
  547. // limit this to 85% since vehicle would blow up otherwise.
  548. //if(_damage >= 0.85) then {
  549. // _damage = 0.85;
  550. //};
  551. _damage;
  552. };
  553.  
  554. server_getDiff = {
  555. private["_variable","_object","_vNew","_vOld","_result"];
  556. _variable = _this select 0;
  557. _object = _this select 1;
  558. _vNew = _object getVariable[_variable,0];
  559. _vOld = _object getVariable[(_variable + "_CHK"),_vNew];
  560. _result = 0;
  561. if (_vNew < _vOld) then {
  562. //JIP issues
  563. _vNew = _vNew + _vOld;
  564. _object getVariable[(_variable + "_CHK"),_vNew];
  565. } else {
  566. _result = _vNew - _vOld;
  567. _object setVariable[(_variable + "_CHK"),_vNew];
  568. };
  569. _result
  570. };
  571.  
  572. server_getDiff2 = {
  573. private["_variable","_object","_vNew","_vOld","_result"];
  574. _variable = _this select 0;
  575. _object = _this select 1;
  576. _vNew = _object getVariable[_variable,0];
  577. _vOld = _object getVariable[(_variable + "_CHK"),_vNew];
  578. _result = _vNew - _vOld;
  579. _object setVariable[(_variable + "_CHK"),_vNew];
  580. _result
  581. };
  582.  
  583. dayz_objectUID = {
  584. private["_position","_dir","_key","_object"];
  585. _object = _this;
  586. _position = getPosATL _object;
  587. _dir = direction _object;
  588. _key = [_dir,_position] call dayz_objectUID2;
  589. _key
  590. };
  591.  
  592. dayz_objectUID2 = {
  593. private["_position","_dir","_key"];
  594. _dir = _this select 0;
  595. _key = "";
  596. _position = _this select 1;
  597. {
  598. _x = _x * 10;
  599. if ( _x < 0 ) then { _x = _x * -10 };
  600. _key = _key + str(round(_x));
  601. } count _position;
  602. _key = _key + str(round(_dir));
  603. _key
  604. };
  605.  
  606. dayz_objectUID3 = {
  607. private["_position","_dir","_key"];
  608. _dir = _this select 0;
  609. _key = "";
  610. _position = _this select 1;
  611. {
  612. _x = _x * 10;
  613. if ( _x < 0 ) then { _x = _x * -10 };
  614. _key = _key + str(round(_x));
  615. } count _position;
  616. _key = _key + str(round(_dir + time));
  617. _key
  618. };
  619.  
  620. dayz_recordLogin = {
  621. private["_key"];
  622. _key = format["CHILD:103:%1:%2:%3:",_this select 0,_this select 1,_this select 2];
  623. _key call server_hiveWrite;
  624. };
  625.  
  626. dayz_perform_purge = {
  627. if(!isNull(_this)) then {
  628. _group = group _this;
  629. _this removeAllMPEventHandlers "mpkilled";
  630. _this removeAllMPEventHandlers "mphit";
  631. _this removeAllMPEventHandlers "mprespawn";
  632. _this removeAllEventHandlers "FiredNear";
  633. _this removeAllEventHandlers "HandleDamage";
  634. _this removeAllEventHandlers "Killed";
  635. _this removeAllEventHandlers "Fired";
  636. _this removeAllEventHandlers "GetOut";
  637. _this removeAllEventHandlers "GetIn";
  638. _this removeAllEventHandlers "Local";
  639. clearVehicleInit _this;
  640. deleteVehicle _this;
  641. if ((count (units _group) == 0) && (_group != grpNull)) then {
  642. deleteGroup _group;
  643. };
  644. };
  645. };
  646.  
  647. dayz_perform_purge_player = {
  648.  
  649. private ["_countr","_backpack","_backpackType","_backpackWpn","_backpackMag","_objWpnTypes","_objWpnQty","_location","_dir","_holder","_weapons","_magazines"];
  650. diag_log ("Purging player: " + str(_this));
  651.  
  652. if(!isNull(_this)) then {
  653.  
  654. _location = getPosATL _this;
  655. _dir = getDir _this;
  656.  
  657. _holder = createVehicle ["GraveDZE", _location, [], 0, "CAN_COLLIDE"];
  658. _holder setDir _dir;
  659. _holder setPosATL _location;
  660.  
  661. _holder enableSimulation false;
  662.  
  663. _weapons = weapons _this;
  664. _magazines = magazines _this;
  665.  
  666. // find backpack
  667. if(!(isNull unitBackpack _this)) then {
  668. _backpack = unitBackpack _this;
  669. _backpackType = typeOf _backpack;
  670. _backpackWpn = getWeaponCargo _backpack;
  671. _backpackMag = getMagazineCargo _backpack;
  672.  
  673. _holder addBackpackCargoGlobal [_backpackType,1];
  674.  
  675. // add items from backpack
  676. _objWpnTypes = _backpackWpn select 0;
  677. _objWpnQty = _backpackWpn select 1;
  678. _countr = 0;
  679. {
  680. _holder addWeaponCargoGlobal [_x,(_objWpnQty select _countr)];
  681. _countr = _countr + 1;
  682. } count _objWpnTypes;
  683.  
  684. // add backpack magazine items
  685. _objWpnTypes = _backpackMag select 0;
  686. _objWpnQty = _backpackMag select 1;
  687. _countr = 0;
  688. {
  689. _holder addMagazineCargoGlobal [_x,(_objWpnQty select _countr)];
  690. _countr = _countr + 1;
  691. } count _objWpnTypes;
  692. };
  693. };
  694.  
  695. // add weapons
  696. {
  697. _holder addWeaponCargoGlobal [_x, 1];
  698. } count _weapons;
  699.  
  700. // add mags
  701. {
  702. _holder addMagazineCargoGlobal [_x, 1];
  703. } count _magazines;
  704. _group = group _this;
  705. _this removeAllMPEventHandlers "mpkilled";
  706. _this removeAllMPEventHandlers "mphit";
  707. _this removeAllMPEventHandlers "mprespawn";
  708. _this removeAllEventHandlers "FiredNear";
  709. _this removeAllEventHandlers "HandleDamage";
  710. _this removeAllEventHandlers "Killed";
  711. _this removeAllEventHandlers "Fired";
  712. _this removeAllEventHandlers "GetOut";
  713. _this removeAllEventHandlers "GetIn";
  714. _this removeAllEventHandlers "Local";
  715. clearVehicleInit _this;
  716. deleteVehicle _this;
  717. if ((count (units _group) == 0) && (_group != grpNull)) then {
  718. deleteGroup _group;
  719. };
  720. // _this = nil;
  721. };
  722.  
  723.  
  724. dayz_removePlayerOnDisconnect = {
  725. if(!isNull(_this)) then {
  726. _group = group _this;
  727. _this removeAllMPEventHandlers "mphit";
  728. deleteVehicle _this;
  729. deleteGroup (group _this);
  730. };
  731. };
  732.  
  733. server_timeSync = {
  734. //Send request
  735. private ["_hour","_minute","_date","_key","_result","_outcome"];
  736. _key = "CHILD:307:";
  737. _result = _key call server_hiveReadWrite;
  738. _outcome = _result select 0;
  739. if(_outcome == "PASS") then {
  740. _date = _result select 1;
  741.  
  742. if(dayz_fullMoonNights) then {
  743. _hour = _date select 3;
  744. _minute = _date select 4;
  745. //Force full moon nights
  746. _date = [2013,8,3,_hour,_minute];
  747. };
  748.  
  749. setDate _date;
  750. PVDZE_plr_SetDate = _date;
  751. publicVariable "PVDZE_plr_SetDate";
  752. diag_log ("TIME SYNC: Local Time set to " + str(_date));
  753. };
  754. };
  755.  
  756. // must spawn these
  757. server_spawncleanDead = {
  758. private ["_deathTime","_delQtyZ","_delQtyP","_qty","_allDead"];
  759. _allDead = allDead;
  760. _delQtyZ = 0;
  761. _delQtyP = 0;
  762. {
  763. if (local _x) then {
  764. if (_x isKindOf "zZombie_Base") then
  765. {
  766. _x call dayz_perform_purge;
  767. sleep 0.05;
  768. _delQtyZ = _delQtyZ + 1;
  769. } else {
  770. if (_x isKindOf "CAManBase") then {
  771. _deathTime = _x getVariable ["processedDeath", diag_tickTime];
  772. if (diag_tickTime - _deathTime > 1800) then {
  773. _x call dayz_perform_purge_player;
  774. sleep 0.025;
  775. _delQtyP = _delQtyP + 1;
  776. };
  777. };
  778. };
  779. };
  780. sleep 0.025;
  781. } count _allDead;
  782. if (_delQtyZ > 0 || _delQtyP > 0) then {
  783. _qty = count _allDead;
  784. diag_log (format["CLEANUP: Deleted %1 players && %2 zombies out of %3 dead",_delQtyP,_delQtyZ,_qty]);
  785. };
  786. };
  787. server_cleanupGroups = {
  788. if (DZE_DYN_AntiStuck3rd > 3) then { DZE_DYN_GroupCleanup = nil; DZE_DYN_AntiStuck3rd = 0; };
  789. if(!isNil "DZE_DYN_GroupCleanup") exitWith { DZE_DYN_AntiStuck3rd = DZE_DYN_AntiStuck3rd + 1;};
  790. DZE_DYN_GroupCleanup = true;
  791. {
  792. if ((count (units _x) == 0) && (_x != grpNull)) then {
  793. deleteGroup _x;
  794. };
  795. sleep 0.001;
  796. } count allGroups;
  797. DZE_DYN_GroupCleanup = nil;
  798. };
  799.  
  800. server_checkHackers = {
  801. if (DZE_DYN_AntiStuck2nd > 3) then { DZE_DYN_HackerCheck = nil; DZE_DYN_AntiStuck2nd = 0; };
  802. if(!isNil "DZE_DYN_HackerCheck") exitWith { DZE_DYN_AntiStuck2nd = DZE_DYN_AntiStuck2nd + 1;};
  803. DZE_DYN_HackerCheck = true;
  804. {
  805. if (!((isNil "_x") || {(isNull _x)})) then {
  806. if(vehicle _x != _x && !(vehicle _x in PVDZE_serverObjectMonitor) && (isPlayer _x) && !((typeOf vehicle _x) in DZE_safeVehicle)) then {
  807. diag_log ("CLEANUP: KILLING A HACKER " + (name _x) + " " + str(_x) + " IN " + (typeOf vehicle _x));
  808. (vehicle _x) setDamage 1;
  809. _x setDamage 1;
  810. sleep 0.25;
  811. };
  812. };
  813. sleep 0.001;
  814. } count allUnits;
  815. DZE_DYN_HackerCheck = nil;
  816. };
  817.  
  818. server_spawnCleanFire = {
  819. private ["_delQtyFP","_qty","_delQtyNull","_missionFires"];
  820. _missionFires = allMissionObjects "Land_Fire_DZ";
  821. _delQtyFP = 0;
  822. {
  823. if (local _x) then {
  824. deleteVehicle _x;
  825. sleep 0.025;
  826. _delQtyFP = _delQtyFP + 1;
  827. };
  828. sleep 0.001;
  829. } count _missionFires;
  830. if (_delQtyFP > 0) then {
  831. _qty = count _missionFires;
  832. diag_log (format["CLEANUP: Deleted %1 fireplaces out of %2",_delQtyNull,_qty]);
  833. };
  834. };
  835. server_spawnCleanLoot = {
  836. private ["_created","_delQty","_nearby","_age","_keep","_qty","_missionObjs","_dateNow"];
  837. if (DZE_DYN_AntiStuck > 3) then { DZE_DYN_cleanLoot = nil; DZE_DYN_AntiStuck = 0; };
  838. if(!isNil "DZE_DYN_cleanLoot") exitWith { DZE_DYN_AntiStuck = DZE_DYN_AntiStuck + 1;};
  839. DZE_DYN_cleanLoot = true;
  840.  
  841. _missionObjs = allMissionObjects "ReammoBox";
  842. _delQty = 0;
  843. _dateNow = (DateToNumber date);
  844. {
  845. if (!isNull _x) then {
  846. _keep = _x getVariable["permaLoot", false];
  847. if (!_keep) then {
  848. _created = _x getVariable["created", -0.1];
  849. if (_created == -0.1) then{
  850. _x setVariable["created", _dateNow, false];
  851. _created = _dateNow;
  852. }
  853. else {
  854. _age = (_dateNow - _created) * 525948;
  855. if (_age > 20) then{
  856. _nearby = { (isPlayer _x) && (alive _x) } count(_x nearEntities[["CAManBase", "AllVehicles"], 130]);
  857. if (_nearby == 0) then{
  858. deleteVehicle _x;
  859. sleep 0.025;
  860. _delQty = _delQty + 1;
  861. };
  862. };
  863. };
  864. };
  865. };
  866. sleep 0.001;
  867. } count _missionObjs;
  868. if (_delQty > 0) then {
  869. _qty = count _missionObjs;
  870. diag_log (format["CLEANUP: Deleted %1 Loot Piles out of %2",_delQty,_qty]);
  871. };
  872. DZE_DYN_cleanLoot = nil;
  873. };
  874.  
  875. server_spawnCleanAnimals = {
  876. private ["_pos","_delQtyAnimal","_qty","_missonAnimals","_nearby"];
  877. _missonAnimals = entities "CAAnimalBase";
  878. _delQtyAnimal = 0;
  879. {
  880. if (local _x) then {
  881. _x call dayz_perform_purge;
  882. sleep 0.05;
  883. _delQtyAnimal = _delQtyAnimal + 1;
  884. } else {
  885. if (!alive _x) then {
  886. _pos = getPosATL _x;
  887. if (count _pos > 0) then {
  888. _nearby = {(isPlayer _x) && (alive _x)} count (_pos nearEntities [["CAManBase","AllVehicles"], 130]);
  889. if (_nearby==0) then {
  890. _x call dayz_perform_purge;
  891. sleep 0.05;
  892. _delQtyAnimal = _delQtyAnimal + 1;
  893. };
  894. };
  895. };
  896. };
  897. sleep 0.001;
  898. } count _missonAnimals;
  899. if (_delQtyAnimal > 0) then {
  900. _qty = count _missonAnimals;
  901. diag_log (format["CLEANUP: Deleted %1 Animals out of %2",_delQtyAnimal,_qty]);
  902. };
  903. };
  904.  
  905. server_logUnlockLockEvent = {
  906. private["_player", "_obj", "_objectID", "_objectUID", "_statusText", "_status"];
  907. _player = _this select 0;
  908. _obj = _this select 1;
  909. _status = _this select 2;
  910. if (!isNull(_obj)) then {
  911. _objectID = _obj getVariable["ObjectID", "0"];
  912. _objectUID = _obj getVariable["ObjectUID", "0"];
  913. _statusText = "UNLOCKED";
  914. if (_status) then {
  915. [_obj, "gear"] call server_updateObject;
  916. _statusText = "LOCKED";
  917. };
  918. diag_log format["SAFE %5: ID:%1 UID:%2 BY %3(%4)", _objectID, _objectUID, (name _player), (getPlayerUID _player), _statusText];
  919. };
  920. };
Advertisement
Add Comment
Please, Sign In to add comment