Guest User

server_monitor.sqf

a guest
Oct 5th, 2013
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 22.75 KB | None | 0 0
  1. []execVM "\z\addons\dayz_server\system\s_fps.sqf"; //server monitor FPS (writes each ~181s diag_fps+181s diag_fpsmin*)
  2. #include "\z\addons\dayz_server\compile\server_toggle_debug.hpp"
  3.  
  4. dayz_versionNo =        getText(configFile >> "CfgMods" >> "DayZ" >> "version");
  5. dayz_hiveVersionNo =    getNumber(configFile >> "CfgMods" >> "DayZ" >> "hiveVersion");
  6. _script = getText(missionConfigFile >> "onPauseScript");
  7.  
  8. if ((count playableUnits == 0) and !isDedicated) then {
  9.     isSinglePlayer = true;
  10. };
  11.  
  12. waitUntil{initialized}; //means all the functions are now defined
  13.  
  14. // ### BASE BUILDING 1.2 ### SERVER SIDE BUILD ARRAYS - START
  15. call build_baseBuilding_arrays;
  16. // ### BASE BUILDING 1.2 ### SERVER SIDE BUILD ARRAYS - END
  17.  
  18. diag_log "HIVE: Starting";
  19.  
  20. //Set the Time
  21.     //Send request
  22.     _key = "CHILD:307:";
  23.     _result = _key call server_hiveReadWrite;
  24.     _outcome = _result select 0;
  25.     if(_outcome == "PASS") then {
  26.         _date = _result select 1;
  27.        
  28.         //date setup
  29.         _year = _date select 0;
  30.         _month = _date select 1;
  31.         _day = _date select 2;
  32.         _hour = _date select 3;
  33.         _minute = _date select 4;
  34.        
  35.         //Force full moon nights
  36.         _date = [2013,8,3,_hour,_minute];
  37.        
  38.         if(isDedicated) then {
  39.             //["dayzSetDate",_date] call broadcastRpcCallAll;
  40.             setDate _date;
  41.             dayzSetDate = _date;
  42.             publicVariable "dayzSetDate";
  43.         };
  44.         diag_log ("HIVE: Local Time set to " + str(_date));
  45.     };
  46.  
  47.     //Stream in objects
  48.     /* STREAM OBJECTS
  49.         //Send the key
  50.         _key = format["CHILD:302:%1:",dayZ_instance];
  51.         _result = _key call server_hiveReadWrite;
  52.  
  53.         diag_log "HIVE: Request sent";
  54.        
  55.         //Process result
  56.         _status = _result select 0;
  57.        
  58.         _myArray = [];
  59.         if (_status == "ObjectStreamStart") then {
  60.             _val = _result select 1;
  61.             //Stream Objects
  62.             diag_log ("HIVE: Commence Object Streaming...");
  63.             for "_i" from 1 to _val do {
  64.                 _result = _key call server_hiveReadWrite;
  65.  
  66.                 _status = _result select 0;
  67.                 _myArray set [count _myArray,_result];
  68.                 //diag_log ("HIVE: Loop ");
  69.             };
  70.             //diag_log ("HIVE: Streamed " + str(_val) + " objects");
  71.         };
  72.    
  73.         _countr = 0;       
  74.         {
  75.                
  76.             //Parse Array
  77.             _countr = _countr + 1;
  78.        
  79.             _idKey =    _x select 1;
  80.             _type =     _x select 2;
  81.             _ownerID =  _x select 3;
  82.             _worldspace = _x select 4;
  83.             _inventory= _x select 5;
  84.             _hitPoints= _x select 6;
  85.             _fuel =     _x select 7;
  86.             _damage =   _x select 8;
  87.  
  88.             _dir = 0;
  89.             _pos = [0,0,0];
  90.             _wsDone = false;           
  91.             if (count _worldspace >= 2) then
  92.             {
  93.                 _dir = _worldspace select 0;
  94.                 if (count (_worldspace select 1) == 3) then {
  95.                     _pos = _worldspace select 1;
  96.                     _wsDone = true;
  97.                 }
  98.             };
  99.            
  100.             if (!_wsDone) then {
  101.                 if (count _worldspace >= 1) then { _dir = _worldspace select 0; };
  102.                 _objectPos = [_worldspace select 1 select 0,_worldspace select 1 select 1,0];      
  103.                 _pos = [(_objectPos),0,15,1,0,2000,0,[],[_objectPos,[]]] call BIS_fnc_findSafePos;
  104.                 if (count _pos < 3) then { _pos = [_pos select 0,_pos select 1,0]; };
  105.                 diag_log ("MOVED OBJ: " + str(_idKey) + " of class " + _type + " to pos: " + str(_pos));
  106.             };
  107.            
  108.             if (_damage < 1) then {
  109.                 diag_log format["OBJ: %1 - %2", _idKey,_type];
  110.                
  111.                 //Create it
  112.                 _object = createVehicle [_type, _pos, [], 0, "CAN_COLLIDE"];
  113.                 _object setVariable ["lastUpdate",time];
  114.                 _object setVariable ["ObjectID", _idKey, true];
  115.                 _object setVariable ["CharacterID", _ownerID, true];
  116.                
  117.                 clearWeaponCargoGlobal  _object;
  118.                 clearMagazineCargoGlobal  _object;
  119.                
  120.                 if (_object isKindOf "TentStorage") then {
  121.                     _pos set [2,0];
  122.                     _object setpos _pos;
  123.                     _object addMPEventHandler ["MPKilled",{_this call vehicle_handleServerKilled;}];
  124.                 };
  125.                 _object setdir _dir;
  126.                 _object setDamage _damage;
  127.                
  128. // ####Copy START
  129. // ##### BASE BUILDING 1.2 Server Side ##### - START
  130. // This sets objects to appear properly once server restarts
  131.         //_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
  132.         if ((_object isKindOf "Static") && !(_object isKindOf "TentStorage")) then {
  133.             _object setpos [(getposATL _object select 0),(getposATL _object select 1), 0];
  134.         };
  135.         //Set Variable
  136.         if (_object isKindOf "Infostand_2_EP1" && !(_object isKindOf "Infostand_1_EP1")) then {
  137.             _object setVariable ["ObjectUID", _worldspace call dayz_objectUID2, true];
  138.         };
  139.  
  140.  
  141.                 // Set whether or not buildable is destructable
  142.         if (typeOf(_object) in allbuildables_class) then {
  143.             diag_log ("SERVER: in allbuildables_class:" + typeOf(_object) + " !");
  144.             for "_i" from 0 to ((count allbuildables) - 1) do
  145.             {
  146.                 _classname = (allbuildables select _i) select _i - _i + 1;
  147.                 _result = [_classname,typeOf(_object)] call BIS_fnc_areEqual;
  148.                 if (_result) then {
  149.                     _requirements = (allbuildables select _i) select _i - _i + 2;
  150.  
  151.                     _isDestructable = _requirements select 13;
  152.                     diag_log ("SERVER: " + typeOf(_object) + " _isDestructable = " + str(_isDestructable));
  153.                     if (!_isDestructable) then {
  154.                         diag_log("Spawned: " + typeOf(_object) + " Handle Damage False");
  155.                         _object addEventHandler ["HandleDamage", {false}];
  156.                     };
  157.                 };
  158.             };
  159.             //gateKeypad = _object addaction ["Defuse", "\z\addons\dayz_server\compile\enterCode.sqf"];
  160.         };
  161. // ##### BASE BUILDING 1.2 Server Side ##### - END
  162. // This sets objects to appear properly once server restarts
  163. // ###COPY END
  164.  
  165.                
  166.                 if (count _inventory > 0) then {
  167.                     //Add weapons
  168.                     _objWpnTypes = (_inventory select 0) select 0;
  169.                     _objWpnQty = (_inventory select 0) select 1;
  170.                     _countr = 0;                   
  171.                     {
  172.                         if (_x == "Crossbow") then { _x = "Crossbow_DZ" }; // Convert Crossbow to Crossbow_DZ
  173.                         _isOK =     isClass(configFile >> "CfgWeapons" >> _x);
  174.                         if (_isOK) then {
  175.                             _block =    getNumber(configFile >> "CfgWeapons" >> _x >> "stopThis") == 1;
  176.                             if (!_block) then {
  177.                                 _object addWeaponCargoGlobal [_x,(_objWpnQty select _countr)];
  178.                             };
  179.                         };
  180.                         _countr = _countr + 1;
  181.                     } forEach _objWpnTypes;
  182.                    
  183.                     //Add Magazines
  184.                     _objWpnTypes = (_inventory select 1) select 0;
  185.                     _objWpnQty = (_inventory select 1) select 1;
  186.                     _countr = 0;
  187.                     {
  188.                         if (_x == "BoltSteel") then { _x = "WoodenArrow" }; // Convert BoltSteel to WoodenArrow
  189.                         _isOK =     isClass(configFile >> "CfgMagazines" >> _x);
  190.                         if (_isOK) then {
  191.                             _block =    getNumber(configFile >> "CfgMagazines" >> _x >> "stopThis") == 1;
  192.                             if (!_block) then {
  193.                                 _object addMagazineCargoGlobal [_x,(_objWpnQty select _countr)];
  194.                             };
  195.                         };
  196.                         _countr = _countr + 1;
  197.                     } forEach _objWpnTypes;
  198.  
  199.                     //Add Backpacks
  200.                     _objWpnTypes = (_inventory select 2) select 0;
  201.                     _objWpnQty = (_inventory select 2) select 1;
  202.                     _countr = 0;
  203.                     {
  204.                         _isOK =     isClass(configFile >> "CfgVehicles" >> _x);
  205.                         if (_isOK) then {
  206.                             _block =    getNumber(configFile >> "CfgVehicles" >> _x >> "stopThis") == 1;
  207.                             if (!_block) then {
  208.                                 _object addBackpackCargoGlobal [_x,(_objWpnQty select _countr)];
  209.                             };
  210.                         };
  211.                         _countr = _countr + 1;
  212.                     } forEach _objWpnTypes;
  213.                 }; 
  214.                
  215.                 if (_object isKindOf "AllVehicles") then {
  216.                     {
  217.                         _selection = _x select 0;
  218.                         _dam = _x select 1;
  219.                         if (_selection in dayZ_explosiveParts and _dam > 0.8) then {_dam = 0.8};
  220.                         [_object,_selection,_dam] call fnc_veh_handleRepair;
  221.                     } forEach _hitpoints;
  222.                     _object setvelocity [0,0,1];
  223.                     _object setFuel _fuel;
  224.                     _object call fnc_veh_ResetEH;
  225.                     //Updated object position if moved
  226.                     if (!_wsDone) then {
  227.                         [_object, "position"] call server_updateObject;
  228.                     };
  229.                 };
  230.  
  231.                 //Monitor the object
  232.                 //_object enableSimulation false;
  233.                 dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_object];
  234.             };
  235.         } forEach _myArray;
  236.        
  237.     // # END OF STREAMING #
  238. */
  239. waituntil{isNil "sm_done"}; // prevent server_monitor be called twice (bug during login of the first player)
  240.  
  241. #include "\z\addons\dayz_server\compile\fa_hiveMaintenance.hpp"
  242.  
  243. if (isServer and isNil "sm_done") then {
  244.     private["_i","_hiveResponse","_key","_objectArray","_objectCount"];
  245.    
  246.     for "_i" from 1 to 5 do {
  247.         diag_log "HIVE: trying to get objects";
  248.         _key = format["CHILD:302:%1:", dayZ_instance];
  249.         _hiveResponse = _key call server_hiveReadWrite;  
  250.         if ((((isnil "_hiveResponse") || {(typeName _hiveResponse != "ARRAY")}) || {((typeName (_hiveResponse select 1)) != "SCALAR")}) || {(_hiveResponse select 1 > 2000)}) then {
  251.             diag_log ("HIVE: connection problem... HiveExt response:"+str(_hiveResponse));
  252.             _hiveResponse = ["",0];
  253.         }
  254.         else {
  255.             diag_log ("HIVE: found "+str(_hiveResponse select 1)+" objects" );
  256.             _i = 99; // break
  257.         };
  258.     };
  259.    
  260.     _objectArray = [];
  261.     if ((_hiveResponse select 0) == "ObjectStreamStart") then {
  262.         _objectCount = _hiveResponse select 1;
  263.         diag_log ("HIVE: Commence Object Streaming...");
  264.         for "_i" from 1 to _objectCount do {
  265.             _hiveResponse = _key call server_hiveReadWrite;
  266.             _objectArray set [_i - 1, _hiveResponse];
  267.             //diag_log (format["HIVE dbg %1 %2", typeName _hiveResponse, _hiveResponse]);
  268.         };
  269.         diag_log ("HIVE: got " + str(count _objectArray) + " objects");
  270. #ifdef EMPTY_TENTS_CHECK
  271.         // check empty tents, remove some of them
  272.         [_objectArray, EMPTY_TENTS_GLOBAL_LIMIT, EMPTY_TENTS_USER_LIMIT] call fa_removeExtraTents;
  273. #endif
  274.         // check vehicles count
  275.         [_objectArray] call fa_checkVehicles;
  276.     };
  277.  
  278.     {
  279.         private["_action","_ObjectID","_class","_CharacterID","_worldspace","_inventory", "_hitpoints","_fuel","_damage","_entity","_dir","_point","_res",  "_rawData","_class","_worldspace","_uid", "_selection", "_dam", "_booleans", "_point", "_wantExplosiveParts"];
  280.  
  281.         _action = _x select 0; // values : "OBJ"=object got from hive  "CREATED"=vehicle just created ...
  282.         _ObjectID = _x select 1;
  283.         _class =    if ((typeName (_x select 2)) == "STRING") then { _x select 2 } else { "Old_bike_TK_CIV_EP1" };
  284.         _CharacterID = _x select 3;        
  285.         _worldspace = if ((typeName (_x select 4)) == "ARRAY") then { _x select 4 } else { [] };
  286.         _inventory= if ((typeName (_x select 5)) == "ARRAY") then { _x select 5 } else { [] };
  287.         _hitpoints= if ((typeName (_x select 6)) == "ARRAY") then { _x select 6 } else { [] };
  288.         _fuel = if ((typeName (_x select 7)) == "SCALAR") then { _x select 7 } else { 0 };
  289.         _damage = if ((typeName (_x select 8)) == "SCALAR") then { _x select 8 } else { 0.9 };  
  290.         _entity = nil;
  291.    
  292.         _dir = floor(random(360));
  293.         _point = getMarkerpos "respawn_west";  
  294.         if (count _worldspace >= 1 && {(typeName (_worldspace select 0)) == "SCALAR"}) then {
  295.             _dir = _worldspace select 0;
  296.         };
  297.         if (count _worldspace == 2 && {(typeName (_worldspace select 1)) == "ARRAY"}) then {
  298.             _i = _worldspace select 1;
  299.             if (count _i == 3 &&
  300.                 {(typeName (_i select 0)) == "SCALAR"} &&
  301.                 {(typeName (_i select 1)) == "SCALAR"} &&
  302.                 {(typeName (_i select 2)) == "SCALAR"}) then {
  303.                 _point = _i;   
  304.             };
  305.         };
  306.    
  307.         // if legit vehicle      
  308.         if ((_class isKindOf "AllVehicles") && ((_CharacterID == "0") OR (_CharacterID == "1")) && (_damage < 1)) then {
  309.             //_damage=0.86;//_action="CREATED";
  310.             _point set [2, 0]; // here _point is in ATL format 
  311. #ifdef VEH_MAINTENANCE_ROTTEN_AT_STARTUP
  312.             // rotten randomly the vehicle. Successive damages will lead to a respawn.
  313.             if ((random(VEH_MAINTENANCE_ROTTEN_AT_STARTUP) < 1) AND {(_action == "OBJ")}) then {
  314.                  _damage = VEH_MAINTENANCE_ROTTEN_LOGIC; _action = "DAMAGED";
  315.             };
  316. #endif
  317. #ifdef VEH_MAINTENANCE_ADD_MISSING     
  318.  
  319.             // ask to create a new vehicle if damage is too high
  320.             if (_damage > 0.85 AND (_action != "CREATED")) then { _action = "SPAWNED"; };  
  321. #endif
  322.             // check for no collision with world. Find a suitable place (depending of defined parameters)
  323.             _worldspace = [_class, _dir, _point, _action] call fa_smartlocation;
  324.             if (count _worldspace < 2) then {  // safe position NOT found
  325.                 _action = "FAILED"; // don't worry, maybe we will find a nice spot next time :)
  326.             }
  327.             else { // found a spot for respawn
  328.                 if ((([_worldspace select 1, _point] call BIS_fnc_distance2D) > 1)
  329.                     AND (_action == "OBJ")) then { _action = "MOVED"; };
  330.                 _dir = _worldspace select 0;
  331.                 _point = _worldspace select 1;
  332.                 _entity = createVehicle [_class, _point, [], 0,
  333.                     if ((_class isKindOf "Air") OR {(_action != "OBJ")}) then {"NONE"} else {"CAN_COLLIDE"}
  334.                 ];
  335.                 _entity setVariable ["ObjectID", _ObjectID, true]; // this variable must be set very early
  336.                 _entity setVariable ["CharacterID", _CharacterID, true];   
  337.                 _entity setVariable ["lastUpdate",time]; // prevent immediate hive write when vehicle parts are set up
  338.                 // setPos will be done again just after setDir, see below....
  339. #ifdef VEH_MAINTENANCE_ADD_MISSING     
  340.                 if (_damage > 0.85) then {
  341.                     _fuel = VEH_MAINTENANCE_SPAWN_FUEL_LOGIC;
  342.                     _hitpoints = [];
  343.                     _damage = _hitpoints call fa_setDamagedParts;
  344.        
  345.                     _inventory = []; // TODO: rewrite this inventory setup.
  346.                     //diag_log (format["VEH MAINTENANCE Creating vehicle Inventory:%1  and  Damaged parts:%2", _inventory, _hitpoints]);
  347.                 };
  348. #endif
  349.                 _entity setDamage _damage;
  350.                 {
  351.                     _wantExplosiveParts = _x;
  352.                     {
  353.                         _selection = _x select 0;
  354.                         _dam = _x select 1;
  355.                         if (_selection in dayZ_explosiveParts) then {
  356.                             if (_wantExplosiveParts) then {
  357.                                 if (_dam > 0.8) then { _dam = 0.8; };
  358.                                 [_entity, _selection, _dam] call fnc_veh_handleDam;
  359.                             };
  360.                         }
  361.                         else {
  362.                             if (!_wantExplosiveParts) then {
  363.                                 [_entity, _selection, _dam] call fnc_veh_handleDam;
  364.                             };
  365.                         };
  366.                     } forEach _hitpoints;
  367.                 } forEach [false, true]; // we set non explosive part first, then explosive parts
  368.                 _entity setvelocity [0,0,1];
  369.                 _entity setFuel _fuel;
  370.                 _entity call fnc_veh_ResetEH;
  371.             };
  372.            
  373.             //Limit ammo of UH1Y
  374.             if (_entity isKindOf "UH1Y_DZ") then {
  375.             _entity setVehicleAmmo 0.2; //was 0.2
  376.             };
  377.                
  378.             //Limit Ammo of ArmoredSUV_PMC
  379.             if (_entity isKindOf "ArmoredSUV_PMC") then {
  380.             _entity setVehicleAmmo 0.2;
  381.             };
  382.                
  383.             //Limit Ammo of GPK
  384.             if (_entity isKindOf "HMMWV_M1151_M2_DES_EP1") then {
  385.             _entity setVehicleAmmo 0.5;
  386.             };
  387.  
  388.             //Limit Ammo of UH60M_DZ
  389.             if (_entity isKindOf "UH60M_DZ") then {
  390.             _entity setVehicleAmmo 0.2;
  391.             };
  392.            
  393.             //Limit Ammo of Camel_DZ
  394.             if (_entity isKindOf "Camel_DZ") then {
  395.             _entity setVehicleAmmo 0.3;
  396.             };
  397.            
  398.             if (_entity isKindOf "AN2_DZ") then {
  399.             _entity addWeapon "M240_veh";
  400.             _entity addMagazine "100Rnd_762x51_M240";
  401.             _entity addMagazine "100Rnd_762x51_M240";
  402.             _entity addMagazine "100Rnd_762x51_M240";
  403.             };
  404.            
  405. #ifdef OBJECT_DEBUG
  406.             diag_log (format["VEHICLE %1 %2 at %3, original damage=%4, effective damage=%6, fuel=%5",
  407.                  _action, _entity call fa_veh2str, (getPosASL _entity) call fa_coor2str, _damage, _fuel, damage _entity]); // , hitpoints:%6, inventory=%7"  , _hitpoints, _inventory
  408. #endif
  409.         }
  410.         else { // else for object or non legit vehicle
  411.             if (!(_class in SafeObjects )) then {  
  412.                 _damage = 1;
  413.             };
  414.             if (_damage < 1) then {
  415.                 // Rule #1: Tents will be always spawned if non empty.
  416.                 // Rule #2: Objects are not spawned if inside/close to building.
  417.                 // Rule #3: Rule #1 is higher priority
  418.                 _booleans=[];
  419.                 _worldspace = [_class, _point, _booleans] call fn_niceSpot;
  420.                 if (_booleans select 3) then { // is in building
  421.                     if ((_class != "TentStorage") OR {(_inventory call fa_tentEmpty)}) then {
  422.                         _action = "FAILED";
  423.                         _damage = 5;
  424. #ifdef OBJECT_DEBUG
  425.                         diag_log(format["Won't spawn object #%1(%4) in/close to a building, _point:%3, inventory: %5 booleans:%2",_ObjectID, _booleans, _point, _class, _inventory]);
  426. #endif
  427. // ####Copy START
  428. // ##### BASE BUILDING 1.2 Server Side ##### - START
  429. // This sets objects to appear properly once server restarts
  430.         _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
  431.         if ((_object isKindOf "Static") && !(_object isKindOf "TentStorage")) then {
  432.             _object setpos [(getposATL _object select 0),(getposATL _object select 1), 0];
  433.         };
  434.         //Set Variable
  435.         if (_object isKindOf "Infostand_2_EP1" && !(_object isKindOf "Infostand_1_EP1")) then {
  436.             _object setVariable ["ObjectUID", _worldspace call dayz_objectUID2, true];
  437.         };
  438.  
  439.  
  440.                 // Set whether or not buildable is destructable
  441.         if (typeOf(_object) in allbuildables_class) then {
  442.             diag_log ("SERVER: in allbuildables_class:" + typeOf(_object) + " !");
  443.             for "_i" from 0 to ((count allbuildables) - 1) do
  444.             {
  445.                 _classname = (allbuildables select _i) select _i - _i + 1;
  446.                 _result = [_classname,typeOf(_object)] call BIS_fnc_areEqual;
  447.                 if (_result) then {
  448.                     _requirements = (allbuildables select _i) select _i - _i + 2;
  449.  
  450.                     _isDestructable = _requirements select 13;
  451.                     diag_log ("SERVER: " + typeOf(_object) + " _isDestructable = " + str(_isDestructable));
  452.                     if (!_isDestructable) then {
  453.                         diag_log("Spawned: " + typeOf(_object) + " Handle Damage False");
  454.                         _object addEventHandler ["HandleDamage", {false}];
  455.                     };
  456.                 };
  457.             };
  458.             //gateKeypad = _object addaction ["Defuse", "\z\addons\dayz_server\compile\enterCode.sqf"];
  459.         };
  460. // ##### BASE BUILDING 1.2 Server Side ##### - END
  461. // This sets objects to appear properly once server restarts
  462. // ###COPY END
  463.                     };
  464.                 };
  465.             };
  466.             if (_damage < 1) then { // create object
  467. #ifdef OBJECTS_FIX_OUTOFMAP
  468.                 _worldspace = [_dir, _point] call fa_staywithus;
  469.                 _dir =  _worldspace select 0;
  470.                 _point =  _worldspace select 1;
  471. #endif
  472.                 // for tents: non colliding position
  473.                 _entity = createVehicle [_class, _point, [], 0,
  474.                     if (_class=="TentStorage") then {"NONE"} else {"CAN_COLLIDE"}
  475.                 ]; 
  476.                 _entity setVariable ["ObjectUID", _ObjectID, true];
  477.                 _entity setVariable ["CharacterID", _CharacterID, true];   
  478.                 _entity setVariable ["lastUpdate",time];
  479.                 _entity setDamage _damage;
  480.    
  481.                 if (_class == "TentStorage") then {
  482.                     _entity addMPEventHandler ["MPKilled",{_this call vehicle_handleServerKilled;}];
  483.                 };
  484.                 //diag_log ("DW_DEBUG " + _class + " #" + str(_ObjectID) + " pos=" +    (_point call fa_coor2str) + ", damage=" + str(_damage)  );
  485.             }
  486.             else { // delete object -- this has been comented out: object are never really deleted from hive
  487.             /*  _key = format["CHILD:306:%1:%2:%3:", _ObjectID, [], 1];
  488.                 _rawData = "HiveEXT" callExtension _key;
  489.                 _key = format["CHILD:304:%1:",_ObjectID]; // delete by ID (not UID which is handler 310)
  490.                 _rawData = "HiveEXT" callExtension _key;*/
  491. #ifdef OBJECT_DEBUG
  492.                 diag_log (format["IGNORED %1 oid#%2 cid:%3 ",
  493.                     _class, _ObjectID, _CharacterID ]);
  494. #endif
  495.             };
  496.         };
  497. //diag_log(format["VEH MAINTENANCE DEBUG %1 %2", __FILE__, __LINE__]);
  498.            
  499.         // common code (vehicle or not)            
  500.         if (_damage < 1 AND !(isNil ("_entity"))) then {
  501.             _entity setdir _dir;
  502.             _entity setPos _point;
  503.             [_entity, _inventory] call fa_populateCargo;
  504.            
  505.             dayz_serverObjectMonitor set [count dayz_serverObjectMonitor, _entity];
  506.    
  507.             // UPDATE MODIFIED OBJECTS TO THE HIVE
  508.             if (_action == "CREATED") then {
  509.                 // insert className damage characterId  worldSpace inventory  hitPoints  fuel uniqueId  
  510.                 _key = format["CHILD:308:%1:%2:%3:%4:%5:%6:%7:%8:%9:", dayZ_instance,
  511.                     _class, _damage , 1,
  512.                     [_dir, _point],
  513.                     [getWeaponCargo _entity, getMagazineCargo _entity ,getBackpackCargo _entity],
  514.                     _hitpoints, _fuel, _ObjectID
  515.                 ];
  516.                 //diag_log (_key);
  517.                 _rawData = "HiveEXT" callExtension _key;
  518.             };
  519.             if (_action == "SPAWNED" || _action == "DAMAGED") then {
  520.                 // update hitpoint,damage   -- already done by needupdate
  521.                 /*_key = format["CHILD:306:%1:%2:%3:", _ObjectID, _hitpoints, _damage];
  522.                 _rawData = "HiveEXT" callExtension _key;*/
  523.             };
  524.             if (_action == "SPAWNED") then {
  525.                 // update inventory  
  526.                 _key = format["CHILD:309:%1:%2:", _ObjectID,
  527.                     [getWeaponCargo _entity, getMagazineCargo _entity, getBackpackCargo _entity]];
  528.                 _rawData = "HiveEXT" callExtension _key;
  529.             };
  530.             if (_action == "MOVED" || _action == "SPAWNED") then {
  531.                 // update position,fuel in Hive  
  532.                 // already done by server_updateObject?
  533.                 /*_key = format["CHILD:305:%1:%2:%3:", _ObjectID, [_dir, _point], _fuel];
  534.                 _rawData = "HiveEXT" callExtension _key;*/
  535.                             //Updated object position if moved
  536.                 [_entity, "position"] call server_updateObject;
  537.             };
  538.         }; // not damaged
  539.         sleep 0.01; // yield to connecting players.
  540.     } forEach _objectArray;
  541.    
  542.     createCenter civilian;
  543.     if (isDedicated) then {
  544.         endLoadingScreen;
  545.     }; 
  546.    
  547.     if (isDedicated) then {
  548.     _id = [] execFSM "\z\addons\dayz_server\system\server_cleanup.fsm";
  549.     };
  550.    
  551.     allowConnection = true;
  552.  
  553.     // [_guaranteedLoot, _randomizedLoot, spawnOnStart, _frequency, _variance, _spawnChance, _spawnMarker, _spawnRadius, _spawnFire, _fadeFire]
  554.     [4, 4, 3, (30 * 60), (15 * 60), 0.99, 'center', 4500, true, false] spawn server_spawnCrashSite;
  555.     // [_guaranteedLoot, _randomizedLoot, _frequency, _variance(DONOTUSE), _spawnChance, _spawnMarker, _spawnRadius, _spawnFire, _fadeFire, waypoints, damage]
  556.     //nul = [9, 5, 1800, 0, 0.69, 'center', 5000, true, false, false, 4, 0.5]spawn server_spawnC130CrashSite;
  557.     //Spawn camps
  558.     // quantity, marker, radius, min distance between 2 camps
  559.     //Server_InfectedCamps = [3, "center", 4500, 2000] call fn_bases;
  560.     //dayzInfectedCamps = Server_InfectedCamps;
  561.     //publicVariable "dayzInfectedCamps";
  562.  
  563.     // antiwallhack
  564.     call compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\fa_antiwallhack.sqf";
  565.    
  566.     sm_done = true;
  567.     publicVariable "sm_done";
  568. };
  569. /*
  570. nul =    [
  571.                 9,        //Number of the guaranteed Loot-Piles at the Crashside
  572.                 4,        //Number of the random Loot-Piles at the Crashside 3+(1,2,3 or 4)
  573.                 (30*60),    //Fixed-Time (in seconds) between each start of a new Chopper
  574.                 (30*60),      //Random time (in seconds) added between each start of a new Chopper
  575.                 0.50,        //Spawnchance of the Heli (1 will spawn all possible Choppers, 0.5 only 50% of them)
  576.                 'center', //'center' Center-Marker for the Random-Crashpoints, for Chernarus this is a point near Stary
  577.                 8000,    // [106,[960.577,3480.34,0.002]]Radius in Meters from the Center-Marker in which the Choppers can crash and get waypoints
  578.                 true,    //Should the spawned crashsite burn (at night) & have smoke?
  579.                 false,    //Should the flames & smoke fade after a while?
  580.                 3,    //RANDOM WP
  581.                 4,        //GUARANTEED WP
  582.                 0.5        //Amount of Damage the Heli has to get while in-air to explode before the POC. (0.0001 = Insta-Explode when any damage//bullethit, 1 = Only Explode when completly damaged)
  583.             ] spawn server_spawnAN2;
  584. */
Advertisement
Add Comment
Please, Sign In to add comment