Advertisement
Guest User

Untitled

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