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

@ -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
};