This commit is contained in:
2023-10-01 20:58:19 +03:00
parent 6268a86c47
commit 6576a3ab6f
53 changed files with 1249 additions and 508 deletions

View File

@ -90,6 +90,7 @@ AllowedVehiclesList = [
["SUV_TK_CIV_EP1_DZE",_Ratio1],
["SUV_White",_Ratio1],
["SUV_Yellow",_Ratio1],
["SUV_Blue_White",_Ratio1],
["Tractor_DZE",_Ratio3],
["TT650_Civ_DZE",_Ratio3],
["TT650_Ins_DZE",_Ratio3],

View File

@ -0,0 +1,39 @@
/*
Safe Zone Relocate by salival (https://github.com/oiad)
*/
private ["_customPosition","_minDist","_maxDist","_maxDamage","_message","_nearVehicles","_objDist","_position","_safeZonePos","_safeZoneRadius","_useCustomPosition","_unlock"];
_useCustomPosition = false; // Enable a custom position to move vehicles to (i.e a junk yard)
_customPosition = [6942.64,15121.6,0]; // Position for vehicles to be moved to if _useCustomPosition = true;
_minDist = 5; // Minimum distance from the custom position to move vehicles to
_maxDist = 1000; // Maximum distance from the safe zone position to find a safe position or custom position for relocation, setting this too low can make vehicles spawn very close to other vehicles.
_objDist = 15; // Minimum distance from the safe position for relocation to the center of the nearest object. Specifying quite a large distance here will slow the function and might often fail to find a suitable position.
_unlock = false; // Unlock vehicle when moved from the safe zone?
_maxDamage = 0.75; // Vehicles above or equal to this amount of damage will be deleted
{
_safeZonePos = _x select 0;
_safeZoneRadius = _x select 1;
_nearVehicles = _safeZonePos nearEntities [["Air","LandVehicle","Ship"],_safeZoneRadius];
{
if (damage _x >= _maxDamage) then {
_message = format ["[SAFEZONE] %1 was deleted from the server for being too damaged before relocate: @%2 %3",typeOf _x,mapGridPosition _x,getPosATL _x];
diag_log _message;
[_x getVariable["ObjectID","0"],_x getVariable["ObjectUID","0"],_x] call server_deleteObjDirect;
deleteVehicle _x;
} else {
if (_useCustomPosition) then {
_position = [_customPosition,_minDist,_maxDist,_objDist,1,0,0,[]] call BIS_fnc_findSafePos;
} else {
_position = [_safeZonePos,(_safeZoneRadius + 50),_maxDist,_objDist,if (_x isKindOf "Ship") then {2} else {0},0,0,[],[_safeZonePos,_safeZonePos]] call BIS_fnc_findSafePos;
};
_x setPos _position;
[_x,"position"] call server_updateObject;
if (_unlock && {locked _x}) then {_x setVehicleLock "UNLOCKED"};
_message = format ["[SAFEZONE] %1 was moved out of a safe zone to: @%2 %3",typeOf _x,mapGridPosition _position,_position];
diag_log _message;
};
} forEach _nearVehicles;
} forEach DZE_safeZonePosArray;

View File

@ -1,7 +1,5 @@
#include "\z\addons\dayz_server\compile\server_toggle_debug.hpp"
if (isNil "DZE_NPC_CleanUp_Time") then {DZE_NPC_CleanUp_Time = -1;};
sched_co_deleteVehicle = {
private "_group";
_this removeAllMPEventHandlers "mpkilled";
@ -28,7 +26,7 @@ sched_co_deleteVehicle = {
sched_corpses = {
private ["_delQtyG","_delQtyZ","_delQtyP","_addFlies","_x","_deathTime","_onoff","_delQtyAnimal","_sound","_deathPos","_cpos","_animal","_nearPlayer","_delQtyV","_delQtyAI"];
private ["_delQtyG","_delQtyZ","_delQtyP","_addFlies","_x","_deathTime","_onoff","_delQtyAnimal","_sound","_deathPos","_cpos","_animal","_nearPlayer","_delQtyV"];
// EVERY 2 MINUTE
// DELETE UNCONTROLLED ZOMBIES --- PUT FLIES ON FRESH PLAYER CORPSES --- REMOVE OLD FLIES & CORPSES
_delQtyZ = 0;
@ -36,10 +34,9 @@ sched_corpses = {
_delQtyG = 0;
_delQtyV = 0;
_addFlies = 0;
_delQtyAI = 0;
{
if (local _x && {_x isKindOf "CAManBase"}) then {
if (_x isKindOf "zZombie_Base") then {
if (_x isKindOf "zZombie_Base" || {typeOf _x == "z_bloodsucker"}) then {
_x call sched_co_deleteVehicle;
_delQtyZ = _delQtyZ + 1;
} else {
@ -62,28 +59,8 @@ sched_corpses = {
_addFlies = _addFlies + 1;
};
};
// 60 * DZE_NPC_CleanUp_Time = how long an NPC corpse stays on the map
if (DZE_NPC_CleanUp_Time != -1 && {diag_tickTime - _deathTime > (60 * DZE_NPC_CleanUp_Time)} && {_x getVariable["bodyName",""] == "NPC"}) then {
if (_x getVariable["sched_co_fliesDeleted",false] or !dayz_enableFlies) then {
// flies have been switched off, we can delete body
_sound = _x getVariable ["sched_co_fliesSource", nil];
if !(isNil "_sound") then {
detach _sound;
deleteVehicle _sound;
};
_x call sched_co_deleteVehicle;
_delQtyAI = _delQtyAI + 1;
} else {
PVCDZ_flies = [ 0, _x ];
publicVariable "PVCDZ_flies";
_x setVariable ["sched_co_fliesDeleted", true];
// body will be deleted at next round
};
};
// 40 minutes = how long a player corpse stays on the map
if ((diag_tickTime - _deathTime > 40*60) && {_x getVariable["bodyName",""] != "NPC"}) then {
if (diag_tickTime - _deathTime > 40*60) then {
if (_x getVariable["sched_co_fliesDeleted",false] or !dayz_enableFlies) then {
// flies have been switched off, we can delete body
_sound = _x getVariable ["sched_co_fliesSource", nil];
@ -120,7 +97,7 @@ sched_corpses = {
if (_onoff == 1) then {
_sound = createSoundSource["Sound_Flies",getPosATL _x,[],0];
_sound attachTo [_x];
_x setVariable ["sched_co_fliesSource", _sound];
_x setVariable ["sched_co_fliesSource", _sound,[false,true] select (DZE_Bury_Body || DZE_Butcher_Body)];
//diag_log "create sound";
};
// broadcast flies status for everyone periodically, to update visible swarm
@ -158,7 +135,7 @@ sched_corpses = {
};
};
} forEach allDead;
_delQtyAnimal = 0;
{
_animal = _x;
@ -181,8 +158,8 @@ sched_corpses = {
#ifdef SERVER_DEBUG
if (_delQtyZ+_delQtyP+_addFlies+_delQtyGrp+_delQtyG+_delQtyV > 0) then {
diag_log format ["%1: Deleted %2 uncontrolled zombies, %3 uncontrolled animals, %4 dead character bodies, %7 ghosts, %8 destroyed vehicles, %9 dead mission ai and %5 empty groups. Added %6 flies.",__FILE__,
_delQtyZ,_delQtyAnimal,_delQtyP,_delQtyGrp,_addFlies,_delQtyG,_delQtyV,_delQtyAI];
diag_log format ["%1: Deleted %2 uncontrolled zombies, %3 uncontrolled animals, %4 dead character bodies, %7 ghosts, %8 destroyed vehicles and %5 empty groups. Added %6 flies.",__FILE__,
_delQtyZ,_delQtyAnimal,_delQtyP,_delQtyGrp,_addFlies,_delQtyG,_delQtyV];
};
#endif
@ -215,4 +192,4 @@ sched_disconnectedPlayers = {
objNull
};
*/
*/

View File

@ -4,15 +4,11 @@
*/
epoch_eventIsAny = {
private ["_boolReturn","_event","_date","_bool","_index"];
_event = _this select 0;
_date = _this select 1;
_boolReturn = false;
_index = 0;
local _event = _this select 0;
local _date = _this select 1;
local _boolReturn = false;
local _index = 0;
{
_bool = false;
if (typeName _x == "STRING") then {
_boolReturn = true;
} else {
@ -21,50 +17,41 @@ epoch_eventIsAny = {
if (!_boolReturn) exitWith {};
_index = _index + 1;
} count _event;
_boolReturn
};
sched_event_init = {
diag_log("EPOCH EVENTS INIT");
diag_log formatText ["EPOCH EVENTS: %1 Events Scheduled",(count EpochEvents)];
""
};
sched_event = {
private ["_date","_key","_result","_outcome","_handle","_datestr","_lastTime"];
// Find current time from server
_lastTime = _this;
_key = "CHILD:307:";
_result = _key call server_hiveReadWrite;
_outcome = _result select 0;
if(_outcome == "PASS") then {
_date = _result select 1;
_datestr = str(_date);
local _lastTime = _this;
local _key = "CHILD:307:";
local _result = _key call server_hiveReadWrite;
local _outcome = _result select 0;
if (_outcome == "PASS") then {
local _date = _result select 1;
local _datestr = str(_date);
if (_lastTime != _datestr) then {
// internal timestamp
ServerCurrentTime = _date;
// Once a minute.
_lastTime = _datestr;
//diag_log ("EVENTS: Local Time is: " + _datestr);
if (count EpochEvents == 0) exitWith {};
{
// Run event at server start when minutes are set to -1
if ((_x select 4) == -1) then {
diag_log ("RUNNING EVENT: " + (_x select 5) + " on " + _datestr);
_handle = [] execVM "\z\addons\dayz_server\modules\" + (_x select 5) + ".sqf";
local _handle = [] execVM "\z\addons\dayz_server\modules\" + (_x select 5) + ".sqf";
// Remove event from array so it doesn't run again.
_lastIndex = (count EpochEvents) - 1;
if (_lastIndex != _forEachIndex) then {EpochEvents set [_forEachIndex, EpochEvents select _lastIndex];};
EpochEvents resize _lastIndex;
EpochEvents = [EpochEvents,_forEachIndex] call fnc_deleteAt;
} else {
if([[(_x select 0),(_x select 1),(_x select 2),(_x select 3),(_x select 4)],_date] call epoch_eventIsAny) then {
diag_log ("RUNNING EVENT: " + (_x select 5) + " on " + _datestr);
_handle = [] execVM "\z\addons\dayz_server\modules\" + (_x select 5) + ".sqf";
local _handle = [] execVM "\z\addons\dayz_server\modules\" + (_x select 5) + ".sqf";
};
};
} forEach EpochEvents;

View File

@ -0,0 +1,57 @@
/*
EVR Storms AKA "Blowouts" Server Scheduler Functions by JasonTM.
The EVR storms are rolled out in stages for JIP players.
The server controls the EVR timing to keep the clients in sync so players have the same experience.
*/
evr_storm = {
PVDZE_EVR = "Stage1";
publicVariable "PVDZE_EVR";
uiSleep 60;
PVDZE_EVR = "Stage2";
publicVariable "PVDZE_EVR";
uiSleep 50;
PVDZE_EVR = "Stage3";
publicVariable "PVDZE_EVR";
uiSleep 40;
PVDZE_EVR = "Stage4";
publicVariable "PVDZE_EVR";
uiSleep 30;
PVDZE_EVR = "Stage5";
publicVariable "PVDZE_EVR";
uiSleep 20;
PVDZE_EVR = "Stage6";
publicVariable "PVDZE_EVR";
uiSleep 10;
PVDZE_EVR = "Stage7";
publicVariable "PVDZE_EVR";
uiSleep 180;
EVR_Lockout = false;
};
sched_evr_init = {
diag_log "EVR STORMS ENABLED";
EVR_Lockout = false; // Prevents the server from starting an EVR storm while one is running.
[diag_tickTime, (((DZE_EVRFirstTime select 0) max (random (DZE_EVRFirstTime select 1))) * 60)]
};
sched_evr = {
local _time = _this select 0;
local _timer = _this select 1;
if (!EVR_Lockout && {diag_tickTime - _time >= _timer}) then {
[] spawn evr_storm;
EVR_Lockout = true;
_time = diag_tickTime;
_timer = ((DZE_EVRTimer select 0) max (random (DZE_EVRTimer select 1))) * 60;
diag_log format ["EVR Storm Started: Next storm in %1 minutes", round(_timer / 60)];
};
[_time, _timer]
};

View File

@ -1,37 +1,41 @@
#define PATH "z\addons\dayz_server\system\scheduler\"
#define PATH "\z\addons\dayz_server\system\scheduler\"
call compile preprocessFileLineNumbers (PATH+"sched_corpses.sqf");
call compile preprocessFileLineNumbers (PATH+"sched_lootpiles.sqf");
call compile preprocessFileLineNumbers (PATH+"sched_sync.sqf");
call compile preprocessFileLineNumbers (PATH+"sched_safetyVehicle.sqf");
call compile preprocessFileLineNumbers (PATH+"sched_dzms.sqf");
call compile preprocessFileLineNumbers (PATH+"sched_wai.sqf");
call compile preprocessFileLineNumbers (PATH+"sched_dzms.sqf");
call compile preprocessFileLineNumbers (PATH+"sched_event.sqf");
call compile preprocessFileLineNumbers (PATH+"sched_traps.sqf");
if (DZE_Bury_Body || DZE_Butcher_Body) then {
call compile preprocessFileLineNumbers (PATH+"sched_lootCrates.sqf");
};
if (DZE_EVR) then {
call compile preprocessFileLineNumbers (PATH+"sched_evr.sqf");
};
[
local _list = [
// period offset code <-> ctx init code ->ctx
[ 60, 0, sched_event, sched_event_init ],
[ 60, 224, sched_corpses ],
[ 300, 336, sched_lootpiles_5m, sched_lootpiles_5m_init ],
[ 90, 60, sched_dzms, sched_dzms_init ],
[ 90, 60, sched_wai, sched_wai_init ],
[ 90, 60, sched_dzms, sched_dzms_init ],
[ 6, 340, sched_lootpiles ],
[ 900, 0, sched_sync ],
[ 120, 48, sched_safetyVehicle ],
[ 360, 480, sched_fps ],
[ 30, 60, sched_traps, sched_traps_init ]
] execFSM ("z\addons\dayz_code\system\scheduler\scheduler.fsm");
];
//diag_log [ __FILE__, "Scheduler started"];
/*
// (see ViralZeds.hpp -> zombie_agent.fsm -> zombie_findOwner.sqf), called when a zombie becomes "local" to the server after the player disconnected
zombie_findOwner = {
(_this select 0) call fa_deleteVehicle;
if (DZE_Bury_Body || DZE_Butcher_Body) then {
_list set [count _list, [ 60, 240, sched_lootCrates ]];
};
*/
if (DZE_EVR) then {
_list set [count _list, [ 60, 180, sched_evr, sched_evr_init ]];
};
_list execFSM ("\z\addons\dayz_code\system\scheduler\scheduler.fsm");
//diag_log [ __FILE__, "Scheduler started"];

View File

@ -0,0 +1,38 @@
#include "\z\addons\dayz_server\compile\server_toggle_debug.hpp"
// Delete loot crates, graves and crosses after 25 minutes
sched_lootCrates = {
private ["_delQtyCrate","_crateTime","_objects","_crates","_graves","_cross"];
_delQtyCrate = 0;
#define CENTER getMarkerPos "center"
#define RADIUS ((getMarkerSize "center") select 1)*2
_crates = CENTER nearObjects ["DZ_AmmoBoxSmallUS",RADIUS];
_graves = CENTER nearObjects ["Grave",RADIUS];
_cross = CENTER nearObjects ["GraveCross1",RADIUS];
_objects = _crates + _graves + _cross;
{
if (_x getVariable ["bury",false]) then {
_crateTime = _x getVariable ["sched_co_crateTime", -1];
if (_crateTime == -1) exitWith {
_crateTime = diag_tickTime;
_x setVariable ["sched_co_crateTime", _crateTime];
};
if (diag_tickTime - _crateTime > 25*60) then {
_x call sched_co_deleteVehicle;
_delQtyCrate = _delQtyCrate + 1;
};
};
} forEach _objects;
#ifdef SERVER_DEBUG
if (_delQtyCrate> 0) then {
diag_log format ["%1: Deleted %2 bury/butcher objects.",__FILE__,_delQtyCrate];
};
#endif
objNull
};

View File

@ -102,7 +102,7 @@ if ((playersNumber west + playersNumber civilian) == 0) exitWith {
_damage = _x select 8;
_storageMoney = _x select 9;
if ((_type isKindOf "AllVehicles")) then {
if ((_type isKindOf "AllVehicles") && {!(_type isKindOf "StaticWeapon") && {!(_type in DZE_StaticWeapons)}}) then {
_VehicleQueue set [_vQty,_x];
_vQty = _vQty + 1;
} else {
@ -183,21 +183,23 @@ if ((playersNumber west + playersNumber civilian) == 0) exitWith {
};
};
_object = _type createVehicle [0,0,0]; //more than 2x faster than createvehicle array
_object setDir _dir;
_object setPosATL _pos;
_object = _type createVehicle [0,0,0]; //more than 2x faster than createvehicle array
_object setDamage _damage;
if (_vecExists) then {
_object setVectorDirAndUp _vector;
} else {
_object setDir _dir; // setdir is incompatible with setVectorDirAndUp and should not be used together on the same object https://community.bistudio.com/wiki/setVectorDirAndUp
};
_object enableSimulation false;
_object setPosATL _pos;
_doorLocked = _type in DZE_DoorsLocked;
_isPlot = _type == "Plastic_Pole_EP1_DZ";
// prevent immediate hive write when vehicle parts are set up
_object setVariable ["lastUpdate",diag_ticktime];
_object setVariable ["ObjectID", _idKey, true];
_object setVariable ["ObjectID", _idKey];
_object setVariable ["OwnerPUID", _ownerPUID, true];
if (Z_SingleCurrency && {_type in DZE_MoneyStorageClasses}) then {
_object setVariable ["cashMoney", _storageMoney, true];
@ -234,7 +236,7 @@ if ((playersNumber west + playersNumber civilian) == 0) exitWith {
{_object addBackpackCargoGlobal [_x, _backpackqty select _foreachindex];} foreach _backpackcargo;
};
} else {
if (DZE_permanentPlot && _isPlot) then {
if (_isPlot) then {
_object setVariable ["plotfriends", _inventory, true];
};
if (DZE_doorManagement && _doorLocked) then {
@ -261,15 +263,20 @@ if ((playersNumber west + playersNumber civilian) == 0) exitWith {
};
};
};
_object setVariable ["CharacterID", _ownerID, true];
if (_type isKindOf "StaticWeapon" || {_type in DZE_StaticWeapons}) then {
[_object,DZE_clearStaticAmmo,false] call fn_vehicleAddons;
};
_setGlobal = [false,true] select ((_type in DZE_LockedStorage) || (_type in DZE_DoorsLocked));
_object setVariable ["CharacterID", _ownerID, _setGlobal];
if (_isSafeObject && !_isTrapItem) then {
_object setVariable["memDir",_dir,true];
if (DZE_GodModeBase && {!(_type in DZE_GodModeBaseExclude)}) then {
_object addEventHandler ["HandleDamage",{false}];
_object addEventHandler ["HandleDamage",{0}];
} else {
_object addMPEventHandler ["MPKilled",{_this call vehicle_handleServerKilled;}];
_object addMPEventHandler ["MPKilled",{if !(isServer) exitWith {};_this call vehicle_handleServerKilled;}];
};
_object setVariable ["OEMPos",_pos,true]; // used for inplace upgrades and lock/unlock of safe
} else {
_object enableSimulation true;
};
@ -338,8 +345,8 @@ if ((playersNumber west + playersNumber civilian) == 0) exitWith {
// prevent immediate hive write when vehicle parts are set up
_object setVariable ["lastUpdate",diag_ticktime];
_object setVariable ["ObjectID", _idKey, true];
if (Z_SingleCurrency && ZSC_VehicleMoneyStorage) then {
_object setVariable ["ObjectID", _idKey];
if (Z_SingleCurrency && {ZSC_VehicleMoneyStorage}) then {
_object setVariable ["cashMoney", _storageMoney, true];
};
@ -362,22 +369,19 @@ if ((playersNumber west + playersNumber civilian) == 0) exitWith {
{_object addBackpackCargoGlobal [_x, _backpackqty select _foreachindex];} foreach _backpackcargo;
};
_object setVariable ["CharacterID", _ownerID, true];
_isAir = _object isKindOf "Air";
{
_selection = _x select 0;
_dam = [_x select 1,(_x select 1) min 0.8] select (!_isAir && {_selection in dayZ_explosiveParts});
_object setHit [_selection,_dam];
} count _hitpoints;
[_object,"damage"] call server_updateObject;
_setGlobal = [false,true] select (_ownerID != "0");
_object setVariable ["CharacterID", _ownerID, _setGlobal];
[_object,_hitpoints] call server_setHitpoints;
_object setFuel _fuel;
[_object,"all",true] call server_updateObject;
[_object,DZE_clearVehicleAmmo,DZE_addVehicleAmmo] call fn_vehicleAddons;
_object call fnc_veh_ResetEH;
if (_ownerID != "0" && {!(_object isKindOf "Bicycle")}) then {
_object setVehicleLock "locked";
//_object setVariable ["MF_Tow_Cannot_Tow",true,true];
};
if (_ownerID != "0" && {!(_object isKindOf "Bicycle")}) then {_object setVehicleLock "locked";};
_serverVehicleCounter set [count _serverVehicleCounter,_type]; // total each vehicle
_object enableSimulation true;
_object setVelocity [0,0,1];
@ -415,7 +419,9 @@ for "_i" from 0 to 10 do {
diag_log format["Total Number of spawn locations %1", actualSpawnMarkerCount];
if (isDedicated) then {endLoadingScreen;};
[] call compile preprocessFileLineNumbers "\z\addons\dayz_server\DZAI\init\dzai_initserver.sqf";
allowConnection = true;
[] ExecVM "\z\addons\dayz_server\DZMS\DZMSInit.sqf";
sm_done = true;
publicVariable "sm_done";
@ -467,4 +473,7 @@ if (_hiveLoaded) then {
//Update gear last after all dynamic vehicles are created to save random loot to database (low priority)
{[_x,"gear"] call server_updateObject} count _vehiclesToUpdate;
};
if (DZE_SafeZone_Relocate) then {
execVM "\z\addons\dayz_server\system\safeZoneRelocate.sqf";
};
};