diff --git a/CHANGELOG.md b/CHANGELOG.md index 94adbf9..c5a415f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,23 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project badly attempts [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [3.0] - 2023-05-03 + +### Added + +- CBA settings for dynamic enable/disable of player/server metrics gathering +- CBA settings for dynamic timing for player/server metrics gathering + +### Changed + +- Reformat CBA settings +- Separate player and server metrics into proper functions/initializers/handlers +- Refactor most functions and change initialization routines in `CfgFunctions` + +### Removed + +- Remove `CfgRemoteExec` from `description.ext` as it has been deprecated as of Arma v1.54 + ## [2.2] - 2023-04-23 ### Added diff --git a/description.ext b/description.ext index 8020801..fbc7690 100644 --- a/description.ext +++ b/description.ext @@ -93,28 +93,6 @@ class cfgFunctions }; -class cfgRemoteExec -{ - // List of script commands allowed to be sent from client via remoteExec - class Commands - { - // State of remoteExec: 0-turned off, 1-turned on, taking whitelist into account, 2-turned on, however, ignoring whitelists (default because of backward compatibility) - mode = 2; - }; - // List of script functions allowed to be sent from client via remoteExec - class Functions - { - // State of remoteExec: 0-turned off, 1-turned on, taking whitelist into account, 2-turned on, however, ignoring whitelists (default because of backward compatibility) - mode = 2; - // Ability to send jip messages: 0-disabled, 1-enabled (default) - jip = 1; - class BIS_fnc_effectKilledAirDestruction {}; - class BIS_fnc_effectKilledSecondaries {}; - class BIS_fnc_objectVar {}; - class BIS_fnc_execVM {}; - }; -}; - class CfgDebriefingSections { class acex_killTracker { title = "Acex Killed Events"; diff --git a/functions/CfgFunctions.hpp b/functions/CfgFunctions.hpp index 8979a7b..7a8c4d5 100644 --- a/functions/CfgFunctions.hpp +++ b/functions/CfgFunctions.hpp @@ -1,46 +1,63 @@ class milsim -{ - tag = "milsim"; +{ + class settings + { + class setDefaults { postInit = 1; }; + class addCBASettings { postInit = 1; }; + class addAARChatHandler { postInit = 1; }; + class addRespawnChatHandler { postInit = 1; }; + }; + class init { - class initManager { postInit = 1; }; - class init {}; - class initPlayerLocal {}; - class initPlayerCPS {}; - class initDNI_PlayerFPS {}; - class initServer {}; + class initServer { postInit = 1;}; //needs refactor + class initPlayerLocal { postInit = 1;}; }; - class userSettings - { - }; - class intel { - class initFBCB2 {}; - class MDS_callsigns {}; - class MDS_fixedAssets {}; - class MDS_rotaryAssets {}; - class MDS_smokeColors {}; - class MDS_radioFrequencies {}; - class MDS_environment {}; - class messageAssetStatus {}; + + class fbcb2 { + class addFBCB2DiaryEntries { postInit = 1; }; + class initFBCB2 { postInit = 1; }; + class processFBCB2Callsigns {}; + class processFBCB2FixedWingAssets {}; + class processFBCB2RotaryAssets {}; + class processFBCB2RadioFrequencies {}; + class processFBCB2SmokeColors {}; + class processFBCB2Environment {}; + class messageFBCB2AssetStatus {}; }; + class client { - class zenModules { postInit = 1; }; + class addZenModules { postInit = 1; }; + class addDNI_PlayerFPS { postInit = 1; }; // needs refactor + class bindEventHandlers { postInit = 1; }; + class bindVehicleActions { postInit = 1; }; + class addClientStatsPFH {}; + class calculateClientStats {}; }; + + class server { + class addServerStatsPFH {}; + class calculateServerStats {}; + }; + class resupply { class createAmmoBox {}; class createWeaponsBox {}; class createMedicalBox {}; } + class ambience { class flakInitVehicle {}; class flakEH {}; }; + class map { - class copyMapFromPlayer {}; - class getPlayerMapMarkers {}; - class loadMapMarkers {}; - class mapMarkerToString {}; - class stringToMapMarker {}; + class initMapCopy { postInit = 1; }; + class copyMapFromPlayer {}; //needs refactor + class getPlayerMapMarkers {}; //needs refactor + class loadMapMarkers {}; //needs refactor + class mapMarkerToString {}; //needs refactor + class stringToMapMarker {}; //needs refactor }; -}; +}; \ No newline at end of file diff --git a/functions/ambience/fn_flakEH.sqf b/functions/ambience/fn_flakEH.sqf index ef81f99..6a2b522 100644 --- a/functions/ambience/fn_flakEH.sqf +++ b/functions/ambience/fn_flakEH.sqf @@ -9,30 +9,30 @@ params [ ["_distanceDispersion", 30, [0]] ]; -// diag_log("flakEH running"); -// diag_log(_event); +// diag_log "[MILSIM] (ambience) flakEH running"; +// diag_log text format["[MILSIM] (ambience) flakEH event: %1", _event]; _unit = _event select 0; -// diag_log(format["i have a unit: %1", _unit]); +// diag_log text format["[MILSIM] (ambience) flahEH vehicle: %1", _unit]; _projectile = _event select 6; -// diag_log(format["i have a projectile in flight: %1", _projectile]); +// diag_log text format["[MILSIM] (ambience) flakEH projectile in flight: %1", _projectile]; deleteVehicle _projectile; -// diag_log("i have deleted the projectile"); +// diag_log text "[MILSIM] (ambience) flakEH projectile deleted"); -// diag_log(_unit weaponsTurret [0] select _primaryTurret); +// diag_log text format["[MILSIM] (ambience) flakEH primary turret: %1", _unit weaponsTurret [0] select _primaryTurret]; _weapon = _unit weaponsTurret [0] select _primaryTurret; _munitionConversionRate = _fullAmmoCount - _flakRoundsEvery; -// diag_log(format["munition count: %1", _unit ammo _weapon]); -// diag_log(format["munition replacement at: %1", _munitionConversionRate]); +// diag_log text format["[MILSIM] (ambience) flakEH munition count: %1", _unit ammo _weapon]; +// diag_log text format["[MILSIM] (ambience) flakEH munition replacement at: %1", _munitionConversionRate]; if (_unit ammo _weapon < _munitionConversionRate) then { _unit setAmmo [_weapon, _fullAmmoCount]; - // diag_log(format["replacing ammo count to: %1", _fullAmmoCount]); + // diag_log text format["[MILSIM] (ambience) flakEH replacing ammo count to: %1", _fullAmmoCount]; _targetPosition = []; @@ -48,7 +48,7 @@ if (_unit ammo _weapon < _munitionConversionRate) then { } else { _possibleTargets = _unit nearTargets _maximumDistance; - diag_log(format["ai has %1 possible targetting solutions", count _possibleTargets]); + diag_log text format["ai has %1 possible targetting solutions", count _possibleTargets]; if ((count _possibleTargets) > 0) then { @@ -59,7 +59,7 @@ if (_unit ammo _weapon < _munitionConversionRate) then { _i = _unit aimedAtTarget [_x select 4, _weapon]; if (_i > _hold && (_x select 3) > 0) then { _target = _x select 4; - diag_log(format["setting target to %1", _target]); + diag_log text format["setting target to %1", _target]; _targetPosition = _x select 0; _hold = _i; }; @@ -69,30 +69,30 @@ if (_unit ammo _weapon < _munitionConversionRate) then { }; - // diag_log(format["i have found target coordinates: %1", _targetPosition]); + // diag_log text format["[MILSIM] (ambience) flakEH target coordinates: %1", _targetPosition]; if ((count _targetPosition) > 0) then { - // diag_log("calculating new projectile placement"); + // diag_log text "[MILSIM] (ambience) flakEH calculating new projectile placement"; _targetX = _targetPosition select 0; _targetY = _targetPosition select 1; _targetZ = _targetPosition select 2; - // diag_log(format["checking target altitude: %1", _targetZ]); + // diag_log text format["[MILSIM] (ambience) flakEH checking target altitude: %1", _targetZ]; if (_targetZ > _minimumAltitude) then { - // diag_log("target is above minimum height, proceeding"); + // diag_log text "[MILSIM] (ambience) flakEH target is above minimum height, proceeding"; if !(lineIntersects [getPos _unit, _targetPosition, _unit, _target]) then { - // diag_log("intersection calculated"); + // diag_log text "[MILSIM] (ambience) flakEH intersection calculated"; _flakDistance = ((speed _target * 0.8) * (_speedDispersion / 100)) + ((_unit distance _target) * (_distanceDispersion / 500)); _distanceX = ((random (_flakDistance * 2)) - _flakDistance) + _targetX; _distanceY = ((random (_flakDistance * 2)) - _flakDistance) + _targetY; _distanceZ = ((random (_flakDistance * 2)) - _flakDistance) + _targetZ; - // diag_log( format["target is distance: %1 / distance2D %2 from me, creating munition distance %3, distance2D %4 from me", _unit distance _targetPosition, _unit distance2D _targetPosition, _unit distance [_distanceX, _distanceY, _distanceZ], _unit distance2D [_distanceX, _distanceY, _distanceZ]]); + // diag_log text format["[MILSIM] (ambience) flakEH target is distance: %1 / distance2D %2 from me, creating munition distance %3, distance2D %4 from me", _unit distance _targetPosition, _unit distance2D _targetPosition, _unit distance [_distanceX, _distanceY, _distanceZ], _unit distance2D [_distanceX, _distanceY, _distanceZ]]; _flak = createVehicle ["SmallSecondary", [_distanceX, _distanceY, _distanceZ], [], 0, "CAN_COLLIDE"]; }; diff --git a/functions/ambience/fn_flakInitVehicle.sqf b/functions/ambience/fn_flakInitVehicle.sqf index 4afcb61..77b6a60 100644 --- a/functions/ambience/fn_flakInitVehicle.sqf +++ b/functions/ambience/fn_flakInitVehicle.sqf @@ -8,34 +8,34 @@ params [ ["_removeMissiles", true, [true]] ]; -diag_log("initializing flak v16"); +diag_log text "[MILSIM] (ambience) initializing flak v18"; _primaryTurret = objNull; if (_removeMissiles) then { - diag_log("removing missiles"); + diag_log text "[MILSIM] (ambience) removing missiles"; _magazines = magazinesAllTurrets _unit; { _magazine = _x select 0; - diag_log( format["Checking: %1", _magazine]); + diag_log text format["[MILSIM] (ambience) checking: %1", _magazine]; _ammo = gettext( configfile >> "CfgMagazines" >> _magazine >> "ammo"); - diag_log( format["ammo: %1", _ammo]); + diag_log text format["[MILSIM] (ambience) ammo: %1", _ammo]; _type = gettext(configFile >> "CfgAmmo" >> _ammo >> "simulation"); - diag_log( format["ammo type: %1", _type]); + diag_log text format["[MILSIM] (ambience) ammo type: %1", _type]; if (_type == "shotMissile") then { _unit removeMagazinesTurret [_magazine, [0]]; - diag_log(format["removing ammo: %1", _ammo]); + diag_log text format["[MILSIM] (ambience) removing ammo: %1", _ammo]; }; if ((_type == "shotBullet") && (_primaryTurret isEqualTo objNull)) then { _primaryTurret = _forEachIndex; - diag_log(format["found primary turret: %1", _unit weaponsTurret [0] select _primaryTurret]); + diag_log text format["[MILSIM] (ambience) found primary turret: %1", _unit weaponsTurret [0] select _primaryTurret]; }; } foreach _magazines; @@ -55,29 +55,27 @@ _unit setVariable["feh_flakRoundsEvery", _flakRoundsEvery]; _unit setVariable["feh_speedDispersion", _speedDispersion]; _unit setVariable["feh_distanceDispersion", _distanceDispersion]; -diag_log( format[ - "{[_this, maximumDistance: %1, minimumAltitude: %2, primaryTurret: %3, fullAmmoCount: %4, flakRoundsEvery: %5, speedDispersion: %6, distanceDispersion: %7] call milsim_fnc_flakEH;}", - _maximumDistance, - _minimumAltitude, - _primaryTurret, - _fullAmmoCount, - _flakRoundsEvery, - _speedDispersion, - _distanceDispersion - ] - ); +diag_log text format [ + "[MILSIM] (ambience) {[_this, maximumDistance: %1, minimumAltitude: %2, primaryTurret: %3, fullAmmoCount: %4, flakRoundsEvery: %5, speedDispersion: %6, distanceDispersion: %7] call milsim_fnc_flakEH;}", + _maximumDistance, + _minimumAltitude, + _primaryTurret, + _fullAmmoCount, + _flakRoundsEvery, + _speedDispersion, + _distanceDispersion + ]; - _unit addEventHandler [ - "Fired", - format[ - "diag_log('firing'); [_this, %1, %2, %3, %4, %5, %6, %7] call milsim_fnc_flakEH", - _maximumDistance, - _minimumAltitude, - _primaryTurret, - _fullAmmoCount, - _flakRoundsEvery, - _speedDispersion, - _distanceDispersion - ] - ]; \ No newline at end of file + _unit addEventHandler ["Fired", + format[ + "[_this, %1, %2, %3, %4, %5, %6, %7] call milsim_fnc_flakEH", + _maximumDistance, + _minimumAltitude, + _primaryTurret, + _fullAmmoCount, + _flakRoundsEvery, + _speedDispersion, + _distanceDispersion + ] +]; \ No newline at end of file diff --git a/functions/client/fn_addClientStatsPFH.sqf b/functions/client/fn_addClientStatsPFH.sqf new file mode 100644 index 0000000..622a617 --- /dev/null +++ b/functions/client/fn_addClientStatsPFH.sqf @@ -0,0 +1,18 @@ +if (!hasInterface) exitWith {}; + +diag_log text "[MILSIM] (client) initializing Stats PFH"; + +_cpsPFH = [ + { + [] call milsim_fnc_calculateClientStats; + }, + "milsim_client_cps_interval" call CBA_settings_fnc_get, + [], + { diag_log text format ["[MILSIM] (client) PFH loaded with interval %1 seconds", "milsim_client_cps_interval" call CBA_settings_fnc_get ], }, + { diag_log text format ["[MILSIM] (client) PFH unloaded"] }, + { "milsim_client_cps_enable" call CBA_settings_fnc_get }, + { false }, + [] +] call CBA_fnc_createPerFrameHandlerObject; + +player setVariable ["milsim_client_cps_handler", _cpsPFH]; diff --git a/functions/init/fn_initDNI_PlayerFPS.sqf b/functions/client/fn_addDNI_PlayerFPS.sqf similarity index 97% rename from functions/init/fn_initDNI_PlayerFPS.sqf rename to functions/client/fn_addDNI_PlayerFPS.sqf index 3b06435..e1bea9f 100644 --- a/functions/init/fn_initDNI_PlayerFPS.sqf +++ b/functions/client/fn_addDNI_PlayerFPS.sqf @@ -1,3 +1,5 @@ +if ( !hasInterface ) exitWith {}; + diag_log text "[MILSIM] (DNI) writing variable loop"; [] spawn { diff --git a/functions/client/fn_zenModules.sqf b/functions/client/fn_addZenModules.sqf similarity index 89% rename from functions/client/fn_zenModules.sqf rename to functions/client/fn_addZenModules.sqf index 2ea9959..72e5e2b 100644 --- a/functions/client/fn_zenModules.sqf +++ b/functions/client/fn_addZenModules.sqf @@ -1,3 +1,5 @@ +if ( !hasInterface ) exitWith {}; + [ "17th Battalion", "Create Resupply Box", @@ -38,7 +40,7 @@ [ "17th Battalion", - "Grounds Cleanup2", + "Grounds Cleanup", { params [["_pos", [0,0,0], [[]], 3], ["_target", objNull, [objNull]]]; @@ -67,4 +69,9 @@ ] call zen_dialog_fnc_create; } -] call zen_custom_modules_fnc_register; \ No newline at end of file +] call zen_custom_modules_fnc_register; + + +diag_log text "[MILSIM] (client) zeus modules added"; + +nil; \ No newline at end of file diff --git a/functions/client/fn_bindEventHandlers.sqf b/functions/client/fn_bindEventHandlers.sqf new file mode 100644 index 0000000..3cb0dd5 --- /dev/null +++ b/functions/client/fn_bindEventHandlers.sqf @@ -0,0 +1,43 @@ +if ( !hasInterface ) exitWith {}; + +player addEventHandler["Respawn", + { + params ["_unit", "_corpse"]; + _killer = _corpse getVariable ["ace_medical_causeOfDeath", "#scripted"]; + if (_killer == "respawn_button") then { + format["[MILSIM] (client) %1 was unconscious then clicked the respawn button", name _unit] remoteExec["diag_log", 0]; + // format["%1 was unconscious then clicked the respawn button", name _unit] remoteExec["systemChat", 0]; + }; + } +]; + + +[ + { + params ["_unit", "_object", "_cost"]; + private _return = (count nearestObjects [_unit, ["B_APC_Tracked_01_CRV_F", "rhsusf_M1239_M2_Deploy_socom_d", "rhsusf_stryker_m1132_m2_wd", "rhsusf_m113_usarmy_supply", "rhsusf_M1078A1P2_B_WD_CP_fmtv_usarmy", "B_Slingload_01_Cargo_F"], 120]) > 0; + _return + } +] call ace_fortify_fnc_addDeployHandler; + + +addMissionEventHandler ["HandleChatMessage", + { + params ["_channel", "_owner", "_from", "_text", "_person", "_name", "_strID", "_forcedDisplay", "_isPlayerMessage", "_sentenceType", "_chatMessageType"]; + + if ( missionNamespace getVariable ["milsim_sideChat", false] ) exitWith{ false }; + + if (_channel != 1) exitWith { false }; + + if ( ( admin _owner ) != 0 ) exitWith { false }; + + if ( !isNull ( getAssignedCuratorLogic _person ) ) exitWith { false }; + + true; + } +]; + + +diag_log text "[MILSIM] (client) event handlers bound"; + +nil; \ No newline at end of file diff --git a/functions/client/fn_bindVehicleActions.sqf b/functions/client/fn_bindVehicleActions.sqf new file mode 100644 index 0000000..ccf502f --- /dev/null +++ b/functions/client/fn_bindVehicleActions.sqf @@ -0,0 +1,67 @@ +if ( !hasInterface ) exitWith {}; + +_checkFuel = +[ + "CheckFuel", + "Check Fuel", + "", + { + hint format ["Fuel: %1%2", floor (fuel _target *100), "%"]; + }, + {true} +] call ace_interact_menu_fnc_createAction; + +["LandVehicle", 0, ["ACE_MainActions"], _checkFuel, true] call ace_interact_menu_fnc_addActionToClass; + + +_unflip = +[ + "Unfuck", + "Flip Vehicle", + "", + { + _target setpos [(getpos _target) select 0,(getpos _target) select 1, 0.5]; + _target setVectorUp surfaceNormal position _target; + }, + {true} +] call ace_interact_menu_fnc_createAction; + +["LandVehicle", 0, ["ACE_MainActions"], _unflip, true] call ace_interact_menu_fnc_addActionToClass; + + +_patchTire = +[ + "patchTire", + "Patch Tire", + "\a3\ui_f\data\IGUI\Cfg\Actions\repair_ca.paa", + { + [_player, "AinvPknlMstpSnonWnonDr_medic5", 0] call ace_common_fnc_doAnimation; + + [ + 30, + [_player, _target], + { + params ["_args"]; + _args params ["_player", "_target"]; + hint "Tire Patched"; + _target setDamage 0.2; + _target setVariable["milsim_ace_repair_wheel_canPatch", false]; + }, + { + params ["_args"]; + _args params ["_player", "_target"]; + hint "Stopped repair"; + [_player, "", 0] call ace_common_fnc_doAnimation; + }, + "Patching" + ] call ace_common_fnc_progressBar + }, + { ( alive _target ) && ( [_player, "ToolKit"] call ace_common_fnc_hasItem ) && ( getDammage _target > 0.2 ) && ( _target getVariable["milsim_ace_repair_wheel_canPatch", true] ) } +] call ace_interact_menu_fnc_createAction; + +["ACE_Wheel", 0, ["ACE_MainActions"], _patchTire, true] call ace_interact_menu_fnc_addActionToClass; + + +diag_log text "[MILSIM] (client) vehicle actions bound"; + +nil; \ No newline at end of file diff --git a/functions/client/fn_calculateClientStats.sqf b/functions/client/fn_calculateClientStats.sqf new file mode 100644 index 0000000..accf498 --- /dev/null +++ b/functions/client/fn_calculateClientStats.sqf @@ -0,0 +1,29 @@ +[] spawn { + // warning: while loop without suspension executes multiple times per frame + private _counter = 0; + private _endTime = diag_tickTime + 5; + private _frameNo = diag_frameNo; + while { diag_tickTime < _endTime } do + { + _counter = _counter + 1; + }; + // in an empty mission, the _counter may go well over 2000 times per frame! + diag_log text format ["[MILSIM] (client) Average Execution: %1 times per frame", _counter / (diag_frameNo - _frameNo)]; + player setVariable ["milsim_player_raw_cps", _counter / (diag_frameNo - _frameNo), true]; + + // with suspension + private _counter = 0; + private _endTime = diag_tickTime + 5; + private _frameNo = diag_frameNo; + while { diag_tickTime < _endTime } do + { + _counter = _counter + 1; + uiSleep 0.001; // waits at least 1 frame + }; + // _counter says one per frame, as expected + diag_log text format ["[MILSIM] (client) Average Execution: %1 times per frame", _counter / (diag_frameNo - _frameNo)]; + player setVariable ["milsim_player_cps", _counter / (diag_frameNo - _frameNo), true]; + +}; + +nil; \ No newline at end of file diff --git a/functions/fbcb2/fn_addFBCB2DiaryEntries.sqf b/functions/fbcb2/fn_addFBCB2DiaryEntries.sqf new file mode 100644 index 0000000..10936a4 --- /dev/null +++ b/functions/fbcb2/fn_addFBCB2DiaryEntries.sqf @@ -0,0 +1,10 @@ +if ( !hasInterface ) exitWith {}; + +player createDiarySubject["Status","FBCB2 - Status"]; +player createDiarySubject["Intel","FBCB2 - Combat Msgs"]; +player createDiarySubject["Messages","FBCB2 - Messages"]; + + +diag_log text "[MILSIM] (fbcb2) diary entries added"; + +nil; \ No newline at end of file diff --git a/functions/fbcb2/fn_initFBCB2.sqf b/functions/fbcb2/fn_initFBCB2.sqf new file mode 100644 index 0000000..4a4d3f4 --- /dev/null +++ b/functions/fbcb2/fn_initFBCB2.sqf @@ -0,0 +1,10 @@ +if ( !hasInterface ) exitWith {}; + +waitUntil { !isNil "milsim_complete" }; + +[] call milsim_fnc_processFBCB2Callsigns; +[] call milsim_fnc_processFBCB2FixedWingAssets; +[] call milsim_fnc_processFBCB2RotaryAssets; +[] call milsim_fnc_processFBCB2RadioFrequencies; +[] call milsim_fnc_processFBCB2SmokeColors; +[] call milsim_fnc_processFBCB2Environment; diff --git a/functions/intel/fn_messageAssetStatus.sqf b/functions/fbcb2/fn_messageFBCB2AssetStatus.sqf similarity index 100% rename from functions/intel/fn_messageAssetStatus.sqf rename to functions/fbcb2/fn_messageFBCB2AssetStatus.sqf diff --git a/functions/intel/fn_MDS_callsigns.sqf b/functions/fbcb2/fn_processFBCB2Callsigns.sqf similarity index 100% rename from functions/intel/fn_MDS_callsigns.sqf rename to functions/fbcb2/fn_processFBCB2Callsigns.sqf diff --git a/functions/intel/fn_MDS_environment.sqf b/functions/fbcb2/fn_processFBCB2Environment.sqf similarity index 100% rename from functions/intel/fn_MDS_environment.sqf rename to functions/fbcb2/fn_processFBCB2Environment.sqf diff --git a/functions/intel/fn_MDS_fixedAssets.sqf b/functions/fbcb2/fn_processFBCB2FixedWingAssets.sqf similarity index 92% rename from functions/intel/fn_MDS_fixedAssets.sqf rename to functions/fbcb2/fn_processFBCB2FixedWingAssets.sqf index 3ec6bcf..539beb2 100644 --- a/functions/intel/fn_MDS_fixedAssets.sqf +++ b/functions/fbcb2/fn_processFBCB2FixedWingAssets.sqf @@ -14,6 +14,6 @@ _text = "=======------ Mission Data Set ---- } foreach _assetList; -_text = _text + "

Run Report on local node?"; +_text = _text + "

Run Report on local node?"; player createDiaryRecord ["Status", ["MDS - ASSETS - FIXED", _text]]; \ No newline at end of file diff --git a/functions/intel/fn_MDS_radioFrequencies.sqf b/functions/fbcb2/fn_processFBCB2RadioFrequencies.sqf similarity index 100% rename from functions/intel/fn_MDS_radioFrequencies.sqf rename to functions/fbcb2/fn_processFBCB2RadioFrequencies.sqf diff --git a/functions/intel/fn_MDS_rotaryAssets.sqf b/functions/fbcb2/fn_processFBCB2RotaryAssets.sqf similarity index 92% rename from functions/intel/fn_MDS_rotaryAssets.sqf rename to functions/fbcb2/fn_processFBCB2RotaryAssets.sqf index 9ccf6e5..a9d40bf 100644 --- a/functions/intel/fn_MDS_rotaryAssets.sqf +++ b/functions/fbcb2/fn_processFBCB2RotaryAssets.sqf @@ -14,6 +14,6 @@ _text = "=======------ Mission Data Set ---- } foreach _assetList; -_text = _text + "

Run Report on local node?"; +_text = _text + "

Run Report on local node?"; player createDiaryRecord ["Status", ["MDS - ASSETS - ROTARY", _text]]; \ No newline at end of file diff --git a/functions/intel/fn_MDS_smokeColors.sqf b/functions/fbcb2/fn_processFBCB2SmokeColors.sqf similarity index 100% rename from functions/intel/fn_MDS_smokeColors.sqf rename to functions/fbcb2/fn_processFBCB2SmokeColors.sqf diff --git a/functions/init/fn_init.sqf b/functions/init/fn_init.sqf deleted file mode 100644 index 6c3f5fe..0000000 --- a/functions/init/fn_init.sqf +++ /dev/null @@ -1,60 +0,0 @@ -// Disable saving -enableSaving[false, false]; - -// Disable radio chatter and sentences -enableRadio false; -enableSentences false; - -// update ace weight settings since arma quadruples the value when an object is loaded into another object -missionNamespace setVariable ["ACE_maxWeightDrag", 2400]; -missionNamespace setVariable ["ACE_maxWeightCarry", 1800]; - -// Disable RHS radio chatter (if RHS is present) -if(isClass(configfile >> "CfgPatches" >> "rhs_main")) then { - rhs_vehicleRadioChatter = 0; -}; - -// Disable ambient life (rabbits & snakes) once the mission starts -waitUntil {time > 0}; -enableEnvironment[false, true]; -diag_log text "[MILSIM] (init) ambient life disabled"; - -[ - "saveaar", - { - [] remoteExec["ocap_fnc_exportData", 2]; - }, - "admin" -] call CBA_fnc_registerChatCommand; - -[ - "respawn", - { - _clientID = _thisArgs select 0; - player setDamage 1; - format["[MILSIM] (init) %1 claims they were glitched and respawned - %2", name player, netID player] remoteExec["diag_log", 2]; - format["%1 claims they were glitched and respawned (%2)", name player, netID player] remoteExec["systemChat", -_clientID]; - }, - "all", - [clientOwner] -] call CBA_fnc_registerChatCommand; - -diag_log text "[MILSIM] (init) OCAP chat handler registered"; - - -[ - "milsim_sideChat", - "CHECKBOX", - "Enable Side Chat Text", - "17th Batallion", - false, - true, - { - params ["_value"]; - missionNamespace setVariable["milsim_sideChat", _value]; - } -] call CBA_fnc_addSetting; - -["milsim_sideChat", false] call CBA_settings_fnc_set; - -diag_log text "[MILSIM] (init) Custom CBA settings initialized"; diff --git a/functions/init/fn_initManager.sqf b/functions/init/fn_initManager.sqf deleted file mode 100644 index fae3de2..0000000 --- a/functions/init/fn_initManager.sqf +++ /dev/null @@ -1,11 +0,0 @@ -[] spawn milsim_fnc_init; - - -if (isServer) then { - [] spawn milsim_fnc_initServer; -}; -if (hasInterface) then { - [] spawn milsim_fnc_initPlayerLocal; -}; - -nil \ No newline at end of file diff --git a/functions/init/fn_initPlayerCPS.sqf b/functions/init/fn_initPlayerCPS.sqf deleted file mode 100644 index 0513f2d..0000000 --- a/functions/init/fn_initPlayerCPS.sqf +++ /dev/null @@ -1,45 +0,0 @@ -diag_log text "[MILSIM] (initPlayerCPS) writing variable loop"; - -_cpsPFH = [ - { - - [] spawn { - // warning: while loop without suspension executes multiple times per frame - private _counter = 0; - private _endTime = diag_tickTime + 5; - private _frameNo = diag_frameNo; - while { diag_tickTime < _endTime } do - { - _counter = _counter + 1; - }; - // in an empty mission, the _counter may go well over 2000 times per frame! - diag_log text format ["[MILSIM] (initPlayerCPS) Average Execution: %1 times per frame", _counter / (diag_frameNo - _frameNo)]; - player setVariable["milsim_player_raw_cps", _counter / (diag_frameNo - _frameNo), true]; - - // with suspension - private _counter = 0; - private _endTime = diag_tickTime + 5; - private _frameNo = diag_frameNo; - while { diag_tickTime < _endTime } do - { - _counter = _counter + 1; - uiSleep 0.001; // waits at least 1 frame - }; - // _counter says one per frame, as expected - diag_log text format ["[MILSIM] (initPlayerCPS) Average Execution: %1 times per frame", _counter / (diag_frameNo - _frameNo)]; - player setVariable["milsim_player_cps", _counter / (diag_frameNo - _frameNo), true]; - - - }; - - }, - 300, - [], - { diag_log text "[MILSIM] (initPlayerCPS) CPS PFH loaded" }, - { diag_log text "IF YOU SEE THIS CPS PFH FUCKED UP" }, - { true }, - { false }, - [] -] call CBA_fnc_createPerFrameHandlerObject; - -player setVariable ["milsim_player_cps_handler", _cpsPFH]; diff --git a/functions/init/fn_initPlayerLocal.sqf b/functions/init/fn_initPlayerLocal.sqf index 0c05243..3a1a2a3 100644 --- a/functions/init/fn_initPlayerLocal.sqf +++ b/functions/init/fn_initPlayerLocal.sqf @@ -1,133 +1,5 @@ -if (!hasInterface) exitWith {}; +if ( !hasInterface ) exitWith {}; -waitUntil {player == player}; - - -player createDiarySubject["Status","FBCB2 - Status"]; -player createDiarySubject["Intel","FBCB2 - Combat Msgs"]; -player createDiarySubject["Messages","FBCB2 - Messages"]; -diag_log text "[MILSIM] (initPlayerLocal) diaries created"; - - -waitUntil {time > 0}; -[] spawn milsim_fnc_initDNI_PlayerFPS; -[] spawn milsim_fnc_initPlayerCPS; - - -_action = [ - "CheckFuel", - "Check Fuel", - "", - { - hint format ["Fuel: %1", (fuel _target *100)] - }, - {true} - ] call ace_interact_menu_fnc_createAction; -["LandVehicle", 0, ["ACE_MainActions"], _action, true] call ace_interact_menu_fnc_addActionToClass; - - -_action = [ - "Unfuck", - "Flip Vehicle", - "", - { - _target setpos [(getpos _target) select 0,(getpos _target) select 1, 0.5]; - _target setVectorUp surfaceNormal position _target; - }, - {true} - ] call ace_interact_menu_fnc_createAction; -["LandVehicle", 0, ["ACE_MainActions"], _action, true] call ace_interact_menu_fnc_addActionToClass; - - -_action = ["CheckExtTank","Check External Tank","",{hint format ["Ext Tank: %1", 5]},{true}] call ace_interact_menu_fnc_createAction; -["Tank_F", 0, ["ACE_MainActions", "CheckFuel"], _action, true] call ace_interact_menu_fnc_addActionToClass; - - -_map_copy_condition = { - ('ItemMap' in (assignedItems _player)) && ('ItemMap' in (assignedItems _target)) && ([_player, _target, []] call ace_common_fnc_canInteractWith) -}; - -_map_copy_action = [ - "MilSimCopyMap", - "Copy Map", -// "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", - "\a3\ui_f\data\igui\cfg\actions\talk_ca.paa", - {[_target,_player] call milsim_fnc_copyMapFromPlayer}, - _map_copy_condition - ] call ace_interact_menu_fnc_createAction; - -["Man", 0, ["ACE_MainActions"], _map_copy_action, true] call ace_interact_menu_fnc_addActionToClass; - - -_patchTire = -[ - "patchTire", - "Patch Tire", - "\a3\ui_f\data\IGUI\Cfg\Actions\repair_ca.paa", - { - [_player, "AinvPknlMstpSnonWnonDr_medic5", 0] call ace_common_fnc_doAnimation; - - [ - 30, - [_player, _target], - { - params ["_args"]; - _args params ["_player", "_target"]; - hint "Tire Patched"; - _target setDamage 0.2; - _target setVariable["milsim_ace_repair_wheel_canPatch", false]; - }, - { - params ["_args"]; - _args params ["_player", "_target"]; - hint "Stopped repair"; - [_player, "", 0] call ace_common_fnc_doAnimation; - }, - "Patching" - ] call ace_common_fnc_progressBar - }, - { ( alive _target ) && ( [_player, "ToolKit"] call ace_common_fnc_hasItem ) && ( getDammage _target > 0.2 ) && ( _target getVariable["milsim_ace_repair_wheel_canPatch", true] ) } -] call ace_interact_menu_fnc_createAction; - - -["ACE_Wheel", 0, ["ACE_MainActions"], _patchTire, true] call ace_interact_menu_fnc_addActionToClass; - - -player addEventHandler["Respawn", -{ - params ["_unit", "_corpse"]; - _killer = _corpse getVariable ["ace_medical_causeOfDeath", "#scripted"]; - if (_killer == "respawn_button") then { - format["[MILSIM] (initPlayerLocal) %1 was unconscious then clicked the respawn button", name _unit] remoteExec["diag_log", 0]; - // format["%1 was unconscious then clicked the respawn button", name _unit] remoteExec["systemChat", 0]; - }; -}]; - - -[{ - params ["_unit", "_object", "_cost"]; - private _return = (count nearestObjects [_unit, ["B_APC_Tracked_01_CRV_F", "rhsusf_M1239_M2_Deploy_socom_d", "rhsusf_stryker_m1132_m2_wd", "rhsusf_m113_usarmy_supply", "rhsusf_M1078A1P2_B_WD_CP_fmtv_usarmy", "B_Slingload_01_Cargo_F"], 120]) > 0; - _return -}] call ace_fortify_fnc_addDeployHandler; - -addMissionEventHandler ["HandleChatMessage", { - params ["_channel", "_owner", "_from", "_text", "_person", "_name", "_strID", "_forcedDisplay", "_isPlayerMessage", "_sentenceType", "_chatMessageType"]; - - if ( missionNamespace getVariable ["milsim_sideChat", false] ) exitWith{ false }; - - if (_channel != 1) exitWith { false }; - - if ( ( admin _owner ) != 0 ) exitWith { false }; - - if ( !isNull ( getAssignedCuratorLogic _person ) ) exitWith { false }; - - true; -}]; - - -waitUntil {!isNil "milsim_complete"}; -[] spawn milsim_fnc_initFBCB2; - - -// Initializes the player/client side Dynamic Groups framework and registers the player group ["InitializePlayer", [player, true]] call BIS_fnc_dynamicGroups; + +nil; \ No newline at end of file diff --git a/functions/init/fn_initServer.sqf b/functions/init/fn_initServer.sqf index 424cbfc..15784ef 100644 --- a/functions/init/fn_initServer.sqf +++ b/functions/init/fn_initServer.sqf @@ -1,140 +1,61 @@ -if (isServer) then { +if (!isServer) exitWith {}; - _fixedAssets = [ - ["Ares", "USAF_A10", 0], - ["Odyssey", "RHSGREF_A29B_HIDF", 0], - ["Hercules", "USAF_C130J", 0] - - ]; - - _rotaryAssets = [ - ["Apollo", "RHS_MELB_MH6M", 0], - ["Artemis", "RHS_MELB_AH6M", 0], - ["Icarus", "RHS_MELB_H6M", 0], - ["Achilles", "RHS_CH_47F", 0], - ["Hades", "ej_MH60MDAP4", 0], - ["Griffin", "RHS_UH60M", 0], - ["Dustoff", "RHS_UH60M_MEV2", 0], - ["Pegasus", "B_T_VTOL_01_INFANTRY_F", 0], - ["Spartan", "B_T_VTOL_01_ARMED_F", 0], - ["Orion", "RHS_AH64D", 0], - ["Athena", "RHS_AH1Z", 0], - ["Homer", "RHS_UH1Y", 0], - ["Atlas", "rhsusf_CH53E_USMC", 0] - - ]; - - _homes = allMissionObjects "ModuleRespawnPosition_F"; +_fixedAssets = [ + ["Ares", "USAF_A10", 0], + ["Odyssey", "RHSGREF_A29B_HIDF", 0], + ["Hercules", "USAF_C130J", 0] + +]; + +_rotaryAssets = [ + ["Apollo", "RHS_MELB_MH6M", 0], + ["Artemis", "RHS_MELB_AH6M", 0], + ["Icarus", "RHS_MELB_H6M", 0], + ["Achilles", "RHS_CH_47F", 0], + ["Hades", "ej_MH60MDAP4", 0], + ["Griffin", "RHS_UH60M", 0], + ["Dustoff", "RHS_UH60M_MEV2", 0], + ["Pegasus", "B_T_VTOL_01_INFANTRY_F", 0], + ["Spartan", "B_T_VTOL_01_ARMED_F", 0], + ["Orion", "RHS_AH64D", 0], + ["Athena", "RHS_AH1Z", 0], + ["Homer", "RHS_UH1Y", 0], + ["Atlas", "rhsusf_CH53E_USMC", 0] +]; + +_homes = allMissionObjects "ModuleRespawnPosition_F"; +{ + _home = _x; { - _home = _x; - { - _a = _home nearEntities [ _x select 1, 750]; - _x set [2, (_x select 2) + count _a]; - - } forEach _fixedAssets; - } forEach _homes; - - missionNamespace setVariable ["milsim_var_fixedAssets", _fixedAssets]; - - { - _home = _x; - { - _a = _home nearEntities [ _x select 1, 750]; - _x set [2, (_x select 2) + count _a]; - - } forEach _rotaryAssets; - } forEach _homes; + _a = _home nearEntities [ _x select 1, 750]; + _x set [2, (_x select 2) + count _a]; - missionNamespace setVariable ["milsim_var_rotaryAssets", _rotaryAssets]; + } forEach _fixedAssets; +} forEach _homes; - publicVariable "milsim_var_fixedAssets"; - publicVariable "milsim_var_rotaryAssets"; - - // Initializes the Dynamic Groups framework and groups - ["Initialize", [true]] call BIS_fnc_dynamicGroups; +missionNamespace setVariable ["milsim_var_fixedAssets", _fixedAssets]; - missionNamespace setVariable["milsim_raw_cps", 0]; - missionNamespace setVariable["milsim_cps", 0]; - - publicVariable "milsim_raw_cps"; - publicVariable "milsim_cps"; +{ + _home = _x; + { + _a = _home nearEntities [ _x select 1, 750]; + _x set [2, (_x select 2) + count _a]; + + } forEach _rotaryAssets; +} forEach _homes; + +missionNamespace setVariable ["milsim_var_rotaryAssets", _rotaryAssets]; - _cpsPFH = [ - { +publicVariable "milsim_var_fixedAssets"; +publicVariable "milsim_var_rotaryAssets"; - [] spawn { - // warning: while loop without suspension executes multiple times per frame - private _counter = 0; - private _endTime = diag_tickTime + 5; - private _frameNo = diag_frameNo; - while { diag_tickTime < _endTime } do - { - _counter = _counter + 1; - }; - // in an empty mission, the _counter may go well over 2000 times per frame! - diag_log text format ["[MILSIM] (initServer) Average Server Execution: %1 times per frame", _counter / (diag_frameNo - _frameNo)]; - missionNamespace setVariable["milsim_raw_cps", _counter / (diag_frameNo - _frameNo)]; - publicVariable "milsim_raw_cps"; - - // with suspension - private _counter = 0; - private _endTime = diag_tickTime + 5; - private _frameNo = diag_frameNo; - while { diag_tickTime < _endTime } do - { - _counter = _counter + 1; - uiSleep 0.001; // waits at least 1 frame - }; - // _counter says one per frame, as expected - diag_log text format ["[MILSIM] (initServer) Average Server Execution: %1 times per frame", _counter / (diag_frameNo - _frameNo)]; - missionNamespace setVariable["milsim_cps", _counter / (diag_frameNo - _frameNo)]; - publicVariable "milsim_cps"; - - ["milsim_serverEfficiency", [ [ ["float", "milsim_raw_cps", missionNamespace getVariable ["milsim_raw_cps", -1]], ["float", "milsim_cps", missionNamespace getVariable ["milsim_cps", -1]] ] ] ] call CBA_fnc_localEvent; - - }; - - }, - 300, - [], - { diag_log text "[MILSIM] (initServer) CPS PFH loaded" }, - { diag_log text "IF YOU SEE THIS CPS PFH FUCKED UP" }, - { true }, - { false }, - [] - ] call CBA_fnc_createPerFrameHandlerObject; +// Initializes the Dynamic Groups framework and groups +["Initialize", [true]] call BIS_fnc_dynamicGroups; - missionNamespace setVariable ["milsim_cps_handler", _cpsPFH]; - _playerCpsPFH = [ - { +missionNamespace setVariable ["milsim_complete", true]; +diag_log text "[MILSIM] (initServer) milsim_complete: version 2.3"; - diag_log text "[MILSIM] (initServer) ** Player Executions **"; - - { - diag_log ( format ["%1: ( %2, %3 )", name _x, _x getVariable ["milsim_player_raw_cps",-1], _x getVariable ["milsim_player_cps",-1] ] ) - } forEach allPlayers; - - diag_log text "[MILSIM] (initServer) ***********************"; - - }, - 300, - [], - { diag_log text "[MILSIM] (initServer) Player CPS PFH loaded" }, - { diag_log text "IF YOU SEE THIS CPS PFH FUCKED UP" }, - { true }, - { false }, - [] - ] call CBA_fnc_createPerFrameHandlerObject; - - missionNamespace setVariable ["milsim_player_cps_handler", _playerCpsPFH]; - - - missionNamespace setVariable ["milsim_complete", true]; - diag_log text "[MILSIM] (initServer) milsim_complete"; - - publicVariable "milsim_complete"; - -}; \ No newline at end of file +publicVariable "milsim_complete"; diff --git a/functions/intel/fn_initFBCB2.sqf b/functions/intel/fn_initFBCB2.sqf deleted file mode 100644 index 968f372..0000000 --- a/functions/intel/fn_initFBCB2.sqf +++ /dev/null @@ -1,8 +0,0 @@ -waitUntil {player == player && !isNil "milsim_complete"}; - -[] spawn milsim_fnc_MDS_callsigns; -[] spawn milsim_fnc_MDS_fixedAssets; -[] spawn milsim_fnc_MDS_rotaryAssets; -[] spawn milsim_fnc_MDS_radioFrequencies; -[] spawn milsim_fnc_MDS_smokeColors; -[] spawn milsim_fnc_MDS_environment; diff --git a/functions/map/fn_initMapCopy.sqf b/functions/map/fn_initMapCopy.sqf new file mode 100644 index 0000000..7e60c51 --- /dev/null +++ b/functions/map/fn_initMapCopy.sqf @@ -0,0 +1,17 @@ +_map_copy_condition = +{ + ('ItemMap' in (assignedItems _player)) && ('ItemMap' in (assignedItems _target)) && ([_player, _target, []] call ace_common_fnc_canInteractWith) +}; + +_map_copy_action = +[ + "MilSimCopyMap", + "Copy Map", + "\a3\ui_f\data\igui\cfg\actions\talk_ca.paa", + { + [_target,_player] call milsim_fnc_copyMapFromPlayer + }, + _map_copy_condition +] call ace_interact_menu_fnc_createAction; + +["Man", 0, ["ACE_MainActions"], _map_copy_action, true] call ace_interact_menu_fnc_addActionToClass; \ No newline at end of file diff --git a/functions/resupply/fn_createAmmoBox.sqf b/functions/resupply/fn_createAmmoBox.sqf index 29903d3..2e3f319 100644 --- a/functions/resupply/fn_createAmmoBox.sqf +++ b/functions/resupply/fn_createAmmoBox.sqf @@ -108,4 +108,4 @@ _weapons = [ [_box,1] call ace_cargo_fnc_setSize; -true; +true; \ No newline at end of file diff --git a/functions/resupply/fn_createMedicalBox.sqf b/functions/resupply/fn_createMedicalBox.sqf index b149db9..4ee057c 100644 --- a/functions/resupply/fn_createMedicalBox.sqf +++ b/functions/resupply/fn_createMedicalBox.sqf @@ -83,4 +83,4 @@ _weapons = []; [_box,1] call ace_cargo_fnc_setSize; -true; +true; \ No newline at end of file diff --git a/functions/resupply/fn_createWeaponsBox.sqf b/functions/resupply/fn_createWeaponsBox.sqf index dd25c58..c5141d7 100644 --- a/functions/resupply/fn_createWeaponsBox.sqf +++ b/functions/resupply/fn_createWeaponsBox.sqf @@ -79,4 +79,4 @@ _weapons = []; [_box,1] call ace_cargo_fnc_setSize; -true; +true; \ No newline at end of file diff --git a/functions/server/fn_addServerStatsPFH.sqf b/functions/server/fn_addServerStatsPFH.sqf new file mode 100644 index 0000000..237c171 --- /dev/null +++ b/functions/server/fn_addServerStatsPFH.sqf @@ -0,0 +1,50 @@ +if (!isServer) exitWith {}; + +missionNamespace setVariable["milsim_raw_cps", 0]; +missionNamespace setVariable["milsim_cps", 0]; + +publicVariable "milsim_raw_cps"; +publicVariable "milsim_cps"; + +diag_log text format ["[MILSIM] (server) initializing Server Stats PFH"]; + +_serverCpsPFH = [ + { + [] call milsim_fnc_calculateServerStats; + }, + "milsim_server_cps_interval" call CBA_settings_fnc_get, + [], + { diag_log text format ["[MILSIM] (server) Server PFH loaded with interval %1 seconds", "milsim_server_cps_interval" call CBA_settings_fnc_get ] }, + { diag_log text format ["[MILSIM] (server) Server PFH unloaded"] }, + { "milsim_server_cps_enable" call CBA_settings_fnc_get }, + { false }, + [] +] call CBA_fnc_createPerFrameHandlerObject; + + +missionNamespace setVariable ["milsim_server_cps_handler", _serverCpsPFH]; + +_playerCpsPFH = [ + { + + diag_log text "[MILSIM] (server) ** Player Executions **"; + + { + diag_log ( format ["%1: ( %2, %3 )", name _x, _x getVariable ["milsim_player_raw_cps",-1], _x getVariable ["milsim_player_cps",-1] ] ) + } forEach allPlayers; + + diag_log text "[MILSIM] (server) ***********************"; + + }, + "milsim_server_cps_interval" call CBA_settings_fnc_get, + [], + { diag_log text format ["[MILSIM] (server) Player PFH loaded"] }, + { diag_log text format ["[MILSIM] (server) Player PFH unloaded"] }, + { "milsim_server_cps_enable" call CBA_settings_fnc_get }, + { false }, + [] +] call CBA_fnc_createPerFrameHandlerObject; + +missionNamespace setVariable ["milsim_player_cps_handler", _playerCpsPFH]; + +nil; diff --git a/functions/server/fn_calculateServerStats.sqf b/functions/server/fn_calculateServerStats.sqf new file mode 100644 index 0000000..5f58b67 --- /dev/null +++ b/functions/server/fn_calculateServerStats.sqf @@ -0,0 +1,34 @@ +[] spawn { + // warning: while loop without suspension executes multiple times per frame + private _counter = 0; + private _endTime = diag_tickTime + 5; + private _frameNo = diag_frameNo; + while { diag_tickTime < _endTime } do + { + _counter = _counter + 1; + }; + + diag_log text format ["[MILSIM] (server) Average Server Execution: %1 times per frame", _counter / (diag_frameNo - _frameNo)]; + + missionNamespace setVariable ["milsim_raw_cps", _counter / (diag_frameNo - _frameNo)]; + publicVariable "milsim_raw_cps"; + + // with suspension + private _counter = 0; + private _endTime = diag_tickTime + 5; + private _frameNo = diag_frameNo; + while { diag_tickTime < _endTime } do + { + _counter = _counter + 1; + uiSleep 0.001; // waits at least 1 frame + }; + + diag_log text format ["[MILSIM] (server) Average Server Execution: %1 times per frame", _counter / (diag_frameNo - _frameNo)]; + + missionNamespace setVariable ["milsim_cps", _counter / (diag_frameNo - _frameNo)]; + publicVariable "milsim_cps"; + + ["milsim_serverEfficiency", [ [ ["float", "milsim_raw_cps", missionNamespace getVariable ["milsim_raw_cps", -1]], ["float", "milsim_cps", missionNamespace getVariable ["milsim_cps", -1]] ] ] ] call CBA_fnc_localEvent; +}; + +nil; \ No newline at end of file diff --git a/functions/settings/fn_addAARChatHandler.sqf b/functions/settings/fn_addAARChatHandler.sqf new file mode 100644 index 0000000..b419a0e --- /dev/null +++ b/functions/settings/fn_addAARChatHandler.sqf @@ -0,0 +1,11 @@ +[ + "saveaar", + { + [] remoteExec["ocap_fnc_exportData", 2]; + }, + "admin" +] call CBA_fnc_registerChatCommand; + +diag_log text "[MILSIM] (settings) OCAP chat handler registered"; + +nil; \ No newline at end of file diff --git a/functions/settings/fn_addCBASettings.sqf b/functions/settings/fn_addCBASettings.sqf new file mode 100644 index 0000000..73395d2 --- /dev/null +++ b/functions/settings/fn_addCBASettings.sqf @@ -0,0 +1,110 @@ +//--------------------- +// Side Chat +//--------------------- + +[ + "milsim_sideChat", + "CHECKBOX", + "Side Chat Text Enabled", + ["17th Batallion", "Side Chat"], + false, + true, + { + params ["_value"]; + diag_log format["side chat activation set to %1", _value]; + } +] call CBA_fnc_addSetting; + +["milsim_sideChat", false] call CBA_settings_fnc_set; + +//--------------------- +// Server CPS +//--------------------- + +[ + "milsim_server_cps_enable", + "CHECKBOX", + "CPS Metrics Enabled", + ["17th Batallion", "Server Metrics"], + true, + true, + { + params ["_value"]; + diag_log format["server cps activation set to %1", _value]; + } +] call CBA_fnc_addSetting; + +["milsim_server_cps_enable", true] call CBA_settings_fnc_set; + +[ + "milsim_server_cps_interval", + "TIME", + "Metrics Interval", + ["17th Batallion", "Server Metrics"], + [60,300,120], + true, + { + if (!isServer) exitWith {}; + + params ["_value"]; + diag_log format["server cps interval set to %1", _value]; + _cpsPFH = missionNamespace getVariable ["milsim_server_cps_handler", ObjNull]; + if (!isNull _cpsPFH) then { + _cpsPFH call CBA_fnc_deletePerFrameHandlerObject; + }; + + _playerCpsPFH = missionNamespace getVariable ["milsim_player_cps_handler", ObjNull]; + if (!isNull _playerCpsPFH) then { + _playerCpsPFH call CBA_fnc_deletePerFrameHandlerObject; + }; + + [] call milsim_fnc_addServerStatsPFH; + + } +] call CBA_fnc_addSetting; + +//--------------------- +// Client CPS +//--------------------- + +[ + "milsim_client_cps_enable", + "CHECKBOX", + "CPS Metrics Enabled", + ["17th Batallion", "Client Metrics"], + true, + true, + { + params ["_value"]; + diag_log format["client cps activation set to %1", _value]; + } +] call CBA_fnc_addSetting; + +["milsim_client_cps_enable", true] call CBA_settings_fnc_set; + +[ + "milsim_client_cps_interval", + "TIME", + "CPS Metrics Interval", + ["17th Batallion", "Client Metrics"], + [60,300,120], + true, + { + if (!hasInterface) exitWith {}; + + params ["_value"]; + diag_log format["client cps interval set to %1", _value]; + _cpsPFH = player getVariable ["milsim_client_cps_handler", ObjNull]; + if (!isNull _cpsPFH) then { + _cpsPFH call CBA_fnc_deletePerFrameHandlerObject; + }; + + [] call milsim_fnc_addClientStatsPFH; + + } +] call CBA_fnc_addSetting; + + +diag_log text "[MILSIM] (settings) Custom CBA settings initialized"; + +nil; \ No newline at end of file diff --git a/functions/settings/fn_addRespawnChatHandler.sqf b/functions/settings/fn_addRespawnChatHandler.sqf new file mode 100644 index 0000000..fa87a52 --- /dev/null +++ b/functions/settings/fn_addRespawnChatHandler.sqf @@ -0,0 +1,15 @@ +[ + "respawn", + { + _clientID = _thisArgs select 0; + player setDamage 1; + format["[MILSIM] (init) %1 claims they were glitched and respawned - %2", name player, netID player] remoteExec["diag_log", 2]; + format["%1 claims they were glitched and respawned (%2)", name player, netID player] remoteExec["systemChat", -_clientID]; + }, + "all", + [clientOwner] +] call CBA_fnc_registerChatCommand; + +diag_log text "[MILSIM] (settings) respawn chat handler registered"; + +nil; \ No newline at end of file diff --git a/functions/settings/fn_setDefaults.sqf b/functions/settings/fn_setDefaults.sqf new file mode 100644 index 0000000..2302972 --- /dev/null +++ b/functions/settings/fn_setDefaults.sqf @@ -0,0 +1,19 @@ +enableSaving[false, false]; + +enableRadio false; +enableSentences false; + +missionNamespace setVariable ["ACE_maxWeightDrag", 2400]; +missionNamespace setVariable ["ACE_maxWeightCarry", 1800]; + +if(isClass(configfile >> "CfgPatches" >> "rhs_main")) then { + rhs_vehicleRadioChatter = 0; +}; + +waitUntil {time > 0}; + +enableEnvironment[false, true]; + +diag_log text "[MILSIM] (settings) defaults set"; + +nil; \ No newline at end of file