From 8fb45fc35c6e7818f13f009eb0cc4b994a6df3d2 Mon Sep 17 00:00:00 2001 From: "DESKTOP-UH65DCE\\MusTanG" Date: Sun, 12 Nov 2017 17:39:03 -0600 Subject: [PATCH] events overhaul Streamline all events to Events Monitor within Server Monitor fsm. Cycles and removes events as they decay or are looted. --- .../EPOCH_server_spawnBoatLoot.sqf | 52 +- .../EPOCH_server_isNearChecks.sqf | 55 + Sources/epoch_server/config.cpp | 1 + .../epoch_server/system/server_monitor.fsm | 1004 +++++++++-------- .../EpochEvents/CarnivalSpawner.sqf | 91 +- .../EpochEvents/ContainerSpawner.sqf | 78 +- .../EpochEvents/EarthQuake.sqf | 77 +- .../EpochEvents/PlantSpawner.sqf | 148 ++- .../EpochEvents/Satellite.sqf | 86 +- Sources/epoch_server_settings/config.cpp | 70 +- 10 files changed, 1077 insertions(+), 585 deletions(-) create mode 100644 Sources/epoch_server/compile/epoch_server/EPOCH_server_isNearChecks.sqf diff --git a/Sources/epoch_server/compile/epoch_looting/EPOCH_server_spawnBoatLoot.sqf b/Sources/epoch_server/compile/epoch_looting/EPOCH_server_spawnBoatLoot.sqf index d9c55968..f2d9f828 100644 --- a/Sources/epoch_server/compile/epoch_looting/EPOCH_server_spawnBoatLoot.sqf +++ b/Sources/epoch_server/compile/epoch_looting/EPOCH_server_spawnBoatLoot.sqf @@ -13,29 +13,39 @@ https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server/compile/epoch_looting/EPOCH_server_spawnBoatLoot.sqf */ //[[[cog import generate_private_arrays ]]] -private ["_worldSize","_shipwrecks","_total","_count","_distFromOthers","_tooClose","_spawnedLoot","_wreck","_item","_markers"]; +private ["_cfgEpoch","_debug","_showBoatMarkers","_decayMarkerColor","_compromisedColor","_worldSize","_shipwrecks","_total","_count","_distFromOthers","_tooClose","_spawnedLoot","_wreck","_item","_markers","_position","_debugMkr","_heightenedPVP"]; //[[[end]]] _cfgEpoch = configFile >> "CfgEpoch" >> worldname; +_debug = if(getNumber(_cfgEpoch >> "debugShipwreckLoot") isEqualTo 1)then{true}else{false}; +_showBoatMarkers = if(getNumber(_cfgEpoch >> "showBoatLootMarkers") isEqualTo 1)then{true}else{false}; +_decayMarkerColor = getText(_cfgEpoch >> "shipwreckDecayMarkerColor"); +_compromisedColor = getText(_cfgEpoch >> "shipwreckCompromisedColor"); +_heightenedPVP = if(getNumber(_cfgEpoch >> "HeightenedPlayerVsPlayer") isEqualTo 1)then{true}else{false}; +_markers = []; +_originalColors = []; + if (getNumber(_cfgEpoch >> "shipwreckLootEnabled") isEqualTo 1) then { _worldSize = worldSize/2; _shipwrecks = nearestTerrainObjects [ [_worldSize, _worldSize], ["SHIPWRECK"], _worldSize]; _total = getNumber(_cfgEpoch >> "maxSpawnedShipwrecks"); - if(_shipwrecks isEqualTo [])exitWith{diag_log "EPOCHDebug: no shipwrecks found"}; - if(_total isEqualTo 0)exitWith{diag_log "EPOCHDebug: no shipwrecks allowed"}; + if(_shipwrecks isEqualTo [])exitWith{if(_debug)then{diag_log "EPOCHDebug: no shipwrecks found"}}; + if(_total isEqualTo 0)exitWith{if(_debug)then{diag_log "EPOCHDebug: no shipwrecks allowed"}}; + _count = count(_shipwrecks); - if(_count < _total)then{diag_log "EPOCHDebug: not enough shipwrecks to fill your needs on this map, trying all available locations!"}; + if(_count < _total)then{if(_debug)then{diag_log "EPOCHDebug: not enough shipwrecks to fill your needs on this map, trying all available locations!"}}; _distFromOthers = getNumber(_cfgEpoch >> "distFromOtherShipwrecks"); _spawnedLoot = []; for "_i" from 1 to _total do { - if(_shipwrecks isEqualTo [])exitWith{diag_log "EPOCHDebug: no more shipwrecks found"}; + if(_shipwrecks isEqualTo [])exitWith{if(_debug)then{diag_log "EPOCHDebug: no more shipwrecks found"}}; + _tooClose = false; _wreck = selectRandom _shipwrecks; if(isNil "_wreck")exitWith{}; { if(!(_spawnedLoot isEqualTo []) && ((_wreck distance _x) < _distFromOthers))exitWith{ - diag_log "EPOCHDebug: Shipwreck too close to another shipwreck"; + if(_debug)then{diag_log "EPOCHDebug: Shipwreck too close to another shipwreck"}; _tooClose = true; _i = (_i - 1); }; @@ -46,12 +56,32 @@ if (getNumber(_cfgEpoch >> "shipwreckLootEnabled") isEqualTo 1) then { _position = [_wreck,1,20,3,1,20,0] call BIS_fnc_findSafePos; _item = createVehicle["container_epoch",_position, [], 0, "NONE"]; _spawnedLoot pushback _wreck; - _item setMass 220; - - if (EPOCH_SHOW_BOATLOOT) then { - _markers = ["Shipwreck",_wreck] call EPOCH_server_createGlobalMarkerSet; + if(_debug)then{ + _debugMkr = createMarker [str(_position),_position]; + _debugMkr setMarkerShape "ICON"; + _debugMkr setMarkerType "mil_dot"; + _debugMkr setMarkerColor "ColorRed"; }; + _item setMass 220; + _item setVariable["EPOCH_Loot",false,true]; + if (_showBoatMarkers) then { + _markers = ["Shipwreck",_wreck] call EPOCH_server_createGlobalMarkerSet; + { + _originalColors pushBack (getMarkerColor _x); + }forEach _markers; + }; + + // Check for HeightenedPlayerVsPlayer false and remove comprimised coloring + if((_showBoatMarkers) && !(_heightenedPVP))then{ + _compromisedColor = getMarkerColor (_markers select 0); + }; + + _rEvents = missionNameSpace getVariable["EPOCH_RunningEvents",[]]; + _shipwreckEvent = [_position, [_item], [], "shipwreckCounter", diag_tickTime, 99999, _showBoatMarkers, _markers, _originalColors, _decayMarkerColor, _compromisedColor]; + missionNameSpace setVariable["EPOCH_RunningEvents",_rEvents + [_shipwreckEvent]]; }; }; - diag_log format["EPOCHDebug: Safely spawned %1 loot container(s) at these shipwreck locations:%2",count _spawnedLoot , _spawnedLoot]; + if(_debug)then{ + diag_log format["EPOCHDebug: Safely spawned %1 loot container(s) at these shipwreck locations:%2",count _spawnedLoot , _spawnedLoot]; + }; }; \ No newline at end of file diff --git a/Sources/epoch_server/compile/epoch_server/EPOCH_server_isNearChecks.sqf b/Sources/epoch_server/compile/epoch_server/EPOCH_server_isNearChecks.sqf new file mode 100644 index 00000000..13484ab0 --- /dev/null +++ b/Sources/epoch_server/compile/epoch_server/EPOCH_server_isNearChecks.sqf @@ -0,0 +1,55 @@ +/* + EPOCH_server_isNearChecks + + Author: DirtySanchez + + Description: + Checks the position provided against distances configured for Traders, Jammers and Players. + + _position - position on map + _traderCheck - BOOL - check _position distance near ProtectionZone_Invisible_F + _jammerCheck - BOOL - check _position distance near PlotPole_EPOCH + _playerCheck - BOOL - check _position distance near other Players + _others - ARRAY - positions to check with _distFromOthers + _distFromOthers - NUMBER - How far away from _others array in meters +*/ + +params [ ["_position",[]], ["_traderCheck",true], ["_jammerCheck",true], ["_playerCheck",true], ["_others",[[0,0,0]]], ["_distFromOthers",2000] ]; +_distFromTraders = getNumber(_cfgEpoch >> "spawnDistanceFromTraders"); +_distFromJammers = getNumber(_cfgEpoch >> "spawnDistanceFromJammers"); +_distFromPlayers = getNumber(_cfgEpoch >> "spawnDistanceFromPlayers"); +_return = true; + +//CHECK FOR PROTECTED AREA WITIN CONFIG RANGE +if(_traderCheck)then{ + _restricted = nearestObjects [_position, ["ProtectionZone_Invisible_F"], _distFromTraders]; + if(count _restricted > 0) then { + _return = false; + }; +}; + +//CHECK FOR JAMMERS IN THE AREA WITHIN CONFIG RANGE +if(_jammerCheck)then{ + _jammers = nearestObjects[_position, ["PlotPole_EPOCH"], _distFromJammers]; + if(count _jammers > 0) then { + _return = false; + }; +}; + +//CHECK TO SEE IF PLAYERS WITHIN CONFIG RANGE +if(_playerCheck)then{ + _playersNearby = _position nearEntities[["Epoch_Male_F", "Epoch_Female_F"], _distFromPlayers]; + if(count _playersNearby > 0) then { + _return = false; + }; +}; + +//CHECK FOR OTHERS +if!(_others isEqualTo [[0,0,0]])then{ + { + if!(_x distance _position > _distFromOthers)then{ + _return = false; + }; + }forEach _others; +}; +_return \ No newline at end of file diff --git a/Sources/epoch_server/config.cpp b/Sources/epoch_server/config.cpp index f4a03418..8632f8a5 100644 --- a/Sources/epoch_server/config.cpp +++ b/Sources/epoch_server/config.cpp @@ -125,6 +125,7 @@ class CfgServerFunctions class server_removeMarker {}; class server_createGlobalMarkerSet {}; class server_deleteGlobalMarkerSet {}; + class server_isNearChecks {}; }; class epoch_missions { class Server_createObject {}; diff --git a/Sources/epoch_server/system/server_monitor.fsm b/Sources/epoch_server/system/server_monitor.fsm index e224aaaa..671dee37 100644 --- a/Sources/epoch_server/system/server_monitor.fsm +++ b/Sources/epoch_server/system/server_monitor.fsm @@ -1,4 +1,4 @@ -/*%FSM*/ +/*%FSM*/ /*%FSM*/ /* item0[] = {"Init",0,250,600.000000,-575.000000,700.000000,-525.000000,0.000000,"Init"}; @@ -12,7 +12,22 @@ item7[] = {"Events_Manager",4,218,599.992371,-192.435822,699.992371,-142.435822, item8[] = {"Save_Vehicles",4,218,450.000000,-300.000000,550.000000,-250.000000,4.000000,"Save" \n "Vehicles"}; item9[] = {"Cleanup_Handler",4,218,750.000000,-450.000000,850.000000,-400.000000,8.000000,"Cleanup" \n "Handler"}; item10[] = {"Server_FPS",4,218,746.045227,-248.683014,846.045227,-198.683014,0.000000,"Server FPS"}; -item11[] = {"Forced_Restart",4,4314,684.856567,-214.145233,784.856567,-164.145233,0.000000,"Forced" \n "Restart"}; +item11[] = {"Forced_Restart",4,218,684.856567,-214.145233,784.856567,-164.145233,0.000000,"Forced" \n "Restart"}; +item12[] = {"Events_Monitor",4,4314,516.730896,-213.251221,616.730896,-163.251221,0.000000,"Events" \n "Monitor"}; +item13[] = {"_",-1,250,532.894043,-183.108612,548.753357,-175.178955,0.000000,""}; +version=1; +class LayoutItems +{ + class Item13 + { + class ItemInfo + { + FontFace="Arial"; + FontHeight=10; + lStyle=1; + }; + }; +}; link0[] = {0,1}; link1[] = {1,2}; link2[] = {2,3}; @@ -24,459 +39,550 @@ link7[] = {2,8}; link8[] = {2,9}; link9[] = {2,10}; link10[] = {2,11}; -link11[] = {3,2}; -link12[] = {4,2}; -link13[] = {5,2}; -link14[] = {6,2}; -link15[] = {7,2}; -link16[] = {8,2}; -link17[] = {9,2}; -link18[] = {10,2}; -link19[] = {11,2}; -globals[] = {0.000000,0,0,0,0,640,480,1,5,6316128,1,275.180084,1161.319580,208.497711,-659.879456,898,884,1}; -window[] = {2,-1,-1,-1,-1,864,104,1396,104,3,916}; +link11[] = {2,12}; +link12[] = {3,2}; +link13[] = {4,2}; +link14[] = {5,2}; +link15[] = {6,2}; +link16[] = {7,2}; +link17[] = {8,2}; +link18[] = {9,2}; +link19[] = {10,2}; +link20[] = {11,2}; +link21[] = {12,2}; +globals[] = {0.000000,0,0,0,0,640,480,1,6,6316128,1,275.180084,1161.319580,208.497711,-659.879456,896,844,1}; +window[] = {2,-1,-1,-32000,-32000,984,224,1516,224,3,918}; *//*%FSM*/ class FSM { - fsmName = "Server Monitor"; - class States - { - /*%FSM*/ - class Init - { - name = "Init"; - init = /*%FSM*/"diag_log ""Loaded Server FSM"";" \n - "" \n - "_cfgSecConf = (configFile >> ""CfgSecConf"");" \n - "_cfgSecConf_vehicles = (_cfgSecConf >> ""vehicles"");" \n - "_safeVehicles = [_cfgSecConf_vehicles, ""safeVehicles"", [""I_UAV_01_F"",""B_Heli_Transport_01_F"",""Steerable_Parachute_F"",""NonSteerable_Parachute_F"",""Land_Camping_Light_F"",""container_epoch""]] call EPOCH_fnc_returnConfigEntry;" \n - "" \n - "_serverSettingsConfig = configFile >> ""CfgEpochServer"";" \n - "_ahInitAuthCfg = [_serverSettingsConfig, ""antihack_ahInitAuthCfg"", [0,180]] call EPOCH_fnc_returnConfigEntry;" \n - "_events = [_serverSettingsConfig, ""events"", []] call EPOCH_fnc_returnConfigEntry;" \n - "" \n - "_initAhInitBanOrLog = _ahInitAuthCfg select 0;" \n - "_initTimeLimit = _ahInitAuthCfg select 1;" \n - "" \n - "// Load Epoch Events 3.0" \n - "{" \n - " diag_log format[""Loading Settings for %1 event..."",configName _x];" \n - " _events pushBack [getNumber (_x >> ""delay""),getText (_x >> ""script""),getNumber (_x >> ""runOnStart""),getNumber (_x >> ""usePrefix""),getNumber (_x >> ""runNumTimes""),getArray (_x >> ""input""),getArray (_x >> ""disallowedWorlds"")];" \n - "} forEach (""isClass _x"" configClasses (configFile >> ""CfgEpochServerEvents""));" \n - "" \n - "_cmdDelay = EPOCH_hiveAdminCmdTime;" \n - "_cmdRun = EPOCH_hiveAdminCmdExec;" \n - "_savePlayerList = EPOCH_hiveAdminSavePlayerList;" \n - "" \n - "_scriptBasedRestart = EPOCH_ServerRestart;" \n - "_forceRestartTime = EPOCH_forceRestartTime;" \n - "_forceRestartTimeWarning = _forceRestartTime-300;" \n - "" \n - "_prevRestartIn = 0;" \n - "_serverLocked = false;" \n - "_serverRestarting = false;" \n - "_players = [];" \n - "_prevPlayers = [];" \n - "_cleanupItems = [];" \n - "_oldFPS = -1;" \n - "EPOCH_diag_fps = -1;" \n - "_serverFpsTime = diag_tickTime;" \n - "_serverFPSCheckFine = true;" \n - "" \n - "_delayTimeSim = diag_tickTime;" \n - "_delayTimeCMD = diag_tickTime;" \n - "_delayTimeDeSim = diag_tickTime;" \n - "_delayTimeSaveVeh = diag_tickTime;" \n - "_lastWeatherChange = diag_tickTime;" \n - "_lastObjectCleanup = diag_tickTime;" \n - "_lastObjectCleanup1 = diag_tickTime;" \n - "" \n - "_pvehTime = diag_tickTime;" \n - "_forcedrestartTimer = diag_tickTime;" \n - "" \n - "_instanceID = call EPOCH_fn_InstanceID;" \n - "" \n - "_checkAuth = {" \n - " params [""_puid"",""_player""];" \n - " if !(isNull _player) then {" \n - " if !(_puid call EPOCH_server_Authed) then {" \n - " private _lastCheck = _player getVariable ""LAST_AUTH_CHECK"";" \n - " if (isNil ""_lastCheck"") then {" \n - " _player setVariable[""LAST_AUTH_CHECK"", diag_tickTime];" \n - " _lastCheck = diag_tickTime;" \n - " };" \n - " if (diag_tickTime - _lastCheck > _initTimeLimit) then {" \n - " _player setVariable[""LAST_AUTH_CHECK"", nil];" \n - " if (_initAhInitBanOrLog == 0) then {" \n - " 'epochserver' callExtension format['820|%1|EpochMod.com Autoban #R2', _puid];" \n - " ['ahb', format['%1 (%2): Player not Authenticated', name _player, _puid]] call EPOCH_fnc_server_hiveLog;" \n - " } else {" \n - " ['ahl', format['%1 (%2): Player not Authenticated', name _player, _puid]] call EPOCH_fnc_server_hiveLog;" \n - " };" \n - " };" \n - " } else {" \n - " _player setVariable[""LAST_AUTH_CHECK"", nil];" \n - " };" \n - " };" \n - "};" \n - "" \n - "_cleanIt = {" \n - " if !(isNull _this) then {" \n - " private _lastCheck = _this getVariable ""LAST_CHECK"";" \n - " if (isNil ""_lastCheck"") then {" \n - " _this setVariable[""LAST_CHECK"", diag_tickTime];" \n - " _lastCheck = diag_tickTime;" \n - " };" \n - " if (diag_tickTime - _lastCheck > 1200) then {" \n - " private _list = (_this nearEntities [[""Epoch_Male_F"",""Epoch_Female_F"",""LandVehicle"",""Ship"",""Air"",""Tank""], 45]) select {isPlayer _x};" \n - " if (_list isEqualTo []) then {" \n - " _this setVariable [""LAST_CHECK"",nil];" \n - " //diag_log format[""DEBUG: _cleanIT del %1"", _this];" \n - " deleteVehicle _this;" \n - " };" \n - " };" \n - " };" \n - "};" \n - "" \n - "_cleanIt2 = {" \n - " if !(isNull _this) then {" \n - " private _removed = false;" \n - " private _lastCheck = _this getVariable ""LAST_CHECK"";" \n - " if (isNil ""_lastCheck"") then {" \n - " _this setVariable[""LAST_CHECK"", diag_tickTime];" \n - " _lastCheck = diag_tickTime;" \n - " };" \n - " if (diag_tickTime - _lastCheck > 1200) then {" \n - " private _list = (_this nearEntities [[""Epoch_Male_F"",""Epoch_Female_F"",""LandVehicle"",""Ship"",""Air"",""Tank""], 45]) select {isPlayer _x};" \n - " if (_list isEqualTo []) then {" \n - " {" \n - " deleteVehicle _x;" \n - " }forEach nearestObjects[_this, [""WeaponHolder""], 2];" \n - " _this setVariable [""LAST_CHECK"",nil];" \n - " //diag_log format[""DEBUG: _cleanIT2 del %1"", _this];" \n - " deleteVehicle _this;" \n - " _removed = true;" \n - " };" \n - " };" \n - " if !(_removed) then {" \n - " EPOCH_cleanupQueue pushBack _this;" \n - " };" \n - " };" \n - "};" \n - ""/*%FSM*/; - precondition = /*%FSM*/""/*%FSM*/; - class Links - { - /*%FSM*/ - class _ + fsmName = "Server Monitor"; + class States { - priority = 0.000000; - to="Process"; - precondition = /*%FSM*/""/*%FSM*/; - condition=/*%FSM*/"true"/*%FSM*/; - action=/*%FSM*/""/*%FSM*/; + /*%FSM*/ + class Init + { + name = "Init"; + itemno = 0; + init = /*%FSM*/"diag_log ""Loaded Server FSM"";" \n + "" \n + "_cfgSecConf = (configFile >> ""CfgSecConf"");" \n + "_cfgSecConf_vehicles = (_cfgSecConf >> ""vehicles"");" \n + "_safeVehicles = [_cfgSecConf_vehicles, ""safeVehicles"", [""I_UAV_01_F"",""B_Heli_Transport_01_F"",""Steerable_Parachute_F"",""NonSteerable_Parachute_F"",""Land_Camping_Light_F"",""container_epoch""]] call EPOCH_fnc_returnConfigEntry;" \n + "" \n + "_serverSettingsConfig = configFile >> ""CfgEpochServer"";" \n + "_ahInitAuthCfg = [_serverSettingsConfig, ""antihack_ahInitAuthCfg"", [0,180]] call EPOCH_fnc_returnConfigEntry;" \n + "_events = [_serverSettingsConfig, ""events"", []] call EPOCH_fnc_returnConfigEntry;" \n + "_events2Check = [];" \n + "" \n + "_initAhInitBanOrLog = _ahInitAuthCfg select 0;" \n + "_initTimeLimit = _ahInitAuthCfg select 1;" \n + "" \n + "// Load Epoch Events 3.0" \n + "{" \n + " diag_log format[""Loading Settings for %1 event..."",configName _x];" \n + " _events pushBack [getNumber (_x >> ""delay""),getText (_x >> ""script""),getNumber (_x >> ""runOnStart""),getNumber (_x >> ""usePrefix""),getNumber (_x >> ""runNumTimes""),getArray (_x >> ""input""),getArray (_x >> ""disallowedWorlds"")];" \n + "} forEach (""isClass _x"" configClasses (configFile >> ""CfgEpochServerEvents""));" \n + "" \n + "_cmdDelay = EPOCH_hiveAdminCmdTime;" \n + "_cmdRun = EPOCH_hiveAdminCmdExec;" \n + "_savePlayerList = EPOCH_hiveAdminSavePlayerList;" \n + "" \n + "_scriptBasedRestart = EPOCH_ServerRestart;" \n + "_forceRestartTime = EPOCH_forceRestartTime;" \n + "_forceRestartTimeWarning = _forceRestartTime-300;" \n + "" \n + "_prevRestartIn = 0;" \n + "_serverLocked = false;" \n + "_serverRestarting = false;" \n + "_players = [];" \n + "_prevPlayers = [];" \n + "_cleanupItems = [];" \n + "_oldFPS = -1;" \n + "EPOCH_diag_fps = -1;" \n + "_serverFpsTime = diag_tickTime;" \n + "_serverFPSCheckFine = true;" \n + "" \n + "_delayTimeSim = diag_tickTime;" \n + "_delayTimeCMD = diag_tickTime;" \n + "_delayTimeDeSim = diag_tickTime;" \n + "_delayTimeSaveVeh = diag_tickTime;" \n + "_lastWeatherChange = diag_tickTime;" \n + "_lastObjectCleanup = diag_tickTime;" \n + "_lastObjectCleanup1 = diag_tickTime;" \n + "" \n + "_pvehTime = diag_tickTime;" \n + "_forcedrestartTimer = diag_tickTime;" \n + "_pvemTime = diag_tickTime;" \n + "" \n + "_instanceID = call EPOCH_fn_InstanceID;" \n + "" \n + "_checkAuth = {" \n + " params [""_puid"",""_player""];" \n + " if !(isNull _player) then {" \n + " if !(_puid call EPOCH_server_Authed) then {" \n + " private _lastCheck = _player getVariable ""LAST_AUTH_CHECK"";" \n + " if (isNil ""_lastCheck"") then {" \n + " _player setVariable[""LAST_AUTH_CHECK"", diag_tickTime];" \n + " _lastCheck = diag_tickTime;" \n + " };" \n + " if (diag_tickTime - _lastCheck > _initTimeLimit) then {" \n + " _player setVariable[""LAST_AUTH_CHECK"", nil];" \n + " if (_initAhInitBanOrLog == 0) then {" \n + " 'epochserver' callExtension format['820|%1|EpochMod.com Autoban #R2', _puid];" \n + " ['ahb', format['%1 (%2): Player not Authenticated', name _player, _puid]] call EPOCH_fnc_server_hiveLog;" \n + " } else {" \n + " ['ahl', format['%1 (%2): Player not Authenticated', name _player, _puid]] call EPOCH_fnc_server_hiveLog;" \n + " };" \n + " };" \n + " } else {" \n + " _player setVariable[""LAST_AUTH_CHECK"", nil];" \n + " };" \n + " };" \n + "};" \n + "" \n + "_cleanIt = {" \n + " if !(isNull _this) then {" \n + " private _lastCheck = _this getVariable ""LAST_CHECK"";" \n + " if (isNil ""_lastCheck"") then {" \n + " _this setVariable[""LAST_CHECK"", diag_tickTime];" \n + " _lastCheck = diag_tickTime;" \n + " };" \n + " if (diag_tickTime - _lastCheck > 1200) then {" \n + " private _list = (_this nearEntities [[""Epoch_Male_F"",""Epoch_Female_F"",""LandVehicle"",""Ship"",""Air"",""Tank""], 45]) select {isPlayer _x};" \n + " if (_list isEqualTo []) then {" \n + " _this setVariable [""LAST_CHECK"",nil];" \n + " //diag_log format[""DEBUG: _cleanIT del %1"", _this];" \n + " deleteVehicle _this;" \n + " };" \n + " };" \n + " };" \n + "};" \n + "" \n + "_cleanIt2 = {" \n + " if !(isNull _this) then {" \n + " private _removed = false;" \n + " private _lastCheck = _this getVariable ""LAST_CHECK"";" \n + " if (isNil ""_lastCheck"") then {" \n + " _this setVariable[""LAST_CHECK"", diag_tickTime];" \n + " _lastCheck = diag_tickTime;" \n + " };" \n + " if (diag_tickTime - _lastCheck > 1200) then {" \n + " private _list = (_this nearEntities [[""Epoch_Male_F"",""Epoch_Female_F"",""LandVehicle"",""Ship"",""Air"",""Tank""], 45]) select {isPlayer _x};" \n + " if (_list isEqualTo []) then {" \n + " {" \n + " deleteVehicle _x;" \n + " }forEach nearestObjects[_this, [""WeaponHolder""], 2];" \n + " _this setVariable [""LAST_CHECK"",nil];" \n + " //diag_log format[""DEBUG: _cleanIT2 del %1"", _this];" \n + " deleteVehicle _this;" \n + " _removed = true;" \n + " };" \n + " };" \n + " if !(_removed) then {" \n + " EPOCH_cleanupQueue pushBack _this;" \n + " };" \n + " };" \n + "};" \n + ""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + itemno = 1; + priority = 0.000000; + to="Process"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"true"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Process + { + name = "Process"; + itemno = 2; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class CMD_queue + { + itemno = 4; + priority = 10.000000; + to="Process"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_cmdRun && ((diag_tickTime - _delayTimeCMD) > _cmdDelay)"/*%FSM*/; + action=/*%FSM*/"_delayTimeCMD = diag_tickTime;" \n + "" \n + "// Execute next item from CMD queue" \n + "_response = ""epochserver"" callExtension format[""600|%1"",_instanceID];" \n + "if (_response != '[1,""""]') then { " \n + " _output = call compile _response; " \n + " if (_output select 0 == 1 && _output select 1 != """") then {" \n + " 0 spawn compile (_output select 1);" \n + " };" \n + "};" \n + ""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Cleanup_Handler + { + itemno = 9; + priority = 8.000000; + to="Process"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"((diag_tickTime - _lastObjectCleanup) > 300)"/*%FSM*/; + action=/*%FSM*/"_lastObjectCleanup = diag_tickTime;" \n + "" \n + "// TODO need better way allMissionObjects is not performant" \n + "if (_cleanupItems isEqualTo []) then {" \n + " _cleanupItems = allMissionObjects ""groundWeaponHolder"" + entities ""WeaponHolderSimulated"";" \n + "};"/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Cleanup + { + itemno = 6; + priority = 8.000000; + to="Process"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"((diag_tickTime - _lastObjectCleanup1) > 1)"/*%FSM*/; + action=/*%FSM*/"_lastObjectCleanup1 = diag_tickTime;" \n + "" \n + "if !(_cleanupItems isEqualTo []) then {" \n + " (_cleanupItems deleteAt 0) call _cleanIt;" \n + "};" \n + "if !(EPOCH_cleanupQueue isEqualTo []) then {" \n + " (EPOCH_cleanupQueue deleteAt 0) call _cleanIt2;" \n + "};"/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Save_Vehicles + { + itemno = 8; + priority = 4.000000; + to="Process"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"((diag_tickTime - _delayTimeSaveVeh) > 1)"/*%FSM*/; + action=/*%FSM*/"_delayTimeSaveVeh = diag_tickTime;" \n + "if !(EPOCH_saveVehQueue isEqualTo []) then {" \n + " _saveVehicle = EPOCH_saveVehQueue deleteAt 0;" \n + " if !(isNull _saveVehicle) then {" \n + " _saveVehicle call EPOCH_server_save_vehicle;" \n + " };" \n + "};" \n + "if !(EPOCH_saveStorQueue isEqualTo []) then {" \n + " _saveStorage = EPOCH_saveStorQueue deleteAt 0;" \n + " if !(isNull _saveStorage) then {" \n + " _saveStorage call EPOCH_server_save_storage;" \n + " };" \n + "};" \n + "if !(EPOCH_saveBuildQueue isEqualTo []) then {" \n + " _saveBuilding = EPOCH_saveBuildQueue deleteAt 0;" \n + " if !(isNull _saveBuilding) then {" \n + " _saveBuilding call EPOCH_saveBuilding;" \n + " };" \n + "};"/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Save_Players + { + itemno = 5; + priority = 3.000000; + to="Process"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!(_players isEqualTo _prevPlayers)"/*%FSM*/; + action=/*%FSM*/"_prevPlayers = _players;" \n + "" \n + "if (_savePlayerList) then {" \n + " [""PLAYERS"", (call EPOCH_fn_InstanceID), _players] call EPOCH_fnc_server_hiveSET;" \n + "};" \n + "// Group cleanup" \n + "{if (units _x isEqualTo []) then {deleteGroup _x}}forEach allGroups"/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Vehicle_and_Player + { + itemno = 3; + priority = 1.000000; + to="Process"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"((diag_tickTime - _delayTimeSim) > 5)"/*%FSM*/; + action=/*%FSM*/"_delayTimeSim = diag_tickTime;" \n + "_playersTemp = [];" \n + "{" \n + " private _vehicle = vehicle _x;" \n + " // if player is inside a vehicle check vehicle is in allowed safe vehicles list." \n + " if (_vehicle != _x && {!(typeOf _vehicle in _safeVehicles)}) then {" \n + " // check if vehicle has token set server side and ignore vehicle if was spawned by a Curator (zeus)" \n + " if ((objectCurators _vehicle) isEqualTo [] && {!(_vehicle call EPOCH_server_getVToken)}) then {" \n + " diag_log format[""ADMIN: Invalid Vehicle detected and deleted %1 with %2 driving"",_vehicle,_x];" \n + " deleteVehicle _vehicle;" \n + " };" \n + " };" \n + "" \n + " private _pUID = getPlayerUID _x;" \n + " // Add all player UIDs to array for use later." \n + " if (_pUID != """") then { _playersTemp pushBack _pUID; };" \n + "" \n + " // If player is not admin check perform checks." \n + " if !(_x call EPOCH_server_isPAdmin) then {" \n + " // check if player is hidden and if so force back visable." \n + " if (isObjectHidden _x) then {" \n + " _x hideObjectGlobal false;" \n + " diag_log format[""ADMIN: Warning!!! player was hidden and forced visable %1"",_x];" \n + " };" \n + " // check player has authenticated with reverse token check." \n + " if (_pUID != """") then {" \n + " [_pUID, _x] call _checkAuth;" \n + " };" \n + " };" \n + "" \n + "}forEach allPlayers;" \n + "_players = _playersTemp;" \n + ""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Server_FPS + { + itemno = 10; + priority = 0.000000; + to="Process"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"((diag_tickTime - _serverFpsTime) > 30) && _serverFPSCheckFine"/*%FSM*/; + action=/*%FSM*/"_serverFpsTime = diag_tickTime;" \n + "" \n + "if (_oldFPS isEqualTo EPOCH_diag_fps) then {" \n + " _currentFPS = round(diag_fps);" \n + " if !(_oldFPS isEqualTo _currentFPS) then {" \n + " missionNamespace setVariable [""EPOCH_diag_fps"",_currentFPS,true];" \n + " _oldFPS = _currentFPS;" \n + " };" \n + "} else {" \n + " missionNamespace setVariable [""EPOCH_diag_fps"", compileFinal """",true];" \n + " _serverFPSCheckFine = false;" \n + "};" \n + ""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Forced_Restart + { + itemno = 11; + priority = 0.000000; + to="Process"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"((diag_tickTime - _forcedrestartTimer) > 20)"/*%FSM*/; + action=/*%FSM*/"// restart script" \n + "_forcedrestartTimer = diag_tickTime;" \n + "if (_scriptBasedRestart) then {" \n + " if (diag_tickTime >= _forceRestartTimeWarning) then {" \n + " if (!_serverLocked) then {" \n + " diag_log ""server shutdown: locked"";" \n + " _serverLocked = true;" \n + " [""lock""] call EPOCH_serverCommand;" \n + " } else {" \n + " if (allPlayers isEqualTo []) then {" \n + " [""shutdown""] call EPOCH_serverCommand;" \n + " diag_log ""server shutdown: now"";" \n + " };" \n + " };" \n + " _restartIn = round((_forceRestartTime-diag_tickTime)/60);" \n + " if (_prevRestartIn != _restartIn) then {" \n + " _prevRestartIn = _restartIn;" \n + " if (_restartIn > 1) then {" \n + " [""message"", format[""Server restart in %1 minutes"",_restartIn]] call EPOCH_serverCommand;" \n + " } else {" \n + " [""message"", format[""Server restart in %1 minute"",1]] call EPOCH_serverCommand;" \n + " };" \n + " };" \n + " };" \n + " // kick all remaining players before shutdown to force player save" \n + " if (diag_tickTime >= _forceRestartTime) then {" \n + " if (_serverRestarting) then {" \n + " [""shutdown""] call EPOCH_serverCommand;" \n + " diag_log ""server shutdown: now"";" \n + " } else {" \n + " {" \n + " [""kick"", _x , ""Server Restarting""] call EPOCH_serverCommand;" \n + " } forEach allPlayers;" \n + " _serverRestarting = true;" \n + " };" \n + " };" \n + "};" \n + ""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Events_Monitor + { + itemno = 12; + priority = 0.000000; + to="Process"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"((diag_tickTime - _pvemTime) > 5)"/*%FSM*/; + action=/*%FSM*/"// Epoch Events Monitor" \n + "_pvemTime = diag_tickTime;" \n + "_events2Check append (missionNamespace getVariable [""EPOCH_RunningEvents"", []]);" \n + "missionNamespace setVariable [""EPOCH_RunningEvents"", nil];" \n + "_newEventsArray = [];" \n + "{" \n + " _x params [""_position"", ""_objs"", ""_extraObjs"", ""_countName"", ""_timeStamp"", ""_decayTime"", ""_showMarkers"", ""_markers"", ""_originalColors"", ""_decayColor"", ""_interactedColor""];" \n + " _formatted = format[""EPOCH_%1"",_countName];" \n + " _current = missionNameSpace getVariable[_formatted,0];" \n + " // check objects" \n + " _objsLeft = [];" \n + " _nearPlayers = (count (_position nearEntities[[""Epoch_Male_F"", ""Epoch_Female_F""], 500]) > 0);" \n + " {" \n + " _isOpenLid = (_x animationPhase 'open_lid' > 0.5); " \n + " _isEPOCH_looted = (_x getVariable [""EPOCH_Loot"",false]);" \n + " _isOpenDoor = (_x animationPhase 'Door_1_rot' > 0.5);" \n + " if(!isNull _x)then{" \n + " _objsLeft pushBack _x;" \n + " };" \n + " if(!(_nearPlayers) && !(_objsLeft isEqualTo []))then{" \n + " if(((_x iskindof 'container_epoch') && {_isOpenLid || _isEPOCH_looted}) || ((_x iskindof 'Cargo_Container') && {_isOpenDoor || _isEPOCH_looted}) || (damage _x isEqualTo 1))then{" \n + " _objsLeft = _objsLeft - [_x];" \n + " };" \n + " };" \n + " }forEach _objs;" \n + " // check event" \n + " if (!(_nearPlayers) && {_objsLeft isEqualTo [] || (diag_tickTime - _timeStamp) > _decayTime}) then {" \n + " // event ends" \n + " missionNameSpace setVariable[_formatted,(_current - 1)];" \n + " if (_showMarkers) then{" \n + " [_markers] call EPOCH_server_deleteGlobalMarkerSet;" \n + " };" \n + " {deleteVehicle _x} forEach _objs;" \n + " {deleteVehicle _x} forEach _extraObjs;" \n + " }else{" \n + " // event continues" \n + " _newEventsArray pushBack _x;" \n + " // check for compromised objs or area" \n + " if (_showMarkers) then{" \n + " if((count(_objsLeft) != count(_objs)) || (count (_position nearEntities[[""Epoch_Male_F"", ""Epoch_Female_F""], 150]) > 0)) then {" \n + " if !((getMarkerColor (_markers select 0)) isEqualTo _interactedColor) then {" \n + " (_markers select 0) setMarkerColor _interactedColor;" \n + " };" \n + " }else{" \n + " if ((getMarkerColor (_markers select 0)) isEqualTo _interactedColor) then {" \n + " if !((diag_tickTime - _timeStamp) > (_decayTime/2)) then {" \n + " (_markers select 0) setMarkerColor (_originalColors select 0);" \n + " }else{" \n + " (_markers select 0) setMarkerColor _decayColor;" \n + " };" \n + " };" \n + " };" \n + " // check for decay and change to configured preset decay color" \n + " if ((diag_tickTime - _timeStamp) > (_decayTime/2)) then {" \n + " if !((getMarkerColor (_markers select 2)) isEqualTo _decayColor) then {" \n + " {" \n + " _x setMarkerColor _decayColor;" \n + " }forEach _markers;" \n + " };" \n + " };" \n + " };" \n + " };" \n + "} forEach _events2Check;" \n + "// remove expired events" \n + "_events2Check = _newEventsArray;"/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Events_Manager + { + itemno = 7; + priority = 0.000000; + to="Process"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"((diag_tickTime - _pvehTime) > 1)"/*%FSM*/; + action=/*%FSM*/"// Epoch Events" \n + "_pvehTime = diag_tickTime;" \n + "_events append (missionNamespace getVariable [""EPOCH_dynamicEvents"", []]);" \n + "missionNamespace setVariable [""EPOCH_dynamicEvents"", nil];" \n + "_newEvents = [];" \n + "{" \n + " _x params [""_time"", ""_scriptName"", [""_runAtStart"",0], [""_usePrePostfix"",1], [""_runNumTimes"",-1], [""_input"",[]], [""_disallowedWorlds"",[]] ];" \n + " _scriptParams = [];" \n + " _scriptcmdMode = ""execVM"";" \n + " if (_scriptName isEqualType []) then {" \n + " _scriptParams = _scriptName param [0,[]];" \n + " _scriptcmdMode = _scriptName param [1,""call""];" \n + " _scriptName = _scriptName param [2,""""];" \n + " };" \n + " _eventKey = format[""EPOCH_EVENT_%1"", _scriptName];" \n + " _eventCounter = format[""EPOCH_EVENT_COUNTER_%1"", _scriptName];" \n + " _lastTime = missionNamespace getVariable _eventKey;" \n + " _counter = missionNamespace getVariable [_eventCounter,0];" \n + " if (isNil ""_lastTime"") then {" \n + " _startTime = diag_tickTime;" \n + " if (_runAtStart isEqualTo 1) then {" \n + " _startTime = diag_tickTime - _time;" \n + " };" \n + " missionNamespace setVariable[_eventKey, _startTime];" \n + " _lastTime = _startTime;" \n + " };" \n + " if ((_counter >= _runNumTimes && _runNumTimes != -1) || worldName in _disallowedWorlds) then {" \n + " diag_log format[""DEBUG: server event removed %1"", _scriptName];" \n + " missionNamespace setVariable[_eventKey, nil];" \n + " missionNamespace setVariable[_eventCounter, nil];" \n + " } else {" \n + " _newEvents pushBack _x;" \n + " if ((diag_tickTime - _lastTime) >= _time) then {" \n + " missionNamespace setVariable[_eventKey, diag_tickTime];" \n + " _preFix = """";" \n + " _postFix = """";" \n + " if (_usePrePostfix == 1) then {" \n + " _preFix = ""\epoch_server_settings\EpochEvents\"";" \n + " _postFix = "".sqf"";" \n + " };" \n + " if (_usePrePostfix == 2) then {" \n + " _preFix = ""\epoch_server_events\EpochEvents\"";" \n + " _postFix = "".sqf"";" \n + " };" \n + " switch (_scriptcmdMode) do {" \n + " case (""call""): {" \n + " // call" \n + " _scriptParams call (missionNamespace getVariable [_scriptName, {}]);" \n + " };" \n + " case (""spawn""): {" \n + " // spawn" \n + " _scriptParams spawn (missionNamespace getVariable [_scriptName, {}]);" \n + " };" \n + " default {" \n + " // execVM" \n + " _handle = _input execVM format[""%1%2%3"",_preFix,_scriptName,_postFix];" \n + " };" \n + " };" \n + " _counter = _counter + 1;" \n + " missionNamespace setVariable[_eventCounter, _counter];" \n + " diag_log format[""DEBUG: server event %1"", _scriptName];" \n + " };" \n + " };" \n + "} forEach _events;" \n + "// remove expired events" \n + "_events = _newEvents;"/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ }; - /*%FSM*/ - }; - }; - /*%FSM*/ - /*%FSM*/ - class Process - { - name = "Process"; - init = /*%FSM*/""/*%FSM*/; - precondition = /*%FSM*/""/*%FSM*/; - class Links - { - /*%FSM*/ - class CMD_queue + initState="Init"; + finalStates[] = { - priority = 10.000000; - to="Process"; - precondition = /*%FSM*/""/*%FSM*/; - condition=/*%FSM*/"_cmdRun && ((diag_tickTime - _delayTimeCMD) > _cmdDelay)"/*%FSM*/; - action=/*%FSM*/"_delayTimeCMD = diag_tickTime;" \n - "" \n - "// Execute next item from CMD queue" \n - "_response = ""epochserver"" callExtension format[""600|%1"",_instanceID];" \n - "if (_response != '[1,""""]') then { " \n - " _output = call compile _response; " \n - " if (_output select 0 == 1 && _output select 1 != """") then {" \n - " 0 spawn compile (_output select 1);" \n - " };" \n - "};" \n - ""/*%FSM*/; }; - /*%FSM*/ - /*%FSM*/ - class Cleanup - { - priority = 8.000000; - to="Process"; - precondition = /*%FSM*/""/*%FSM*/; - condition=/*%FSM*/"((diag_tickTime - _lastObjectCleanup1) > 1)"/*%FSM*/; - action=/*%FSM*/"_lastObjectCleanup1 = diag_tickTime;" \n - "" \n - "if !(_cleanupItems isEqualTo []) then {" \n - " (_cleanupItems deleteAt 0) call _cleanIt;" \n - "};" \n - "if !(EPOCH_cleanupQueue isEqualTo []) then {" \n - " (EPOCH_cleanupQueue deleteAt 0) call _cleanIt2;" \n - "};"/*%FSM*/; - }; - /*%FSM*/ - /*%FSM*/ - class Cleanup_Handler - { - priority = 8.000000; - to="Process"; - precondition = /*%FSM*/""/*%FSM*/; - condition=/*%FSM*/"((diag_tickTime - _lastObjectCleanup) > 300)"/*%FSM*/; - action=/*%FSM*/"_lastObjectCleanup = diag_tickTime;" \n - "" \n - "// TODO need better way allMissionObjects is not performant" \n - "if (_cleanupItems isEqualTo []) then {" \n - " _cleanupItems = allMissionObjects ""groundWeaponHolder"" + entities ""WeaponHolderSimulated"";" \n - "};"/*%FSM*/; - }; - /*%FSM*/ - /*%FSM*/ - class Save_Vehicles - { - priority = 4.000000; - to="Process"; - precondition = /*%FSM*/""/*%FSM*/; - condition=/*%FSM*/"((diag_tickTime - _delayTimeSaveVeh) > 1)"/*%FSM*/; - action=/*%FSM*/"_delayTimeSaveVeh = diag_tickTime;" \n - "if !(EPOCH_saveVehQueue isEqualTo []) then {" \n - " _saveVehicle = EPOCH_saveVehQueue deleteAt 0;" \n - " if !(isNull _saveVehicle) then {" \n - " _saveVehicle call EPOCH_server_save_vehicle;" \n - " };" \n - "};" \n - "if !(EPOCH_saveStorQueue isEqualTo []) then {" \n - " _saveStorage = EPOCH_saveStorQueue deleteAt 0;" \n - " if !(isNull _saveStorage) then {" \n - " _saveStorage call EPOCH_server_save_storage;" \n - " };" \n - "};" \n - "if !(EPOCH_saveBuildQueue isEqualTo []) then {" \n - " _saveBuilding = EPOCH_saveBuildQueue deleteAt 0;" \n - " if !(isNull _saveBuilding) then {" \n - " _saveBuilding call EPOCH_saveBuilding;" \n - " };" \n - "};"/*%FSM*/; - }; - /*%FSM*/ - /*%FSM*/ - class Save_Players - { - priority = 3.000000; - to="Process"; - precondition = /*%FSM*/""/*%FSM*/; - condition=/*%FSM*/"!(_players isEqualTo _prevPlayers)"/*%FSM*/; - action=/*%FSM*/"_prevPlayers = _players;" \n - "" \n - "if (_savePlayerList) then {" \n - " [""PLAYERS"", (call EPOCH_fn_InstanceID), _players] call EPOCH_fnc_server_hiveSET;" \n - "};" \n - "// Group cleanup" \n - "{if (units _x isEqualTo []) then {deleteGroup _x}}forEach allGroups"/*%FSM*/; - }; - /*%FSM*/ - /*%FSM*/ - class Vehicle_and_Player - { - priority = 1.000000; - to="Process"; - precondition = /*%FSM*/""/*%FSM*/; - condition=/*%FSM*/"((diag_tickTime - _delayTimeSim) > 5)"/*%FSM*/; - action=/*%FSM*/"_delayTimeSim = diag_tickTime;" \n - "_playersTemp = [];" \n - "{" \n - " private _vehicle = vehicle _x;" \n - " // if player is inside a vehicle check vehicle is in allowed safe vehicles list." \n - " if (_vehicle != _x && {!(typeOf _vehicle in _safeVehicles)}) then {" \n - " // check if vehicle has token set server side and ignore vehicle if was spawned by a Curator (zeus)" \n - " if ((objectCurators _vehicle) isEqualTo [] && {!(_vehicle call EPOCH_server_getVToken)}) then {" \n - " diag_log format[""ADMIN: Invalid Vehicle detected and deleted %1 with %2 driving"",_vehicle,_x];" \n - " deleteVehicle _vehicle;" \n - " };" \n - " };" \n - "" \n - " private _pUID = getPlayerUID _x;" \n - " // Add all player UIDs to array for use later." \n - " if (_pUID != """") then { _playersTemp pushBack _pUID; };" \n - "" \n - " // If player is not admin check perform checks." \n - " if !(_x call EPOCH_server_isPAdmin) then {" \n - " // check if player is hidden and if so force back visable." \n - " if (isObjectHidden _x) then {" \n - " _x hideObjectGlobal false;" \n - " diag_log format[""ADMIN: Warning!!! player was hidden and forced visable %1"",_x];" \n - " };" \n - " // check player has authenticated with reverse token check." \n - " if (_pUID != """") then {" \n - " [_pUID, _x] call _checkAuth;" \n - " };" \n - " };" \n - "" \n - "}forEach allPlayers;" \n - "_players = _playersTemp;" \n - ""/*%FSM*/; - }; - /*%FSM*/ - /*%FSM*/ - class Events_Manager - { - priority = 0.000000; - to="Process"; - precondition = /*%FSM*/""/*%FSM*/; - condition=/*%FSM*/"((diag_tickTime - _pvehTime) > 1)"/*%FSM*/; - action=/*%FSM*/"// Epoch Events" \n - "_pvehTime = diag_tickTime;" \n - "_events append (missionNamespace getVariable [""EPOCH_dynamicEvents"", []]);" \n - "missionNamespace setVariable [""EPOCH_dynamicEvents"", nil];" \n - "_newEvents = [];" \n - "{" \n - " _x params [""_time"", ""_scriptName"", [""_runAtStart"",0], [""_usePrePostfix"",1], [""_runNumTimes"",-1], [""_input"",[]], [""_disallowedWorlds"",[]] ];" \n - " _scriptParams = [];" \n - " _scriptcmdMode = ""execVM"";" \n - " if (_scriptName isEqualType []) then {" \n - " _scriptParams = _scriptName param [0,[]];" \n - " _scriptcmdMode = _scriptName param [1,""call""];" \n - " _scriptName = _scriptName param [2,""""];" \n - " };" \n - " _eventKey = format[""EPOCH_EVENT_%1"", _scriptName];" \n - " _eventCounter = format[""EPOCH_EVENT_COUNTER_%1"", _scriptName];" \n - " _lastTime = missionNamespace getVariable _eventKey;" \n - " _counter = missionNamespace getVariable [_eventCounter,0];" \n - " if (isNil ""_lastTime"") then {" \n - " _startTime = diag_tickTime;" \n - " if (_runAtStart isEqualTo 1) then {" \n - " _startTime = diag_tickTime - _time;" \n - " };" \n - " missionNamespace setVariable[_eventKey, _startTime];" \n - " _lastTime = _startTime;" \n - " };" \n - " if ((_counter >= _runNumTimes && _runNumTimes != -1) || worldName in _disallowedWorlds) then {" \n - " diag_log format[""DEBUG: server event removed %1"", _scriptName];" \n - " missionNamespace setVariable[_eventKey, nil];" \n - " missionNamespace setVariable[_eventCounter, nil];" \n - " } else {" \n - " _newEvents pushBack _x;" \n - " if ((diag_tickTime - _lastTime) >= _time) then {" \n - " missionNamespace setVariable[_eventKey, diag_tickTime];" \n - " _preFix = """";" \n - " _postFix = """";" \n - " if (_usePrePostfix == 1) then {" \n - " _preFix = ""\epoch_server_settings\EpochEvents\"";" \n - " _postFix = "".sqf"";" \n - " };" \n - " if (_usePrePostfix == 2) then {" \n - " _preFix = ""\epoch_server_events\EpochEvents\"";" \n - " _postFix = "".sqf"";" \n - " };" \n - " switch (_scriptcmdMode) do {" \n - " case (""call""): {" \n - " // call" \n - " _scriptParams call (missionNamespace getVariable [_scriptName, {}]);" \n - " };" \n - " case (""spawn""): {" \n - " // spawn" \n - " _scriptParams spawn (missionNamespace getVariable [_scriptName, {}]);" \n - " };" \n - " default {" \n - " // execVM" \n - " _handle = _input execVM format[""%1%2%3"",_preFix,_scriptName,_postFix];" \n - " };" \n - " };" \n - " _counter = _counter + 1;" \n - " missionNamespace setVariable[_eventCounter, _counter];" \n - " diag_log format[""DEBUG: server event %1"", _scriptName];" \n - " };" \n - " };" \n - "} forEach _events;" \n - "// remove expired events" \n - "_events = _newEvents;"/*%FSM*/; - }; - /*%FSM*/ - /*%FSM*/ - class Server_FPS - { - priority = 0.000000; - to="Process"; - precondition = /*%FSM*/""/*%FSM*/; - condition=/*%FSM*/"((diag_tickTime - _serverFpsTime) > 30) && _serverFPSCheckFine"/*%FSM*/; - action=/*%FSM*/"_serverFpsTime = diag_tickTime;" \n - "" \n - "if (_oldFPS isEqualTo EPOCH_diag_fps) then {" \n - " _currentFPS = round(diag_fps);" \n - " if !(_oldFPS isEqualTo _currentFPS) then {" \n - " missionNamespace setVariable [""EPOCH_diag_fps"",_currentFPS,true];" \n - " _oldFPS = _currentFPS;" \n - " };" \n - "} else {" \n - " missionNamespace setVariable [""EPOCH_diag_fps"", compileFinal """",true];" \n - " _serverFPSCheckFine = false;" \n - "};" \n - ""/*%FSM*/; - }; - /*%FSM*/ - /*%FSM*/ - class Forced_Restart - { - priority = 0.000000; - to="Process"; - precondition = /*%FSM*/""/*%FSM*/; - condition=/*%FSM*/"((diag_tickTime - _forcedrestartTimer) > 20)"/*%FSM*/; - action=/*%FSM*/"// restart script" \n - "_forcedrestartTimer = diag_tickTime;" \n - "if (_scriptBasedRestart) then {" \n - " if (diag_tickTime >= _forceRestartTimeWarning) then {" \n - " if (!_serverLocked) then {" \n - " diag_log ""server shutdown: locked"";" \n - " _serverLocked = true;" \n - " [""lock""] call EPOCH_serverCommand;" \n - " } else {" \n - " if (allPlayers isEqualTo []) then {" \n - " [""shutdown""] call EPOCH_serverCommand;" \n - " diag_log ""server shutdown: now"";" \n - " };" \n - " };" \n - " _restartIn = round((_forceRestartTime-diag_tickTime)/60);" \n - " if (_prevRestartIn != _restartIn) then {" \n - " _prevRestartIn = _restartIn;" \n - " if (_restartIn > 1) then {" \n - " [""message"", format[""Server restart in %1 minutes"",_restartIn]] call EPOCH_serverCommand;" \n - " } else {" \n - " [""message"", format[""Server restart in %1 minute"",1]] call EPOCH_serverCommand;" \n - " };" \n - " };" \n - " };" \n - " // kick all remaining players before shutdown to force player save" \n - " if (diag_tickTime >= _forceRestartTime) then {" \n - " if (_serverRestarting) then {" \n - " [""shutdown""] call EPOCH_serverCommand;" \n - " diag_log ""server shutdown: now"";" \n - " } else {" \n - " {" \n - " [""kick"", _x , ""Server Restarting""] call EPOCH_serverCommand;" \n - " } forEach allPlayers;" \n - " _serverRestarting = true;" \n - " };" \n - " };" \n - "};" \n - ""/*%FSM*/; - }; - /*%FSM*/ - }; - }; - /*%FSM*/ - }; - initState="Init"; - finalStates[] = - { - }; }; /*%FSM*/ \ No newline at end of file diff --git a/Sources/epoch_server_settings/EpochEvents/CarnivalSpawner.sqf b/Sources/epoch_server_settings/EpochEvents/CarnivalSpawner.sqf index b4def8fc..8974ec15 100644 --- a/Sources/epoch_server_settings/EpochEvents/CarnivalSpawner.sqf +++ b/Sources/epoch_server_settings/EpochEvents/CarnivalSpawner.sqf @@ -6,18 +6,89 @@ https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server_settings/EpochEvents/CarnivalSpawner.sqf */ //[[[cog import generate_private_arrays ]]] -private ["_ferrisPosition","_item","_markers"]; +private ["_cfgEpoch", "_debug", "_showMarkers", "_limit", "_counter", "_decayTime", "_distFromOthers", "_others", "_position", "_goodPos", "_objs","_item", "_lootPos", "_lootPos", "_loot", "_debugMkr", "_markers", "_originalColors", "_decayMarkerColor", "_compromisedColor", "_rEvents", "_thisEvent"]; //[[[end]]] -_ferrisPosition = [epoch_centerMarkerPosition, 0, EPOCH_dynamicVehicleArea, 10, 0, 4000, 0] call BIS_fnc_findSafePos; -if ((count _ferrisPosition) == 2) then{ - _item = createVehicle["ferrisWheel_EPOCH", _ferrisPosition, [], 0.0, "CAN_COLLIDE"]; +_cfgEpoch = configFile >> "CfgEpoch" >> worldname; +_debug = if(getNumber(_cfgEpoch >> "debugCarnivalSpawner") isEqualTo 1)then{true}else{false}; +_limit = getNumber(_cfgEpoch >> "maxCarnivalSpawns"); +_counter = missionNameSpace getVariable["EPOCH_carnivalCounter",0]; +_others = missionNameSpace getVariable["EPOCH_carnivals", [[0,0,0]] ]; +_distFromOthers = getNumber(_cfgEpoch >> "distFromOtherCarnivals"); - { - _item = createVehicle[_x, _ferrisPosition, [], 80, "NONE"]; - sleep 1; - } forEach["Carnival_Tent", "Land_Slide_F", "Carnival_Tent", "Land_Carousel_01_F", "Carnival_Tent", "Carnival_Tent"]; +//STOP THE SCRIPT AND EXIT IF THE COUNTER IS TOO HIGH. +if (_counter >= _limit) exitWith { + if (_debug) then {diag_log "DEBUG: suppressed carnival spawn over limit"}; +}; - if (EPOCH_showShippingContainers) then{ - _markers = ["Carnival",_ferrisPosition] call EPOCH_server_createGlobalMarkerSet; +for "_i" from 0 to 100 step 1 do { + _position = [epoch_centerMarkerPosition, 0, EPOCH_dynamicVehicleArea, 10, 0, 1000, 0] call BIS_fnc_findSafePos; + _goodPos = true; + + _goodPos = [_position, true, true, true, _others, _distFromOthers] call EPOCH_server_isNearChecks; + + if(_goodPos)then{ + _i = 100; + }else{ + _position = []; + }; +}; + +_objs = []; +if ((count _position) == 2) then{ + // CREATE THE CARNIVAL AREA AND LOOT + _item = createVehicle["ferrisWheel_EPOCH", _position, [], 0.0, "CAN_COLLIDE"]; + _objs pushBack _item; + _lootPos = [_position,1,20,3,1,20,0] call BIS_fnc_findSafePos; + _loot = createVehicle["container_epoch", _lootPos, [], 0.0, "CAN_COLLIDE"]; + _loot setMass 220; + _loot setVariable["EPOCH_Loot",false,true]; + + if(_debug)then{ + _debugMkr = createMarker [str(_lootPos),_lootPos]; + _debugMkr setMarkerShape "ICON"; + _debugMkr setMarkerType "mil_dot"; + _debugMkr setMarkerColor "ColorRed"; + }; + + { + _item = createVehicle[_x, _position, [], 80, "NONE"]; + _objs pushBack _item; + sleep 1; + } forEach (getArray(_cfgEpoch >> "carnivalSpawnedObjects")); + + // SET UP THE MARKER. + _markers = []; + _originalColors = []; + _showMarkers = if(getNumber(_cfgEpoch >> "showCarnivalMarkers") isEqualTo 1)then{true}else{false}; + _decayMarkerColor = getText(_cfgEpoch >> "carnivalDecayMarkerColor"); + _compromisedColor = getText(_cfgEpoch >> "carnivalCompromisedColor"); + if (_showMarkers) then{ + _markers = ["Carnival",_position] call EPOCH_server_createGlobalMarkerSet; + { + _originalColors pushBack (getMarkerColor _x); + }forEach _markers; + + // Check for HeightenedPlayerVsPlayer false and remove comprimised coloring + if!(getNumber(_cfgEpoch >> "HeightenedPlayerVsPlayer") isEqualTo 1)then{ + _compromisedColor = getMarkerColor (_markers select 0); + }; + }; + + // TICK COUNTER + 1 SPAWNED PLANT PATCH. + _counter = _counter + 1; + missionNameSpace setVariable["EPOCH_carnivalCounter",_counter]; + + // ADD POSITION TO OTHERS ARRAY + missionNameSpace setVariable["EPOCH_carnivals", _others + [_position]]; + + // SEND EVENT TO MONITOR + _decayTime = getNumber(_cfgEpoch >> "carnivalDecayTime"); + _serverSettingsConfig = configFile >> "CfgEpochServer"; + _timeMultiplier = ([_serverSettingsConfig, "timeMultiplier", 1] call EPOCH_fnc_returnConfigEntry); + _rEvents = missionNameSpace getVariable["EPOCH_RunningEvents",[]]; + _thisEvent = [_lootPos, [_loot], _objs,"carnivalCounter", diag_tickTime, (_decayTime * _timeMultiplier), _showMarkers, _markers, _originalColors, _decayMarkerColor, _compromisedColor]; + missionNameSpace setVariable["EPOCH_RunningEvents",_rEvents + [_thisEvent]]; + if (_debug) then { + diag_log format["EPOCHDebug: carnivalSpawner-%1", missionNameSpace getVariable["EPOCH_RunningEvents",[]]]; }; }; diff --git a/Sources/epoch_server_settings/EpochEvents/ContainerSpawner.sqf b/Sources/epoch_server_settings/EpochEvents/ContainerSpawner.sqf index 18286054..ee23767c 100644 --- a/Sources/epoch_server_settings/EpochEvents/ContainerSpawner.sqf +++ b/Sources/epoch_server_settings/EpochEvents/ContainerSpawner.sqf @@ -6,12 +6,78 @@ https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server_settings/EpochEvents/ContainterSpawner.sqf */ //[[[cog import generate_private_arrays ]]] -private ["_cargoPosition","_item","_markers"]; +private ["_position","_item","_markers"]; //[[[end]]] -_cargoPosition = [epoch_centerMarkerPosition, 0, EPOCH_dynamicVehicleArea, 10, 0, 4000, 1] call BIS_fnc_findSafePos; -if ((count _cargoPosition) == 2) then{ - _item = createVehicle["Cargo_Container", _cargoPosition, [], 0.0, "CAN_COLLIDE"]; - if (EPOCH_showShippingContainers) then{ - _markers = ["Container",_cargoPosition] call EPOCH_server_createGlobalMarkerSet; +_cfgEpoch = configFile >> "CfgEpoch" >> worldname; +_debug = if(getNumber(_cfgEpoch >> "debugContainerSpawner") isEqualTo 1)then{true}else{false}; +_limit = getNumber(_cfgEpoch >> "maxContainerSpawns"); +_counter = missionNameSpace getVariable["EPOCH_containerCounter",0]; +_others = missionNameSpace getVariable["EPOCH_containers", [[0,0,0]] ]; +_distFromOthers = getNumber(_cfgEpoch >> "distFromOtherContainers"); + +//STOP THE SCRIPT AND EXIT IF THE COUNTER IS TOO HIGH. +if (_counter >= _limit) exitWith { + if (_debug) then {diag_log "DEBUG: suppressed CONTAINER spawn over limit"}; +}; + +// FIND A POSITION +for "_i" from 0 to 100 step 1 do { + _position = [epoch_centerMarkerPosition, 0, EPOCH_dynamicVehicleArea, 10, 0, 4000, 1] call BIS_fnc_findSafePos; + _goodPos = true; + + _goodPos = [_position, true, true, true, _others, _distFromOthers] call EPOCH_server_isNearChecks; + + if(_goodPos)then{ + _i = 100; + }else{ + _position = []; }; }; + +if ((count _position) == 2) then{ + // CREATE THE CARGO CONTAINER + _item = createVehicle["Cargo_Container", _position, [], 0.0, "CAN_COLLIDE"]; + if(_debug)then{ + _debugMkr = createMarker [str(_position), _position]; + _debugMkr setMarkerShape "ICON"; + _debugMkr setMarkerType "mil_dot"; + _debugMkr setMarkerColor "ColorRed"; + }; + + // SET UP THE MARKER. + _markers = []; + _originalColors = []; + _showMarkers = if(getNumber(_cfgEpoch >> "showContainerMarkers") isEqualTo 1)then{true}else{false}; + _decayMarkerColor = getText(_cfgEpoch >> "containerDecayMarkerColor"); + _compromisedColor = getText(_cfgEpoch >> "containerCompromisedColor"); + if (_showMarkers) then{ + _markers = ["Container",_position] call EPOCH_server_createGlobalMarkerSet; + { + _originalColors pushBack (getMarkerColor _x); + }forEach _markers; + + // Check for HeightenedPlayerVsPlayer false and remove comprimised coloring + if!(getNumber(_cfgEpoch >> "HeightenedPlayerVsPlayer") isEqualTo 1)then{ + _compromisedColor = getMarkerColor (_markers select 0); + }; + }; + + // TICK COUNTER + 1 + _counter = _counter + 1; + missionNameSpace setVariable["EPOCH_containerCounter",_counter]; + + // ADD POSITION TO OTHERS ARRAY + missionNameSpace setVariable["EPOCH_containers", _others + [_position]]; + + // SEND EVENT TO MONITOR + _decayTime = getNumber(_cfgEpoch >> "containerDecayTime"); + _serverSettingsConfig = configFile >> "CfgEpochServer"; + _timeMultiplier = ([_serverSettingsConfig, "timeMultiplier", 1] call EPOCH_fnc_returnConfigEntry); + _rEvents = missionNameSpace getVariable["EPOCH_RunningEvents",[]]; + _thisEvent = [_position, [_item], [], "containerCounter", diag_tickTime, (_decayTime * _timeMultiplier), _showMarkers, _markers, _originalColors, _decayMarkerColor, _compromisedColor]; + missionNameSpace setVariable["EPOCH_RunningEvents",_rEvents + [_thisEvent]]; + if (_debug) then { + diag_log format["EPOCHDebug: containerSpawner-%1", missionNameSpace getVariable["EPOCH_RunningEvents",[]]]; + }; +}; +// END SCRIPT. \ No newline at end of file diff --git a/Sources/epoch_server_settings/EpochEvents/EarthQuake.sqf b/Sources/epoch_server_settings/EpochEvents/EarthQuake.sqf index cef11b69..e2948fa8 100644 --- a/Sources/epoch_server_settings/EpochEvents/EarthQuake.sqf +++ b/Sources/epoch_server_settings/EpochEvents/EarthQuake.sqf @@ -1,14 +1,40 @@ /* - Earthquake and Mineral Deposit Event + Earthquake and Mineral Deposit Event by Aaron Clark - EpochMod.com - + + Events Overhaul by DirtySanchez + Improvements and or bugfixes and other contributions are welcome via the github: https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server_settings/EpochEvents/Earthquake.sqf */ //[[[cog import generate_private_arrays ]]] -private ["_chance","_item","_markers","_minerals","_playersNearEpicenter","_position"]; +private ["_cfgEpoch", "_debug", "_limit", "_counter", "_others", "_distFromOthers", "_position", "_goodPos", "_playersNearEpicenter", "_chance", "_minerals", "_item", "_debugMkr", "_markers", "_originalColors", "_showMarkers", "_decayMarkerColor", "_compromisedColor", "_spawned", "_decayTime", "_rEvents", "_thisEvent"]; //[[[end]]] -_position = [epoch_centerMarkerPosition, 0, EPOCH_dynamicVehicleArea, 10, 0, 1000, 0] call BIS_fnc_findSafePos; +_cfgEpoch = configFile >> "CfgEpoch" >> worldname; +_debug = if(getNumber(_cfgEpoch >> "debugEarthquakeSpawner") isEqualTo 1)then{true}else{false}; +_limit = getNumber(_cfgEpoch >> "maxEarthquakeSpawns"); +_counter = missionNameSpace getVariable["EPOCH_earthquakeCounter",0]; +_others = missionNameSpace getVariable["EPOCH_earthquakes", [[0,0,0]] ]; +_distFromOthers = getNumber(_cfgEpoch >> "distFromOtherEarthquakes"); + +//STOP THE SCRIPT AND EXIT IF THE COUNTER IS TOO HIGH. +if (_counter >= _limit) exitWith { + if (_debug) then {diag_log "DEBUG: suppressed EARTHQUAKE spawn over limit"}; +}; + +for "_i" from 0 to 100 step 1 do { + _position = [epoch_centerMarkerPosition, 0, EPOCH_dynamicVehicleArea, 10, 0, 1000, 0] call BIS_fnc_findSafePos; + _goodPos = true; + + _goodPos = [_position, true, true, false, _others, _distFromOthers] call EPOCH_server_isNearChecks; + + if(_goodPos)then{ + _i = 100; + }else{ + _position = []; + }; +}; + if ((count _position) == 2) then{ _playersNearEpicenter = _position nearEntities[["Epoch_Male_F", "Epoch_Female_F"], 1000]; // decrease chance with more players @@ -21,10 +47,49 @@ if ((count _position) == 2) then{ }; // Mineral veins - _minerals = ["MineralDepositCopper_EPOCH", "MineralDepositGold_EPOCH", "MineralDepositSilver_EPOCH"]; + _minerals = getArray(_cfgEpoch >> "availableMinerals"); _item = createVehicle[(selectRandom _minerals), _position, [], 0.0, "CAN_COLLIDE"]; - if (EPOCH_showEarthQuakes) then{ + if(_debug)then{ + _debugMkr = createMarker [str(_position), _position]; + _debugMkr setMarkerShape "ICON"; + _debugMkr setMarkerType "mil_dot"; + _debugMkr setMarkerColor "ColorRed"; + }; + + // Place markers and get decay, compromised and original colors + _markers = []; + _originalColors = []; + _showMarkers = if(getNumber(_cfgEpoch >> "showEarthquakeMarkers") isEqualTo 1)then{true}else{false}; + _decayMarkerColor = getText(_cfgEpoch >> "earthquakeDecayMarkerColor"); + _compromisedColor = getText(_cfgEpoch >> "earthquakeCompromisedColor"); + if (_showMarkers) then{ _markers = ["EarthQuake",_position] call EPOCH_server_createGlobalMarkerSet; + { + _originalColors pushBack (getMarkerColor _x); + }forEach _markers; + + // Check for HeightenedPlayerVsPlayer false and remove comprimised coloring + if!(getNumber(_cfgEpoch >> "HeightenedPlayerVsPlayer") isEqualTo 1)then{ + _compromisedColor = getMarkerColor (_markers select 0); + }; + }; + + // Tick Counter +1 + _counter = _counter + 1; + missionNameSpace setVariable["EPOCH_earthquakeCounter",_counter]; + + // ADD POSITION TO OTHERS ARRAY + missionNameSpace setVariable["EPOCH_earthquakes", _others + [_position]]; + + // SEND EVENT TO MONITOR + _decayTime = getNumber(_cfgEpoch >> "earthquakeDecayTime"); + _serverSettingsConfig = configFile >> "CfgEpochServer"; + _timeMultiplier = ([_serverSettingsConfig, "timeMultiplier", 1] call EPOCH_fnc_returnConfigEntry); + _rEvents = missionNameSpace getVariable["EPOCH_RunningEvents",[]]; + _thisEvent = [_position, [_item], [], "earthquakeCounter", diag_tickTime, (_decayTime * _timeMultiplier), _showMarkers, _markers, _originalColors, _decayMarkerColor, _compromisedColor]; + missionNameSpace setVariable["EPOCH_RunningEvents",_rEvents + [_thisEvent]]; + if (_debug) then { + diag_log format["EPOCHDebug: earthquakeSpawner-%1", missionNameSpace getVariable["EPOCH_RunningEvents",[]]]; }; }; }; diff --git a/Sources/epoch_server_settings/EpochEvents/PlantSpawner.sqf b/Sources/epoch_server_settings/EpochEvents/PlantSpawner.sqf index dbdbfa9c..d61051c7 100644 --- a/Sources/epoch_server_settings/EpochEvents/PlantSpawner.sqf +++ b/Sources/epoch_server_settings/EpochEvents/PlantSpawner.sqf @@ -3,6 +3,8 @@ Redbeard Actual Aaron Clark - EpochMod.com + Events Overhaul by DirtySanchez + Description: Improved Plant Spawner - Plant Patch Spawner Event spawns a random number of plants based on plant type. @@ -15,64 +17,49 @@ https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server_settings/EpochEvents/PlantSpawner.sqf */ //[[[cog import generate_private_arrays ]]] -private ["_debug","_decayTime","_jammers","_markers","_nearbyLocations","_plant","_plantCount","_plants","_playersNearby","_position","_restricted","_scatter","_selectedLocation","_showPlantMarkers","_timeStamp"]; +private ["_cfgEpoch", "_debug", "_limit", "_counter", "_distFromOthers", "_others", "_nearbyLocations", "_position", "_selectedLocation", "_goodPos", "_plantsArray", "_plant", "_plantCount", "_scatter", "_plants", "_plantPos", "_debugMkr", "_markers", "_originalColors", "_showMarkers", "_decayMarkerColor", "_compromisedColor", "_decayTime", "_rEvents","_thisEvent"]; //[[[end]]] - -// SET THIS TO TRUE TO GET MESSAGES IN LOG. -_debug = true; -_showPlantMarkers = true; - -// select a plant type to spawn -_plant = selectRandom ["Goldenseal_EPOCH", "Goldenseal_EPOCH", "Goldenseal_EPOCH", "Poppy_EPOCH", "Pumpkin_EPOCH"]; - -// START PLANT PATCH SPAWN LIMIT CODE IF EPOCH_plantCounter HAS NOT BEEN INITIATED. -// THIS MAKES SURE IT ONLY DOES THIS BIT THE FIRST TIME THE EVENT RUNS. -if (isNil "EPOCH_plantCounter") then { - //SET COUNTER TO ZERO. - EPOCH_plantCounter = 0; - //SET LIMIT TO FIVE. - EPOCH_plantLimit = 5; -}; +_cfgEpoch = configFile >> "CfgEpoch" >> worldname; +_debug = if(getNumber(_cfgEpoch >> "debugPlantSpawner") isEqualTo 1)then{true}else{false}; +_limit = getNumber(_cfgEpoch >> "maxPlantSpawns"); +_counter = missionNameSpace getVariable["EPOCH_plantCounter",0]; +_others = missionNameSpace getVariable["EPOCH_plants", [[0,0,0]] ]; +_distFromOthers = getNumber(_cfgEpoch >> "distFromOtherPlants"); //STOP THE SCRIPT AND EXIT IF THE COUNTER IS TOO HIGH. -if (EPOCH_plantCounter >= EPOCH_plantLimit) exitWith { +if (_counter >= _limit) exitWith { if (_debug) then {diag_log "DEBUG: suppressed plant spawn over limit"}; }; // FIND A POSITION FOR PLANT PATCH prefer Hills and Vineyards _nearbyLocations = nearestLocations [epoch_centerMarkerPosition,["VegetationVineyard","Hill"],EPOCH_dynamicVehicleArea]; -if (_nearbyLocations isEqualTo []) then { - _position = [epoch_centerMarkerPosition, 0, EPOCH_dynamicVehicleArea, 10, 0, 4000, 0] call BIS_fnc_findSafePos; -} else { - _selectedLocation = locationPosition (selectRandom _nearbyLocations); - _position = [_selectedLocation, 0, 1000, 10, 0, 4000, 0] call BIS_fnc_findSafePos; -}; +for "_i" from 0 to 100 step 1 do { + if (_nearbyLocations isEqualTo []) then { + _position = [epoch_centerMarkerPosition, 0, EPOCH_dynamicVehicleArea, 10, 0, 4000, 0] call BIS_fnc_findSafePos; + } else { + _selectedLocation = locationPosition (selectRandom _nearbyLocations); + _position = [_selectedLocation, 0, 1000, 10, 0, 4000, 0] call BIS_fnc_findSafePos; + }; + _goodPos = true; + + _goodPos = [_position, true, true, true, _others, _distFromOthers] call EPOCH_server_isNearChecks; -//CHECK FOR PROTECTED AREA WITIN 2000 METERS. -_restricted = nearestObjects [_position, ["ProtectionZone_Invisible_F"], 2000]; -if(count _restricted > 0) exitWith { - if (_debug) then {diag_log "DEBUG: suppressed PLANT PATCH spawn TRADER too close"}; -}; - -//CHECK FOR JAMMERS IN THE AREA WITHIN 1000 METERS. -_jammers = nearestObjects[_position, ["PlotPole_EPOCH"], 1000]; -if(count _jammers > 0) exitWith { - if (_debug) then {diag_log "DEBUG: suppressed PLANT PATCH spawn jammer too close"}; -}; - -//CHECK TO SEE IF PLAYERS WITHIN 900 METERS. -_playersNearby = _position nearEntities[["Epoch_Male_F", "Epoch_Female_F"], 900]; -if(count _playersNearby > 0) exitWith { - if (_debug) then {diag_log "DEBUG: suppressed PLANT PATCH spawn PLAYER too close"}; + if(_goodPos)then{ + _i = 100; + }else{ + _position = []; + }; }; // IF WE MADE IT THIS FAR, WE CAN SPAWN SOME SHIT. if ((count _position) == 2) then{ - + // select a plant type to spawn + _plantsArray = getArray(_cfgEpoch >> "availablePlants"); + _plant = selectRandom _plantsArray; + // vary plant count and scatter by plant type - _plantCount = 1; + _plantCount = (floor(random(2))); _scatter = 10; - _decayTime = 1200; switch _plant do { case "Goldenseal_EPOCH": { _plantCount = (floor(random(4)))+3; @@ -90,52 +77,51 @@ if ((count _position) == 2) then{ _plants = []; // CREATE THE PATCH OF PLANTS. - for "_i" from 1 to _plantCount step 1 do { + for "_i" from 0 to (_plantCount - 1) step 1 do { _plants pushBack createVehicle[_plant, _position, [], _scatter, "NONE"]; + if(_debug)then{ + _plantPos = getPosATL (_plants select _i); + _debugMkr = createMarker [str(_plantPos), _plantPos]; + _debugMkr setMarkerShape "ICON"; + _debugMkr setMarkerType "mil_dot"; + _debugMkr setMarkerColor "ColorRed"; + }; }; - _timeStamp = diag_tickTime; // SET UP THE MARKER. - if (_showPlantMarkers) then{ + _markers = []; + _originalColors = []; + _showMarkers = if(getNumber(_cfgEpoch >> "showPlantMarkers") isEqualTo 1)then{true}else{false}; + _decayMarkerColor = getText(_cfgEpoch >> "plantDecayMarkerColor"); + _compromisedColor = getText(_cfgEpoch >> "plantCompromisedColor"); + if (_showMarkers) then{ _markers = ["PlantSpawn",_position] call EPOCH_server_createGlobalMarkerSet; - }; - - // TICK COUNTER + 1 SPAWNED PLANT PATCH. - EPOCH_plantCounter = EPOCH_plantCounter + 1; - - // wait loop to handle plant patch - while {true} do { - private _plantsLeft = _plants select {!isNull _x}; - // Wait for all plants to be picked or to decay - if (_plantsLeft isEqualTo [] || (diag_tickTime - _timeStamp) > _decayTime) exitWith { - // TICK THE COUNTER DOWN SO A NEW PLANT PATCH WILL SPAWN TO TAKE ITS PLACE. - EPOCH_plantCounter = EPOCH_plantCounter - 1; - // DELETE THAT MARKER. - if (_showPlantMarkers) then{ - [_markers] call EPOCH_server_deleteGlobalMarkerSet; - }; - // remove any left over "dead" plants (only if decayTime is reached) - {deleteVehicle _x} forEach _plantsLeft; - }; - // set marker to brown to show 50% decay but not if already marked as picked (red). { - if !(getMarkerColor _x in ["ColorRed","ColorBrown"]) then { - if ((diag_tickTime - _timeStamp) > (_decayTime/2)) then { - _x setMarkerColor "ColorBrown"; - }; - }; + _originalColors pushBack (getMarkerColor _x); }forEach _markers; - // WAIT FOR A PLAYER TO Pick one plant then set marker to red - if (count _plantsLeft != _plantCount) then { - if (_showPlantMarkers) then{ - { - if (getMarkerColor _x != "ColorRed") then { - _x setMarkerColor "ColorRed"; - }; - }forEach _markers; - }; + + // Check for HeightenedPlayerVsPlayer false and remove comprimised coloring + if!(getNumber(_cfgEpoch >> "HeightenedPlayerVsPlayer") isEqualTo 1)then{ + _compromisedColor = getMarkerColor (_markers select 0); }; - sleep 30; + }; + + // TICK COUNTER + 1 + _counter = _counter + 1; + missionNameSpace setVariable["EPOCH_plantCounter",_counter]; + + // ADD POSITION TO OTHERS ARRAY + missionNameSpace setVariable["EPOCH_plants", _others + [_position]]; + + // SEND EVENT TO MONITOR + _decayTime = getNumber(_cfgEpoch >> "plantDecayTime"); + _serverSettingsConfig = configFile >> "CfgEpochServer"; + _timeMultiplier = ([_serverSettingsConfig, "timeMultiplier", 1] call EPOCH_fnc_returnConfigEntry); + _rEvents = missionNameSpace getVariable["EPOCH_RunningEvents",[]]; + _thisEvent = [_position, _plants, [], "plantCounter", diag_tickTime, (_decayTime * _timeMultiplier), _showMarkers, _markers, _originalColors, _decayMarkerColor, _compromisedColor]; + missionNameSpace setVariable["EPOCH_RunningEvents",_rEvents + [_thisEvent]]; + if (_debug) then { + diag_log format["EPOCHDebug: plantSpawner-EPOCH_PlantSpawns:%1", missionNameSpace getVariable["EPOCH_RunningEvents",[]]]; }; }; // END SCRIPT. \ No newline at end of file diff --git a/Sources/epoch_server_settings/EpochEvents/Satellite.sqf b/Sources/epoch_server_settings/EpochEvents/Satellite.sqf index f73216a2..5b59919f 100644 --- a/Sources/epoch_server_settings/EpochEvents/Satellite.sqf +++ b/Sources/epoch_server_settings/EpochEvents/Satellite.sqf @@ -8,23 +8,77 @@ //[[[cog import generate_private_arrays ]]] private ["_satellite","_markers","_playersNearEpicenter","_position","_satellites"]; //[[[end]]] -_position = [epoch_centerMarkerPosition, 0, EPOCH_dynamicVehicleArea, 10, 0, 1000, 0] call BIS_fnc_findSafePos; -if ((count _position) == 2) then{ +_cfgEpoch = configFile >> "CfgEpoch" >> worldname; +_debug = if(getNumber(_cfgEpoch >> "debugSatelliteSpawner") isEqualTo 1)then{true}else{false}; +_limit = getNumber(_cfgEpoch >> "maxSatelliteSpawns"); +_counter = missionNameSpace getVariable["EPOCH_satelliteCounter",0]; +_others = missionNameSpace getVariable["EPOCH_satellites", [[0,0,0]] ]; +_distFromOthers = getNumber(_cfgEpoch >> "distFromOtherSatellites"); - // spawn Satellite - _satellites = ["Land_Wreck_Satellite_EPOCH"]; - _satellite = createVehicle[(selectRandom _satellites), _position, [], 0.0, "CAN_COLLIDE"]; +//STOP THE SCRIPT AND EXIT IF THE COUNTER IS TOO HIGH. +if (_counter >= _limit) exitWith { + if (_debug) then {diag_log "DEBUG: suppressed SATELLITE spawn over limit"}; +}; - // send shockwave + effects to each player in zone at time of crash - _playersNearEpicenter = _position nearEntities[["Epoch_Male_F", "Epoch_Female_F"], 1000]; - if !(_playersNearEpicenter isEqualTo[]) then{ - [_satellite, -1, 0.8, false] remoteExec ['BIS_fnc_sandstorm',_playersNearEpicenter]; - }; - - // set rads - _satellite setVariable ["EPOCH_Rads", [30,50], true]; //30 rads within 50 meters - - if (EPOCH_showSatellites) then{ - _markers = ["Satellite",_position] call EPOCH_server_createGlobalMarkerSet; +// FIND A POSITION +for "_i" from 0 to 100 step 1 do { + _position = [epoch_centerMarkerPosition, 0, EPOCH_dynamicVehicleArea, 10, 0, 1000, 0] call BIS_fnc_findSafePos; + _goodPos = true; + + _goodPos = [_position, true, true, true, _others, _distFromOthers] call EPOCH_server_isNearChecks; + + if(_goodPos)then{ + _i = 100; + }else{ + _position = []; }; }; + +if ((count _position) == 2) then{ + // select a Satellite type to spawn + _satellites = getArray(_cfgEpoch >> "availableSatellites"); + _satellite = createVehicle[(selectRandom _satellites), _position, [], 0.0, "CAN_COLLIDE"]; + if(_debug)then{ + _debugMkr = createMarker [str(_position), _position]; + _debugMkr setMarkerShape "ICON"; + _debugMkr setMarkerType "mil_dot"; + _debugMkr setMarkerColor "ColorRed"; + }; + + // SET UP THE MARKER. + _markers = []; + _originalColors = []; + _showMarkers = if(getNumber(_cfgEpoch >> "showSatelliteMarkers") isEqualTo 1)then{true}else{false}; + _decayMarkerColor = getText(_cfgEpoch >> "satelliteDecayMarkerColor"); + _compromisedColor = getText(_cfgEpoch >> "satelliteCompromisedColor"); + if (_showMarkers) then{ + _markers = ["Satellite",_position] call EPOCH_server_createGlobalMarkerSet; + { + _originalColors pushBack (getMarkerColor _x); + }forEach _markers; + + // Check for HeightenedPlayerVsPlayer false and remove comprimised coloring + if!(getNumber(_cfgEpoch >> "HeightenedPlayerVsPlayer") isEqualTo 1)then{ + _compromisedColor = getMarkerColor (_markers select 0); + }; + }; + + // TICK COUNTER + 1 + _counter = _counter + 1; + missionNameSpace setVariable["EPOCH_satelliteCounter",_counter]; + + // ADD POSITION TO OTHERS ARRAY + missionNameSpace setVariable["EPOCH_satellites", _others + [_position]]; + + // SEND EVENT TO MONITOR + _decayTime = getNumber(_cfgEpoch >> "satelliteDecayTime"); + _serverSettingsConfig = configFile >> "CfgEpochServer"; + _timeMultiplier = ([_serverSettingsConfig, "timeMultiplier", 1] call EPOCH_fnc_returnConfigEntry); + _rEvents = missionNameSpace getVariable["EPOCH_RunningEvents",[]]; + _thisEvent = [_position, [_satellite], [], "satelliteCounter", diag_tickTime, (_decayTime * _timeMultiplier), _showMarkers, _markers, _originalColors, _decayMarkerColor, _compromisedColor]; + missionNameSpace setVariable["EPOCH_RunningEvents",_rEvents + [_thisEvent]]; + if (_debug) then { + diag_log format["EPOCHDebug: satelliteSpawner-%1", missionNameSpace getVariable["EPOCH_RunningEvents",[]]]; + }; +}; +// END SCRIPT. \ No newline at end of file diff --git a/Sources/epoch_server_settings/config.cpp b/Sources/epoch_server_settings/config.cpp index 7524d3f5..9ec4313a 100644 --- a/Sources/epoch_server_settings/config.cpp +++ b/Sources/epoch_server_settings/config.cpp @@ -52,7 +52,6 @@ class CfgEpoch class Default { worldSize = 12000; - plantLimit = 10; vehicleSpawnTypes[] = { {"FlatAreaCity",1}, {"FlatAreaCitySmall",1}, @@ -79,11 +78,6 @@ class CfgEpoch traderHomes[] = {"House", "Building"}; traderUniforms[] = {"U_OG_leader", "U_C_Poloshirt_stripped", "U_C_Poloshirt_blue", "U_C_Poloshirt_burgundy", "U_C_Poloshirt_tricolour", "U_C_Poloshirt_salmon", "U_C_Poloshirt_redwhite", "U_C_Poor_1", "U_C_WorkerCoveralls", "U_C_Journalist", "U_C_Scientist", "U_OrestesBody"}; - // Shipwrecks - shipwreckLootEnabled = 1; - maxSpawnedShipwrecks = 12; - distFromOtherShipwrecks = 750; - // Debug Box telePos[] = {}; lightPos[] = { @@ -93,6 +87,70 @@ class CfgEpoch debugBoxClass = "Debug_static_F"; cloneClasses[] = {"clone_empty_static_F", "clone_male_static_F", "clone_female_static_F"}; + // Settings for Events, Missions, etc + spawnDistanceFromPlayers = 500; + spawnDistanceFromJammers = 1000; + spawnDistanceFromTraders = 2000; + HeightenedPlayerVsPlayer = 1; // 0 = OFF + + // Shipwrecks Loot Box Spawner + shipwreckLootEnabled = 1; // 0 = OFF + debugShipwreckLoot = 0; // 1 = ON + showBoatLootMarkers = 1; + maxSpawnedShipwrecks = 12; + distFromOtherShipwrecks = 750; + shipwreckDecayMarkerColor = "ColorBrown"; // decay changes icon (_markers select 2) + shipwreckCompromisedColor = "ColorRed"; // compromised changes active surround (_markers select 0) + + // Plant Spawner + debugPlantSpawner = 0; + showPlantMarkers = 1; + maxPlantSpawns = 5; + distFromOtherPlants = 2500; + plantDecayTime = 1200; //Half this time results in decayMarkerColor marker + plantDecayMarkerColor = "ColorBrown"; + plantCompromisedColor = "ColorRed"; + availablePlants[] = {"Goldenseal_EPOCH", "Goldenseal_EPOCH", "Goldenseal_EPOCH", "Poppy_EPOCH", "Pumpkin_EPOCH"}; + + // Carnival and Loot Box Spawner + debugCarnivalSpawner = 0; + showCarnivalMarkers = 1; + maxCarnivalSpawns = 2; + distFromOtherCarnivals = 5000; + carnivalDecayTime = 3600; + carnivalDecayMarkerColor = "ColorBrown"; + carnivalCompromisedColor = "ColorRed"; + carnivalSpawnedObjects[] = {"Carnival_Tent", "Land_Slide_F", "Carnival_Tent", "Land_Carousel_01_F", "Carnival_Tent", "Carnival_Tent"}; + + // EarthQuake and Mineral Deposit Spawner + debugEarthquakeSpawner = 0; + showEarthquakeMarkers = 1; + maxEarthquakeSpawns = 3; + distFromOtherEarthquakes = 1500; + earthquakeDecayTime = 2400; + earthquakeDecayMarkerColor = "ColorBrown"; + earthquakeCompromisedColor = "ColorRed"; + availableMinerals[] = {"MineralDepositCopper_EPOCH", "MineralDepositGold_EPOCH", "MineralDepositSilver_EPOCH"}; + + // Container Spawner + debugContainerSpawner = 0; + showContainerMarkers = 1; + maxContainerSpawns = 5; + distFromOtherContainers = 3500; + containerDecayTime = 1200; + containerDecayMarkerColor = "ColorBrown"; + containerCompromisedColor = "ColorRed"; + + // Satellite Crash Spawner + debugSatelliteSpawner = 0; + showSatelliteMarkers = 1; + maxSatelliteSpawns = 5; + distFromOtherSatellites = 2500; + satelliteDecayTime = 2700; + satelliteDecayMarkerColor = "ColorBrown"; + satelliteCompromisedColor = "ColorRed"; + availableSatellites[] = {"Land_Wreck_Satellite_EPOCH"}; + propsPos[] = {}; staticNpcPos[] = {}; forcedVehicleSpawnTable = "";