Advertisement
Guest User

Untitled

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