Advertisement
Guest User

Untitled

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