Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.78 KB | None | 0 0
  1. private ["_nul","_result","_pos","_wsDone","_dir","_isOK","_countr","_objWpnTypes","_objWpnQty","_dam","_selection","_totalvehicles","_object","_idKey","_type","_ownerID","_worldspace","_intentory","_hitPoints","_fuel","_damage","_key","_vehLimit","_hiveResponse","_objectCount","_codeCount","_data","_status","_val","_traderid","_retrader","_traderData","_id","_lockable","_debugMarkerPosition","_vehicle_0","_bQty","_vQty","_BuildingQueue","_objectQueue","_superkey","_shutdown","_res","_hiveLoaded"];
  2.  
  3. dayz_versionNo = getText(configFile >> "CfgMods" >> "DayZ" >> "version");
  4. dayz_hiveVersionNo = getNumber(configFile >> "CfgMods" >> "DayZ" >> "hiveVersion");
  5.  
  6. _hiveLoaded = false;
  7.  
  8. waitUntil{initialized};
  9.  
  10. diag_log "HIVE: Starting";
  11.  
  12. waituntil{isNil "sm_done"};
  13.  
  14. if(isnil "MaxVehicleLimit") then {
  15. MaxVehicleLimit = 50;
  16. };
  17.  
  18. if(isnil "MaxDynamicDebris") then {
  19. MaxDynamicDebris = 100;
  20. };
  21.  
  22. if(isnil "MaxAmmoBoxes") then {
  23. MaxAmmoBoxes = 3;
  24. };
  25.  
  26. if(isnil "MaxMineVeins") then {
  27. MaxMineVeins = 50;
  28. };
  29.  
  30. if (isServer && isNil "sm_done") then {
  31.  
  32. serverVehicleCounter = [];
  33. _hiveResponse = [];
  34.  
  35. for "_i" from 1 to 5 do {
  36.  
  37. diag_log "HIVE: trying to get objects";
  38.  
  39. _key = format["CHILD:302:%1:", dayZ_instance];
  40. _hiveResponse = _key call server_hiveReadWrite;
  41.  
  42. if ((((isnil "_hiveResponse") || {(typeName _hiveResponse != "ARRAY")}) || {((typeName (_hiveResponse select 1)) != "SCALAR")})) then {
  43.  
  44. if ((_hiveResponse select 1) == "Instance already initialized") then {
  45. _superkey = profileNamespace getVariable "SUPERKEY";
  46. _shutdown = format["CHILD:400:%1:", _superkey];
  47. _res = _shutdown call server_hiveReadWrite;
  48. diag_log ("HIVE: attempt to kill.. HiveExt response:"+str(_res));
  49. } else {
  50. diag_log ("HIVE: connection problem... HiveExt response:"+str(_hiveResponse));
  51. };
  52. _hiveResponse = ["",0];
  53. }
  54. else {
  55. diag_log ("HIVE: found "+str(_hiveResponse select 1)+" objects" );
  56. _i = 99;
  57. };
  58. };
  59.  
  60. _BuildingQueue = [];
  61. _objectQueue = [];
  62.  
  63. if ((_hiveResponse select 0) == "ObjectStreamStart") then {
  64.  
  65. profileNamespace setVariable ["SUPERKEY",(_hiveResponse select 2)];
  66.  
  67. _hiveLoaded = true;
  68.  
  69. diag_log ("HIVE: Commence Object Streaming...");
  70.  
  71. _key = format["CHILD:302:%1:", dayZ_instance];
  72. _objectCount = _hiveResponse select 1;
  73. _bQty = 0;
  74. _vQty = 0;
  75.  
  76. for "_i" from 1 to _objectCount do {
  77.  
  78. _hiveResponse = _key call server_hiveReadWriteLarge;
  79.  
  80. if ((_hiveResponse select 2) isKindOf "ModularItems") then {
  81. _BuildingQueue set [_bQty,_hiveResponse];
  82. _bQty = _bQty + 1;
  83. } else {
  84. _objectQueue set [_vQty,_hiveResponse];
  85. _vQty = _vQty + 1;
  86. };
  87. };
  88. diag_log ("HIVE: got " + str(_bQty) + " Epoch Objects and " + str(_vQty) + " Vehicles");
  89. };
  90.  
  91. _totalvehicles = 0;
  92. {
  93. _idKey = _x select 1;
  94. _type = _x select 2;
  95. _ownerID = _x select 3;
  96.  
  97. _worldspace = _x select 4;
  98. _intentory = _x select 5;
  99. _hitPoints = _x select 6;
  100. _fuel = _x select 7;
  101. _damage = _x select 8;
  102. _dir = 0;
  103. _pos = [0,0,0];
  104. _wsDone = false;
  105.  
  106. if (count _worldspace >= 2) then
  107. {
  108. _dir = _worldspace select 0;
  109. if (count (_worldspace select 1) == 3) then {
  110. _pos = _worldspace select 1;
  111. _wsDone = true;
  112. }
  113. };
  114.  
  115. if (!_wsDone) then {
  116. if (count _worldspace >= 1) then { _dir = _worldspace select 0; };
  117. _pos = [getMarkerPos "center",0,4000,10,0,2000,0] call BIS_fnc_findSafePos;
  118. if (count _pos < 3) then { _pos = [_pos select 0,_pos select 1,0]; };
  119. diag_log ("MOVED OBJ: " + str(_idKey) + " of class " + _type + " to pos: " + str(_pos));
  120. };
  121.  
  122. _vector = [[0,0,0],[0,0,0]];
  123. _vecExists = false;
  124. _ownerPUID = "0";
  125. if (count _worldspace >= 3) then{
  126. if(count _worldspace == 3) then{
  127. if(typename (_worldspace select 2) == "STRING")then{
  128. _ownerPUID = _worldspace select 2;
  129. }else{
  130. if(typename (_worldspace select 2) == "ARRAY")then{
  131. _vector = _worldspace select 2;
  132. if(count _vector == 2)then{
  133. if(((count (_vector select 0)) == 3) && ((count (_vector select 1)) == 3))then{
  134. _vecExists = true;
  135. };
  136. };
  137. };
  138. };
  139.  
  140. }else{
  141. //Was not 3 elements, so check if 4 or more
  142. if(count _worldspace == 4) then{
  143. if(typename (_worldspace select 3) == "STRING")then{
  144. _ownerPUID = _worldspace select 3;
  145. }else{
  146. if(typename (_worldspace select 2) == "STRING")then{
  147. _ownerPUID = _worldspace select 2;
  148. };
  149. };
  150.  
  151.  
  152. if(typename (_worldspace select 2) == "ARRAY")then{
  153. _vector = _worldspace select 2;
  154. if(count _vector == 2)then{
  155. if(((count (_vector select 0)) == 3) && ((count (_vector select 1)) == 3))then{
  156. _vecExists = true;
  157. };
  158. };
  159. }else{
  160. if(typename (_worldspace select 3) == "ARRAY")then{
  161. _vector = _worldspace select 3;
  162. if(count _vector == 2)then{
  163. if(((count (_vector select 0)) == 3) && ((count (_vector select 1)) == 3))then{
  164. _vecExists = true;
  165. };
  166. };
  167. };
  168. };
  169.  
  170. }else{
  171. //More than 3 or 4 elements found
  172. //Might add a search for the vector, ownerPUID will equal 0
  173. };
  174. };
  175. };
  176.  
  177. if (_damage < 1) then {
  178.  
  179. _object = createVehicle [_type, _pos, [], 0, "CAN_COLLIDE"];
  180.  
  181. if (typeOf (_object) in DZE_DoorsLocked) then {
  182. _object setVariable ["doorfriends", _intentory, true];
  183. };
  184. _object setVariable ["lastUpdate",time];
  185. _object setVariable ["ObjectID", _idKey, true];
  186. if (typeOf (_object) == "Plastic_Pole_EP1_DZ") then {
  187. _object setVariable ["plotfriends", _intentory, true];
  188. };
  189.  
  190. if (typeOf (_object) == "Plastic_Pole_EP1_DZ") then {
  191. _object setVariable ["plotfriends", _intentory, true];
  192. };
  193.  
  194. _lockable = 0;
  195. if(isNumber (configFile >> "CfgVehicles" >> _type >> "lockable")) then {
  196. _lockable = getNumber(configFile >> "CfgVehicles" >> _type >> "lockable");
  197. };
  198.  
  199. if (_lockable == 4) then {
  200. _codeCount = (count (toArray _ownerID));
  201. if(_codeCount == 3) then {
  202. _ownerID = format["0%1", _ownerID];
  203. };
  204. if(_codeCount == 2) then {
  205. _ownerID = format["00%1", _ownerID];
  206. };
  207. if(_codeCount == 1) then {
  208. _ownerID = format["000%1", _ownerID];
  209. };
  210. };
  211.  
  212. if (_lockable == 3) then {
  213. _codeCount = (count (toArray _ownerID));
  214. if(_codeCount == 2) then {
  215. _ownerID = format["0%1", _ownerID];
  216. };
  217. if(_codeCount == 1) then {
  218. _ownerID = format["00%1", _ownerID];
  219. };
  220. };
  221.  
  222. _object setVariable ["CharacterID", _ownerID, true];
  223.  
  224. clearWeaponCargoGlobal _object;
  225. clearMagazineCargoGlobal _object;
  226.  
  227. _object setdir _dir;
  228.  
  229. if(_vecExists)then{
  230. _object setVectorDirAndUp _vector;
  231. };
  232. _object setposATL _pos;
  233. _object setDamage _damage;
  234. //#########################INDESTRUCTIBLE ITEMS#########################
  235. if ((typeOf _object) in indestructible) then {
  236. _object addEventHandler ["HandleDamage", {false}];
  237. _object enableSimulation false;
  238. } else {
  239. _object addMPEventHandler ["MPKilled",{_this call object_handleServerKilled;}];
  240. };
  241. //######################################################################
  242.  
  243. //#########################REMOVED FOR INDESTRUCTIBLE ITEMS#########################
  244. // if (DZE_GodModeBase) then {
  245. // _object addEventHandler ["HandleDamage", {false}];
  246. // } else {
  247. // _object addMPEventHandler ["MPKilled",{_this call object_handleServerKilled;}];
  248. // };
  249. //##################################################################################
  250. _object enableSimulation false;
  251. _object setVariable ["OEMPos", _pos, true];
  252. };
  253.  
  254. if ((count _intentory > 0) && !(typeOf( _object) == "Plastic_Pole_EP1_DZ") && !(typeOf( _object) in DZE_DoorsLocked)) then {
  255. if (_type in DZE_LockedStorage) then {
  256. _object setVariable ["WeaponCargo", (_intentory select 0),true];
  257. _object setVariable ["MagazineCargo", (_intentory select 1),true];
  258. _object setVariable ["BackpackCargo", (_intentory select 2),true];
  259. } else {
  260. _objWpnTypes = (_intentory select 0) select 0;
  261. _objWpnQty = (_intentory select 0) select 1;
  262. _countr = 0;
  263. {
  264. if(_x in (DZE_REPLACE_WEAPONS select 0)) then {
  265. _x = (DZE_REPLACE_WEAPONS select 1) select ((DZE_REPLACE_WEAPONS select 0) find _x);
  266. };
  267. _isOK = isClass(configFile >> "CfgWeapons" >> _x);
  268. if (_isOK) then {
  269. _object addWeaponCargoGlobal [_x,(_objWpnQty select _countr)];
  270. };
  271. _countr = _countr + 1;
  272. } count _objWpnTypes;
  273.  
  274. _objWpnTypes = (_intentory select 1) select 0;
  275. _objWpnQty = (_intentory select 1) select 1;
  276. _countr = 0;
  277.  
  278. {
  279. if (_x == "BoltSteel") then { _x = "WoodenArrow" };
  280. if (_x == "ItemTent") then { _x = "ItemTentOld" };
  281. _isOK = isClass(configFile >> "CfgMagazines" >> _x);
  282. if (_isOK) then {
  283. _object addMagazineCargoGlobal [_x,(_objWpnQty select _countr)];
  284. };
  285. _countr = _countr + 1;
  286. } count _objWpnTypes;
  287.  
  288. _objWpnTypes = (_intentory select 2) select 0;
  289. _objWpnQty = (_intentory select 2) select 1;
  290. _countr = 0;
  291.  
  292. {
  293. _isOK = isClass(configFile >> "CfgVehicles" >> _x);
  294. if (_isOK) then {
  295. _object addBackpackCargoGlobal [_x,(_objWpnQty select _countr)];
  296. };
  297. _countr = _countr + 1;
  298. } count _objWpnTypes;
  299. };
  300. };
  301.  
  302. if (_object isKindOf "AllVehicles") then {
  303. {
  304. _selection = _x select 0;
  305. _dam = _x select 1;
  306. if (_selection in dayZ_explosiveParts && _dam > 0.8) then {_dam = 0.8};
  307. [_object,_selection,_dam] call object_setFixServer;
  308. } count _hitpoints;
  309.  
  310. _object setFuel _fuel;
  311.  
  312. if (!((typeOf _object) in dayz_allowedObjects)) then {
  313.  
  314. _object call fnc_veh_ResetEH;
  315.  
  316. if(_ownerID != "0" && !(_object isKindOf "Bicycle")) then {
  317. _object setvehiclelock "locked";
  318. };
  319.  
  320. _totalvehicles = _totalvehicles + 1;
  321.  
  322. serverVehicleCounter set [count serverVehicleCounter,_type];
  323. };
  324. };
  325. PVDZE_serverObjectMonitor set [count PVDZE_serverObjectMonitor,_object];
  326. };
  327. } count (_BuildingQueue + _objectQueue);
  328.  
  329. if !(DZE_ConfigTrader) then {
  330. {
  331. _traderData = call compile format["menu_%1;",_x];
  332.  
  333. if(!isNil "_traderData") then {
  334. {
  335. _traderid = _x select 1;
  336. _retrader = [];
  337. _key = format["CHILD:399:%1:",_traderid];
  338. _data = "HiveEXT" callExtension _key;
  339. _result = call compile format ["%1",_data];
  340. _status = _result select 0;
  341.  
  342. if (_status == "ObjectStreamStart") then {
  343. _val = _result select 1;
  344. call compile format["ServerTcache_%1 = [];",_traderid];
  345. for "_i" from 1 to _val do {
  346. _data = "HiveEXT" callExtension _key;
  347. _result = call compile format ["%1",_data];
  348. call compile format["ServerTcache_%1 set [count ServerTcache_%1,%2]",_traderid,_result];
  349. _retrader set [count _retrader,_result];
  350. };
  351. };
  352.  
  353. } forEach (_traderData select 0);
  354. };
  355. } forEach serverTraders;
  356. };
  357.  
  358. if (_hiveLoaded) then {
  359. _vehLimit = MaxVehicleLimit - _totalvehicles;
  360. if(_vehLimit > 0) then {
  361. diag_log ("HIVE: Spawning # of Vehicles: " + str(_vehLimit));
  362. for "_x" from 1 to _vehLimit do {
  363. [] spawn spawn_vehicles;
  364. };
  365. } else {
  366. diag_log "HIVE: Vehicle Spawn limit reached!";
  367. };
  368. };
  369.  
  370. diag_log ("HIVE: Spawning # of Debris: " + str(MaxDynamicDebris));
  371.  
  372. for "_x" from 1 to MaxDynamicDebris do {
  373. [] spawn spawn_roadblocks;
  374. };
  375.  
  376. diag_log ("HIVE: Spawning # of Ammo Boxes: " + str(MaxAmmoBoxes));
  377.  
  378. for "_x" from 1 to MaxAmmoBoxes do {
  379. [] spawn spawn_ammosupply;
  380. };
  381.  
  382. diag_log ("HIVE: Spawning # of Veins: " + str(MaxMineVeins));
  383.  
  384. for "_x" from 1 to MaxMineVeins do {
  385. [] spawn spawn_mineveins;
  386. };
  387.  
  388. if(isnil "dayz_MapArea") then {
  389. dayz_MapArea = 10000;
  390. };
  391.  
  392. if(isnil "HeliCrashArea") then {
  393. HeliCrashArea = dayz_MapArea / 2;
  394. };
  395.  
  396. if(isnil "OldHeliCrash") then {
  397. OldHeliCrash = false;
  398. };
  399.  
  400. if(OldHeliCrash) then {
  401. _nul = [3, 4, (50 * 60), (15 * 60), 0.75, 'center', HeliCrashArea, true, false] spawn server_spawnCrashSite;
  402. };
  403.  
  404. if (isDedicated) then {
  405. _id = [] spawn server_spawnEvents;
  406. [] spawn {
  407. private ["_id"];
  408. sleep 200;
  409. waitUntil {!isNil "server_spawnCleanAnimals"};
  410. _id = [] execFSM "\z\addons\dayz_server\system\server_cleanup.fsm";
  411. };
  412.  
  413. _debugMarkerPosition = getMarkerPos "respawn_west";
  414. _debugMarkerPosition = [(_debugMarkerPosition select 0),(_debugMarkerPosition select 1),1];
  415. _vehicle_0 = createVehicle ["DebugBox_DZ", _debugMarkerPosition, [], 0, "CAN_COLLIDE"];
  416. _vehicle_0 setPos _debugMarkerPosition;
  417. _vehicle_0 setVariable ["ObjectID","1",true];
  418.  
  419. if(isnil "spawnMarkerCount") then {
  420. spawnMarkerCount = 10;
  421. };
  422.  
  423. actualSpawnMarkerCount = 0;
  424.  
  425. for "_i" from 0 to spawnMarkerCount do {
  426. if (!([(getMarkerPos format["spawn%1", _i]), [0,0,0]] call BIS_fnc_areEqual)) then {
  427. actualSpawnMarkerCount = actualSpawnMarkerCount + 1;
  428. } else {
  429. _i = spawnMarkerCount + 99;
  430. };
  431. };
  432. diag_log format["Total Number of spawn locations %1", actualSpawnMarkerCount];
  433. endLoadingScreen;
  434. };
  435. [] ExecVM "\z\addons\dayz_server\WAI\init.sqf";
  436. allowConnection = true;
  437. sm_done = true;
  438. publicVariable "sm_done";
  439. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement