Advertisement
Guest User

Untitled

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