Advertisement
Guest User

mission.sqf

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