Advertisement
Guest User

Untitled

a guest
Jan 3rd, 2014
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.45 KB | None | 0 0
  1. private ["_date","_year","_month","_day","_hour","_minute","_date1","_hiveResponse","_key","_objectCount","_dir","_point","_i","_action","_dam","_selection","_wantExplosiveParts","_entity","_worldspace","_damage","_booleans","_rawData","_ObjectID","_class","_CharacterID","_inventory","_hitpoints","_fuel","_id","_objectArray","_script","_result","_outcome"];
  2. []execVM "\z\addons\dayz_server\system\s_fps.sqf"; //server monitor FPS (writes each ~181s diag_fps+181s diag_fpsmin*)
  3. #include "\z\addons\dayz_server\compile\server_toggle_debug.hpp"
  4.  
  5. dayz_versionNo = getText(configFile >> "CfgMods" >> "DayZ" >> "version");
  6. dayz_hiveVersionNo = getNumber(configFile >> "CfgMods" >> "DayZ" >> "hiveVersion");
  7.  
  8. waitUntil{initialized}; //means all the functions are now defined
  9.  
  10. diag_log "HIVE: Starting";
  11.  
  12. //Set the Time
  13. //Send request
  14. _key = "CHILD:307:";
  15. _result = _key call server_hiveReadWrite;
  16. _outcome = _result select 0;
  17. if(_outcome == "PASS") then {
  18. _date = _result select 1;
  19.  
  20. //date setup
  21. _year = _date select 0;
  22. _month = _date select 1;
  23. _day = _date select 2;
  24. _hour = _date select 3;
  25. _minute = _date select 4;
  26.  
  27. //Force full moon nights
  28. _date1 = [2013,8,3,_hour,_minute];
  29.  
  30. if(isDedicated) then {
  31. //["dayzSetDate",_date] call broadcastRpcCallAll;
  32. setDate _date1;
  33. dayzSetDate = _date1;
  34. dayz_storeTimeDate = _date1;
  35. publicVariable "dayzSetDate";
  36. };
  37. diag_log ("HIVE: Local Time set to " + str(_date1));
  38. };
  39.  
  40. waituntil{isNil "sm_done"}; // prevent server_monitor be called twice (bug during login of the first player)
  41.  
  42. if (isServer and isNil "sm_done") then {
  43.  
  44. //Stream in objects
  45. /* STREAM OBJECTS */
  46. //Send the key
  47. _key = format["CHILD:302:%1:",dayZ_instance];
  48. _result = _key call server_hiveReadWrite;
  49.  
  50. diag_log "HIVE: Request sent";
  51.  
  52. //Process result
  53. _status = _result select 0;
  54.  
  55. _myArray = [];
  56. if (_status == "ObjectStreamStart") then {
  57. _val = _result select 1;
  58. //Stream Objects
  59. diag_log ("HIVE: Commence Object Streaming...");
  60. for "_i" from 1 to _val do {
  61. _result = _key call server_hiveReadWrite;
  62.  
  63. _status = _result select 0;
  64. _myArray set [count _myArray,_result];
  65. //diag_log ("HIVE: Loop ");
  66. };
  67. diag_log ("HIVE: Streamed " + str(_val) + " objects");
  68. };
  69.  
  70. _countr = 0;
  71. {
  72.  
  73. //Parse Array
  74. _countr = _countr + 1;
  75.  
  76. _action = _x select 0;
  77. _idKey = _x select 1;
  78. _type = if ((typeName (_x select 2)) == "STRING") then { _x select 2 };
  79. _ownerID = _x select 3;
  80. _worldspace = if ((typeName (_x select 4)) == "ARRAY") then { _x select 4 } else { [] };
  81. _inventory = if ((typeName (_x select 5)) == "ARRAY") then { _x select 5 } else { [] };
  82. _hitPoints = if ((typeName (_x select 6)) == "ARRAY") then { _x select 6 } else { [] };
  83. _fuel = if ((typeName (_x select 7)) == "SCALAR") then { _x select 7 } else { 0 };
  84. _damage = if ((typeName (_x select 8)) == "SCALAR") then { _x select 8 } else { 0.9 };
  85.  
  86. _dir = floor(random(360));
  87. _pos = getMarkerpos "respawn_west";
  88. _wsDone = false;
  89.  
  90. if (count _worldspace >= 1 && {(typeName (_worldspace select 0)) == "SCALAR"}) then {
  91. _dir = _worldspace select 0;
  92. };
  93. if (count _worldspace == 2 && {(typeName (_worldspace select 1)) == "ARRAY"}) then {
  94. _i = _worldspace select 1;
  95. if (count _i == 3 &&
  96. {(typeName (_i select 0)) == "SCALAR"} &&
  97. {(typeName (_i select 1)) == "SCALAR"} &&
  98. {(typeName (_i select 2)) == "SCALAR"}) then {
  99. _pos = _i;
  100. _wsDone = true;
  101. };
  102. };
  103. if (!_wsDone) then {
  104. _pos = [getMarkerPos "center",0,30,10,0,2000,0] call BIS_fnc_findSafePos;
  105. if (count _pos < 3) then { _pos = [_pos select 0,_pos select 1,0]; };
  106. diag_log ("MOVED OBJ: " + str(_idKey) + " of class " + _type + " to pos: " + str(_pos));
  107. };
  108.  
  109. if (_damage < 1) then {
  110. //diag_log format["OBJ: %1 - %2,%3,%4,%5,%6,%7,%8", _idKey,_type,_ownerID,_worldspace,_inventory,_hitPoints,_fuel,_damage];
  111.  
  112. dayz_nonCollide = ["DomeTentStorage","TentStorage","CamoNet_DZ"];
  113.  
  114. //Create it
  115. _object = createVehicle [_type, _pos, [], 0, if (_type in dayz_nonCollide) then {"NONE"} else {"CAN_COLLIDE"}];
  116. _object setVariable ["lastUpdate",time];
  117. _object setVariable ["ObjectID", _idKey, true];
  118. _object setVariable ["CharacterID", _ownerID, true];
  119.  
  120. _object setdir _dir;
  121. _object setDamage _damage;
  122.  
  123. //Dont add inventory for traps.
  124. if (!(_object isKindOf "TrapItems")) then {
  125. _cargo = _inventory;
  126. clearWeaponCargoGlobal _object;
  127. clearMagazineCargoGlobal _object;
  128. clearBackpackCargoGlobal _object;
  129. _config = ["CfgWeapons", "CfgMagazines", "CfgVehicles" ];
  130. {
  131. _magItemTypes = _x select 0;
  132. _magItemQtys = _x select 1;
  133. _i = _forEachIndex;
  134. {
  135. if (_x == "Crossbow") then { _x = "Crossbow_DZ" }; // Convert Crossbow to Crossbow_DZ
  136. if (_x == "BoltSteel") then { _x = "WoodenArrow" }; // Convert BoltSteel to WoodenArrow
  137. // Convert to DayZ Weapons
  138. if (_x == "DMR") then { _x = "DMR_DZ" };
  139. //if (_x == "M14_EP1") then { _x = "M14_DZ" };
  140. if (_x == "SVD") then { _x = "SVD_DZ" };
  141. if (_x == "SVD_CAMO") then { _x = "SVD_CAMO_DZ" };
  142. if (isClass(configFile >> (_config select _i) >> _x) &&
  143. getNumber(configFile >> (_config select _i) >> _x >> "stopThis") != 1) then {
  144. if (_forEachIndex < count _magItemQtys) then {
  145. switch (_i) do {
  146. case 0: { _object addWeaponCargoGlobal [_x,(_magItemQtys select _forEachIndex)]; };
  147. case 1: { _object addMagazineCargoGlobal [_x,(_magItemQtys select _forEachIndex)]; };
  148. case 2: { _object addBackpackCargoGlobal [_x,(_magItemQtys select _forEachIndex)]; };
  149. };
  150. };
  151. };
  152. } forEach _magItemTypes;
  153. } forEach _cargo;
  154. };
  155.  
  156. if (_object isKindOf "AllVehicles") then {
  157. {
  158. _selection = _x select 0;
  159. _dam = _x select 1;
  160. if (_selection in dayZ_explosiveParts and _dam > 0.8) then {_dam = 0.8};
  161.  
  162. [_object,_selection,_dam] call fnc_veh_setFixServer;
  163. } forEach _hitpoints;
  164. _object setvelocity [0,0,1];
  165. _object setFuel _fuel;
  166. _object call fnc_veh_ResetEH;
  167. } else {
  168. if (true) then {
  169. if (_object isKindOf "TentStorage" || _object isKindOf "CamoNet_DZ" || _object isKindOf "Land_A_tent") then {
  170. //_booleans=[];
  171. //_pos = [_type, _pos, _booleans] call fn_niceSpot;
  172. _pos set [2,0];
  173. _object setPosATL _pos;
  174. _object addMPEventHandler ["MPKilled",{_this call vehicle_handleServerKilled;}];
  175. };
  176.  
  177. if (_object isKindOf "TrapItems") then {
  178. _object setVariable ["armed", _inventory select 0, false];
  179. };
  180. } else {
  181. _damage = 1;
  182. _object setDamage _damage;
  183. diag_log format["OBJ: %1 - %2 REMOVED", _object,_damage];
  184. };
  185.  
  186. };
  187.  
  188. //Monitor the object
  189. //_object enableSimulation false;
  190. dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_object];
  191. };
  192. sleep 0.01;
  193. } forEach _myArray;
  194.  
  195. // # END OF STREAMING #
  196.  
  197. createCenter civilian;
  198. if (isDedicated) then {
  199. endLoadingScreen;
  200. };
  201.  
  202. //Send the key
  203. _key = format["CHILD:999:select b.class_name, ib.worldspace from instance_building ib join building b on ib.building_id = b.id where ib.instance_id = ?:[%1]:", dayZ_instance];
  204. _data = "HiveEXT" callExtension _key;
  205.  
  206. diag_log("SERVER: Fetching buildings...");
  207.  
  208. //Process result
  209. _result = call compile format ["%1", _data];
  210. _status = _result select 0;
  211.  
  212. _bldList = [];
  213. _bldCount = 0;
  214. if (_status == "CustomStreamStart") then {
  215. _val = _result select 1;
  216. for "_i" from 1 to _val do {
  217. _data = "HiveEXT" callExtension _key;
  218. _result = call compile format ["%1",_data];
  219.  
  220. _pos = call compile (_result select 1);
  221. _dir = _pos select 0;
  222. _pos = _pos select 1;
  223.  
  224. _building = createVehicle [_result select 0, _pos, [], 0, "CAN_COLLIDE"];
  225. _building setDir _dir;
  226. _building setVariable ["permaLoot",true,true];
  227. _bldCount = _bldCount + 1;
  228. };
  229. diag_log ("SERVER: Spawned " + str(_bldCount) + " buildings!");
  230. };
  231.  
  232. if (isDedicated) then {
  233. _id = [] execFSM "\z\addons\dayz_server\system\server_cleanup.fsm";
  234. };
  235.  
  236. allowConnection = true;
  237.  
  238. // antiwallhack
  239. call compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\fa_antiwallhack.sqf";
  240.  
  241. sm_done = true;
  242. publicVariable "sm_done";
  243.  
  244. dayz_Crashspawner = [] spawn {
  245. // [_guaranteedLoot, _randomizedLoot, spawnOnStart, _frequency, _variance, _spawnChance, _spawnMarker, _spawnRadius, _spawnFire, _fadeFire]
  246. [3, 4, 3, (40 * 60), (15 * 60), 0.75, 'center', 4000, true, false] call server_spawnCrashSite;
  247. };
  248.  
  249. //Spawn camps
  250. dayz_Campspawner = [] spawn {
  251. // quantity, marker, radius, min distance between 2 camps
  252. Server_InfectedCamps = [3, "center", 4500, 2000] call fn_bases;
  253. dayzInfectedCamps = Server_InfectedCamps;
  254. publicVariable "dayzInfectedCamps";
  255. };
  256.  
  257. dayz_Plantspawner = [] spawn {
  258. [300] call server_plantSpawner;
  259. };
  260.  
  261. //if (isDedicated) then {
  262. //Wild Zeds Ownership isnt working as expected yet
  263. // execFSM "\z\addons\dayz_server\system\zombie_wildagent.fsm";
  264. //};
  265.  
  266. // Trap loop
  267. [] spawn {
  268. private ["_array","_array2","_array3","_script","_armed"];
  269. _array = str dayz_traps;
  270. _array2 = str dayz_traps_active;
  271. _array3 = str dayz_traps_trigger;
  272.  
  273. while { true } do {
  274. if ((str dayz_traps != _array) || (str dayz_traps_active != _array2) || (str dayz_traps_trigger != _array3)) then {
  275. _array = str dayz_traps;
  276. _array2 = str dayz_traps_active;
  277. _array3 = str dayz_traps_trigger;
  278.  
  279. diag_log "DEBUG: traps";
  280. diag_log format["dayz_traps (%2) -> %1", dayz_traps, count dayz_traps];
  281. diag_log format["dayz_traps_active (%2) -> %1", dayz_traps_active, count dayz_traps_active];
  282. diag_log format["dayz_traps_trigger (%2) -> %1", dayz_traps_trigger, count dayz_traps_trigger];
  283. diag_log "DEBUG: end traps";
  284. };
  285.  
  286. {
  287. if (isNull _x) then {
  288. dayz_traps = dayz_traps - [_x];
  289. };
  290.  
  291. _script = call compile getText (configFile >> "CfgVehicles" >> typeOf _x >> "script");
  292. _armed = _x getVariable ["armed", false];
  293.  
  294. if (_armed) then {
  295. if !(_x in dayz_traps_active) then {
  296. ["arm", _x] call _script;
  297. };
  298. } else {
  299. if (_x in dayz_traps_active) then {
  300. ["disarm", _x] call _script;
  301. };
  302. };
  303.  
  304. //sleep 0.01;
  305. } forEach dayz_traps;
  306. };
  307. };
  308. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement