mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2026-02-26 17:51:51 +03:00
Server Done I Think
This commit is contained in:
158
SQF/dayz_server/system/scheduler/sched_corpses.sqf
Normal file
158
SQF/dayz_server/system/scheduler/sched_corpses.sqf
Normal file
@@ -0,0 +1,158 @@
|
||||
#include "\z\addons\dayz_server\compile\server_toggle_debug.hpp"
|
||||
|
||||
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 ["_delQtyZ","_delQtyP","_addFlies","_x","_deathTime","_onoff","_delQtyAnimal", "_sound", "_deathPos", "_cpos"];
|
||||
// EVERY 2 MINUTE
|
||||
// DELETE UNCONTROLLED ZOMBIES --- PUT FLIES ON FRESH PLAYER CORPSES --- REMOVE OLD FLIES & CORPSES
|
||||
_delQtyZ = 0;
|
||||
_delQtyP = 0;
|
||||
_addFlies = 0;
|
||||
// diag_log "bodies ...";
|
||||
{
|
||||
if (local _x) then {
|
||||
if (_x isKindOf "zZombie_Base") then {
|
||||
_x call sched_co_deleteVehicle;
|
||||
_delQtyZ = _delQtyZ + 1;
|
||||
} else {
|
||||
if (_x isKindOf "CAManBase") then {
|
||||
_deathTime = _x getVariable ["sched_co_deathTime", -1];
|
||||
if (_deathTime == -1) then {
|
||||
|
||||
_deathPos = _x getVariable [ "deathPos", getMarkerPos "respawn_west" ];
|
||||
_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 has been moved! CID#",(_x getVariable["characterID", "?"]),"from:", _cpos, "to:", _deathPos ];
|
||||
_x setPosATL _deathPos;
|
||||
};
|
||||
_deathTime = diag_tickTime;
|
||||
_x setVariable ["sched_co_deathTime", _deathTime];
|
||||
_x setVariable ["sched_co_fliesAdded", true];
|
||||
_addFlies = _addFlies + 1;
|
||||
|
||||
};
|
||||
// 40 minutes = how long a player corpse stays on the map
|
||||
if (diag_tickTime - _deathTime > 40*60) then {
|
||||
if (_x getVariable ["sched_co_fliesDeleted", false]) 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 {
|
||||
_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";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
} forEach allDead;
|
||||
|
||||
_delQtyAnimal = 0;
|
||||
{
|
||||
if (local _x) then {
|
||||
_x 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 > 0) then {
|
||||
diag_log format ["%1: Deleted %2 uncontrolled zombies, %3 uncontrolled animals, %4 dead character bodies and %5 empty groups. Added %6 flies.", __FILE__,
|
||||
_delQtyZ, _delQtyAnimal, _delQtyP,_delQtyGrp, _addFlies ];
|
||||
};
|
||||
#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
|
||||
};
|
||||
*/
|
||||
35
SQF/dayz_server/system/scheduler/sched_init.sqf
Normal file
35
SQF/dayz_server/system/scheduler/sched_init.sqf
Normal file
@@ -0,0 +1,35 @@
|
||||
|
||||
_base="z\addons\dayz_server\system\scheduler\";
|
||||
|
||||
call compile preprocessFileLineNumbers (_base+"sched_corpses.sqf");
|
||||
call compile preprocessFileLineNumbers (_base+"sched_lootpiles.sqf");
|
||||
//call compile preprocessFileLineNumbers (_base+"sched_playersHivesync.sqf");
|
||||
//call compile preprocessFileLineNumbers (_base+"sched_vehiclesHivesync.sqf");
|
||||
call compile preprocessFileLineNumbers (_base+"sched_sync.sqf");
|
||||
//call compile preprocessFileLineNumbers (_base+"sched_traps.sqf");
|
||||
call compile preprocessFileLineNumbers (_base+"sched_safetyVehicle.sqf");
|
||||
|
||||
[
|
||||
// period offset code <-> ctx init code ->ctx
|
||||
//[ 60, 121, sched_playersHivesync, sched_playersHivesync_init ],
|
||||
//[ 60, 133, sched_vehiclesHivesync, sched_vehiclesHivesync_init ],
|
||||
[ 60, 224, sched_corpses ],
|
||||
[ 300, 336, sched_lootpiles_5m, sched_lootpiles_5m_init ],
|
||||
[ 6, 340, sched_lootpiles ],
|
||||
[ 900, 0, sched_sync ],
|
||||
[ 120, 48, sched_safetyVehicle ]
|
||||
//[ 0.1, 1, sched_traps ]
|
||||
] 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;
|
||||
};
|
||||
*/
|
||||
|
||||
113
SQF/dayz_server/system/scheduler/sched_lootpiles.sqf
Normal file
113
SQF/dayz_server/system/scheduler/sched_lootpiles.sqf
Normal file
@@ -0,0 +1,113 @@
|
||||
#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;
|
||||
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
|
||||
};
|
||||
|
||||
44
SQF/dayz_server/system/scheduler/sched_playersHivesync.sqf
Normal file
44
SQF/dayz_server/system/scheduler/sched_playersHivesync.sqf
Normal file
@@ -0,0 +1,44 @@
|
||||
|
||||
|
||||
sched_playershivewrite = {
|
||||
private ["_n","_x","_damage","_pos","_otime","_opos","_odamage"];
|
||||
// EVERY 1 MINUTE
|
||||
// FORCE HIVE WRITE FOR PLAYERS WHO NEED IT (HUMANITY OR POSITION OR TIMEOUT CHANGE)
|
||||
_n = 0;
|
||||
{
|
||||
if ((isPlayer _x) AND {(alive _x)}) then {
|
||||
_damage = _x getVariable [ "USEC_BloodQty", -1 ];
|
||||
_pos = visiblePosition _x; // genuine position, deals with player in vehicle or not
|
||||
if (_damage >= 0) then { // not a character?
|
||||
_otime = _x getVariable [ "sched_ph_sync_time", -1];
|
||||
_opos = _x getVariable [ "sched_ph_sync_pos", _pos];
|
||||
_odamage = _x getVariable [ "sched_ph_sync_dmg", _damage];
|
||||
if (_otime == -1) then {
|
||||
_otime = diag_tickTime;
|
||||
_x setVariable [ "sched_ph_sync_time", _otime];
|
||||
_x setVariable [ "sched_ph_sync_pos", _opos];
|
||||
_x setVariable [ "sched_ph_sync_dmg", _odamage];
|
||||
};
|
||||
if ((diag_tickTime - _otime > 600) OR {((_pos distance _opos > 50) OR {(_odamage != _damage)})}) then {
|
||||
[_x, nil, true] call server_playerSync;
|
||||
_x setVariable [ "sched_ph_sync_time", diag_tickTime];
|
||||
_x setVariable [ "sched_ph_sync_pos", _pos];
|
||||
_x setVariable [ "sched_ph_sync_dmg", _damage];
|
||||
_n = _n + 1;
|
||||
};
|
||||
};
|
||||
if ([ -11000+500, 15360-21000+500, 0 ] distance _pos < 2000) then {
|
||||
diag_log format [ "HACK, player %1 at anti-ESP zone, killing him but no HIVE save for him.", _x call fa_plr2str ];
|
||||
_x setVariable ["CharacterID", nil, true ];
|
||||
unassignVehicle _x;
|
||||
_pos set [2, 2000]; // will be killed by gravity OR kick by anti TP
|
||||
_x setPosATL _pos;
|
||||
};
|
||||
};
|
||||
} forEach playableUnits;
|
||||
if (_n > 0) then {
|
||||
diag_log format ["%1: sync'ed %2 players to HIVE", __FILE__, _n];
|
||||
};
|
||||
|
||||
objNull
|
||||
};
|
||||
12
SQF/dayz_server/system/scheduler/sched_safetyVehicle.sqf
Normal file
12
SQF/dayz_server/system/scheduler/sched_safetyVehicle.sqf
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
sched_safetyVehicle = {
|
||||
{
|
||||
if (vehicle _x != _x && !(vehicle _x in dayz_serverObjectMonitor) && (typeOf vehicle _x) != "ParachuteWest") then {
|
||||
diag_log [ __FILE__, "KILLING A HACKER", name _x, " IN ", typeOf vehicle _x ];
|
||||
(vehicle _x) setDamage 1;
|
||||
_x setDamage 1;
|
||||
};
|
||||
} forEach allUnits;
|
||||
|
||||
objNull
|
||||
};
|
||||
25
SQF/dayz_server/system/scheduler/sched_sync.sqf
Normal file
25
SQF/dayz_server/system/scheduler/sched_sync.sqf
Normal file
@@ -0,0 +1,25 @@
|
||||
sched_sync = {
|
||||
private ["_result","_outcome","_date","_hour","_minute"];
|
||||
// EVERY 15 MINUTES
|
||||
// RESYNC TIME WITH HIVE DLL SYSTEM CALL
|
||||
|
||||
_result = "CHILD:307:" call server_hiveReadWrite;
|
||||
_outcome = _result select 0;
|
||||
if(_outcome == "PASS") then {
|
||||
_date = _result select 1;
|
||||
|
||||
_hour = _date select 3;
|
||||
_minute = _date select 4;
|
||||
|
||||
if(dayz_ForcefullmoonNights) then {
|
||||
_date = [2012,8,2,_hour,_minute];
|
||||
};
|
||||
|
||||
setDate _date;
|
||||
dayzSetDate = _date;
|
||||
publicVariable "dayzSetDate";
|
||||
diag_log [ __FILE__, "TIME SYNC: Local Time set to:", _date, "Fullmoon:",dayz_ForcefullmoonNights, "Date given by HiveExt.dll:", _result select 1];
|
||||
};
|
||||
|
||||
objNull
|
||||
};
|
||||
33
SQF/dayz_server/system/scheduler/sched_traps.sqf
Normal file
33
SQF/dayz_server/system/scheduler/sched_traps.sqf
Normal file
@@ -0,0 +1,33 @@
|
||||
sched_traps = {
|
||||
private ["_n","_x"];
|
||||
// EVERY 5 SECONDS
|
||||
// CHECK TRAPS STATE
|
||||
if (!isNil "dayz_traps") then {
|
||||
_n = 0;
|
||||
{
|
||||
if ((isNil "_x") OR {(isNull _x)}) then {
|
||||
dayz_traps = dayz_traps - [_x];
|
||||
}
|
||||
else {
|
||||
if (_x getVariable ["armed", false]) then {
|
||||
if !(_x in dayz_traps_active) then {
|
||||
["arm", _x] call compile getText (configFile >> "CfgVehicles" >> typeOf _x >> "script");
|
||||
if !(_x in dayz_traps_active) then { dayz_traps_active set [ count dayz_traps_active, _x ]; };
|
||||
_n = _n + 1;
|
||||
};
|
||||
} else {
|
||||
if (_x in dayz_traps_active) then {
|
||||
["disarm", _x] call compile getText (configFile >> "CfgVehicles" >> typeOf _x >> "script");
|
||||
if (_x in dayz_traps_active) then { dayz_traps_active = dayz_traps_active - [_x]; };
|
||||
_n = _n + 1;
|
||||
};
|
||||
};
|
||||
};
|
||||
} forEach dayz_traps;
|
||||
if (_n > 0) then {
|
||||
diag_log format ["%1: traps polling, changed %2 states", __FILE__, _n];
|
||||
};
|
||||
};
|
||||
|
||||
objNull
|
||||
};
|
||||
37
SQF/dayz_server/system/scheduler/sched_vehiclesHivesync.sqf
Normal file
37
SQF/dayz_server/system/scheduler/sched_vehiclesHivesync.sqf
Normal file
@@ -0,0 +1,37 @@
|
||||
|
||||
sched_vehicleshivewrite = {
|
||||
private ["_n","_x","_damage","_pos","_otime","_opos","_odamage"];
|
||||
// EVERY 1 MINUTE
|
||||
// FORCE HIVE WRITE FOR VEHICLES WHO NEED IT (DAMAGE OR POSITION OR TIMEOUT CHANGE)
|
||||
_n = 0;
|
||||
{
|
||||
if (_x isKindOf "AllVehicles") then {
|
||||
_damage = damage _x;
|
||||
_pos = getPosASL _x;
|
||||
_otime = _x getVariable [ "sched_vh_sync_time", -1];
|
||||
_opos = _x getVariable [ "sched_vh_sync_pos", _pos];
|
||||
_odamage = _x getVariable [ "sched_vh_sync_dmg", _damage];
|
||||
if (_otime == -1) then {
|
||||
_otime = diag_tickTime - random 480;
|
||||
_x setVariable [ "sched_vh_sync_time", _otime];
|
||||
_x setVariable [ "sched_vh_sync_pos", _opos];
|
||||
_x setVariable [ "sched_vh_sync_dmg", _odamage];
|
||||
};
|
||||
if ((diag_tickTime - _otime > 600) OR {((_pos distance _opos > 50) OR {(_odamage != _damage)})}) then {
|
||||
_x setVariable [ "sched_vh_sync_time", diag_tickTime];
|
||||
_x setVariable [ "sched_vh_sync_pos", _pos];
|
||||
_x setVariable [ "sched_vh_sync_dmg", _damage];
|
||||
[_x, "all", true] call server_updateObject;
|
||||
_n = _n + 1;
|
||||
}/*
|
||||
else {
|
||||
diag_log format ["%1: veh %2 %3 %4 %5", __FILE__, _x, _otime, _opos, _odamage];
|
||||
}*/;
|
||||
};
|
||||
} forEach vehicles;
|
||||
if (_n > 0) then {
|
||||
diag_log format ["%1: sync'ed %2 vehicles to HIVE", __FILE__, _n];
|
||||
};
|
||||
|
||||
objNull
|
||||
};
|
||||
Reference in New Issue
Block a user