Advertisement
Guest User

Untitled

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