Initial
This commit is contained in:
218
@DayZ_Epoch_Server/addons/dayz_server/system/scheduler/sched_corpses.sqf
Executable file
218
@DayZ_Epoch_Server/addons/dayz_server/system/scheduler/sched_corpses.sqf
Executable file
@ -0,0 +1,218 @@
|
||||
#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";
|
||||
_this removeAllMPEventHandlers "mphit";
|
||||
_this removeAllMPEventHandlers "mprespawn";
|
||||
_this removeAllEventHandlers "FiredNear";
|
||||
_this removeAllEventHandlers "HandleDamage";
|
||||
_this removeAllEventHandlers "Killed";
|
||||
_this removeAllEventHandlers "Fired";
|
||||
_this removeAllEventHandlers "GetIn";
|
||||
_this removeAllEventHandlers "GetOut";
|
||||
_this removeAllEventHandlers "Local";
|
||||
_this removeAllEventHandlers "Respawn";
|
||||
|
||||
clearVehicleInit _this;
|
||||
_group = group _this;
|
||||
deleteVehicle _this;
|
||||
if (count units _group == 0) then {
|
||||
deleteGroup _group;
|
||||
};
|
||||
|
||||
_this = nil;
|
||||
};
|
||||
|
||||
|
||||
sched_corpses = {
|
||||
private ["_delQtyG","_delQtyZ","_delQtyP","_addFlies","_x","_deathTime","_onoff","_delQtyAnimal","_sound","_deathPos","_cpos","_animal","_nearPlayer","_delQtyV","_delQtyAI"];
|
||||
// EVERY 2 MINUTE
|
||||
// DELETE UNCONTROLLED ZOMBIES --- PUT FLIES ON FRESH PLAYER CORPSES --- REMOVE OLD FLIES & CORPSES
|
||||
_delQtyZ = 0;
|
||||
_delQtyP = 0;
|
||||
_delQtyG = 0;
|
||||
_delQtyV = 0;
|
||||
_addFlies = 0;
|
||||
_delQtyAI = 0;
|
||||
{
|
||||
if (local _x && {_x isKindOf "CAManBase"}) then {
|
||||
if (_x isKindOf "zZombie_Base") then {
|
||||
_x call sched_co_deleteVehicle;
|
||||
_delQtyZ = _delQtyZ + 1;
|
||||
} else {
|
||||
//Only spawn flies on actual dead player, otherwise delete the body (clean up left over ghost from relogging, sometimes it is not deleted automatically by Arma or onPlayerDisconnect)
|
||||
//AI mods will need to setVariable "bodyName" on their dead units to prevent them being cleaned up
|
||||
_deathTime = _x getVariable ["sched_co_deathTime", -1];
|
||||
if (_x getVariable["bodyName",""] != "") then {
|
||||
if (_deathTime == -1) then {
|
||||
/*_deathPos = _x getVariable ["deathPos",respawn_west_original];
|
||||
_cpos = getPosATL _x;
|
||||
// forbid a move further than 50 meters, or burried body (antihack)
|
||||
if (_deathPos distance _cpos > 50 or _deathPos select 2 < -0.2) then {
|
||||
diag_log [ __FILE__, "Corpse should have been moved! CID#",(_x getVariable["characterID", "?"]),"from:", _cpos, "to:", _deathPos ];
|
||||
//_x setPosATL _deathPos;
|
||||
};*/
|
||||
_deathTime = diag_tickTime;
|
||||
_x setVariable ["sched_co_deathTime", _deathTime];
|
||||
if (dayz_enableFlies) then {
|
||||
_x setVariable ["sched_co_fliesAdded", true];
|
||||
_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 (_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;
|
||||
_delQtyP = _delQtyP + 1;
|
||||
} else {
|
||||
PVCDZ_flies = [ 0, _x ];
|
||||
publicVariable "PVCDZ_flies";
|
||||
_x setVariable ["sched_co_fliesDeleted", true];
|
||||
// body will be deleted at next round
|
||||
};
|
||||
} else {
|
||||
// Do not spawn flies immediately after death. Wait 10 minutes.
|
||||
if ((diag_tickTime - _deathTime < 10*60) or !dayz_enableFlies) exitWith {};
|
||||
_onoff = 1;
|
||||
// remove flies on heavy rain.
|
||||
if (rain > 0.25) then { _onoff = 0; };
|
||||
// switch flies sound on/off.
|
||||
// sound must be deleted/respawned periodically because new players won't ear it otherwise,
|
||||
// and other players would ear it several times (very loud noise)
|
||||
_sound = _x getVariable ["sched_co_fliesSource", nil];
|
||||
if !(isNil "_sound") then {
|
||||
detach _sound;
|
||||
deleteVehicle _sound;
|
||||
_x setVariable ["sched_co_fliesSource", nil];
|
||||
//diag_log "delete sound";
|
||||
};
|
||||
if (_onoff == 1) then {
|
||||
_sound = createSoundSource["Sound_Flies",getPosATL _x,[],0];
|
||||
_sound attachTo [_x];
|
||||
_x setVariable ["sched_co_fliesSource", _sound];
|
||||
//diag_log "create sound";
|
||||
};
|
||||
// broadcast flies status for everyone periodically, to update visible swarm
|
||||
PVCDZ_flies = [ _onoff, _x ];
|
||||
publicVariable "PVCDZ_flies";
|
||||
};
|
||||
} else {
|
||||
if (_deathTime == -1) then {
|
||||
_deathTime = diag_tickTime;
|
||||
_x setVariable ["sched_co_deathTime", _deathTime];
|
||||
} else {
|
||||
// Wait 30s to make sure the server had time to setVariable "bodyName". PVDZ_plr_Death can be delayed by a few seconds.
|
||||
if (diag_tickTime - _deathTime > 30) then {
|
||||
_x call sched_co_deleteVehicle;
|
||||
_delQtyG = _delQtyG + 1;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
if (_x in vehicles) then {
|
||||
_deathTime = _x getVariable ["sched_co_deathTime", -1];
|
||||
|
||||
if (_deathTime == -1) then {
|
||||
_deathTime = diag_tickTime;
|
||||
_x setVariable ["sched_co_deathTime", _deathTime];
|
||||
};
|
||||
|
||||
// 5 minutes = how long a destroyed vehicle stays on the map
|
||||
if (diag_tickTime - _deathTime > 5*60) then {
|
||||
{deleteVehicle _x} forEach (_x nearObjects ["CraterLong",50]);
|
||||
_x call sched_co_deleteVehicle;
|
||||
_delQtyV = _delQtyV + 1;
|
||||
};
|
||||
};
|
||||
} forEach allDead;
|
||||
|
||||
_delQtyAnimal = 0;
|
||||
{
|
||||
_animal = _x;
|
||||
if (local _animal) then {
|
||||
_nearPlayer = {isPlayer _x} count (_animal nearEntities ["CAManBase",150]);
|
||||
if (_nearPlayer == 0) then {
|
||||
_animal call sched_co_deleteVehicle;
|
||||
_delQtyAnimal = _delQtyAnimal + 1;
|
||||
};
|
||||
};
|
||||
} forEach entities "CAAnimalBase";
|
||||
|
||||
_delQtyGrp=0;
|
||||
{
|
||||
if (count units _x==0) then {
|
||||
deleteGroup _x;
|
||||
_delQtyGrp = _delQtyGrp + 1;
|
||||
};
|
||||
} forEach allGroups;
|
||||
|
||||
#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];
|
||||
};
|
||||
#endif
|
||||
|
||||
objNull
|
||||
};
|
||||
|
||||
/*
|
||||
sched_disconnectedPlayers = {
|
||||
private ["_x","_disconnectTime"];
|
||||
{
|
||||
diag_log (_x);
|
||||
if (local _x) then {
|
||||
_disconnectTime = _x getVariable ["sched_co_disconnectTime", -1];
|
||||
if (_disconnectTime == -1) then {
|
||||
_disconnectTime = diag_tickTime;
|
||||
_x setVariable ["sched_co_disconnectTime", _disconnectTime];
|
||||
};
|
||||
if (diag_tickTime - _disconnectTime > dayz_ghostTimer) then {
|
||||
if (alive _x) then {
|
||||
[_x,nil] call server_playerSync;
|
||||
};
|
||||
|
||||
dayz_disconnectPlayers = dayz_disconnectPlayers - [_x];
|
||||
|
||||
_x call sched_co_deleteVehicle;
|
||||
};
|
||||
diag_log format["%1 - %2",_x,_disconnectTime];
|
||||
};
|
||||
} forEach dayz_disconnectPlayers;
|
||||
|
||||
objNull
|
||||
};
|
||||
*/
|
52
@DayZ_Epoch_Server/addons/dayz_server/system/scheduler/sched_dzms.sqf
Executable file
52
@DayZ_Epoch_Server/addons/dayz_server/system/scheduler/sched_dzms.sqf
Executable file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
This scheduled task checks for running DZMS missions and starts them appropriately.
|
||||
*/
|
||||
|
||||
sched_dzms_init = {
|
||||
diag_log("[DZMS]: Scheduler Started");
|
||||
local _array = +DZMSMissionArray;
|
||||
local _timeBandit = ((random(DZMSBanditMax - DZMSBanditMin) + DZMSBanditMin) * 60);
|
||||
local _timeHero = ((random(DZMSHeroMax - DZMSHeroMin) + DZMSHeroMin) * 60);
|
||||
[_array,_timeBandit,_timeHero]
|
||||
};
|
||||
|
||||
sched_dzms = {
|
||||
local _array = _this select 0;
|
||||
local _timeBandit = _this select 1;
|
||||
local _timeHero = _this select 2;
|
||||
local _varName = "";
|
||||
|
||||
// Bandit mission timer
|
||||
if (((diag_tickTime - DZMSBanditEndTime) >= _timeBandit) && {DZMSBanditRunning < DZMSBanditLimit} && {DZMSMarkerReady}) then {
|
||||
DZMSMarkerReady = false;
|
||||
_varName = _array call BIS_fnc_selectRandom;
|
||||
DZMSMissionData = DZMSMissionData + [[0,[],[],[],[],[]]];
|
||||
DZMSBanditEndTime = diag_tickTime;
|
||||
DZMSBanditRunning = DZMSBanditRunning + 1;
|
||||
["Bandit"] execVM format ["\z\addons\dayz_server\DZMS\Missions\%1.sqf",_varName];
|
||||
if (DZMSDebug) then {diag_log text format ["[DZMS]: Running Bandit Mission %1.",_varName];};
|
||||
};
|
||||
|
||||
// Hero mission timer
|
||||
if (((diag_tickTime - DZMSHeroEndTime) >= _timeHero) && {DZMSHeroRunning < DZMSHeroLimit} && {DZMSMarkerReady}) then {
|
||||
DZMSMarkerReady = false;
|
||||
_varName = _array call BIS_fnc_selectRandom;
|
||||
DZMSMissionData = DZMSMissionData + [[0,[],[],[],[],[]]];
|
||||
DZMSHeroEndTime = diag_tickTime;
|
||||
DZMSHeroRunning = DZMSHeroRunning + 1;
|
||||
["Hero"] execVM format ["\z\addons\dayz_server\DZMS\Missions\%1.sqf",_varName];
|
||||
if (DZMSDebug) then {diag_log text format ["[DZMS]: Running Hero Mission %1.",_varName];};
|
||||
};
|
||||
|
||||
// Remove mission from array and reset array if necessary
|
||||
_array = _array - [_varName];
|
||||
if (count _array == 0) then {
|
||||
_array = +DZMSMissionArray;
|
||||
};
|
||||
|
||||
// Reset times
|
||||
_timeBandit = ((random(DZMSBanditMax - DZMSBanditMin) + DZMSBanditMin) * 60);
|
||||
_timeHero = ((random(DZMSHeroMax - DZMSHeroMin) + DZMSHeroMin) * 60);
|
||||
|
||||
[_array,_timeBandit,_timeHero]
|
||||
};
|
74
@DayZ_Epoch_Server/addons/dayz_server/system/scheduler/sched_event.sqf
Executable file
74
@DayZ_Epoch_Server/addons/dayz_server/system/scheduler/sched_event.sqf
Executable file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
DayZ Epoch Event Scheduler
|
||||
Made for DayZ Epoch please ask permission to use/edit/distrubute email vbawol@veteranbastards.com.
|
||||
*/
|
||||
|
||||
epoch_eventIsAny = {
|
||||
private ["_boolReturn","_event","_date","_bool","_index"];
|
||||
_event = _this select 0;
|
||||
_date = _this select 1;
|
||||
|
||||
_boolReturn = false;
|
||||
|
||||
_index = 0;
|
||||
{
|
||||
_bool = false;
|
||||
if (typeName _x == "STRING") then {
|
||||
_boolReturn = true;
|
||||
} else {
|
||||
_boolReturn = ((_date select _index) == _x);
|
||||
};
|
||||
if (!_boolReturn) exitWith {};
|
||||
_index = _index + 1;
|
||||
} count _event;
|
||||
|
||||
_boolReturn
|
||||
};
|
||||
|
||||
sched_event_init = {
|
||||
diag_log("EPOCH EVENTS INIT");
|
||||
""
|
||||
};
|
||||
|
||||
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);
|
||||
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";
|
||||
|
||||
// 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;
|
||||
} 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";
|
||||
};
|
||||
};
|
||||
} forEach EpochEvents;
|
||||
};
|
||||
};
|
||||
_lastTime
|
||||
};
|
37
@DayZ_Epoch_Server/addons/dayz_server/system/scheduler/sched_init.sqf
Executable file
37
@DayZ_Epoch_Server/addons/dayz_server/system/scheduler/sched_init.sqf
Executable file
@ -0,0 +1,37 @@
|
||||
#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_event.sqf");
|
||||
call compile preprocessFileLineNumbers (PATH+"sched_traps.sqf");
|
||||
|
||||
[
|
||||
// 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 ],
|
||||
[ 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;
|
||||
};
|
||||
*/
|
||||
|
115
@DayZ_Epoch_Server/addons/dayz_server/system/scheduler/sched_lootpiles.sqf
Executable file
115
@DayZ_Epoch_Server/addons/dayz_server/system/scheduler/sched_lootpiles.sqf
Executable file
@ -0,0 +1,115 @@
|
||||
#include "\z\addons\dayz_server\compile\server_toggle_debug.hpp"
|
||||
|
||||
sched_lootpiles_5m_init = {
|
||||
sched_lp_state = 0;
|
||||
sched_lp_var1 = 0;
|
||||
sched_lp_lootTotal = 0;
|
||||
sched_lp_delqty = 0;
|
||||
sched_lp_players = [];
|
||||
sched_lp_list = [];
|
||||
|
||||
objNull
|
||||
};
|
||||
|
||||
sched_lootpiles_5m = {
|
||||
private ["_created","_kind","_x"];
|
||||
if (sched_lp_state == 0) then {
|
||||
sched_lp_list = [];
|
||||
sched_lp_lootTotal = 0;
|
||||
{
|
||||
_kind = _x;
|
||||
{
|
||||
_created = _x getVariable ["created",-1];
|
||||
if (_created == -1) then {
|
||||
_created = diag_tickTime;
|
||||
_x setVariable ["created",_created];
|
||||
};
|
||||
if (!(_x getVariable ["permaLoot",false]) AND {(diag_tickTime - _created > 1500)}) then {
|
||||
sched_lp_list set [ count sched_lp_list, _x ];
|
||||
};
|
||||
sched_lp_lootTotal = sched_lp_lootTotal + 1;
|
||||
} forEach allMissionObjects _kind;
|
||||
} forEach [ "Blood_Trail_DZ", "ReammoBox", "Land_Fire_DZ", "flamable_DZ" ];
|
||||
#ifdef SERVER_DEBUG
|
||||
diag_log ["sched_lootpiles_5mn: reset lootpiles check, total visited:", sched_lp_lootTotal, "listed:", count sched_lp_list];
|
||||
#endif
|
||||
if (count sched_lp_list > 0) then {
|
||||
sched_lp_state = 1;
|
||||
sched_lp_var1 = 0;
|
||||
sched_lp_players = +(playableUnits);
|
||||
};
|
||||
};
|
||||
objNull
|
||||
};
|
||||
|
||||
sched_lootpiles = {
|
||||
private ["_plrBatch","_chunkSize","_imax","_plr","_i","_x", "_changed"];
|
||||
// EVERY 5 MINUTES, ONE OF THESE TASKS SPACED BY 5 SECONDS:
|
||||
// LOOK FOR OLD LOOTPILES -OR- IGNORE LOOTPILES NEAR _plrBatch PLAYERS -OR- REMOVE REMAINING _chunkSize LOOTPILES
|
||||
_chunkSize = 50;
|
||||
_plrBatch = 10;
|
||||
switch true do {
|
||||
case (sched_lp_state == 1): { // forEach players -> ignore nearby loot
|
||||
_imax = (count sched_lp_players) min (sched_lp_var1 + _plrBatch);
|
||||
//diag_log format ["%1: lootpiles foreach players from:%2 to:%3 players:%4 old:%5 total:%6", __FILE__, sched_lp_var1, _imax, count sched_lp_players, count sched_lp_list, sched_lp_lootTotal ];
|
||||
for "_i" from sched_lp_var1 to _imax-1 do {
|
||||
_plr = (sched_lp_players select _i);
|
||||
if (!(isNull _plr) AND {(isPlayer _plr)}) then {
|
||||
_plr = vehicle _plr;
|
||||
{
|
||||
if (_x IN sched_lp_list) then {
|
||||
sched_lp_list = sched_lp_list - [_x];
|
||||
};
|
||||
} forEach ((getPosATL _plr) nearObjects ["ReammoBox",250]);
|
||||
}/*
|
||||
else {
|
||||
diag_log format [ "%1 player left? %2", __FILE__, _x ];
|
||||
}*/;
|
||||
};
|
||||
sched_lp_var1 = _imax;
|
||||
_changed = false;
|
||||
if (_imax == count sched_lp_players) then { // catch the few players who entered meanwhile
|
||||
{
|
||||
if !(_x in sched_lp_players) then {
|
||||
sched_lp_players set [ count sched_lp_players, _x ];
|
||||
_changed = true;
|
||||
};
|
||||
} forEach playableUnits;
|
||||
};
|
||||
if (!_changed) then {
|
||||
sched_lp_state = 2;
|
||||
sched_lp_var1 = 0;
|
||||
sched_lp_delqty = count sched_lp_list;
|
||||
#ifdef SERVER_DEBUG
|
||||
diag_log [ "sched_lootpiles:Will delete",sched_lp_delqty,"lootpiles"];
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
#ifdef SERVER_DEBUG
|
||||
diag_log [ "sched_lootpiles:Extended loop for new players", _imax, count sched_lp_players];
|
||||
#endif
|
||||
};
|
||||
};
|
||||
case (sched_lp_state == 2): { // forEAch remaining lootpiles -> delete
|
||||
_imax = (sched_lp_delqty) min (sched_lp_var1 + _chunkSize);
|
||||
//diag_log format ["%1: lootpiles foreach loot to del from:%2 to:%3 old:%4 total:%5", __FILE__, sched_lp_var1, _imax, sched_lp_delqty, sched_lp_lootTotal ];
|
||||
for "_i" from sched_lp_var1 to _imax-1 do {
|
||||
_x = sched_lp_list select _i;
|
||||
if (!isNull _x) then {
|
||||
deleteVehicle _x;
|
||||
};
|
||||
};
|
||||
sched_lp_var1 = _imax;
|
||||
if (_imax == sched_lp_delqty) then {
|
||||
sched_lp_state = 0;
|
||||
sched_lp_list = [];
|
||||
#ifdef SERVER_DEBUG
|
||||
diag_log format ["%1: deleted %2 lootpiles from %3 total", __FILE__, sched_lp_delqty, sched_lp_lootTotal ];
|
||||
#endif
|
||||
};
|
||||
};
|
||||
}; // switch
|
||||
|
||||
objNull
|
||||
};
|
||||
|
@ -0,0 +1,12 @@
|
||||
|
||||
sched_safetyVehicle = {
|
||||
{
|
||||
if (vehicle _x != _x && !(vehicle _x in dayz_serverObjectMonitor) && !((typeOf vehicle _x) in DZE_safeVehicle)) then {
|
||||
diag_log [ __FILE__, "KILLING A HACKER", name _x, " IN ", typeOf vehicle _x ];
|
||||
(vehicle _x) setDamage 1;
|
||||
_x setDamage 1;
|
||||
};
|
||||
} forEach allUnits;
|
||||
|
||||
objNull
|
||||
};
|
62
@DayZ_Epoch_Server/addons/dayz_server/system/scheduler/sched_sync.sqf
Executable file
62
@DayZ_Epoch_Server/addons/dayz_server/system/scheduler/sched_sync.sqf
Executable file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
Instructions for using day/night schedule.
|
||||
|
||||
1. In your server config folder, edit file HiveExt.ini. Change [Time] Type to Local...Type = Local.
|
||||
2. Uncomment line 16 in this file: //#define DAY_NIGHT_SCHEDULE
|
||||
3. Adjust the hours of the day that you want to have night time in the arrays.
|
||||
|
||||
NOTES:
|
||||
The date/time is local to the server's time zone.
|
||||
The days referred to here are days of the month, not days of the week.
|
||||
You can configure odd and even days of the month to have different night time hours.
|
||||
Coordinate the hours with BEC server restarts defined in scheduler.xml.
|
||||
The default arrays alternate between day and night on a 4 hour schedule based on 0000, 0400, 0800, 1200, 1600, and 2000 restarts.
|
||||
*/
|
||||
|
||||
//#define DAY_NIGHT_SCHEDULE // Uncomment this line to enable day/night schedule.
|
||||
#define EVEN_DAY_NIGHT_HOURS [0,1,2,3,8,9,10,11,16,17,18,19] // These are the hours of the even numbered monthly days you wish to have night.
|
||||
#define ODD_DAY_NIGHT_HOURS [0,1,2,3,8,9,10,11,16,17,18,19] // These are the hours of the odd numbered monthly days you wish to have night.
|
||||
|
||||
|
||||
sched_sync = {
|
||||
private ["_date","_hour","_minute"];
|
||||
// RESYNC TIME ON ALL MACHINES EVERY 15 MINUTES
|
||||
// Date format [Year,Month,Day of the month,Hour,Minute]
|
||||
|
||||
_date = ServerCurrentTime; // ServerCurrentTime is set at server start in sched_event and updated every 60 seconds.
|
||||
_day = _date select 2;
|
||||
_hour = _date select 3;
|
||||
_minute = _date select 4;
|
||||
|
||||
#ifdef DAY_NIGHT_SCHEDULE
|
||||
_date set[3, 12]; // daytime unless overwritten below.
|
||||
|
||||
if (_day % 2 == 0) then { // check if day of the month is divisible by 2.
|
||||
if (_hour in EVEN_DAY_NIGHT_HOURS) then {
|
||||
_date set[3, 20]; // set hour to 20.
|
||||
};
|
||||
} else {
|
||||
if (_hour in ODD_DAY_NIGHT_HOURS) then {
|
||||
_date set[3, 20]; // set hour to 20.
|
||||
};
|
||||
};
|
||||
#endif
|
||||
|
||||
if(dayz_ForcefullmoonNights) then {
|
||||
_date = [2012,8,2,(_date select 3),_minute];
|
||||
};
|
||||
|
||||
dayz_storeTimeDate = _date; // dayz_storeTimeDate is used to set the date on client connections.
|
||||
|
||||
setDate _date;
|
||||
dayzSetDate = _date;
|
||||
publicVariable "dayzSetDate";
|
||||
diag_log [ __FILE__, "TIME SYNC: Local Time set to:", _date, "Fullmoon:",dayz_ForcefullmoonNights, "Date given by HiveExt.dll:", _date];
|
||||
|
||||
objNull
|
||||
};
|
||||
|
||||
sched_fps = {
|
||||
diag_log format["SERVER FPS: %1 PLAYERS: %2",round diag_fps,playersNumber west];
|
||||
objNull
|
||||
};
|
49
@DayZ_Epoch_Server/addons/dayz_server/system/scheduler/sched_traps.sqf
Executable file
49
@DayZ_Epoch_Server/addons/dayz_server/system/scheduler/sched_traps.sqf
Executable file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
This scheduled task checks for changes in the number of bear traps set by players.
|
||||
It is set to run every 30 seconds by default in sched_init.
|
||||
For each of the traps, it gets the "armed" variable and calls the appropriate script
|
||||
to arm or disarm the bear trap. Lazy eval has been added so that the function evaluates
|
||||
quickly. Bear traps are not a popular feature in DayZ Epoch.
|
||||
*/
|
||||
|
||||
sched_traps_init = {
|
||||
//diag_log("Bear Trap Monitor Started");
|
||||
[str dayz_traps,str dayz_traps_active,str dayz_traps_trigger]
|
||||
};
|
||||
|
||||
sched_traps = {
|
||||
private ["_array","_array2","_array3","_script","_armed"];
|
||||
_array = _this select 0;
|
||||
_array2 = _this select 1;
|
||||
_array3 = _this select 2;
|
||||
|
||||
if ((str dayz_traps != _array) || {str dayz_traps_active != _array2} || {str dayz_traps_trigger != _array3}) then {
|
||||
_array = str dayz_traps;
|
||||
_array2 = str dayz_traps_active;
|
||||
_array3 = str dayz_traps_trigger;
|
||||
//diag_log "DEBUG: traps";
|
||||
//diag_log format["dayz_traps (%2) -> %1", dayz_traps, count dayz_traps];
|
||||
//diag_log format["dayz_traps_active (%2) -> %1", dayz_traps_active, count dayz_traps_active];
|
||||
//diag_log format["dayz_traps_trigger (%2) -> %1", dayz_traps_trigger, count dayz_traps_trigger];
|
||||
//diag_log "DEBUG: end traps";
|
||||
};
|
||||
|
||||
{
|
||||
if (isNull _x) then {
|
||||
dayz_traps = dayz_traps - [_x];
|
||||
_armed = false;
|
||||
_script = {};
|
||||
} else {
|
||||
_armed = _x getVariable ["armed", false];
|
||||
_script = call compile getText (configFile >> "CfgVehicles" >> typeOf _x >> "script");
|
||||
};
|
||||
|
||||
if (_armed) then {
|
||||
if !(_x in dayz_traps_active) then {["arm", _x] call _script;};
|
||||
} else {
|
||||
if (_x in dayz_traps_active) then {["disarm", _x] call _script;};
|
||||
};
|
||||
} forEach dayz_traps;
|
||||
|
||||
[_array,_array2,_array3]
|
||||
};
|
78
@DayZ_Epoch_Server/addons/dayz_server/system/scheduler/sched_wai.sqf
Executable file
78
@DayZ_Epoch_Server/addons/dayz_server/system/scheduler/sched_wai.sqf
Executable file
@ -0,0 +1,78 @@
|
||||
/*
|
||||
This scheduled task checks for running WAI missions and starts them appropriately.
|
||||
*/
|
||||
|
||||
sched_wai_init = {
|
||||
diag_log("WAI: Scheduler Started");
|
||||
local _hArray = +wai_hero_missions;
|
||||
local _bArray = +wai_bandit_missions;
|
||||
local _hTime = (random((wai_mission_timer select 1) - (wai_mission_timer select 0)) + (wai_mission_timer select 0)) * 60;
|
||||
local _bTime = (random((wai_mission_timer select 1) - (wai_mission_timer select 0)) + (wai_mission_timer select 0)) * 60;
|
||||
[_hArray,_bArray,_bTime,_hTime]
|
||||
};
|
||||
|
||||
sched_wai = {
|
||||
local _hArray = _this select 0;
|
||||
local _bArray = _this select 1;
|
||||
local _bTime = _this select 2;
|
||||
local _hTime = _this select 3;
|
||||
local _mission = "";
|
||||
|
||||
// Bandit mission timer
|
||||
if (WAI_MarkerReady && {diag_tickTime - wai_b_starttime >= _bTime} && {b_missionsrunning < wai_bandit_limit}) then {
|
||||
WAI_MarkerReady = false;
|
||||
local _selected = false;
|
||||
|
||||
while {!_selected} do {
|
||||
if (wai_debug_mode) then {diag_log format["WAI: Bandit Array: %1",_bArray];};
|
||||
_mission = _bArray select (floor (random (count _bArray)));
|
||||
_index = [_bArray, (_mission select 0)] call BIS_fnc_findNestedElement select 0;
|
||||
_bArray = [_bArray,_index] call fnc_deleteAt;
|
||||
if (count _bArray == 0) then {_bArray = +wai_bandit_missions;};
|
||||
if ((_mission select 1) >= random 1) then {
|
||||
_selected = true;
|
||||
if (wai_debug_mode) then {diag_log format["WAI: Bandit mission %1 selected.",(_mission select 0)];};
|
||||
} else {
|
||||
if (wai_debug_mode) then {diag_log format["WAI: Bandit mission %1 NOT selected.",(_mission select 0)];};
|
||||
};
|
||||
};
|
||||
|
||||
b_missionsrunning = b_missionsrunning + 1;
|
||||
wai_b_starttime = diag_tickTime;
|
||||
wai_mission_markers set [(count wai_mission_markers), ("MainBandit" + str(count wai_mission_data))];
|
||||
wai_mission_data = wai_mission_data + [[0,[],[],[],[],[],[]]];
|
||||
["MainBandit","Hero"] execVM format ["\z\addons\dayz_server\WAI\missions\missions\%1.sqf",(_mission select 0)];
|
||||
};
|
||||
|
||||
// Hero mission timer
|
||||
if (WAI_MarkerReady && {diag_tickTime - wai_h_starttime >= _hTime} && {h_missionsrunning < wai_hero_limit}) then {
|
||||
WAI_MarkerReady = false;
|
||||
local _selected = false;
|
||||
|
||||
while {!_selected} do {
|
||||
if (wai_debug_mode) then {diag_log format["WAI: Hero Array: %1",_hArray];};
|
||||
_mission = _hArray select (floor (random (count _hArray)));
|
||||
_index = [_hArray, (_mission select 0)] call BIS_fnc_findNestedElement select 0;
|
||||
_hArray = [_hArray,_index] call fnc_deleteAt;
|
||||
if (count _hArray == 0) then {_hArray = +wai_hero_missions;};
|
||||
if ((_mission select 1) >= random 1) then {
|
||||
_selected = true;
|
||||
if (wai_debug_mode) then {diag_log format["WAI: Hero mission %1 selected.",(_mission select 0)];};
|
||||
} else {
|
||||
if (wai_debug_mode) then {diag_log format["WAI: Hero mission %1 NOT selected.",(_mission select 0)];};
|
||||
};
|
||||
};
|
||||
|
||||
h_missionsrunning = h_missionsrunning + 1;
|
||||
wai_h_starttime = diag_tickTime;
|
||||
wai_mission_markers set [(count wai_mission_markers), ("MainHero" + str(count wai_mission_data))];
|
||||
wai_mission_data = wai_mission_data + [[0,[],[],[],[],[],[]]];
|
||||
["MainHero","Bandit"] execVM format ["\z\addons\dayz_server\WAI\missions\missions\%1.sqf",(_mission select 0)];
|
||||
};
|
||||
|
||||
// Reset times
|
||||
_hTime = (random((wai_mission_timer select 1) - (wai_mission_timer select 0)) + (wai_mission_timer select 0)) * 60;
|
||||
_bTime = (random((wai_mission_timer select 1) - (wai_mission_timer select 0)) + (wai_mission_timer select 0)) * 60;
|
||||
|
||||
[_hArray,_bArray,_bTime,_hTime]
|
||||
};
|
Reference in New Issue
Block a user