Guest User

Untitled

a guest
Oct 6th, 2013
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.68 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. // ### BASE BUILDING 1.2 ### SERVER SIDE BUILD ARRAYS - START
  11. call build_baseBuilding_arrays;
  12. // ### BASE BUILDING 1.2 ### SERVER SIDE BUILD ARRAYS - END
  13.  
  14. diag_log "HIVE: Starting";
  15.  
  16. //Set the Time
  17. //Send request
  18. _key = "CHILD:307:";
  19. _result = _key call server_hiveReadWrite;
  20. _outcome = _result select 0;
  21. if(_outcome == "PASS") then {
  22. _date = _result select 1;
  23.  
  24. //date setup
  25. _year = _date select 0;
  26. _month = _date select 1;
  27. _day = _date select 2;
  28. _hour = _date select 3;
  29. _minute = _date select 4;
  30.  
  31. //Force full moon nights
  32. _date1 = [2013,8,3,_hour,_minute];
  33.  
  34. if(isDedicated) then {
  35. //["dayzSetDate",_date] call broadcastRpcCallAll;
  36. setDate _date1;
  37. dayzSetDate = _date1;
  38. dayz_storeTimeDate = _date1;
  39. publicVariable "dayzSetDate";
  40. };
  41. diag_log ("HIVE: Local Time set to " + str(_date1));
  42. };
  43.  
  44. waituntil{isNil "sm_done"}; // prevent server_monitor be called twice (bug during login of the first player)
  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. _idKey = _x select 1;
  81. _type = _x select 2;
  82. _ownerID = _x select 3;
  83. _worldspace = _x select 4;
  84. _inventory = _x select 5;
  85. _hitPoints= _x select 6;
  86. _fuel = _x select 7;
  87. _damage = _x select 8;
  88.  
  89. _dir = 0;
  90. _pos = [0,0,0];
  91. _wsDone = false;
  92. if (count _worldspace >= 2) then
  93. {
  94. _dir = _worldspace select 0;
  95. if (count (_worldspace select 1) == 3) then {
  96. _pos = _worldspace select 1;
  97. _wsDone = true;
  98. }
  99. };
  100. if (!_wsDone) then {
  101. if (count _worldspace >= 1) then { _dir = _worldspace select 0; };
  102. _pos = [getMarkerPos "center",0,50,10,0,2000,0] call BIS_fnc_findSafePos;
  103. if (count _pos < 3) then { _pos = [_pos select 0,_pos select 1,0]; };
  104. diag_log ("MOVED OBJ: " + str(_idKey) + " of class " + _type + " to pos: " + str(_pos));
  105. };
  106.  
  107. if (_damage < 1) then {
  108. //diag_log format["OBJ: %1 - %2,%3,%4,%5,%6,%7,%8", _idKey,_type,_ownerID,_worldspace,_inventory,_hitPoints,_fuel,_damage];
  109.  
  110. //Create it
  111. _object = createVehicle [_type, _pos, [], 0, "CAN_COLLIDE"];
  112. _object setVariable ["lastUpdate",time];
  113. _object setVariable ["ObjectID", _idKey, true];
  114. _object setVariable ["CharacterID", _ownerID, true];
  115.  
  116. if (_object isKindOf "TentStorage" || _object isKindOf "CamoNet_DZ" || _object isKindOf "Land_A_tent" || (typeOf(_object) in allbuildables_class) ) then {
  117. _pos set [2,0];
  118. _object setpos _pos;
  119. if (_object isKindOf "TentStorage" || _object isKindOf "CamoNet_DZ" || _object isKindOf "Land_A_tent" ) then {
  120. _object addMPEventHandler ["MPKilled",{_this call vehicle_handleServerKilled;}];
  121. };
  122. };
  123.  
  124.  
  125. // ##### BASE BUILDING 1.2 Server Side ##### - START
  126. // This sets objects to appear properly once server restarts
  127. //_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
  128.  
  129.  
  130. if ((_type == "Static") && !(_type == "TentStorage")) then {
  131. _object setpos [(getposATL _object select 0),(getposATL _object select 1), 0];
  132. };
  133. //Set Variable
  134. if ((_type == "Infostand_2_EP1") && !(_type == "Infostand_1_EP1")) then {
  135. _object setVariable ["ObjectUID", _idKey, 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. // This sets objects to appear properly once server restarts
  160. // ##### BASE BUILDING 1.2 Server Side ##### - END
  161.  
  162.  
  163. _object setdir _dir;
  164. _object setDamage _damage;
  165.  
  166. //Dont add inventory for traps.
  167. if (!(_object isKindOf "TrapItems")) then {
  168. _cargo = _inventory;
  169. clearWeaponCargoGlobal _object;
  170. clearMagazineCargoGlobal _object;
  171. clearBackpackCargoGlobal _object;
  172. _config = ["CfgWeapons", "CfgMagazines", "CfgVehicles" ];
  173. {
  174. _magItemTypes = _x select 0;
  175. _magItemQtys = _x select 1;
  176. _i = _forEachIndex;
  177. {
  178. if (_x == "Crossbow") then { _x = "Crossbow_DZ" }; // Convert Crossbow to Crossbow_DZ
  179. if (_x == "BoltSteel") then { _x = "WoodenArrow" }; // Convert BoltSteel to WoodenArrow
  180. // Convert to DayZ Weapons
  181. if (_x == "DMR") then { _x = "DMR_DZ" };
  182. //if (_x == "M14_EP1") then { _x = "M14_DZ" };
  183. if (_x == "SVD") then { _x = "SVD_DZ" };
  184. if (_x == "SVD_CAMO") then { _x = "SVD_CAMO_DZ" };
  185. if (isClass(configFile >> (_config select _i) >> _x) &&
  186. getNumber(configFile >> (_config select _i) >> _x >> "stopThis") != 1) then {
  187. if (_forEachIndex < count _magItemQtys) then {
  188. switch (_i) do {
  189. case 0: { _object addWeaponCargoGlobal [_x,(_magItemQtys select _forEachIndex)]; };
  190. case 1: { _object addMagazineCargoGlobal [_x,(_magItemQtys select _forEachIndex)]; };
  191. case 2: { _object addBackpackCargoGlobal [_x,(_magItemQtys select _forEachIndex)]; };
  192. };
  193. };
  194. };
  195. } forEach _magItemTypes;
  196. } forEach _cargo;
  197. };
  198.  
  199. if (_object isKindOf "AllVehicles") then {
  200. {
  201. _selection = _x select 0;
  202. _dam = _x select 1;
  203. if (_selection in dayZ_explosiveParts and _dam > 0.8) then {_dam = 0.8};
  204.  
  205. [_object,_selection,_dam] call fnc_veh_setFixServer;
  206. } forEach _hitpoints;
  207. _object setvelocity [0,0,1];
  208. _object setFuel _fuel;
  209. _object call fnc_veh_ResetEH;
  210.  
  211.  
  212. } else {
  213. if (!(_type in SafeObjects )) then {
  214. _damage = 1;
  215. diag_log format["OBJ: %1 - %2 REMOVED", _object,_damage];
  216. };
  217. };
  218.  
  219. if (_object isKindOf "TrapItems") then {
  220. _object setVariable ["armed", _inventory select 0, false];
  221. };
  222.  
  223. //Monitor the object
  224. //_object enableSimulation false;
  225. dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_object];
  226. };
  227. } forEach _myArray;
  228.  
  229. // # END OF STREAMING #
  230.  
  231. createCenter civilian;
  232. if (isDedicated) then {
  233. endLoadingScreen;
  234. };
  235.  
  236. if (isDedicated) then {
  237. _id = [] execFSM "\z\addons\dayz_server\system\server_cleanup.fsm";
  238. };
  239.  
  240. allowConnection = true;
  241.  
  242. // antiwallhack
  243. call compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\fa_antiwallhack.sqf";
  244.  
  245. sm_done = true;
  246. publicVariable "sm_done";
  247.  
  248. dayz_Crashspawner = [] spawn {
  249. // [_guaranteedLoot, _randomizedLoot, spawnOnStart, _frequency, _variance, _spawnChance, _spawnMarker, _spawnRadius, _spawnFire, _fadeFire]
  250. [3, 4, 3, (40 * 60), (15 * 60), 0.75, 'center', 4000, true, false] call server_spawnCrashSite;
  251. };
  252.  
  253. //Spawn camps
  254. dayz_Campspawner = [] spawn {
  255. // quantity, marker, radius, min distance between 2 camps
  256. Server_InfectedCamps = [3, "center", 4500, 2000] call fn_bases;
  257. dayzInfectedCamps = Server_InfectedCamps;
  258. publicVariable "dayzInfectedCamps";
  259. };
  260.  
  261. dayz_Plantspawner = [] spawn {
  262. [300] call server_plantSpawner;
  263. };
  264.  
  265. //if (isDedicated) then {
  266. //Wild Zeds Ownership isnt working as expected yet
  267. // execFSM "\z\addons\dayz_server\system\zombie_wildagent.fsm";
  268. //};
  269.  
  270. // Trap loop
  271. [] call {
  272. private ["_array","_array2","_array3","_script","_armed"];
  273. _array = str dayz_traps;
  274. _array2 = str dayz_traps_active;
  275. _array3 = str dayz_traps_trigger;
  276.  
  277. while { true } do {
  278. if ((str dayz_traps != _array) || (str dayz_traps_active != _array2) || (str dayz_traps_trigger != _array3)) then {
  279. _array = str dayz_traps;
  280. _array2 = str dayz_traps_active;
  281. _array3 = str dayz_traps_trigger;
  282.  
  283. diag_log "DEBUG: traps";
  284. diag_log format["dayz_traps (%2) -> %1", dayz_traps, count dayz_traps];
  285. diag_log format["dayz_traps_active (%2) -> %1", dayz_traps_active, count dayz_traps_active];
  286. diag_log format["dayz_traps_trigger (%2) -> %1", dayz_traps_trigger, count dayz_traps_trigger];
  287. diag_log "DEBUG: end traps";
  288. };
  289.  
  290. {
  291. if (isNull _x) then {
  292. dayz_traps = dayz_traps - [_x];
  293. };
  294.  
  295. _script = call compile getText (configFile >> "CfgVehicles" >> typeOf _x >> "script");
  296. _armed = _x getVariable ["armed", false];
  297.  
  298. if (_armed) then {
  299. if !(_x in dayz_traps_active) then {
  300. ["arm", _x] call _script;
  301. };
  302. } else {
  303. if (_x in dayz_traps_active) then {
  304. ["disarm", _x] call _script;
  305. };
  306. };
  307.  
  308. //sleep 0.01;
  309. } forEach dayz_traps;
  310. };
  311. };
  312. };
Advertisement
Add Comment
Please, Sign In to add comment