Guest User

Untitled

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