From 3f5c6c5a59b281d41e6980183d3faf2f5a420550 Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Fri, 2 Feb 2024 01:06:43 -0800 Subject: [PATCH 01/16] WIP: add asset diary pages --- description.ext | 1 + functions/CfgFunctions.hpp | 19 ++ functions/definitions/ApprovedAssets.hpp | 22 +++ .../assets/byBase/fn_getAssetsByBase.sqf | 4 + .../byBase/fn_getStartingAssetsByBase.sqf | 4 + .../assets/byBase/fn_updateAssetsByBase.sqf | 15 ++ functions/fbcb2/assets/fn_getInventory.sqf | 123 +++++++++++++ .../fbcb2/assets/fn_getMagsForWeapon.sqf | 80 +++++++++ functions/fbcb2/assets/fn_getVehicleData.sqf | 166 ++++++++++++++++++ functions/fbcb2/assets/fn_getWeaponry.sqf | 55 ++++++ .../fbcb2/assets/fn_removeMarkersOnMap.sqf | 13 ++ .../fbcb2/assets/fn_showMarkersOnMap.sqf | 38 ++++ .../fbcb2/assets/fn_updateAssetDiary.sqf | 119 +++++++++++++ functions/fbcb2/fn_initFBCB2.sqf | 3 + .../fbcb2/fn_processFBCB2FixedWingAssets.sqf | 2 +- .../util/fn_createOrUpdateDiaryRecord.sqf | 12 +- functions/init/fn_initServer.sqf | 56 +----- functions/reinsert/fn_getNearestBase.sqf | 2 +- functions/reinsert/server/fn_initServer.sqf | 4 +- 19 files changed, 682 insertions(+), 56 deletions(-) create mode 100644 functions/definitions/ApprovedAssets.hpp create mode 100644 functions/fbcb2/assets/byBase/fn_getAssetsByBase.sqf create mode 100644 functions/fbcb2/assets/byBase/fn_getStartingAssetsByBase.sqf create mode 100644 functions/fbcb2/assets/byBase/fn_updateAssetsByBase.sqf create mode 100644 functions/fbcb2/assets/fn_getInventory.sqf create mode 100644 functions/fbcb2/assets/fn_getMagsForWeapon.sqf create mode 100644 functions/fbcb2/assets/fn_getVehicleData.sqf create mode 100644 functions/fbcb2/assets/fn_getWeaponry.sqf create mode 100644 functions/fbcb2/assets/fn_removeMarkersOnMap.sqf create mode 100644 functions/fbcb2/assets/fn_showMarkersOnMap.sqf create mode 100644 functions/fbcb2/assets/fn_updateAssetDiary.sqf diff --git a/description.ext b/description.ext index 5b61555..232b61e 100644 --- a/description.ext +++ b/description.ext @@ -19,6 +19,7 @@ #include "mission_settings.hpp" #include "functions\definitions\DisallowedEquipment.hpp" #include "functions\definitions\BattalionInfo.hpp" +#include "functions\definitions\ApprovedAssets.hpp" //-------------------------------------------MISSION INFO-------------------------------------------------------------------- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/functions/CfgFunctions.hpp b/functions/CfgFunctions.hpp index f7d3fb2..b4f2ab8 100644 --- a/functions/CfgFunctions.hpp +++ b/functions/CfgFunctions.hpp @@ -88,6 +88,25 @@ class milsim }; }; +class milsim_fbcb2_assets { + class functions { + file = "functions\fbcb2\assets"; + class updateAssetDiary {}; + class getMagsForWeapon {}; + class getWeaponry {}; + class getInventory {}; + class getVehicleData {}; + class showMarkersOnMap {}; + class removeMarkersOnMap {}; + }; + class assetsByBase { + file = "functions\fbcb2\assets\byBase"; + class getAssetsByBase {}; + class getStartingAssetsByBase {}; + class updateAssetsByBase {}; + }; +}; + class milsim_reinsert { class functions { file = "functions\reinsert"; diff --git a/functions/definitions/ApprovedAssets.hpp b/functions/definitions/ApprovedAssets.hpp new file mode 100644 index 0000000..b9af09e --- /dev/null +++ b/functions/definitions/ApprovedAssets.hpp @@ -0,0 +1,22 @@ +// Lists approved fixed-wing and rotary vehicle types that mission makers can use in their missions. + +class ApprovedAssets { + // Fixed-wing aircraft + class USAF_A10 {callsign = "Ares";assetType = "FixedWing";}; + class RHSGREF_A29B_HIDF {callsign = "Odyssey";assetType = "FixedWing";}; + class USAF_C130J {callsign = "Hercules";assetType = "FixedWing";}; + // Rotary aircraft + class RHS_MELB_MH6M {callsign = "Apollo";assetType = "Rotary";}; + class RHS_MELB_AH6M {callsign = "Artemis";assetType = "Rotary";}; + class RHS_MELB_H6M {callsign = "Icarus";assetType = "Rotary";}; + class RHS_CH_47F {callsign = "Achilles";assetType = "Rotary";}; + class ej_MH60MDAP4 {callsign = "Hades";assetType = "Rotary";}; + class RHS_UH60M {callsign = "Griffin";assetType = "Rotary";}; + class RHS_UH60M_MEV2 {callsign = "Dustoff";assetType = "Rotary";}; + class B_T_VTOL_01_INFANTRY_F {callsign = "Pegasus";assetType = "Rotary";}; + class B_T_VTOL_01_ARMED_F {callsign = "Spartan";assetType = "Rotary";}; + class RHS_AH64D {callsign = "Orion";assetType = "Rotary";}; + class RHS_AH1Z {callsign = "Athena";assetType = "Rotary";}; + class RHS_UH1Y {callsign = "Homer";assetType = "Rotary";}; + class rhsusf_CH53E_USMC {callsign = "Atlas";assetType = "Rotary";}; +}; \ No newline at end of file diff --git a/functions/fbcb2/assets/byBase/fn_getAssetsByBase.sqf b/functions/fbcb2/assets/byBase/fn_getAssetsByBase.sqf new file mode 100644 index 0000000..05dcd14 --- /dev/null +++ b/functions/fbcb2/assets/byBase/fn_getAssetsByBase.sqf @@ -0,0 +1,4 @@ +// return each base with its assets +milsim_baseObjects apply { + [_x, _x getVariable ["milsim_fbcb2_assets_assetsAtThisBase", []]] +}; \ No newline at end of file diff --git a/functions/fbcb2/assets/byBase/fn_getStartingAssetsByBase.sqf b/functions/fbcb2/assets/byBase/fn_getStartingAssetsByBase.sqf new file mode 100644 index 0000000..4c83db4 --- /dev/null +++ b/functions/fbcb2/assets/byBase/fn_getStartingAssetsByBase.sqf @@ -0,0 +1,4 @@ +// return each base with its assets +milsim_baseObjects apply { + [_x, _x getVariable ["milsim_fbcb2_assets_assetsStartedAtThisBase", []]] +}; \ No newline at end of file diff --git a/functions/fbcb2/assets/byBase/fn_updateAssetsByBase.sqf b/functions/fbcb2/assets/byBase/fn_updateAssetsByBase.sqf new file mode 100644 index 0000000..e34cdb7 --- /dev/null +++ b/functions/fbcb2/assets/byBase/fn_updateAssetsByBase.sqf @@ -0,0 +1,15 @@ +params [["_isInit", false, [false]]]; + +{ // find approved assets at each base + private _base = _x; + private _baseAssets = _base getVariable ["milsim_fbcb2_assets_assetsAtThisBase", []]; + { + private _className = configName _x; + _a = _base nearEntities [_className, 750]; + _baseAssets append _a; + } forEach ((missionConfigFile >> "ApprovedAssets") call BIS_fnc_returnChildren); + _base setVariable ["milsim_fbcb2_assets_assetsAtThisBase", _baseAssets, true]; + if (_isInit) then { + _base setVariable ["milsim_fbcb2_assets_assetsStartedAtThisBase", _baseAssets, true]; + }; +} forEach milsim_baseObjects; \ No newline at end of file diff --git a/functions/fbcb2/assets/fn_getInventory.sqf b/functions/fbcb2/assets/fn_getInventory.sqf new file mode 100644 index 0000000..13777a0 --- /dev/null +++ b/functions/fbcb2/assets/fn_getInventory.sqf @@ -0,0 +1,123 @@ +params ["_vic"]; + + +_vicDispName = configOf _vic call BIS_fnc_displayName; +private _thisArr = []; + +// _thisArr pushBack getItemCargo _vic; +// _thisArr pushBack getBackpackCargo _vic; +// _thisArr pushBack getMagazineCargo _vic; +// _thisArr pushBack getWeaponCargo _vic; + +private _ItemCargo = []; +private _MagazineCargo = []; +private _WeaponCargo = []; +private _BackpackCargo = []; + +{ + private _config = _x call CBA_fnc_getItemConfig; + _ItemCargo pushBack [ + getText (_config >> "displayName"), + getText (_config >> "picture") + ]; +} forEach ItemCargo _vic; +{ + private _config = _x call CBA_fnc_getItemConfig; + _MagazineCargo pushBack [ + getText (_config >> "displayName"), + getText (_config >> "picture") + ]; +} forEach MagazineCargo _vic; +{ + // private _config = _x call CBA_fnc_getObjectConfig; + _WeaponCargo pushBack [ + getText (configFile >> "CfgWeapons" >> _x >> "displayName"), + getText (configFile >> "CfgWeapons" >> _x >> "picture") + ]; +} forEach WeaponCargo _vic; +{ + private _config = _x call CBA_fnc_getObjectConfig; + _BackpackCargo pushBack [ + getText (_config >> "displayName"), + getText (_config >> "picture") + ]; +} forEach BackpackCargo _vic; + +private _sortedItemCargo = ([_ItemCargo call BIS_fnc_consolidateArray, [], {_x # 0 # 0}] call BIS_fnc_sortBy) select {!(_x # 0 # 0 isEqualTo "")}; +private _sortedMagazineCargo = ([_MagazineCargo call BIS_fnc_consolidateArray, [], {_x # 0 # 0}] call BIS_fnc_sortBy) select {!(_x # 0 # 0 isEqualTo "")}; +private _sortedWeaponCargo = ([_WeaponCargo call BIS_fnc_consolidateArray, [], {_x # 0 # 0}] call BIS_fnc_sortBy) select {!(_x # 0 # 0 isEqualTo "")}; +private _sortedBackpackCargo = ([_BackpackCargo call BIS_fnc_consolidateArray, [], {_x # 0 # 0}] call BIS_fnc_sortBy) select {!(_x # 0 # 0 isEqualTo "")}; + +// "debug_console" callExtension(str _sortedItemCargo + "~0100"); +// "debug_console" callExtension(str _sortedMagazineCargo + "~0100"); +// "debug_console" callExtension(str _sortedWeaponCargo + "~0100"); +// "debug_console" callExtension(str _sortedBackpackCargo + "~0100"); + +if (count _sortedItemCargo > 0) then { + _thisArr pushBack format["Items:"]; + private _itemCargoOut = []; + { + private _name = _x # 0 # 0; + private _pic = _x # 0 # 1; + private _count = _x # 1; + if (_pic == "") then { + _itemCargoOut pushBack format["%3 x%2", _pic, _count, _name]; + } else { + _itemCargoOut pushBack format["x%2", _pic, _count, _name]; + }; + if ((_forEachIndex + 1) mod 6 == 0) then {_itemCargoOut pushBack "
"}; + } forEach _sortedItemCargo; + _thisArr pushBack (_itemCargoOut joinString ""); +}; +if (count _sortedMagazineCargo > 0) then { + _thisArr pushBack format["Magazines:"]; + private _magCargoOut = []; + { + private _name = _x # 0 # 0; + private _pic = _x # 0 # 1; + private _count = _x # 1; + if (_pic == "") then { + _magCargoOut pushBack format["%3 x%2", _pic, _count, _name]; + } else { + _magCargoOut pushBack format["x%2", _pic, _count, _name]; + }; + if ((_forEachIndex + 1) mod 6 == 0) then {_magCargoOut pushBack "
"}; + } forEach _sortedMagazineCargo; + _thisArr pushBack (_magCargoOut joinString ""); +}; +if (count _sortedWeaponCargo > 0) then { + _thisArr pushBack format["Weapons:"]; + private _weaponCargoOut = []; + { + private _name = _x # 0 # 0; + private _pic = _x # 0 # 1; + private _count = _x # 1; + if (_pic == "") then { + _weaponCargoOut pushBack format["%3 x%2", _pic, _count, _name]; + } else { + _weaponCargoOut pushBack format["x%2", _pic, _count, _name]; + }; + if ((_forEachIndex + 1) mod 3 == 0) then {_weaponCargoOut pushBack "
"}; + } forEach _sortedWeaponCargo; + _thisArr pushBack (_weaponCargoOut joinString ""); +}; +if (count _sortedBackpackCargo > 0) then { + _thisArr pushBack format["Backpacks:"]; + private _backpackCargoOut = []; + { + private _name = _x # 0 # 0; + private _pic = _x # 0 # 1; + private _count = _x # 1; + if (_pic == "") then { + _backpackCargoOut pushBack format["%3 x%2", _pic, _count, _name]; + } else { + _backpackCargoOut pushBack format["x%2", _pic, _count, _name]; + }; + if ((_forEachIndex + 1) mod 4 == 0) then {_backpackCargoOut pushBack "
"}; + } forEach _sortedBackpackCargo; + _thisArr pushBack (_backpackCargoOut joinString ""); + // "debug_console" callExtension(str _backpackCargoOut + "~0100"); +}; + +// "debug_console" callExtension(str _thisArr + "~1100"); +_thisArr; \ No newline at end of file diff --git a/functions/fbcb2/assets/fn_getMagsForWeapon.sqf b/functions/fbcb2/assets/fn_getMagsForWeapon.sqf new file mode 100644 index 0000000..dc32c7f --- /dev/null +++ b/functions/fbcb2/assets/fn_getMagsForWeapon.sqf @@ -0,0 +1,80 @@ +params ["_vic", "_path", "_wep", "_magsHere", "_pylons"]; + +if (_path isEqualTo []) then {_path = [-1]}; +// "debug_console" callExtension (_wep + "#0100"); +if (_wep in [ + "rhs_weap_MASTERSAFE", + "rhs_weap_fcs_ammo", + "rhs_weap_laserDesignator_AI", + "rhs_weap_fcs_ah64", + "rhs_weap_DummyLauncher", + "rhs_weap_fcs_nolrf_ammo", + "rhsusf_weap_duke", + "TruckHorn", + "TruckHorn2", + "TruckHorn3" +]) exitWith {[[]]}; + +private _thisArr = []; +_wepConfig = (configFile >> "CfgWeapons" >> _wep); +_wepDisp = [(_wepConfig >> "displayName"), "STRING", "Weapon"] call CBA_fnc_getConfigEntry; +if (_wep == "rhs_weap_smokegen") then {_wepDisp = "Smoke Generator"}; +if (_wepDisp isEqualTo "") exitWith {[[]]}; + +// "debug_console" callExtension (_wepDisp + "#0100"); +_magsToCheck = (_vic magazinesTurret _path); + + +// See if the first default magazine in the config of this weapon is meant to be used on a pylon. If so, process differently +// _mag1pylonWeapon = ""; +// _magsConfigArr = [(_wepConfig >> "magazines"), "ARRAY", []] call CBA_fnc_getConfigEntry; +// if (_magsConfigArr isEqualTo []) then { +// _mag1pylonWeapon = ""; +// } else { +// _mag1Name = _magsConfigArr # 0; +// _mag1pylonWeapon = [(configFile >> "CfgMagazines" >> _mag1Name >> "pylonWeapon"), "STRING", ""] call CBA_fnc_getConfigEntry; +// }; + +_pylonMagNames = _pylons apply {_x # 3}; + +_compatMagsRef = [_wepConfig, true] call CBA_fnc_compatibleMagazines; +_magsFound = _compatMagsRef select {_magsToCheck find _x != -1}; + +private _magsArr = []; + +if (!((_magsFound # 0) in _pylonMagNames)) then { + // Not a pylon weapon, so check mags in turret storage + _thisArr pushBack format[" %1", _wepDisp]; + { + _thisMag = _x; + _magAmmo = _vic magazineTurretAmmo [_x, _path]; + _magCount = (_magsHere select {_x # 0 == _thisMag} apply {_x # 1}) # 0; + + private _magConfig = (configFile >> "CfgMagazines" >> _thisMag); + private _magName = [(_magConfig >> "displayName"), "STRING", "Magazine"] call CBA_fnc_getConfigEntry; + if (_magName isEqualTo "") then {_magName = "Magazine"}; + + + + _magsArr pushBack format[ + " + %1 | %2 rounds | %3 mags", + _magName, + _magAmmo, + _magCount + ]; + } forEach _magsFound; +} else { + // This is a pylon weapon, so make a unique entry and directly check ammo on pylon + _thisArr pushBack format[" %1 [Pylon]", _wepDisp]; +}; + +_thisArr pushBack _magsArr; +// "debug_console" callExtension (str _magsArr + "#0100"); +_thisArr; +// _thisArr; +// "debug_console" callExtension (format[ +// " %1 | %2 rounds | %3 mags#0110", +// getText(configFile >> "CfgMagazines" >> _thisMag >> "displayName"), +// _magAmmo, +// _magCount +// ]); \ No newline at end of file diff --git a/functions/fbcb2/assets/fn_getVehicleData.sqf b/functions/fbcb2/assets/fn_getVehicleData.sqf new file mode 100644 index 0000000..d7ba851 --- /dev/null +++ b/functions/fbcb2/assets/fn_getVehicleData.sqf @@ -0,0 +1,166 @@ +params ["_vic"]; + +private _title = []; +private _image = []; +private _info = []; +private _capacity = []; + +// Excluded 2024-02-01 +// private _weapons = []; +// private _pylonWeapons = []; +// private _inventory = []; + + +private _vicConfig = configOf _vic; +private _class = configName _vicConfig; +private _objType = (_vic call BIS_fnc_objectType) select 1; +private _dispName = getText(_vicConfig >> 'displayName'); + +// "debug_console" callExtension (format["VehicleName = %1", _dispName] + "#0110"); + +private _cat = getText(_vicConfig >> 'category'); +private _fac = getText(_vicConfig >> 'faction'); +private _side = [getNumber(_vicConfig >> 'side')] call BIS_fnc_sideName; +private _canFloat = (_vicConfig >> "canFloat") call BIS_fnc_getCfgDataBool; + +private _totalSeats = [_class, true] call BIS_fnc_crewCount; // Number of total seats: crew + non-FFV cargo/passengers + FFV cargo/passengers +private _crewSeats = [_class, false] call BIS_fnc_crewCount; // Number of crew seats only +private _driverSeats = fullcrew [_vic, "driver", true]; +private _gunnerSeats = fullCrew [_vic, "gunner", true]; +private _commanderSeats = fullCrew [_vic, "commander", true]; +// _cargoSeats = fullCrew [_vic, "cargo", true]; +private _cargoSeats = _totalSeats - _crewSeats; // Number of total cargo/passenger seats: non-FFV + FFV +private _turretSeatsRaw = fullCrew [_vic, "turret", true]; +private _turretSeats = _turretSeatsRaw select {(_x # 4) isEqualTo false}; +private _ffvSeats = _turretSeatsRaw select {(_x # 4) isEqualTo true}; + +private _pylons = getAllPylonsInfo _vic; + +/////////////////////////////////////////////// +// WRITE TITLE +/////////////////////////////////////////////// +_title pushBack format["%1", _dispName]; + +/////////////////////////////////////////////// +// WRITE IMAGE +/////////////////////////////////////////////// +// Editor preview image +_image pushBack format["", getText(_vicConfig >> 'editorPreview')]; +_image pushBack linebreak; +// Thumbnail image +// _image pushBack format["", getText(_vicConfig >> 'picture')]; +// _image pushBack linebreak; + +/////////////////////////////////////////////// +// WRITE INFO +/////////////////////////////////////////////// +_info pushBack format["INFO"]; +_info pushBack format[" Classname: %1", _class]; +_info pushBack format[" Side: %1", _side]; +_info pushBack format[" Category: %1", _objType]; +_info pushBack format[" Faction: %1", _fac]; +_info pushBack format[" Can Float: %1", _canFloat]; + +/////////////////////////////////////////////// +// WRITE CAPACITY +/////////////////////////////////////////////// +_capacity pushBack format["CAPACITY: %1", _totalSeats]; +_capacity pushBack format[" Driver Seats: %1", count _driverSeats]; +_capacity pushBack format[" Gunner Seats: %1", count _gunnerSeats]; +_capacity pushBack format[" Commander Seats: %1", count _commanderSeats]; +_capacity pushBack format[" Turret Seats: %1", count _turretSeats]; +_capacity pushBack format[" Cargo Seats: %1", _cargoSeats]; +_capacity pushBack format[" FFV Seats: %1", count _ffvSeats]; + +/////////////////////////////////////////////// +// GATHER WEAPONS AVAILABLE TO SEATS AND TURRETS +// EXCLUDED 2024-02-01 +/////////////////////////////////////////////// +// _weapons pushBack format["WEAPONS"]; +// // DRIVER +// [_driverSeats apply {_x # 3}, "DRIVER/PILOT", _weapons] call milsim_fbcb2_assets_fnc_getWeaponry; + +// //GUNNER +// [_gunnerSeats apply {_x # 3}, "GUNNER/COPILOT", _weapons] call milsim_fbcb2_assets_fnc_getWeaponry; + +// // COMMANDER +// // "debug_console" callExtension ("COMMANDER" + "#1100"); +// [_commanderSeats apply {_x # 3}, "COMMANDER", _weapons] call milsim_fbcb2_assets_fnc_getWeaponry; + +// // TURRETS +// [_turretSeats apply {_x # 3}, "TURRET", _weapons] call milsim_fbcb2_assets_fnc_getWeaponry; + +/////////////////////////////////////////////// +// GATHER PYLON WEAPONS WITH AMMO +// EXCLUDED 2024-02-01 +/////////////////////////////////////////////// + +// _pilotWeps = []; +// _otherWeps = []; + +// _parsePylonWeapons = { +// params ["_input"]; +// _input params ["_index", "_name", "_turretPath", "_magazine","_ammoCount","_id"]; +// // "debug_console" callExtension (str _turretPath + "~0000"); + +// _magName = getText(configFile >> "CfgMagazines" >> _magazine >> "displayName"); +// if (_magName isEqualTo "") exitWith {}; + +// if (_turretPath isEqualTo [-1]) then { +// _pilotWeps pushBack format[ +// " %1 | %2 rounds", +// _magName, +// _ammoCount +// ]; +// } else { +// _otherWeps pushBack format[ +// " %1 | %2 rounds", +// _magName, +// _ammoCount +// ]; +// }; +// }; + +/////////////////////////////////////////////// +// WRITE PYLON WEAPONS +/////////////////////////////////////////////// + +// if (count _pylons > 0) then { +// _pylonWeapons pushBack format["PYLON WEAPONS"]; +// { +// [_x] call _parsePylonWeapons; +// } forEach _pylons; +// _pylonWeapons pushBack format[" PILOT"]; +// { +// _pylonWeapons pushBack _x; +// } forEach _pilotWeps; +// _pylonWeapons pushBack format[" GUNNER"]; +// { +// _pylonWeapons pushBack _x; +// } forEach _otherWeps; +// }; + +/////////////////////////////////////////////// +// GATHER INVENTORY +// EXCLUDED 2024-02-01 +/////////////////////////////////////////////// +// _invLines = [_vic] call milsim_fbcb2_assets_fnc_getInventory; +// if (count _invLines > 0) then { +// _inventory pushBack format["INVENTORY"]; +// _inventory append _invLines; +// }; + + +/////////////////////////////////////////////// +// CLOSE AND RETURN +/////////////////////////////////////////////// + +[_vicConfig, _dispName, [ + _title joinString "
", + _image joinString "
", + _info joinString "
", + _capacity joinString "
" + // _weapons joinString "
", + // _pylonWeapons joinString "
", + // _inventory joinString "
" +]]; \ No newline at end of file diff --git a/functions/fbcb2/assets/fn_getWeaponry.sqf b/functions/fbcb2/assets/fn_getWeaponry.sqf new file mode 100644 index 0000000..06be3d2 --- /dev/null +++ b/functions/fbcb2/assets/fn_getWeaponry.sqf @@ -0,0 +1,55 @@ +params ["_turretPaths", "_seatCategory", "_outArr"]; +{ + _path = _x; + if (_path isEqualTo []) then {_path = [-1]}; + _weps = _vic weaponsTurret _path; + private _thisArr = []; + if (count _weps isNotEqualTo 0) then { + _magsHere = _vic magazinesTurret _path call BIS_fnc_consolidateArray; + + private _wepMags = []; + { + private _wepDet = [_vic, _path, _x, _magsHere, _pylons] call milsim_fbcb2_assets_fnc_getMagsForWeapon; + if (!(_wepDet isEqualTo [[]])) then { + _wepMags pushBack _wepDet; + }; + } forEach _weps; + + if (count _wepMags > 0) then { + // "debug_console" callExtension (format["_wepMags Driver = %1", [_wepMags] call CBA_fnc_encodeJSON] + "#1100"); + { + _thisArr pushBack _x # 0; + if (count _x > 1) then { + { + _thisArr pushBack _x; + } forEach (_x # 1); + } + } forEach _wepMags; + }; + };// else { + // "debug_console" callExtension (format["Running Mags Only."] + "#1100"); + // "debug_console" callExtension (format["Vic: %1",_vic] + "#1100"); + // "debug_console" callExtension (format["Path: %1", _path] + "#1100"); + // _mags = ([_vic, _path] call _getMags); + + // if (count _mags > 0) then { + // { + // _thisArr pushBack _x; + // } forEach _mags; + // }; + // }; + + if (count _thisArr > 0) then { + private _turretConfig = [_vic, _x] call BIS_fnc_turretConfig; + private _turretDisplayName = [_turretConfig] call BIS_fnc_displayName; + if (_turretDisplayName != "") then { + _outArr pushBack format[" %1 (""%2"")", _seatCategory, _turretDisplayName]; + } else { + _outArr pushBack format[" %1", _seatCategory]; + }; + + { + _outArr pushBack _x; + } forEach _thisArr; + } +} forEach _turretPaths; \ No newline at end of file diff --git a/functions/fbcb2/assets/fn_removeMarkersOnMap.sqf b/functions/fbcb2/assets/fn_removeMarkersOnMap.sqf new file mode 100644 index 0000000..07051c1 --- /dev/null +++ b/functions/fbcb2/assets/fn_removeMarkersOnMap.sqf @@ -0,0 +1,13 @@ +private _assetMarkerStore = localNamespace getVariable [ + "milsim_fbcb2_assets_markerStore", + [] +]; + +{ + deleteMarkerLocal _x; +} forEach _assetMarkerStore; + +localNamespace setVariable [ + "milsim_fbcb2_assets_markerStore", + [] +]; \ No newline at end of file diff --git a/functions/fbcb2/assets/fn_showMarkersOnMap.sqf b/functions/fbcb2/assets/fn_showMarkersOnMap.sqf new file mode 100644 index 0000000..7f2b1e8 --- /dev/null +++ b/functions/fbcb2/assets/fn_showMarkersOnMap.sqf @@ -0,0 +1,38 @@ +params [ + ["_className", "", [""]], + ["_markerType", "hd_dot", [""]], + ["_markerColor", "", [""]], + ["_positions", [], []] +]; + +if (count _className isEqualTo 0) exitWith { + ["No class name provided!"] call BIS_fnc_error; +}; +if (count _markerColor isEqualTo 0) exitWith { + ["No marker color provided!"] call BIS_fnc_error; +}; +if (count _positions isEqualTo 0) exitWith { + ["No positions provided!"] call BIS_fnc_error; +}; + +private _assetMarkerStore = localNamespace getVariable [ + "milsim_fbcb2_assets_markerStore", + [] +]; + +private _start = (count _assetMarkerStore) + 1; +{ + _position = _x; + _newMarker = createMarkerLocal [ + format["milsim_fbcb2_assets_marker_%1", _start], + _position + ]; + _newMarker setMarkerTypeLocal _markerType; + _newMarker setMarkerColorLocal _markerColor; + _newMarker setMarkerTextLocal str(_start); + + _assetMarkerStore pushBack _newMarker; + _start = _start + 1; +} forEach _positions; + +localNamespace setVariable ["milsim_fbcb2_assets_markerStore", _assetMarkerStore]; diff --git a/functions/fbcb2/assets/fn_updateAssetDiary.sqf b/functions/fbcb2/assets/fn_updateAssetDiary.sqf new file mode 100644 index 0000000..e729efb --- /dev/null +++ b/functions/fbcb2/assets/fn_updateAssetDiary.sqf @@ -0,0 +1,119 @@ +// create diary records + +private _vehiclesByBase = call milsim_fbcb2_assets_fnc_getAssetsByBase; +if (count _vehiclesByBase isEqualTo 0) exitWith {false}; +private _vehicles = []; +{ + _vehicles append (_x#1); +} forEach _vehiclesByBase; + +if (count _vehicles isEqualTo 0) exitWith {false}; +private _distinctVehiclesClassNames = []; +{ + _distinctVehiclesClassNames pushBackUnique (typeOf _x); +} forEach _vehicles; + + +// ForEach unique vehicle class name, we'll find the first and gather its info +{ + private _className = _x; + private _vehiclesOfThisKind = _vehicles select {typeOf _x isEqualTo _className}; + // This should never happen, but... + if (count _vehiclesOfThisKind isEqualTo 0) then {continue}; + + // Take the first vehicle as a representative + private _representativeVehicle = _vehiclesOfThisKind#0; + private _vehicleCfg = configOf _representativeVehicle; + + // Process the vehicle for extended info + // Exclusion list for display names + if ( + ((configOf _representativeVehicle) call BIS_fnc_displayName) + in ["Helicopter"] + ) then {continue}; + + // Get the vehicle data + private _processed = [_representativeVehicle] call milsim_fbcb2_assets_fnc_getVehicleData; + + if (isNil "_processed") then {continue}; + _processed params ["_vehicleCfg", "_displayName", "_diaryTextSections"]; + _diaryTextSections params [ + "_title", + "_image", + "_info", + "_capacity" + // "_weapons", + // "_pylonWeapons", + // "_inventory" + ]; + + // Create the diary record + private _recordText = []; + // Add the title and image + _recordText pushBack _title; + _recordText pushBack _image; + _recordText pushBack "
"; + _recordText pushBack format[ + "COUNT ACTIVE: %1", + count _vehiclesOfThisKind + ]; + + // Here, we'll create a link to show markers on the map for all vehicles of this kind + private _randomColor = selectRandom [ + ["ColorRed", "#FF0000", "Red"], + ["ColorGreen", "#00FF00", "Green"], + ["ColorBlue", "#0000FF", "Blue"], + ["ColorYellow", "#FFFF00", "Yellow"], + ["ColorWhite", "#FFFFFF", "White"] + ]; + private _vehicleCfg = configFile >> "CfgVehicles" >> _className; + // get 'picture' for record + private _icon = getText(_vehicleCfg >> "picture"); + // determine marker type + private _markerType = "mil_dot"; + switch (true) do { + case (_representativeVehicle isKindOf "Helicopter"): { + _markerType = "loc_heli"; + }; + case (_representativeVehicle isKindOf "Air"): { + _markerType = "loc_plane"; + }; + default { + _markerType = "loc_truck"; + }; + }; + + _recordText pushBack format[ + "SHOW MARKERS at vehicle positions (in %5)", + _className, + _markerType, + _randomColor#0, + (_vehiclesOfThisKind apply {getPosASL _x}), + format["%2", _randomColor#1, _randomColor#2] + ]; + + // Link to hide markers + _recordText pushBack "REMOVE ALL MARKERS showing asset positions" + "
"; + + // Link to update asset diary entries + _recordText pushBack "UPDATE ENTRIES for all assets" + "
"; + + // Add info and capacity sections + _recordText pushBack _info; + _recordText pushBack _capacity; + + [ + milsim_fbcb2_subjectAssetsID, + format[ + "%1x %2", + count _vehiclesOfThisKind, + (configOf _representativeVehicle) call BIS_fnc_displayName + ], + _recordText joinString "
", + _icon + ] call milsim_fnc_createOrUpdateDiaryRecord; + +// "\A3\ui_f\data\igui\cfg\simpleTasks\types\car_ca.paa" +} forEach _distinctVehiclesClassNames; + +true; \ No newline at end of file diff --git a/functions/fbcb2/fn_initFBCB2.sqf b/functions/fbcb2/fn_initFBCB2.sqf index ba00b91..0e0bccd 100644 --- a/functions/fbcb2/fn_initFBCB2.sqf +++ b/functions/fbcb2/fn_initFBCB2.sqf @@ -14,11 +14,13 @@ milsim_fbcb2_subjectStatusID = "FBCB2_Status"; milsim_fbcb2_subjectIntelID = "FBCB2_Intel"; milsim_fbcb2_subjectMessagesID = "FBCB2_Messages"; milsim_fbcb2_subjectFrequenciesID = "FBCB2_Frequencies"; +milsim_fbcb2_subjectAssetsID = "FBCB2_Assets"; player createDiarySubject[milsim_fbcb2_subjectStatusID, "FBCB2 - Status"]; player createDiarySubject[milsim_fbcb2_subjectMessagesID, "FBCB2 - Messages"]; player createDiarySubject[milsim_fbcb2_subjectIntelID, "FBCB2 - Intel"]; player createDiarySubject[milsim_fbcb2_subjectFrequenciesID, "FBCB2 - Frequencies"]; +player createDiarySubject[milsim_fbcb2_subjectAssetsID, "FBCB2 - Assets"]; // store records in format: // [subject, [ @@ -32,3 +34,4 @@ milsim_fbcb2_diaryRecords = createHashMap; [] call milsim_fnc_processFBCB2RadioFrequencies; [] call milsim_fnc_processFBCB2SmokeColors; [] call milsim_fnc_processFBCB2Environment; +[] call milsim_fbcb2_assets_fnc_updateAssetDiary; diff --git a/functions/fbcb2/fn_processFBCB2FixedWingAssets.sqf b/functions/fbcb2/fn_processFBCB2FixedWingAssets.sqf index 773e0e1..19135ed 100644 --- a/functions/fbcb2/fn_processFBCB2FixedWingAssets.sqf +++ b/functions/fbcb2/fn_processFBCB2FixedWingAssets.sqf @@ -4,7 +4,7 @@ private _assetList = missionNamespace getVariable "milsim_var_fixedAssets"; _text = "=======------ Mission Data Set ------======="; - { +{ _callSign = _x select 0; _asset = _x select 1; _assigned = _x select 2; diff --git a/functions/fbcb2/util/fn_createOrUpdateDiaryRecord.sqf b/functions/fbcb2/util/fn_createOrUpdateDiaryRecord.sqf index 89380e8..eb591c5 100644 --- a/functions/fbcb2/util/fn_createOrUpdateDiaryRecord.sqf +++ b/functions/fbcb2/util/fn_createOrUpdateDiaryRecord.sqf @@ -1,7 +1,8 @@ params [ ["_subjectID", milsim_fbcb2_subjectStatusID, [""]], ["_recordTitle", "", [""]], - ["_recordText", "", [""]] + ["_recordText", "", [""]], + ["_recordIcon", "", [""]] ]; // Check if already created @@ -12,7 +13,14 @@ if (!isNull _existingRecord) then { player setDiaryRecordText [[_subjectID, _existingRecord], [_recordTitle, _recordText]]; systemChat format ["Updated diary record: %1", _recordTitle]; } else { - private _new = player createDiaryRecord [_subjectID, [_recordTitle, _recordText]]; + private _new = player createDiaryRecord [ + _subjectID, + [ + _recordTitle, + _recordText, + _recordIcon + ] + ]; _subjectRecords set [_recordTitle, _new]; milsim_fbcb2_diaryRecords set [_subjectID, _subjectRecords]; }; \ No newline at end of file diff --git a/functions/init/fn_initServer.sqf b/functions/init/fn_initServer.sqf index 0ddff3c..3a886bd 100644 --- a/functions/init/fn_initServer.sqf +++ b/functions/init/fn_initServer.sqf @@ -2,58 +2,14 @@ if (!isServer) exitWith {}; // define milsim_resupply_crateDefinitions call milsim_fnc_crateDefinitions; - -_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; - { - _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; - -missionNamespace setVariable ["milsim_var_rotaryAssets", _rotaryAssets]; - -publicVariable "milsim_var_fixedAssets"; -publicVariable "milsim_var_rotaryAssets"; - +milsim_baseObjects = allMissionObjects "ModuleRespawnPosition_F"; +publicVariable "milsim_baseObjects"; +// init asset stores at bases +[true] call milsim_fbcb2_assets_fnc_updateAssetsByBase; +// run update every 5 minutes +[{call milsim_fbcb2_assets_fnc_updateAssetsByBase;}, 60*5] call CBA_fnc_addPerFrameHandler; // Initializes the Dynamic Groups framework and groups ["Initialize", [true]] call BIS_fnc_dynamicGroups; diff --git a/functions/reinsert/fn_getNearestBase.sqf b/functions/reinsert/fn_getNearestBase.sqf index 049cc04..03207a4 100644 --- a/functions/reinsert/fn_getNearestBase.sqf +++ b/functions/reinsert/fn_getNearestBase.sqf @@ -1,7 +1,7 @@ params [["_player", objNull, [objNull]]]; if (isNull _player) exitWith {objNull}; -private _bases = missionNamespace getVariable ["milsim_reinsert_bases", []]; +private _bases = missionNamespace getVariable ["milsim_baseObjects", []]; if (count _bases == 0) exitWith {objNull}; // get nearest base (Module_Respawn_F) diff --git a/functions/reinsert/server/fn_initServer.sqf b/functions/reinsert/server/fn_initServer.sqf index 9dd329f..03370a0 100644 --- a/functions/reinsert/server/fn_initServer.sqf +++ b/functions/reinsert/server/fn_initServer.sqf @@ -6,8 +6,8 @@ if (!isServer) exitWith {}; // array of all respawn modules in the mission, used as 'base' locations for reinsertion -milsim_reinsert_bases = allMissionObjects "ModuleRespawnPosition_F"; -publicVariable "milsim_reinsert_bases"; +milsim_baseObjects = allMissionObjects "ModuleRespawnPosition_F"; +publicVariable "milsim_baseObjects"; // register queue milsim_reinsert_reinsertionQueue = []; -- 2.37.3.windows.1 From b67888f4f1c22c2a093a1a0f8a5cf432e8cfee33 Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Fri, 2 Feb 2024 14:34:04 -0800 Subject: [PATCH 02/16] locally tested, adds more features. ready for dedi --- functions/CfgFunctions.hpp | 17 ++- .../assets/byBase/fn_updateAssetsByBase.sqf | 115 ++++++++++++++-- .../assets/fn_removeAssetDiaryRecords.sqf | 16 +++ .../fbcb2/assets/fn_removeMarkersOnMap.sqf | 13 -- .../fbcb2/assets/fn_showMarkersOnMap.sqf | 38 ------ .../fbcb2/assets/fn_updateAssetDiary.sqf | 71 +++++++++- .../assets/markers/fn_removeMarkersOnMap.sqf | 25 ++++ .../assets/markers/fn_showMarkersOnMap.sqf | 123 ++++++++++++++++++ functions/fbcb2/fn_initFBCB2.sqf | 10 +- .../fbcb2/fn_processFBCB2FixedWingAssets.sqf | 26 ---- .../fbcb2/fn_processFBCB2RotaryAssets.sqf | 26 ---- .../util/fn_createOrUpdateDiaryRecord.sqf | 4 +- functions/fbcb2/util/fn_removeDiaryRecord.sqf | 0 functions/init/fn_initServer.sqf | 2 +- .../reinsert/client/fn_addAceSelfActions.sqf | 6 +- functions/reinsert/fn_getBaseName.sqf | 8 -- functions/reinsert/server/fn_addToQueue.sqf | 4 +- .../reinsert/server/fn_globalShowQueue.sqf | 8 +- .../reinsert/server/fn_removeFromQueue.sqf | 6 +- .../fn_returnReinsertQueueNotification.sqf | 2 +- .../reinsert/server/fn_validateQueue.sqf | 10 +- functions/settings/fn_addCBASettings.sqf | 26 ++++ functions/util/fn_getNameOfBase.sqf | 17 +++ .../{reinsert => util}/fn_getNearestBase.sqf | 6 +- 24 files changed, 416 insertions(+), 163 deletions(-) create mode 100644 functions/fbcb2/assets/fn_removeAssetDiaryRecords.sqf delete mode 100644 functions/fbcb2/assets/fn_removeMarkersOnMap.sqf delete mode 100644 functions/fbcb2/assets/fn_showMarkersOnMap.sqf create mode 100644 functions/fbcb2/assets/markers/fn_removeMarkersOnMap.sqf create mode 100644 functions/fbcb2/assets/markers/fn_showMarkersOnMap.sqf delete mode 100644 functions/fbcb2/fn_processFBCB2FixedWingAssets.sqf delete mode 100644 functions/fbcb2/fn_processFBCB2RotaryAssets.sqf create mode 100644 functions/fbcb2/util/fn_removeDiaryRecord.sqf delete mode 100644 functions/reinsert/fn_getBaseName.sqf create mode 100644 functions/util/fn_getNameOfBase.sqf rename functions/{reinsert => util}/fn_getNearestBase.sqf (56%) diff --git a/functions/CfgFunctions.hpp b/functions/CfgFunctions.hpp index b4f2ab8..d8d6331 100644 --- a/functions/CfgFunctions.hpp +++ b/functions/CfgFunctions.hpp @@ -16,8 +16,6 @@ class milsim class fbcb2 { class initFBCB2 { postInit = 1; }; - class processFBCB2FixedWingAssets {}; - class processFBCB2RotaryAssets {}; class processFBCB2RadioFrequencies {}; class processFBCB2SmokeColors {}; class processFBCB2Environment {}; @@ -85,6 +83,8 @@ class milsim class padString {}; class recurseSubclasses {}; class getBattalionCfg {}; + class getNameOfBase {}; + class getNearestBase {}; }; }; @@ -92,12 +92,11 @@ class milsim_fbcb2_assets { class functions { file = "functions\fbcb2\assets"; class updateAssetDiary {}; + class removeAssetDiaryRecords {}; class getMagsForWeapon {}; class getWeaponry {}; class getInventory {}; class getVehicleData {}; - class showMarkersOnMap {}; - class removeMarkersOnMap {}; }; class assetsByBase { file = "functions\fbcb2\assets\byBase"; @@ -105,14 +104,14 @@ class milsim_fbcb2_assets { class getStartingAssetsByBase {}; class updateAssetsByBase {}; }; + class markers { + file = "functions\fbcb2\assets\markers"; + class showMarkersOnMap {}; + class removeMarkersOnMap {}; + } }; class milsim_reinsert { - class functions { - file = "functions\reinsert"; - class getBaseName {}; - class getNearestBase {}; - }; class server { file = "functions\reinsert\server"; class initServer { postInit = 1; }; diff --git a/functions/fbcb2/assets/byBase/fn_updateAssetsByBase.sqf b/functions/fbcb2/assets/byBase/fn_updateAssetsByBase.sqf index e34cdb7..da06aef 100644 --- a/functions/fbcb2/assets/byBase/fn_updateAssetsByBase.sqf +++ b/functions/fbcb2/assets/byBase/fn_updateAssetsByBase.sqf @@ -1,15 +1,106 @@ params [["_isInit", false, [false]]]; -{ // find approved assets at each base - private _base = _x; - private _baseAssets = _base getVariable ["milsim_fbcb2_assets_assetsAtThisBase", []]; - { - private _className = configName _x; - _a = _base nearEntities [_className, 750]; - _baseAssets append _a; - } forEach ((missionConfigFile >> "ApprovedAssets") call BIS_fnc_returnChildren); - _base setVariable ["milsim_fbcb2_assets_assetsAtThisBase", _baseAssets, true]; - if (_isInit) then { - _base setVariable ["milsim_fbcb2_assets_assetsStartedAtThisBase", _baseAssets, true]; + +// Get all approved assets on map, find the closest base +// Then determine if it's within range +// If it is, add it to the base's assets list +// This is to ensure bases with overlapping detection range don't have duplicate assets +private _allVehicles = vehicles; +private _allSaved = []; + +private _assetsAtThisBaseVar = "milsim_fbcb2_assets_assetsAtThisBase"; +private _assetsStartedAtThisBaseVar = "milsim_fbcb2_assets_assetsStartedAtThisBase"; +{ + private _className = configName _x; + private _callsign = getText(_x >> "callsign"); + private _found = _allVehicles select { typeOf _x == _className }; + { + private _asset = _x; + // avoid duplicates + if (_asset in _allSaved) then {continue}; + private _closestBase = [_asset] call milsim_fnc_getNearestBase; + if (isNull _closestBase) then { + // no base found + continue; + }; + if ( + _asset distance _closestBase > + milsim_fbcb2_assets_setting_detectionRangeFromBase + ) then { + // not within range + continue; + }; + + _asset setVariable ["milsim_fbcb2_assets_callsign", _callsign, true]; + + // add to base's assets list + private _baseAssets = _closestBase getVariable [_assetsAtThisBaseVar, []]; + _baseAssets pushBackUnique _asset; + // broadcast later so we're not spamming network + _closestBase setVariable [ + _assetsAtThisBaseVar, + _baseAssets + ]; + + // if this is the init, set the base's assets started at this base + if (_isInit) then { + // broadcast later so we're not spamming network + _closestBase setVariable [ + _assetsStartedAtThisBaseVar, + _baseAssets + ]; + }; + + _allSaved pushBack _asset; + } forEach _found; +} forEach ((missionConfigFile >> "ApprovedAssets") call BIS_fnc_returnChildren); + +// Add all ground vehicles (LandVehicle) +{ + private _asset = _x; + // avoid duplicates + if (_asset in _allSaved) then {continue}; + + private _closestBase = [_asset] call milsim_fnc_getNearestBase; + if (isNull _closestBase) then { + // no base found + continue; }; -} forEach milsim_baseObjects; \ No newline at end of file + + if ( + _asset distance _closestBase > + milsim_fbcb2_assets_setting_detectionRangeFromBase + ) then { + // not within range + continue; + }; + + // add to base's assets list + private _baseAssets = _closestBase getVariable [_assetsAtThisBaseVar, []]; + _baseAssets pushBackUnique _asset; + // broadcast later so we're not spamming network + _closestBase setVariable [ + _assetsAtThisBaseVar, + _baseAssets + ]; + + // if this is the init, set the base's assets started at this base + if (_isInit) then { + // broadcast later so we're not spamming network + _closestBase setVariable [ + _assetsStartedAtThisBaseVar, + _baseAssets + ]; + }; +} forEach (_allVehicles select { _x isKindOf "LandVehicle" }); + + +// make the asset lists public +{ + private _baseAssets = _x getVariable [_assetsAtThisBaseVar, []]; + _x setVariable [_assetsAtThisBaseVar, _baseAssets, true]; + if (_isInit) then { + _x setVariable [_assetsStartedAtThisBaseVar, _baseAssets, true]; + }; +} forEach milsim_baseObjects; + diff --git a/functions/fbcb2/assets/fn_removeAssetDiaryRecords.sqf b/functions/fbcb2/assets/fn_removeAssetDiaryRecords.sqf new file mode 100644 index 0000000..400cd7d --- /dev/null +++ b/functions/fbcb2/assets/fn_removeAssetDiaryRecords.sqf @@ -0,0 +1,16 @@ +if (!hasInterface) exitWith {}; + +{ + private _diarySubject = _x; + private _records = player allDiaryRecords _diarySubject; + if (count _records isEqualTo 0) then {continue}; + + { + private _diaryRecord = _x select -1; + player removeDiaryRecord [_diarySubject, _diaryRecord]; + } forEach _records; +} forEach [ + milsim_fbcb2_subjectAssetsFixedWingID, + milsim_fbcb2_subjectAssetsRotaryID, + milsim_fbcb2_subjectAssetsGroundID +]; \ No newline at end of file diff --git a/functions/fbcb2/assets/fn_removeMarkersOnMap.sqf b/functions/fbcb2/assets/fn_removeMarkersOnMap.sqf deleted file mode 100644 index 07051c1..0000000 --- a/functions/fbcb2/assets/fn_removeMarkersOnMap.sqf +++ /dev/null @@ -1,13 +0,0 @@ -private _assetMarkerStore = localNamespace getVariable [ - "milsim_fbcb2_assets_markerStore", - [] -]; - -{ - deleteMarkerLocal _x; -} forEach _assetMarkerStore; - -localNamespace setVariable [ - "milsim_fbcb2_assets_markerStore", - [] -]; \ No newline at end of file diff --git a/functions/fbcb2/assets/fn_showMarkersOnMap.sqf b/functions/fbcb2/assets/fn_showMarkersOnMap.sqf deleted file mode 100644 index 7f2b1e8..0000000 --- a/functions/fbcb2/assets/fn_showMarkersOnMap.sqf +++ /dev/null @@ -1,38 +0,0 @@ -params [ - ["_className", "", [""]], - ["_markerType", "hd_dot", [""]], - ["_markerColor", "", [""]], - ["_positions", [], []] -]; - -if (count _className isEqualTo 0) exitWith { - ["No class name provided!"] call BIS_fnc_error; -}; -if (count _markerColor isEqualTo 0) exitWith { - ["No marker color provided!"] call BIS_fnc_error; -}; -if (count _positions isEqualTo 0) exitWith { - ["No positions provided!"] call BIS_fnc_error; -}; - -private _assetMarkerStore = localNamespace getVariable [ - "milsim_fbcb2_assets_markerStore", - [] -]; - -private _start = (count _assetMarkerStore) + 1; -{ - _position = _x; - _newMarker = createMarkerLocal [ - format["milsim_fbcb2_assets_marker_%1", _start], - _position - ]; - _newMarker setMarkerTypeLocal _markerType; - _newMarker setMarkerColorLocal _markerColor; - _newMarker setMarkerTextLocal str(_start); - - _assetMarkerStore pushBack _newMarker; - _start = _start + 1; -} forEach _positions; - -localNamespace setVariable ["milsim_fbcb2_assets_markerStore", _assetMarkerStore]; diff --git a/functions/fbcb2/assets/fn_updateAssetDiary.sqf b/functions/fbcb2/assets/fn_updateAssetDiary.sqf index e729efb..9709b9d 100644 --- a/functions/fbcb2/assets/fn_updateAssetDiary.sqf +++ b/functions/fbcb2/assets/fn_updateAssetDiary.sqf @@ -1,7 +1,19 @@ +if (!hasInterface) exitWith {}; + // create diary records + +// remove any existing asset map markers +call milsim_fbcb2_assets_fnc_removeMarkersOnMap; + +// remove existing asset records +call milsim_fbcb2_assets_fnc_removeAssetDiaryRecords; + +// get all vehicles by base private _vehiclesByBase = call milsim_fbcb2_assets_fnc_getAssetsByBase; if (count _vehiclesByBase isEqualTo 0) exitWith {false}; + +// put vehicles from each base into a single array private _vehicles = []; { _vehicles append (_x#1); @@ -24,6 +36,12 @@ private _distinctVehiclesClassNames = []; // Take the first vehicle as a representative private _representativeVehicle = _vehiclesOfThisKind#0; private _vehicleCfg = configOf _representativeVehicle; + private _vehicleCallsign = toUpper ( + _representativeVehicle getVariable [ + "milsim_fbcb2_assets_callsign", + "NONE ASSIGNED" + ] + ); // Process the vehicle for extended info // Exclusion list for display names @@ -53,6 +71,10 @@ private _distinctVehiclesClassNames = []; _recordText pushBack _title; _recordText pushBack _image; _recordText pushBack "
"; + _recordText pushBack format[ + "CALLSIGN: %1", + _vehicleCallsign + ]; _recordText pushBack format[ "COUNT ACTIVE: %1", count _vehiclesOfThisKind @@ -78,32 +100,63 @@ private _distinctVehiclesClassNames = []; case (_representativeVehicle isKindOf "Air"): { _markerType = "loc_plane"; }; + case (_representativeVehicle isKindOf "Ship"): { + _markerType = "loc_boat"; + }; + case (_representativeVehicle isKindOf "Car"): { + _markerType = "loc_car"; + }; default { _markerType = "loc_truck"; }; }; + // Link to show markers _recordText pushBack format[ "SHOW MARKERS at vehicle positions (in %5)", _className, _markerType, _randomColor#0, - (_vehiclesOfThisKind apply {getPosASL _x}), + _vehiclesOfThisKind, format["%2", _randomColor#1, _randomColor#2] ]; // Link to hide markers - _recordText pushBack "REMOVE ALL MARKERS showing asset positions" + "
"; + _recordText pushBack "REMOVE ALL MARKERS showing asset positions"; // Link to update asset diary entries - _recordText pushBack "UPDATE ENTRIES for all assets" + "
"; + _recordText pushBack "UPDATE ENTRIES for all assets"; + + _recordText pushBack format[ + "%1", + "Notes:
+ - Markers are only displayed on your local machine.
+ - The REMOVE ALL option will remove all assets' markers from the map.
+ - UPDATE ENTRIES will update the asset diary with the latest information (~5 minutes at most)." + ]; + + // Add info and capacity sections _recordText pushBack _info; _recordText pushBack _capacity; + + private _subjectID = ""; + switch (true) do { + case (_representativeVehicle isKindOf "Helicopter"): { + _subjectID = milsim_fbcb2_subjectAssetsRotaryID; + }; + case (_representativeVehicle isKindOf "Air"): { + _subjectID = milsim_fbcb2_subjectAssetsFixedWingID; + }; + default { + _subjectID = milsim_fbcb2_subjectAssetsGroundID; + }; + }; + [ - milsim_fbcb2_subjectAssetsID, + _subjectID, format[ "%1x %2", count _vehiclesOfThisKind, @@ -116,4 +169,14 @@ private _distinctVehiclesClassNames = []; // "\A3\ui_f\data\igui\cfg\simpleTasks\types\car_ca.paa" } forEach _distinctVehiclesClassNames; +// log to RPT +[ + "fbcb2_assets", + "UPDATED ASSET DIARY", + [ + ["assetCount", count _vehicles], + ["distinctAssetCount", count _distinctVehiclesClassNames] + ] +] call milsim_fnc_log; + true; \ No newline at end of file diff --git a/functions/fbcb2/assets/markers/fn_removeMarkersOnMap.sqf b/functions/fbcb2/assets/markers/fn_removeMarkersOnMap.sqf new file mode 100644 index 0000000..ef6db27 --- /dev/null +++ b/functions/fbcb2/assets/markers/fn_removeMarkersOnMap.sqf @@ -0,0 +1,25 @@ +private _baseMarkerStoreVar = "milsim_fbcb2_assets_baseMarkerStore"; +private _assetMarkerStoreVar = "milsim_fbcb2_assets_assetMarkerStore"; + +private _baseMarkerStore = localNamespace getVariable [ + _baseMarkerStoreVar, + [] +]; +private _assetMarkerStore = localNamespace getVariable [ + _assetMarkerStoreVar, + [] +]; + +// delete markers +{ + deleteMarkerLocal (_x#1); +} forEach (_baseMarkerStore + _assetMarkerStore); + +localNamespace setVariable [ + _baseMarkerStoreVar, + [] +]; +localNamespace setVariable [ + _assetMarkerStoreVar, + [] +]; diff --git a/functions/fbcb2/assets/markers/fn_showMarkersOnMap.sqf b/functions/fbcb2/assets/markers/fn_showMarkersOnMap.sqf new file mode 100644 index 0000000..c28426b --- /dev/null +++ b/functions/fbcb2/assets/markers/fn_showMarkersOnMap.sqf @@ -0,0 +1,123 @@ +params [ + ["_className", "", [""]], + ["_markerType", "hd_dot", [""]], + ["_markerColor", "", [""]], + ["_assetObjects", [], []] +]; + +if (count _className isEqualTo 0) exitWith { + ["No class name provided!"] call BIS_fnc_error; +}; +if (count _markerColor isEqualTo 0) exitWith { + ["No marker color provided!"] call BIS_fnc_error; +}; +if (count _assetObjects isEqualTo 0) exitWith { + ["No vehicles provided!"] call BIS_fnc_error; +}; + +private _baseMarkerStoreVar = "milsim_fbcb2_assets_baseMarkerStore"; +private _assetMarkerStoreVar = "milsim_fbcb2_assets_assetMarkerStore"; + +private _baseMarkerStore = localNamespace getVariable [ + _baseMarkerStoreVar, + [] +]; +private _assetMarkerStore = localNamespace getVariable [ + _assetMarkerStoreVar, + [] +]; + +/////////////////////////////////////////////////////////////////////////////// +// Create base markers if not already present +if (not (count _baseMarkerStore > 0)) then { + { + private _base = _x; + + // create a circle marker with range as the detection range of assets + _newMarker = createMarkerLocal [ + format["milsim_fbcb2_assets_base_marker_%1", _forEachIndex + 1], + getPosASL _base + ]; + _newMarker setMarkerTypeLocal "mil_dot"; + _newMarker setMarkerColorLocal "ColorGreen"; + _newMarker setMarkerShapeLocal "ELLIPSE"; + _newMarker setMarkerSizeLocal [ + milsim_fbcb2_assets_setting_detectionRangeFromBase, + milsim_fbcb2_assets_setting_detectionRangeFromBase + ]; + _newMarker setMarkerAlphaLocal 0.5; + _newMarker setMarkerTextLocal str(_forEachIndex + 1); + + _baseMarkerStore pushBack [ + _base, + _newMarker + ]; + + // create a flag marker at base position + _newMarker = createMarkerLocal [ + format["milsim_fbcb2_assets_base_flag_marker_%1", _forEachIndex + 1], + getPosASL _base + ]; + _newMarker setMarkerTypeLocal "mil_flag"; + _newMarker setMarkerColorLocal "ColorGreen"; + _newMarker setMarkerSizeLocal [0.7, 0.7]; + _newMarker setMarkerTextLocal ([_base] call milsim_fnc_getNameOfBase); + + _baseMarkerStore pushBack [ + _base, + _newMarker + ]; + } forEach milsim_baseObjects; + + localNamespace setVariable [_baseMarkerStoreVar, _baseMarkerStore]; +}; + + +private _start = (count _assetMarkerStore) + 1; +private _createdAssetMarkers = []; +{ + private _asset = _x; + // if asset was removed since last update + if (isNull _asset) then {continue}; + // check if a marker is already placed for this asset + if ( + (_assetMarkerStore findIf { _x select 0 isEqualTo _asset }) + > -1 + ) then {continue}; + + // create a marker for the asset + private _newMarker = createMarkerLocal [ + format["milsim_fbcb2_assets_marker_%1", _start], + getPosASL _asset + ]; + _newMarker setMarkerAlphaLocal 0; + _newMarker setMarkerTypeLocal _markerType; + _newMarker setMarkerColorLocal _markerColor; + // _newMarker setMarkerTextLocal ([configOf _asset] call BIS_fnc_displayName); + + _createdAssetMarkers pushBack [ + _asset, + _newMarker + ]; + _start = _start + 1; +} forEach _assetObjects; + +// unhide added asset markers sequentially +[_createdAssetMarkers apply {_x#1}] spawn { + params ["_markers"]; + for "_alpha" from 0.0 to 1.0 step 0.03 do + { + { + _x setMarkerAlphaLocal _alpha; + } forEach _markers; + Sleep 0.002; + }; +}; + +// add to store +{ + _assetMarkerStore pushBack _x; +} forEach _createdAssetMarkers; + +// update store var +localNamespace setVariable [_assetMarkerStoreVar, _assetMarkerStore]; diff --git a/functions/fbcb2/fn_initFBCB2.sqf b/functions/fbcb2/fn_initFBCB2.sqf index 0e0bccd..1f3e864 100644 --- a/functions/fbcb2/fn_initFBCB2.sqf +++ b/functions/fbcb2/fn_initFBCB2.sqf @@ -14,13 +14,17 @@ milsim_fbcb2_subjectStatusID = "FBCB2_Status"; milsim_fbcb2_subjectIntelID = "FBCB2_Intel"; milsim_fbcb2_subjectMessagesID = "FBCB2_Messages"; milsim_fbcb2_subjectFrequenciesID = "FBCB2_Frequencies"; -milsim_fbcb2_subjectAssetsID = "FBCB2_Assets"; +milsim_fbcb2_subjectAssetsFixedWingID = "FBCB2_Assets_FixedWing"; +milsim_fbcb2_subjectAssetsRotaryID = "FBCB2_Assets_Rotary"; +milsim_fbcb2_subjectAssetsGroundID = "FBCB2_Assets_Ground"; player createDiarySubject[milsim_fbcb2_subjectStatusID, "FBCB2 - Status"]; player createDiarySubject[milsim_fbcb2_subjectMessagesID, "FBCB2 - Messages"]; player createDiarySubject[milsim_fbcb2_subjectIntelID, "FBCB2 - Intel"]; player createDiarySubject[milsim_fbcb2_subjectFrequenciesID, "FBCB2 - Frequencies"]; -player createDiarySubject[milsim_fbcb2_subjectAssetsID, "FBCB2 - Assets"]; +player createDiarySubject[milsim_fbcb2_subjectAssetsFixedWingID, "FBCB2 - Assets Plane"]; +player createDiarySubject[milsim_fbcb2_subjectAssetsRotaryID, "FBCB2 - Assets Rotary"]; +player createDiarySubject[milsim_fbcb2_subjectAssetsGroundID, "FBCB2 - Assets Ground"]; // store records in format: // [subject, [ @@ -29,8 +33,6 @@ player createDiarySubject[milsim_fbcb2_subjectAssetsID, "FBCB2 - Assets"]; milsim_fbcb2_diaryRecords = createHashMap; // populate diary -[] call milsim_fnc_processFBCB2FixedWingAssets; -[] call milsim_fnc_processFBCB2RotaryAssets; [] call milsim_fnc_processFBCB2RadioFrequencies; [] call milsim_fnc_processFBCB2SmokeColors; [] call milsim_fnc_processFBCB2Environment; diff --git a/functions/fbcb2/fn_processFBCB2FixedWingAssets.sqf b/functions/fbcb2/fn_processFBCB2FixedWingAssets.sqf deleted file mode 100644 index 19135ed..0000000 --- a/functions/fbcb2/fn_processFBCB2FixedWingAssets.sqf +++ /dev/null @@ -1,26 +0,0 @@ -private _recordTitle = "MDS - ASSETS - FIXED"; - -private _assetList = missionNamespace getVariable "milsim_var_fixedAssets"; - -_text = "=======------ Mission Data Set ------======="; - -{ - _callSign = _x select 0; - _asset = _x select 1; - _assigned = _x select 2; - _name = getText(configFile >> "CfgVehicles" >> _asset >> "displayName"); - - _data = "Callsign: " + _callsign + "
Asset: " + _name + "
Assigned: " + str _assigned + ""; - - _text = _text + "

" + _data; - -} foreach _assetList; - -_text = _text + "

Run Report on local node?"; - - -[ - milsim_fbcb2_subjectStatusID, - _recordTitle, - _text -] call milsim_fnc_createOrUpdateDiaryRecord; \ No newline at end of file diff --git a/functions/fbcb2/fn_processFBCB2RotaryAssets.sqf b/functions/fbcb2/fn_processFBCB2RotaryAssets.sqf deleted file mode 100644 index 95bdeda..0000000 --- a/functions/fbcb2/fn_processFBCB2RotaryAssets.sqf +++ /dev/null @@ -1,26 +0,0 @@ -private _recordTitle = "MDS - ASSETS - ROTARY"; - -_assetList = missionNamespace getVariable "milsim_var_rotaryAssets"; - -_text = "=======------ Mission Data Set ------======="; - - { - _callSign = _x select 0; - _asset = _x select 1; - _assigned = _x select 2; - _name = getText(configFile >> "CfgVehicles" >> _asset >> "displayName"); - - _data = "Callsign: " + _callsign + "
Asset: " + _name + "
Assigned: " + str _assigned + ""; - - _text = _text + "

" + _data; - -} foreach _assetList; - -_text = _text + "

Run Report on local node?"; - - -[ - milsim_fbcb2_subjectStatusID, - _recordTitle, - _text -] call milsim_fnc_createOrUpdateDiaryRecord; \ No newline at end of file diff --git a/functions/fbcb2/util/fn_createOrUpdateDiaryRecord.sqf b/functions/fbcb2/util/fn_createOrUpdateDiaryRecord.sqf index eb591c5..6cd8330 100644 --- a/functions/fbcb2/util/fn_createOrUpdateDiaryRecord.sqf +++ b/functions/fbcb2/util/fn_createOrUpdateDiaryRecord.sqf @@ -1,3 +1,5 @@ +if (!hasInterface) exitWith {}; + params [ ["_subjectID", milsim_fbcb2_subjectStatusID, [""]], ["_recordTitle", "", [""]], @@ -10,7 +12,7 @@ private _subjectRecords = milsim_fbcb2_diaryRecords getOrDefault [_subjectID, cr private _existingRecord = _subjectRecords getOrDefault [_recordTitle, diaryRecordNull, true]; if (!isNull _existingRecord) then { - player setDiaryRecordText [[_subjectID, _existingRecord], [_recordTitle, _recordText]]; + player setDiaryRecordText [[_subjectID, _existingRecord], [_recordTitle, _recordText, _recordIcon]]; systemChat format ["Updated diary record: %1", _recordTitle]; } else { private _new = player createDiaryRecord [ diff --git a/functions/fbcb2/util/fn_removeDiaryRecord.sqf b/functions/fbcb2/util/fn_removeDiaryRecord.sqf new file mode 100644 index 0000000..e69de29 diff --git a/functions/init/fn_initServer.sqf b/functions/init/fn_initServer.sqf index 3a886bd..e851136 100644 --- a/functions/init/fn_initServer.sqf +++ b/functions/init/fn_initServer.sqf @@ -9,7 +9,7 @@ publicVariable "milsim_baseObjects"; // init asset stores at bases [true] call milsim_fbcb2_assets_fnc_updateAssetsByBase; // run update every 5 minutes -[{call milsim_fbcb2_assets_fnc_updateAssetsByBase;}, 60*5] call CBA_fnc_addPerFrameHandler; +[{[false] call milsim_fbcb2_assets_fnc_updateAssetsByBase;}, 60*5] call CBA_fnc_addPerFrameHandler; // Initializes the Dynamic Groups framework and groups ["Initialize", [true]] call BIS_fnc_dynamicGroups; diff --git a/functions/reinsert/client/fn_addAceSelfActions.sqf b/functions/reinsert/client/fn_addAceSelfActions.sqf index 7734e1b..137540d 100644 --- a/functions/reinsert/client/fn_addAceSelfActions.sqf +++ b/functions/reinsert/client/fn_addAceSelfActions.sqf @@ -13,8 +13,8 @@ private _fileForReinsertAction = [ { // statement params ["_target", "_player", "_params"]; // find nearest base or location - private _base = [_player] call milsim_reinsert_fnc_getNearestBase; - private _baseName = [_base] call milsim_reinsert_fnc_getBaseName; + private _base = [_player] call milsim_fnc_getNearestBase; + private _baseName = [_base] call milsim_fnc_getNameOfBase; // send event to server ["milsim_reinsert_fileReinsertRequest", [_player, _base]] call CBA_fnc_serverEvent; // notify player their request was filed @@ -23,7 +23,7 @@ private _fileForReinsertAction = [ { // condition params ["_target", "_player", "_params"]; // find nearest base or location - private _base = [_player] call milsim_reinsert_fnc_getNearestBase; + private _base = [_player] call milsim_fnc_getNearestBase; private _baseDistance = _player distance _base; private _maxRangeToReady = missionNamespace getVariable ["milsim_reinsert_setting_reinsertion_maxRangeToReady", 400]; diff --git a/functions/reinsert/fn_getBaseName.sqf b/functions/reinsert/fn_getBaseName.sqf deleted file mode 100644 index ab2cbf8..0000000 --- a/functions/reinsert/fn_getBaseName.sqf +++ /dev/null @@ -1,8 +0,0 @@ -params [["_base", objNull, [objNull]]]; -if (_base == objNull) exitWith {""}; - -// get base name -private _baseName = _base getVariable ["name", ""]; -if (_baseName == "") then {_baseName = format["near %1", text (nearestLocation [_base, ["NameCity", "NameLocal"]])]}; - -_baseName; \ No newline at end of file diff --git a/functions/reinsert/server/fn_addToQueue.sqf b/functions/reinsert/server/fn_addToQueue.sqf index ce662d1..55d14a3 100644 --- a/functions/reinsert/server/fn_addToQueue.sqf +++ b/functions/reinsert/server/fn_addToQueue.sqf @@ -41,9 +41,9 @@ publicVariable "milsim_reinsert_reinsertionQueue"; // log to rpt private _logParams = [ - ["filedAtBase", [_base] call milsim_reinsert_fnc_getBaseName], + ["filedAtBase", [_base] call milsim_fnc_getNameOfBase], ["filedAtBaseDistance", _player distance _base], - ["closestBase", [_nearestBase] call milsim_reinsert_fnc_getBaseName], + ["closestBase", [_nearestBase] call milsim_fnc_getNameOfBase], ["closestBaseDistance", _player distance _nearestBase], ["maxDistanceSetting", _maxRangeToReady], ["inQueueDuration", diag_tickTime - _timeFiled] diff --git a/functions/reinsert/server/fn_globalShowQueue.sqf b/functions/reinsert/server/fn_globalShowQueue.sqf index a85462e..ea7e80e 100644 --- a/functions/reinsert/server/fn_globalShowQueue.sqf +++ b/functions/reinsert/server/fn_globalShowQueue.sqf @@ -21,7 +21,7 @@ if (count _timeoutPlayers > 0) then { private _thisBase = _x; // Add line for base name - _playerLines pushBack ([[_thisBase] call milsim_reinsert_fnc_getBaseName, 1, [0,1,0,1]]); + _playerLines pushBack ([[_thisBase] call milsim_fnc_getNameOfBase, 1, [0,1,0,1]]); // Get players under this base private _thisBasePlayers = _timeoutPlayers select {_x#1 isEqualTo _thisBase}; @@ -35,7 +35,7 @@ if (count _timeoutPlayers > 0) then { { // for each player under this base, add a line _x params ["_player", "_base", "_timeFiled"]; // get the closest base to the player - private _nearestBase = [_player] call milsim_reinsert_fnc_getNearestBase; + private _nearestBase = [_player] call milsim_fnc_getNearestBase; // add player to array of players under bases _playerLines pushBack ([format [ @@ -47,9 +47,9 @@ if (count _timeoutPlayers > 0) then { // log to rpt private _logParams = [ - ["filedAtBase", [_base] call milsim_reinsert_fnc_getBaseName], + ["filedAtBase", [_base] call milsim_fnc_getNameOfBase], ["filedAtBaseDistance", _player distance _base], - ["closestBase", [_nearestBase] call milsim_reinsert_fnc_getBaseName], + ["closestBase", [_nearestBase] call milsim_fnc_getNameOfBase], ["closestBaseDistance", _player distance _nearestBase], ["maxDistanceSetting", _maxRangeToReady], ["inQueueDuration", diag_tickTime - _timeFiled] diff --git a/functions/reinsert/server/fn_removeFromQueue.sqf b/functions/reinsert/server/fn_removeFromQueue.sqf index 0e24679..7c131a1 100644 --- a/functions/reinsert/server/fn_removeFromQueue.sqf +++ b/functions/reinsert/server/fn_removeFromQueue.sqf @@ -39,12 +39,12 @@ publicVariable "milsim_reinsert_reinsertionQueue"; // get first entry (longest wait) (_unitArrs#0) params ["_player", "_base", "_timeFiled"]; // _unitArr = [unit, base, timeInQueue] // get the closest base to the player -private _nearestBase = [_player] call milsim_reinsert_fnc_getNearestBase; +private _nearestBase = [_player] call milsim_fnc_getNearestBase; // log to rpt private _logParams = [ - ["filedAtBase", [_base] call milsim_reinsert_fnc_getBaseName], + ["filedAtBase", [_base] call milsim_fnc_getNameOfBase], ["filedAtBaseDistance", _player distance _base], - ["closestBase", [_nearestBase] call milsim_reinsert_fnc_getBaseName], + ["closestBase", [_nearestBase] call milsim_fnc_getNameOfBase], ["closestBaseDistance", _player distance _nearestBase], ["maxDistanceSetting", _maxRangeToReady], ["inQueueDuration", diag_tickTime - _timeFiled] diff --git a/functions/reinsert/server/fn_returnReinsertQueueNotification.sqf b/functions/reinsert/server/fn_returnReinsertQueueNotification.sqf index d114ad2..ffe648b 100644 --- a/functions/reinsert/server/fn_returnReinsertQueueNotification.sqf +++ b/functions/reinsert/server/fn_returnReinsertQueueNotification.sqf @@ -48,7 +48,7 @@ if (count _basesWithPeople isEqualTo 0) then { // forEach _basesWithPeople { private _thisBase = _x; - private _baseName = [_thisBase] call milsim_reinsert_fnc_getBaseName; + private _baseName = [_thisBase] call milsim_fnc_getNameOfBase; // generate player lines for this base private _playerLines = _queue select { diff --git a/functions/reinsert/server/fn_validateQueue.sqf b/functions/reinsert/server/fn_validateQueue.sqf index 9c59209..5e27733 100644 --- a/functions/reinsert/server/fn_validateQueue.sqf +++ b/functions/reinsert/server/fn_validateQueue.sqf @@ -7,16 +7,16 @@ private _maxRangeToReady = missionNamespace getVariable ["milsim_reinsert_settin private _distanceToOriginalBase = _player distance _base; // get the closest base to the player - private _nearestBase = [_player] call milsim_reinsert_fnc_getNearestBase; + private _nearestBase = [_player] call milsim_fnc_getNearestBase; private _isCloseEnoughToAnyBase = (_player distance _nearestBase) < _maxRangeToReady; if (not _isCloseEnoughToAnyBase || not (alive _player)) then { // don't include player in updated queue // log to rpt private _logParams = [ - ["filedAtBase", [_base] call milsim_reinsert_fnc_getBaseName], + ["filedAtBase", [_base] call milsim_fnc_getNameOfBase], ["filedAtBaseDistance", _player distance _base], - ["closestBase", [_nearestBase] call milsim_reinsert_fnc_getBaseName], + ["closestBase", [_nearestBase] call milsim_fnc_getNameOfBase], ["closestBaseDistance", _player distance _nearestBase], ["maxDistanceSetting", _maxRangeToReady], ["inQueueDuration", diag_tickTime - _timeFiled] @@ -36,9 +36,9 @@ private _maxRangeToReady = missionNamespace getVariable ["milsim_reinsert_settin // if player's base has changed, log to rpt if (_base != _nearestBase) then { private _logParams = [ - ["filedAtBase", [_base] call milsim_reinsert_fnc_getBaseName], + ["filedAtBase", [_base] call milsim_fnc_getNameOfBase], ["filedAtBaseDistance", _player distance _base], - ["closestBase", [_nearestBase] call milsim_reinsert_fnc_getBaseName], + ["closestBase", [_nearestBase] call milsim_fnc_getNameOfBase], ["closestBaseDistance", _player distance _nearestBase], ["maxDistanceSetting", _maxRangeToReady], ["inQueueDuration", diag_tickTime - _timeFiled] diff --git a/functions/settings/fn_addCBASettings.sqf b/functions/settings/fn_addCBASettings.sqf index 2f22ebf..703bab9 100644 --- a/functions/settings/fn_addCBASettings.sqf +++ b/functions/settings/fn_addCBASettings.sqf @@ -242,6 +242,32 @@ } ] call CBA_fnc_addSetting; +//--------------------- +// Asset Diary and Markers Settings + +[ + "milsim_fbcb2_assets_setting_detectionRangeFromBase", // variable + "SLIDER", // type + ["Detection Range From Base", "The range from a base that assets will be detected"], // title + ["17th Battalion", "Asset Diary and Markers"], // category + [0, 1000, 750, 0, false], // [_min, _max, _default, _trailingDecimals, _isPercentage] + true, // global setting + { + params ["_value"]; + [ + "fbcb2_assets", + "SETTING CHANGED", + [ + [ + "setting", + "milsim_fbcb2_assets_setting_detectionRangeFromBase" + ], + ["newValue", _value] + ] + ] call milsim_fnc_log; + } +] call CBA_fnc_addSetting; + diag_log text "[MILSIM] (settings) Custom CBA settings initialized"; nil; \ No newline at end of file diff --git a/functions/util/fn_getNameOfBase.sqf b/functions/util/fn_getNameOfBase.sqf new file mode 100644 index 0000000..81ed4ec --- /dev/null +++ b/functions/util/fn_getNameOfBase.sqf @@ -0,0 +1,17 @@ +params [["_base", objNull, [objNull]]]; +if (_base == objNull) exitWith {""}; + +// get base name +private _baseName = _base getVariable ["name", ""]; +// if (_baseName == "") then { +// _baseName = format[ +// "near %1", +// text (nearestLocation [_base, ["NameCity", "NameLocal"]]) +// ] +// }; + +if (_baseName == "") then { + _baseName = _base call BIS_fnc_locationDescription; +}; + +_baseName; \ No newline at end of file diff --git a/functions/reinsert/fn_getNearestBase.sqf b/functions/util/fn_getNearestBase.sqf similarity index 56% rename from functions/reinsert/fn_getNearestBase.sqf rename to functions/util/fn_getNearestBase.sqf index 03207a4..68b103c 100644 --- a/functions/reinsert/fn_getNearestBase.sqf +++ b/functions/util/fn_getNearestBase.sqf @@ -1,10 +1,10 @@ -params [["_player", objNull, [objNull]]]; -if (isNull _player) exitWith {objNull}; +params [["_object", objNull, [objNull]]]; +if (isNull _object) exitWith {objNull}; private _bases = missionNamespace getVariable ["milsim_baseObjects", []]; if (count _bases == 0) exitWith {objNull}; // get nearest base (Module_Respawn_F) -private _closestBase = [_bases, _player] call BIS_fnc_nearestPosition; +private _closestBase = [_bases, _object] call BIS_fnc_nearestPosition; if (isNull _closestBase) exitWith {objNull}; _closestBase; \ No newline at end of file -- 2.37.3.windows.1 From 8d93bb57439afab591b8cacab84e6e57a6b2c60a Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Fri, 2 Feb 2024 15:13:45 -0800 Subject: [PATCH 03/16] adds starting assets and assets at mission end to RPT --- .../assets/byBase/fn_updateAssetsByBase.sqf | 85 +++++++++++++++++-- functions/init/fn_initServer.sqf | 15 +++- 2 files changed, 92 insertions(+), 8 deletions(-) diff --git a/functions/fbcb2/assets/byBase/fn_updateAssetsByBase.sqf b/functions/fbcb2/assets/byBase/fn_updateAssetsByBase.sqf index da06aef..e243526 100644 --- a/functions/fbcb2/assets/byBase/fn_updateAssetsByBase.sqf +++ b/functions/fbcb2/assets/byBase/fn_updateAssetsByBase.sqf @@ -1,5 +1,9 @@ -params [["_isInit", false, [false]]]; +params [ + ["_isInit", false, [false]], + ["_logCurrentAssets", false, [false]] +]; +if (!isServer) exitWith {}; // Get all approved assets on map, find the closest base // Then determine if it's within range @@ -10,6 +14,7 @@ private _allSaved = []; private _assetsAtThisBaseVar = "milsim_fbcb2_assets_assetsAtThisBase"; private _assetsStartedAtThisBaseVar = "milsim_fbcb2_assets_assetsStartedAtThisBase"; + { private _className = configName _x; private _callsign = getText(_x >> "callsign"); @@ -94,13 +99,81 @@ private _assetsStartedAtThisBaseVar = "milsim_fbcb2_assets_assetsStartedAtThisBa }; } forEach (_allVehicles select { _x isKindOf "LandVehicle" }); - -// make the asset lists public +//////////////////////////////////////////////////////////////////////// +// publish updated base variables +//////////////////////////////////////////////////////////////////////// { - private _baseAssets = _x getVariable [_assetsAtThisBaseVar, []]; - _x setVariable [_assetsAtThisBaseVar, _baseAssets, true]; + private _base = _x; + + // save current assets + private _baseAssets = _base getVariable [_assetsAtThisBaseVar, []]; + _base setVariable [_assetsAtThisBaseVar, _baseAssets, true]; + + // if init, save starting assets if (_isInit) then { - _x setVariable [_assetsStartedAtThisBaseVar, _baseAssets, true]; + _base setVariable [_assetsStartedAtThisBaseVar, _baseAssets, true]; }; } forEach milsim_baseObjects; +//////////////////////////////////////////////////////////////////////// +// log starting assets if init +// log current assets if requested (for end of mission counts) +//////////////////////////////////////////////////////////////////////// +if !(_isInit || _logCurrentAssets) exitWith {}; + +{ + private _base = _x; + + // get current assets + private _baseAssets = _base getVariable [_assetsAtThisBaseVar, []]; + + // prepare key value for logging + private _baseAssetsHashesPrep = _baseAssets apply { + private _asset = _x; + [ + ["callsign", _asset getVariable [ + "milsim_fbcb2_assets_callsign", + "N/A" + ]], + ["className", typeOf _asset], + ["displayName", (configOf _asset) call BIS_fnc_displayName] + ]; + }; + + _baseAssetsHashesPrep = _baseAssetsHashesPrep call BIS_fnc_consolidateArray; + + private _baseAssetsHashes = []; + { + private _out = createHashMapFromArray (_x#0); + _out set ["count", _x#1]; + _baseAssetsHashes pushBack _out; + } forEach _baseAssetsHashesPrep; + + // if logging current assets + if (_logCurrentAssets) then { + { + [ + "fbcb2_assets", + "CURRENT ASSETS", + [ + ["baseName", [[_base] call milsim_fnc_getNameOfBase]], + ["asset", _x] + ] + ] call milsim_fnc_log; + } forEach _baseAssetsHashes; + }; + + // if init, log starting assets + if (_isInit) then { + { + [ + "fbcb2_assets", + "STARTING ASSETS", + [ + ["baseName", [[_base] call milsim_fnc_getNameOfBase]], + ["asset", _x] + ] + ] call milsim_fnc_log; + } forEach _baseAssetsHashes; + }; +} forEach milsim_baseObjects; \ No newline at end of file diff --git a/functions/init/fn_initServer.sqf b/functions/init/fn_initServer.sqf index e851136..b3f1e57 100644 --- a/functions/init/fn_initServer.sqf +++ b/functions/init/fn_initServer.sqf @@ -8,8 +8,19 @@ publicVariable "milsim_baseObjects"; // init asset stores at bases [true] call milsim_fbcb2_assets_fnc_updateAssetsByBase; -// run update every 5 minutes -[{[false] call milsim_fbcb2_assets_fnc_updateAssetsByBase;}, 60*5] call CBA_fnc_addPerFrameHandler; +// starting 5 minutes after postInit, update asset stores every 5 minutes +[{ + [ + {[false] call milsim_fbcb2_assets_fnc_updateAssetsByBase;}, + 60*5 + ] call CBA_fnc_addPerFrameHandler; +}, 60*5] call CBA_fnc_waitAndExecute; + +// add end mission EH +addMissionEventHandler ["MPEnded", { + // log the "current" asset counts to RPT + [false, true] call milsim_fbcb2_assets_fnc_updateAssetsByBase; +}]; // Initializes the Dynamic Groups framework and groups ["Initialize", [true]] call BIS_fnc_dynamicGroups; -- 2.37.3.windows.1 From b8b8f1de224a27b66bb5dcd6c3832a0e134a9f35 Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Sat, 3 Feb 2024 13:53:28 -0800 Subject: [PATCH 04/16] use netId in dairy entry link for dedicated to work --- .../fbcb2/assets/fn_updateAssetDiary.sqf | 8 +++-- .../assets/markers/fn_showMarkersOnMap.sqf | 29 ++++--------------- 2 files changed, 12 insertions(+), 25 deletions(-) diff --git a/functions/fbcb2/assets/fn_updateAssetDiary.sqf b/functions/fbcb2/assets/fn_updateAssetDiary.sqf index 9709b9d..b17763e 100644 --- a/functions/fbcb2/assets/fn_updateAssetDiary.sqf +++ b/functions/fbcb2/assets/fn_updateAssetDiary.sqf @@ -112,14 +112,18 @@ private _distinctVehiclesClassNames = []; }; // Link to show markers - _recordText pushBack format[ + private _showMarkersText = format[ "SHOW MARKERS at vehicle positions (in %5)", _className, _markerType, _randomColor#0, - _vehiclesOfThisKind, + (_vehiclesOfThisKind apply { + format["%1", _x call BIS_fnc_netId] + }), format["%2", _randomColor#1, _randomColor#2] ]; + hint _showMarkersText; + _recordText pushBack _showMarkersText; // Link to hide markers _recordText pushBack "REMOVE ALL MARKERS showing asset positions"; diff --git a/functions/fbcb2/assets/markers/fn_showMarkersOnMap.sqf b/functions/fbcb2/assets/markers/fn_showMarkersOnMap.sqf index c28426b..c804d76 100644 --- a/functions/fbcb2/assets/markers/fn_showMarkersOnMap.sqf +++ b/functions/fbcb2/assets/markers/fn_showMarkersOnMap.sqf @@ -30,7 +30,7 @@ private _assetMarkerStore = localNamespace getVariable [ /////////////////////////////////////////////////////////////////////////////// // Create base markers if not already present if (not (count _baseMarkerStore > 0)) then { - { + { // milsim_baseObjects is accessed directly, so are valid objects private _base = _x; // create a circle marker with range as the detection range of assets @@ -74,9 +74,9 @@ if (not (count _baseMarkerStore > 0)) then { private _start = (count _assetMarkerStore) + 1; -private _createdAssetMarkers = []; -{ - private _asset = _x; +{ // _assetObjects is a serialized parameter, so we pass the netIds (strings) + private _assetNetIdStr = _x; + private _asset = _assetNetIdStr call BIS_fnc_objectFromNetId; // if asset was removed since last update if (isNull _asset) then {continue}; // check if a marker is already placed for this asset @@ -90,34 +90,17 @@ private _createdAssetMarkers = []; format["milsim_fbcb2_assets_marker_%1", _start], getPosASL _asset ]; - _newMarker setMarkerAlphaLocal 0; + _newMarker setMarkerAlphaLocal 1; _newMarker setMarkerTypeLocal _markerType; _newMarker setMarkerColorLocal _markerColor; // _newMarker setMarkerTextLocal ([configOf _asset] call BIS_fnc_displayName); - _createdAssetMarkers pushBack [ + _assetMarkerStore pushBack [ _asset, _newMarker ]; _start = _start + 1; } forEach _assetObjects; -// unhide added asset markers sequentially -[_createdAssetMarkers apply {_x#1}] spawn { - params ["_markers"]; - for "_alpha" from 0.0 to 1.0 step 0.03 do - { - { - _x setMarkerAlphaLocal _alpha; - } forEach _markers; - Sleep 0.002; - }; -}; - -// add to store -{ - _assetMarkerStore pushBack _x; -} forEach _createdAssetMarkers; - // update store var localNamespace setVariable [_assetMarkerStoreVar, _assetMarkerStore]; -- 2.37.3.windows.1 From affc8ffb1f05e781bea7b92e1b7f43b1f7d54aa6 Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Sat, 3 Feb 2024 15:04:47 -0800 Subject: [PATCH 05/16] remove debug hint --- functions/fbcb2/assets/fn_updateAssetDiary.sqf | 1 - 1 file changed, 1 deletion(-) diff --git a/functions/fbcb2/assets/fn_updateAssetDiary.sqf b/functions/fbcb2/assets/fn_updateAssetDiary.sqf index b17763e..784242f 100644 --- a/functions/fbcb2/assets/fn_updateAssetDiary.sqf +++ b/functions/fbcb2/assets/fn_updateAssetDiary.sqf @@ -122,7 +122,6 @@ private _distinctVehiclesClassNames = []; }), format["%2", _randomColor#1, _randomColor#2] ]; - hint _showMarkersText; _recordText pushBack _showMarkersText; // Link to hide markers -- 2.37.3.windows.1 From 7ef48ecaa2786424eb74b16fc37f01977677f5b9 Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Sat, 3 Feb 2024 18:40:18 -0800 Subject: [PATCH 06/16] move to cfg, update createbox, create /defines --- defines/ApprovedAssets.hpp | 22 ++ .../definitions => defines}/BattalionInfo.hpp | 0 .../DisallowedEquipment.hpp | 0 defines/SupplyCrates.hpp | 180 ++++++++++++++++ description.ext | 7 +- functions/CfgFunctions.hpp | 25 ++- functions/client/fn_addZenModules.sqf | 34 +-- functions/definitions/ApprovedAssets.hpp | 22 -- functions/init/fn_initPlayerLocal.sqf | 3 - functions/init/fn_initServer.sqf | 3 - functions/resupply/fn_crateDefinitions.sqf | 201 ------------------ functions/resupply/fn_createBox.sqf | 132 +++++++++--- functions/resupply/fn_getSupplyCratesCfg.sqf | 1 + 13 files changed, 339 insertions(+), 291 deletions(-) create mode 100644 defines/ApprovedAssets.hpp rename {functions/definitions => defines}/BattalionInfo.hpp (100%) rename {functions/definitions => defines}/DisallowedEquipment.hpp (100%) create mode 100644 defines/SupplyCrates.hpp delete mode 100644 functions/definitions/ApprovedAssets.hpp delete mode 100644 functions/resupply/fn_crateDefinitions.sqf create mode 100644 functions/resupply/fn_getSupplyCratesCfg.sqf diff --git a/defines/ApprovedAssets.hpp b/defines/ApprovedAssets.hpp new file mode 100644 index 0000000..32a80f5 --- /dev/null +++ b/defines/ApprovedAssets.hpp @@ -0,0 +1,22 @@ +// Lists approved fixed-wing and rotary vehicle types that mission makers can use in their missions. + +class ApprovedAssets { + // Fixed-wing aircraft + class USAF_A10 {callsign = "Ares";}; + class RHSGREF_A29B_HIDF {callsign = "Odyssey";}; + class USAF_C130J {callsign = "Hercules";}; + // Rotary aircraft + class RHS_MELB_MH6M {callsign = "Apollo";}; + class RHS_MELB_AH6M {callsign = "Artemis";}; + class RHS_MELB_H6M {callsign = "Icarus";}; + class RHS_CH_47F {callsign = "Achilles";}; + class ej_MH60MDAP4 {callsign = "Hades";}; + class RHS_UH60M {callsign = "Griffin";}; + class RHS_UH60M_MEV2 {callsign = "Dustoff";}; + class B_T_VTOL_01_INFANTRY_F {callsign = "Pegasus";}; + class B_T_VTOL_01_ARMED_F {callsign = "Spartan";}; + class RHS_AH64D {callsign = "Orion";}; + class RHS_AH1Z {callsign = "Athena";}; + class RHS_UH1Y {callsign = "Homer";}; + class rhsusf_CH53E_USMC {callsign = "Atlas";}; +}; \ No newline at end of file diff --git a/functions/definitions/BattalionInfo.hpp b/defines/BattalionInfo.hpp similarity index 100% rename from functions/definitions/BattalionInfo.hpp rename to defines/BattalionInfo.hpp diff --git a/functions/definitions/DisallowedEquipment.hpp b/defines/DisallowedEquipment.hpp similarity index 100% rename from functions/definitions/DisallowedEquipment.hpp rename to defines/DisallowedEquipment.hpp diff --git a/defines/SupplyCrates.hpp b/defines/SupplyCrates.hpp new file mode 100644 index 0000000..a1cebac --- /dev/null +++ b/defines/SupplyCrates.hpp @@ -0,0 +1,180 @@ +class SupplyCrates { + class AmmoSquad { + boxClass = "Box_Syndicate_Ammo_F"; + displayName = "Squad Ammo"; + tooltip = "A crate containing general ammunition and equipment for an infantry squad."; + icon = "\A3\ui_f\data\map\vehicleicons\iconCrateAmmo_ca.paa"; + + backpacks[] = {}; + weapons[] = { + {"rhs_weap_M136",4}, + {"rhs_weap_M136_hp",4}, + {"rhs_weap_m72a7",2} + }; + magazines[] = { + {"1Rnd_SmokePurple_Grenade_shell",12}, + {"1Rnd_SmokeBlue_Grenade_shell",24}, + {"1Rnd_SmokeOrange_Grenade_shell",12}, + {"rhs_mag_M441_HE",25}, + {"rhs_mag_M433_HEDP",15}, + {"ACE_40mm_Flare_ir",12}, + {"rhsusf_200Rnd_556x45_mixed_soft_pouch_coyote",25}, + {"rhsusf_20Rnd_762x51_m993_Mag",25}, + {"SmokeShell",12}, + {"rhs_mag_m67",12}, + {"1Rnd_Smoke_Grenade_shell",24}, + {"1Rnd_SmokeRed_Grenade_shell",24}, + {"1Rnd_SmokeGreen_Grenade_shell",24}, + {"1Rnd_SmokeYellow_Grenade_shell",12}, + {"Tier1_30Rnd_556x45_M856A1_EMag",25}, + {"Tier1_30Rnd_556x45_Mk318Mod0_EMag",75}, + {"ACE_30Rnd_65_Creedmor_mag",25}, + {"SMA_30Rnd_762x35_BLK_EPR",25}, + {"Tier1_30Rnd_762x35_300BLK_SMK_PMAG",25}, + {"SMA_30Rnd_68x43_SPC_FMJ",25}, + {"SMA_30Rnd_68x43_SPC_FMJ_Tracer",25}, + {"SMA_20Rnd_762x51mm_M80A1_EPR",25}, + {"SMA_20Rnd_762x51mm_M80A1_EPR_Tracer",25}, + {"SMA_20Rnd_762x51mm_Mk316_Mod_0_Special_Long_Range",25}, + {"SMA_20Rnd_762x51mm_Mk316_Mod_0_Special_Long_Range_Tracer",25}, + {"Tier1_250Rnd_762x51_Belt_M993_AP",15}, + {"ACE_20Rnd_762x51_Mag_Tracer",25}, + {"ACE_20Rnd_762x51_M993_AP_Mag",25}, + {"rhsusf_20Rnd_762x51_SR25_m993_Mag",25}, + {"Tier1_20Rnd_762x51_M993_SR25_Mag",25}, + {"Tier1_20Rnd_65x48_Creedmoor_SR25_Mag",25}, + {"rhssaf_30rnd_556x45_EPR_G36", 25}, + {"DemoCharge_Remote_Mag",16} + }; + items[] = {}; + }; + + class AmmoHeavy { + boxClass = "Box_NATO_Wps_F"; + displayName = "Heavy Ammo"; + tooltip = "A crate containing mixed ammo for rifles, ARs, MAT, and HAT."; + icon = "\A3\ui_f\data\map\vehicleicons\iconCrateWpns_ca.paa"; + + backpacks[] = {}; + weapons[] = {}; + magazines[] = { + {"MRAWS_HEAT_F",35}, + {"MRAWS_HE_F",15}, + {"Tier1_250Rnd_762x51_Belt_M993_AP",50}, + {"Tier1_30Rnd_556x45_M856A1_EMag",25}, + {"Tier1_30Rnd_556x45_Mk318Mod0_EMag",50}, + {"Titan_AA",10}, + {"Titan_AT",10}, + {"200Rnd_65x39_cased_Box_Tracer_Red",50} + }; + items[] = {}; + }; + + class MedicalSupplies { + boxClass = "ACE_medicalSupplyCrate_advanced"; + displayName = "Medical Crate"; + tooltip = "A crate containing medical supplies."; + icon = "\A3\ui_f\data\map\vehicleicons\pictureHeal_ca.paa"; + + backpacks[] = {}; + weapons[] = {}; + magazines[] = {}; + items[] = { + {"ACE_packingBandage",100}, + {"ACE_elasticBandage",100}, + {"ACE_tourniquet",48}, + {"ACE_splint",48}, + {"ACE_morphine",50}, + {"ACE_epinephrine",50}, + {"ACE_bloodIV",75}, + {"ACE_bloodIV_500",50}, + {"ACE_bloodIV_250",25}, + {"ACE_quikclot",75}, + {"ACE_personalAidKit", 5}, + {"ACE_surgicalKit", 5} + }; + }; + + class Launchers { + boxClass = "Box_NATO_WpsLaunch_F"; + displayName = "Launcher Crate"; + tooltip = "A crate containing missile launchers and ammunition."; + icon = "\A3\ui_f\data\map\vehicleicons\iconCrateLong_ca.paa"; + + backpacks[] = {}; + weapons[] = { + {"launch_B_Titan_short_F",2}, + {"launch_NLAW_F",2}, + {"rhs_weap_fim92",2} + }; + magazines[] = { + {"Titan_AA",6}, + {"Titan_AT",6} + }; + items[] = {}; + }; + + class CrewServedWeapons { + boxClass = "Box_NATO_Equip_F"; + displayName = "CSW Crate"; + tooltip = "A crate containing backpacks that assemble into static weapons."; + icon = "\A3\ui_f\data\igui\cfg\simpleTasks\types\defend_ca.paa"; + + backpacks[] = { + {"RHS_M2_Gun_Bag",2}, + {"RHS_M2_Tripod_Bag",2}, + {"RHS_M2_MiniTripod_Bag",2}, + {"rhs_Tow_Gun_Bag",2}, + {"rhs_TOW_Tripod_Bag",2}, + {"UK3CB_Static_M240_Elcan_Gun_Bag",2}, + {"UK3CB_B_Static_M240_Elcan_Tripod_Low_Bag_US_D",2}, + {"RHS_Mk19_Gun_Bag",2}, + {"RHS_Mk19_Tripod_Bag",2} + }; + weapons[] = {}; + magazines[] = {}; + items[] = {}; + }; + + class MortarMk6Resupply { + boxClass = "Box_NATO_WpsSpecial_F"; + displayName = "Mortar MK6 Supply Crate"; + tooltip = "A crate containing Mk6 mortar resupply (tubes) and tools."; + icon = "\A3\ui_f\data\map\vehicleicons\iconStaticMortar_ca.paa"; + + backpacks[] = { + {"B_Mortar_01_support_F",3}, + {"B_Mortar_01_weapon_F",6}, + {"UK3CB_LSM_B_B_CARRYALL_RADIO_TIG_STRIPE_01",1} + }; + weapons[] = { + {"ACE_Vector",2} + }; + magazines[] = { + {"acex_intelitems_notepad",2} + }; + items[] = { + {"ACE_artilleryTable",2}, + {"ACE_RangeTable_82mm",2}, + {"ACE_microDAGR",2}, + {"ACE_MapTools",2} + }; + }; + + class Mortar60mmCommandoResupply { + boxClass = "Box_NATO_WpsSpecial_F"; + displayName = "Mortar 60mm Commando Supply Crate"; + tooltip = "A crate containing COMMANDO 60mm mortar shells and some STANAGs."; + icon = "\A3\ui_f\data\igui\cfg\simpleTasks\types\scout_ca.paa"; + + backpacks[] = {}; + weapons[] = {}; + magazines[] = { + {"twc_2inch_he_1rnd",70}, + {"twc_2inch_smoke_1rnd",15}, + {"twc_2inch_illum_1rnd",15}, + {"Tier1_30Rnd_556x45_Mk318Mod0_EMag",20} + }; + items[] = {}; + }; +}; \ No newline at end of file diff --git a/description.ext b/description.ext index 232b61e..9781ede 100644 --- a/description.ext +++ b/description.ext @@ -17,9 +17,10 @@ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #include "mission_settings.hpp" -#include "functions\definitions\DisallowedEquipment.hpp" -#include "functions\definitions\BattalionInfo.hpp" -#include "functions\definitions\ApprovedAssets.hpp" +#include "defines\ApprovedAssets.hpp" +#include "defines\BattalionInfo.hpp" +#include "defines\DisallowedEquipment.hpp" +#include "defines\SupplyCrates.hpp" //-------------------------------------------MISSION INFO-------------------------------------------------------------------- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/functions/CfgFunctions.hpp b/functions/CfgFunctions.hpp index d8d6331..68eae3c 100644 --- a/functions/CfgFunctions.hpp +++ b/functions/CfgFunctions.hpp @@ -49,17 +49,6 @@ class milsim class logPlayerInventory {}; }; - class resupply { - class crateDefinitions {}; - class createAmmoBox {}; - class createBox {}; - class createCSWBox {}; - class createLaunchersBox {}; - class createMedicalBox {}; - class createMortarBox {}; - class createWeaponsBox {}; - } - class ambience { class flakInitVehicle {}; class flakEH {}; @@ -88,6 +77,20 @@ class milsim }; }; +class milsim_resupply { + class functions { + file = "functions\resupply"; + class createAmmoBox {}; + class createBox {}; + class createCSWBox {}; + class createLaunchersBox {}; + class createMedicalBox {}; + class createMortarBox {}; + class createWeaponsBox {}; + class getSupplyCratesCfg {}; + }; +}; + class milsim_fbcb2_assets { class functions { file = "functions\fbcb2\assets"; diff --git a/functions/client/fn_addZenModules.sqf b/functions/client/fn_addZenModules.sqf index ec7ca94..211aa43 100644 --- a/functions/client/fn_addZenModules.sqf +++ b/functions/client/fn_addZenModules.sqf @@ -5,24 +5,28 @@ if ( !hasInterface ) exitWith {}; "Create Resupply Box", { params [["_pos", [0,0,0], [[]], 3], ["_target", objNull, [objNull]]]; - _keysSorted = keys milsim_resupply_crateDefinitions; - _keysSorted sort true; - _comboOptions = []; - _comboOptions resize (count _keysSorted); - for "_i" from 0 to (count _keysSorted) - 1 do { - private _definition = milsim_resupply_crateDefinitions get (_keysSorted select _i); - _comboOptions set [_i, [ - _definition getOrDefault ["displayName", "ERROR"], // display name - _definition getOrDefault ["description", "No description"], // tooltip - _definition getOrDefault ["icon", "No icon"] // icon - ]]; + // get parent definition + private _supplyCratesCfg = call milsim_resupply_fnc_getSupplyCratesCfg; + // get the subclass names + private _boxTypesAvailable = _supplyCratesCfg call BIS_fnc_getCfgSubClasses; + + _boxTypesAvailable sort true; + _comboOptions = _boxTypesAvailable apply { + [ + // display name + [_supplyCratesCfg >> _x >> "displayName", "STRING", "ERROR"] call CBA_fnc_getConfigEntry, + // tooltip + [_supplyCratesCfg >> _x >> "tooltip", "STRING", "ERROR"] call CBA_fnc_getConfigEntry, + // icon + [_supplyCratesCfg >> _x >> "icon", "STRING", "ERROR"] call CBA_fnc_getConfigEntry + ] }; [ "Resupply Box Options", [ // [ "COMBO", "Box Type", [[1,2,3], [["Ammo"],["Weapons"],["Medical"]],0] ] - ["COMBO", "Box Type", [_keysSorted, _comboOptions, 0]] + ["COMBO", "Box Type", [_boxTypesAvailable, _comboOptions, 0]] ], { @@ -32,14 +36,14 @@ if ( !hasInterface ) exitWith {}; _args params ["_pos", "_target", "_keysSorted"]; - private _box = [_target, _typeOptionSelected, _pos] call milsim_fnc_createBox; + private _box = [_target, _typeOptionSelected, _pos] call milsim_resupply_fnc_createBox; if (isNull _box) exitWith { ["Resupply Box", "WARNING: Failed to locate or create box!"] call BIS_fnc_curatorHint; }; - ["Resupply Box", format["Created a %1 box", _typeOptionSelected]] call BIS_fnc_curatorHint; + ["Resupply Box", format["Created box from class %1", _typeOptionSelected]] call BIS_fnc_curatorHint; }, {}, - [_pos, _target, _options] + [_pos, _target] ] call zen_dialog_fnc_create; } ] call zen_custom_modules_fnc_register; diff --git a/functions/definitions/ApprovedAssets.hpp b/functions/definitions/ApprovedAssets.hpp deleted file mode 100644 index b9af09e..0000000 --- a/functions/definitions/ApprovedAssets.hpp +++ /dev/null @@ -1,22 +0,0 @@ -// Lists approved fixed-wing and rotary vehicle types that mission makers can use in their missions. - -class ApprovedAssets { - // Fixed-wing aircraft - class USAF_A10 {callsign = "Ares";assetType = "FixedWing";}; - class RHSGREF_A29B_HIDF {callsign = "Odyssey";assetType = "FixedWing";}; - class USAF_C130J {callsign = "Hercules";assetType = "FixedWing";}; - // Rotary aircraft - class RHS_MELB_MH6M {callsign = "Apollo";assetType = "Rotary";}; - class RHS_MELB_AH6M {callsign = "Artemis";assetType = "Rotary";}; - class RHS_MELB_H6M {callsign = "Icarus";assetType = "Rotary";}; - class RHS_CH_47F {callsign = "Achilles";assetType = "Rotary";}; - class ej_MH60MDAP4 {callsign = "Hades";assetType = "Rotary";}; - class RHS_UH60M {callsign = "Griffin";assetType = "Rotary";}; - class RHS_UH60M_MEV2 {callsign = "Dustoff";assetType = "Rotary";}; - class B_T_VTOL_01_INFANTRY_F {callsign = "Pegasus";assetType = "Rotary";}; - class B_T_VTOL_01_ARMED_F {callsign = "Spartan";assetType = "Rotary";}; - class RHS_AH64D {callsign = "Orion";assetType = "Rotary";}; - class RHS_AH1Z {callsign = "Athena";assetType = "Rotary";}; - class RHS_UH1Y {callsign = "Homer";assetType = "Rotary";}; - class rhsusf_CH53E_USMC {callsign = "Atlas";assetType = "Rotary";}; -}; \ No newline at end of file diff --git a/functions/init/fn_initPlayerLocal.sqf b/functions/init/fn_initPlayerLocal.sqf index efdebe5..d72495f 100644 --- a/functions/init/fn_initPlayerLocal.sqf +++ b/functions/init/fn_initPlayerLocal.sqf @@ -9,9 +9,6 @@ if (!isServer) then { }] call CBA_fnc_addEventHandler; }; -// define milsim_resupply_crateDefinitions -call milsim_fnc_crateDefinitions; - ["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 b3f1e57..d70c518 100644 --- a/functions/init/fn_initServer.sqf +++ b/functions/init/fn_initServer.sqf @@ -1,8 +1,5 @@ if (!isServer) exitWith {}; -// define milsim_resupply_crateDefinitions -call milsim_fnc_crateDefinitions; - milsim_baseObjects = allMissionObjects "ModuleRespawnPosition_F"; publicVariable "milsim_baseObjects"; diff --git a/functions/resupply/fn_crateDefinitions.sqf b/functions/resupply/fn_crateDefinitions.sqf deleted file mode 100644 index 17bb3e8..0000000 --- a/functions/resupply/fn_crateDefinitions.sqf +++ /dev/null @@ -1,201 +0,0 @@ -milsim_resupply_crateDefinitions = createHashMapFromArray [ - ["AMMO LIGHT", createHashMapFromArray [ - ["className", "Box_Syndicate_Ammo_F"], - ["displayName", "Ammo Crate"], - ["description", "A crate containing general ammunition and equipment for an infantry squad."], - ["icon", "\A3\ui_f\data\igui\cfg\simpleTasks\types\rifle_ca.paa"], - ["items", createHashMapFromArray [ - ["backpacks", []], - ["weapons", [ - ["rhs_weap_M136",4], - ["rhs_weap_M136_hp",4], - ["rhs_weap_m72a7",2] - ]], - ["magazines", [ - ["1Rnd_SmokePurple_Grenade_shell",12], - ["1Rnd_SmokeBlue_Grenade_shell",24], - ["1Rnd_SmokeOrange_Grenade_shell",12], - ["rhs_mag_M441_HE",25], - ["rhs_mag_M433_HEDP",15], - ["ACE_40mm_Flare_ir",12], - ["rhsusf_200Rnd_556x45_mixed_soft_pouch_coyote",25], - ["rhsusf_20Rnd_762x51_m993_Mag",25], - ["SmokeShell",12], - ["rhs_mag_m67",12], - ["1Rnd_Smoke_Grenade_shell",24], - ["1Rnd_SmokeRed_Grenade_shell",24], - ["1Rnd_SmokeGreen_Grenade_shell",24], - ["1Rnd_SmokeYellow_Grenade_shell",12], - ["Tier1_30Rnd_556x45_M856A1_EMag",25], - ["Tier1_30Rnd_556x45_Mk318Mod0_EMag",75], - ["ACE_30Rnd_65_Creedmor_mag",25], - ["SMA_30Rnd_762x35_BLK_EPR",25], - ["Tier1_30Rnd_762x35_300BLK_SMK_PMAG",25], - ["SMA_30Rnd_68x43_SPC_FMJ",25], - ["SMA_30Rnd_68x43_SPC_FMJ_Tracer",25], - ["SMA_20Rnd_762x51mm_M80A1_EPR",25], - ["SMA_20Rnd_762x51mm_M80A1_EPR_Tracer",25], - ["SMA_20Rnd_762x51mm_Mk316_Mod_0_Special_Long_Range",25], - ["SMA_20Rnd_762x51mm_Mk316_Mod_0_Special_Long_Range_Tracer",25], - ["Tier1_250Rnd_762x51_Belt_M993_AP",15], - ["ACE_20Rnd_762x51_Mag_Tracer",25], - ["ACE_20Rnd_762x51_M993_AP_Mag",25], - ["rhsusf_20Rnd_762x51_SR25_m993_Mag",25], - ["Tier1_20Rnd_762x51_M993_SR25_Mag",25], - ["Tier1_20Rnd_65x48_Creedmoor_SR25_Mag",25], - ["rhssaf_30rnd_556x45_EPR_G36", 25], - ["DemoCharge_Remote_Mag",16] - ]], - ["items", []] - ] - ]]], - ["AMMO HEAVY", createHashMapFromArray [ - ["className", "Box_NATO_Wps_F"], - ["displayName", "Heavy Ammo Crate"], - ["description", "A crate containing mixed ammo for rifles, ARs, MAT, and HAT."], - ["icon", "\A3\ui_f\data\igui\cfg\simpleTasks\types\heli_ca.paa"], - ["items", createHashMapFromArray [ - ["backpacks", []], - ["weapons", []], - ["magazines", [ - ["MRAWS_HEAT_F",35], - ["MRAWS_HE_F",15], - ["Tier1_250Rnd_762x51_Belt_M993_AP",50], - ["Tier1_30Rnd_556x45_M856A1_EMag",25], - ["Tier1_30Rnd_556x45_Mk318Mod0_EMag",50], - ["Titan_AA",10], - ["Titan_AT",10], - ["200Rnd_65x39_cased_Box_Tracer_Red",50] - ]], - ["items", []] - ] - ]]], - ["AMMO MORTAR", createHashMapFromArray [ - ["className", "Box_Syndicate_Wps_F"], - ["displayName", "Mortar Ammo Crate"], - ["description", "A crate containing mortar ammunition."], - ["icon", "\A3\ui_f\data\igui\cfg\simpleTasks\types\scout_ca.paa"], - ["items", createHashMapFromArray [ - ["backpacks", []], - ["weapons", []], - ["magazines", [ - ["ACE_1Rnd_82mm_Mo_HE",24], - ["ACE_1Rnd_82mm_Mo_Smoke",12], - ["ACE_1Rnd_82mm_Mo_Illum",12] - ]], - ["items", []] - ] - ]]], - ["MEDICAL", createHashMapFromArray [ - ["className", "ACE_medicalSupplyCrate_advanced"], - ["displayName", "Medical Crate"], - ["description", "A crate containing medical supplies."], - ["icon", "\A3\ui_f\data\igui\cfg\simpleTasks\types\heal_ca.paa"], - ["items", createHashMapFromArray [ - ["backpacks", []], - ["weapons", []], - ["magazines", []], - ["items", [ - ["ACE_packingBandage",100], - ["ACE_elasticBandage",100], - ["ACE_tourniquet",48], - ["ACE_splint",48], - ["ACE_morphine",50], - ["ACE_epinephrine",50], - ["ACE_bloodIV",75], - ["ACE_bloodIV_500",50], - ["ACE_bloodIV_250",25], - ["ACE_quikclot",75], - ["ACE_personalAidKit", 5], - ["ACE_surgicalKit", 5] - ]] - ] - ]]], - ["LAUNCHERS", createHashMapFromArray [ - ["className", "Box_NATO_WpsLaunch_F"], - ["displayName", "Launcher Crate"], - ["description", "A crate containing missile launchers and ammunition."], - ["icon", "\A3\ui_f\data\igui\cfg\simpleTasks\types\heli_ca.paa"], - ["items", createHashMapFromArray [ - ["backpacks", [ - - ]], - ["weapons", [ - ["launch_B_Titan_short_F",2], - ["launch_NLAW_F",2], - ["rhs_weap_fim92",2] - ]], - ["magazines", [ - ["Titan_AA",6], - ["Titan_AT",6] - ]], - ["items", [ - - ]] - ] - ]]], - ["CSW", createHashMapFromArray [ - ["className", "Box_NATO_Equip_F"], - ["displayName", "CSW Crate"], - ["description", "A crate containing backpacks that assemble into static weapons."], - ["icon", "\A3\ui_f\data\igui\cfg\simpleTasks\types\defend_ca.paa"], - ["items", createHashMapFromArray [ - ["backpacks", [ - ["RHS_M2_Gun_Bag",2], - ["RHS_M2_Tripod_Bag",2], - ["RHS_M2_MiniTripod_Bag",2], - ["rhs_Tow_Gun_Bag",2], - ["rhs_TOW_Tripod_Bag",2], - ["UK3CB_Static_M240_Elcan_Gun_Bag",2], - ["UK3CB_B_Static_M240_Elcan_Tripod_Low_Bag_US_D",2], - ["RHS_Mk19_Gun_Bag",2], - ["RHS_Mk19_Tripod_Bag",2] - ]], - ["weapons", []], - ["magazines", []], - ["items", []] - ] - ]]], - ["MORTAR MK6", createHashMapFromArray [ - ["className", "Box_NATO_WpsSpecial_F"], - ["displayName", "Mortar MK6 Supply Crate"], - ["description", "A crate containing Mk6 mortar resupply (tubes) and tools."], - ["icon", "\A3\ui_f\data\igui\cfg\simpleTasks\types\scout_ca.paa"], - ["items", createHashMapFromArray [ - ["backpacks", [ - ["B_Mortar_01_support_F",3], - ["B_Mortar_01_weapon_F",6], - ["UK3CB_LSM_B_B_CARRYALL_RADIO_TIG_STRIPE_01",1] - ]], - ["weapons", [ - ["ACE_Vector",2] - ]], - ["magazines", [ - ["acex_intelitems_notepad",2] - ]], - ["items", [ - ["ACE_artilleryTable",2], - ["ACE_RangeTable_82mm",2], - ["ACE_microDAGR",2], - ["ACE_MapTools",2] - ]] - ] - ]]], - ["MORTAR 60MM COMMANDO", createHashMapFromArray [ - ["className", "Box_NATO_WpsSpecial_F"], - ["displayName", "Mortar 60mm Commando Supply Crate"], - ["description", "A crate containing COMMANDO 60mm mortar shells and some STANAGs."], - ["icon", "\A3\ui_f\data\igui\cfg\simpleTasks\types\scout_ca.paa"], - ["items", createHashMapFromArray [ - ["backpacks", []], - ["weapons", []], - ["magazines", [ - ["twc_2inch_he_1rnd",70], - ["twc_2inch_smoke_1rnd",15], - ["twc_2inch_illum_1rnd",15], - ["Tier1_30Rnd_556x45_Mk318Mod0_EMag",20] - ]], - ["items", []] - ] - ]]] -]; \ No newline at end of file diff --git a/functions/resupply/fn_createBox.sqf b/functions/resupply/fn_createBox.sqf index 0917746..b4576ef 100644 --- a/functions/resupply/fn_createBox.sqf +++ b/functions/resupply/fn_createBox.sqf @@ -1,18 +1,19 @@ /* * Author: Hizumi & IndigoFox * - * Create Mortar resupply box for the 17th Battalion + * Create Mortar resupply box for the 17th Battalion. Primarily called from milsim_fnc_addZenModules * * Arguments: * 0: Vehicle - - * 1: Position - + * 1: Type - + * 2: Position - * * Return Value: * Function executed * * Example: - * [box] call milsim_fnc_createBox; // create mortar ammo box via init line of editor object - * [objNull, pos] call milsim_fnc_createBox; // create mortar ammo box via zeus module + * [box, "AmmoSquad"] call milsim_fnc_createBox; // create mortar ammo box via init line of editor object + * [objNull, "AmmoHeavy", pos] call milsim_fnc_createBox; // create mortar ammo box via zeus module * * Public: Yes * @@ -34,68 +35,133 @@ params [ ["_pos", [0,0,0], [[]], 3] ]; -if (isNil "milsim_resupply_crateDefinitions") exitWith { - format["Resupply Boxes: milsim_resupply_crateDefinitions is not defined, possibly a bad edit?"] remoteExec ["systemChat", 0]; - false; +// get defs class +private _supplyCratesCfg = call milsim_resupply_fnc_getSupplyCratesCfg; +if (!isClass _supplyCratesCfg) exitWith { + ["Resupply Boxes: Failed to load crate definitions, possibly a bad edit?"] call BIS_fnc_error; + objNull; }; +// get the subclass names +private _boxTypesAvailable = _supplyCratesCfg call BIS_fnc_getCfgSubClasses; + +// if no type is provided, show the available types if (_type isEqualTo "") exitWith { - format["Resupply Boxes: [_boxObject, _type, _pos] call milsim_fnc_createBox"] remoteExec ["systemChat", 0]; - format["Please use one of the following types for _type:"] remoteExec ["systemChat", 0]; - format["%1", (keys milsim_resupply_crateDefinitions)] remoteExec ["systemChat", 0]; - false; + [ + "%1 | %2 %3", + "Resupply Boxes: [_boxObject, _type, _pos] call milsim_fnc_createBox", + "No type provided. Please use one of the following types for _type:", + _boxTypesAvailable joinString ", " + ] call BIS_fnc_error; + objNull; }; -private _boxData = milsim_resupply_crateDefinitions getOrDefault [_type, createHashMap]; -if (count _boxData isEqualTo 0) exitWith { - format["Resupply Boxes: [_boxObject, _type, _pos] call milsim_fnc_createBox"] remoteExec ["systemChat", 0]; - format["%1 is not a valid type for _type", _type] remoteExec ["systemChat", 0]; - format["Please use one of the following types for _type:"] remoteExec ["systemChat", 0]; - format["%1", (keys milsim_resupply_crateDefinitions)] remoteExec ["systemChat", 0]; - false; + +////////////////////////////////////////////////////////////////////////// +// get the box definition class +////////////////////////////////////////////////////////////////////////// +private _boxDef = (_supplyCratesCfg >> _type); +// validate it exists +if (!isClass _boxDef) exitWith { + [ + "%1 | %2 %3", + "Resupply Boxes: [_boxObject, _type, _pos] call milsim_fnc_createBox", + "Invalid type provided. Please use one of the following types for _type:", + _boxTypesAvailable joinString ", " + ] call BIS_fnc_error; + objNull; }; -private _boxItems = _boxData getOrDefault ["items", createHashMap]; - +////////////////////////////////////////////////////////////////////////// +// Create box if one wasn't provided in parameters +////////////////////////////////////////////////////////////////////////// if (isNull _box) then { - _box = (_boxData get "className") createVehicle _pos; + private _neededBoxType = getText(_boxDef >> "boxClass"); + if (_neededBoxType isEqualTo "") exitWith { + [ + "Resupply Boxes: Failed to create box. No boxClass defined in the box definition." + ] call BIS_fnc_error; + objNull; + }; + _box = _neededBoxType createVehicle _pos; }; + +////////////////////////////////////////////////////////////////////////// +// Clear box +////////////////////////////////////////////////////////////////////////// clearBackpackCargoGlobal _box; clearItemCargoGlobal _box; clearMagazineCargoGlobal _box; clearWeaponCargoGlobal _box; +////////////////////////////////////////////////////////////////////////// +// Get [item, quantity] arrays from definition +////////////////////////////////////////////////////////////////////////// +private _backpacks = ([_boxDef >> "backpacks"] call BIS_fnc_getCfgDataArray); +if (isNil "_backpacks") exitWith { + [ + "Resupply Boxes: Failed to create box. No backpacks defined in the box definition." + ] call BIS_fnc_error; + objNull; +}; + +private _weapons = ([_boxDef >> "weapons"] call BIS_fnc_getCfgDataArray); +if (isNil "_weapons") exitWith { + [ + "Resupply Boxes: Failed to create box. No weapons defined in the box definition." + ] call BIS_fnc_error; + objNull; +}; + +private _magazines = ([_boxDef >> "magazines"] call BIS_fnc_getCfgDataArray); +if (isNil "_magazines") exitWith { + [ + "Resupply Boxes: Failed to create box. No magazines defined in the box definition." + ] call BIS_fnc_error; + objNull; +}; + +private _items = ([_boxDef >> "items"] call BIS_fnc_getCfgDataArray); +if (isNil "_items") exitWith { + [ + "Resupply Boxes: Failed to create box. No items defined in the box definition." + ] call BIS_fnc_error; + objNull; +}; + +////////////////////////////////////////////////////////////////////////// +// Add stuff to box +////////////////////////////////////////////////////////////////////////// { _x params ["_class", "_qty"]; - _box addBackpackCargoGlobal [_class, _qty] - -} foreach (_boxItems getOrDefault ["backpacks", []]); +} foreach _backpacks; { _x params ["_class", "_qty"]; - _box addItemCargoGlobal [_class, _qty] - -} foreach (_boxItems getOrDefault ["items", []]); +} foreach _items; { _x params ["_class", "_qty"]; - _box addMagazineCargoGlobal [_class, _qty] - -} foreach (_boxItems getOrDefault ["magazines", []]); +} foreach _magazines; { _x params ["_class", "_qty"]; - _box addWeaponCargoGlobal [_class, _qty] - -} foreach (_boxItems getOrDefault ["weapons", []]); +} foreach _weapons; + +////////////////////////////////////////////////////////////////////////// +// Adjust ACE settings +////////////////////////////////////////////////////////////////////////// +// set box size [_box,1] call ace_cargo_fnc_setSize; // ignore weight restrictions for carry/drag _box setVariable ["ace_ignoreWeightCarry", true, true]; + +// Return the box _box; \ No newline at end of file diff --git a/functions/resupply/fn_getSupplyCratesCfg.sqf b/functions/resupply/fn_getSupplyCratesCfg.sqf new file mode 100644 index 0000000..2bf1a5f --- /dev/null +++ b/functions/resupply/fn_getSupplyCratesCfg.sqf @@ -0,0 +1 @@ +(missionConfigFile >> "SupplyCrates"); \ No newline at end of file -- 2.37.3.windows.1 From 09dcde7471c606c5eca58267d55ad2b463dcc9b9 Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Sat, 3 Feb 2024 20:59:51 -0800 Subject: [PATCH 07/16] wip --- defines/VehicleFlags.hpp | 129 ++++++++++ functions/CfgFunctions.hpp | 11 +- functions/client/fn_initVehicleFlags.sqf | 225 ------------------ .../fn_getActionsFlagCategories.sqf | 87 +++++++ .../vehicleFlags/fn_getVehicleFlagsCfg.sqf | 1 + .../vehicleFlags/fn_initVehicleFlags.sqf | 113 +++++++++ functions/vehicleFlags/fn_isClassExcluded.sqf | 26 ++ 7 files changed, 366 insertions(+), 226 deletions(-) create mode 100644 defines/VehicleFlags.hpp delete mode 100644 functions/client/fn_initVehicleFlags.sqf create mode 100644 functions/vehicleFlags/fn_getActionsFlagCategories.sqf create mode 100644 functions/vehicleFlags/fn_getVehicleFlagsCfg.sqf create mode 100644 functions/vehicleFlags/fn_initVehicleFlags.sqf create mode 100644 functions/vehicleFlags/fn_isClassExcluded.sqf diff --git a/defines/VehicleFlags.hpp b/defines/VehicleFlags.hpp new file mode 100644 index 0000000..fce9606 --- /dev/null +++ b/defines/VehicleFlags.hpp @@ -0,0 +1,129 @@ +class VehicleFlags { + + texturePBOName = "textures"; + baseClassesToApplyActionsFor[] = { + "LandVehicle", + "Helicopter" + }; + + class ExcludedVehicles { + classesWithoutFlagProxies[] = { + "TF373_SOAR_MH47G_Base", // MH-47G Chinook + "RHS_MELB_base", // MELB AH-6M/MH-6M/H-6M Little Bird + "USAF_C17", // C17 Globemaster III + "USAF_C130J", // C130J Super Hercules + "USAF_AC130U", // AC130 Spooky II + "ej_UH60M_base", // UH-60M Black Hawk + DAP variants + "rhsusf_fmtv_base" // M1083A1P2 variants + SOV SOCOM variants + }; + }; + + class FlagCategories { + class ChevronNumbers { + actionID = "flag_chevron_numbers"; + actionTitle = "Chevron Numbers"; + + class Chevron1 { + actionID = "flag_chevron_id1"; + actionTitle = "Flag 1"; + texture = "textures\flag_number\flag_id_1_co.paa"; + }; + class Chevron2 { + actionID = "flag_chevron_id2"; + actionTitle = "Flag 2"; + texture = "textures\flag_number\flag_id_2_co.paa"; + }; + class Chevron3 { + actionID = "flag_chevron_id3"; + actionTitle = "Flag 3"; + texture = "textures\flag_number\flag_id_3_co.paa"; + }; + class Chevron4 { + actionID = "flag_chevron_id4"; + actionTitle = "Flag 4"; + texture = "textures\flag_number\flag_id_4_co.paa"; + }; + class Chevron5 { + actionID = "flag_chevron_id5"; + actionTitle = "Flag 5"; + texture = "textures\flag_number\flag_id_5_co.paa"; + }; + class Chevron6 { + actionID = "flag_chevron_id6"; + actionTitle = "Flag 6"; + texture = "textures\flag_number\flag_id_6_co.paa"; + }; + class Chevron7 { + actionID = "flag_chevron_id7"; + actionTitle = "Flag 7"; + texture = "textures\flag_number\flag_id_7_co.paa"; + }; + class Chevron8 { + actionID = "flag_chevron_id8"; + actionTitle = "Flag 8"; + texture = "textures\flag_number\flag_id_8_co.paa"; + }; + class Chevron9 { + actionID = "flag_chevron_id9"; + actionTitle = "Flag 9"; + texture = "textures\flag_number\flag_id_9_co.paa"; + }; + class Chevron10 { + actionID = "flag_chevron_id10"; + actionTitle = "Flag 10"; + texture = "textures\flag_number\flag_id_10_co.paa"; + }; + class ChevronHQ { + actionID = "flag_chevron_hq"; + actionTitle = "Flag HQ"; + texture = "textures\flag_number\flag_id_hq_co.paa"; + }; + }; + + class SimpleShapes { + actionID = "flag_simpleshape"; + actionTitle = "Simple Shapes"; + + class GreenOctagon { + actionID = "flag_simpleshape_greenoctagon"; + actionTitle = "Green Octagon"; + texture = "textures\simple_shape\flag_simpleshape_greenoctagon_co.paa"; + }; + class BlueCircle { + actionID = "flag_simpleshape_bluecircle"; + actionTitle = "Blue Circle"; + texture = "textures\simple_shape\flag_simpleshape_bluecircle_co.paa"; + }; + class OrangeSquare { + actionID = "flag_simpleshape_orangesquare"; + actionTitle = "Orange Square"; + texture = "textures\simple_shape\flag_simpleshape_orangesquare_co.paa"; + }; + class PinkTriangle { + actionID = "flag_simpleshape_pinktriangle"; + actionTitle = "Pink Triangle"; + texture = "textures\simple_shape\flag_simpleshape_pinktriangle_co.paa"; + }; + class RedPentagon { + actionID = "flag_simpleshape_redpentagon"; + actionTitle = "Red Pentagon"; + texture = "textures\simple_shape\flag_simpleshape_redpentagon_co.paa"; + }; + }; + + class Miscellaneous { + actionID = "flag_misc"; + actionTitle = "Miscellaneous"; + class BattalionEmblem { + actionID = "flag_17th_emblem"; + actionTitle = "17th Emblem"; + texture = "textures\flags_misc\flag_17th_emblem_co.paa"; + }; + class RedCross { + actionID = "flag_redcross"; + actionTitle = "Red Cross"; + texture = "textures\flags_misc\flag_redcross_co.paa"; + }; + }; + }; +}; \ No newline at end of file diff --git a/functions/CfgFunctions.hpp b/functions/CfgFunctions.hpp index 68eae3c..3709be3 100644 --- a/functions/CfgFunctions.hpp +++ b/functions/CfgFunctions.hpp @@ -39,7 +39,6 @@ class milsim class addClientStatsPFH {}; class addMedicalOverlayPFH { postInit = 1; }; class calculateClientStats {}; - class initVehicleFlags { postInit = 1; }; class bindEmptyGroupGarbageCleanup { postInit = 1; }; }; @@ -131,4 +130,14 @@ class milsim_reinsert { class addCheckQueueSelfAction {}; class requestShowQueue {}; }; +}; + +class milsim_vehicleFlags { + class functions { + file = "functions\vehicleFlags"; + class initVehicleFlags {postInit = 1}; + class getActionsFlagCategories {}; + class getVehicleFlagsCfg {}; + class isClassExcluded{}; + }; }; \ No newline at end of file diff --git a/functions/client/fn_initVehicleFlags.sqf b/functions/client/fn_initVehicleFlags.sqf deleted file mode 100644 index 20c2e02..0000000 --- a/functions/client/fn_initVehicleFlags.sqf +++ /dev/null @@ -1,225 +0,0 @@ -milsim_vehicleflag_options = [ - ["Chevron IDs", [ - ["flag_chevron_id1", createHashMapFromArray [ - ["Title", "Flag 1"], - ["Texture", "textures\flag_number\flag_id_1_co.paa"] - ]], - ["flag_chevron_id2", createHashMapFromArray [ - ["Title", "Flag 2"], - ["Texture", "textures\flag_number\flag_id_2_co.paa"] - ]], - ["flag_chevron_id3", createHashMapFromArray [ - ["Title", "Flag 3"], - ["Texture", "textures\flag_number\flag_id_3_co.paa"] - ]], - ["flag_chevron_id4", createHashMapFromArray [ - ["Title", "Flag 4"], - ["Texture", "textures\flag_number\flag_id_4_co.paa"] - ]], - ["flag_chevron_id5", createHashMapFromArray [ - ["Title", "Flag 5"], - ["Texture", "textures\flag_number\flag_id_5_co.paa"] - ]], - ["flag_chevron_id6", createHashMapFromArray [ - ["Title", "Flag 6"], - ["Texture", "textures\flag_number\flag_id_6_co.paa"] - ]], - ["flag_chevron_id7", createHashMapFromArray [ - ["Title", "Flag 7"], - ["Texture", "textures\flag_number\flag_id_7_co.paa"] - ]], - ["flag_chevron_id8", createHashMapFromArray [ - ["Title", "Flag 8"], - ["Texture", "textures\flag_number\flag_id_8_co.paa"] - ]], - ["flag_chevron_id9", createHashMapFromArray [ - ["Title", "Flag 9"], - ["Texture", "textures\flag_number\flag_id_9_co.paa"] - ]], - ["flag_chevron_id10", createHashMapFromArray [ - ["Title", "Flag 10"], - ["Texture", "textures\flag_number\flag_id_10_co.paa"] - ]], - ["flag_chevron_hq", createHashMapFromArray [ - ["Title", "Flag HQ"], - ["Texture", "textures\flag_number\flag_id_hq_co.paa"] - ]] - ]], - ["Simple Shapes", [ - ["flag_simpleshape_greenoctagon", createHashMapFromArray [ - ["Title", "Green Octagon"], - ["Texture", "textures\simple_shape\flag_simpleshape_greenoctagon_co.paa"] - ]], - ["flag_simpleshape_bluecircle", createHashMapFromArray [ - ["Title", "Blue Circle"], - ["Texture", "textures\simple_shape\flag_simpleshape_bluecircle_co.paa"] - ]], - ["flag_simpleshape_orangesquare", createHashMapFromArray [ - ["Title", "Orange Square"], - ["Texture", "textures\simple_shape\flag_simpleshape_orangesquare_co.paa"] - ]], - ["flag_simpleshape_pinktriangle", createHashMapFromArray[ - ["Title", "Pink Triangle"], - ["Texture", "textures\simple_shape\flag_simpleshape_pinktriangle_co.paa"] - ]], - ["flag_simpleshape_redpentagon", createHashMapFromArray [ - ["Title", "Red Pentagon"], - ["Texture", "textures\simple_shape\flag_simpleshape_redpentagon_co.paa"] - ]] - ]], - ["Miscellaneous", [ - ["flag_17th_emblem", createHashMapFromArray [ - ["Title", "17th Emblem"], - ["Texture", "textures\flags_misc\flag_17th_emblem_co.paa"] - ]], - ["flag_redcross", createHashMapFromArray [ - ["Title", "Red Cross"], - ["Texture", "textures\flags_misc\flag_redcross_co.paa"] - ]] - ]] -]; - - -private _appliedParentClasses = [ - "LandVehicle", - "Helicopter" -]; - -private _modelsWithoutFlagProxies = [ - "TF373_SOAR_MH47G_Base", // MH-47G Chinook - "RHS_MELB_base", // MELB AH-6M/MH-6M/H-6M Little Bird - "USAF_C17", // C17 Globemaster III - "USAF_C130J", // C130J Super Hercules - "USAF_AC130U", // AC130 Spooky II - "ej_UH60M_base", // UH-60M Black Hawk + DAP variants - "rhsusf_fmtv_base" // M1083A1P2 variants + SOV SOCOM variants -]; - -{ - private _parentClass = _x; - [_parentClass, "InitPost", { - private _flagActionID = "SetVehicleFlag"; - private _flagMasterAction = [ - _flagActionID, // id - "Set Vehicle Flag", // displayed title - "\A3\ui_f\data\map\markers\flags\nato_ca.paa", // flag icon - {true}, // statement - { - params ["_target", "_player", "_params"]; - private _modelsWithoutFlagProxies = _params select 1; - - // check if hierarchy includes any of the models without flag proxies - private _excluded = false; - { - if (_excluded) exitWith {false}; - _excluded = _target isKindOf _x; - } forEach _modelsWithoutFlagProxies; - if (_excluded) exitWith {false}; - - - // check if vehicle is alive - alive _target; - }, // condition - { - params ["_target", "_player", "_params"]; - private _flagActionID = _params#0; - private _actions = []; - { - _x params ["_flagCategory", "_flagOptions"]; - // diag_log format ["NewFlagCategory: %1 %2", _flagCategory, _flagOptions]; - - private _flagCategoryOption = [ - _flagActionID + "_" + _flagCategory, // id - _flagCategory, // displayed title - (_flagOptions#0#1) get "Texture", // flag icon - {true}, // statement - { - params ["_target", "_player", "_params"]; - alive _target; - // true; - }, // condition - { - params ["_target", "_player", "_params"]; - _params params ["_flagActionID", "_flagCategoryID", "_flagOptions"]; - private _categoryOptions = []; - { - _x params ["_flagOptionID", "_flagOptionData"]; - // diag_log format ["NewFlagOption: %1 %2", _flagOptionID, _flagOptionData]; - private _newFlagOption = [ - _flagActionID + "_" + _flagCategory + "_" + _flagOptionID, // id - _flagOptionData get "Title", // displayed title - _flagOptionData get "Texture", // flag icon - { - params ["_target", "_player", "_params"]; - _target forceFlagTexture (_params select 2); - }, // statement - { - params ["_target", "_player", "_params"]; - alive _target; - // true; - }, // condition - nil, // child code - [_flagActionID, _flagCategoryID, getMissionPath (_flagOptionData get "Texture")], // params - nil, // position - 4, // distance - [false, false, false, false, false] // other params - ] call ace_interact_menu_fnc_createAction; - _categoryOptions pushBack [_newFlagOption, [], _target]; - } forEach _flagOptions; - _categoryOptions; - }, // child code - [_flagActionID, _flagCategoryID, _flagOptions], // params - nil, // position - 4, // distance - [false, false, false, false, false], // other params - nil // modifier function code - ] call ace_interact_menu_fnc_createAction; - - _actions pushBack [_flagCategoryOption, [], _target]; - } forEach milsim_vehicleflag_options; - - _actions; - }, // child code - [_flagActionID, _modelsWithoutFlagProxies], // params - nil, // position - 4, // distance - [false, false, false, false, false], // other params - nil // modifier function code - ] call ace_interact_menu_fnc_createAction; - - // add action to add flag - [ - (_this select 0), // object - 0, // action 0 or self-action 1 - ["ACE_MainActions"], // parent - _flagMasterAction // action - ] call ace_interact_menu_fnc_addActionToObject; - - - // add action to remove flag - private _removeFlagAction = [ - _flagActionID + "_removeflag", // id - "Remove Flag", // displayed title - "\A3\ui_f\data\map\markers\flags\nato_ca.paa", // flag icon - { - params ["_target", "_player", "_params"]; - _target forceFlagTexture ""; - }, // statement - { - params ["_target", "_player", "_params"]; - alive _target && getForcedFlagTexture _target != ""; - }, // condition - nil // child code - ] call ace_interact_menu_fnc_createAction; - - [ - (_this select 0), // object - 0, // action 0 or self-action 1 - ["ACE_MainActions", _flagActionID], // parent - _removeFlagAction // action - ] call ace_interact_menu_fnc_addActionToObject; - - }, true, [], true] call CBA_fnc_addClassEventHandler; -} forEach _appliedParentClasses; - -nil; \ No newline at end of file diff --git a/functions/vehicleFlags/fn_getActionsFlagCategories.sqf b/functions/vehicleFlags/fn_getActionsFlagCategories.sqf new file mode 100644 index 0000000..640235d --- /dev/null +++ b/functions/vehicleFlags/fn_getActionsFlagCategories.sqf @@ -0,0 +1,87 @@ +/* + Used to generate flag category and nested flag child options for the ACE3 interaction menu. + + Parameters: + 0: STRING - Parent action ID + 1: ARRAY - Flag category configs +*/ + +params ["_rootActionID", "_flagCategoryCfgs"]; + +private _allCategoryActions = []; + +{ + // diag_log format ["NewFlagCategory: %1 %2", _flagCategory, _flagOptions]; + + private _flagCategoryCfg = _x; + private _flagCategoryActionID = getText(_flagCategoryCfg >> "actionID"); + private _flagCategoryTitle = getText(_flagCategoryCfg >> "actionTitle"); + + private _flagSubclassesCfgs = _flagCategoryCfg call BIS_fnc_returnChildren; + + private _flagCategoryAction = [ + _rootActionID + "_" + _flagCategoryActionID, // id + _flagCategoryTitle, // displayed title + getText((_flagSubclassesCfgs#0) >> "texture"), // flag icon for category - use first flag option + {true}, // statement + { + params ["_target", "_player", "_params"]; + alive _target; + // true; + }, // condition + { + // generate child code under category + // this is the level where actual flag options will be displayed + params ["_target", "_player", "_params"]; + _params params ["_rootActionID", "_flagCategoryActionID", "_flagSubclassesCfgs"]; + + private _individualFlagActions = []; + { // forEach _flagSubclassesCfgs; + private _flagOptionCfg = _x; + private _flagOptionID = getText(_flagOptionCfg >> "actionID"); + private _flagOptionTitle = getText(_flagOptionCfg >> "actionTitle"); + private _flagOptionTexture = getText(_flagOptionCfg >> "texture"); + + // diag_log format ["NewFlagOption: %1 %2", _flagOptionID, _flagOptionData]; + + private _newFlagOption = [ + + _rootActionID + "_" + _flagCategoryActionID + "_" + _flagOptionID, // id + _flagOptionTitle, // displayed title + _flagOptionTexture, // flag icon + { + params ["_target", "_player", "_params"]; + _params params ["_flagOptionTexture"]; + _target forceFlagTexture _flagOptionTexture; + }, // statement + { + params ["_target", "_player", "_params"]; + alive _target; + // true; + }, // condition + nil, // child code + [_flagOptionTexture], // params + nil, // position + 4, // distance + [false, false, false, false, false] // other params + ] call ace_interact_menu_fnc_createAction; + + // add flag option to category subactions + _individualFlagActions pushBack [_newFlagOption, [], _target]; + } forEach _flagSubclassesCfgs; + + // return the generated flag options to the category as child actions + _individualFlagActions; + }, // child code + [_rootActionID, _flagCategoryActionID, _flagSubclassesCfgs], // params + nil, // position + 4, // distance + [false, false, false, false, false], // other params + nil // modifier function code + ] call ace_interact_menu_fnc_createAction; + + // add category to all category actions array + _allCategoryActions pushBack [_flagCategoryAction, [], _target]; +} forEach _flagCategoryCfgs; + +_allCategoryActions; \ No newline at end of file diff --git a/functions/vehicleFlags/fn_getVehicleFlagsCfg.sqf b/functions/vehicleFlags/fn_getVehicleFlagsCfg.sqf new file mode 100644 index 0000000..6330cbc --- /dev/null +++ b/functions/vehicleFlags/fn_getVehicleFlagsCfg.sqf @@ -0,0 +1 @@ +(missionConfigFile >> "VehicleFlags"); \ No newline at end of file diff --git a/functions/vehicleFlags/fn_initVehicleFlags.sqf b/functions/vehicleFlags/fn_initVehicleFlags.sqf new file mode 100644 index 0000000..2141de4 --- /dev/null +++ b/functions/vehicleFlags/fn_initVehicleFlags.sqf @@ -0,0 +1,113 @@ +if (!hasInterface) exitWith {}; + +private _vehicleFlagsCfg = call milsim_vehicleFlags_fnc_getVehicleFlagsCfg; + +if (!isClass _vehicleFlagsCfg) exitWith { + ["WARNING: Vehicle Flags: Vehicle Flags config not found. Vehicle Flags will not be available."] call BIS_fnc_error; +}; + +// get texture pbo class +private _texturePboName = getText(_vehicleFlagsCfg >> "texturePBOName"); +if (_texturePboName == "") exitWith { + ["WARNING: Vehicle Flags: Texture PBO definition is missing or a blank string! Vehicle Flags will not be available."] call BIS_fnc_error; +}; +if (!isClass (configFile >> "CfgPatches" >> _texturePboName)) exitWith { + [ + "WARNING: Vehicle Flags: Texture PBO not found (%1). Vehicle Flags will not be available.", + _texturePboName + ] call BIS_fnc_error; +}; + +private _baseClassesToApplyActionsFor = + (_vehicleFlagsCfg >> "baseClassesToApplyActionsFor") call BIS_fnc_getCfgDataArray; +private _flagCategoryCfgs = (_vehicleFlagsCfg >> "FlagCategories") call BIS_fnc_returnChildren; + +{ // forEach _baseClassesToApplyActionsFor + private _parentClass = _x; + + //////////////////////////////////////////////////////////////////////// + // add CBA class event handler to add actions to vehicles after they are initialized + // all classes that inherit from the base classes will also have this applied + // an exclusion function is present for manually excluding specific classes + //////////////////////////////////////////////////////////////////////// + [_parentClass, "InitPost", { + + //////////////////////////////////////////////////////////////////////// + // create the root action + //////////////////////////////////////////////////////////////////////// + private _rootActionID = "SetVehicleFlag"; + private _flagRootAction = [ + _rootActionID, // id + "Set Vehicle Flag", // displayed title + "\A3\ui_f\data\map\markers\flags\nato_ca.paa", // flag icon + {true}, // statement + { + params ["_target", "_player", "_params"]; + // _params params ["_parentActionID", "_flagCategories"]; + + // check if vehicle is excluded + private _excluded = [typeOf _target] call milsim_vehicleFlags_fnc_isClassExcluded; + if (_excluded || !alive _target) exitWith {false}; + + true; + }, // condition + { + //////////////////////////////////////////////////////////////////////// + // create the flag category actions (with nested flag actions) + //////////////////////////////////////////////////////////////////////// + params ["_target", "_player", "_params"]; + _params params ["_rootActionID", "_flagCategoryCfgs"]; + + // return category child actions with individual flag actions nested as children + [_rootActionID, _flagCategoryCfgs] call milsim_vehicleFlags_fnc_getActionsFlagCategories; + + }, // child code + [_rootActionID, _flagCategoryCfgs], // params + nil, // position + 4, // distance + [false, false, false, false, false], // other params + nil // modifier function code + ] call ace_interact_menu_fnc_createAction; + + //////////////////////////////////////////////////////////////////////// + // add root action to add flags + //////////////////////////////////////////////////////////////////////// + [ + (_this select 0), // object + 0, // action 0 or self-action 1 + ["ACE_MainActions"], // parent + _flagRootAction // action + ] call ace_interact_menu_fnc_addActionToObject; + + //////////////////////////////////////////////////////////////////////// + // add action to remove flag under the root action + //////////////////////////////////////////////////////////////////////// + // create action + private _removeFlagAction = [ + _flagRootAction + "_removeflag", // id + "Remove Flag", // displayed title + "\A3\ui_f\data\map\markers\flags\nato_ca.paa", // flag icon + { + params ["_target", "_player", "_params"]; + _target forceFlagTexture ""; + }, // statement + { + params ["_target", "_player", "_params"]; + alive _target && getForcedFlagTexture _target != ""; + }, // condition + nil // child code + ] call ace_interact_menu_fnc_createAction; + + // add the action to the vehicle + // in this class event handler, this#0 will be the vehicle + [ + (_this select 0), // object + 0, // action 0 or self-action 1 + ["ACE_MainActions", _flagActionID], // parent + _removeFlagAction // action + ] call ace_interact_menu_fnc_addActionToObject; + + }, true, [], true] call CBA_fnc_addClassEventHandler; +} forEach _baseClassesToApplyActionsFor; + +nil; \ No newline at end of file diff --git a/functions/vehicleFlags/fn_isClassExcluded.sqf b/functions/vehicleFlags/fn_isClassExcluded.sqf new file mode 100644 index 0000000..5d1b85d --- /dev/null +++ b/functions/vehicleFlags/fn_isClassExcluded.sqf @@ -0,0 +1,26 @@ +/* + Used to read vehicle flags config and check provided classname against all present exclusion groups. + + Author: IndigoFox + + Parameter(s): + 0: STRING - Classname of the vehicle to check +*/ + + +if (!hasInterface) exitWith {}; + +params ["_className", "", [""]]; +if (_className == "") exitWith {false}; + +private _vehicleFlagsCfg = call milsim_vehicleFlags_fnc_getVehicleFlagsCfg; +private _excludedVehiclesClass = (_vehicleFlagsCfg >> "ExcludedVehicles"); +private _exclusionGroups = configProperties [_vehicleFlagsCfg >> "ExcludedVehicles"]; + +{ + // Check if the class doesn't have a flag proxy + private _excludedClasses = _x call BIS_fnc_getCfgDataArray; + if (_className in _excludedClasses) exitWith {true}; +} forEach _exclusionGroups; + +false; -- 2.37.3.windows.1 From 94ccf0d80d03771e4ec13fe14c83a9c93526946d Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Sat, 3 Feb 2024 22:37:44 -0800 Subject: [PATCH 08/16] adds scroll wheel spawning and setting, adds utils for getting cfg --- aaFrameworkUtils/getSupplyCratesFromCfg.sqf | 35 ++++++++ .../parseSupplyCratesExported.json | 1 + .../parseSupplyCratesJSONToCSV.py | 37 ++++++++ aaFrameworkUtils/test.csv | 84 +++++++++++++++++++ defines/SupplyCrates.hpp | 4 +- functions/CfgFunctions.hpp | 2 + functions/init/fn_initPlayerLocal.sqf | 11 +++ .../fn_addArsenalObjectSpawnBoxActions.sqf | 31 +++++++ functions/resupply/fn_addCBASettings.sqf | 22 +++++ 9 files changed, 225 insertions(+), 2 deletions(-) create mode 100644 aaFrameworkUtils/getSupplyCratesFromCfg.sqf create mode 100644 aaFrameworkUtils/parseSupplyCratesExported.json create mode 100644 aaFrameworkUtils/parseSupplyCratesJSONToCSV.py create mode 100644 aaFrameworkUtils/test.csv create mode 100644 functions/resupply/fn_addArsenalObjectSpawnBoxActions.sqf create mode 100644 functions/resupply/fn_addCBASettings.sqf diff --git a/aaFrameworkUtils/getSupplyCratesFromCfg.sqf b/aaFrameworkUtils/getSupplyCratesFromCfg.sqf new file mode 100644 index 0000000..a848951 --- /dev/null +++ b/aaFrameworkUtils/getSupplyCratesFromCfg.sqf @@ -0,0 +1,35 @@ +private _supplyCratesCfg = call milsim_resupply_fnc_getSupplyCratesCfg; + +private _properties = []; +{ + _properties append ((configProperties [_x]) apply {configName _x}); +} forEach (_supplyCratesCfg call BIS_fnc_returnChildren); + +_properties = _properties arrayIntersect _properties; + +private _cfgVals = []; +{ + private _cfg = _x; + private _cfgName = configName _x; + _vals = createHashMap; + + { + _vals set [_x, (_cfg >> _x) call BIS_fnc_getCfgData]; + } forEach _properties; + + { + private _arr = _vals get _x; + private _newArr = []; + { + _x params ["_class", "_count"]; + private _cfg = _class call CBA_fnc_getItemConfig; + private _name = [_cfg] call BIS_fnc_displayName; + _newArr pushBack [_class, _name, _count]; + } forEach _arr; + _vals set [_x, _newArr]; + } forEach ["backpacks", "weapons", "items", "magazines"]; + + _cfgVals pushBack [_cfgName, _vals]; +} forEach (_supplyCratesCfg call BIS_fnc_returnChildren); + +text ([createHashMapFromArray _cfgVals] call CBA_fnc_encodeJSON); \ No newline at end of file diff --git a/aaFrameworkUtils/parseSupplyCratesExported.json b/aaFrameworkUtils/parseSupplyCratesExported.json new file mode 100644 index 0000000..e3cf53a --- /dev/null +++ b/aaFrameworkUtils/parseSupplyCratesExported.json @@ -0,0 +1 @@ +{"CrewServedWeapons": {"items": [], "displayName": "CSW Crate", "tooltip": "A crate containing backpacks that assemble into static weapons.", "boxClass": "Box_NATO_Equip_F", "backpacks": [["RHS_M2_Gun_Bag", "M2 Gun Bag", 2], ["RHS_M2_Tripod_Bag", "M2 Tripod Bag", 2], ["RHS_M2_MiniTripod_Bag", "M3 Minitripod Bag", 2], ["rhs_Tow_Gun_Bag", "TOW Gun Bag", 2], ["rhs_TOW_Tripod_Bag", "TOW Tripod Bag", 2], ["UK3CB_Static_M240_Elcan_Gun_Bag", "M240 w/Elcan Gun Bag", 2], ["UK3CB_B_Static_M240_Elcan_Tripod_Low_Bag_US_D", "M240 w/Elcan Tripod Bag (Low)", 2], ["RHS_Mk19_Gun_Bag", "Mk19 Gun Bag", 2], ["RHS_Mk19_Tripod_Bag", "Mk19 Tripod Bag", 2]], "icon": "\\A3\\ui_f\\data\\igui\\cfg\\simpleTasks\\types\\defend_ca.paa", "weapons": [], "magazines": []}, "MortarMk6Resupply": {"items": [["ACE_artilleryTable", "Artillery Rangetable", 2], ["ACE_RangeTable_82mm", "82mm Rangetable", 2], ["ACE_microDAGR", "MicroDAGR GPS", 2], ["ACE_MapTools", "Map Tools", 2]], "displayName": "Mortar MK6 Supply Crate", "tooltip": "A crate containing Mk6 mortar resupply (tubes) and tools.", "boxClass": "Box_NATO_WpsSpecial_F", "backpacks": [["B_Mortar_01_support_F", "Folded Mk6 Mortar Bipod [NATO]", 3], ["B_Mortar_01_weapon_F", "Folded Mk6 Mortar Tube [NATO]", 6], ["UK3CB_LSM_B_B_CARRYALL_RADIO_TIG_STRIPE_01", "Carryall Backpack RT1523g (Tiger Stripe 01)", 1]], "icon": "\\A3\\ui_f\\data\\map\\vehicleicons\\iconStaticMortar_ca.paa", "weapons": [["ACE_Vector", "Vector 21 Nite", 2]], "magazines": [["acex_intelitems_notepad", "Notepad", 2]]}, "AmmoSquad": {"items": [], "displayName": "Squad Ammo", "tooltip": "A crate containing general ammunition and equipment for an infantry squad.", "boxClass": "Box_Syndicate_Ammo_F", "backpacks": [], "icon": "\\A3\\ui_f\\data\\map\\vehicleicons\\iconCrateAmmo_ca.paa", "weapons": [["rhs_weap_M136", "M136 (HEAT)", 4], ["rhs_weap_M136_hp", "M136 (HP)", 4], ["rhs_weap_m72a7", "M72A7", 2]], "magazines": [["1Rnd_SmokePurple_Grenade_shell", "Smoke Round (Purple)", 12], ["1Rnd_SmokeBlue_Grenade_shell", "Smoke Round (Blue)", 24], ["1Rnd_SmokeOrange_Grenade_shell", "Smoke Round (Orange)", 12], ["rhs_mag_M441_HE", "M441 HE Grenade Round", 25], ["rhs_mag_M433_HEDP", "M433 HEDP Grenade Round", 15], ["ACE_40mm_Flare_ir", "M992 Illumination Flare (IR)", 12], ["rhsusf_200Rnd_556x45_mixed_soft_pouch_coyote", "200rnd M249 Softpack M855A1 (Mixed)", 25], ["rhsusf_20Rnd_762x51_m993_Mag", "20rnd M14 M993 AP", 25], ["SmokeShell", "M83 Smoke Grenade (White)", 12], ["rhs_mag_m67", "M67 Fragmentation Grenade", 12], ["1Rnd_Smoke_Grenade_shell", "Smoke Round (White)", 24], ["1Rnd_SmokeRed_Grenade_shell", "Smoke Round (Red)", 24], ["1Rnd_SmokeGreen_Grenade_shell", "Smoke Round (Green)", 24], ["1Rnd_SmokeYellow_Grenade_shell", "Smoke Round (Yellow)", 12], ["Tier1_30Rnd_556x45_M856A1_EMag", "30rnd EMAG M856A1 (Tracer)", 25], ["Tier1_30Rnd_556x45_Mk318Mod0_EMag", "30rnd EMAG Mk318 Mod 0", 75], ["ACE_30Rnd_65_Creedmor_mag", "6.5 mm Creedmor 30Rnd Sand Mag", 25], ["SMA_30Rnd_762x35_BLK_EPR", "30 Round .300 Blackout EPR", 25], ["Tier1_30Rnd_762x35_300BLK_SMK_PMAG", "30rnd PMAG .300 Custom Combat TAC-TX", 25], ["SMA_30Rnd_68x43_SPC_FMJ", "SPC FMJ 6.8x43 30rnd Mag", 25], ["SMA_30Rnd_68x43_SPC_FMJ_Tracer", "SPC FMJ 6.8x43 30rnd Tracer Mag", 25], ["SMA_20Rnd_762x51mm_M80A1_EPR", "M80A1 EPR 762x51mm 20rnd Mag", 25], ["SMA_20Rnd_762x51mm_M80A1_EPR_Tracer", "M80A1 EPR 762x51mm 20rnd Tracer Mag", 25], ["SMA_20Rnd_762x51mm_Mk316_Mod_0_Special_Long_Range", "Mk316 Mod 0 762x51mm SBLR 20rnd Mag", 25], ["SMA_20Rnd_762x51mm_Mk316_Mod_0_Special_Long_Range_Tracer", "Mk316 Mod 0 762x51mm SBLR 20rnd Tracer Mag", 25], ["Tier1_250Rnd_762x51_Belt_M993_AP", "250rnd Ammo Belt M993 AP", 15], ["ACE_20Rnd_762x51_Mag_Tracer", "7.62 mm 20Rnd Mag (Tracer)", 25], ["ACE_20Rnd_762x51_M993_AP_Mag", "7.62 mm 20Rnd Mag (M993 AP)", 25], ["rhsusf_20Rnd_762x51_SR25_m993_Mag", "20rnd SR-25 M993 AP", 25], ["Tier1_20Rnd_762x51_M993_SR25_Mag", "20rnd SR-25/M110 M993 AP", 25], ["Tier1_20Rnd_65x48_Creedmoor_SR25_Mag", "20rnd SR-25/M110 6.5mm Creedmoor", 25], ["rhssaf_30rnd_556x45_EPR_G36", "30rnd G36 M855A1", 25], ["DemoCharge_Remote_Mag", "M112 Demolition Block", 16]]}, "AmmoHeavy": {"items": [], "displayName": "Heavy Ammo", "tooltip": "A crate containing mixed ammo for rifles, ARs, MAT, and HAT.", "boxClass": "Box_NATO_Wps_F", "backpacks": [], "icon": "\\A3\\ui_f\\data\\map\\vehicleicons\\iconCrateWpns_ca.paa", "weapons": [], "magazines": [["MRAWS_HEAT_F", "MAAWS HEAT 75 Round", 35], ["MRAWS_HE_F", "MAAWS HE 44 Round", 15], ["Tier1_250Rnd_762x51_Belt_M993_AP", "250rnd Ammo Belt M993 AP", 50], ["Tier1_30Rnd_556x45_M856A1_EMag", "30rnd EMAG M856A1 (Tracer)", 25], ["Tier1_30Rnd_556x45_Mk318Mod0_EMag", "30rnd EMAG Mk318 Mod 0", 50], ["Titan_AA", "Titan AA Missile", 10], ["Titan_AT", "Titan AT Missile", 10], ["200Rnd_65x39_cased_Box_Tracer_Red", "6.5mm 200Rnd Belt Tracer (Red)", 50]]}, "Launchers": {"items": [], "displayName": "Launcher Crate", "tooltip": "A crate containing missile launchers and ammunition.", "boxClass": "Box_NATO_WpsLaunch_F", "backpacks": [], "icon": "\\A3\\ui_f\\data\\map\\vehicleicons\\iconCrateLong_ca.paa", "weapons": [["launch_B_Titan_short_F", "Titan MPRL Compact (Sand)", 2], ["launch_NLAW_F", "NLAW", 2], ["rhs_weap_fim92", "FIM-92F", 2]], "magazines": [["Titan_AA", "Titan AA Missile", 6], ["Titan_AT", "Titan AT Missile", 6]]}, "Mortar60mmCommandoResupply": {"items": [], "displayName": "Mortar 60mm Commando Supply Crate", "tooltip": "A crate containing COMMANDO 60mm mortar shells and some STANAGs.", "boxClass": "Box_NATO_WpsSpecial_F", "backpacks": [], "icon": "\\A3\\ui_f\\data\\igui\\cfg\\simpleTasks\\types\\scout_ca.paa", "weapons": [], "magazines": [["twc_2inch_he_1rnd", "60mm COMMANDO 1Rnd HE", 70], ["twc_2inch_smoke_1rnd", "60mm COMMANDO 1Rnd Smoke", 15], ["twc_2inch_illum_1rnd", "60mm COMMANDO 1Rnd Illum", 15], ["Tier1_30Rnd_556x45_Mk318Mod0_EMag", "30rnd EMAG Mk318 Mod 0", 20]]}, "MedicalSupplies": {"items": [["ACE_packingBandage", "Bandage (Packing)", 100], ["ACE_elasticBandage", "Bandage (Elastic)", 100], ["ACE_tourniquet", "Tourniquet (CAT)", 48], ["ACE_splint", "Splint", 48], ["ACE_morphine", "Morphine Autoinjector", 50], ["ACE_epinephrine", "Epinephrine Autoinjector", 50], ["ACE_bloodIV", "Blood IV (1000ml)", 75], ["ACE_bloodIV_500", "Blood IV (500ml)", 50], ["ACE_bloodIV_250", "Blood IV (250ml)", 25], ["ACE_quikclot", "Bandage (QuikClot)", 75], ["ACE_personalAidKit", "Personal Aid Kit", 5], ["ACE_surgicalKit", "Surgical Kit", 5]], "displayName": "Medical Crate", "tooltip": "A crate containing medical supplies.", "boxClass": "ACE_medicalSupplyCrate_advanced", "backpacks": [], "icon": "\\A3\\ui_f\\data\\map\\vehicleicons\\pictureHeal_ca.paa", "weapons": [], "magazines": []}} \ No newline at end of file diff --git a/aaFrameworkUtils/parseSupplyCratesJSONToCSV.py b/aaFrameworkUtils/parseSupplyCratesJSONToCSV.py new file mode 100644 index 0000000..e789899 --- /dev/null +++ b/aaFrameworkUtils/parseSupplyCratesJSONToCSV.py @@ -0,0 +1,37 @@ +import sys +import json +import csv + + +def parseSupplyCratesJSONToCSV(jsonFile, csvFile): + with open(jsonFile, 'r') as file: + supply_boxes = json.load(file) + + headers = ["box_config_name", "box_friendly_name", "box_class", "box_tooltip", "category", "item_class", "item_name", "quantity"] + all_rows = [] + for supply_box_name in supply_boxes.keys(): + supply_box_data = supply_boxes[supply_box_name] + + display_name = supply_box_data['displayName'] + tooltip = supply_box_data['tooltip'] + box_class = supply_box_data['boxClass'] + for category in ["items", "backpacks", "weapons", "magazines"]: + for item in supply_box_data[category]: + item_class = item[0] + item_name = item[1] + item_quantity = item[2] + row = [supply_box_name, display_name, box_class, tooltip, category, item_class, item_name, item_quantity] + all_rows.append(row) + + + with open(csvFile, 'w', newline='', encoding='utf-8') as file: + writer = csv.writer(file) + writer.writerow(headers) + writer.writerows(all_rows) + +if __name__ == "__main__": + jsonFile = sys.argv[1] + csvFile = sys.argv[2] + parseSupplyCratesJSONToCSV(jsonFile, csvFile) + print(f"Done! {csvFile} created.") + \ No newline at end of file diff --git a/aaFrameworkUtils/test.csv b/aaFrameworkUtils/test.csv new file mode 100644 index 0000000..cf3ca96 --- /dev/null +++ b/aaFrameworkUtils/test.csv @@ -0,0 +1,84 @@ +box_config_name,box_friendly_name,box_class,box_tooltip,category,item_class,item_name,quantity +CrewServedWeapons,CSW Crate,Box_NATO_Equip_F,A crate containing backpacks that assemble into static weapons.,backpacks,RHS_M2_Gun_Bag,M2 Gun Bag,2 +CrewServedWeapons,CSW Crate,Box_NATO_Equip_F,A crate containing backpacks that assemble into static weapons.,backpacks,RHS_M2_Tripod_Bag,M2 Tripod Bag,2 +CrewServedWeapons,CSW Crate,Box_NATO_Equip_F,A crate containing backpacks that assemble into static weapons.,backpacks,RHS_M2_MiniTripod_Bag,M3 Minitripod Bag,2 +CrewServedWeapons,CSW Crate,Box_NATO_Equip_F,A crate containing backpacks that assemble into static weapons.,backpacks,rhs_Tow_Gun_Bag,TOW Gun Bag,2 +CrewServedWeapons,CSW Crate,Box_NATO_Equip_F,A crate containing backpacks that assemble into static weapons.,backpacks,rhs_TOW_Tripod_Bag,TOW Tripod Bag,2 +CrewServedWeapons,CSW Crate,Box_NATO_Equip_F,A crate containing backpacks that assemble into static weapons.,backpacks,UK3CB_Static_M240_Elcan_Gun_Bag,M240 w/Elcan Gun Bag,2 +CrewServedWeapons,CSW Crate,Box_NATO_Equip_F,A crate containing backpacks that assemble into static weapons.,backpacks,UK3CB_B_Static_M240_Elcan_Tripod_Low_Bag_US_D,M240 w/Elcan Tripod Bag (Low),2 +CrewServedWeapons,CSW Crate,Box_NATO_Equip_F,A crate containing backpacks that assemble into static weapons.,backpacks,RHS_Mk19_Gun_Bag,Mk19 Gun Bag,2 +CrewServedWeapons,CSW Crate,Box_NATO_Equip_F,A crate containing backpacks that assemble into static weapons.,backpacks,RHS_Mk19_Tripod_Bag,Mk19 Tripod Bag,2 +MortarMk6Resupply,Mortar MK6 Supply Crate,Box_NATO_WpsSpecial_F,A crate containing Mk6 mortar resupply (tubes) and tools.,items,ACE_artilleryTable,Artillery Rangetable,2 +MortarMk6Resupply,Mortar MK6 Supply Crate,Box_NATO_WpsSpecial_F,A crate containing Mk6 mortar resupply (tubes) and tools.,items,ACE_RangeTable_82mm,82mm Rangetable,2 +MortarMk6Resupply,Mortar MK6 Supply Crate,Box_NATO_WpsSpecial_F,A crate containing Mk6 mortar resupply (tubes) and tools.,items,ACE_microDAGR,MicroDAGR GPS,2 +MortarMk6Resupply,Mortar MK6 Supply Crate,Box_NATO_WpsSpecial_F,A crate containing Mk6 mortar resupply (tubes) and tools.,items,ACE_MapTools,Map Tools,2 +MortarMk6Resupply,Mortar MK6 Supply Crate,Box_NATO_WpsSpecial_F,A crate containing Mk6 mortar resupply (tubes) and tools.,backpacks,B_Mortar_01_support_F,Folded Mk6 Mortar Bipod [NATO],3 +MortarMk6Resupply,Mortar MK6 Supply Crate,Box_NATO_WpsSpecial_F,A crate containing Mk6 mortar resupply (tubes) and tools.,backpacks,B_Mortar_01_weapon_F,Folded Mk6 Mortar Tube [NATO],6 +MortarMk6Resupply,Mortar MK6 Supply Crate,Box_NATO_WpsSpecial_F,A crate containing Mk6 mortar resupply (tubes) and tools.,backpacks,UK3CB_LSM_B_B_CARRYALL_RADIO_TIG_STRIPE_01,Carryall Backpack RT1523g (Tiger Stripe 01),1 +MortarMk6Resupply,Mortar MK6 Supply Crate,Box_NATO_WpsSpecial_F,A crate containing Mk6 mortar resupply (tubes) and tools.,weapons,ACE_Vector,Vector 21 Nite,2 +MortarMk6Resupply,Mortar MK6 Supply Crate,Box_NATO_WpsSpecial_F,A crate containing Mk6 mortar resupply (tubes) and tools.,magazines,acex_intelitems_notepad,Notepad,2 +AmmoSquad,Squad Ammo,Box_Syndicate_Ammo_F,A crate containing general ammunition and equipment for an infantry squad.,weapons,rhs_weap_M136,M136 (HEAT),4 +AmmoSquad,Squad Ammo,Box_Syndicate_Ammo_F,A crate containing general ammunition and equipment for an infantry squad.,weapons,rhs_weap_M136_hp,M136 (HP),4 +AmmoSquad,Squad Ammo,Box_Syndicate_Ammo_F,A crate containing general ammunition and equipment for an infantry squad.,weapons,rhs_weap_m72a7,M72A7,2 +AmmoSquad,Squad Ammo,Box_Syndicate_Ammo_F,A crate containing general ammunition and equipment for an infantry squad.,magazines,1Rnd_SmokePurple_Grenade_shell,Smoke Round (Purple),12 +AmmoSquad,Squad Ammo,Box_Syndicate_Ammo_F,A crate containing general ammunition and equipment for an infantry squad.,magazines,1Rnd_SmokeBlue_Grenade_shell,Smoke Round (Blue),24 +AmmoSquad,Squad Ammo,Box_Syndicate_Ammo_F,A crate containing general ammunition and equipment for an infantry squad.,magazines,1Rnd_SmokeOrange_Grenade_shell,Smoke Round (Orange),12 +AmmoSquad,Squad Ammo,Box_Syndicate_Ammo_F,A crate containing general ammunition and equipment for an infantry squad.,magazines,rhs_mag_M441_HE,M441 HE Grenade Round,25 +AmmoSquad,Squad Ammo,Box_Syndicate_Ammo_F,A crate containing general ammunition and equipment for an infantry squad.,magazines,rhs_mag_M433_HEDP,M433 HEDP Grenade Round,15 +AmmoSquad,Squad Ammo,Box_Syndicate_Ammo_F,A crate containing general ammunition and equipment for an infantry squad.,magazines,ACE_40mm_Flare_ir,M992 Illumination Flare (IR),12 +AmmoSquad,Squad Ammo,Box_Syndicate_Ammo_F,A crate containing general ammunition and equipment for an infantry squad.,magazines,rhsusf_200Rnd_556x45_mixed_soft_pouch_coyote,200rnd M249 Softpack M855A1 (Mixed),25 +AmmoSquad,Squad Ammo,Box_Syndicate_Ammo_F,A crate containing general ammunition and equipment for an infantry squad.,magazines,rhsusf_20Rnd_762x51_m993_Mag,20rnd M14 M993 AP,25 +AmmoSquad,Squad Ammo,Box_Syndicate_Ammo_F,A crate containing general ammunition and equipment for an infantry squad.,magazines,SmokeShell,M83 Smoke Grenade (White),12 +AmmoSquad,Squad Ammo,Box_Syndicate_Ammo_F,A crate containing general ammunition and equipment for an infantry squad.,magazines,rhs_mag_m67,M67 Fragmentation Grenade,12 +AmmoSquad,Squad Ammo,Box_Syndicate_Ammo_F,A crate containing general ammunition and equipment for an infantry squad.,magazines,1Rnd_Smoke_Grenade_shell,Smoke Round (White),24 +AmmoSquad,Squad Ammo,Box_Syndicate_Ammo_F,A crate containing general ammunition and equipment for an infantry squad.,magazines,1Rnd_SmokeRed_Grenade_shell,Smoke Round (Red),24 +AmmoSquad,Squad Ammo,Box_Syndicate_Ammo_F,A crate containing general ammunition and equipment for an infantry squad.,magazines,1Rnd_SmokeGreen_Grenade_shell,Smoke Round (Green),24 +AmmoSquad,Squad Ammo,Box_Syndicate_Ammo_F,A crate containing general ammunition and equipment for an infantry squad.,magazines,1Rnd_SmokeYellow_Grenade_shell,Smoke Round (Yellow),12 +AmmoSquad,Squad Ammo,Box_Syndicate_Ammo_F,A crate containing general ammunition and equipment for an infantry squad.,magazines,Tier1_30Rnd_556x45_M856A1_EMag,30rnd EMAG M856A1 (Tracer),25 +AmmoSquad,Squad Ammo,Box_Syndicate_Ammo_F,A crate containing general ammunition and equipment for an infantry squad.,magazines,Tier1_30Rnd_556x45_Mk318Mod0_EMag,30rnd EMAG Mk318 Mod 0,75 +AmmoSquad,Squad Ammo,Box_Syndicate_Ammo_F,A crate containing general ammunition and equipment for an infantry squad.,magazines,ACE_30Rnd_65_Creedmor_mag,6.5 mm Creedmor 30Rnd Sand Mag,25 +AmmoSquad,Squad Ammo,Box_Syndicate_Ammo_F,A crate containing general ammunition and equipment for an infantry squad.,magazines,SMA_30Rnd_762x35_BLK_EPR,30 Round .300 Blackout EPR,25 +AmmoSquad,Squad Ammo,Box_Syndicate_Ammo_F,A crate containing general ammunition and equipment for an infantry squad.,magazines,Tier1_30Rnd_762x35_300BLK_SMK_PMAG,30rnd PMAG .300 Custom Combat TAC-TX,25 +AmmoSquad,Squad Ammo,Box_Syndicate_Ammo_F,A crate containing general ammunition and equipment for an infantry squad.,magazines,SMA_30Rnd_68x43_SPC_FMJ,SPC FMJ 6.8x43 30rnd Mag,25 +AmmoSquad,Squad Ammo,Box_Syndicate_Ammo_F,A crate containing general ammunition and equipment for an infantry squad.,magazines,SMA_30Rnd_68x43_SPC_FMJ_Tracer,SPC FMJ 6.8x43 30rnd Tracer Mag,25 +AmmoSquad,Squad Ammo,Box_Syndicate_Ammo_F,A crate containing general ammunition and equipment for an infantry squad.,magazines,SMA_20Rnd_762x51mm_M80A1_EPR,M80A1 EPR 762x51mm 20rnd Mag,25 +AmmoSquad,Squad Ammo,Box_Syndicate_Ammo_F,A crate containing general ammunition and equipment for an infantry squad.,magazines,SMA_20Rnd_762x51mm_M80A1_EPR_Tracer,M80A1 EPR 762x51mm 20rnd Tracer Mag,25 +AmmoSquad,Squad Ammo,Box_Syndicate_Ammo_F,A crate containing general ammunition and equipment for an infantry squad.,magazines,SMA_20Rnd_762x51mm_Mk316_Mod_0_Special_Long_Range,Mk316 Mod 0 762x51mm SBLR 20rnd Mag,25 +AmmoSquad,Squad Ammo,Box_Syndicate_Ammo_F,A crate containing general ammunition and equipment for an infantry squad.,magazines,SMA_20Rnd_762x51mm_Mk316_Mod_0_Special_Long_Range_Tracer,Mk316 Mod 0 762x51mm SBLR 20rnd Tracer Mag,25 +AmmoSquad,Squad Ammo,Box_Syndicate_Ammo_F,A crate containing general ammunition and equipment for an infantry squad.,magazines,Tier1_250Rnd_762x51_Belt_M993_AP,250rnd Ammo Belt M993 AP,15 +AmmoSquad,Squad Ammo,Box_Syndicate_Ammo_F,A crate containing general ammunition and equipment for an infantry squad.,magazines,ACE_20Rnd_762x51_Mag_Tracer,7.62 mm 20Rnd Mag (Tracer),25 +AmmoSquad,Squad Ammo,Box_Syndicate_Ammo_F,A crate containing general ammunition and equipment for an infantry squad.,magazines,ACE_20Rnd_762x51_M993_AP_Mag,7.62 mm 20Rnd Mag (M993 AP),25 +AmmoSquad,Squad Ammo,Box_Syndicate_Ammo_F,A crate containing general ammunition and equipment for an infantry squad.,magazines,rhsusf_20Rnd_762x51_SR25_m993_Mag,20rnd SR-25 M993 AP,25 +AmmoSquad,Squad Ammo,Box_Syndicate_Ammo_F,A crate containing general ammunition and equipment for an infantry squad.,magazines,Tier1_20Rnd_762x51_M993_SR25_Mag,20rnd SR-25/M110 M993 AP,25 +AmmoSquad,Squad Ammo,Box_Syndicate_Ammo_F,A crate containing general ammunition and equipment for an infantry squad.,magazines,Tier1_20Rnd_65x48_Creedmoor_SR25_Mag,20rnd SR-25/M110 6.5mm Creedmoor,25 +AmmoSquad,Squad Ammo,Box_Syndicate_Ammo_F,A crate containing general ammunition and equipment for an infantry squad.,magazines,rhssaf_30rnd_556x45_EPR_G36,30rnd G36 M855A1,25 +AmmoSquad,Squad Ammo,Box_Syndicate_Ammo_F,A crate containing general ammunition and equipment for an infantry squad.,magazines,DemoCharge_Remote_Mag,M112 Demolition Block,16 +AmmoHeavy,Heavy Ammo,Box_NATO_Wps_F,"A crate containing mixed ammo for rifles, ARs, MAT, and HAT.",magazines,MRAWS_HEAT_F,MAAWS HEAT 75 Round,35 +AmmoHeavy,Heavy Ammo,Box_NATO_Wps_F,"A crate containing mixed ammo for rifles, ARs, MAT, and HAT.",magazines,MRAWS_HE_F,MAAWS HE 44 Round,15 +AmmoHeavy,Heavy Ammo,Box_NATO_Wps_F,"A crate containing mixed ammo for rifles, ARs, MAT, and HAT.",magazines,Tier1_250Rnd_762x51_Belt_M993_AP,250rnd Ammo Belt M993 AP,50 +AmmoHeavy,Heavy Ammo,Box_NATO_Wps_F,"A crate containing mixed ammo for rifles, ARs, MAT, and HAT.",magazines,Tier1_30Rnd_556x45_M856A1_EMag,30rnd EMAG M856A1 (Tracer),25 +AmmoHeavy,Heavy Ammo,Box_NATO_Wps_F,"A crate containing mixed ammo for rifles, ARs, MAT, and HAT.",magazines,Tier1_30Rnd_556x45_Mk318Mod0_EMag,30rnd EMAG Mk318 Mod 0,50 +AmmoHeavy,Heavy Ammo,Box_NATO_Wps_F,"A crate containing mixed ammo for rifles, ARs, MAT, and HAT.",magazines,Titan_AA,Titan AA Missile,10 +AmmoHeavy,Heavy Ammo,Box_NATO_Wps_F,"A crate containing mixed ammo for rifles, ARs, MAT, and HAT.",magazines,Titan_AT,Titan AT Missile,10 +AmmoHeavy,Heavy Ammo,Box_NATO_Wps_F,"A crate containing mixed ammo for rifles, ARs, MAT, and HAT.",magazines,200Rnd_65x39_cased_Box_Tracer_Red,6.5mm 200Rnd Belt Tracer (Red),50 +Launchers,Launcher Crate,Box_NATO_WpsLaunch_F,A crate containing missile launchers and ammunition.,weapons,launch_B_Titan_short_F,Titan MPRL Compact (Sand),2 +Launchers,Launcher Crate,Box_NATO_WpsLaunch_F,A crate containing missile launchers and ammunition.,weapons,launch_NLAW_F,NLAW,2 +Launchers,Launcher Crate,Box_NATO_WpsLaunch_F,A crate containing missile launchers and ammunition.,weapons,rhs_weap_fim92,FIM-92F,2 +Launchers,Launcher Crate,Box_NATO_WpsLaunch_F,A crate containing missile launchers and ammunition.,magazines,Titan_AA,Titan AA Missile,6 +Launchers,Launcher Crate,Box_NATO_WpsLaunch_F,A crate containing missile launchers and ammunition.,magazines,Titan_AT,Titan AT Missile,6 +Mortar60mmCommandoResupply,Mortar 60mm Commando Supply Crate,Box_NATO_WpsSpecial_F,A crate containing COMMANDO 60mm mortar shells and some STANAGs.,magazines,twc_2inch_he_1rnd,60mm COMMANDO 1Rnd HE,70 +Mortar60mmCommandoResupply,Mortar 60mm Commando Supply Crate,Box_NATO_WpsSpecial_F,A crate containing COMMANDO 60mm mortar shells and some STANAGs.,magazines,twc_2inch_smoke_1rnd,60mm COMMANDO 1Rnd Smoke,15 +Mortar60mmCommandoResupply,Mortar 60mm Commando Supply Crate,Box_NATO_WpsSpecial_F,A crate containing COMMANDO 60mm mortar shells and some STANAGs.,magazines,twc_2inch_illum_1rnd,60mm COMMANDO 1Rnd Illum,15 +Mortar60mmCommandoResupply,Mortar 60mm Commando Supply Crate,Box_NATO_WpsSpecial_F,A crate containing COMMANDO 60mm mortar shells and some STANAGs.,magazines,Tier1_30Rnd_556x45_Mk318Mod0_EMag,30rnd EMAG Mk318 Mod 0,20 +MedicalSupplies,Medical Crate,ACE_medicalSupplyCrate_advanced,A crate containing medical supplies.,items,ACE_packingBandage,Bandage (Packing),100 +MedicalSupplies,Medical Crate,ACE_medicalSupplyCrate_advanced,A crate containing medical supplies.,items,ACE_elasticBandage,Bandage (Elastic),100 +MedicalSupplies,Medical Crate,ACE_medicalSupplyCrate_advanced,A crate containing medical supplies.,items,ACE_tourniquet,Tourniquet (CAT),48 +MedicalSupplies,Medical Crate,ACE_medicalSupplyCrate_advanced,A crate containing medical supplies.,items,ACE_splint,Splint,48 +MedicalSupplies,Medical Crate,ACE_medicalSupplyCrate_advanced,A crate containing medical supplies.,items,ACE_morphine,Morphine Autoinjector,50 +MedicalSupplies,Medical Crate,ACE_medicalSupplyCrate_advanced,A crate containing medical supplies.,items,ACE_epinephrine,Epinephrine Autoinjector,50 +MedicalSupplies,Medical Crate,ACE_medicalSupplyCrate_advanced,A crate containing medical supplies.,items,ACE_bloodIV,Blood IV (1000ml),75 +MedicalSupplies,Medical Crate,ACE_medicalSupplyCrate_advanced,A crate containing medical supplies.,items,ACE_bloodIV_500,Blood IV (500ml),50 +MedicalSupplies,Medical Crate,ACE_medicalSupplyCrate_advanced,A crate containing medical supplies.,items,ACE_bloodIV_250,Blood IV (250ml),25 +MedicalSupplies,Medical Crate,ACE_medicalSupplyCrate_advanced,A crate containing medical supplies.,items,ACE_quikclot,Bandage (QuikClot),75 +MedicalSupplies,Medical Crate,ACE_medicalSupplyCrate_advanced,A crate containing medical supplies.,items,ACE_personalAidKit,Personal Aid Kit,5 +MedicalSupplies,Medical Crate,ACE_medicalSupplyCrate_advanced,A crate containing medical supplies.,items,ACE_surgicalKit,Surgical Kit,5 diff --git a/defines/SupplyCrates.hpp b/defines/SupplyCrates.hpp index a1cebac..51245fd 100644 --- a/defines/SupplyCrates.hpp +++ b/defines/SupplyCrates.hpp @@ -1,7 +1,7 @@ class SupplyCrates { class AmmoSquad { boxClass = "Box_Syndicate_Ammo_F"; - displayName = "Squad Ammo"; + displayName = "Squad Ammo Crate"; tooltip = "A crate containing general ammunition and equipment for an infantry squad."; icon = "\A3\ui_f\data\map\vehicleicons\iconCrateAmmo_ca.paa"; @@ -51,7 +51,7 @@ class SupplyCrates { class AmmoHeavy { boxClass = "Box_NATO_Wps_F"; - displayName = "Heavy Ammo"; + displayName = "Heavy Ammo Crate"; tooltip = "A crate containing mixed ammo for rifles, ARs, MAT, and HAT."; icon = "\A3\ui_f\data\map\vehicleicons\iconCrateWpns_ca.paa"; diff --git a/functions/CfgFunctions.hpp b/functions/CfgFunctions.hpp index 68eae3c..842b180 100644 --- a/functions/CfgFunctions.hpp +++ b/functions/CfgFunctions.hpp @@ -88,6 +88,8 @@ class milsim_resupply { class createMortarBox {}; class createWeaponsBox {}; class getSupplyCratesCfg {}; + class addArsenalObjectSpawnBoxActions {}; + class addCBASettings {postInit=1;}; }; }; diff --git a/functions/init/fn_initPlayerLocal.sqf b/functions/init/fn_initPlayerLocal.sqf index d72495f..1ba5f10 100644 --- a/functions/init/fn_initPlayerLocal.sqf +++ b/functions/init/fn_initPlayerLocal.sqf @@ -9,6 +9,17 @@ if (!isServer) then { }] call CBA_fnc_addEventHandler; }; +// 5 seconds after the client is loaded, add the resupply action to all arsenal boxes +[ + {time > 5}, + { + if (missionNamespace getVariable [ + "milsim_resupply_setting_allowSupplyBoxScrollWheelSpawning", + false + ]) then {call milsim_resupply_fnc_addSpawnBoxActions} + } +] call CBA_fnc_waitUntilAndExecute; + ["InitializePlayer", [player, true]] call BIS_fnc_dynamicGroups; nil; \ No newline at end of file diff --git a/functions/resupply/fn_addArsenalObjectSpawnBoxActions.sqf b/functions/resupply/fn_addArsenalObjectSpawnBoxActions.sqf new file mode 100644 index 0000000..74963ac --- /dev/null +++ b/functions/resupply/fn_addArsenalObjectSpawnBoxActions.sqf @@ -0,0 +1,31 @@ +// adds a scroll wheel action to all arsenal boxes to spawn different supply crate types + +private _arsenalBoxClassName = "Land_PaperBox_open_full_F"; + +// get all instances of the arsenal item +private _arsenalBoxes = (allMissionObjects _arsenalBoxClassName) select { + // only select the ones that already have user actions attached + count (actionIDs _x) > 0; +}; + +private _supplyCratesCfg = call milsim_resupply_fnc_getSupplyCratesCfg; +private _supplyCrateTypesCfgs = _supplyCratesCfg call BIS_fnc_returnChildren; + +{ + // add scroll wheel action to spawn different supply box types + private _arsenalBox = _x; + { + private _cfg = _x; + private _supplyCrateDisplayName = (_cfg >> "displayName") call BIS_fnc_getCfgData; + + _arsenalBox addAction [format ["Spawn %1", _supplyCrateDisplayName], { + params ["_target", "_caller", "_actionId", "_arguments"]; + _arguments params ["_supplyCrateCfg"]; + [ + objNull, + configName _supplyCrateCfg, + getPos _target + ] call milsim_resupply_fnc_createBox; + }, [_cfg], 0, false, true, "", ""]; + } forEach _supplyCrateTypesCfgs; +} forEach _arsenalBoxes; \ No newline at end of file diff --git a/functions/resupply/fn_addCBASettings.sqf b/functions/resupply/fn_addCBASettings.sqf new file mode 100644 index 0000000..47d700a --- /dev/null +++ b/functions/resupply/fn_addCBASettings.sqf @@ -0,0 +1,22 @@ +[ + "milsim_resupply_setting_allowSupplyBoxScrollWheelSpawning", // variable + "CHECKBOX", // type + ["Enabled", "If true, adds scroll wheel options to arsenal boxes to spawn supply boxes"], // title + ["17th Battalion", "Resupply"], // category + false, // default value + true, // global setting + { + params ["_value"]; + [ + "resupply", + "SETTING CHANGED", + [ + [ + "setting", + "milsim_resupply_setting_allowSupplyBoxScrollWheelSpawning" + ], + ["newValue", _value] + ] + ] call milsim_fnc_log; + } +] call CBA_fnc_addSetting; \ No newline at end of file -- 2.37.3.windows.1 From d7b8e5186e64b7e1c9d57a38d7c6e1b318d37f04 Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Sat, 3 Feb 2024 22:55:21 -0800 Subject: [PATCH 09/16] tested local --- description.ext | 1 + .../vehicleFlags/fn_getActionsFlagCategories.sqf | 3 +++ functions/vehicleFlags/fn_initVehicleFlags.sqf | 16 ++-------------- functions/vehicleFlags/fn_isClassExcluded.sqf | 2 +- 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/description.ext b/description.ext index 9781ede..3bb5ba0 100644 --- a/description.ext +++ b/description.ext @@ -21,6 +21,7 @@ #include "defines\BattalionInfo.hpp" #include "defines\DisallowedEquipment.hpp" #include "defines\SupplyCrates.hpp" +#include "defines\VehicleFlags.hpp" //-------------------------------------------MISSION INFO-------------------------------------------------------------------- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/functions/vehicleFlags/fn_getActionsFlagCategories.sqf b/functions/vehicleFlags/fn_getActionsFlagCategories.sqf index 640235d..1c9aabc 100644 --- a/functions/vehicleFlags/fn_getActionsFlagCategories.sqf +++ b/functions/vehicleFlags/fn_getActionsFlagCategories.sqf @@ -42,6 +42,9 @@ private _allCategoryActions = []; private _flagOptionTitle = getText(_flagOptionCfg >> "actionTitle"); private _flagOptionTexture = getText(_flagOptionCfg >> "texture"); + // if the texture doesn't exist at the config path, skip this flag option + if (not (fileExists _flagOptionTexture)) then {continue}; + // diag_log format ["NewFlagOption: %1 %2", _flagOptionID, _flagOptionData]; private _newFlagOption = [ diff --git a/functions/vehicleFlags/fn_initVehicleFlags.sqf b/functions/vehicleFlags/fn_initVehicleFlags.sqf index 2141de4..32f2952 100644 --- a/functions/vehicleFlags/fn_initVehicleFlags.sqf +++ b/functions/vehicleFlags/fn_initVehicleFlags.sqf @@ -6,18 +6,6 @@ if (!isClass _vehicleFlagsCfg) exitWith { ["WARNING: Vehicle Flags: Vehicle Flags config not found. Vehicle Flags will not be available."] call BIS_fnc_error; }; -// get texture pbo class -private _texturePboName = getText(_vehicleFlagsCfg >> "texturePBOName"); -if (_texturePboName == "") exitWith { - ["WARNING: Vehicle Flags: Texture PBO definition is missing or a blank string! Vehicle Flags will not be available."] call BIS_fnc_error; -}; -if (!isClass (configFile >> "CfgPatches" >> _texturePboName)) exitWith { - [ - "WARNING: Vehicle Flags: Texture PBO not found (%1). Vehicle Flags will not be available.", - _texturePboName - ] call BIS_fnc_error; -}; - private _baseClassesToApplyActionsFor = (_vehicleFlagsCfg >> "baseClassesToApplyActionsFor") call BIS_fnc_getCfgDataArray; private _flagCategoryCfgs = (_vehicleFlagsCfg >> "FlagCategories") call BIS_fnc_returnChildren; @@ -84,7 +72,7 @@ private _flagCategoryCfgs = (_vehicleFlagsCfg >> "FlagCategories") call BIS_fnc_ //////////////////////////////////////////////////////////////////////// // create action private _removeFlagAction = [ - _flagRootAction + "_removeflag", // id + _rootActionID + "_removeflag", // id "Remove Flag", // displayed title "\A3\ui_f\data\map\markers\flags\nato_ca.paa", // flag icon { @@ -103,7 +91,7 @@ private _flagCategoryCfgs = (_vehicleFlagsCfg >> "FlagCategories") call BIS_fnc_ [ (_this select 0), // object 0, // action 0 or self-action 1 - ["ACE_MainActions", _flagActionID], // parent + ["ACE_MainActions", _rootActionID], // parent _removeFlagAction // action ] call ace_interact_menu_fnc_addActionToObject; diff --git a/functions/vehicleFlags/fn_isClassExcluded.sqf b/functions/vehicleFlags/fn_isClassExcluded.sqf index 5d1b85d..223d6ae 100644 --- a/functions/vehicleFlags/fn_isClassExcluded.sqf +++ b/functions/vehicleFlags/fn_isClassExcluded.sqf @@ -10,7 +10,7 @@ if (!hasInterface) exitWith {}; -params ["_className", "", [""]]; +params [["_className", "", [""]]]; if (_className == "") exitWith {false}; private _vehicleFlagsCfg = call milsim_vehicleFlags_fnc_getVehicleFlagsCfg; -- 2.37.3.windows.1 From 4cfa159ee9934ae5618c1ff37578cdd3c9245a95 Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Sun, 4 Feb 2024 21:23:12 -0800 Subject: [PATCH 10/16] change root level folder name to framework, update resupply+vehicleflags tested locally --- description.ext | 3 +- {functions => framework}/CfgFunctions.hpp | 58 ++++++++++--------- .../ambience/fn_flakEH.sqf | 0 .../ambience/fn_flakInitVehicle.sqf | 0 .../client/fn_addClientStatsPFH.sqf | 0 .../client/fn_addDNI_PlayerFPS.sqf | 0 .../client/fn_addMedicalOverlayPFH.sqf | 0 .../client/fn_addZenModules.sqf | 0 .../fn_bindEmptyGroupGarbageCleanup.sqf | 0 .../client/fn_bindEventHandlers.sqf | 8 +-- .../client/fn_bindVehicleActions.sqf | 0 .../client/fn_calculateClientStats.sqf | 0 .../assets/byBase/fn_getAssetsByBase.sqf | 0 .../byBase/fn_getStartingAssetsByBase.sqf | 0 .../assets/byBase/fn_updateAssetsByBase.sqf | 12 ++-- .../fbcb2/assets/fn_getInventory.sqf | 0 .../fbcb2/assets/fn_getMagsForWeapon.sqf | 0 .../fbcb2/assets/fn_getVehicleData.sqf | 0 .../fbcb2/assets/fn_getWeaponry.sqf | 0 .../assets/fn_removeAssetDiaryRecords.sqf | 0 .../fbcb2/assets/fn_updateAssetDiary.sqf | 2 +- .../assets/markers/fn_removeMarkersOnMap.sqf | 0 .../assets/markers/fn_showMarkersOnMap.sqf | 2 +- .../fbcb2/fn_hintFBCB2AssetStatus.sqf | 0 .../fbcb2/fn_initFBCB2.sqf | 0 .../fbcb2/fn_processFBCB2Environment.sqf | 0 .../fbcb2/fn_processFBCB2RadioFrequencies.sqf | 2 +- .../fbcb2/fn_processFBCB2SmokeColors.sqf | 0 .../fn_formatRadioElementForDiary.sqf | 4 +- .../fn_generateElementFrequencyRecordText.sqf | 6 +- .../util/fn_createOrUpdateDiaryRecord.sqf | 0 .../fbcb2/util/fn_removeDiaryRecord.sqf | 0 framework/init/fn_initPlayerLocal.sqf | 14 +++++ .../init/fn_initServer.sqf | 0 .../map/fn_copyMapFromPlayer.sqf | 0 .../map/fn_getPlayerMapMarkers.sqf | 0 .../map/fn_initMapCopy.sqf | 0 .../map/fn_loadMapMarkers.sqf | 0 .../map/fn_mapMarkerToString.sqf | 0 .../map/fn_stringToMapMarker.sqf | 0 .../reinsert/client/fn_addAceSelfActions.sqf | 6 +- .../client/fn_addCheckQueueSelfAction.sqf | 0 .../reinsert/client/fn_initClient.sqf | 0 .../reinsert/client/fn_requestShowQueue.sqf | 0 .../reinsert/server/fn_addToQueue.sqf | 12 ++-- .../reinsert/server/fn_globalShowQueue.sqf | 12 ++-- .../reinsert/server/fn_initServer.sqf | 0 .../reinsert/server/fn_removeFromQueue.sqf | 14 ++--- .../fn_returnReinsertQueueNotification.sqf | 6 +- .../reinsert/server/fn_validateQueue.sqf | 18 +++--- .../fn_addArsenalObjectSpawnBoxActions.sqf | 6 +- .../resupply/functions/fn_addCBASettings.sqf | 25 ++++++++ .../resupply/functions}/fn_createBox.sqf | 5 +- .../functions/fn_getSupplyCratesCfg.sqf | 2 + framework/resupply/functions/fn_init.sqf | 12 ++++ framework/resupply/script_component.hpp | 3 + framework/script_macros.hpp | 5 ++ framework/script_mod.hpp | 10 ++++ framework/script_version.hpp | 4 ++ .../server/fn_addServerStatsPFH.sqf | 0 .../server/fn_calculateServerStats.sqf | 0 .../server/fn_logPlayerInventory.sqf | 16 ++--- .../settings/fn_addAARChatHandler.sqf | 0 .../settings/fn_addCBASettings.sqf | 12 ++-- .../settings/fn_addRespawnChatHandler.sqf | 4 +- .../settings/fn_setDefaults.sqf | 0 .../util/fn_addPlayerInfoToArray.sqf | 0 .../util/fn_getBattalionCfg.sqf | 0 .../util/fn_getNameOfBase.sqf | 0 .../util/fn_getNearestBase.sqf | 0 {functions => framework}/util/fn_log.sqf | 2 +- .../util/fn_logMissionInfo.sqf | 2 +- .../util/fn_padString.sqf | 0 .../util/fn_recurseSubclasses.sqf | 0 .../fn_getActionsFlagCategories.sqf | 0 .../functions}/fn_getVehicleFlagsCfg.sqf | 0 .../vehicleFlags/functions/fn_init.sqf | 8 ++- .../functions}/fn_isClassExcluded.sqf | 0 framework/vehicleFlags/script_component.hpp | 3 + functions/init/fn_initPlayerLocal.sqf | 25 -------- functions/resupply/fn_addCBASettings.sqf | 22 ------- functions/resupply/fn_createAmmoBox.sqf | 36 ------------ functions/resupply/fn_createCSWBox.sqf | 36 ------------ functions/resupply/fn_createLaunchersBox.sqf | 36 ------------ functions/resupply/fn_createMedicalBox.sqf | 26 --------- functions/resupply/fn_createMortarBox.sqf | 36 ------------ functions/resupply/fn_createWeaponsBox.sqf | 36 ------------ functions/resupply/fn_getSupplyCratesCfg.sqf | 1 - 88 files changed, 193 insertions(+), 359 deletions(-) rename {functions => framework}/CfgFunctions.hpp (80%) rename {functions => framework}/ambience/fn_flakEH.sqf (100%) rename {functions => framework}/ambience/fn_flakInitVehicle.sqf (100%) rename {functions => framework}/client/fn_addClientStatsPFH.sqf (100%) rename {functions => framework}/client/fn_addDNI_PlayerFPS.sqf (100%) rename {functions => framework}/client/fn_addMedicalOverlayPFH.sqf (100%) rename {functions => framework}/client/fn_addZenModules.sqf (100%) rename {functions => framework}/client/fn_bindEmptyGroupGarbageCleanup.sqf (100%) rename {functions => framework}/client/fn_bindEventHandlers.sqf (86%) rename {functions => framework}/client/fn_bindVehicleActions.sqf (100%) rename {functions => framework}/client/fn_calculateClientStats.sqf (100%) rename {functions => framework}/fbcb2/assets/byBase/fn_getAssetsByBase.sqf (100%) rename {functions => framework}/fbcb2/assets/byBase/fn_getStartingAssetsByBase.sqf (100%) rename {functions => framework}/fbcb2/assets/byBase/fn_updateAssetsByBase.sqf (92%) rename {functions => framework}/fbcb2/assets/fn_getInventory.sqf (100%) rename {functions => framework}/fbcb2/assets/fn_getMagsForWeapon.sqf (100%) rename {functions => framework}/fbcb2/assets/fn_getVehicleData.sqf (100%) rename {functions => framework}/fbcb2/assets/fn_getWeaponry.sqf (100%) rename {functions => framework}/fbcb2/assets/fn_removeAssetDiaryRecords.sqf (100%) rename {functions => framework}/fbcb2/assets/fn_updateAssetDiary.sqf (99%) rename {functions => framework}/fbcb2/assets/markers/fn_removeMarkersOnMap.sqf (100%) rename {functions => framework}/fbcb2/assets/markers/fn_showMarkersOnMap.sqf (97%) rename {functions => framework}/fbcb2/fn_hintFBCB2AssetStatus.sqf (100%) rename {functions => framework}/fbcb2/fn_initFBCB2.sqf (100%) rename {functions => framework}/fbcb2/fn_processFBCB2Environment.sqf (100%) rename {functions => framework}/fbcb2/fn_processFBCB2RadioFrequencies.sqf (96%) rename {functions => framework}/fbcb2/fn_processFBCB2SmokeColors.sqf (100%) rename {functions => framework}/fbcb2/radioFrequencies/fn_formatRadioElementForDiary.sqf (92%) rename {functions => framework}/fbcb2/radioFrequencies/fn_generateElementFrequencyRecordText.sqf (92%) rename {functions => framework}/fbcb2/util/fn_createOrUpdateDiaryRecord.sqf (100%) rename {functions => framework}/fbcb2/util/fn_removeDiaryRecord.sqf (100%) create mode 100644 framework/init/fn_initPlayerLocal.sqf rename {functions => framework}/init/fn_initServer.sqf (100%) rename {functions => framework}/map/fn_copyMapFromPlayer.sqf (100%) rename {functions => framework}/map/fn_getPlayerMapMarkers.sqf (100%) rename {functions => framework}/map/fn_initMapCopy.sqf (100%) rename {functions => framework}/map/fn_loadMapMarkers.sqf (100%) rename {functions => framework}/map/fn_mapMarkerToString.sqf (100%) rename {functions => framework}/map/fn_stringToMapMarker.sqf (100%) rename {functions => framework}/reinsert/client/fn_addAceSelfActions.sqf (93%) rename {functions => framework}/reinsert/client/fn_addCheckQueueSelfAction.sqf (100%) rename {functions => framework}/reinsert/client/fn_initClient.sqf (100%) rename {functions => framework}/reinsert/client/fn_requestShowQueue.sqf (100%) rename {functions => framework}/reinsert/server/fn_addToQueue.sqf (78%) rename {functions => framework}/reinsert/server/fn_globalShowQueue.sqf (85%) rename {functions => framework}/reinsert/server/fn_initServer.sqf (100%) rename {functions => framework}/reinsert/server/fn_removeFromQueue.sqf (79%) rename {functions => framework}/reinsert/server/fn_returnReinsertQueueNotification.sqf (93%) rename {functions => framework}/reinsert/server/fn_validateQueue.sqf (73%) rename {functions/resupply => framework/resupply/functions}/fn_addArsenalObjectSpawnBoxActions.sqf (87%) create mode 100644 framework/resupply/functions/fn_addCBASettings.sqf rename {functions/resupply => framework/resupply/functions}/fn_createBox.sqf (98%) create mode 100644 framework/resupply/functions/fn_getSupplyCratesCfg.sqf create mode 100644 framework/resupply/functions/fn_init.sqf create mode 100644 framework/resupply/script_component.hpp create mode 100644 framework/script_macros.hpp create mode 100644 framework/script_mod.hpp create mode 100644 framework/script_version.hpp rename {functions => framework}/server/fn_addServerStatsPFH.sqf (100%) rename {functions => framework}/server/fn_calculateServerStats.sqf (100%) rename {functions => framework}/server/fn_logPlayerInventory.sqf (92%) rename {functions => framework}/settings/fn_addAARChatHandler.sqf (100%) rename {functions => framework}/settings/fn_addCBASettings.sqf (97%) rename {functions => framework}/settings/fn_addRespawnChatHandler.sqf (81%) rename {functions => framework}/settings/fn_setDefaults.sqf (100%) rename {functions => framework}/util/fn_addPlayerInfoToArray.sqf (100%) rename {functions => framework}/util/fn_getBattalionCfg.sqf (100%) rename {functions => framework}/util/fn_getNameOfBase.sqf (100%) rename {functions => framework}/util/fn_getNearestBase.sqf (100%) rename {functions => framework}/util/fn_log.sqf (92%) rename {functions => framework}/util/fn_logMissionInfo.sqf (97%) rename {functions => framework}/util/fn_padString.sqf (100%) rename {functions => framework}/util/fn_recurseSubclasses.sqf (100%) rename {functions/vehicleFlags => framework/vehicleFlags/functions}/fn_getActionsFlagCategories.sqf (100%) rename {functions/vehicleFlags => framework/vehicleFlags/functions}/fn_getVehicleFlagsCfg.sqf (100%) rename functions/vehicleFlags/fn_initVehicleFlags.sqf => framework/vehicleFlags/functions/fn_init.sqf (93%) rename {functions/vehicleFlags => framework/vehicleFlags/functions}/fn_isClassExcluded.sqf (100%) create mode 100644 framework/vehicleFlags/script_component.hpp delete mode 100644 functions/init/fn_initPlayerLocal.sqf delete mode 100644 functions/resupply/fn_addCBASettings.sqf delete mode 100644 functions/resupply/fn_createAmmoBox.sqf delete mode 100644 functions/resupply/fn_createCSWBox.sqf delete mode 100644 functions/resupply/fn_createLaunchersBox.sqf delete mode 100644 functions/resupply/fn_createMedicalBox.sqf delete mode 100644 functions/resupply/fn_createMortarBox.sqf delete mode 100644 functions/resupply/fn_createWeaponsBox.sqf delete mode 100644 functions/resupply/fn_getSupplyCratesCfg.sqf diff --git a/description.ext b/description.ext index 3bb5ba0..558a08f 100644 --- a/description.ext +++ b/description.ext @@ -17,6 +17,7 @@ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #include "mission_settings.hpp" +#include "framework\script_mod.hpp" #include "defines\ApprovedAssets.hpp" #include "defines\BattalionInfo.hpp" #include "defines\DisallowedEquipment.hpp" @@ -94,7 +95,7 @@ class Params class cfgFunctions { - #include "functions\CfgFunctions.hpp" + #include "framework\CfgFunctions.hpp" }; diff --git a/functions/CfgFunctions.hpp b/framework/CfgFunctions.hpp similarity index 80% rename from functions/CfgFunctions.hpp rename to framework/CfgFunctions.hpp index 4c4a8d1..d19b024 100644 --- a/functions/CfgFunctions.hpp +++ b/framework/CfgFunctions.hpp @@ -2,6 +2,7 @@ class milsim { class settings { + file = "framework\settings"; class setDefaults { postInit = 1; }; class addCBASettings { postInit = 1; }; class addAARChatHandler { postInit = 1; }; @@ -10,11 +11,13 @@ class milsim class init { + file = "framework\init"; class initServer { postInit = 1;}; //needs refactor class initPlayerLocal { postInit = 1;}; }; class fbcb2 { + file = "framework\fbcb2"; class initFBCB2 { postInit = 1; }; class processFBCB2RadioFrequencies {}; class processFBCB2SmokeColors {}; @@ -22,16 +25,17 @@ class milsim class hintFBCB2AssetStatus {}; }; class fbcb2_util { - file = "functions\fbcb2\util"; + file = "framework\fbcb2\util"; class createOrUpdateDiaryRecord {}; }; class fbcb2_radioFrequencies { - file = "functions\fbcb2\radioFrequencies"; + file = "framework\fbcb2\radioFrequencies"; class formatRadioElementForDiary {}; class generateElementFrequencyRecordText {}; }; class client { + file = "framework\client"; class addZenModules { postInit = 1; }; class addDNI_PlayerFPS { postInit = 1; }; // needs refactor class bindEventHandlers { postInit = 1; }; @@ -43,18 +47,21 @@ class milsim }; class server { + file = "framework\server"; class addServerStatsPFH {}; class calculateServerStats {}; class logPlayerInventory {}; }; class ambience { + file = "framework\ambience"; class flakInitVehicle {}; class flakEH {}; }; class map { + file = "framework\map"; class initMapCopy { postInit = 1; }; class copyMapFromPlayer {}; //needs refactor class getPlayerMapMarkers {}; //needs refactor @@ -62,9 +69,11 @@ class milsim class mapMarkerToString {}; //needs refactor class stringToMapMarker {}; //needs refactor }; +}; - class util - { +class milsim_util { + class functions { + file = "framework\util"; class logMissionInfo { postInit = 1; }; class addPlayerInfoToArray {}; class log {}; @@ -78,14 +87,9 @@ class milsim class milsim_resupply { class functions { - file = "functions\resupply"; - class createAmmoBox {}; + file = "framework\resupply\functions"; + class init {postInit=1;}; class createBox {}; - class createCSWBox {}; - class createLaunchersBox {}; - class createMedicalBox {}; - class createMortarBox {}; - class createWeaponsBox {}; class getSupplyCratesCfg {}; class addArsenalObjectSpawnBoxActions {}; class addCBASettings {postInit=1;}; @@ -94,7 +98,7 @@ class milsim_resupply { class milsim_fbcb2_assets { class functions { - file = "functions\fbcb2\assets"; + file = "framework\fbcb2\assets"; class updateAssetDiary {}; class removeAssetDiaryRecords {}; class getMagsForWeapon {}; @@ -103,21 +107,31 @@ class milsim_fbcb2_assets { class getVehicleData {}; }; class assetsByBase { - file = "functions\fbcb2\assets\byBase"; + file = "framework\fbcb2\assets\byBase"; class getAssetsByBase {}; class getStartingAssetsByBase {}; class updateAssetsByBase {}; }; class markers { - file = "functions\fbcb2\assets\markers"; + file = "framework\fbcb2\assets\markers"; class showMarkersOnMap {}; class removeMarkersOnMap {}; - } + }; +}; + +class milsim_vehicleFlags { + class functions { + file = "framework\vehicleFlags\functions"; + class init {postInit=1;}; + class getActionsFlagCategories {}; + class getVehicleFlagsCfg {}; + class isClassExcluded {}; + }; }; class milsim_reinsert { class server { - file = "functions\reinsert\server"; + file = "framework\reinsert\server"; class initServer { postInit = 1; }; class addToQueue {}; class globalShowQueue {}; @@ -126,20 +140,10 @@ class milsim_reinsert { class validateQueue {}; }; class client { - file = "functions\reinsert\client"; + file = "framework\reinsert\client"; class initClient { postInit = 1; }; class addAceSelfActions {}; class addCheckQueueSelfAction {}; class requestShowQueue {}; }; -}; - -class milsim_vehicleFlags { - class functions { - file = "functions\vehicleFlags"; - class initVehicleFlags {postInit = 1}; - class getActionsFlagCategories {}; - class getVehicleFlagsCfg {}; - class isClassExcluded{}; - }; }; \ No newline at end of file diff --git a/functions/ambience/fn_flakEH.sqf b/framework/ambience/fn_flakEH.sqf similarity index 100% rename from functions/ambience/fn_flakEH.sqf rename to framework/ambience/fn_flakEH.sqf diff --git a/functions/ambience/fn_flakInitVehicle.sqf b/framework/ambience/fn_flakInitVehicle.sqf similarity index 100% rename from functions/ambience/fn_flakInitVehicle.sqf rename to framework/ambience/fn_flakInitVehicle.sqf diff --git a/functions/client/fn_addClientStatsPFH.sqf b/framework/client/fn_addClientStatsPFH.sqf similarity index 100% rename from functions/client/fn_addClientStatsPFH.sqf rename to framework/client/fn_addClientStatsPFH.sqf diff --git a/functions/client/fn_addDNI_PlayerFPS.sqf b/framework/client/fn_addDNI_PlayerFPS.sqf similarity index 100% rename from functions/client/fn_addDNI_PlayerFPS.sqf rename to framework/client/fn_addDNI_PlayerFPS.sqf diff --git a/functions/client/fn_addMedicalOverlayPFH.sqf b/framework/client/fn_addMedicalOverlayPFH.sqf similarity index 100% rename from functions/client/fn_addMedicalOverlayPFH.sqf rename to framework/client/fn_addMedicalOverlayPFH.sqf diff --git a/functions/client/fn_addZenModules.sqf b/framework/client/fn_addZenModules.sqf similarity index 100% rename from functions/client/fn_addZenModules.sqf rename to framework/client/fn_addZenModules.sqf diff --git a/functions/client/fn_bindEmptyGroupGarbageCleanup.sqf b/framework/client/fn_bindEmptyGroupGarbageCleanup.sqf similarity index 100% rename from functions/client/fn_bindEmptyGroupGarbageCleanup.sqf rename to framework/client/fn_bindEmptyGroupGarbageCleanup.sqf diff --git a/functions/client/fn_bindEventHandlers.sqf b/framework/client/fn_bindEventHandlers.sqf similarity index 86% rename from functions/client/fn_bindEventHandlers.sqf rename to framework/client/fn_bindEventHandlers.sqf index b4bcf8f..55d4781 100644 --- a/functions/client/fn_bindEventHandlers.sqf +++ b/framework/client/fn_bindEventHandlers.sqf @@ -8,8 +8,8 @@ player addEventHandler["Respawn", [ "client", "RESPAWNED WHILE UNCONSCIOUS", - [_unit] call milsim_fnc_addPlayerInfoToArray - ] remoteExec ["milsim_fnc_log", 2]; + [_unit] call milsim_util_fnc_addPlayerInfoToArray + ] remoteExec ["milsim_util_fnc_log", 2]; // format["%1 was unconscious then clicked the respawn button", name _unit] remoteExec["systemChat", 0]; }; } @@ -43,11 +43,11 @@ addMissionEventHandler ["HandleChatMessage", ["ace_arsenal_displayClosed", { - [player] remoteExec ["milsim_fnc_logPlayerInventory", 2]; + [player] remoteExec ["milsim_util_fnc_logPlayerInventory", 2]; }] call CBA_fnc_addEventHandler; [missionNamespace, "arsenalClosed", { - [player] remoteExec ["milsim_fnc_logPlayerInventory", 2]; + [player] remoteExec ["milsim_util_fnc_logPlayerInventory", 2]; }] call BIS_fnc_addScriptedEventHandler; diag_log text "[MILSIM] (client) event handlers bound"; diff --git a/functions/client/fn_bindVehicleActions.sqf b/framework/client/fn_bindVehicleActions.sqf similarity index 100% rename from functions/client/fn_bindVehicleActions.sqf rename to framework/client/fn_bindVehicleActions.sqf diff --git a/functions/client/fn_calculateClientStats.sqf b/framework/client/fn_calculateClientStats.sqf similarity index 100% rename from functions/client/fn_calculateClientStats.sqf rename to framework/client/fn_calculateClientStats.sqf diff --git a/functions/fbcb2/assets/byBase/fn_getAssetsByBase.sqf b/framework/fbcb2/assets/byBase/fn_getAssetsByBase.sqf similarity index 100% rename from functions/fbcb2/assets/byBase/fn_getAssetsByBase.sqf rename to framework/fbcb2/assets/byBase/fn_getAssetsByBase.sqf diff --git a/functions/fbcb2/assets/byBase/fn_getStartingAssetsByBase.sqf b/framework/fbcb2/assets/byBase/fn_getStartingAssetsByBase.sqf similarity index 100% rename from functions/fbcb2/assets/byBase/fn_getStartingAssetsByBase.sqf rename to framework/fbcb2/assets/byBase/fn_getStartingAssetsByBase.sqf diff --git a/functions/fbcb2/assets/byBase/fn_updateAssetsByBase.sqf b/framework/fbcb2/assets/byBase/fn_updateAssetsByBase.sqf similarity index 92% rename from functions/fbcb2/assets/byBase/fn_updateAssetsByBase.sqf rename to framework/fbcb2/assets/byBase/fn_updateAssetsByBase.sqf index e243526..d5f5ffb 100644 --- a/functions/fbcb2/assets/byBase/fn_updateAssetsByBase.sqf +++ b/framework/fbcb2/assets/byBase/fn_updateAssetsByBase.sqf @@ -23,7 +23,7 @@ private _assetsStartedAtThisBaseVar = "milsim_fbcb2_assets_assetsStartedAtThisBa private _asset = _x; // avoid duplicates if (_asset in _allSaved) then {continue}; - private _closestBase = [_asset] call milsim_fnc_getNearestBase; + private _closestBase = [_asset] call milsim_util_fnc_getNearestBase; if (isNull _closestBase) then { // no base found continue; @@ -66,7 +66,7 @@ private _assetsStartedAtThisBaseVar = "milsim_fbcb2_assets_assetsStartedAtThisBa // avoid duplicates if (_asset in _allSaved) then {continue}; - private _closestBase = [_asset] call milsim_fnc_getNearestBase; + private _closestBase = [_asset] call milsim_util_fnc_getNearestBase; if (isNull _closestBase) then { // no base found continue; @@ -156,10 +156,10 @@ if !(_isInit || _logCurrentAssets) exitWith {}; "fbcb2_assets", "CURRENT ASSETS", [ - ["baseName", [[_base] call milsim_fnc_getNameOfBase]], + ["baseName", [[_base] call milsim_util_fnc_getNameOfBase]], ["asset", _x] ] - ] call milsim_fnc_log; + ] call milsim_util_fnc_log; } forEach _baseAssetsHashes; }; @@ -170,10 +170,10 @@ if !(_isInit || _logCurrentAssets) exitWith {}; "fbcb2_assets", "STARTING ASSETS", [ - ["baseName", [[_base] call milsim_fnc_getNameOfBase]], + ["baseName", [[_base] call milsim_util_fnc_getNameOfBase]], ["asset", _x] ] - ] call milsim_fnc_log; + ] call milsim_util_fnc_log; } forEach _baseAssetsHashes; }; } forEach milsim_baseObjects; \ No newline at end of file diff --git a/functions/fbcb2/assets/fn_getInventory.sqf b/framework/fbcb2/assets/fn_getInventory.sqf similarity index 100% rename from functions/fbcb2/assets/fn_getInventory.sqf rename to framework/fbcb2/assets/fn_getInventory.sqf diff --git a/functions/fbcb2/assets/fn_getMagsForWeapon.sqf b/framework/fbcb2/assets/fn_getMagsForWeapon.sqf similarity index 100% rename from functions/fbcb2/assets/fn_getMagsForWeapon.sqf rename to framework/fbcb2/assets/fn_getMagsForWeapon.sqf diff --git a/functions/fbcb2/assets/fn_getVehicleData.sqf b/framework/fbcb2/assets/fn_getVehicleData.sqf similarity index 100% rename from functions/fbcb2/assets/fn_getVehicleData.sqf rename to framework/fbcb2/assets/fn_getVehicleData.sqf diff --git a/functions/fbcb2/assets/fn_getWeaponry.sqf b/framework/fbcb2/assets/fn_getWeaponry.sqf similarity index 100% rename from functions/fbcb2/assets/fn_getWeaponry.sqf rename to framework/fbcb2/assets/fn_getWeaponry.sqf diff --git a/functions/fbcb2/assets/fn_removeAssetDiaryRecords.sqf b/framework/fbcb2/assets/fn_removeAssetDiaryRecords.sqf similarity index 100% rename from functions/fbcb2/assets/fn_removeAssetDiaryRecords.sqf rename to framework/fbcb2/assets/fn_removeAssetDiaryRecords.sqf diff --git a/functions/fbcb2/assets/fn_updateAssetDiary.sqf b/framework/fbcb2/assets/fn_updateAssetDiary.sqf similarity index 99% rename from functions/fbcb2/assets/fn_updateAssetDiary.sqf rename to framework/fbcb2/assets/fn_updateAssetDiary.sqf index 784242f..0f87ef2 100644 --- a/functions/fbcb2/assets/fn_updateAssetDiary.sqf +++ b/framework/fbcb2/assets/fn_updateAssetDiary.sqf @@ -180,6 +180,6 @@ private _distinctVehiclesClassNames = []; ["assetCount", count _vehicles], ["distinctAssetCount", count _distinctVehiclesClassNames] ] -] call milsim_fnc_log; +] call milsim_util_fnc_log; true; \ No newline at end of file diff --git a/functions/fbcb2/assets/markers/fn_removeMarkersOnMap.sqf b/framework/fbcb2/assets/markers/fn_removeMarkersOnMap.sqf similarity index 100% rename from functions/fbcb2/assets/markers/fn_removeMarkersOnMap.sqf rename to framework/fbcb2/assets/markers/fn_removeMarkersOnMap.sqf diff --git a/functions/fbcb2/assets/markers/fn_showMarkersOnMap.sqf b/framework/fbcb2/assets/markers/fn_showMarkersOnMap.sqf similarity index 97% rename from functions/fbcb2/assets/markers/fn_showMarkersOnMap.sqf rename to framework/fbcb2/assets/markers/fn_showMarkersOnMap.sqf index c804d76..bb7bea4 100644 --- a/functions/fbcb2/assets/markers/fn_showMarkersOnMap.sqf +++ b/framework/fbcb2/assets/markers/fn_showMarkersOnMap.sqf @@ -61,7 +61,7 @@ if (not (count _baseMarkerStore > 0)) then { _newMarker setMarkerTypeLocal "mil_flag"; _newMarker setMarkerColorLocal "ColorGreen"; _newMarker setMarkerSizeLocal [0.7, 0.7]; - _newMarker setMarkerTextLocal ([_base] call milsim_fnc_getNameOfBase); + _newMarker setMarkerTextLocal ([_base] call milsim_util_fnc_getNameOfBase); _baseMarkerStore pushBack [ _base, diff --git a/functions/fbcb2/fn_hintFBCB2AssetStatus.sqf b/framework/fbcb2/fn_hintFBCB2AssetStatus.sqf similarity index 100% rename from functions/fbcb2/fn_hintFBCB2AssetStatus.sqf rename to framework/fbcb2/fn_hintFBCB2AssetStatus.sqf diff --git a/functions/fbcb2/fn_initFBCB2.sqf b/framework/fbcb2/fn_initFBCB2.sqf similarity index 100% rename from functions/fbcb2/fn_initFBCB2.sqf rename to framework/fbcb2/fn_initFBCB2.sqf diff --git a/functions/fbcb2/fn_processFBCB2Environment.sqf b/framework/fbcb2/fn_processFBCB2Environment.sqf similarity index 100% rename from functions/fbcb2/fn_processFBCB2Environment.sqf rename to framework/fbcb2/fn_processFBCB2Environment.sqf diff --git a/functions/fbcb2/fn_processFBCB2RadioFrequencies.sqf b/framework/fbcb2/fn_processFBCB2RadioFrequencies.sqf similarity index 96% rename from functions/fbcb2/fn_processFBCB2RadioFrequencies.sqf rename to framework/fbcb2/fn_processFBCB2RadioFrequencies.sqf index 69270a8..15e26eb 100644 --- a/functions/fbcb2/fn_processFBCB2RadioFrequencies.sqf +++ b/framework/fbcb2/fn_processFBCB2RadioFrequencies.sqf @@ -4,7 +4,7 @@ //////////////////////////////////////// // Get info from missionConfigFile //////////////////////////////////////// -private _battalionInfoCfg = call milsim_fnc_getBattalionCfg; +private _battalionInfoCfg = call milsim_util_fnc_getBattalionCfg; private _battalionElementCfgs = [_battalionInfoCfg >> "Command"] call BIS_fnc_returnChildren; //////////////////////////////////////// diff --git a/functions/fbcb2/fn_processFBCB2SmokeColors.sqf b/framework/fbcb2/fn_processFBCB2SmokeColors.sqf similarity index 100% rename from functions/fbcb2/fn_processFBCB2SmokeColors.sqf rename to framework/fbcb2/fn_processFBCB2SmokeColors.sqf diff --git a/functions/fbcb2/radioFrequencies/fn_formatRadioElementForDiary.sqf b/framework/fbcb2/radioFrequencies/fn_formatRadioElementForDiary.sqf similarity index 92% rename from functions/fbcb2/radioFrequencies/fn_formatRadioElementForDiary.sqf rename to framework/fbcb2/radioFrequencies/fn_formatRadioElementForDiary.sqf index 8a4bdc0..fce0c35 100644 --- a/functions/fbcb2/radioFrequencies/fn_formatRadioElementForDiary.sqf +++ b/framework/fbcb2/radioFrequencies/fn_formatRadioElementForDiary.sqf @@ -62,8 +62,8 @@ _freqLeadingSpace = _freqLeadingSpace joinString ""; _ELEMENT_FREQ_SIZE, _ELEMENT_FREQ_FONT, _FREQ_TEXT_COLOR, - [_role, "right", " ", _FREQ_PAD_LENGTH] call milsim_fnc_padString, - [_srStr, "right", " ", _FREQ_PAD_LENGTH] call milsim_fnc_padString, + [_role, "right", " ", _FREQ_PAD_LENGTH] call milsim_util_fnc_padString, + [_srStr, "right", " ", _FREQ_PAD_LENGTH] call milsim_util_fnc_padString, _lrStr ]; } forEach (getArray (_cfg >> "frequencies")); diff --git a/functions/fbcb2/radioFrequencies/fn_generateElementFrequencyRecordText.sqf b/framework/fbcb2/radioFrequencies/fn_generateElementFrequencyRecordText.sqf similarity index 92% rename from functions/fbcb2/radioFrequencies/fn_generateElementFrequencyRecordText.sqf rename to framework/fbcb2/radioFrequencies/fn_generateElementFrequencyRecordText.sqf index 113ede7..b7a8986 100644 --- a/functions/fbcb2/radioFrequencies/fn_generateElementFrequencyRecordText.sqf +++ b/framework/fbcb2/radioFrequencies/fn_generateElementFrequencyRecordText.sqf @@ -51,8 +51,8 @@ private _headers = [ _ELEMENT_FREQ_SIZE, _ELEMENT_FREQ_FONT, _FREQ_TEXT_COLOR, - ["ROLE", "right", " ", _FREQ_PAD_LENGTH] call milsim_fnc_padString, - ["SR", "right", " ", _FREQ_PAD_LENGTH] call milsim_fnc_padString, + ["ROLE", "right", " ", _FREQ_PAD_LENGTH] call milsim_util_fnc_padString, + ["SR", "right", " ", _FREQ_PAD_LENGTH] call milsim_util_fnc_padString, "LR" ] ]; @@ -71,7 +71,7 @@ if (_shouldProcessChildCfgs) then { private _lines = [_cfg, _recurseCounter+1] call milsim_fnc_formatRadioElementForDiary; // private _lines = [_cfg, _indentCount] call t; _allText pushBack (_lines joinString "
"); - }] call milsim_fnc_recurseSubclasses; + }] call milsim_util_fnc_recurseSubclasses; } else { // or if the param was false, just add the battalion element private _lines = [_battalionElement, 1] call milsim_fnc_formatRadioElementForDiary; diff --git a/functions/fbcb2/util/fn_createOrUpdateDiaryRecord.sqf b/framework/fbcb2/util/fn_createOrUpdateDiaryRecord.sqf similarity index 100% rename from functions/fbcb2/util/fn_createOrUpdateDiaryRecord.sqf rename to framework/fbcb2/util/fn_createOrUpdateDiaryRecord.sqf diff --git a/functions/fbcb2/util/fn_removeDiaryRecord.sqf b/framework/fbcb2/util/fn_removeDiaryRecord.sqf similarity index 100% rename from functions/fbcb2/util/fn_removeDiaryRecord.sqf rename to framework/fbcb2/util/fn_removeDiaryRecord.sqf diff --git a/framework/init/fn_initPlayerLocal.sqf b/framework/init/fn_initPlayerLocal.sqf new file mode 100644 index 0000000..d72495f --- /dev/null +++ b/framework/init/fn_initPlayerLocal.sqf @@ -0,0 +1,14 @@ +if ( !hasInterface ) exitWith {}; + +if (!isServer) then { + ["milsim_logText", { + params [["_strArray", [""], [[]]]]; + { + diag_log text _x; + } forEach _strArray; + }] call CBA_fnc_addEventHandler; +}; + +["InitializePlayer", [player, true]] call BIS_fnc_dynamicGroups; + +nil; \ No newline at end of file diff --git a/functions/init/fn_initServer.sqf b/framework/init/fn_initServer.sqf similarity index 100% rename from functions/init/fn_initServer.sqf rename to framework/init/fn_initServer.sqf diff --git a/functions/map/fn_copyMapFromPlayer.sqf b/framework/map/fn_copyMapFromPlayer.sqf similarity index 100% rename from functions/map/fn_copyMapFromPlayer.sqf rename to framework/map/fn_copyMapFromPlayer.sqf diff --git a/functions/map/fn_getPlayerMapMarkers.sqf b/framework/map/fn_getPlayerMapMarkers.sqf similarity index 100% rename from functions/map/fn_getPlayerMapMarkers.sqf rename to framework/map/fn_getPlayerMapMarkers.sqf diff --git a/functions/map/fn_initMapCopy.sqf b/framework/map/fn_initMapCopy.sqf similarity index 100% rename from functions/map/fn_initMapCopy.sqf rename to framework/map/fn_initMapCopy.sqf diff --git a/functions/map/fn_loadMapMarkers.sqf b/framework/map/fn_loadMapMarkers.sqf similarity index 100% rename from functions/map/fn_loadMapMarkers.sqf rename to framework/map/fn_loadMapMarkers.sqf diff --git a/functions/map/fn_mapMarkerToString.sqf b/framework/map/fn_mapMarkerToString.sqf similarity index 100% rename from functions/map/fn_mapMarkerToString.sqf rename to framework/map/fn_mapMarkerToString.sqf diff --git a/functions/map/fn_stringToMapMarker.sqf b/framework/map/fn_stringToMapMarker.sqf similarity index 100% rename from functions/map/fn_stringToMapMarker.sqf rename to framework/map/fn_stringToMapMarker.sqf diff --git a/functions/reinsert/client/fn_addAceSelfActions.sqf b/framework/reinsert/client/fn_addAceSelfActions.sqf similarity index 93% rename from functions/reinsert/client/fn_addAceSelfActions.sqf rename to framework/reinsert/client/fn_addAceSelfActions.sqf index 137540d..f587af7 100644 --- a/functions/reinsert/client/fn_addAceSelfActions.sqf +++ b/framework/reinsert/client/fn_addAceSelfActions.sqf @@ -13,8 +13,8 @@ private _fileForReinsertAction = [ { // statement params ["_target", "_player", "_params"]; // find nearest base or location - private _base = [_player] call milsim_fnc_getNearestBase; - private _baseName = [_base] call milsim_fnc_getNameOfBase; + private _base = [_player] call milsim_util_fnc_getNearestBase; + private _baseName = [_base] call milsim_util_fnc_getNameOfBase; // send event to server ["milsim_reinsert_fileReinsertRequest", [_player, _base]] call CBA_fnc_serverEvent; // notify player their request was filed @@ -23,7 +23,7 @@ private _fileForReinsertAction = [ { // condition params ["_target", "_player", "_params"]; // find nearest base or location - private _base = [_player] call milsim_fnc_getNearestBase; + private _base = [_player] call milsim_util_fnc_getNearestBase; private _baseDistance = _player distance _base; private _maxRangeToReady = missionNamespace getVariable ["milsim_reinsert_setting_reinsertion_maxRangeToReady", 400]; diff --git a/functions/reinsert/client/fn_addCheckQueueSelfAction.sqf b/framework/reinsert/client/fn_addCheckQueueSelfAction.sqf similarity index 100% rename from functions/reinsert/client/fn_addCheckQueueSelfAction.sqf rename to framework/reinsert/client/fn_addCheckQueueSelfAction.sqf diff --git a/functions/reinsert/client/fn_initClient.sqf b/framework/reinsert/client/fn_initClient.sqf similarity index 100% rename from functions/reinsert/client/fn_initClient.sqf rename to framework/reinsert/client/fn_initClient.sqf diff --git a/functions/reinsert/client/fn_requestShowQueue.sqf b/framework/reinsert/client/fn_requestShowQueue.sqf similarity index 100% rename from functions/reinsert/client/fn_requestShowQueue.sqf rename to framework/reinsert/client/fn_requestShowQueue.sqf diff --git a/functions/reinsert/server/fn_addToQueue.sqf b/framework/reinsert/server/fn_addToQueue.sqf similarity index 78% rename from functions/reinsert/server/fn_addToQueue.sqf rename to framework/reinsert/server/fn_addToQueue.sqf index 55d14a3..1df3fc1 100644 --- a/functions/reinsert/server/fn_addToQueue.sqf +++ b/framework/reinsert/server/fn_addToQueue.sqf @@ -12,7 +12,7 @@ if (!isServer) exitWith { ["player", _player], ["base", _base] ] - ] call milsim_fnc_log; + ] call milsim_util_fnc_log; }; if ( isNull _player || @@ -25,7 +25,7 @@ if ( ["player", _player], ["base", _base] ] - ] call milsim_fnc_log; + ] call milsim_util_fnc_log; }; @@ -41,16 +41,16 @@ publicVariable "milsim_reinsert_reinsertionQueue"; // log to rpt private _logParams = [ - ["filedAtBase", [_base] call milsim_fnc_getNameOfBase], + ["filedAtBase", [_base] call milsim_util_fnc_getNameOfBase], ["filedAtBaseDistance", _player distance _base], - ["closestBase", [_nearestBase] call milsim_fnc_getNameOfBase], + ["closestBase", [_nearestBase] call milsim_util_fnc_getNameOfBase], ["closestBaseDistance", _player distance _nearestBase], ["maxDistanceSetting", _maxRangeToReady], ["inQueueDuration", diag_tickTime - _timeFiled] ]; -_logParams = [_player, _logParams] call milsim_fnc_addPlayerInfoToArray; +_logParams = [_player, _logParams] call milsim_util_fnc_addPlayerInfoToArray; [ "respawn_reinsertion", "PLAYER FILED REQUEST", _logParams -] call milsim_fnc_log; \ No newline at end of file +] call milsim_util_fnc_log; \ No newline at end of file diff --git a/functions/reinsert/server/fn_globalShowQueue.sqf b/framework/reinsert/server/fn_globalShowQueue.sqf similarity index 85% rename from functions/reinsert/server/fn_globalShowQueue.sqf rename to framework/reinsert/server/fn_globalShowQueue.sqf index ea7e80e..ac5eb7b 100644 --- a/functions/reinsert/server/fn_globalShowQueue.sqf +++ b/framework/reinsert/server/fn_globalShowQueue.sqf @@ -21,7 +21,7 @@ if (count _timeoutPlayers > 0) then { private _thisBase = _x; // Add line for base name - _playerLines pushBack ([[_thisBase] call milsim_fnc_getNameOfBase, 1, [0,1,0,1]]); + _playerLines pushBack ([[_thisBase] call milsim_util_fnc_getNameOfBase, 1, [0,1,0,1]]); // Get players under this base private _thisBasePlayers = _timeoutPlayers select {_x#1 isEqualTo _thisBase}; @@ -35,7 +35,7 @@ if (count _timeoutPlayers > 0) then { { // for each player under this base, add a line _x params ["_player", "_base", "_timeFiled"]; // get the closest base to the player - private _nearestBase = [_player] call milsim_fnc_getNearestBase; + private _nearestBase = [_player] call milsim_util_fnc_getNearestBase; // add player to array of players under bases _playerLines pushBack ([format [ @@ -47,19 +47,19 @@ if (count _timeoutPlayers > 0) then { // log to rpt private _logParams = [ - ["filedAtBase", [_base] call milsim_fnc_getNameOfBase], + ["filedAtBase", [_base] call milsim_util_fnc_getNameOfBase], ["filedAtBaseDistance", _player distance _base], - ["closestBase", [_nearestBase] call milsim_fnc_getNameOfBase], + ["closestBase", [_nearestBase] call milsim_util_fnc_getNameOfBase], ["closestBaseDistance", _player distance _nearestBase], ["maxDistanceSetting", _maxRangeToReady], ["inQueueDuration", diag_tickTime - _timeFiled] ]; - _logParams = [_player, _logParams] call milsim_fnc_addPlayerInfoToArray; + _logParams = [_player, _logParams] call milsim_util_fnc_addPlayerInfoToArray; [ "respawn_reinsertion", "PLAYER WAITING OVER TIMEOUT", _logParams - ] call milsim_fnc_log; + ] call milsim_util_fnc_log; } forEach _thisBasePlayers; } forEach _basesWithPeople; diff --git a/functions/reinsert/server/fn_initServer.sqf b/framework/reinsert/server/fn_initServer.sqf similarity index 100% rename from functions/reinsert/server/fn_initServer.sqf rename to framework/reinsert/server/fn_initServer.sqf diff --git a/functions/reinsert/server/fn_removeFromQueue.sqf b/framework/reinsert/server/fn_removeFromQueue.sqf similarity index 79% rename from functions/reinsert/server/fn_removeFromQueue.sqf rename to framework/reinsert/server/fn_removeFromQueue.sqf index 7c131a1..5fc5bbd 100644 --- a/functions/reinsert/server/fn_removeFromQueue.sqf +++ b/framework/reinsert/server/fn_removeFromQueue.sqf @@ -7,7 +7,7 @@ if (!isServer) exitWith { [ ["player", _player] ] - ] call milsim_fnc_log; + ] call milsim_util_fnc_log; }; if (isNull _player) exitWith { [ @@ -16,7 +16,7 @@ if (isNull _player) exitWith { [ ["player", _player] ] - ] call milsim_fnc_log; + ] call milsim_util_fnc_log; }; // get entries for this player from queue @@ -39,19 +39,19 @@ publicVariable "milsim_reinsert_reinsertionQueue"; // get first entry (longest wait) (_unitArrs#0) params ["_player", "_base", "_timeFiled"]; // _unitArr = [unit, base, timeInQueue] // get the closest base to the player -private _nearestBase = [_player] call milsim_fnc_getNearestBase; +private _nearestBase = [_player] call milsim_util_fnc_getNearestBase; // log to rpt private _logParams = [ - ["filedAtBase", [_base] call milsim_fnc_getNameOfBase], + ["filedAtBase", [_base] call milsim_util_fnc_getNameOfBase], ["filedAtBaseDistance", _player distance _base], - ["closestBase", [_nearestBase] call milsim_fnc_getNameOfBase], + ["closestBase", [_nearestBase] call milsim_util_fnc_getNameOfBase], ["closestBaseDistance", _player distance _nearestBase], ["maxDistanceSetting", _maxRangeToReady], ["inQueueDuration", diag_tickTime - _timeFiled] ]; -_logParams = [_player, _logParams] call milsim_fnc_addPlayerInfoToArray; +_logParams = [_player, _logParams] call milsim_util_fnc_addPlayerInfoToArray; [ "respawn_reinsertion", "PLAYER RESCINDED REQUEST", _logParams -] call milsim_fnc_log; \ No newline at end of file +] call milsim_util_fnc_log; \ No newline at end of file diff --git a/functions/reinsert/server/fn_returnReinsertQueueNotification.sqf b/framework/reinsert/server/fn_returnReinsertQueueNotification.sqf similarity index 93% rename from functions/reinsert/server/fn_returnReinsertQueueNotification.sqf rename to framework/reinsert/server/fn_returnReinsertQueueNotification.sqf index ffe648b..fcda7b5 100644 --- a/functions/reinsert/server/fn_returnReinsertQueueNotification.sqf +++ b/framework/reinsert/server/fn_returnReinsertQueueNotification.sqf @@ -25,12 +25,12 @@ if (isNull _userObject) exitWith { }; // log to rpt -private _logParams = [_userObject, []] call milsim_fnc_addPlayerInfoToArray; +private _logParams = [_userObject, []] call milsim_util_fnc_addPlayerInfoToArray; [ "respawn_reinsertion", "SHOW QUEUE REQUESTED", _logParams -] call milsim_fnc_log; +] call milsim_util_fnc_log; private _queue = missionNamespace getVariable ["milsim_reinsert_reinsertionQueue", []]; // get base objects from queue @@ -48,7 +48,7 @@ if (count _basesWithPeople isEqualTo 0) then { // forEach _basesWithPeople { private _thisBase = _x; - private _baseName = [_thisBase] call milsim_fnc_getNameOfBase; + private _baseName = [_thisBase] call milsim_util_fnc_getNameOfBase; // generate player lines for this base private _playerLines = _queue select { diff --git a/functions/reinsert/server/fn_validateQueue.sqf b/framework/reinsert/server/fn_validateQueue.sqf similarity index 73% rename from functions/reinsert/server/fn_validateQueue.sqf rename to framework/reinsert/server/fn_validateQueue.sqf index 5e27733..546768b 100644 --- a/functions/reinsert/server/fn_validateQueue.sqf +++ b/framework/reinsert/server/fn_validateQueue.sqf @@ -7,26 +7,26 @@ private _maxRangeToReady = missionNamespace getVariable ["milsim_reinsert_settin private _distanceToOriginalBase = _player distance _base; // get the closest base to the player - private _nearestBase = [_player] call milsim_fnc_getNearestBase; + private _nearestBase = [_player] call milsim_util_fnc_getNearestBase; private _isCloseEnoughToAnyBase = (_player distance _nearestBase) < _maxRangeToReady; if (not _isCloseEnoughToAnyBase || not (alive _player)) then { // don't include player in updated queue // log to rpt private _logParams = [ - ["filedAtBase", [_base] call milsim_fnc_getNameOfBase], + ["filedAtBase", [_base] call milsim_util_fnc_getNameOfBase], ["filedAtBaseDistance", _player distance _base], - ["closestBase", [_nearestBase] call milsim_fnc_getNameOfBase], + ["closestBase", [_nearestBase] call milsim_util_fnc_getNameOfBase], ["closestBaseDistance", _player distance _nearestBase], ["maxDistanceSetting", _maxRangeToReady], ["inQueueDuration", diag_tickTime - _timeFiled] ]; - _logParams = [_player, _logParams] call milsim_fnc_addPlayerInfoToArray; + _logParams = [_player, _logParams] call milsim_util_fnc_addPlayerInfoToArray; [ "respawn_reinsertion", "PLAYER DEQUEUED AUTOMATICALLY", _logParams - ] call milsim_fnc_log; + ] call milsim_util_fnc_log; // continue loop continue }; @@ -36,19 +36,19 @@ private _maxRangeToReady = missionNamespace getVariable ["milsim_reinsert_settin // if player's base has changed, log to rpt if (_base != _nearestBase) then { private _logParams = [ - ["filedAtBase", [_base] call milsim_fnc_getNameOfBase], + ["filedAtBase", [_base] call milsim_util_fnc_getNameOfBase], ["filedAtBaseDistance", _player distance _base], - ["closestBase", [_nearestBase] call milsim_fnc_getNameOfBase], + ["closestBase", [_nearestBase] call milsim_util_fnc_getNameOfBase], ["closestBaseDistance", _player distance _nearestBase], ["maxDistanceSetting", _maxRangeToReady], ["inQueueDuration", diag_tickTime - _timeFiled] ]; - _logParams = [_player, _logParams] call milsim_fnc_addPlayerInfoToArray; + _logParams = [_player, _logParams] call milsim_util_fnc_addPlayerInfoToArray; [ "respawn_reinsertion", "PLAYER BASE WAS UPDATED", _logParams - ] call milsim_fnc_log; + ] call milsim_util_fnc_log; }; } forEach milsim_reinsert_reinsertionQueue; diff --git a/functions/resupply/fn_addArsenalObjectSpawnBoxActions.sqf b/framework/resupply/functions/fn_addArsenalObjectSpawnBoxActions.sqf similarity index 87% rename from functions/resupply/fn_addArsenalObjectSpawnBoxActions.sqf rename to framework/resupply/functions/fn_addArsenalObjectSpawnBoxActions.sqf index 74963ac..1e9d62b 100644 --- a/functions/resupply/fn_addArsenalObjectSpawnBoxActions.sqf +++ b/framework/resupply/functions/fn_addArsenalObjectSpawnBoxActions.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + // adds a scroll wheel action to all arsenal boxes to spawn different supply crate types private _arsenalBoxClassName = "Land_PaperBox_open_full_F"; @@ -8,7 +10,7 @@ private _arsenalBoxes = (allMissionObjects _arsenalBoxClassName) select { count (actionIDs _x) > 0; }; -private _supplyCratesCfg = call milsim_resupply_fnc_getSupplyCratesCfg; +private _supplyCratesCfg = call FUNC(getSupplyCratesCfg); private _supplyCrateTypesCfgs = _supplyCratesCfg call BIS_fnc_returnChildren; { @@ -25,7 +27,7 @@ private _supplyCrateTypesCfgs = _supplyCratesCfg call BIS_fnc_returnChildren; objNull, configName _supplyCrateCfg, getPos _target - ] call milsim_resupply_fnc_createBox; + ] call FUNC(createBox); }, [_cfg], 0, false, true, "", ""]; } forEach _supplyCrateTypesCfgs; } forEach _arsenalBoxes; \ No newline at end of file diff --git a/framework/resupply/functions/fn_addCBASettings.sqf b/framework/resupply/functions/fn_addCBASettings.sqf new file mode 100644 index 0000000..ec8a7f1 --- /dev/null +++ b/framework/resupply/functions/fn_addCBASettings.sqf @@ -0,0 +1,25 @@ +#include "..\script_component.hpp" + +[ + QGVAR(setting_allowSupplyBoxScrollWheelSpawning), // variable + "CHECKBOX", // type + ["Allow Spawning Boxes from Arsenal Box", "If true, adds scroll wheel options to arsenal boxes to spawn supply boxes"], // title + [QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)], // category + false, // default value + true, // global setting + { + params ["_value"]; + [ + QUOTE(COMPONENT), + "SETTING CHANGED", + [ + [ + "setting", + QGVAR(setting_allowSupplyBoxScrollWheelSpawning) + ], + ["newValue", _value] + ] + ] call EFUNC(util,log); + }, + true // requires mission restart +] call CBA_fnc_addSetting; \ No newline at end of file diff --git a/functions/resupply/fn_createBox.sqf b/framework/resupply/functions/fn_createBox.sqf similarity index 98% rename from functions/resupply/fn_createBox.sqf rename to framework/resupply/functions/fn_createBox.sqf index b4576ef..6bbfbb9 100644 --- a/functions/resupply/fn_createBox.sqf +++ b/framework/resupply/functions/fn_createBox.sqf @@ -27,7 +27,8 @@ ["weapon", (weaponCargo cursorObject) call BIS_fnc_consolidateArray] ]]; */ - + +#include "..\script_component.hpp" params [ ["_box", objNull, [objNull]], @@ -36,7 +37,7 @@ params [ ]; // get defs class -private _supplyCratesCfg = call milsim_resupply_fnc_getSupplyCratesCfg; +private _supplyCratesCfg = call FUNC(getSupplyCratesCfg); if (!isClass _supplyCratesCfg) exitWith { ["Resupply Boxes: Failed to load crate definitions, possibly a bad edit?"] call BIS_fnc_error; objNull; diff --git a/framework/resupply/functions/fn_getSupplyCratesCfg.sqf b/framework/resupply/functions/fn_getSupplyCratesCfg.sqf new file mode 100644 index 0000000..62c7a5e --- /dev/null +++ b/framework/resupply/functions/fn_getSupplyCratesCfg.sqf @@ -0,0 +1,2 @@ +#include "..\script_component.hpp" +(missionConfigFile >> "SupplyCrates"); \ No newline at end of file diff --git a/framework/resupply/functions/fn_init.sqf b/framework/resupply/functions/fn_init.sqf new file mode 100644 index 0000000..ddb55b6 --- /dev/null +++ b/framework/resupply/functions/fn_init.sqf @@ -0,0 +1,12 @@ +#include "..\script_component.hpp" + +// 5 seconds after the client is loaded, add the resupply action to all arsenal boxes +[ + {time > 5}, + { + if (missionNamespace getVariable [ + QGVAR(setting_allowSupplyBoxScrollWheelSpawning), + false + ]) then {call FUNC(addSpawnBoxActions)} + } +] call CBA_fnc_waitUntilAndExecute; \ No newline at end of file diff --git a/framework/resupply/script_component.hpp b/framework/resupply/script_component.hpp new file mode 100644 index 0000000..fd4aad0 --- /dev/null +++ b/framework/resupply/script_component.hpp @@ -0,0 +1,3 @@ +#define COMPONENT resupply +#define COMPONENT_BEAUTIFIED Resupply +#include "../script_mod.hpp" \ No newline at end of file diff --git a/framework/script_macros.hpp b/framework/script_macros.hpp new file mode 100644 index 0000000..840c73f --- /dev/null +++ b/framework/script_macros.hpp @@ -0,0 +1,5 @@ +// all text before cba include +#define SETTINGS_GROUP_NAME 17th Battalion + + +#include "\x\cba\addons\main\script_macros_mission.hpp" \ No newline at end of file diff --git a/framework/script_mod.hpp b/framework/script_mod.hpp new file mode 100644 index 0000000..cdbf23f --- /dev/null +++ b/framework/script_mod.hpp @@ -0,0 +1,10 @@ +#define PREFIX milsim + +#include "script_version.hpp" + +#define VERSION MAJOR.MINOR.PATCHLVL +#define VERSION_STR MAJOR.MINOR.PATCHLVL +#define VERSION_AR MAJOR,MINOR,PATCHLVL + +// should always be last +#include "script_macros.hpp" \ No newline at end of file diff --git a/framework/script_version.hpp b/framework/script_version.hpp new file mode 100644 index 0000000..5e3d29c --- /dev/null +++ b/framework/script_version.hpp @@ -0,0 +1,4 @@ +#define MAJOR 3 +#define MINOR 2 +#define PATCHLVL 1 +#define BUILD 0 diff --git a/functions/server/fn_addServerStatsPFH.sqf b/framework/server/fn_addServerStatsPFH.sqf similarity index 100% rename from functions/server/fn_addServerStatsPFH.sqf rename to framework/server/fn_addServerStatsPFH.sqf diff --git a/functions/server/fn_calculateServerStats.sqf b/framework/server/fn_calculateServerStats.sqf similarity index 100% rename from functions/server/fn_calculateServerStats.sqf rename to framework/server/fn_calculateServerStats.sqf diff --git a/functions/server/fn_logPlayerInventory.sqf b/framework/server/fn_logPlayerInventory.sqf similarity index 92% rename from functions/server/fn_logPlayerInventory.sqf rename to framework/server/fn_logPlayerInventory.sqf index 835d529..105b286 100644 --- a/functions/server/fn_logPlayerInventory.sqf +++ b/framework/server/fn_logPlayerInventory.sqf @@ -1,5 +1,5 @@ /* - Function: milsim_fnc_logPlayerInventory + Function: milsim_util_fnc_logPlayerInventory Description: Checks a player's inventory for non-compliant items and logs results to all machines. @@ -22,7 +22,7 @@ if (!isPlayer _player) exitWith { "logPlayerInventory", "PARAM PLAYER IS NOT A PLAYER", [["player", _player]] - ] call milsim_fnc_log; + ] call milsim_util_fnc_log; }; // testing @@ -55,8 +55,8 @@ _playerItems pushBack (uniform _player); [ "logPlayerInventory", "CHECKING PLAYER INVENTORY", - [_player] call milsim_fnc_addPlayerInfoToArray -] call milsim_fnc_log; + [_player] call milsim_util_fnc_addPlayerInfoToArray +] call milsim_util_fnc_log; //////////////////////////////////////// // HARDCODED DISALLOWED ITEMS - see functions/definitions/DisallowedEquipment.hpp @@ -117,8 +117,8 @@ if (count _allFoundItemsSoFar isEqualTo 0) exitWith { [ "logPlayerInventory", "PLAYER INVENTORY IS COMPLIANT", - [_player] call milsim_fnc_addPlayerInfoToArray - ] call milsim_fnc_log; + [_player] call milsim_util_fnc_addPlayerInfoToArray + ] call milsim_util_fnc_log; }; // Log all non-compliant items @@ -138,7 +138,7 @@ if (count _allFoundItemsSoFar isEqualTo 0) exitWith { ["category", _categoryLabel], ["className", _itemClassName], ["displayName", [_itemConfig] call BIS_fnc_displayName] - ]] call milsim_fnc_addPlayerInfoToArray - ] call milsim_fnc_log; + ]] call milsim_util_fnc_addPlayerInfoToArray + ] call milsim_util_fnc_log; } forEach _items; } forEach _foundItemsKeyValue; \ No newline at end of file diff --git a/functions/settings/fn_addAARChatHandler.sqf b/framework/settings/fn_addAARChatHandler.sqf similarity index 100% rename from functions/settings/fn_addAARChatHandler.sqf rename to framework/settings/fn_addAARChatHandler.sqf diff --git a/functions/settings/fn_addCBASettings.sqf b/framework/settings/fn_addCBASettings.sqf similarity index 97% rename from functions/settings/fn_addCBASettings.sqf rename to framework/settings/fn_addCBASettings.sqf index 703bab9..ce3a11a 100644 --- a/functions/settings/fn_addCBASettings.sqf +++ b/framework/settings/fn_addCBASettings.sqf @@ -146,7 +146,7 @@ ], ["newValue", _value] ] - ] call milsim_fnc_log; + ] call milsim_util_fnc_log; } ] call CBA_fnc_addSetting; @@ -169,7 +169,7 @@ ], ["newValue", _value] ] - ] call milsim_fnc_log; + ] call milsim_util_fnc_log; } ] call CBA_fnc_addSetting; @@ -192,7 +192,7 @@ ], ["newValue", _value] ] - ] call milsim_fnc_log; + ] call milsim_util_fnc_log; } ] call CBA_fnc_addSetting; @@ -215,7 +215,7 @@ ], ["newValue", _value] ] - ] call milsim_fnc_log; + ] call milsim_util_fnc_log; } ] call CBA_fnc_addSetting; @@ -238,7 +238,7 @@ ], ["newValue", _value] ] - ] call milsim_fnc_log; + ] call milsim_util_fnc_log; } ] call CBA_fnc_addSetting; @@ -264,7 +264,7 @@ ], ["newValue", _value] ] - ] call milsim_fnc_log; + ] call milsim_util_fnc_log; } ] call CBA_fnc_addSetting; diff --git a/functions/settings/fn_addRespawnChatHandler.sqf b/framework/settings/fn_addRespawnChatHandler.sqf similarity index 81% rename from functions/settings/fn_addRespawnChatHandler.sqf rename to framework/settings/fn_addRespawnChatHandler.sqf index fed6acb..9c9f8f6 100644 --- a/functions/settings/fn_addRespawnChatHandler.sqf +++ b/framework/settings/fn_addRespawnChatHandler.sqf @@ -8,8 +8,8 @@ [ "init", "CHAT COMMAND RESPAWN", - [player] call milsim_fnc_addPlayerInfoToArray - ] remoteExec ["milsim_fnc_log", 2]; + [player] call milsim_util_fnc_addPlayerInfoToArray + ] remoteExec ["milsim_util_fnc_log", 2]; // systemChat to all remote machines format["%1 claims they were glitched and respawned (%2)", name player, netID player] remoteExec["systemChat", -_clientID]; diff --git a/functions/settings/fn_setDefaults.sqf b/framework/settings/fn_setDefaults.sqf similarity index 100% rename from functions/settings/fn_setDefaults.sqf rename to framework/settings/fn_setDefaults.sqf diff --git a/functions/util/fn_addPlayerInfoToArray.sqf b/framework/util/fn_addPlayerInfoToArray.sqf similarity index 100% rename from functions/util/fn_addPlayerInfoToArray.sqf rename to framework/util/fn_addPlayerInfoToArray.sqf diff --git a/functions/util/fn_getBattalionCfg.sqf b/framework/util/fn_getBattalionCfg.sqf similarity index 100% rename from functions/util/fn_getBattalionCfg.sqf rename to framework/util/fn_getBattalionCfg.sqf diff --git a/functions/util/fn_getNameOfBase.sqf b/framework/util/fn_getNameOfBase.sqf similarity index 100% rename from functions/util/fn_getNameOfBase.sqf rename to framework/util/fn_getNameOfBase.sqf diff --git a/functions/util/fn_getNearestBase.sqf b/framework/util/fn_getNearestBase.sqf similarity index 100% rename from functions/util/fn_getNearestBase.sqf rename to framework/util/fn_getNearestBase.sqf diff --git a/functions/util/fn_log.sqf b/framework/util/fn_log.sqf similarity index 92% rename from functions/util/fn_log.sqf rename to framework/util/fn_log.sqf index d80dbc2..2df2574 100644 --- a/functions/util/fn_log.sqf +++ b/framework/util/fn_log.sqf @@ -1,5 +1,5 @@ /* - Function: milsim_fnc_log + Function: milsim_util_fnc_log Description: Used to log messages to the server RPT file. diff --git a/functions/util/fn_logMissionInfo.sqf b/framework/util/fn_logMissionInfo.sqf similarity index 97% rename from functions/util/fn_logMissionInfo.sqf rename to framework/util/fn_logMissionInfo.sqf index 6286476..d2c1364 100644 --- a/functions/util/fn_logMissionInfo.sqf +++ b/framework/util/fn_logMissionInfo.sqf @@ -20,4 +20,4 @@ ["LOGIC", playableSlotsNumber sideLogic] // 5 is LOGIC side ]] ] -] call milsim_fnc_log; \ No newline at end of file +] call milsim_util_fnc_log; \ No newline at end of file diff --git a/functions/util/fn_padString.sqf b/framework/util/fn_padString.sqf similarity index 100% rename from functions/util/fn_padString.sqf rename to framework/util/fn_padString.sqf diff --git a/functions/util/fn_recurseSubclasses.sqf b/framework/util/fn_recurseSubclasses.sqf similarity index 100% rename from functions/util/fn_recurseSubclasses.sqf rename to framework/util/fn_recurseSubclasses.sqf diff --git a/functions/vehicleFlags/fn_getActionsFlagCategories.sqf b/framework/vehicleFlags/functions/fn_getActionsFlagCategories.sqf similarity index 100% rename from functions/vehicleFlags/fn_getActionsFlagCategories.sqf rename to framework/vehicleFlags/functions/fn_getActionsFlagCategories.sqf diff --git a/functions/vehicleFlags/fn_getVehicleFlagsCfg.sqf b/framework/vehicleFlags/functions/fn_getVehicleFlagsCfg.sqf similarity index 100% rename from functions/vehicleFlags/fn_getVehicleFlagsCfg.sqf rename to framework/vehicleFlags/functions/fn_getVehicleFlagsCfg.sqf diff --git a/functions/vehicleFlags/fn_initVehicleFlags.sqf b/framework/vehicleFlags/functions/fn_init.sqf similarity index 93% rename from functions/vehicleFlags/fn_initVehicleFlags.sqf rename to framework/vehicleFlags/functions/fn_init.sqf index 32f2952..061b456 100644 --- a/functions/vehicleFlags/fn_initVehicleFlags.sqf +++ b/framework/vehicleFlags/functions/fn_init.sqf @@ -1,6 +1,8 @@ if (!hasInterface) exitWith {}; -private _vehicleFlagsCfg = call milsim_vehicleFlags_fnc_getVehicleFlagsCfg; +#include "..\script_component.hpp" + +private _vehicleFlagsCfg = call FUNC(getVehicleFlagsCfg); if (!isClass _vehicleFlagsCfg) exitWith { ["WARNING: Vehicle Flags: Vehicle Flags config not found. Vehicle Flags will not be available."] call BIS_fnc_error; @@ -34,7 +36,7 @@ private _flagCategoryCfgs = (_vehicleFlagsCfg >> "FlagCategories") call BIS_fnc_ // _params params ["_parentActionID", "_flagCategories"]; // check if vehicle is excluded - private _excluded = [typeOf _target] call milsim_vehicleFlags_fnc_isClassExcluded; + private _excluded = [typeOf _target] call FUNC(isClassExcluded); if (_excluded || !alive _target) exitWith {false}; true; @@ -47,7 +49,7 @@ private _flagCategoryCfgs = (_vehicleFlagsCfg >> "FlagCategories") call BIS_fnc_ _params params ["_rootActionID", "_flagCategoryCfgs"]; // return category child actions with individual flag actions nested as children - [_rootActionID, _flagCategoryCfgs] call milsim_vehicleFlags_fnc_getActionsFlagCategories; + [_rootActionID, _flagCategoryCfgs] call FUNC(getActionsFlagCategories); }, // child code [_rootActionID, _flagCategoryCfgs], // params diff --git a/functions/vehicleFlags/fn_isClassExcluded.sqf b/framework/vehicleFlags/functions/fn_isClassExcluded.sqf similarity index 100% rename from functions/vehicleFlags/fn_isClassExcluded.sqf rename to framework/vehicleFlags/functions/fn_isClassExcluded.sqf diff --git a/framework/vehicleFlags/script_component.hpp b/framework/vehicleFlags/script_component.hpp new file mode 100644 index 0000000..bba2e0d --- /dev/null +++ b/framework/vehicleFlags/script_component.hpp @@ -0,0 +1,3 @@ +#define COMPONENT vehicleFlags +#define COMPONENT_BEAUTIFIED Vehicle Flags +#include "../script_mod.hpp" \ No newline at end of file diff --git a/functions/init/fn_initPlayerLocal.sqf b/functions/init/fn_initPlayerLocal.sqf deleted file mode 100644 index 1ba5f10..0000000 --- a/functions/init/fn_initPlayerLocal.sqf +++ /dev/null @@ -1,25 +0,0 @@ -if ( !hasInterface ) exitWith {}; - -if (!isServer) then { - ["milsim_logText", { - params [["_strArray", [""], [[]]]]; - { - diag_log text _x; - } forEach _strArray; - }] call CBA_fnc_addEventHandler; -}; - -// 5 seconds after the client is loaded, add the resupply action to all arsenal boxes -[ - {time > 5}, - { - if (missionNamespace getVariable [ - "milsim_resupply_setting_allowSupplyBoxScrollWheelSpawning", - false - ]) then {call milsim_resupply_fnc_addSpawnBoxActions} - } -] call CBA_fnc_waitUntilAndExecute; - -["InitializePlayer", [player, true]] call BIS_fnc_dynamicGroups; - -nil; \ No newline at end of file diff --git a/functions/resupply/fn_addCBASettings.sqf b/functions/resupply/fn_addCBASettings.sqf deleted file mode 100644 index 47d700a..0000000 --- a/functions/resupply/fn_addCBASettings.sqf +++ /dev/null @@ -1,22 +0,0 @@ -[ - "milsim_resupply_setting_allowSupplyBoxScrollWheelSpawning", // variable - "CHECKBOX", // type - ["Enabled", "If true, adds scroll wheel options to arsenal boxes to spawn supply boxes"], // title - ["17th Battalion", "Resupply"], // category - false, // default value - true, // global setting - { - params ["_value"]; - [ - "resupply", - "SETTING CHANGED", - [ - [ - "setting", - "milsim_resupply_setting_allowSupplyBoxScrollWheelSpawning" - ], - ["newValue", _value] - ] - ] call milsim_fnc_log; - } -] call CBA_fnc_addSetting; \ No newline at end of file diff --git a/functions/resupply/fn_createAmmoBox.sqf b/functions/resupply/fn_createAmmoBox.sqf deleted file mode 100644 index 06da1f4..0000000 --- a/functions/resupply/fn_createAmmoBox.sqf +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Author: Hizumi - * - * Create Ammo resupply box for the 17th Battalion - * - * Arguments: - * 0: Vehicle - - * 1: Position - - * - * Return Value: - * Function executed - * - * Example: - * [box] call milsim_fnc_createAmmoBox; // create ammo box via init line of editor object - * [objNull, pos] call milsim_fnc_createAmmoBox; // create ammo box via zeus module - * - * Public: Yes - * - * Note: For gathering: - formatText ["%1", [ - ["containerClassname", typeOf cursorObject], - ["backpack", (backpackCargo cursorObject) call BIS_fnc_consolidateArray], - ["item", (itemCargo cursorObject) call BIS_fnc_consolidateArray], - ["magazine", (magazineCargo cursorObject) call BIS_fnc_consolidateArray], - ["magazineAmmo", magazinesAmmoCargo cursorObject], - ["weapon", (weaponCargo cursorObject) call BIS_fnc_consolidateArray] - ]]; - */ - - -params [ - ["_box", objNull, [objNull]], - ["_pos", [0,0,0], [[]], 3] -]; - -[_box, "AMMO LIGHT", _pos] call milsim_fnc_createBox; \ No newline at end of file diff --git a/functions/resupply/fn_createCSWBox.sqf b/functions/resupply/fn_createCSWBox.sqf deleted file mode 100644 index 180e21c..0000000 --- a/functions/resupply/fn_createCSWBox.sqf +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Author: Hizumi & IndigoFox - * - * Create Ammo resupply box for the 17th Battalion - * - * Arguments: - * 0: Vehicle - - * 1: Position - - * - * Return Value: - * Function executed - * - * Example: - * [box] call milsim_fnc_createCSWBox; // create ammo box via init line of editor object - * [objNull, pos] call milsim_fnc_createCSWBox; // create ammo box via zeus module - * - * Public: Yes - * - * Note: For gathering: - formatText ["%1", [ - ["containerClassname", typeOf cursorObject], - ["backpack", (backpackCargo cursorObject) call BIS_fnc_consolidateArray], - ["item", (itemCargo cursorObject) call BIS_fnc_consolidateArray], - ["magazine", (magazineCargo cursorObject) call BIS_fnc_consolidateArray], - ["magazineAmmo", magazinesAmmoCargo cursorObject], - ["weapon", (weaponCargo cursorObject) call BIS_fnc_consolidateArray] - ]]; - */ - - -params [ - ["_box", objNull, [objNull]], - ["_pos", [0,0,0], [[]], 3] -]; - -[_box, "CSW", _pos] call milsim_fnc_createBox; \ No newline at end of file diff --git a/functions/resupply/fn_createLaunchersBox.sqf b/functions/resupply/fn_createLaunchersBox.sqf deleted file mode 100644 index a702aa0..0000000 --- a/functions/resupply/fn_createLaunchersBox.sqf +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Author: Hizumi & IndigoFox - * - * Create Ammo resupply box for the 17th Battalion - * - * Arguments: - * 0: Vehicle - - * 1: Position - - * - * Return Value: - * Function executed - * - * Example: - * [box] call milsim_fnc_createLaunchersBox; // create ammo box via init line of editor object - * [objNull, pos] call milsim_fnc_createLaunchersBox; // create ammo box via zeus module - * - * Public: Yes - * - * Note: For gathering: - formatText ["%1", [ - ["containerClassname", typeOf cursorObject], - ["backpack", (backpackCargo cursorObject) call BIS_fnc_consolidateArray], - ["item", (itemCargo cursorObject) call BIS_fnc_consolidateArray], - ["magazine", (magazineCargo cursorObject) call BIS_fnc_consolidateArray], - ["magazineAmmo", magazinesAmmoCargo cursorObject], - ["weapon", (weaponCargo cursorObject) call BIS_fnc_consolidateArray] - ]]; - */ - - -params [ - ["_box", objNull, [objNull]], - ["_pos", [0,0,0], [[]], 3] -]; - -[_box, "LAUNCHERS", _pos] call milsim_fnc_createBox; \ No newline at end of file diff --git a/functions/resupply/fn_createMedicalBox.sqf b/functions/resupply/fn_createMedicalBox.sqf deleted file mode 100644 index 0b0b0a0..0000000 --- a/functions/resupply/fn_createMedicalBox.sqf +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Author: Hizumi - * - * Create Ammo resupply box for the 17th Battalion - * - * Arguments: - * 0: Vehicle - - * 1: Position - - * - * Return Value: - * Function executed - * - * Example: - * [box] call milsim_fnc_createMedicalBox; // create ammo box via init line of editor object - * [objNull, pos] call milsim_fnc_createMedicalBox // create ammo box via zeus module - * - * Public: Yes - */ - - -params [ - ["_box", objNull, [objNull]], - ["_pos", [0,0,0], [[]], 3] -]; - -[_box, "MEDICAL", _pos] call milsim_fnc_createBox; \ No newline at end of file diff --git a/functions/resupply/fn_createMortarBox.sqf b/functions/resupply/fn_createMortarBox.sqf deleted file mode 100644 index 8d63374..0000000 --- a/functions/resupply/fn_createMortarBox.sqf +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Author: Hizumi & IndigoFox - * - * Create Mortar resupply box for the 17th Battalion - * - * Arguments: - * 0: Vehicle - - * 1: Position - - * - * Return Value: - * Function executed - * - * Example: - * [box] call milsim_fnc_createMortarBox; // create mortar ammo box via init line of editor object - * [objNull, pos] call milsim_fnc_createMortarBox; // create mortar ammo box via zeus module - * - * Public: Yes - * - * Note: For gathering: - formatText ["%1", [ - ["containerClassname", typeOf cursorObject], - ["backpack", (backpackCargo cursorObject) call BIS_fnc_consolidateArray], - ["item", (itemCargo cursorObject) call BIS_fnc_consolidateArray], - ["magazine", (magazineCargo cursorObject) call BIS_fnc_consolidateArray], - ["magazineAmmo", magazinesAmmoCargo cursorObject], - ["weapon", (weaponCargo cursorObject) call BIS_fnc_consolidateArray] - ]]; - */ - - -params [ - ["_box", objNull, [objNull]], - ["_pos", [0,0,0], [[]], 3] -]; - -[_box, "AMMO MORTAR", _pos] call milsim_fnc_createBox; \ No newline at end of file diff --git a/functions/resupply/fn_createWeaponsBox.sqf b/functions/resupply/fn_createWeaponsBox.sqf deleted file mode 100644 index 5907845..0000000 --- a/functions/resupply/fn_createWeaponsBox.sqf +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Author: Hizumi - * - * Create Ammo resupply box for the 17th Battalion - * - * Arguments: - * 0: Vehicle - - * 1: Position - - * - * Return Value: - * Function executed - * - * Example: - * [box] call milsim_fnc_createWeaponsBox; // create ammo box via init line of editor object - * [objNull, pos] call milsim_fnc_createWeaponsBox; // create ammo box via zeus module - * - * Public: Yes - * - * Note: For gathering: - formatText ["%1", [ - ["containerClassname", typeOf cursorObject], - ["backpack", (backpackCargo cursorObject) call BIS_fnc_consolidateArray], - ["item", (itemCargo cursorObject) call BIS_fnc_consolidateArray], - ["magazine", (magazineCargo cursorObject) call BIS_fnc_consolidateArray], - ["magazineAmmo", magazinesAmmoCargo cursorObject], - ["weapon", (weaponCargo cursorObject) call BIS_fnc_consolidateArray] - ]]; - */ - - -params [ - ["_box", objNull, [objNull]], - ["_pos", [0,0,0], [[]], 3] -]; - -[_box, "AMMO HEAVY", _pos] call milsim_fnc_createBox; \ No newline at end of file diff --git a/functions/resupply/fn_getSupplyCratesCfg.sqf b/functions/resupply/fn_getSupplyCratesCfg.sqf deleted file mode 100644 index 2bf1a5f..0000000 --- a/functions/resupply/fn_getSupplyCratesCfg.sqf +++ /dev/null @@ -1 +0,0 @@ -(missionConfigFile >> "SupplyCrates"); \ No newline at end of file -- 2.37.3.windows.1 From f450f4611b0175f742abaed3e46acc3215ba688f Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Sun, 4 Feb 2024 22:18:06 -0800 Subject: [PATCH 11/16] wip, fbcb2_assets, init, util --- framework/CfgFunctions.hpp | 27 +- .../functions/fn_addCBASettings.sqf | 27 + .../functions}/fn_getAssetsByBase.sqf | 0 .../functions}/fn_getInventory.sqf | 0 .../functions}/fn_getMagsForWeapon.sqf | 0 .../functions}/fn_getStartingAssetsByBase.sqf | 0 .../functions}/fn_getVehicleData.sqf | 0 .../functions}/fn_getWeaponry.sqf | 0 .../fbcb2_assets/functions/fn_initClient.sqf | 9 + .../fbcb2_assets/functions/fn_initServer.sqf | 23 + .../functions}/fn_removeAssetDiaryRecords.sqf | 0 .../functions}/fn_removeMarkersOnMap.sqf | 0 .../functions}/fn_showMarkersOnMap.sqf | 0 .../functions}/fn_updateAssetDiary.sqf | 29 +- .../functions}/fn_updateAssetsByBase.sqf | 16 +- framework/fbcb2_assets/script_component.hpp | 3 + framework/init/fn_initServer.sqf | 35 - .../{ => functions}/fn_initPlayerLocal.sqf | 0 framework/init/functions/fn_initServer.sqf | 26 + framework/init/script_component.hpp | 3 + framework/settings/fn_addCBASettings.sqf | 26 - .../fn_addPlayerInfoToArray.sqf | 2 + .../{ => functions}/fn_getBattalionCfg.sqf | 0 .../util/{ => functions}/fn_getNameOfBase.sqf | 2 + .../{ => functions}/fn_getNearestBase.sqf | 2 + framework/util/{ => functions}/fn_log.sqf | 3 +- .../{ => functions}/fn_logMissionInfo.sqf | 6 +- .../util/{ => functions}/fn_padString.sqf | 2 + .../{ => functions}/fn_recurseSubclasses.sqf | 2 + framework/util/script_component.hpp | 3 + .../cba/addons/main/script_macros_common.hpp | 1835 +++++++++++++++++ .../cba/addons/main/script_macros_mission.hpp | 85 + 32 files changed, 2066 insertions(+), 100 deletions(-) create mode 100644 framework/fbcb2_assets/functions/fn_addCBASettings.sqf rename framework/{fbcb2/assets/byBase => fbcb2_assets/functions}/fn_getAssetsByBase.sqf (100%) rename framework/{fbcb2/assets => fbcb2_assets/functions}/fn_getInventory.sqf (100%) rename framework/{fbcb2/assets => fbcb2_assets/functions}/fn_getMagsForWeapon.sqf (100%) rename framework/{fbcb2/assets/byBase => fbcb2_assets/functions}/fn_getStartingAssetsByBase.sqf (100%) rename framework/{fbcb2/assets => fbcb2_assets/functions}/fn_getVehicleData.sqf (100%) rename framework/{fbcb2/assets => fbcb2_assets/functions}/fn_getWeaponry.sqf (100%) create mode 100644 framework/fbcb2_assets/functions/fn_initClient.sqf create mode 100644 framework/fbcb2_assets/functions/fn_initServer.sqf rename framework/{fbcb2/assets => fbcb2_assets/functions}/fn_removeAssetDiaryRecords.sqf (100%) rename framework/{fbcb2/assets/markers => fbcb2_assets/functions}/fn_removeMarkersOnMap.sqf (100%) rename framework/{fbcb2/assets/markers => fbcb2_assets/functions}/fn_showMarkersOnMap.sqf (100%) rename framework/{fbcb2/assets => fbcb2_assets/functions}/fn_updateAssetDiary.sqf (81%) rename framework/{fbcb2/assets/byBase => fbcb2_assets/functions}/fn_updateAssetsByBase.sqf (89%) create mode 100644 framework/fbcb2_assets/script_component.hpp delete mode 100644 framework/init/fn_initServer.sqf rename framework/init/{ => functions}/fn_initPlayerLocal.sqf (100%) create mode 100644 framework/init/functions/fn_initServer.sqf create mode 100644 framework/init/script_component.hpp rename framework/util/{ => functions}/fn_addPlayerInfoToArray.sqf (88%) rename framework/util/{ => functions}/fn_getBattalionCfg.sqf (100%) rename framework/util/{ => functions}/fn_getNameOfBase.sqf (89%) rename framework/util/{ => functions}/fn_getNearestBase.sqf (87%) rename framework/util/{ => functions}/fn_log.sqf (76%) rename framework/util/{ => functions}/fn_logMissionInfo.sqf (92%) rename framework/util/{ => functions}/fn_padString.sqf (92%) rename framework/util/{ => functions}/fn_recurseSubclasses.sqf (93%) create mode 100644 framework/util/script_component.hpp create mode 100644 framework/x/cba/addons/main/script_macros_common.hpp create mode 100644 framework/x/cba/addons/main/script_macros_mission.hpp diff --git a/framework/CfgFunctions.hpp b/framework/CfgFunctions.hpp index d19b024..76ade6b 100644 --- a/framework/CfgFunctions.hpp +++ b/framework/CfgFunctions.hpp @@ -1,4 +1,6 @@ -class milsim +#include "script_mod.hpp" + +class PREFIX { class settings { @@ -11,7 +13,7 @@ class milsim class init { - file = "framework\init"; + file = "framework\init\functions"; class initServer { postInit = 1;}; //needs refactor class initPlayerLocal { postInit = 1;}; }; @@ -71,9 +73,9 @@ class milsim }; }; -class milsim_util { +class DOUBLES(PREFIX,util) { class functions { - file = "framework\util"; + file = "framework\util\functions"; class logMissionInfo { postInit = 1; }; class addPlayerInfoToArray {}; class log {}; @@ -85,7 +87,7 @@ class milsim_util { }; }; -class milsim_resupply { +class DOUBLES(PREFIX,resupply) { class functions { file = "framework\resupply\functions"; class init {postInit=1;}; @@ -96,30 +98,25 @@ class milsim_resupply { }; }; -class milsim_fbcb2_assets { +class DOUBLES(PREFIX,fbcb2_assets) { class functions { - file = "framework\fbcb2\assets"; + file = "framework\fbcb2_assets\functions"; + class init {postInit=1;}; class updateAssetDiary {}; class removeAssetDiaryRecords {}; class getMagsForWeapon {}; class getWeaponry {}; class getInventory {}; class getVehicleData {}; - }; - class assetsByBase { - file = "framework\fbcb2\assets\byBase"; class getAssetsByBase {}; class getStartingAssetsByBase {}; class updateAssetsByBase {}; - }; - class markers { - file = "framework\fbcb2\assets\markers"; class showMarkersOnMap {}; class removeMarkersOnMap {}; }; }; -class milsim_vehicleFlags { +class DOUBLES(PREFIX,vehicleFlags) { class functions { file = "framework\vehicleFlags\functions"; class init {postInit=1;}; @@ -129,7 +126,7 @@ class milsim_vehicleFlags { }; }; -class milsim_reinsert { +class DOUBLES(PREFIX,reinsert) { class server { file = "framework\reinsert\server"; class initServer { postInit = 1; }; diff --git a/framework/fbcb2_assets/functions/fn_addCBASettings.sqf b/framework/fbcb2_assets/functions/fn_addCBASettings.sqf new file mode 100644 index 0000000..5964caf --- /dev/null +++ b/framework/fbcb2_assets/functions/fn_addCBASettings.sqf @@ -0,0 +1,27 @@ +#include "..\script_component.hpp" + +//--------------------- +// Asset Diary and Markers Settings + +[ + QGVAR(setting_detectionRangeFromBase), // variable + "SLIDER", // type + ["Detection Range From Base", "The range from a base that assets will be detected"], // title + [QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)], // category + [0, 1000, 750, 0, false], // [_min, _max, _default, _trailingDecimals, _isPercentage] + true, // global setting + { + params ["_value"]; + [ + "fbcb2_assets", + "SETTING CHANGED", + [ + [ + "setting", + "milsim_fbcb2_assets_setting_detectionRangeFromBase" + ], + ["newValue", _value] + ] + ] call milsim_util_fnc_log; + } +] call CBA_fnc_addSetting; \ No newline at end of file diff --git a/framework/fbcb2/assets/byBase/fn_getAssetsByBase.sqf b/framework/fbcb2_assets/functions/fn_getAssetsByBase.sqf similarity index 100% rename from framework/fbcb2/assets/byBase/fn_getAssetsByBase.sqf rename to framework/fbcb2_assets/functions/fn_getAssetsByBase.sqf diff --git a/framework/fbcb2/assets/fn_getInventory.sqf b/framework/fbcb2_assets/functions/fn_getInventory.sqf similarity index 100% rename from framework/fbcb2/assets/fn_getInventory.sqf rename to framework/fbcb2_assets/functions/fn_getInventory.sqf diff --git a/framework/fbcb2/assets/fn_getMagsForWeapon.sqf b/framework/fbcb2_assets/functions/fn_getMagsForWeapon.sqf similarity index 100% rename from framework/fbcb2/assets/fn_getMagsForWeapon.sqf rename to framework/fbcb2_assets/functions/fn_getMagsForWeapon.sqf diff --git a/framework/fbcb2/assets/byBase/fn_getStartingAssetsByBase.sqf b/framework/fbcb2_assets/functions/fn_getStartingAssetsByBase.sqf similarity index 100% rename from framework/fbcb2/assets/byBase/fn_getStartingAssetsByBase.sqf rename to framework/fbcb2_assets/functions/fn_getStartingAssetsByBase.sqf diff --git a/framework/fbcb2/assets/fn_getVehicleData.sqf b/framework/fbcb2_assets/functions/fn_getVehicleData.sqf similarity index 100% rename from framework/fbcb2/assets/fn_getVehicleData.sqf rename to framework/fbcb2_assets/functions/fn_getVehicleData.sqf diff --git a/framework/fbcb2/assets/fn_getWeaponry.sqf b/framework/fbcb2_assets/functions/fn_getWeaponry.sqf similarity index 100% rename from framework/fbcb2/assets/fn_getWeaponry.sqf rename to framework/fbcb2_assets/functions/fn_getWeaponry.sqf diff --git a/framework/fbcb2_assets/functions/fn_initClient.sqf b/framework/fbcb2_assets/functions/fn_initClient.sqf new file mode 100644 index 0000000..28f1103 --- /dev/null +++ b/framework/fbcb2_assets/functions/fn_initClient.sqf @@ -0,0 +1,9 @@ +#include "..\script_component.hpp" + +if (!hasInterface) exitWith {}; + +// once the server has published that assets have been gathered and distributed to bases (respawn modules), +// we can update the asset diary on our end using that data +[{missionNamespace getVariable [QGVAR(serverAssetsReady), false]}, { + call FUNC(updateAssetDiary); +}] call CBA_fnc_waitUntilAndExecute; diff --git a/framework/fbcb2_assets/functions/fn_initServer.sqf b/framework/fbcb2_assets/functions/fn_initServer.sqf new file mode 100644 index 0000000..70acbed --- /dev/null +++ b/framework/fbcb2_assets/functions/fn_initServer.sqf @@ -0,0 +1,23 @@ +#include "..\script_component.hpp" + +if (!isServer) exitWith {}; + +// init asset stores at bases +[true] call FUNC(updateAssetsByBase); + +missionNamespace setVariable [QGVAR(serverAssetsReady), true, true]; + +// starting 5 minutes after postInit, update asset stores every 5 minutes +[{ + [ + {[false] call FUNC(updateAssetsByBase);}, + 60*5 + ] call CBA_fnc_addPerFrameHandler; +}, 60*5] call CBA_fnc_waitAndExecute; + + +// add end mission EH +addMissionEventHandler ["MPEnded", { + // log the "current" asset counts to RPT + [false, true] call FUNC(updateAssetsByBase); +}]; \ No newline at end of file diff --git a/framework/fbcb2/assets/fn_removeAssetDiaryRecords.sqf b/framework/fbcb2_assets/functions/fn_removeAssetDiaryRecords.sqf similarity index 100% rename from framework/fbcb2/assets/fn_removeAssetDiaryRecords.sqf rename to framework/fbcb2_assets/functions/fn_removeAssetDiaryRecords.sqf diff --git a/framework/fbcb2/assets/markers/fn_removeMarkersOnMap.sqf b/framework/fbcb2_assets/functions/fn_removeMarkersOnMap.sqf similarity index 100% rename from framework/fbcb2/assets/markers/fn_removeMarkersOnMap.sqf rename to framework/fbcb2_assets/functions/fn_removeMarkersOnMap.sqf diff --git a/framework/fbcb2/assets/markers/fn_showMarkersOnMap.sqf b/framework/fbcb2_assets/functions/fn_showMarkersOnMap.sqf similarity index 100% rename from framework/fbcb2/assets/markers/fn_showMarkersOnMap.sqf rename to framework/fbcb2_assets/functions/fn_showMarkersOnMap.sqf diff --git a/framework/fbcb2/assets/fn_updateAssetDiary.sqf b/framework/fbcb2_assets/functions/fn_updateAssetDiary.sqf similarity index 81% rename from framework/fbcb2/assets/fn_updateAssetDiary.sqf rename to framework/fbcb2_assets/functions/fn_updateAssetDiary.sqf index 0f87ef2..c96fab8 100644 --- a/framework/fbcb2/assets/fn_updateAssetDiary.sqf +++ b/framework/fbcb2_assets/functions/fn_updateAssetDiary.sqf @@ -1,16 +1,17 @@ +#include "..\script_component.hpp" + if (!hasInterface) exitWith {}; // create diary records - // remove any existing asset map markers -call milsim_fbcb2_assets_fnc_removeMarkersOnMap; +call FUNC(removeMarkersOnMap); // remove existing asset records -call milsim_fbcb2_assets_fnc_removeAssetDiaryRecords; +call FUNC(removeAssetDiaryRecords); // get all vehicles by base -private _vehiclesByBase = call milsim_fbcb2_assets_fnc_getAssetsByBase; +private _vehiclesByBase = call FUNC(getAssetsByBase); if (count _vehiclesByBase isEqualTo 0) exitWith {false}; // put vehicles from each base into a single array @@ -38,7 +39,7 @@ private _distinctVehiclesClassNames = []; private _vehicleCfg = configOf _representativeVehicle; private _vehicleCallsign = toUpper ( _representativeVehicle getVariable [ - "milsim_fbcb2_assets_callsign", + QGVAR(callsign), "NONE ASSIGNED" ] ); @@ -51,7 +52,7 @@ private _distinctVehiclesClassNames = []; ) then {continue}; // Get the vehicle data - private _processed = [_representativeVehicle] call milsim_fbcb2_assets_fnc_getVehicleData; + private _processed = [_representativeVehicle] call FUNC(getVehicleData); if (isNil "_processed") then {continue}; _processed params ["_vehicleCfg", "_displayName", "_diaryTextSections"]; @@ -113,7 +114,7 @@ private _distinctVehiclesClassNames = []; // Link to show markers private _showMarkersText = format[ - "SHOW MARKERS at vehicle positions (in %5)", + "SHOW MARKERS at vehicle positions (in %5)", _className, _markerType, _randomColor#0, @@ -125,10 +126,10 @@ private _distinctVehiclesClassNames = []; _recordText pushBack _showMarkersText; // Link to hide markers - _recordText pushBack "REMOVE ALL MARKERS showing asset positions"; + _recordText pushBack "REMOVE ALL MARKERS showing asset positions"; // Link to update asset diary entries - _recordText pushBack "UPDATE ENTRIES for all assets"; + _recordText pushBack "UPDATE ENTRIES for all assets"; _recordText pushBack format[ "%1", @@ -148,13 +149,13 @@ private _distinctVehiclesClassNames = []; private _subjectID = ""; switch (true) do { case (_representativeVehicle isKindOf "Helicopter"): { - _subjectID = milsim_fbcb2_subjectAssetsRotaryID; + _subjectID = EGVAR(fbcb2,subjectAssetsRotaryID); }; case (_representativeVehicle isKindOf "Air"): { - _subjectID = milsim_fbcb2_subjectAssetsFixedWingID; + _subjectID = EGVAR(fbcb2,subjectAssetsFixedWingID); }; default { - _subjectID = milsim_fbcb2_subjectAssetsGroundID; + _subjectID = EGVAR(fbcb2,subjectAssetsGroundID); }; }; @@ -174,12 +175,12 @@ private _distinctVehiclesClassNames = []; // log to RPT [ - "fbcb2_assets", + QUOTE(COMPONENT), "UPDATED ASSET DIARY", [ ["assetCount", count _vehicles], ["distinctAssetCount", count _distinctVehiclesClassNames] ] -] call milsim_util_fnc_log; +] call EFUNC(util,log); true; \ No newline at end of file diff --git a/framework/fbcb2/assets/byBase/fn_updateAssetsByBase.sqf b/framework/fbcb2_assets/functions/fn_updateAssetsByBase.sqf similarity index 89% rename from framework/fbcb2/assets/byBase/fn_updateAssetsByBase.sqf rename to framework/fbcb2_assets/functions/fn_updateAssetsByBase.sqf index d5f5ffb..23fdef5 100644 --- a/framework/fbcb2/assets/byBase/fn_updateAssetsByBase.sqf +++ b/framework/fbcb2_assets/functions/fn_updateAssetsByBase.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + params [ ["_isInit", false, [false]], ["_logCurrentAssets", false, [false]] @@ -12,8 +14,8 @@ if (!isServer) exitWith {}; private _allVehicles = vehicles; private _allSaved = []; -private _assetsAtThisBaseVar = "milsim_fbcb2_assets_assetsAtThisBase"; -private _assetsStartedAtThisBaseVar = "milsim_fbcb2_assets_assetsStartedAtThisBase"; +private _assetsAtThisBaseVar = QGVAR(assetsAtThisBase); +private _assetsStartedAtThisBaseVar = QGVAR(assetsStartedAtThisBase); { private _className = configName _x; @@ -23,7 +25,7 @@ private _assetsStartedAtThisBaseVar = "milsim_fbcb2_assets_assetsStartedAtThisBa private _asset = _x; // avoid duplicates if (_asset in _allSaved) then {continue}; - private _closestBase = [_asset] call milsim_util_fnc_getNearestBase; + private _closestBase = [_asset] call EFUNC(util,getNearestBase); if (isNull _closestBase) then { // no base found continue; @@ -36,7 +38,7 @@ private _assetsStartedAtThisBaseVar = "milsim_fbcb2_assets_assetsStartedAtThisBa continue; }; - _asset setVariable ["milsim_fbcb2_assets_callsign", _callsign, true]; + _asset setVariable [QGVAR(callsign), _callsign, true]; // add to base's assets list private _baseAssets = _closestBase getVariable [_assetsAtThisBaseVar, []]; @@ -66,7 +68,7 @@ private _assetsStartedAtThisBaseVar = "milsim_fbcb2_assets_assetsStartedAtThisBa // avoid duplicates if (_asset in _allSaved) then {continue}; - private _closestBase = [_asset] call milsim_util_fnc_getNearestBase; + private _closestBase = [_asset] call EFUNC(util,getNearestBase); if (isNull _closestBase) then { // no base found continue; @@ -74,7 +76,7 @@ private _assetsStartedAtThisBaseVar = "milsim_fbcb2_assets_assetsStartedAtThisBa if ( _asset distance _closestBase > - milsim_fbcb2_assets_setting_detectionRangeFromBase + GVAR(setting_detectionRangeFromBase) ) then { // not within range continue; @@ -132,7 +134,7 @@ if !(_isInit || _logCurrentAssets) exitWith {}; private _asset = _x; [ ["callsign", _asset getVariable [ - "milsim_fbcb2_assets_callsign", + QGVAR(callsign), "N/A" ]], ["className", typeOf _asset], diff --git a/framework/fbcb2_assets/script_component.hpp b/framework/fbcb2_assets/script_component.hpp new file mode 100644 index 0000000..c5a24ae --- /dev/null +++ b/framework/fbcb2_assets/script_component.hpp @@ -0,0 +1,3 @@ +#define COMPONENT fbcb2_assets +#define COMPONENT_BEAUTIFIED FBCB2 - Assets +#include "../script_mod.hpp" \ No newline at end of file diff --git a/framework/init/fn_initServer.sqf b/framework/init/fn_initServer.sqf deleted file mode 100644 index d70c518..0000000 --- a/framework/init/fn_initServer.sqf +++ /dev/null @@ -1,35 +0,0 @@ -if (!isServer) exitWith {}; - -milsim_baseObjects = allMissionObjects "ModuleRespawnPosition_F"; -publicVariable "milsim_baseObjects"; - -// init asset stores at bases -[true] call milsim_fbcb2_assets_fnc_updateAssetsByBase; -// starting 5 minutes after postInit, update asset stores every 5 minutes -[{ - [ - {[false] call milsim_fbcb2_assets_fnc_updateAssetsByBase;}, - 60*5 - ] call CBA_fnc_addPerFrameHandler; -}, 60*5] call CBA_fnc_waitAndExecute; - -// add end mission EH -addMissionEventHandler ["MPEnded", { - // log the "current" asset counts to RPT - [false, true] call milsim_fbcb2_assets_fnc_updateAssetsByBase; -}]; - -// Initializes the Dynamic Groups framework and groups -["Initialize", [true]] call BIS_fnc_dynamicGroups; - -["milsim_logText", { - params [["_strArray", [""], [[]]]]; - { - diag_log text _x; - } forEach _strArray; -}] call CBA_fnc_addEventHandler; - -missionNamespace setVariable ["milsim_complete", true]; -diag_log text "[MILSIM] (initServer) milsim_complete: version 2.3"; - -publicVariable "milsim_complete"; diff --git a/framework/init/fn_initPlayerLocal.sqf b/framework/init/functions/fn_initPlayerLocal.sqf similarity index 100% rename from framework/init/fn_initPlayerLocal.sqf rename to framework/init/functions/fn_initPlayerLocal.sqf diff --git a/framework/init/functions/fn_initServer.sqf b/framework/init/functions/fn_initServer.sqf new file mode 100644 index 0000000..5ad0adf --- /dev/null +++ b/framework/init/functions/fn_initServer.sqf @@ -0,0 +1,26 @@ +#include "..\script_component.hpp" + +if (!isServer) exitWith {}; + +milsim_baseObjects = allMissionObjects "ModuleRespawnPosition_F"; +publicVariable "milsim_baseObjects"; + +// Initializes the Dynamic Groups framework and groups +["Initialize", [true]] call BIS_fnc_dynamicGroups; + +["milsim_logText", { + params [["_strArray", [""], [[]]]]; + { + diag_log text _x; + } forEach _strArray; +}] call CBA_fnc_addEventHandler; + +missionNamespace setVariable [QGVARMAIN(complete), true]; + +[ + QUOTE(COMPONENT), + format["%1: version %2", QGVARMAIN(complete), QUOTE(VERSION_STR)], + [["version", QUOTE(VERSION_STR)]] +] call EFUNC(util,log); + +publicVariable "milsim_complete"; diff --git a/framework/init/script_component.hpp b/framework/init/script_component.hpp new file mode 100644 index 0000000..fedab82 --- /dev/null +++ b/framework/init/script_component.hpp @@ -0,0 +1,3 @@ +#define COMPONENT init +#define COMPONENT_BEAUTIFIED Init +#include "../script_mod.hpp" \ No newline at end of file diff --git a/framework/settings/fn_addCBASettings.sqf b/framework/settings/fn_addCBASettings.sqf index ce3a11a..6e4a56e 100644 --- a/framework/settings/fn_addCBASettings.sqf +++ b/framework/settings/fn_addCBASettings.sqf @@ -242,32 +242,6 @@ } ] call CBA_fnc_addSetting; -//--------------------- -// Asset Diary and Markers Settings - -[ - "milsim_fbcb2_assets_setting_detectionRangeFromBase", // variable - "SLIDER", // type - ["Detection Range From Base", "The range from a base that assets will be detected"], // title - ["17th Battalion", "Asset Diary and Markers"], // category - [0, 1000, 750, 0, false], // [_min, _max, _default, _trailingDecimals, _isPercentage] - true, // global setting - { - params ["_value"]; - [ - "fbcb2_assets", - "SETTING CHANGED", - [ - [ - "setting", - "milsim_fbcb2_assets_setting_detectionRangeFromBase" - ], - ["newValue", _value] - ] - ] call milsim_util_fnc_log; - } -] call CBA_fnc_addSetting; - diag_log text "[MILSIM] (settings) Custom CBA settings initialized"; nil; \ No newline at end of file diff --git a/framework/util/fn_addPlayerInfoToArray.sqf b/framework/util/functions/fn_addPlayerInfoToArray.sqf similarity index 88% rename from framework/util/fn_addPlayerInfoToArray.sqf rename to framework/util/functions/fn_addPlayerInfoToArray.sqf index 4a473df..3035094 100644 --- a/framework/util/fn_addPlayerInfoToArray.sqf +++ b/framework/util/functions/fn_addPlayerInfoToArray.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + params [["_playerObj", objNull], ["_arrayToModify", [], [[]]]]; if (isNull _playerObj) exitWith {_arrayToModify}; diff --git a/framework/util/fn_getBattalionCfg.sqf b/framework/util/functions/fn_getBattalionCfg.sqf similarity index 100% rename from framework/util/fn_getBattalionCfg.sqf rename to framework/util/functions/fn_getBattalionCfg.sqf diff --git a/framework/util/fn_getNameOfBase.sqf b/framework/util/functions/fn_getNameOfBase.sqf similarity index 89% rename from framework/util/fn_getNameOfBase.sqf rename to framework/util/functions/fn_getNameOfBase.sqf index 81ed4ec..c0d56e8 100644 --- a/framework/util/fn_getNameOfBase.sqf +++ b/framework/util/functions/fn_getNameOfBase.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + params [["_base", objNull, [objNull]]]; if (_base == objNull) exitWith {""}; diff --git a/framework/util/fn_getNearestBase.sqf b/framework/util/functions/fn_getNearestBase.sqf similarity index 87% rename from framework/util/fn_getNearestBase.sqf rename to framework/util/functions/fn_getNearestBase.sqf index 68b103c..4dfc208 100644 --- a/framework/util/fn_getNearestBase.sqf +++ b/framework/util/functions/fn_getNearestBase.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + params [["_object", objNull, [objNull]]]; if (isNull _object) exitWith {objNull}; diff --git a/framework/util/fn_log.sqf b/framework/util/functions/fn_log.sqf similarity index 76% rename from framework/util/fn_log.sqf rename to framework/util/functions/fn_log.sqf index 2df2574..80639e0 100644 --- a/framework/util/fn_log.sqf +++ b/framework/util/functions/fn_log.sqf @@ -9,6 +9,7 @@ 1: STRING - message to log. 2: ARRAY - Key value pairs of data to log. */ +#include "..\script_component.hpp" params [ ["_component", "", [""]], @@ -23,6 +24,6 @@ _message regexReplace ["\[", "("]; _message regexReplace ["\]", ")"]; private _json = [_hash] call CBA_fnc_encodeJSON; -_log = format ["[milsim] [%1] [%2] [%3] :: %4", _component, _fnc_scriptNameParent, _message, _json]; +_log = format ["[%1] [%2] [%3] [%4] :: %5", QUOTE(PREFIX), _component, _fnc_scriptNameParent, _message, _json]; diag_log text _log; \ No newline at end of file diff --git a/framework/util/fn_logMissionInfo.sqf b/framework/util/functions/fn_logMissionInfo.sqf similarity index 92% rename from framework/util/fn_logMissionInfo.sqf rename to framework/util/functions/fn_logMissionInfo.sqf index d2c1364..1da141c 100644 --- a/framework/util/fn_logMissionInfo.sqf +++ b/framework/util/functions/fn_logMissionInfo.sqf @@ -1,5 +1,7 @@ +#include "..\script_component.hpp" + [ - "init", + QUOTE(COMPONENT), "MISSION INFO", [ ["serverName", serverName], @@ -20,4 +22,4 @@ ["LOGIC", playableSlotsNumber sideLogic] // 5 is LOGIC side ]] ] -] call milsim_util_fnc_log; \ No newline at end of file +] call FUNC(log); \ No newline at end of file diff --git a/framework/util/fn_padString.sqf b/framework/util/functions/fn_padString.sqf similarity index 92% rename from framework/util/fn_padString.sqf rename to framework/util/functions/fn_padString.sqf index e5d3faf..f387ca5 100644 --- a/framework/util/fn_padString.sqf +++ b/framework/util/functions/fn_padString.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + params [ ["_text", "", [""]], ["_padSide", "left", ["left", "right"]], diff --git a/framework/util/fn_recurseSubclasses.sqf b/framework/util/functions/fn_recurseSubclasses.sqf similarity index 93% rename from framework/util/fn_recurseSubclasses.sqf rename to framework/util/functions/fn_recurseSubclasses.sqf index b4ba431..73cf984 100644 --- a/framework/util/fn_recurseSubclasses.sqf +++ b/framework/util/functions/fn_recurseSubclasses.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + params [ ["_cfg", configNull, [configNull]], ["_code", {}, [{}]] diff --git a/framework/util/script_component.hpp b/framework/util/script_component.hpp new file mode 100644 index 0000000..36f9a27 --- /dev/null +++ b/framework/util/script_component.hpp @@ -0,0 +1,3 @@ +#define COMPONENT util +#define COMPONENT_BEAUTIFIED Utilities +#include "../script_mod.hpp" \ No newline at end of file diff --git a/framework/x/cba/addons/main/script_macros_common.hpp b/framework/x/cba/addons/main/script_macros_common.hpp new file mode 100644 index 0000000..c2e5d56 --- /dev/null +++ b/framework/x/cba/addons/main/script_macros_common.hpp @@ -0,0 +1,1835 @@ +/* + Header: script_macros_common.hpp + + Description: + A general set of useful macro functions for use by CBA itself or by any module that uses CBA. + + Authors: + Sickboy and Spooner +*/ + +/* **************************************************** + New - Should be exported to general addon + Aim: + - Simplify (shorten) the amount of characters required for repetitive tasks + - Provide a solid structure that can be dynamic and easy editable (Which sometimes means we cannot adhere to Aim #1 ;-) + An example is the path that is built from defines. Some available in this file, others in mods and addons. + + Follows Standard: + Object variables: PREFIX_COMPONENT + Main-object variables: PREFIX_main + Paths: MAINPREFIX\PREFIX\SUBPREFIX\COMPONENT\SCRIPTNAME.sqf + e.g: x\six\addons\sys_menu\fDate.sqf + + Usage: + define PREFIX and COMPONENT, then include this file + (Note, you could have a main addon for your mod, define the PREFIX in a macros.hpp, + and include this script_macros_common.hpp file. + Then in your addons, add a component.hpp, define the COMPONENT, + and include your mod's script_macros.hpp + In your scripts you can then include the addon's component.hpp with relative path) + + use in subcomponents (subconfigs) + define SUBCOMPONENT and include parent component's script_component.hpp + currently only supported by SUBADDON, additional macros may be added in the future + + TODO: + - Try only to use 1 string type " vs ' + - Evaluate double functions, and simplification + - Evaluate naming scheme; current = prototype + - Evaluate "Debug" features.. + - Evaluate "create mini function per precompiled script, that will load the script on first usage, rather than on init" + - Also saw "Namespace" typeName, evaluate which we need :P + - Single/Multi player gamelogics? (Incase of MP, you would want only 1 gamelogic per component, which is pv'ed from server, etc) + */ + +#ifndef MAINPREFIX + #define MAINPREFIX x +#endif + +#ifndef SUBPREFIX + #define SUBPREFIX addons +#endif + +#ifndef MAINLOGIC + #define MAINLOGIC main +#endif + +#define ADDON DOUBLES(PREFIX,COMPONENT) +#define MAIN_ADDON DOUBLES(PREFIX,main) + +#ifdef SUBCOMPONENT + #define SUBADDON DOUBLES(ADDON,SUBCOMPONENT) +#endif + +/* ------------------------------------------- +Macro: VERSION_CONFIG + Define CBA Versioning System config entries. + + VERSION should be a floating-point number (1 separator). + VERSION_STR is a string representation of the version. + VERSION_AR is an array representation of the version. + + VERSION must always be defined, otherwise it is 0. + VERSION_STR and VERSION_AR default to VERSION if undefined. + +Parameters: + None + +Example: + (begin example) + #define VERSION 1.0 + #define VERSION_STR 1.0.1 + #define VERSION_AR 1,0,1 + + class CfgPatches { + class MyMod_main { + VERSION_CONFIG; + }; + }; + (end) + +Author: + ?, Jonpas +------------------------------------------- */ +#ifndef VERSION + #define VERSION 0 +#endif + +#ifndef VERSION_STR + #define VERSION_STR VERSION +#endif + +#ifndef VERSION_AR + #define VERSION_AR VERSION +#endif + +#ifndef VERSION_CONFIG + #define VERSION_CONFIG version = VERSION; versionStr = QUOTE(VERSION_STR); versionAr[] = {VERSION_AR} +#endif + +/* ------------------------------------------- +Group: Debugging +------------------------------------------- */ + +/* ------------------------------------------- +Macros: DEBUG_MODE_x + Managing debugging based on debug level. + + According to the *highest* level of debugging that has been defined *before* script_macros_common.hpp is included, + only the appropriate debugging commands will be functional. With no level explicitely defined, assume DEBUG_MODE_NORMAL. + + DEBUG_MODE_FULL - Full debugging output. + DEBUG_MODE_NORMAL - All debugging except and (Default setting if none specified). + DEBUG_MODE_MINIMAL - Only and enabled. + +Examples: + In order to turn on full debugging for a single file, + (begin example) + // Top of individual script file. + #define DEBUG_MODE_FULL + + (end) + + In order to force minimal debugging for a single component, + (begin example) + // Top of addons\\script_component.hpp + // Ensure that any FULL and NORMAL setting from the individual files are undefined and MINIMAL is set. + #ifdef DEBUG_MODE_FULL + #undef DEBUG_MODE_FULL + #endif + #ifdef DEBUG_MODE_NORMAL + #undef DEBUG_MODE_NORMAL + #endif + #ifndef DEBUG_MODE_MINIMAL + #define DEBUG_MODE_MINIMAL + #endif + + (end) + + In order to turn on full debugging for a whole addon, + (begin example) + // Top of addons\main\script_macros.hpp + #ifndef DEBUG_MODE_FULL + #define DEBUG_MODE_FULL + #endif + + (end) + +Author: + Spooner +------------------------------------------- */ + +// If DEBUG_MODE_FULL, then also enable DEBUG_MODE_NORMAL. +#ifdef DEBUG_MODE_FULL +#define DEBUG_MODE_NORMAL +#endif + +// If DEBUG_MODE_NORMAL, then also enable DEBUG_MODE_MINIMAL. +#ifdef DEBUG_MODE_NORMAL +#define DEBUG_MODE_MINIMAL +#endif + +// If no debug modes specified, use DEBUG_MODE_NORMAL (+ DEBUG_MODE_MINIMAL). +#ifndef DEBUG_MODE_MINIMAL +#define DEBUG_MODE_NORMAL +#define DEBUG_MODE_MINIMAL +#endif + +#define LOG_SYS_FORMAT(LEVEL,MESSAGE) format ['[%1] (%2) %3: %4', toUpper 'PREFIX', 'COMPONENT', LEVEL, MESSAGE] + +#ifdef DEBUG_SYNCHRONOUS +#define LOG_SYS(LEVEL,MESSAGE) diag_log text LOG_SYS_FORMAT(LEVEL,MESSAGE) +#else +#define LOG_SYS(LEVEL,MESSAGE) LOG_SYS_FORMAT(LEVEL,MESSAGE) call CBA_fnc_log +#endif + +#define LOG_SYS_FILELINENUMBERS(LEVEL,MESSAGE) LOG_SYS(LEVEL,format [ARR_4('%1 %2:%3',MESSAGE,__FILE__,__LINE__ + 1)]) + +/* ------------------------------------------- +Macro: LOG() + Log a debug message into the RPT log. + + Only run if is defined. + +Parameters: + MESSAGE - Message to record + +Example: + (begin example) + LOG("Initiated clog-dancing simulator."); + (end) + +Author: + Spooner +------------------------------------------- */ +#ifdef DEBUG_MODE_FULL + +#define LOG(MESSAGE) LOG_SYS('LOG',MESSAGE) +#define LOG_1(MESSAGE,ARG1) LOG(FORMAT_1(MESSAGE,ARG1)) +#define LOG_2(MESSAGE,ARG1,ARG2) LOG(FORMAT_2(MESSAGE,ARG1,ARG2)) +#define LOG_3(MESSAGE,ARG1,ARG2,ARG3) LOG(FORMAT_3(MESSAGE,ARG1,ARG2,ARG3)) +#define LOG_4(MESSAGE,ARG1,ARG2,ARG3,ARG4) LOG(FORMAT_4(MESSAGE,ARG1,ARG2,ARG3,ARG4)) +#define LOG_5(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5) LOG(FORMAT_5(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5)) +#define LOG_6(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6) LOG(FORMAT_6(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6)) +#define LOG_7(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7) LOG(FORMAT_7(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7)) +#define LOG_8(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8) LOG(FORMAT_8(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8)) + +#else + +#define LOG(MESSAGE) /* disabled */ +#define LOG_1(MESSAGE,ARG1) /* disabled */ +#define LOG_2(MESSAGE,ARG1,ARG2) /* disabled */ +#define LOG_3(MESSAGE,ARG1,ARG2,ARG3) /* disabled */ +#define LOG_4(MESSAGE,ARG1,ARG2,ARG3,ARG4) /* disabled */ +#define LOG_5(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5) /* disabled */ +#define LOG_6(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6) /* disabled */ +#define LOG_7(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7) /* disabled */ +#define LOG_8(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8) /* disabled */ + +#endif + +/* ------------------------------------------- +Macro: INFO() + Record a message without file and line number in the RPT log. + +Parameters: + MESSAGE - Message to record + +Example: + (begin example) + INFO("Mod X is loaded, do Y"); + (end) + +Author: + commy2 +------------------------------------------- */ +#define INFO(MESSAGE) LOG_SYS('INFO',MESSAGE) +#define INFO_1(MESSAGE,ARG1) INFO(FORMAT_1(MESSAGE,ARG1)) +#define INFO_2(MESSAGE,ARG1,ARG2) INFO(FORMAT_2(MESSAGE,ARG1,ARG2)) +#define INFO_3(MESSAGE,ARG1,ARG2,ARG3) INFO(FORMAT_3(MESSAGE,ARG1,ARG2,ARG3)) +#define INFO_4(MESSAGE,ARG1,ARG2,ARG3,ARG4) INFO(FORMAT_4(MESSAGE,ARG1,ARG2,ARG3,ARG4)) +#define INFO_5(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5) INFO(FORMAT_5(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5)) +#define INFO_6(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6) INFO(FORMAT_6(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6)) +#define INFO_7(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7) INFO(FORMAT_7(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7)) +#define INFO_8(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8) INFO(FORMAT_8(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8)) + +/* ------------------------------------------- +Macro: WARNING() + Record a non-critical error in the RPT log. + + Only run if or higher is defined. + +Parameters: + MESSAGE - Message to record + +Example: + (begin example) + WARNING("This function has been deprecated. Please don't use it in future!"); + (end) + +Author: + Spooner +------------------------------------------- */ +#ifdef DEBUG_MODE_NORMAL + +#define WARNING(MESSAGE) LOG_SYS('WARNING',MESSAGE) +#define WARNING_1(MESSAGE,ARG1) WARNING(FORMAT_1(MESSAGE,ARG1)) +#define WARNING_2(MESSAGE,ARG1,ARG2) WARNING(FORMAT_2(MESSAGE,ARG1,ARG2)) +#define WARNING_3(MESSAGE,ARG1,ARG2,ARG3) WARNING(FORMAT_3(MESSAGE,ARG1,ARG2,ARG3)) +#define WARNING_4(MESSAGE,ARG1,ARG2,ARG3,ARG4) WARNING(FORMAT_4(MESSAGE,ARG1,ARG2,ARG3,ARG4)) +#define WARNING_5(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5) WARNING(FORMAT_5(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5)) +#define WARNING_6(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6) WARNING(FORMAT_6(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6)) +#define WARNING_7(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7) WARNING(FORMAT_7(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7)) +#define WARNING_8(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8) WARNING(FORMAT_8(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8)) + +#else + +#define WARNING(MESSAGE) /* disabled */ +#define WARNING_1(MESSAGE,ARG1) /* disabled */ +#define WARNING_2(MESSAGE,ARG1,ARG2) /* disabled */ +#define WARNING_3(MESSAGE,ARG1,ARG2,ARG3) /* disabled */ +#define WARNING_4(MESSAGE,ARG1,ARG2,ARG3,ARG4) /* disabled */ +#define WARNING_5(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5) /* disabled */ +#define WARNING_6(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6) /* disabled */ +#define WARNING_7(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7) /* disabled */ +#define WARNING_8(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8) /* disabled */ + +#endif + +/* ------------------------------------------- +Macro: ERROR() + Record a critical error in the RPT log. + +Parameters: + MESSAGE - Message to record + +Example: + (begin example) + ERROR("value of frog not found in config ...yada...yada..."); + (end) + +Author: + Spooner +------------------------------------------- */ +#define ERROR(MESSAGE) LOG_SYS('ERROR',MESSAGE) +#define ERROR_1(MESSAGE,ARG1) ERROR(FORMAT_1(MESSAGE,ARG1)) +#define ERROR_2(MESSAGE,ARG1,ARG2) ERROR(FORMAT_2(MESSAGE,ARG1,ARG2)) +#define ERROR_3(MESSAGE,ARG1,ARG2,ARG3) ERROR(FORMAT_3(MESSAGE,ARG1,ARG2,ARG3)) +#define ERROR_4(MESSAGE,ARG1,ARG2,ARG3,ARG4) ERROR(FORMAT_4(MESSAGE,ARG1,ARG2,ARG3,ARG4)) +#define ERROR_5(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5) ERROR(FORMAT_5(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5)) +#define ERROR_6(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6) ERROR(FORMAT_6(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6)) +#define ERROR_7(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7) ERROR(FORMAT_7(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7)) +#define ERROR_8(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8) ERROR(FORMAT_8(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8)) + +/* ------------------------------------------- +Macro: ERROR_MSG() + Record a critical error in the RPT log and display on screen error message. + + Newlines (\n) in the MESSAGE will be put on separate lines. + +Parameters: + MESSAGE - Message to record + +Example: + (begin example) + ERROR_MSG("value of frog not found in config ...yada...yada..."); + (end) + +Author: + commy2 +------------------------------------------- */ +#define ERROR_MSG(MESSAGE) ['PREFIX', 'COMPONENT', nil, MESSAGE, __FILE__, __LINE__ + 1] call CBA_fnc_error +#define ERROR_MSG_1(MESSAGE,ARG1) ERROR_MSG(FORMAT_1(MESSAGE,ARG1)) +#define ERROR_MSG_2(MESSAGE,ARG1,ARG2) ERROR_MSG(FORMAT_2(MESSAGE,ARG1,ARG2)) +#define ERROR_MSG_3(MESSAGE,ARG1,ARG2,ARG3) ERROR_MSG(FORMAT_3(MESSAGE,ARG1,ARG2,ARG3)) +#define ERROR_MSG_4(MESSAGE,ARG1,ARG2,ARG3,ARG4) ERROR_MSG(FORMAT_4(MESSAGE,ARG1,ARG2,ARG3,ARG4)) +#define ERROR_MSG_5(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5) ERROR_MSG(FORMAT_5(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5)) +#define ERROR_MSG_6(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6) ERROR_MSG(FORMAT_6(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6)) +#define ERROR_MSG_7(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7) ERROR_MSG(FORMAT_7(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7)) +#define ERROR_MSG_8(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8) ERROR_MSG(FORMAT_8(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8)) + +/* ------------------------------------------- +Macro: ERROR_WITH_TITLE() + Record a critical error in the RPT log. + + The title can be specified (in the heading is always just "ERROR") + Newlines (\n) in the MESSAGE will be put on separate lines. + +Parameters: + TITLE - Title of error message + MESSAGE - Body of error message + +Example: + (begin example) + ERROR_WITH_TITLE("Value not found","Value of frog not found in config ...yada...yada..."); + (end) + +Author: + Spooner +------------------------------------------- */ +#define ERROR_WITH_TITLE(TITLE,MESSAGE) ['PREFIX', 'COMPONENT', TITLE, MESSAGE, __FILE__, __LINE__ + 1] call CBA_fnc_error +#define ERROR_WITH_TITLE_1(TITLE,MESSAGE,ARG1) ERROR_WITH_TITLE(TITLE,FORMAT_1(MESSAGE,ARG1)) +#define ERROR_WITH_TITLE_2(TITLE,MESSAGE,ARG1,ARG2) ERROR_WITH_TITLE(TITLE,FORMAT_2(MESSAGE,ARG1,ARG2)) +#define ERROR_WITH_TITLE_3(TITLE,MESSAGE,ARG1,ARG2,ARG3) ERROR_WITH_TITLE(TITLE,FORMAT_3(MESSAGE,ARG1,ARG2,ARG3)) +#define ERROR_WITH_TITLE_4(TITLE,MESSAGE,ARG1,ARG2,ARG3,ARG4) ERROR_WITH_TITLE(TITLE,FORMAT_4(MESSAGE,ARG1,ARG2,ARG3,ARG4)) +#define ERROR_WITH_TITLE_5(TITLE,MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5) ERROR_WITH_TITLE(TITLE,FORMAT_5(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5)) +#define ERROR_WITH_TITLE_6(TITLE,MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6) ERROR_WITH_TITLE(TITLE,FORMAT_6(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6)) +#define ERROR_WITH_TITLE_7(TITLE,MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7) ERROR_WITH_TITLE(TITLE,FORMAT_7(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7)) +#define ERROR_WITH_TITLE_8(TITLE,MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8) ERROR_WITH_TITLE(TITLE,FORMAT_8(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8)) + +/* ------------------------------------------- +Macro: MESSAGE_WITH_TITLE() + Record a single line in the RPT log. + +Parameters: + TITLE - Title of log message + MESSAGE - Body of message + +Example: + (begin example) + MESSAGE_WITH_TITLE("Value found","Value of frog found in config "); + (end) + +Author: + Killswitch +------------------------------------------- */ +#define MESSAGE_WITH_TITLE(TITLE,MESSAGE) LOG_SYS_FILELINENUMBERS(TITLE,MESSAGE) + +/* ------------------------------------------- +Macro: RETDEF() + If a variable is undefined, return the default value. Otherwise, return the + variable itself. + +Parameters: + VARIABLE - the variable to check + DEFAULT_VALUE - the default value to use if variable is undefined + +Example: + (begin example) + // _var is undefined + hintSilent format ["_var=%1", RETDEF(_var,5)]; // "_var=5" + _var = 7; + hintSilent format ["_var=%1", RETDEF(_var,5)]; // "_var=7" + (end example) +Author: + 654wak654 +------------------------------------------- */ +#define RETDEF(VARIABLE,DEFAULT_VALUE) (if (isNil {VARIABLE}) then [{DEFAULT_VALUE}, {VARIABLE}]) + +/* ------------------------------------------- +Macro: RETNIL() + If a variable is undefined, return the value nil. Otherwise, return the + variable itself. + +Parameters: + VARIABLE - the variable to check + +Example: + (begin example) + // _var is undefined + hintSilent format ["_var=%1", RETNIL(_var)]; // "_var=any" + (end example) + +Author: + Alef (see CBA issue #8514) +------------------------------------------- */ +#define RETNIL(VARIABLE) RETDEF(VARIABLE,nil) + +/* ------------------------------------------- +Macros: TRACE_n() + Log a message and 1-8 variables to the RPT log. + + Only run if is defined. + + TRACE_1(MESSAGE,A) - Log 1 variable. + TRACE_2(MESSAGE,A,B) - Log 2 variables. + TRACE_3(MESSAGE,A,B,C) - Log 3 variables. + TRACE_4(MESSAGE,A,B,C,D) - Log 4 variables. + TRACE_5(MESSAGE,A,B,C,D,E) - Log 5 variables. + TRACE_6(MESSAGE,A,B,C,D,E,F) - Log 6 variables. + TRACE_7(MESSAGE,A,B,C,D,E,F,G) - Log 7 variables. + TRACE_8(MESSAGE,A,B,C,D,E,F,G,H) - Log 8 variables. + TRACE_9(MESSAGE,A,B,C,D,E,F,G,H,I) - Log 9 variables. + +Parameters: + MESSAGE - Message to add to the trace [String] + A..H - Variable names to log values of [Any] + +Example: + (begin example) + TRACE_3("After takeoff",_vehicle player,getPos (_vehicle player), getPosASL (_vehicle player)); + (end) + +Author: + Spooner +------------------------------------------- */ +#define PFORMAT_1(MESSAGE,A) \ + format ['%1: A=%2', MESSAGE, RETNIL(A)] + +#define PFORMAT_2(MESSAGE,A,B) \ + format ['%1: A=%2, B=%3', MESSAGE, RETNIL(A), RETNIL(B)] + +#define PFORMAT_3(MESSAGE,A,B,C) \ + format ['%1: A=%2, B=%3, C=%4', MESSAGE, RETNIL(A), RETNIL(B), RETNIL(C)] + +#define PFORMAT_4(MESSAGE,A,B,C,D) \ + format ['%1: A=%2, B=%3, C=%4, D=%5', MESSAGE, RETNIL(A), RETNIL(B), RETNIL(C), RETNIL(D)] + +#define PFORMAT_5(MESSAGE,A,B,C,D,E) \ + format ['%1: A=%2, B=%3, C=%4, D=%5, E=%6', MESSAGE, RETNIL(A), RETNIL(B), RETNIL(C), RETNIL(D), RETNIL(E)] + +#define PFORMAT_6(MESSAGE,A,B,C,D,E,F) \ + format ['%1: A=%2, B=%3, C=%4, D=%5, E=%6, F=%7', MESSAGE, RETNIL(A), RETNIL(B), RETNIL(C), RETNIL(D), RETNIL(E), RETNIL(F)] + +#define PFORMAT_7(MESSAGE,A,B,C,D,E,F,G) \ + format ['%1: A=%2, B=%3, C=%4, D=%5, E=%6, F=%7, G=%8', MESSAGE, RETNIL(A), RETNIL(B), RETNIL(C), RETNIL(D), RETNIL(E), RETNIL(F), RETNIL(G)] + +#define PFORMAT_8(MESSAGE,A,B,C,D,E,F,G,H) \ + format ['%1: A=%2, B=%3, C=%4, D=%5, E=%6, F=%7, G=%8, H=%9', MESSAGE, RETNIL(A), RETNIL(B), RETNIL(C), RETNIL(D), RETNIL(E), RETNIL(F), RETNIL(G), RETNIL(H)] + +#define PFORMAT_9(MESSAGE,A,B,C,D,E,F,G,H,I) \ + format ['%1: A=%2, B=%3, C=%4, D=%5, E=%6, F=%7, G=%8, H=%9, I=%10', MESSAGE, RETNIL(A), RETNIL(B), RETNIL(C), RETNIL(D), RETNIL(E), RETNIL(F), RETNIL(G), RETNIL(H), RETNIL(I)] + + +#ifdef DEBUG_MODE_FULL +#define TRACE_1(MESSAGE,A) LOG_SYS_FILELINENUMBERS('TRACE',PFORMAT_1(str diag_frameNo + ' ' + (MESSAGE),A)) +#define TRACE_2(MESSAGE,A,B) LOG_SYS_FILELINENUMBERS('TRACE',PFORMAT_2(str diag_frameNo + ' ' + (MESSAGE),A,B)) +#define TRACE_3(MESSAGE,A,B,C) LOG_SYS_FILELINENUMBERS('TRACE',PFORMAT_3(str diag_frameNo + ' ' + (MESSAGE),A,B,C)) +#define TRACE_4(MESSAGE,A,B,C,D) LOG_SYS_FILELINENUMBERS('TRACE',PFORMAT_4(str diag_frameNo + ' ' + (MESSAGE),A,B,C,D)) +#define TRACE_5(MESSAGE,A,B,C,D,E) LOG_SYS_FILELINENUMBERS('TRACE',PFORMAT_5(str diag_frameNo + ' ' + (MESSAGE),A,B,C,D,E)) +#define TRACE_6(MESSAGE,A,B,C,D,E,F) LOG_SYS_FILELINENUMBERS('TRACE',PFORMAT_6(str diag_frameNo + ' ' + (MESSAGE),A,B,C,D,E,F)) +#define TRACE_7(MESSAGE,A,B,C,D,E,F,G) LOG_SYS_FILELINENUMBERS('TRACE',PFORMAT_7(str diag_frameNo + ' ' + (MESSAGE),A,B,C,D,E,F,G)) +#define TRACE_8(MESSAGE,A,B,C,D,E,F,G,H) LOG_SYS_FILELINENUMBERS('TRACE',PFORMAT_8(str diag_frameNo + ' ' + (MESSAGE),A,B,C,D,E,F,G,H)) +#define TRACE_9(MESSAGE,A,B,C,D,E,F,G,H,I) LOG_SYS_FILELINENUMBERS('TRACE',PFORMAT_9(str diag_frameNo + ' ' + (MESSAGE),A,B,C,D,E,F,G,H,I)) +#else +#define TRACE_1(MESSAGE,A) /* disabled */ +#define TRACE_2(MESSAGE,A,B) /* disabled */ +#define TRACE_3(MESSAGE,A,B,C) /* disabled */ +#define TRACE_4(MESSAGE,A,B,C,D) /* disabled */ +#define TRACE_5(MESSAGE,A,B,C,D,E) /* disabled */ +#define TRACE_6(MESSAGE,A,B,C,D,E,F) /* disabled */ +#define TRACE_7(MESSAGE,A,B,C,D,E,F,G) /* disabled */ +#define TRACE_8(MESSAGE,A,B,C,D,E,F,G,H) /* disabled */ +#define TRACE_9(MESSAGE,A,B,C,D,E,F,G,H,I) /* disabled */ +#endif + +/* ------------------------------------------- +Group: General +------------------------------------------- */ + +// ************************************* +// Internal Functions +#define DOUBLES(var1,var2) var1##_##var2 +#define TRIPLES(var1,var2,var3) var1##_##var2##_##var3 +#define QUOTE(var1) #var1 + +#ifdef MODULAR + #define COMPONENT_T DOUBLES(t,COMPONENT) + #define COMPONENT_M DOUBLES(m,COMPONENT) + #define COMPONENT_S DOUBLES(s,COMPONENT) + #define COMPONENT_C DOUBLES(c,COMPONENT) + #define COMPONENT_F COMPONENT_C +#else + #define COMPONENT_T COMPONENT + #define COMPONENT_M COMPONENT + #define COMPONENT_S COMPONENT + #define COMPONENT_F COMPONENT + #define COMPONENT_C COMPONENT +#endif + +/* ------------------------------------------- +Macro: INC() + +Description: + Increase a number by one. + +Parameters: + VAR - Variable to increment [Number] + +Example: + (begin example) + _counter = 0; + INC(_counter); + // _counter => 1 + (end) + +Author: + Spooner +------------------------------------------- */ +#define INC(var) var = (var) + 1 + +/* ------------------------------------------- +Macro: DEC() + +Description: + Decrease a number by one. + +Parameters: + VAR - Variable to decrement [Number] + +Example: + (begin example) + _counter = 99; + DEC(_counter); + // _counter => 98 + (end) + +Author: + Spooner +------------------------------------------- */ +#define DEC(var) var = (var) - 1 + +/* ------------------------------------------- +Macro: ADD() + +Description: + Add a value to a variable. Variable and value should be both Numbers or both Strings. + +Parameters: + VAR - Variable to add to [Number or String] + VALUE - Value to add [Number or String] + +Examples: + (begin example) + _counter = 2; + ADD(_counter,3); + // _counter => 5 + (end) + (begin example) + _str = "hello"; + ADD(_str," "); + ADD(_str,"Fred"); + // _str => "hello Fred" + (end) + +Author: + Sickboy +------------------------------------------- */ +#define ADD(var1,var2) var1 = (var1) + (var2) + +/* ------------------------------------------- +Macro: SUB() + +Description: + Subtract a value from a number variable. VAR and VALUE should both be Numbers. + +Parameters: + VAR - Variable to subtract from [Number] + VALUE - Value to subtract [Number] + +Examples: + (begin example) + _numChickens = 2; + SUB(_numChickens,3); + // _numChickens => -1 + (end) +------------------------------------------- */ +#define SUB(var1,var2) var1 = (var1) - (var2) + +/* ------------------------------------------- +Macro: REM() + +Description: + Remove an element from an array each time it occurs. + + This recreates the entire array, so use BIS_fnc_removeIndex if modification of the original array is required + or if only one of the elements that matches ELEMENT needs to be removed. + +Parameters: + ARRAY - Array to modify [Array] + ELEMENT - Element to remove [Any] + +Examples: + (begin example) + _array = [1, 2, 3, 4, 3, 8]; + REM(_array,3); + // _array = [1, 2, 4, 8]; + (end) + +Author: + Spooner +------------------------------------------- */ +#define REM(var1,var2) SUB(var1,[var2]) + +/* ------------------------------------------- +Macro: PUSH() + +Description: + Appends a single value onto the end of an ARRAY. Change is made to the ARRAY itself, not creating a new array. + +Parameters: + ARRAY - Array to push element onto [Array] + ELEMENT - Element to push [Any] + +Examples: + (begin example) + _fish = ["blue", "green", "smelly"]; + PUSH(_fish,"monkey-flavoured"); + // _fish => ["blue", "green", "smelly", "monkey-flavoured"] + (end) + +Author: + Spooner +------------------------------------------- */ +#define PUSH(var1,var2) (var1) pushBack (var2) + +/* ------------------------------------------- +Macro: MAP() +Description: + Applies given code to each element of the array, then assigns the + resulting array to the original +Parameters: + ARRAY - Array to be modified + CODE - Code that'll be applied to each element of the array. +Example: + (begin example) + _array = [1, 2, 3, 4, 3, 8]; + MAP(_array,_x + 1); + // _array is now [2, 3, 4, 5, 4, 9]; + (end) +Author: + 654wak654 +------------------------------------------- */ +#define MAP(ARR,CODE) ARR = ARR apply {CODE} + +/* ------------------------------------------- +Macro: FILTER() +Description: + Filters an array based on given code, then assigns the resulting array + to the original +Parameters: + ARRAY - Array to be filtered + CODE - Condition to pick elements +Example: + (begin example) + _array = [1, 2, 3, 4, 3, 8]; + FILTER(_array,_x % 2 == 0) + // _array is now [2, 4, 8]; + (end) +Author: + Commy2 +------------------------------------------- */ +#define FILTER(ARR,CODE) ARR = ARR select {CODE} + +/* ------------------------------------------- +Macro: UNIQUE() +Description: + Removes duplicate values in given array +Parameters: + ARRAY - The array to be modified +Example: + (begin example) + _someArray = [4, 4, 5, 5, 5, 2]; + UNIQUE(_someArray); + // _someArray is now [4, 5, 2] + (end) +Author: + Commy2 +------------------------------------------- */ +#define UNIQUE(ARR) ARR = ARR arrayIntersect ARR + +/* ------------------------------------------- +Macro: INTERSECTION() +Description: + Finds unique common elements between two arrays and assigns them + to the first array +Parameters: + ARRAY0 - The array to be modified + ARRAY1 - The array to find intersections with +Example: + (begin example) + _someArray = [1, 2, 3, 4, 5, 5]; + _anotherArray = [4, 5, 6, 7]; + INTERSECTION(_someArray,_anotherArray); + // _someArray is now [4, 5] + (end) +Author: + 654wak654 +------------------------------------------- */ +#define INTERSECTION(ARG0,ARG1) ARG0 = ARG0 arrayIntersect (ARG1) + +/* ------------------------------------------- +Macro: ISNILS() + +Description: + Sets a variable with a value, but only if it is undefined. + +Parameters: + VARIABLE - Variable to set [Any, not nil] + DEFAULT_VALUE - Value to set VARIABLE to if it is undefined [Any, not nil] + +Examples: + (begin example) + // _fish is undefined + ISNILS(_fish,0); + // _fish => 0 + (end) + (begin example) + _fish = 12; + // ...later... + ISNILS(_fish,0); + // _fish => 12 + (end) + +Author: + Sickboy +------------------------------------------- */ +#define ISNILS(VARIABLE,DEFAULT_VALUE) if (isNil #VARIABLE) then { VARIABLE = DEFAULT_VALUE } +#define ISNILS2(var1,var2,var3,var4) ISNILS(TRIPLES(var1,var2,var3),var4) +#define ISNILS3(var1,var2,var3) ISNILS(DOUBLES(var1,var2),var3) +#define ISNIL(var1,var2) ISNILS2(PREFIX,COMPONENT,var1,var2) +#define ISNILMAIN(var1,var2) ISNILS3(PREFIX,var1,var2) + +#define CREATELOGICS(var1,var2) var1##_##var2 = ([sideLogic] call CBA_fnc_getSharedGroup) createUnit ["LOGIC", [0, 0, 0], [], 0, "NONE"] +#define CREATELOGICLOCALS(var1,var2) var1##_##var2 = "LOGIC" createVehicleLocal [0, 0, 0] +#define CREATELOGICGLOBALS(var1,var2) var1##_##var2 = ([sideLogic] call CBA_fnc_getSharedGroup) createUnit ["LOGIC", [0, 0, 0], [], 0, "NONE"]; publicVariable QUOTE(DOUBLES(var1,var2)) +#define CREATELOGICGLOBALTESTS(var1,var2) var1##_##var2 = ([sideLogic] call CBA_fnc_getSharedGroup) createUnit [QUOTE(DOUBLES(ADDON,logic)), [0, 0, 0], [], 0, "NONE"] + +#define GETVARS(var1,var2,var3) (var1##_##var2 getVariable #var3) +#define GETVARMAINS(var1,var2) GETVARS(var1,MAINLOGIC,var2) + +#ifndef PATHTO_SYS + #define PATHTO_SYS(var1,var2,var3) \MAINPREFIX\var1\SUBPREFIX\var2\var3.sqf +#endif +#ifndef PATHTOF_SYS + #define PATHTOF_SYS(var1,var2,var3) \MAINPREFIX\var1\SUBPREFIX\var2\var3 +#endif + +#ifndef PATHTOF2_SYS + #define PATHTOF2_SYS(var1,var2,var3) MAINPREFIX\var1\SUBPREFIX\var2\var3 +#endif + +#define PATHTO_R(var1) PATHTOF2_SYS(PREFIX,COMPONENT_C,var1) +#define PATHTO_T(var1) PATHTOF_SYS(PREFIX,COMPONENT_T,var1) +#define PATHTO_M(var1) PATHTOF_SYS(PREFIX,COMPONENT_M,var1) +#define PATHTO_S(var1) PATHTOF_SYS(PREFIX,COMPONENT_S,var1) +#define PATHTO_C(var1) PATHTOF_SYS(PREFIX,COMPONENT_C,var1) +#define PATHTO_F(var1) PATHTO_SYS(PREFIX,COMPONENT_F,var1) + +// Already quoted "" +#define QPATHTO_R(var1) QUOTE(PATHTO_R(var1)) +#define QPATHTO_T(var1) QUOTE(PATHTO_T(var1)) +#define QPATHTO_M(var1) QUOTE(PATHTO_M(var1)) +#define QPATHTO_S(var1) QUOTE(PATHTO_S(var1)) +#define QPATHTO_C(var1) QUOTE(PATHTO_C(var1)) +#define QPATHTO_F(var1) QUOTE(PATHTO_F(var1)) + +// This only works for binarized configs after recompiling the pbos +// TODO: Reduce amount of calls / code.. +#define COMPILE_FILE2_CFG_SYS(var1) compile preprocessFileLineNumbers var1 +#define COMPILE_FILE2_SYS(var1) COMPILE_FILE2_CFG_SYS(var1) + +#define COMPILE_FILE_SYS(var1,var2,var3) COMPILE_FILE2_SYS('PATHTO_SYS(var1,var2,var3)') +#define COMPILE_FILE_CFG_SYS(var1,var2,var3) COMPILE_FILE2_CFG_SYS('PATHTO_SYS(var1,var2,var3)') + +#define SETVARS(var1,var2) var1##_##var2 setVariable +#define SETVARMAINS(var1) SETVARS(var1,MAINLOGIC) +#define GVARMAINS(var1,var2) var1##_##var2 +#define CFGSETTINGSS(var1,var2) configFile >> "CfgSettings" >> #var1 >> #var2 +//#define SETGVARS(var1,var2,var3) var1##_##var2##_##var3 = +//#define SETGVARMAINS(var1,var2) var1##_##var2 = + +// Compile-Once, JIT: On first use. +// #define PREPMAIN_SYS(var1,var2,var3) var1##_fnc_##var3 = { var1##_fnc_##var3 = COMPILE_FILE_SYS(var1,var2,DOUBLES(fnc,var3)); if (isNil "_this") then { call var1##_fnc_##var3 } else { _this call var1##_fnc_##var3 } } +// #define PREP_SYS(var1,var2,var3) var1##_##var2##_fnc_##var3 = { var1##_##var2##_fnc_##var3 = COMPILE_FILE_SYS(var1,var2,DOUBLES(fnc,var3)); if (isNil "_this") then { call var1##_##var2##_fnc_##var3 } else { _this call var1##_##var2##_fnc_##var3 } } +// #define PREP_SYS2(var1,var2,var3,var4) var1##_##var2##_fnc_##var4 = { var1##_##var2##_fnc_##var4 = COMPILE_FILE_SYS(var1,var3,DOUBLES(fnc,var4)); if (isNil "_this") then { call var1##_##var2##_fnc_##var4 } else { _this call var1##_##var2##_fnc_##var4 } } + +// Compile-Once, at Macro. As opposed to Compile-Once, on first use. +#define PREPMAIN_SYS(var1,var2,var3) var1##_fnc_##var3 = COMPILE_FILE_SYS(var1,var2,DOUBLES(fnc,var3)) +#define PREP_SYS(var1,var2,var3) var1##_##var2##_fnc_##var3 = COMPILE_FILE_SYS(var1,var2,DOUBLES(fnc,var3)) +#define PREP_SYS2(var1,var2,var3,var4) var1##_##var2##_fnc_##var4 = COMPILE_FILE_SYS(var1,var3,DOUBLES(fnc,var4)) + +#define LSTR(var1) TRIPLES(ADDON,STR,var1) + +#ifndef DEBUG_SETTINGS + #define DEBUG_SETTINGS [false, true, false] +#endif + +#define MSG_INIT QUOTE(Initializing: ADDON version: VERSION) + +// ************************************* +// User Functions +#define CFGSETTINGS CFGSETTINGSS(PREFIX,COMPONENT) +#define PATHTO(var1) PATHTO_SYS(PREFIX,COMPONENT_F,var1) +#define PATHTOF(var1) PATHTOF_SYS(PREFIX,COMPONENT,var1) +#define PATHTOEF(var1,var2) PATHTOF_SYS(PREFIX,var1,var2) +#define QPATHTOF(var1) QUOTE(PATHTOF(var1)) +#define QPATHTOEF(var1,var2) QUOTE(PATHTOEF(var1,var2)) + +#define COMPILE_FILE(var1) COMPILE_FILE_SYS(PREFIX,COMPONENT_F,var1) +#define COMPILE_FILE_CFG(var1) COMPILE_FILE_CFG_SYS(PREFIX,COMPONENT_F,var1) +#define COMPILE_FILE2(var1) COMPILE_FILE2_SYS('var1') +#define COMPILE_FILE2_CFG(var1) COMPILE_FILE2_CFG_SYS('var1') + +#define COMPILE_SCRIPT(var1) compileScript ['PATHTO_SYS(PREFIX,COMPONENT_F,var1)'] + + +#define VERSIONING_SYS(var1) class CfgSettings { \ + class CBA { \ + class Versioning { \ + class var1 {}; \ + }; \ + }; \ +}; + +#define VERSIONING VERSIONING_SYS(PREFIX) + +/* ------------------------------------------- +Macro: GVAR() + Get full variable identifier for a global variable owned by this component. + +Parameters: + VARIABLE - Partial name of global variable owned by this component [Any]. + +Example: + (begin example) + GVAR(frog) = 12; + // In SPON_FrogDancing component, equivalent to SPON_FrogDancing_frog = 12 + (end) + +Author: + Sickboy +------------------------------------------- */ +#define GVAR(var1) DOUBLES(ADDON,var1) +#define EGVAR(var1,var2) TRIPLES(PREFIX,var1,var2) +#define QGVAR(var1) QUOTE(GVAR(var1)) +#define QEGVAR(var1,var2) QUOTE(EGVAR(var1,var2)) +#define QQGVAR(var1) QUOTE(QGVAR(var1)) +#define QQEGVAR(var1,var2) QUOTE(QEGVAR(var1,var2)) + +/* ------------------------------------------- +Macro: GVARMAIN() + Get full variable identifier for a global variable owned by this addon. + +Parameters: + VARIABLE - Partial name of global variable owned by this addon [Any]. + +Example: + (begin example) + GVARMAIN(frog) = 12; + // In SPON_FrogDancing component, equivalent to SPON_frog = 12 + (end) + +Author: + Sickboy +------------------------------------------- */ +#define GVARMAIN(var1) GVARMAINS(PREFIX,var1) +#define QGVARMAIN(var1) QUOTE(GVARMAIN(var1)) +#define QQGVARMAIN(var1) QUOTE(QGVARMAIN(var1)) +// TODO: What's this? +#define SETTINGS DOUBLES(PREFIX,settings) +#define CREATELOGIC CREATELOGICS(PREFIX,COMPONENT) +#define CREATELOGICGLOBAL CREATELOGICGLOBALS(PREFIX,COMPONENT) +#define CREATELOGICGLOBALTEST CREATELOGICGLOBALTESTS(PREFIX,COMPONENT) +#define CREATELOGICLOCAL CREATELOGICLOCALS(PREFIX,COMPONENT) +#define CREATELOGICMAIN CREATELOGICS(PREFIX,MAINLOGIC) +#define GETVAR(var1) GETVARS(PREFIX,COMPONENT,var1) +#define SETVAR SETVARS(PREFIX,COMPONENT) +#define SETVARMAIN SETVARMAINS(PREFIX) +#define IFCOUNT(var1,var2,var3) if (count var1 > var2) then { var3 = var1 select var2 }; + +/* ------------------------------------------- +Macro: PREP() + +Description: + Defines a function. + + Full file path: + '\MAINPREFIX\PREFIX\SUBPREFIX\COMPONENT\fnc_.sqf' + + Resulting function name: + 'PREFIX_COMPONENT_' + + The PREP macro should be placed in a script run by a XEH preStart and XEH preInit event. + + The PREP macro allows for CBA function caching, which drastically speeds up load times. + Beware though that function caching is enabled by default and as such to disable it, you need to + #define DISABLE_COMPILE_CACHE above your #include "script_components.hpp" include! + + The function will be defined in ui and mission namespace. It can not be overwritten without + a mission restart. + +Parameters: + FUNCTION NAME - Name of the function, unquoted + +Examples: + (begin example) + PREP(banana); + call FUNC(banana); + (end) + +Author: + dixon13 + ------------------------------------------- */ +//#define PREP(var1) PREP_SYS(PREFIX,COMPONENT_F,var1) + +#ifdef DISABLE_COMPILE_CACHE + #define PREP(var1) TRIPLES(ADDON,fnc,var1) = compile preProcessFileLineNumbers 'PATHTO_SYS(PREFIX,COMPONENT_F,DOUBLES(fnc,var1))' + #define PREPMAIN(var1) TRIPLES(PREFIX,fnc,var1) = compile preProcessFileLineNumbers 'PATHTO_SYS(PREFIX,COMPONENT_F,DOUBLES(fnc,var1))' +#else + #define PREP(var1) ['PATHTO_SYS(PREFIX,COMPONENT_F,DOUBLES(fnc,var1))', 'TRIPLES(ADDON,fnc,var1)'] call SLX_XEH_COMPILE_NEW + #define PREPMAIN(var1) ['PATHTO_SYS(PREFIX,COMPONENT_F,DOUBLES(fnc,var1))', 'TRIPLES(PREFIX,fnc,var1)'] call SLX_XEH_COMPILE_NEW +#endif + +/* ------------------------------------------- +Macro: PATHTO_FNC() + +Description: + Defines a function inside CfgFunctions. + + Full file path in addons: + '\MAINPREFIX\PREFIX\SUBPREFIX\COMPONENT\fnc_.sqf' + Define 'RECOMPILE' to enable recompiling. + Define 'SKIP_FUNCTION_HEADER' to skip adding function header. + +Parameters: + FUNCTION NAME - Name of the function, unquoted + +Examples: + (begin example) + // file name: fnc_addPerFrameHandler.sqf + class CfgFunctions { + class CBA { + class Misc { + PATHTO_FNC(addPerFrameHandler); + }; + }; + }; + // -> CBA_fnc_addPerFrameHandler + (end) + +Author: + dixon13, commy2 + ------------------------------------------- */ +#ifdef RECOMPILE + #undef RECOMPILE + #define RECOMPILE recompile = 1 +#else + #define RECOMPILE recompile = 0 +#endif +// Set function header type: -1 - no header; 0 - default header; 1 - system header. +#ifdef SKIP_FUNCTION_HEADER + #define CFGFUNCTION_HEADER headerType = -1 +#else + #define CFGFUNCTION_HEADER headerType = 0 +#endif + +#define PATHTO_FNC(func) class func {\ + file = QPATHTOF(DOUBLES(fnc,func).sqf);\ + CFGFUNCTION_HEADER;\ + RECOMPILE;\ +} + +#define FUNC(var1) TRIPLES(ADDON,fnc,var1) +#define FUNCMAIN(var1) TRIPLES(PREFIX,fnc,var1) +#define FUNC_INNER(var1,var2) TRIPLES(DOUBLES(PREFIX,var1),fnc,var2) +#define EFUNC(var1,var2) FUNC_INNER(var1,var2) +#define QFUNC(var1) QUOTE(FUNC(var1)) +#define QFUNCMAIN(var1) QUOTE(FUNCMAIN(var1)) +#define QFUNC_INNER(var1,var2) QUOTE(FUNC_INNER(var1,var2)) +#define QEFUNC(var1,var2) QUOTE(EFUNC(var1,var2)) +#define QQFUNC(var1) QUOTE(QFUNC(var1)) +#define QQFUNCMAIN(var1) QUOTE(QFUNCMAIN(var1)) +#define QQFUNC_INNER(var1,var2) QUOTE(QFUNC_INNER(var1,var2)) +#define QQEFUNC(var1,var2) QUOTE(QEFUNC(var1,var2)) + +#ifndef PRELOAD_ADDONS + #define PRELOAD_ADDONS class CfgAddons { \ + class PreloadAddons { \ + class ADDON { \ + list[]={ QUOTE(ADDON) }; \ + }; \ + }; \ +} +#endif + +/* ------------------------------------------- +Macros: ARG_#() + Select from list of array arguments + +Parameters: + VARIABLE(1-8) - elements for the list + +Author: + Rommel +------------------------------------------- */ +#define ARG_1(A,B) ((A) select (B)) +#define ARG_2(A,B,C) (ARG_1(ARG_1(A,B),C)) +#define ARG_3(A,B,C,D) (ARG_1(ARG_2(A,B,C),D)) +#define ARG_4(A,B,C,D,E) (ARG_1(ARG_3(A,B,C,D),E)) +#define ARG_5(A,B,C,D,E,F) (ARG_1(ARG_4(A,B,C,D,E),F)) +#define ARG_6(A,B,C,D,E,F,G) (ARG_1(ARG_5(A,B,C,D,E,F),G)) +#define ARG_7(A,B,C,D,E,F,G,H) (ARG_1(ARG_6(A,B,C,D,E,E,F,G),H)) +#define ARG_8(A,B,C,D,E,F,G,H,I) (ARG_1(ARG_7(A,B,C,D,E,E,F,G,H),I)) + +/* ------------------------------------------- +Macros: ARR_#() + Create list from arguments. Useful for working around , in macro parameters. + 1-8 arguments possible. + +Parameters: + VARIABLE(1-8) - elements for the list + +Author: + Nou +------------------------------------------- */ +#define ARR_1(ARG1) ARG1 +#define ARR_2(ARG1,ARG2) ARG1, ARG2 +#define ARR_3(ARG1,ARG2,ARG3) ARG1, ARG2, ARG3 +#define ARR_4(ARG1,ARG2,ARG3,ARG4) ARG1, ARG2, ARG3, ARG4 +#define ARR_5(ARG1,ARG2,ARG3,ARG4,ARG5) ARG1, ARG2, ARG3, ARG4, ARG5 +#define ARR_6(ARG1,ARG2,ARG3,ARG4,ARG5,ARG6) ARG1, ARG2, ARG3, ARG4, ARG5, ARG6 +#define ARR_7(ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7) ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7 +#define ARR_8(ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8) ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7, ARG8 + +/* ------------------------------------------- +Macros: FORMAT_#(STR, ARG1) + Format - Useful for working around , in macro parameters. + 1-8 arguments possible. + +Parameters: + STRING - string used by format + VARIABLE(1-8) - elements for usage in format + +Author: + Nou & Sickboy +------------------------------------------- */ +#define FORMAT_1(STR,ARG1) format[STR, ARG1] +#define FORMAT_2(STR,ARG1,ARG2) format[STR, ARG1, ARG2] +#define FORMAT_3(STR,ARG1,ARG2,ARG3) format[STR, ARG1, ARG2, ARG3] +#define FORMAT_4(STR,ARG1,ARG2,ARG3,ARG4) format[STR, ARG1, ARG2, ARG3, ARG4] +#define FORMAT_5(STR,ARG1,ARG2,ARG3,ARG4,ARG5) format[STR, ARG1, ARG2, ARG3, ARG4, ARG5] +#define FORMAT_6(STR,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6) format[STR, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6] +#define FORMAT_7(STR,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7) format[STR, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7] +#define FORMAT_8(STR,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8) format[STR, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7, ARG8] + +// CONTROL(46) 12 +#define DISPLAY(A) (findDisplay A) +#define CONTROL(A) DISPLAY(A) displayCtrl + +/* ------------------------------------------- +Macros: IS_x() + Checking the data types of variables. + + IS_ARRAY() - Array + IS_BOOL() - Boolean + IS_BOOLEAN() - UI display handle(synonym for ) + IS_CODE() - Code block (i.e a compiled function) + IS_CONFIG() - Configuration + IS_CONTROL() - UI control handle. + IS_DISPLAY() - UI display handle. + IS_FUNCTION() - A compiled function (synonym for ) + IS_GROUP() - Group. + IS_INTEGER() - Is a number a whole number? + IS_LOCATION() - World location. + IS_NUMBER() - A floating point number (synonym for ) + IS_OBJECT() - World object. + IS_SCALAR() - Floating point number. + IS_SCRIPT() - A script handle (as returned by execVM and spawn commands). + IS_SIDE() - Game side. + IS_STRING() - World object. + IS_TEXT() - Structured text. + +Parameters: + VARIABLE - Variable to check if it is of a particular type [Any, not nil] + +Author: + Spooner +------------------------------------------- */ +#define IS_META_SYS(VAR,TYPE) (if (isNil {VAR}) then {false} else {(VAR) isEqualType TYPE}) +#define IS_ARRAY(VAR) IS_META_SYS(VAR,[]) +#define IS_BOOL(VAR) IS_META_SYS(VAR,false) +#define IS_CODE(VAR) IS_META_SYS(VAR,{}) +#define IS_CONFIG(VAR) IS_META_SYS(VAR,configNull) +#define IS_CONTROL(VAR) IS_META_SYS(VAR,controlNull) +#define IS_DISPLAY(VAR) IS_META_SYS(VAR,displayNull) +#define IS_GROUP(VAR) IS_META_SYS(VAR,grpNull) +#define IS_OBJECT(VAR) IS_META_SYS(VAR,objNull) +#define IS_SCALAR(VAR) IS_META_SYS(VAR,0) +#define IS_SCRIPT(VAR) IS_META_SYS(VAR,scriptNull) +#define IS_SIDE(VAR) IS_META_SYS(VAR,west) +#define IS_STRING(VAR) IS_META_SYS(VAR,"STRING") +#define IS_TEXT(VAR) IS_META_SYS(VAR,text "") +#define IS_LOCATION(VAR) IS_META_SYS(VAR,locationNull) + +#define IS_BOOLEAN(VAR) IS_BOOL(VAR) +#define IS_FUNCTION(VAR) IS_CODE(VAR) +#define IS_INTEGER(VAR) (if (IS_SCALAR(VAR)) then {floor (VAR) == (VAR)} else {false}) +#define IS_NUMBER(VAR) IS_SCALAR(VAR) + +#define FLOAT_TO_STRING(num) (if (_this == 0) then {"0"} else {str parseNumber (str (_this % _this) + str floor abs _this) + "." + (str (abs _this - floor abs _this) select [2]) + "0"}) + +/* ------------------------------------------- +Macro: SCRIPT() + Sets name of script (relies on PREFIX and COMPONENT values being #defined). + Define 'SKIP_SCRIPT_NAME' to skip adding scriptName. + +Parameters: + NAME - Name of script [Indentifier] + +Example: + (begin example) + SCRIPT(eradicateMuppets); + (end) + +Author: + Spooner +------------------------------------------- */ +#ifndef SKIP_SCRIPT_NAME + #define SCRIPT(NAME) scriptName 'PREFIX\COMPONENT\NAME' +#else + #define SCRIPT(NAME) /* nope */ +#endif + +/* ------------------------------------------- +Macros: EXPLODE_n() + DEPRECATED - Use param/params commands added in Arma 3 1.48 + + Splitting an ARRAY into a number of variables (A, B, C, etc). + + Note that this NOT does make the created variables private. + _PVT variants do. + + EXPLODE_1(ARRAY,A,B) - Split a 1-element array into separate variable. + EXPLODE_2(ARRAY,A,B) - Split a 2-element array into separate variables. + EXPLODE_3(ARRAY,A,B,C) - Split a 3-element array into separate variables. + EXPLODE_4(ARRAY,A,B,C,D) - Split a 4-element array into separate variables. + EXPLODE_5(ARRAY,A,B,C,D,E) - Split a 5-element array into separate variables. + EXPLODE_6(ARRAY,A,B,C,D,E,F) - Split a 6-element array into separate variables. + EXPLODE_7(ARRAY,A,B,C,D,E,F,G) - Split a 7-element array into separate variables. + EXPLODE_8(ARRAY,A,B,C,D,E,F,G,H) - Split a 8-element array into separate variables. + EXPLODE_9(ARRAY,A,B,C,D,E,F,G,H,I) - Split a 9-element array into separate variables. + +Parameters: + ARRAY - Array to read from [Array] + A..H - Names of variables to set from array [Identifier] + +Example: + (begin example) + _array = ["fred", 156.8, 120.9]; + EXPLODE_3(_array,_name,_height,_weight); + (end) + +Author: + Spooner +------------------------------------------- */ +#define EXPLODE_1_SYS(ARRAY,A) A = ARRAY param [0] +#define EXPLODE_1(ARRAY,A) EXPLODE_1_SYS(ARRAY,A); TRACE_1("EXPLODE_1, " + QUOTE(ARRAY),A) +#define EXPLODE_1_PVT(ARRAY,A) ARRAY params [#A]; TRACE_1("EXPLODE_1, " + QUOTE(ARRAY),A) + +#define EXPLODE_2_SYS(ARRAY,A,B) EXPLODE_1_SYS(ARRAY,A); B = ARRAY param [1] +#define EXPLODE_2(ARRAY,A,B) EXPLODE_2_SYS(ARRAY,A,B); TRACE_2("EXPLODE_2, " + QUOTE(ARRAY),A,B) +#define EXPLODE_2_PVT(ARRAY,A,B) ARRAY params [#A,#B]; TRACE_2("EXPLODE_2, " + QUOTE(ARRAY),A,B) + +#define EXPLODE_3_SYS(ARRAY,A,B,C) EXPLODE_2_SYS(ARRAY,A,B); C = ARRAY param [2] +#define EXPLODE_3(ARRAY,A,B,C) EXPLODE_3_SYS(ARRAY,A,B,C); TRACE_3("EXPLODE_3, " + QUOTE(ARRAY),A,B,C) +#define EXPLODE_3_PVT(ARRAY,A,B,C) ARRAY params [#A,#B,#C]; TRACE_3("EXPLODE_3, " + QUOTE(ARRAY),A,B,C) + +#define EXPLODE_4_SYS(ARRAY,A,B,C,D) EXPLODE_3_SYS(ARRAY,A,B,C); D = ARRAY param [3] +#define EXPLODE_4(ARRAY,A,B,C,D) EXPLODE_4_SYS(ARRAY,A,B,C,D); TRACE_4("EXPLODE_4, " + QUOTE(ARRAY),A,B,C,D) +#define EXPLODE_4_PVT(ARRAY,A,B,C,D) ARRAY params [#A,#B,#C,#D]; TRACE_4("EXPLODE_4, " + QUOTE(ARRAY),A,B,C,D) + +#define EXPLODE_5_SYS(ARRAY,A,B,C,D,E) EXPLODE_4_SYS(ARRAY,A,B,C,D); E = ARRAY param [4] +#define EXPLODE_5(ARRAY,A,B,C,D,E) EXPLODE_5_SYS(ARRAY,A,B,C,D,E); TRACE_5("EXPLODE_5, " + QUOTE(ARRAY),A,B,C,D,E) +#define EXPLODE_5_PVT(ARRAY,A,B,C,D,E) ARRAY params [#A,#B,#C,#D,#E]; TRACE_5("EXPLODE_5, " + QUOTE(ARRAY),A,B,C,D,E) + +#define EXPLODE_6_SYS(ARRAY,A,B,C,D,E,F) EXPLODE_5_SYS(ARRAY,A,B,C,D,E); F = ARRAY param [5] +#define EXPLODE_6(ARRAY,A,B,C,D,E,F) EXPLODE_6_SYS(ARRAY,A,B,C,D,E,F); TRACE_6("EXPLODE_6, " + QUOTE(ARRAY),A,B,C,D,E,F) +#define EXPLODE_6_PVT(ARRAY,A,B,C,D,E,F) ARRAY params [#A,#B,#C,#D,#E,#F]; TRACE_6("EXPLODE_6, " + QUOTE(ARRAY),A,B,C,D,E,F) + +#define EXPLODE_7_SYS(ARRAY,A,B,C,D,E,F,G) EXPLODE_6_SYS(ARRAY,A,B,C,D,E,F); G = ARRAY param [6] +#define EXPLODE_7(ARRAY,A,B,C,D,E,F,G) EXPLODE_7_SYS(ARRAY,A,B,C,D,E,F,G); TRACE_7("EXPLODE_7, " + QUOTE(ARRAY),A,B,C,D,E,F,G) +#define EXPLODE_7_PVT(ARRAY,A,B,C,D,E,F,G) ARRAY params [#A,#B,#C,#D,#E,#F,#G]; TRACE_7("EXPLODE_7, " + QUOTE(ARRAY),A,B,C,D,E,F,G) + +#define EXPLODE_8_SYS(ARRAY,A,B,C,D,E,F,G,H) EXPLODE_7_SYS(ARRAY,A,B,C,D,E,F,G); H = ARRAY param [7] +#define EXPLODE_8(ARRAY,A,B,C,D,E,F,G,H) EXPLODE_8_SYS(ARRAY,A,B,C,D,E,F,G,H); TRACE_8("EXPLODE_8, " + QUOTE(ARRAY),A,B,C,D,E,F,G,H) +#define EXPLODE_8_PVT(ARRAY,A,B,C,D,E,F,G,H) ARRAY params [#A,#B,#C,#D,#E,#F,#G,#H]; TRACE_8("EXPLODE_8, " + QUOTE(ARRAY),A,B,C,D,E,F,G,H) + +#define EXPLODE_9_SYS(ARRAY,A,B,C,D,E,F,G,H,I) EXPLODE_8_SYS(ARRAY,A,B,C,D,E,F,G,H); I = ARRAY param [8] +#define EXPLODE_9(ARRAY,A,B,C,D,E,F,G,H,I) EXPLODE_9_SYS(ARRAY,A,B,C,D,E,F,G,H,I); TRACE_9("EXPLODE_9, " + QUOTE(ARRAY),A,B,C,D,E,F,G,H,I) +#define EXPLODE_9_PVT(ARRAY,A,B,C,D,E,F,G,H,I) ARRAY params [#A,#B,#C,#D,#E,#F,#G,#H,#I]; TRACE_9("EXPLODE_9, " + QUOTE(ARRAY),A,B,C,D,E,F,G,H,I) + +/* ------------------------------------------- +Macro: xSTRING() + Get full string identifier from a stringtable owned by this component. + +Parameters: + VARIABLE - Partial name of global variable owned by this component [Any]. + +Example: + ADDON is CBA_Balls. + (begin example) + // Localized String (localize command must still be used with it) + LSTRING(Example); // STR_CBA_Balls_Example; + // Config String (note the $) + CSTRING(Example); // $STR_CBA_Balls_Example; + (end) + +Author: + Jonpas +------------------------------------------- */ +#ifndef STRING_MACROS_GUARD +#define STRING_MACROS_GUARD + #define LSTRING(var1) QUOTE(TRIPLES(STR,ADDON,var1)) + #define ELSTRING(var1,var2) QUOTE(TRIPLES(STR,DOUBLES(PREFIX,var1),var2)) + #define CSTRING(var1) QUOTE(TRIPLES($STR,ADDON,var1)) + #define ECSTRING(var1,var2) QUOTE(TRIPLES($STR,DOUBLES(PREFIX,var1),var2)) + #define SUBCSTRING(var1) QUOTE(TRIPLES($STR,SUBADDON,var1)) + + #define LLSTRING(var1) localize QUOTE(TRIPLES(STR,ADDON,var1)) + #define LELSTRING(var1,var2) localize QUOTE(TRIPLES(STR,DOUBLES(PREFIX,var1),var2)) + #define LSUBLSTRING(var1) localize QUOTE(TRIPLES(STR,SUBADDON,var1)) +#endif + + +/* ------------------------------------------- +Group: Managing Function Parameters +------------------------------------------- */ + +/* ------------------------------------------- +Macros: PARAMS_n() + DEPRECATED - Use param/params commands added in Arma 3 1.48 + + Setting variables based on parameters passed to a function. + + Each parameter is defines as private and set to the appropriate value from _this. + + PARAMS_1(A) - Get 1 parameter from the _this array (or _this if it's not an array). + PARAMS_2(A,B) - Get 2 parameters from the _this array. + PARAMS_3(A,B,C) - Get 3 parameters from the _this array. + PARAMS_4(A,B,C,D) - Get 4 parameters from the _this array. + PARAMS_5(A,B,C,D,E) - Get 5 parameters from the _this array. + PARAMS_6(A,B,C,D,E,F) - Get 6 parameters from the _this array. + PARAMS_7(A,B,C,D,E,F,G) - Get 7 parameters from the _this array. + PARAMS_8(A,B,C,D,E,F,G,H) - Get 8 parameters from the _this array. + +Parameters: + A..H - Name of variable to read from _this [Identifier] + +Example: + A function called like this: + (begin example) + [_name,_address,_telephone] call recordPersonalDetails; + (end) + expects 3 parameters and those variables could be initialised at the start of the function definition with: + (begin example) + recordPersonalDetails = { + PARAMS_3(_name,_address,_telephone); + // Rest of function follows... + }; + (end) + +Author: + Spooner +------------------------------------------- */ +#define PARAMS_1(A) EXPLODE_1_PVT(_this,A) +#define PARAMS_2(A,B) EXPLODE_2_PVT(_this,A,B) +#define PARAMS_3(A,B,C) EXPLODE_3_PVT(_this,A,B,C) +#define PARAMS_4(A,B,C,D) EXPLODE_4_PVT(_this,A,B,C,D) +#define PARAMS_5(A,B,C,D,E) EXPLODE_5_PVT(_this,A,B,C,D,E) +#define PARAMS_6(A,B,C,D,E,F) EXPLODE_6_PVT(_this,A,B,C,D,E,F) +#define PARAMS_7(A,B,C,D,E,F,G) EXPLODE_7_PVT(_this,A,B,C,D,E,F,G) +#define PARAMS_8(A,B,C,D,E,F,G,H) EXPLODE_8_PVT(_this,A,B,C,D,E,F,G,H) +#define PARAMS_9(A,B,C,D,E,F,G,H,I) EXPLODE_9_PVT(_this,A,B,C,D,E,F,G,H,I) + +/* ------------------------------------------- +Macro: DEFAULT_PARAM() + DEPRECATED - Use param/params commands added in Arma 3 1.48 + + Getting a default function parameter. This may be used together with to have a mix of required and + optional parameters. + +Parameters: + INDEX - Index of parameter in _this [Integer, 0+] + NAME - Name of the variable to set [Identifier] + DEF_VALUE - Default value to use in case the array is too short or the value at INDEX is nil [Any] + +Example: + A function called with optional parameters: + (begin example) + [_name] call myFunction; + [_name, _numberOfLegs] call myFunction; + [_name, _numberOfLegs, _hasAHead] call myFunction; + (end) + 1 required parameter and 2 optional parameters. Those variables could be initialised at the start of the function + definition with: + (begin example) + myFunction = { + PARAMS_1(_name); + DEFAULT_PARAM(1,_numberOfLegs,2); + DEFAULT_PARAM(2,_hasAHead,true); + // Rest of function follows... + }; + (end) + +Author: + Spooner +------------------------------------------- */ +#define DEFAULT_PARAM(INDEX,NAME,DEF_VALUE) \ + private [#NAME,"_this"]; \ + ISNILS(_this,[]); \ + NAME = _this param [INDEX, DEF_VALUE]; \ + TRACE_3("DEFAULT_PARAM",INDEX,NAME,DEF_VALUE) + +/* ------------------------------------------- +Macro: KEY_PARAM() + Get value from key in _this list, return default when key is not included in list. + +Parameters: + KEY - Key name [String] + NAME - Name of the variable to set [Identifier] + DEF_VALUE - Default value to use in case key not found [ANY] + +Example: + + +Author: + Muzzleflash +------------------------------------------- */ +#define KEY_PARAM(KEY,NAME,DEF_VALUE) \ + private #NAME; \ + NAME = [toLower KEY, toUpper KEY, DEF_VALUE, RETNIL(_this)] call CBA_fnc_getArg; \ + TRACE_3("KEY_PARAM",KEY,NAME,DEF_VALUE) + +/* ------------------------------------------- +Group: Assertions +------------------------------------------- */ + +#define ASSERTION_ERROR(MESSAGE) ERROR_WITH_TITLE("Assertion failed!",MESSAGE) + +/* ------------------------------------------- +Macro: ASSERT_TRUE() + Asserts that a CONDITION is true. When an assertion fails, an error is raised with the given MESSAGE. + +Parameters: + CONDITION - Condition to assert as true [Boolean] + MESSSAGE - Message to display if (A OPERATOR B) is false [String] + +Example: + (begin example) + ASSERT_TRUE(_frogIsDead,"The frog is alive"); + (end) + +Author: + Spooner +------------------------------------------- */ +#define ASSERT_TRUE(CONDITION,MESSAGE) \ + if (not (CONDITION)) then \ + { \ + ASSERTION_ERROR('Assertion (CONDITION) failed!\n\n' + (MESSAGE)); \ + } + +/* ------------------------------------------- +Macro: ASSERT_FALSE() + Asserts that a CONDITION is false. When an assertion fails, an error is raised with the given MESSAGE. + +Parameters: + CONDITION - Condition to assert as false [Boolean] + MESSSAGE - Message to display if (A OPERATOR B) is true [String] + +Example: + (begin example) + ASSERT_FALSE(_frogIsDead,"The frog died"); + (end) + +Author: + Spooner +------------------------------------------- */ +#define ASSERT_FALSE(CONDITION,MESSAGE) \ + if (CONDITION) then \ + { \ + ASSERTION_ERROR('Assertion (not (CONDITION)) failed!\n\n' + (MESSAGE)) \ + } + +/* ------------------------------------------- +Macro: ASSERT_OP() + Asserts that (A OPERATOR B) is true. When an assertion fails, an error is raised with the given MESSAGE. + +Parameters: + A - First value [Any] + OPERATOR - Binary operator to use [Operator] + B - Second value [Any] + MESSSAGE - Message to display if (A OPERATOR B) is false. [String] + +Example: + (begin example) + ASSERT_OP(_fish,>,5,"Too few fish!"); + (end) + +Author: + Spooner +------------------------------------------- */ +#define ASSERT_OP(A,OPERATOR,B,MESSAGE) \ + if (not ((A) OPERATOR (B))) then \ + { \ + ASSERTION_ERROR('Assertion (A OPERATOR B) failed!\n' + 'A: ' + (str (A)) + '\n' + 'B: ' + (str (B)) + "\n\n" + (MESSAGE)); \ + } + +/* ------------------------------------------- +Macro: ASSERT_DEFINED() + Asserts that a VARIABLE is defined. When an assertion fails, an error is raised with the given MESSAGE.. + +Parameters: + VARIABLE - Variable to test if defined [String or Function]. + MESSAGE - Message to display if variable is undefined [String]. + +Examples: + (begin example) + ASSERT_DEFINED("_anUndefinedVar","Too few fish!"); + ASSERT_DEFINED({ obj getVariable "anUndefinedVar" },"Too many fish!"); + (end) + +Author: + Spooner +------------------------------------------- */ +#define ASSERT_DEFINED(VARIABLE,MESSAGE) \ + if (isNil VARIABLE) then \ + { \ + ASSERTION_ERROR('Assertion (VARIABLE is defined) failed!\n\n' + (MESSAGE)); \ + } + +/* ------------------------------------------- +Group: Unit tests +------------------------------------------- */ +#define TEST_SUCCESS(MESSAGE) MESSAGE_WITH_TITLE("Test OK",MESSAGE) +#define TEST_FAIL(MESSAGE) ERROR_WITH_TITLE("Test FAIL",MESSAGE) + +/* ------------------------------------------- +Macro: TEST_TRUE() + Tests that a CONDITION is true. + If the condition is not true, an error is raised with the given MESSAGE. + +Parameters: + CONDITION - Condition to assert as true [Boolean] + MESSSAGE - Message to display if (A OPERATOR B) is false [String] + +Example: + (begin example) + TEST_TRUE(_frogIsDead,"The frog is alive"); + (end) + +Author: + Killswitch +------------------------------------------- */ +#define TEST_TRUE(CONDITION, MESSAGE) \ + if (CONDITION) then \ + { \ + TEST_SUCCESS('(CONDITION)'); \ + } \ + else \ + { \ + TEST_FAIL('(CONDITION) ' + (MESSAGE)); \ + } + +/* ------------------------------------------- +Macro: TEST_FALSE() + Tests that a CONDITION is false. + If the condition is not false, an error is raised with the given MESSAGE. + +Parameters: + CONDITION - Condition to test as false [Boolean] + MESSSAGE - Message to display if (A OPERATOR B) is true [String] + +Example: + (begin example) + TEST_FALSE(_frogIsDead,"The frog died"); + (end) + +Author: + Killswitch +------------------------------------------- */ +#define TEST_FALSE(CONDITION, MESSAGE) \ + if (not (CONDITION)) then \ + { \ + TEST_SUCCESS('(not (CONDITION))'); \ + } \ + else \ + { \ + TEST_FAIL('(not (CONDITION)) ' + (MESSAGE)); \ + } + +/* ------------------------------------------- +Macro: TEST_OP() + Tests that (A OPERATOR B) is true. + If the test fails, an error is raised with the given MESSAGE. + +Parameters: + A - First value [Any] + OPERATOR - Binary operator to use [Operator] + B - Second value [Any] + MESSSAGE - Message to display if (A OPERATOR B) is false. [String] + +Example: + (begin example) + TEST_OP(_fish,>,5,"Too few fish!"); + (end) + +Author: + Killswitch +------------------------------------------- */ +#define TEST_OP(A,OPERATOR,B,MESSAGE) \ + if ((A) OPERATOR (B)) then \ + { \ + TEST_SUCCESS('(A OPERATOR B)') \ + } \ + else \ + { \ + TEST_FAIL('(A OPERATOR B)') \ + }; + +/* ------------------------------------------- +Macro: TEST_DEFINED_AND_OP() + Tests that A and B are defined and (A OPERATOR B) is true. + If the test fails, an error is raised with the given MESSAGE. + +Parameters: + A - First value [Any] + OPERATOR - Binary operator to use [Operator] + B - Second value [Any] + MESSSAGE - Message to display [String] + +Example: + (begin example) + TEST_OP(_fish,>,5,"Too few fish!"); + (end) + +Author: + Killswitch, PabstMirror +------------------------------------------- */ +#define TEST_DEFINED_AND_OP(A,OPERATOR,B,MESSAGE) \ + if (isNil #A) then { \ + TEST_FAIL('(A is not defined) ' + (MESSAGE)); \ + } else { \ + if (isNil #B) then { \ + TEST_FAIL('(B is not defined) ' + (MESSAGE)); \ + } else { \ + if ((A) OPERATOR (B)) then { \ + TEST_SUCCESS('(A OPERATOR B) ' + (MESSAGE)) \ + } else { \ + TEST_FAIL('(A OPERATOR B) ' + (MESSAGE)) \ + }; }; }; + + +/* ------------------------------------------- +Macro: TEST_DEFINED() + Tests that a VARIABLE is defined. + +Parameters: + VARIABLE - Variable to test if defined [String or Function]. + MESSAGE - Message to display if variable is undefined [String]. + +Examples: + (begin example) + TEST_DEFINED("_anUndefinedVar","Too few fish!"); + TEST_DEFINED({ obj getVariable "anUndefinedVar" },"Too many fish!"); + (end) + +Author: + Killswitch +------------------------------------------- */ +#define TEST_DEFINED(VARIABLE,MESSAGE) \ + if (not isNil VARIABLE) then \ + { \ + TEST_SUCCESS('(' + VARIABLE + ' is defined)'); \ + } \ + else \ + { \ + TEST_FAIL('(' + VARIABLE + ' is not defined)' + (MESSAGE)); \ + } + +/* ------------------------------------------- +Group: Managing Deprecation +------------------------------------------- */ + +/* ------------------------------------------- +Macro: DEPRECATE_SYS() + Allow deprecation of a function that has been renamed. + + Replaces an old OLD_FUNCTION (which will have PREFIX_ prepended) with a NEW_FUNCTION + (PREFIX_ prepended) with the intention that the old function will be disabled in the future. + + Shows a warning in RPT each time the deprecated function is used, but runs the new function. + +Parameters: + OLD_FUNCTION - Full name of old function [Identifier for function that does not exist any more] + NEW_FUNCTION - Full name of new function [Function] + +Example: + (begin example) + // After renaming CBA_fnc_frog as CBA_fnc_fish + DEPRECATE_SYS(CBA_fnc_frog,CBA_fnc_fish); + (end) + +Author: + Sickboy +------------------------------------------- */ +#define DEPRECATE_SYS(OLD_FUNCTION,NEW_FUNCTION) \ + OLD_FUNCTION = { \ + WARNING('Deprecated function used: OLD_FUNCTION (new: NEW_FUNCTION) in ADDON'); \ + if (isNil "_this") then { call NEW_FUNCTION } else { _this call NEW_FUNCTION }; \ + } + +/* ------------------------------------------- +Macro: DEPRECATE() + Allow deprecation of a function, in the current component, that has been renamed. + + Replaces an OLD_FUNCTION (which will have PREFIX_ prepended) with a NEW_FUNCTION + (PREFIX_ prepended) with the intention that the old function will be disabled in the future. + + Shows a warning in RPT each time the deprecated function is used, but runs the new function. + +Parameters: + OLD_FUNCTION - Name of old function, assuming PREFIX [Identifier for function that does not exist any more] + NEW_FUNCTION - Name of new function, assuming PREFIX [Function] + +Example: + (begin example) + // After renaming CBA_fnc_frog as CBA_fnc_fish + DEPRECATE(fnc_frog,fnc_fish); + (end) + +Author: + Sickboy +------------------------------------------- */ +#define DEPRECATE(OLD_FUNCTION,NEW_FUNCTION) \ + DEPRECATE_SYS(DOUBLES(PREFIX,OLD_FUNCTION),DOUBLES(PREFIX,NEW_FUNCTION)) + +/* ------------------------------------------- +Macro: OBSOLETE_SYS() + Replace a function that has become obsolete. + + Replace an obsolete OLD_FUNCTION with a simple COMMAND_FUNCTION, with the intention that anyone + using the function should replace it with the simple command, since the function will be disabled in the future. + + Shows a warning in RPT each time the deprecated function is used, and runs the command function. + +Parameters: + OLD_FUNCTION - Full name of old function [Identifier for function that does not exist any more] + COMMAND_CODE - Code to replace the old function [Function] + +Example: + (begin example) + // In Arma2, currentWeapon command made the CBA_fMyWeapon function obsolete: + OBSOLETE_SYS(CBA_fMyWeapon,{ currentWeapon player }); + (end) + +Author: + Spooner +------------------------------------------- */ +#define OBSOLETE_SYS(OLD_FUNCTION,COMMAND_CODE) \ + OLD_FUNCTION = { \ + WARNING('Obsolete function used: (use: OLD_FUNCTION) in ADDON'); \ + if (isNil "_this") then { call COMMAND_CODE } else { _this call COMMAND_CODE }; \ + } + +/* ------------------------------------------- +Macro: OBSOLETE() + Replace a function, in the current component, that has become obsolete. + + Replace an obsolete OLD_FUNCTION (which will have PREFIX_ prepended) with a simple + COMMAND_CODE, with the intention that anyone using the function should replace it with the simple + command. + + Shows a warning in RPT each time the deprecated function is used. + +Parameters: + OLD_FUNCTION - Name of old function, assuming PREFIX [Identifier for function that does not exist any more] + COMMAND_CODE - Code to replace the old function [Function] + +Example: + (begin example) + // In Arma2, currentWeapon command made the CBA_fMyWeapon function obsolete: + OBSOLETE(fMyWeapon,{ currentWeapon player }); + (end) + +Author: + Spooner +------------------------------------------- */ +#define OBSOLETE(OLD_FUNCTION,COMMAND_CODE) \ + OBSOLETE_SYS(DOUBLES(PREFIX,OLD_FUNCTION),COMMAND_CODE) + +#define BWC_CONFIG(NAME) class NAME { \ + units[] = {}; \ + weapons[] = {}; \ + requiredVersion = REQUIRED_VERSION; \ + requiredAddons[] = {}; \ + version = VERSION; \ +} + +// XEH Specific +#define XEH_CLASS CBA_Extended_EventHandlers +#define XEH_CLASS_BASE DOUBLES(XEH_CLASS,base) +#define XEH_DISABLED class EventHandlers { class XEH_CLASS {}; }; SLX_XEH_DISABLED = 1 +#define XEH_ENABLED class EventHandlers { class XEH_CLASS { EXTENDED_EVENTHANDLERS }; }; SLX_XEH_DISABLED = 0 + +// TODO: These are actually outdated; _Once ? +#define XEH_PRE_INIT QUOTE(call COMPILE_FILE(XEH_PreInit_Once)) +#define XEH_PRE_CINIT QUOTE(call COMPILE_FILE(XEH_PreClientInit_Once)) +#define XEH_PRE_SINIT QUOTE(call COMPILE_FILE(XEH_PreServerInit_Once)) + +#define XEH_POST_INIT QUOTE(call COMPILE_FILE(XEH_PostInit_Once)) +#define XEH_POST_CINIT QUOTE(call COMPILE_FILE(XEH_PostClientInit_Once)) +#define XEH_POST_SINIT QUOTE(call COMPILE_FILE(XEH_PostServerInit_Once)) + +/* ------------------------------------------- +Macro: IS_ADMIN + Check if the local machine is an admin in the multiplayer environment. + + Reports 'true' for logged and voted in admins. + +Parameters: + None + +Example: + (begin example) + // print "true" if player is admin + systemChat str IS_ADMIN; + (end) + +Author: + commy2 +------------------------------------------- */ +#define IS_ADMIN_SYS(x) x##kick +#define IS_ADMIN serverCommandAvailable 'IS_ADMIN_SYS(#)' + +/* ------------------------------------------- +Macro: IS_ADMIN_LOGGED + Check if the local machine is a logged in admin in the multiplayer environment. + + Reports 'false' if the player was voted to be the admin. + +Parameters: + None + +Example: + (begin example) + // print "true" if player is admin and entered in the server password + systemChat str IS_ADMIN_LOGGED; + (end) + +Author: + commy2 +------------------------------------------- */ +#define IS_ADMIN_LOGGED_SYS(x) x##shutdown +#define IS_ADMIN_LOGGED serverCommandAvailable 'IS_ADMIN_LOGGED_SYS(#)' + +/* ------------------------------------------- +Macro: FILE_EXISTS + Check if a file exists + + Reports "false" if the file does not exist. + +Parameters: + FILE - Path to the file + +Example: + (begin example) + // print "true" if file exists + systemChat str FILE_EXISTS("\A3\ui_f\data\igui\cfg\cursors\weapon_ca.paa"); + (end) + +Author: + commy2 +------------------------------------------- */ +#define FILE_EXISTS(FILE) (fileExists (FILE)) \ No newline at end of file diff --git a/framework/x/cba/addons/main/script_macros_mission.hpp b/framework/x/cba/addons/main/script_macros_mission.hpp new file mode 100644 index 0000000..d2eae33 --- /dev/null +++ b/framework/x/cba/addons/main/script_macros_mission.hpp @@ -0,0 +1,85 @@ +#include "script_macros_common.hpp" + +/* + Header: script_macros_mission.hpp + + Description: + Modifies script_common_macros.hpp for compatiblity with missions. + Some addon specific functionality might be lost. + + Authors: + Muzzleflash + + Changes from script_macros_mission.hpp: + Follows Standard: + Object variables: PREFIX_COMPONENT + Main-object variables: PREFIX_main + Paths: PREFIX\COMPONENT\SCRIPTNAME.sqf + Or if CUSTOM_FOLDER is defined: + CUSTOM_FOLDER\SCRIPTNAME.sqf + eg. six\sys_menu\fDate.sqf + + Usage: + Define PREFIX and COMPONENT, then include this file: + + +*/ + +/* + CUSTOM_FOLDER + + Custom folder to search for files in. Will not change variable names. + Default is PREFIX\COMPONENT + + Example: + (begin example) + #define CUSTOM_FOLDER MyPackage\ScriptA + (end) + + (begin example) + #define CUSTOM_FOLDER COMPONENT\functions + (end) + + +*/ + +#undef PATHTO_SYS +#undef PATHTOF_SYS +#undef PATHTOF2_SYS +#ifdef CUSTOM_FOLDER + #define PATHTO_SYS(var1,var2,var3) ##CUSTOM_FOLDER\##var3.sqf + #define PATHTOF_SYS(var1,var2,var3) ##CUSTOM_FOLDER\##var3 + #define PATHTOF2_SYS(var1,var2,var3) ##CUSTOM_FOLDER\##var3 +#else + #define PATHTO_SYS(var1,var2,var3) ##var1\##var2\##var3.sqf + #define PATHTOF_SYS(var1,var2,var3) ##var1\##var2\##var3 + #define PATHTOF2_SYS(var1,var2,var3) ##var1\##var2\##var3 +#endif + +/************************** REMOVAL OF MACROS ***********************/ + +#undef MAINPREFIX +#undef SUBPREFIX +#undef VERSION_AR +#undef VERSION_CONFIG + +#undef VERSIONING_SYS +#undef VERSIONING + +#undef PRELOAD_ADDONS + +#undef BWC_CONFIG + +#undef XEH_DISABLED +#undef XEH_PRE_INIT +#undef XEH_PRE_CINIT +#undef XEH_PRE_SINIT +#undef XEH_POST_INIT +#undef XEH_POST_CINIT +#undef XEH_POST_SINIT + +#undef PATHTO_FNC +#define PATHTO_FNC(func) class func {\ + file = QUOTE(DOUBLES(fnc,func).sqf);\ + RECOMPILE;\ +} \ No newline at end of file -- 2.37.3.windows.1 From f588ffa4a063588c5145b8de048d4e34c3506b90 Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Mon, 5 Feb 2024 17:42:31 -0800 Subject: [PATCH 12/16] many changes. includes rework of baselocation-asset storage format --- defines/BattalionInfo.hpp | 4 +- description.ext | 7 +- framework/CfgFunctions.hpp | 270 +++++++++--------- framework/fbcb2/fn_hintFBCB2AssetStatus.sqf | 31 -- framework/fbcb2/fn_initFBCB2.sqf | 39 --- framework/fbcb2/util/fn_removeDiaryRecord.sqf | 0 .../functions/fn_addCBASettings.sqf | 12 +- .../functions/fn_getAssetsByBase.sqf | 6 +- .../functions/fn_getCallsignFromClassname.sqf | 15 + .../fn_getStartingAndCurrentAssets.sqf | 17 ++ .../functions/fn_getStartingAssetsByBase.sqf | 6 +- .../functions/fn_getVehicleData.sqf | 2 +- .../functions/fn_hintAllApprovedAssets.sqf | 93 ++++++ .../functions/fn_isAssetInRangeOfBase.sqf | 8 + .../functions/fn_removeAssetDiaryRecords.sqf | 8 +- .../functions/fn_removeMarkersOnMap.sqf | 11 +- .../functions/fn_showMarkersOnMap.sqf | 25 +- .../functions/fn_updateAssetDiary.sqf | 214 +++++++++----- .../functions/fn_updateAssetsByBase.sqf | 71 ++--- framework/fbcb2_main/functions/fn_init.sqf | 39 +++ .../functions}/fn_processFBCB2Environment.sqf | 20 +- .../fn_processFBCB2RadioFrequencies.sqf | 37 ++- .../functions}/fn_processFBCB2SmokeColors.sqf | 14 +- framework/fbcb2_main/script_component.hpp | 3 + .../util/fn_createOrUpdateDiaryRecord.sqf | 8 +- .../util}/fn_formatRadioElementForDiary.sqf | 6 +- .../fn_generateElementFrequencyRecordText.sqf | 31 +- framework/init/functions/fn_initServer.sqf | 2 +- framework/reinsert/script_component.hpp | 3 + .../resupply/functions/fn_addCBASettings.sqf | 8 +- .../functions/fn_getApprovedAssetsCfg.sqf | 14 + .../util/functions/fn_getBattalionCfg.sqf | 15 +- 32 files changed, 657 insertions(+), 382 deletions(-) delete mode 100644 framework/fbcb2/fn_hintFBCB2AssetStatus.sqf delete mode 100644 framework/fbcb2/fn_initFBCB2.sqf delete mode 100644 framework/fbcb2/util/fn_removeDiaryRecord.sqf create mode 100644 framework/fbcb2_assets/functions/fn_getCallsignFromClassname.sqf create mode 100644 framework/fbcb2_assets/functions/fn_getStartingAndCurrentAssets.sqf create mode 100644 framework/fbcb2_assets/functions/fn_hintAllApprovedAssets.sqf create mode 100644 framework/fbcb2_assets/functions/fn_isAssetInRangeOfBase.sqf create mode 100644 framework/fbcb2_main/functions/fn_init.sqf rename framework/{fbcb2 => fbcb2_main/functions}/fn_processFBCB2Environment.sqf (72%) rename framework/{fbcb2 => fbcb2_main/functions}/fn_processFBCB2RadioFrequencies.sqf (63%) rename framework/{fbcb2 => fbcb2_main/functions}/fn_processFBCB2SmokeColors.sqf (78%) create mode 100644 framework/fbcb2_main/script_component.hpp rename framework/{fbcb2 => fbcb2_main}/util/fn_createOrUpdateDiaryRecord.sqf (72%) rename framework/{fbcb2/radioFrequencies => fbcb2_main/util}/fn_formatRadioElementForDiary.sqf (91%) rename framework/{fbcb2/radioFrequencies => fbcb2_main/util}/fn_generateElementFrequencyRecordText.sqf (77%) create mode 100644 framework/reinsert/script_component.hpp create mode 100644 framework/util/functions/fn_getApprovedAssetsCfg.sqf diff --git a/defines/BattalionInfo.hpp b/defines/BattalionInfo.hpp index 52ab77a..58920bc 100644 --- a/defines/BattalionInfo.hpp +++ b/defines/BattalionInfo.hpp @@ -229,8 +229,8 @@ class BattalionInfo { }; }; - class Attack { - callsign = CALLSIGN_ELEMENT(ECHO_CALLSIGN, ATTACK); + class Armor { + callsign = CALLSIGN_ELEMENT(ECHO_CALLSIGN, ARMOR); textColor = LVL4_TEXT_COLOR; frequencies[] = { {"Contact", {}, {FREQ_ECHO_GROUND, FREQ_ECHO_FLIGHT_CAS}}, diff --git a/description.ext b/description.ext index 558a08f..6355ab9 100644 --- a/description.ext +++ b/description.ext @@ -93,10 +93,9 @@ class Params }; -class cfgFunctions -{ - #include "framework\CfgFunctions.hpp" -}; +// CfgFunctions +#include "framework\CfgFunctions.hpp" + class CfgDebriefingSections { diff --git a/framework/CfgFunctions.hpp b/framework/CfgFunctions.hpp index 76ade6b..b2690ff 100644 --- a/framework/CfgFunctions.hpp +++ b/framework/CfgFunctions.hpp @@ -1,146 +1,158 @@ #include "script_mod.hpp" -class PREFIX -{ - class settings - { - file = "framework\settings"; - class setDefaults { postInit = 1; }; - class addCBASettings { postInit = 1; }; - class addAARChatHandler { postInit = 1; }; - class addRespawnChatHandler { postInit = 1; }; +class CfgFunctions { + class PREFIX + { + class settings + { + file = "framework\settings"; + class setDefaults { postInit = 1; }; + class addCBASettings { preInit = 1; }; + class addAARChatHandler { postInit = 1; }; + class addRespawnChatHandler { postInit = 1; }; + }; + + class init + { + file = "framework\init\functions"; + class initServer { postInit = 1;}; //needs refactor + class initPlayerLocal { postInit = 1;}; + }; + + class client { + file = "framework\client"; + class addZenModules { postInit = 1; }; + class addDNI_PlayerFPS { postInit = 1; }; // needs refactor + class bindEventHandlers { postInit = 1; }; + class bindVehicleActions { postInit = 1; }; + class addClientStatsPFH {}; + class addMedicalOverlayPFH { postInit = 1; }; + class calculateClientStats {}; + class bindEmptyGroupGarbageCleanup { postInit = 1; }; + }; + + class server { + file = "framework\server"; + class addServerStatsPFH {}; + class calculateServerStats {}; + class logPlayerInventory {}; + }; + + class ambience { + file = "framework\ambience"; + class flakInitVehicle {}; + class flakEH {}; + }; + + class map + { + file = "framework\map"; + class initMapCopy { postInit = 1; }; + class copyMapFromPlayer {}; //needs refactor + class getPlayerMapMarkers {}; //needs refactor + class loadMapMarkers {}; //needs refactor + class mapMarkerToString {}; //needs refactor + class stringToMapMarker {}; //needs refactor + }; }; - class init - { - file = "framework\init\functions"; - class initServer { postInit = 1;}; //needs refactor - class initPlayerLocal { postInit = 1;}; + + + class DOUBLES(PREFIX,fbcb2_assets) { + class functions { + file = "framework\fbcb2_assets\functions"; + class addCBASettings {preInit=1;}; + class initClient {postInit=1;}; + class initServer {postInit=1;}; + class getAssetsByBase {}; + class getInventory {}; + class getMagsForWeapon {}; + class getStartingAssetsByBase {}; + class getVehicleData {}; + class getWeaponry {}; + class hintAllApprovedAssets {}; + class removeAssetDiaryRecords {}; + class removeMarkersOnMap {}; + class showMarkersOnMap {}; + class updateAssetDiary {}; + class updateAssetsByBase {}; + class getCallsignFromClassname {}; + class getStartingAndCurrentAssets {}; + class isAssetInRangeOfBase {}; + }; }; - class fbcb2 { - file = "framework\fbcb2"; - class initFBCB2 { postInit = 1; }; - class processFBCB2RadioFrequencies {}; - class processFBCB2SmokeColors {}; - class processFBCB2Environment {}; - class hintFBCB2AssetStatus {}; - }; - class fbcb2_util { - file = "framework\fbcb2\util"; - class createOrUpdateDiaryRecord {}; - }; - class fbcb2_radioFrequencies { - file = "framework\fbcb2\radioFrequencies"; - class formatRadioElementForDiary {}; - class generateElementFrequencyRecordText {}; + class DOUBLES(PREFIX,fbcb2_main) { + class functions { + file = "framework\fbcb2_main\functions"; + class init { postInit = 1; }; + + class processFBCB2Environment {}; + class processFBCB2RadioFrequencies {}; + class processFBCB2SmokeColors {}; + }; + class util { + file = "framework\fbcb2_main\util"; + class createOrUpdateDiaryRecord {}; + class formatRadioElementForDiary {}; + class generateElementFrequencyRecordText {}; + }; }; - class client { - file = "framework\client"; - class addZenModules { postInit = 1; }; - class addDNI_PlayerFPS { postInit = 1; }; // needs refactor - class bindEventHandlers { postInit = 1; }; - class bindVehicleActions { postInit = 1; }; - class addClientStatsPFH {}; - class addMedicalOverlayPFH { postInit = 1; }; - class calculateClientStats {}; - class bindEmptyGroupGarbageCleanup { postInit = 1; }; + class DOUBLES(PREFIX,reinsert) { + class server { + file = "framework\reinsert\server"; + class initServer { postInit = 1; }; + class addToQueue {}; + class globalShowQueue {}; + class removeFromQueue {}; + class returnReinsertQueueNotification {}; + class validateQueue {}; + }; + class client { + file = "framework\reinsert\client"; + class initClient { postInit = 1; }; + class addAceSelfActions {}; + class addCheckQueueSelfAction {}; + class requestShowQueue {}; + }; }; - class server { - file = "framework\server"; - class addServerStatsPFH {}; - class calculateServerStats {}; - class logPlayerInventory {}; + class DOUBLES(PREFIX,resupply) { + class functions { + file = "framework\resupply\functions"; + class addCBASettings {preInit=1;}; + class init {postInit=1;}; + class createBox {}; + class getSupplyCratesCfg {}; + class addArsenalObjectSpawnBoxActions {}; + }; }; - class ambience { - file = "framework\ambience"; - class flakInitVehicle {}; - class flakEH {}; + class DOUBLES(PREFIX,util) { + class functions { + file = "framework\util\functions"; + class logMissionInfo { postInit = 1; }; + class addPlayerInfoToArray {}; + class log {}; + class padString {}; + class recurseSubclasses {}; + class getBattalionCfg {}; + class getNameOfBase {}; + class getNearestBase {}; + class getApprovedAssetsCfg {}; + }; }; - class map - { - file = "framework\map"; - class initMapCopy { postInit = 1; }; - class copyMapFromPlayer {}; //needs refactor - class getPlayerMapMarkers {}; //needs refactor - class loadMapMarkers {}; //needs refactor - class mapMarkerToString {}; //needs refactor - class stringToMapMarker {}; //needs refactor + class DOUBLES(PREFIX,vehicleFlags) { + class functions { + file = "framework\vehicleFlags\functions"; + class init {postInit=1;}; + class getActionsFlagCategories {}; + class getVehicleFlagsCfg {}; + class isClassExcluded {}; + }; }; -}; -class DOUBLES(PREFIX,util) { - class functions { - file = "framework\util\functions"; - class logMissionInfo { postInit = 1; }; - class addPlayerInfoToArray {}; - class log {}; - class padString {}; - class recurseSubclasses {}; - class getBattalionCfg {}; - class getNameOfBase {}; - class getNearestBase {}; - }; -}; - -class DOUBLES(PREFIX,resupply) { - class functions { - file = "framework\resupply\functions"; - class init {postInit=1;}; - class createBox {}; - class getSupplyCratesCfg {}; - class addArsenalObjectSpawnBoxActions {}; - class addCBASettings {postInit=1;}; - }; -}; - -class DOUBLES(PREFIX,fbcb2_assets) { - class functions { - file = "framework\fbcb2_assets\functions"; - class init {postInit=1;}; - class updateAssetDiary {}; - class removeAssetDiaryRecords {}; - class getMagsForWeapon {}; - class getWeaponry {}; - class getInventory {}; - class getVehicleData {}; - class getAssetsByBase {}; - class getStartingAssetsByBase {}; - class updateAssetsByBase {}; - class showMarkersOnMap {}; - class removeMarkersOnMap {}; - }; -}; - -class DOUBLES(PREFIX,vehicleFlags) { - class functions { - file = "framework\vehicleFlags\functions"; - class init {postInit=1;}; - class getActionsFlagCategories {}; - class getVehicleFlagsCfg {}; - class isClassExcluded {}; - }; -}; - -class DOUBLES(PREFIX,reinsert) { - class server { - file = "framework\reinsert\server"; - class initServer { postInit = 1; }; - class addToQueue {}; - class globalShowQueue {}; - class removeFromQueue {}; - class returnReinsertQueueNotification {}; - class validateQueue {}; - }; - class client { - file = "framework\reinsert\client"; - class initClient { postInit = 1; }; - class addAceSelfActions {}; - class addCheckQueueSelfAction {}; - class requestShowQueue {}; - }; + }; \ No newline at end of file diff --git a/framework/fbcb2/fn_hintFBCB2AssetStatus.sqf b/framework/fbcb2/fn_hintFBCB2AssetStatus.sqf deleted file mode 100644 index 6571a0b..0000000 --- a/framework/fbcb2/fn_hintFBCB2AssetStatus.sqf +++ /dev/null @@ -1,31 +0,0 @@ -_assetList = param [0, [objNull], [[objNull]]]; - -_text = parseText "MESSAGE"; -_text = composeText [_text, lineBreak ]; - -_text = composeText [_text, parseText "AssetAvailable", lineBreak ]; - -{ - _callSign = _x select 0; - _asset = _x select 1; - _assigned = _x select 2; - _available = 0; //count (getMarkerPos "respawn_west" nearEntities [ _asset, 2000] ); - - _homes = allMissionObjects "ModuleRespawnPosition_F"; - - { - _home = _x; - _available = _available + count( _home nearEntities [ _asset, 750] ); - } forEach _homes; - - - _image = getText(configFile >> "CfgVehicles" >> _asset >> "picture"); - - _name = getText(configFile >> "CfgVehicles" >> _asset >> "displayName") select [0, 24]; - _data = " " + _name + "" + str _available + " [ " + str _assigned +" ]"; - _text = composeText[ _text, parseText _data, lineBreak ]; - - -} foreach _assetList; - -hint _text; diff --git a/framework/fbcb2/fn_initFBCB2.sqf b/framework/fbcb2/fn_initFBCB2.sqf deleted file mode 100644 index 1f3e864..0000000 --- a/framework/fbcb2/fn_initFBCB2.sqf +++ /dev/null @@ -1,39 +0,0 @@ - -if ( !hasInterface ) exitWith {}; - -waitUntil { !isNil "milsim_complete" }; - -milsim_fbcb2_recordTitleColor = "#ff6666"; -milsim_fbcb2_recordTitleFont = "PuristaMedium"; -milsim_fbcb2_recordTitleSize = 20; - -milsim_fbcb2_recordTextHeaderSize = 16; -milsim_fbcb2_recordTextBodySize = 14; - -milsim_fbcb2_subjectStatusID = "FBCB2_Status"; -milsim_fbcb2_subjectIntelID = "FBCB2_Intel"; -milsim_fbcb2_subjectMessagesID = "FBCB2_Messages"; -milsim_fbcb2_subjectFrequenciesID = "FBCB2_Frequencies"; -milsim_fbcb2_subjectAssetsFixedWingID = "FBCB2_Assets_FixedWing"; -milsim_fbcb2_subjectAssetsRotaryID = "FBCB2_Assets_Rotary"; -milsim_fbcb2_subjectAssetsGroundID = "FBCB2_Assets_Ground"; - -player createDiarySubject[milsim_fbcb2_subjectStatusID, "FBCB2 - Status"]; -player createDiarySubject[milsim_fbcb2_subjectMessagesID, "FBCB2 - Messages"]; -player createDiarySubject[milsim_fbcb2_subjectIntelID, "FBCB2 - Intel"]; -player createDiarySubject[milsim_fbcb2_subjectFrequenciesID, "FBCB2 - Frequencies"]; -player createDiarySubject[milsim_fbcb2_subjectAssetsFixedWingID, "FBCB2 - Assets Plane"]; -player createDiarySubject[milsim_fbcb2_subjectAssetsRotaryID, "FBCB2 - Assets Rotary"]; -player createDiarySubject[milsim_fbcb2_subjectAssetsGroundID, "FBCB2 - Assets Ground"]; - -// store records in format: -// [subject, [ -// [title, diaryRecord] -// ]] -milsim_fbcb2_diaryRecords = createHashMap; - -// populate diary -[] call milsim_fnc_processFBCB2RadioFrequencies; -[] call milsim_fnc_processFBCB2SmokeColors; -[] call milsim_fnc_processFBCB2Environment; -[] call milsim_fbcb2_assets_fnc_updateAssetDiary; diff --git a/framework/fbcb2/util/fn_removeDiaryRecord.sqf b/framework/fbcb2/util/fn_removeDiaryRecord.sqf deleted file mode 100644 index e69de29..0000000 diff --git a/framework/fbcb2_assets/functions/fn_addCBASettings.sqf b/framework/fbcb2_assets/functions/fn_addCBASettings.sqf index 5964caf..fe0e0fc 100644 --- a/framework/fbcb2_assets/functions/fn_addCBASettings.sqf +++ b/framework/fbcb2_assets/functions/fn_addCBASettings.sqf @@ -13,7 +13,7 @@ { params ["_value"]; [ - "fbcb2_assets", + QUOTE(COMPONENT), "SETTING CHANGED", [ [ @@ -22,6 +22,12 @@ ], ["newValue", _value] ] - ] call milsim_util_fnc_log; + ] call EFUNC(util,log); } -] call CBA_fnc_addSetting; \ No newline at end of file +] call CBA_fnc_addSetting; + +[ + QUOTE(COMPONENT), + "CREATED SETTINGS", + [] +] call EFUNC(util,log); \ No newline at end of file diff --git a/framework/fbcb2_assets/functions/fn_getAssetsByBase.sqf b/framework/fbcb2_assets/functions/fn_getAssetsByBase.sqf index 05dcd14..a42bc1c 100644 --- a/framework/fbcb2_assets/functions/fn_getAssetsByBase.sqf +++ b/framework/fbcb2_assets/functions/fn_getAssetsByBase.sqf @@ -1,4 +1,6 @@ +#include "../script_component.hpp" + // return each base with its assets -milsim_baseObjects apply { - [_x, _x getVariable ["milsim_fbcb2_assets_assetsAtThisBase", []]] +GVARMAIN(baseObjects) apply { + [_x, _x getVariable [QGVAR(assetsAtThisBase), []]] }; \ No newline at end of file diff --git a/framework/fbcb2_assets/functions/fn_getCallsignFromClassname.sqf b/framework/fbcb2_assets/functions/fn_getCallsignFromClassname.sqf new file mode 100644 index 0000000..866331c --- /dev/null +++ b/framework/fbcb2_assets/functions/fn_getCallsignFromClassname.sqf @@ -0,0 +1,15 @@ +#include "..\script_component.hpp" + +params [ + ["_className", "", [""]] +]; + +// Get the approved assets config +private _approvedAssetsCfg = call EFUNC(util,getApprovedAssetsCfg); +if (isNull _approvedAssetsCfg) exitWith {""}; + +// Get the asset definition +private _assetDef = (_approvedAssetsCfg >> _className); +if (isClass _assetDef) exitWith {getText(_assetDef >> "callsign")}; + +""; \ No newline at end of file diff --git a/framework/fbcb2_assets/functions/fn_getStartingAndCurrentAssets.sqf b/framework/fbcb2_assets/functions/fn_getStartingAndCurrentAssets.sqf new file mode 100644 index 0000000..a939818 --- /dev/null +++ b/framework/fbcb2_assets/functions/fn_getStartingAndCurrentAssets.sqf @@ -0,0 +1,17 @@ +#include "..\script_component.hpp" + +// get all starting assets at each base and combine to array +private _startingAssetsByBase = call FUNC(getStartingAssetsByBase); +private _startingAssets = []; +{ + _startingAssets append (_x#1); +} forEach _startingAssetsByBase; + +// get all current assets at each base and combine to array +private _assetsByBase = call FUNC(getAssetsByBase); +private _assets = []; +{ + _assets append (_x#1); +} forEach _assetsByBase; + +[_startingAssets, _assets]; \ No newline at end of file diff --git a/framework/fbcb2_assets/functions/fn_getStartingAssetsByBase.sqf b/framework/fbcb2_assets/functions/fn_getStartingAssetsByBase.sqf index 4c83db4..a0f082b 100644 --- a/framework/fbcb2_assets/functions/fn_getStartingAssetsByBase.sqf +++ b/framework/fbcb2_assets/functions/fn_getStartingAssetsByBase.sqf @@ -1,4 +1,6 @@ +#include "../script_component.hpp" + // return each base with its assets -milsim_baseObjects apply { - [_x, _x getVariable ["milsim_fbcb2_assets_assetsStartedAtThisBase", []]] +GVARMAIN(baseObjects) apply { + [_x, _x getVariable [QGVAR(assetsStartedAtThisBase), []]] }; \ No newline at end of file diff --git a/framework/fbcb2_assets/functions/fn_getVehicleData.sqf b/framework/fbcb2_assets/functions/fn_getVehicleData.sqf index d7ba851..cf5d7b2 100644 --- a/framework/fbcb2_assets/functions/fn_getVehicleData.sqf +++ b/framework/fbcb2_assets/functions/fn_getVehicleData.sqf @@ -39,7 +39,7 @@ private _pylons = getAllPylonsInfo _vic; /////////////////////////////////////////////// // WRITE TITLE /////////////////////////////////////////////// -_title pushBack format["%1", _dispName]; +_title pushBack format["%1", _dispName]; /////////////////////////////////////////////// // WRITE IMAGE diff --git a/framework/fbcb2_assets/functions/fn_hintAllApprovedAssets.sqf b/framework/fbcb2_assets/functions/fn_hintAllApprovedAssets.sqf new file mode 100644 index 0000000..7a851fe --- /dev/null +++ b/framework/fbcb2_assets/functions/fn_hintAllApprovedAssets.sqf @@ -0,0 +1,93 @@ +#include "..\script_component.hpp" + +// get vehicles the mission started with at base locations +(call FUNC(getStartingAndCurrentAssets)) params [ + "_startingAssets", + "_currentAssets" +]; + +// get distinct classnames to group by +private _distinctStartingAssetsClassNames = []; +{ + _x params ["_netId", "_cfg"]; + private _className = configName _cfg; + _distinctStartingAssetsClassNames pushBackUnique _className; +} forEach _startingAssets; + +// get the approved assets config to identify callsigns +private _approvedAssetsCfg = call EFUNC(util,getApprovedAssetsCfg); +if (isNull _approvedAssetsCfg) exitWith { + [ + QUOTE(COMPONENT), + "No approved assets defined.", + [] + ] call EFUNC(util,log); + [ + "ERROR: No approved assets defined. See defines/ApprovedAssets.hpp" + ] call BIS_fnc_error; +}; + +_text = parseText "MESSAGE"; +_text = composeText [_text, lineBreak ]; + +_text = composeText [_text, parseText "AssetAvailable", lineBreak ]; + +{ + private _className = _x; + // only approved assets + if (!isClass (_approvedAssetsCfg >> _className)) then {continue}; + + private _callsign = [_className] call FUNC(getCallsignFromClassname); + + private _startingAssetsOfThisType = _startingAssets select { + // select all starting assets of this type + _x params ["_netId", "_cfg"]; + _className isEqualTo (configName _cfg); + }; + private _currentAssetsOfThisType = _currentAssets select { + _x params ["_netId", "_cfg"]; + private _object = _netId call BIS_fnc_objectFromNetId; + // objNull if deleted, then check classname and if alive + !isNull _object && { + _className isEqualTo (typeOf _object) && + alive _object + }; + }; + + (_startingAssetsOfThisType#0) params [ + "_assetNetId", + "_assetCfg" + ]; + + _assigned = count _startingAssetsOfThisType; + _available = count _currentAssetsOfThisType; + // count (getMarkerPos "respawn_west" nearEntities [ _asset, 2000] ); + + + _image = getText(_assetCfg >> "picture"); + + _name = getText(_assetCfg >> "displayName") select [0, 22]; + private _data = format[ + " %2%3 [ %4 ]", + _image, + _name, + _available, + _assigned + ]; + + // private _data = format[ + // " + // %2 + // %3 + // %4", + // _image, + // _name, + // _assigned, + // _available + // ]; + _text = composeText[ _text, parseText _data, lineBreak ]; + + +} foreach _distinctStartingAssetsClassNames; + +hint _text; \ No newline at end of file diff --git a/framework/fbcb2_assets/functions/fn_isAssetInRangeOfBase.sqf b/framework/fbcb2_assets/functions/fn_isAssetInRangeOfBase.sqf new file mode 100644 index 0000000..c858c14 --- /dev/null +++ b/framework/fbcb2_assets/functions/fn_isAssetInRangeOfBase.sqf @@ -0,0 +1,8 @@ +#include "..\script_component.hpp" + +params [["_asset", objNull, [objNull]]]; + +private _closestBase = [_asset] call EFUNC(util,getNearestBase); +if (isNull _closestBase) exitWith {false}; + +(_asset distance2D _closestBase) <= GVAR(setting_detectionRangeFromBase) \ No newline at end of file diff --git a/framework/fbcb2_assets/functions/fn_removeAssetDiaryRecords.sqf b/framework/fbcb2_assets/functions/fn_removeAssetDiaryRecords.sqf index 400cd7d..98f41eb 100644 --- a/framework/fbcb2_assets/functions/fn_removeAssetDiaryRecords.sqf +++ b/framework/fbcb2_assets/functions/fn_removeAssetDiaryRecords.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + if (!hasInterface) exitWith {}; { @@ -10,7 +12,7 @@ if (!hasInterface) exitWith {}; player removeDiaryRecord [_diarySubject, _diaryRecord]; } forEach _records; } forEach [ - milsim_fbcb2_subjectAssetsFixedWingID, - milsim_fbcb2_subjectAssetsRotaryID, - milsim_fbcb2_subjectAssetsGroundID + EGVAR(fbcb2_main,subjectAssetsFixedWingID), + EGVAR(fbcb2_main,subjectAssetsRotaryID), + EGVAR(fbcb2_main,subjectAssetsGroundID) ]; \ No newline at end of file diff --git a/framework/fbcb2_assets/functions/fn_removeMarkersOnMap.sqf b/framework/fbcb2_assets/functions/fn_removeMarkersOnMap.sqf index ef6db27..ea6f78f 100644 --- a/framework/fbcb2_assets/functions/fn_removeMarkersOnMap.sqf +++ b/framework/fbcb2_assets/functions/fn_removeMarkersOnMap.sqf @@ -1,12 +1,11 @@ -private _baseMarkerStoreVar = "milsim_fbcb2_assets_baseMarkerStore"; -private _assetMarkerStoreVar = "milsim_fbcb2_assets_assetMarkerStore"; +#include "..\script_component.hpp" private _baseMarkerStore = localNamespace getVariable [ - _baseMarkerStoreVar, + QGVAR(baseMarkerStore), [] ]; private _assetMarkerStore = localNamespace getVariable [ - _assetMarkerStoreVar, + QGVAR(assetMarkerStore), [] ]; @@ -16,10 +15,10 @@ private _assetMarkerStore = localNamespace getVariable [ } forEach (_baseMarkerStore + _assetMarkerStore); localNamespace setVariable [ - _baseMarkerStoreVar, + QGVAR(baseMarkerStore), [] ]; localNamespace setVariable [ - _assetMarkerStoreVar, + QGVAR(assetMarkerStore), [] ]; diff --git a/framework/fbcb2_assets/functions/fn_showMarkersOnMap.sqf b/framework/fbcb2_assets/functions/fn_showMarkersOnMap.sqf index bb7bea4..265f0b6 100644 --- a/framework/fbcb2_assets/functions/fn_showMarkersOnMap.sqf +++ b/framework/fbcb2_assets/functions/fn_showMarkersOnMap.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + params [ ["_className", "", [""]], ["_markerType", "hd_dot", [""]], @@ -12,11 +14,11 @@ if (count _markerColor isEqualTo 0) exitWith { ["No marker color provided!"] call BIS_fnc_error; }; if (count _assetObjects isEqualTo 0) exitWith { - ["No vehicles provided!"] call BIS_fnc_error; + ["No vehicles to draw markers for!"] call BIS_fnc_error; }; -private _baseMarkerStoreVar = "milsim_fbcb2_assets_baseMarkerStore"; -private _assetMarkerStoreVar = "milsim_fbcb2_assets_assetMarkerStore"; +private _baseMarkerStoreVar = QGVAR(baseMarkerStore); +private _assetMarkerStoreVar = QGVAR(assetMarkerStore); private _baseMarkerStore = localNamespace getVariable [ _baseMarkerStoreVar, @@ -35,15 +37,15 @@ if (not (count _baseMarkerStore > 0)) then { // create a circle marker with range as the detection range of assets _newMarker = createMarkerLocal [ - format["milsim_fbcb2_assets_base_marker_%1", _forEachIndex + 1], + format["%1_%2", QGVAR(baseCircleMarker), _forEachIndex + 1], getPosASL _base ]; _newMarker setMarkerTypeLocal "mil_dot"; _newMarker setMarkerColorLocal "ColorGreen"; _newMarker setMarkerShapeLocal "ELLIPSE"; _newMarker setMarkerSizeLocal [ - milsim_fbcb2_assets_setting_detectionRangeFromBase, - milsim_fbcb2_assets_setting_detectionRangeFromBase + GVAR(setting_detectionRangeFromBase), + GVAR(setting_detectionRangeFromBase) ]; _newMarker setMarkerAlphaLocal 0.5; _newMarker setMarkerTextLocal str(_forEachIndex + 1); @@ -55,19 +57,19 @@ if (not (count _baseMarkerStore > 0)) then { // create a flag marker at base position _newMarker = createMarkerLocal [ - format["milsim_fbcb2_assets_base_flag_marker_%1", _forEachIndex + 1], + format["%1_%2", QGVAR(baseFlagMarker), _forEachIndex + 1], getPosASL _base ]; _newMarker setMarkerTypeLocal "mil_flag"; _newMarker setMarkerColorLocal "ColorGreen"; _newMarker setMarkerSizeLocal [0.7, 0.7]; - _newMarker setMarkerTextLocal ([_base] call milsim_util_fnc_getNameOfBase); + _newMarker setMarkerTextLocal ([_base] call EFUNC(util,getNameOfBase)); _baseMarkerStore pushBack [ _base, _newMarker ]; - } forEach milsim_baseObjects; + } forEach GVARMAIN(baseObjects); localNamespace setVariable [_baseMarkerStoreVar, _baseMarkerStore]; }; @@ -85,9 +87,12 @@ private _start = (count _assetMarkerStore) + 1; > -1 ) then {continue}; + // check if the asset is within base detection range + if (not ([_asset] call FUNC(isAssetInRangeOfBase))) then {continue}; + // create a marker for the asset private _newMarker = createMarkerLocal [ - format["milsim_fbcb2_assets_marker_%1", _start], + format["%1_%2", QGVAR(assetMarker), _start], getPosASL _asset ]; _newMarker setMarkerAlphaLocal 1; diff --git a/framework/fbcb2_assets/functions/fn_updateAssetDiary.sqf b/framework/fbcb2_assets/functions/fn_updateAssetDiary.sqf index c96fab8..9d5cc7e 100644 --- a/framework/fbcb2_assets/functions/fn_updateAssetDiary.sqf +++ b/framework/fbcb2_assets/functions/fn_updateAssetDiary.sqf @@ -10,101 +10,145 @@ call FUNC(removeMarkersOnMap); // remove existing asset records call FUNC(removeAssetDiaryRecords); -// get all vehicles by base -private _vehiclesByBase = call FUNC(getAssetsByBase); -if (count _vehiclesByBase isEqualTo 0) exitWith {false}; +(call FUNC(getStartingAndCurrentAssets)) params [ + "_startingAssets", + "_currentAssets" +]; -// put vehicles from each base into a single array -private _vehicles = []; -{ - _vehicles append (_x#1); -} forEach _vehiclesByBase; - -if (count _vehicles isEqualTo 0) exitWith {false}; +// get distinct vehicle class names private _distinctVehiclesClassNames = []; { - _distinctVehiclesClassNames pushBackUnique (typeOf _x); -} forEach _vehicles; + _x params ["_netId", "_cfg"]; + private _className = configName _cfg; + _distinctVehiclesClassNames pushBackUnique _className; +} forEach _startingAssets; +// for random color cycling +private _colorSelectionIndex = 0; +private _randomColors = [ + ["ColorRed", "#FF0000", "Red"], + ["ColorGreen", "#00FF00", "Green"], + ["ColorBlue", "#0000FF", "Blue"], + ["ColorYellow", "#FFFF00", "Yellow"], + ["ColorWhite", "#FFFFFF", "White"] +]; + // ForEach unique vehicle class name, we'll find the first and gather its info { private _className = _x; - private _vehiclesOfThisKind = _vehicles select {typeOf _x isEqualTo _className}; - // This should never happen, but... - if (count _vehiclesOfThisKind isEqualTo 0) then {continue}; - - // Take the first vehicle as a representative - private _representativeVehicle = _vehiclesOfThisKind#0; - private _vehicleCfg = configOf _representativeVehicle; private _vehicleCallsign = toUpper ( - _representativeVehicle getVariable [ - QGVAR(callsign), - "NONE ASSIGNED" - ] + [_className] call FUNC(getCallsignFromClassname) ); + // Get all starting assets of this type + private _startingAssetsOfThisType = _startingAssets select { + _x params ["_netId", "_cfg"]; + _className isEqualTo (configName _cfg); + }; + // Get all current assets of this type + private _currentAssetsOfThisType = _currentAssets select { + _x params ["_netId", "_cfg"]; + private _object = _netId call BIS_fnc_objectFromNetId; + // objNull if deleted, then check classname and if alive + !isNull _object && {_className isEqualTo (typeOf _object) && alive _object}; + }; + // This should never happen, but... + if (count _startingAssetsOfThisType isEqualTo 0) then {continue}; + + // Try to find a not null vehicle that can be processed + private _exampleVehicleToProcess = objNull; + private _assetCfg = configNull; + + private _exampleVehicleToProcessIndex = _startingAssetsOfThisType findIf { + _x params ["_netId", "_cfg"]; + !isNull (_netId call BIS_fnc_objectFromNetId); + }; + // If found, get the data + if (_exampleVehicleToProcessIndex > -1) then { + private _exampleData = _startingAssetsOfThisType select _exampleVehicleToProcessIndex; + _assetNetId = _exampleData#0; + _assetCfg = _exampleData#1; + _exampleVehicleToProcess = _assetNetId call BIS_fnc_objectFromNetId; + } else { + // otherwise, we only have the config to work with + private _exampleData = _startingAssetsOfThisType#0; + _assetCfg = _exampleData#1; + }; + + private _parentClassNames = [_assetCfg, true] call BIS_fnc_returnParents; + + + // Process the vehicle for extended info // Exclusion list for display names if ( - ((configOf _representativeVehicle) call BIS_fnc_displayName) + [_assetCfg] call BIS_fnc_displayName in ["Helicopter"] ) then {continue}; // Get the vehicle data - private _processed = [_representativeVehicle] call FUNC(getVehicleData); - - if (isNil "_processed") then {continue}; - _processed params ["_vehicleCfg", "_displayName", "_diaryTextSections"]; + private _processed = [configNull, "", []]; + if (!isNull _exampleVehicleToProcess) then { + _processed = [_exampleVehicleToProcess] call FUNC(getVehicleData); + }; + _processed params ["_processedVehicleCfg", "_displayName", "_diaryTextSections"]; _diaryTextSections params [ - "_title", - "_image", - "_info", - "_capacity" - // "_weapons", - // "_pylonWeapons", - // "_inventory" + ["_title", "", [""]], + ["_image", "", [""]], + ["_info", "", [""]], + ["_capacity", "", [""]] + // ["_weapons", "", [""]], + // ["_pylonWeapons", "", [""]], + // ["_inventory", "", [""]] ]; + // Get what we can from the vehicle cfg + // Create the diary record private _recordText = []; // Add the title and image - _recordText pushBack _title; + if (count _title isEqualTo 0) then { + _title = format["%1", [_assetCfg] call BIS_fnc_displayName]; + }; + _recordText pushBack format[ + "%1", + _title + ]; + if (count _image isEqualTo 0) then { + _image = format["", getText(_assetCfg >> 'editorPreview')]; + }; _recordText pushBack _image; _recordText pushBack "
"; _recordText pushBack format[ "CALLSIGN: %1", _vehicleCallsign ]; + _recordText pushBack format[ + "COUNT STARTED: %1", + count _startingAssetsOfThisType + ]; _recordText pushBack format[ "COUNT ACTIVE: %1", - count _vehiclesOfThisKind + count _currentAssetsOfThisType ]; // Here, we'll create a link to show markers on the map for all vehicles of this kind - private _randomColor = selectRandom [ - ["ColorRed", "#FF0000", "Red"], - ["ColorGreen", "#00FF00", "Green"], - ["ColorBlue", "#0000FF", "Blue"], - ["ColorYellow", "#FFFF00", "Yellow"], - ["ColorWhite", "#FFFFFF", "White"] - ]; - private _vehicleCfg = configFile >> "CfgVehicles" >> _className; // get 'picture' for record - private _icon = getText(_vehicleCfg >> "picture"); + private _icon = getText(_assetCfg >> "picture"); // determine marker type private _markerType = "mil_dot"; switch (true) do { - case (_representativeVehicle isKindOf "Helicopter"): { + case ("Helicopter" in _parentClassNames): { _markerType = "loc_heli"; }; - case (_representativeVehicle isKindOf "Air"): { + case ("Air" in _parentClassNames): { _markerType = "loc_plane"; }; - case (_representativeVehicle isKindOf "Ship"): { + case ("Ship" in _parentClassNames): { _markerType = "loc_boat"; }; - case (_representativeVehicle isKindOf "Car"): { + case ("Car" in _parentClassNames): { _markerType = "loc_car"; }; default { @@ -112,63 +156,92 @@ private _distinctVehiclesClassNames = []; }; }; + private "_randomColor"; + if (_colorSelectionIndex < count _randomColors) then { + _randomColor = _randomColors select _colorSelectionIndex; + INC(_colorSelectionIndex); + } else { + _colorSelectionIndex = 0; + _randomColor = _randomColors select _colorSelectionIndex; + }; + // Link to show markers private _showMarkersText = format[ - "SHOW MARKERS at vehicle positions (in %5)", + "SHOW MARKERS for vehicles at base (in %6)", _className, _markerType, _randomColor#0, - (_vehiclesOfThisKind apply { - format["%1", _x call BIS_fnc_netId] + (_currentAssetsOfThisType apply { + _x params ["_netId", "_cfg"]; + _netId; }), + QFUNC(showMarkersOnMap), format["%2", _randomColor#1, _randomColor#2] ]; _recordText pushBack _showMarkersText; // Link to hide markers - _recordText pushBack "REMOVE ALL MARKERS showing asset positions"; + _recordText pushBack format[ + "REMOVE ALL MARKERS showing asset positions", + QFUNC(removeMarkersOnMap) + ]; // Link to update asset diary entries - _recordText pushBack "UPDATE ENTRIES for all assets"; + _recordText pushBack format[ + "UPDATE ENTRIES for all assets", + QFUNC(updateAssetDiary) + ]; + + // link to display hint with all assets + _recordText pushBack format[ + "SHOW APPROVED ASSET COUNTS via hint", + QFUNC(hintAllApprovedAssets) + ]; _recordText pushBack format[ "%1", "Notes:
- Markers are only displayed on your local machine.
- The REMOVE ALL option will remove all assets' markers from the map.
- - UPDATE ENTRIES will update the asset diary with the latest information (~5 minutes at most)." + - UPDATE ENTRIES will update the asset diary with the latest information.
+ - Markers will only be displayed for assets that are within a certain distance of a base." ]; - // Add info and capacity sections - _recordText pushBack _info; - _recordText pushBack _capacity; + // Add info and capacity sections - exclude if no living examples were found + if (count _info > 0) then { + _recordText pushBack _info; + }; + if (count _capacity > 0) then { + _recordText pushBack _capacity; + }; private _subjectID = ""; switch (true) do { - case (_representativeVehicle isKindOf "Helicopter"): { - _subjectID = EGVAR(fbcb2,subjectAssetsRotaryID); + case ("Helicopter" in _parentClassNames): { + _subjectID = EGVAR(fbcb2_main,subjectAssetsRotaryID); }; - case (_representativeVehicle isKindOf "Air"): { - _subjectID = EGVAR(fbcb2,subjectAssetsFixedWingID); + case ("Air" in _parentClassNames): { + _subjectID = EGVAR(fbcb2_main,subjectAssetsFixedWingID); }; default { - _subjectID = EGVAR(fbcb2,subjectAssetsGroundID); + _subjectID = EGVAR(fbcb2_main,subjectAssetsGroundID); }; }; [ _subjectID, format[ - "%1x %2", - count _vehiclesOfThisKind, - (configOf _representativeVehicle) call BIS_fnc_displayName + "[%1/%2] %3", + count _currentAssetsOfThisType, + count _startingAssetsOfThisType, + (_assetCfg) call BIS_fnc_displayName ], _recordText joinString "
", _icon - ] call milsim_fnc_createOrUpdateDiaryRecord; + ] call EFUNC(fbcb2_main,createOrUpdateDiaryRecord); // "\A3\ui_f\data\igui\cfg\simpleTasks\types\car_ca.paa" } forEach _distinctVehiclesClassNames; @@ -178,8 +251,9 @@ private _distinctVehiclesClassNames = []; QUOTE(COMPONENT), "UPDATED ASSET DIARY", [ - ["assetCount", count _vehicles], - ["distinctAssetCount", count _distinctVehiclesClassNames] + ["startingAssetCount", count _startingAssets], + ["startingAssetCountDistinct", count _distinctVehiclesClassNames], + ["currentassetCount", count _currentAssets] ] ] call EFUNC(util,log); diff --git a/framework/fbcb2_assets/functions/fn_updateAssetsByBase.sqf b/framework/fbcb2_assets/functions/fn_updateAssetsByBase.sqf index 23fdef5..c775bbe 100644 --- a/framework/fbcb2_assets/functions/fn_updateAssetsByBase.sqf +++ b/framework/fbcb2_assets/functions/fn_updateAssetsByBase.sqf @@ -17,32 +17,29 @@ private _allSaved = []; private _assetsAtThisBaseVar = QGVAR(assetsAtThisBase); private _assetsStartedAtThisBaseVar = QGVAR(assetsStartedAtThisBase); +private _approvedAssetsCfg = call EFUNC(util,getApprovedAssetsCfg); +if (isNull _approvedAssetsCfg) exitWith {}; + { private _className = configName _x; private _callsign = getText(_x >> "callsign"); private _found = _allVehicles select { typeOf _x == _className }; { private _asset = _x; + // avoid duplicates if (_asset in _allSaved) then {continue}; - private _closestBase = [_asset] call EFUNC(util,getNearestBase); - if (isNull _closestBase) then { - // no base found - continue; - }; - if ( - _asset distance _closestBase > - milsim_fbcb2_assets_setting_detectionRangeFromBase - ) then { - // not within range - continue; - }; - _asset setVariable [QGVAR(callsign), _callsign, true]; + if (not ([_asset] call FUNC(isAssetInRangeOfBase))) then {continue}; + // add to base's assets list + private _closestBase = [_asset] call EFUNC(util,getNearestBase); private _baseAssets = _closestBase getVariable [_assetsAtThisBaseVar, []]; - _baseAssets pushBackUnique _asset; + _baseAssets pushBackUnique [ + _asset call BIS_fnc_netId, + configOf _asset + ]; // broadcast later so we're not spamming network _closestBase setVariable [ _assetsAtThisBaseVar, @@ -60,7 +57,7 @@ private _assetsStartedAtThisBaseVar = QGVAR(assetsStartedAtThisBase); _allSaved pushBack _asset; } forEach _found; -} forEach ((missionConfigFile >> "ApprovedAssets") call BIS_fnc_returnChildren); +} forEach (_approvedAssetsCfg call BIS_fnc_returnChildren); // Add all ground vehicles (LandVehicle) { @@ -68,23 +65,16 @@ private _assetsStartedAtThisBaseVar = QGVAR(assetsStartedAtThisBase); // avoid duplicates if (_asset in _allSaved) then {continue}; - private _closestBase = [_asset] call EFUNC(util,getNearestBase); - if (isNull _closestBase) then { - // no base found - continue; - }; + if (not ([_asset] call FUNC(isAssetInRangeOfBase))) then {continue}; - if ( - _asset distance _closestBase > - GVAR(setting_detectionRangeFromBase) - ) then { - // not within range - continue; - }; // add to base's assets list + private _closestBase = [_asset] call EFUNC(util,getNearestBase); private _baseAssets = _closestBase getVariable [_assetsAtThisBaseVar, []]; - _baseAssets pushBackUnique _asset; + _baseAssets pushBackUnique [ + _asset call BIS_fnc_netId, + configOf _asset + ]; // broadcast later so we're not spamming network _closestBase setVariable [ _assetsAtThisBaseVar, @@ -115,7 +105,7 @@ private _assetsStartedAtThisBaseVar = QGVAR(assetsStartedAtThisBase); if (_isInit) then { _base setVariable [_assetsStartedAtThisBaseVar, _baseAssets, true]; }; -} forEach milsim_baseObjects; +} forEach GVARMAIN(baseObjects); //////////////////////////////////////////////////////////////////////// // log starting assets if init @@ -131,14 +121,11 @@ if !(_isInit || _logCurrentAssets) exitWith {}; // prepare key value for logging private _baseAssetsHashesPrep = _baseAssets apply { - private _asset = _x; + _x params ["_netId", "_cfg"]; [ - ["callsign", _asset getVariable [ - QGVAR(callsign), - "N/A" - ]], - ["className", typeOf _asset], - ["displayName", (configOf _asset) call BIS_fnc_displayName] + ["callsign", [configName _cfg] call FUNC(getCallsignFromClassname)], + ["className", configName _cfg], + ["displayName", [_cfg] call BIS_fnc_displayName] ]; }; @@ -155,13 +142,13 @@ if !(_isInit || _logCurrentAssets) exitWith {}; if (_logCurrentAssets) then { { [ - "fbcb2_assets", + QUOTE(COMPONENT), "CURRENT ASSETS", [ - ["baseName", [[_base] call milsim_util_fnc_getNameOfBase]], + ["baseName", [[_base] call EFUNC(util,getNameOfBase)]], ["asset", _x] ] - ] call milsim_util_fnc_log; + ] call EFUNC(util,log); } forEach _baseAssetsHashes; }; @@ -172,10 +159,10 @@ if !(_isInit || _logCurrentAssets) exitWith {}; "fbcb2_assets", "STARTING ASSETS", [ - ["baseName", [[_base] call milsim_util_fnc_getNameOfBase]], + ["baseName", [[_base] call EFUNC(util,getNameOfBase)]], ["asset", _x] ] - ] call milsim_util_fnc_log; + ] call EFUNC(util,log); } forEach _baseAssetsHashes; }; -} forEach milsim_baseObjects; \ No newline at end of file +} forEach GVARMAIN(baseObjects); \ No newline at end of file diff --git a/framework/fbcb2_main/functions/fn_init.sqf b/framework/fbcb2_main/functions/fn_init.sqf new file mode 100644 index 0000000..fe1f55f --- /dev/null +++ b/framework/fbcb2_main/functions/fn_init.sqf @@ -0,0 +1,39 @@ +#include "../script_component.hpp" + +if ( !hasInterface ) exitWith {}; + +waitUntil { !isNil QGVARMAIN(complete) }; + +GVAR(recordTitleColor) = "#ff6666"; +GVAR(recordTitleFont) = "PuristaMedium"; +GVAR(recordTitleSize) = 20; + +GVAR(recordTextHeaderSize) = 16; +GVAR(recordTextBodySize) = 14; + +GVAR(subjectStatusID) = "FBCB2_Status"; +GVAR(subjectIntelID) = "FBCB2_Intel"; +GVAR(subjectMessagesID) = "FBCB2_Messages"; +GVAR(subjectFrequenciesID) = "FBCB2_Frequencies"; +GVAR(subjectAssetsFixedWingID) = "FBCB2_Assets_FixedWing"; +GVAR(subjectAssetsRotaryID) = "FBCB2_Assets_Rotary"; +GVAR(subjectAssetsGroundID) = "FBCB2_Assets_Ground"; + +player createDiarySubject[GVAR(subjectStatusID), "FBCB2 Status"]; +player createDiarySubject[GVAR(subjectMessagesID), "FBCB2 Messages"]; +player createDiarySubject[GVAR(subjectIntelID), "FBCB2 Intel"]; +player createDiarySubject[GVAR(subjectFrequenciesID), "FBCB2 Frequencies"]; +player createDiarySubject[GVAR(subjectAssetsFixedWingID), "FBCB2 Planes"]; +player createDiarySubject[GVAR(subjectAssetsRotaryID), "FBCB2 Helicopters"]; +player createDiarySubject[GVAR(subjectAssetsGroundID), "FBCB2 Ground"]; + +// store records in format: +// [subject, [ +// [title, diaryRecord] +// ]] +GVAR(diaryRecords) = createHashMap; + +// run main inits - assets handled in that component +[] call FUNC(processFBCB2RadioFrequencies); +[] call FUNC(processFBCB2SmokeColors); +[] call FUNC(processFBCB2Environment); \ No newline at end of file diff --git a/framework/fbcb2/fn_processFBCB2Environment.sqf b/framework/fbcb2_main/functions/fn_processFBCB2Environment.sqf similarity index 72% rename from framework/fbcb2/fn_processFBCB2Environment.sqf rename to framework/fbcb2_main/functions/fn_processFBCB2Environment.sqf index 91c8bac..1bc6612 100644 --- a/framework/fbcb2/fn_processFBCB2Environment.sqf +++ b/framework/fbcb2_main/functions/fn_processFBCB2Environment.sqf @@ -1,11 +1,13 @@ +#include "..\script_component.hpp" + private _recordTitle = "MDS - INTEL - ENVIRONMENT"; private _text = [ format[ "%4

", - milsim_fbcb2_recordTitleSize, - milsim_fbcb2_recordTitleColor, - milsim_fbcb2_recordTitleFont, + GVAR(recordTitleSize), + GVAR(recordTitleColor), + GVAR(recordTitleFont), _recordTitle ] ]; @@ -19,9 +21,9 @@ private _sunTimes = date call BIS_fnc_sunriseSunsetTime; _text pushBack format[ "Local Sunrise
%5

", - milsim_fbcb2_recordTextHeaderSize, + GVAR(recordTextHeaderSize), _sunriseColor, - milsim_fbcb2_recordTextBodySize, + GVAR(recordTextBodySize), _whiteColor, ([_sunTimes select 0, "HH:MM"] call BIS_fnc_timeToString) ]; @@ -29,9 +31,9 @@ _text pushBack format[ _text pushBack format[ "Local Sunset
%5

", - milsim_fbcb2_recordTextHeaderSize, + GVAR(recordTextHeaderSize), _sunsetColor, - milsim_fbcb2_recordTextBodySize, + GVAR(recordTextBodySize), _whiteColor, ([_sunTimes select 1, "HH:MM"] call BIS_fnc_timeToString) ]; @@ -39,7 +41,7 @@ _text pushBack format[ _text = _text joinString ""; [ - milsim_fbcb2_subjectIntelID, + GVAR(subjectIntelID), _recordTitle, _text -] call milsim_fnc_createOrUpdateDiaryRecord; \ No newline at end of file +] call FUNC(createOrUpdateDiaryRecord); \ No newline at end of file diff --git a/framework/fbcb2/fn_processFBCB2RadioFrequencies.sqf b/framework/fbcb2_main/functions/fn_processFBCB2RadioFrequencies.sqf similarity index 63% rename from framework/fbcb2/fn_processFBCB2RadioFrequencies.sqf rename to framework/fbcb2_main/functions/fn_processFBCB2RadioFrequencies.sqf index 15e26eb..3a633da 100644 --- a/framework/fbcb2/fn_processFBCB2RadioFrequencies.sqf +++ b/framework/fbcb2_main/functions/fn_processFBCB2RadioFrequencies.sqf @@ -1,11 +1,28 @@ // updated 2024-02-01 by IndigoFox // now reads from the battalion config structure to generate the diary entries +#include "../script_component.hpp" + //////////////////////////////////////// // Get info from missionConfigFile //////////////////////////////////////// -private _battalionInfoCfg = call milsim_util_fnc_getBattalionCfg; +private _battalionInfoCfg = call EFUNC(util,getBattalionCfg); +if (isNull _battalionInfoCfg) exitWith { + [ + QUOTE(COMPONENT), + "Null Battalion Config", + [] + ] call EFUNC(util,log); +}; + private _battalionElementCfgs = [_battalionInfoCfg >> "Command"] call BIS_fnc_returnChildren; +if (count _battalionElementCfgs == 0) exitWith { + [ + QUOTE(COMPONENT), + "ERROR: No battalion elements found. Check that the battalion config is correctly structured. See defines/BattalionInfo.hpp and framework/util/functions/getBattalionCfg.sqf.", + [] + ] call EFUNC(util,log); +}; //////////////////////////////////////// // Define formatting constants @@ -29,22 +46,28 @@ private _FREQ_TEXT_COLOR = "#CCCCCC"; reverse _battalionElementCfgs; { + diag_log text format[ + "[%1] <%2> Processing battalion element %3", + QUOTE(PREFIX), + _fnc_scriptName, + configName _x + ]; // recursively generate diary text for all child elements of battalion-level elements - private _diaryTitleText = [_x, true] call milsim_fnc_generateElementFrequencyRecordText; + private _diaryTitleText = [_x, true] call FUNC(generateElementFrequencyRecordText); [ - milsim_fbcb2_subjectFrequenciesID, + GVAR(subjectFrequenciesID), _diaryTitleText#0, _diaryTitleText#1 - ] call milsim_fnc_createOrUpdateDiaryRecord; + ] call FUNC(createOrUpdateDiaryRecord); } forEach _battalionElementCfgs; // add the battalion command to the top of the list // don't process child elements -private _diaryTitleText = [_battalionInfoCfg >> "Command", false] call milsim_fnc_generateElementFrequencyRecordText; +private _diaryTitleText = [_battalionInfoCfg >> "Command", false] call FUNC(generateElementFrequencyRecordText); [ - milsim_fbcb2_subjectFrequenciesID, + GVAR(subjectFrequenciesID), _diaryTitleText#0, _diaryTitleText#1 -] call milsim_fnc_createOrUpdateDiaryRecord; +] call FUNC(createOrUpdateDiaryRecord); true; \ No newline at end of file diff --git a/framework/fbcb2/fn_processFBCB2SmokeColors.sqf b/framework/fbcb2_main/functions/fn_processFBCB2SmokeColors.sqf similarity index 78% rename from framework/fbcb2/fn_processFBCB2SmokeColors.sqf rename to framework/fbcb2_main/functions/fn_processFBCB2SmokeColors.sqf index 1797d06..7622d46 100644 --- a/framework/fbcb2/fn_processFBCB2SmokeColors.sqf +++ b/framework/fbcb2_main/functions/fn_processFBCB2SmokeColors.sqf @@ -1,12 +1,14 @@ +#include "../script_component.hpp" + private _recordTitle = "MDS - INTEL - SMOKES"; private _text = [ // Title format[ "%4", - milsim_fbcb2_recordTitleSize, - milsim_fbcb2_recordTitleColor, - milsim_fbcb2_recordTitleFont, + GVAR(recordTitleSize), + GVAR(recordTitleColor), + GVAR(recordTitleFont), _recordTitle ] ]; @@ -25,7 +27,7 @@ private _smokeColors = [ _x params ["_color", "_name", "_description"]; _text pushBack format[ "%3 - %4", - milsim_fbcb2_recordTextHeaderSize, + GVAR(recordTextHeaderSize), _color, _name, _description @@ -35,7 +37,7 @@ private _smokeColors = [ _text = _text joinString "

"; [ - milsim_fbcb2_subjectIntelID, + GVAR(subjectIntelID), _recordTitle, _text -] call milsim_fnc_createOrUpdateDiaryRecord; \ No newline at end of file +] call FUNC(createOrUpdateDiaryRecord); \ No newline at end of file diff --git a/framework/fbcb2_main/script_component.hpp b/framework/fbcb2_main/script_component.hpp new file mode 100644 index 0000000..ef7f377 --- /dev/null +++ b/framework/fbcb2_main/script_component.hpp @@ -0,0 +1,3 @@ +#define COMPONENT fbcb2_main +#define COMPONENT_BEAUTIFIED FBCB2 - Main +#include "../script_mod.hpp" \ No newline at end of file diff --git a/framework/fbcb2/util/fn_createOrUpdateDiaryRecord.sqf b/framework/fbcb2_main/util/fn_createOrUpdateDiaryRecord.sqf similarity index 72% rename from framework/fbcb2/util/fn_createOrUpdateDiaryRecord.sqf rename to framework/fbcb2_main/util/fn_createOrUpdateDiaryRecord.sqf index 6cd8330..e828493 100644 --- a/framework/fbcb2/util/fn_createOrUpdateDiaryRecord.sqf +++ b/framework/fbcb2_main/util/fn_createOrUpdateDiaryRecord.sqf @@ -1,14 +1,16 @@ +#include "../script_component.hpp" + if (!hasInterface) exitWith {}; params [ - ["_subjectID", milsim_fbcb2_subjectStatusID, [""]], + ["_subjectID", GVAR(subjectStatusID), [""]], ["_recordTitle", "", [""]], ["_recordText", "", [""]], ["_recordIcon", "", [""]] ]; // Check if already created -private _subjectRecords = milsim_fbcb2_diaryRecords getOrDefault [_subjectID, createHashMap, true]; +private _subjectRecords = GVAR(diaryRecords) getOrDefault [_subjectID, createHashMap, true]; private _existingRecord = _subjectRecords getOrDefault [_recordTitle, diaryRecordNull, true]; if (!isNull _existingRecord) then { @@ -24,5 +26,5 @@ if (!isNull _existingRecord) then { ] ]; _subjectRecords set [_recordTitle, _new]; - milsim_fbcb2_diaryRecords set [_subjectID, _subjectRecords]; + GVAR(diaryRecords) set [_subjectID, _subjectRecords]; }; \ No newline at end of file diff --git a/framework/fbcb2/radioFrequencies/fn_formatRadioElementForDiary.sqf b/framework/fbcb2_main/util/fn_formatRadioElementForDiary.sqf similarity index 91% rename from framework/fbcb2/radioFrequencies/fn_formatRadioElementForDiary.sqf rename to framework/fbcb2_main/util/fn_formatRadioElementForDiary.sqf index fce0c35..223de2a 100644 --- a/framework/fbcb2/radioFrequencies/fn_formatRadioElementForDiary.sqf +++ b/framework/fbcb2_main/util/fn_formatRadioElementForDiary.sqf @@ -1,4 +1,6 @@ // called from milsim_fnc_processFBCB2RadioFrequencies +#include "../script_component.hpp" + params ["_cfg", ["_indentCount", 1, [5]]]; ////////////////////////////////////////////////////// @@ -62,8 +64,8 @@ _freqLeadingSpace = _freqLeadingSpace joinString ""; _ELEMENT_FREQ_SIZE, _ELEMENT_FREQ_FONT, _FREQ_TEXT_COLOR, - [_role, "right", " ", _FREQ_PAD_LENGTH] call milsim_util_fnc_padString, - [_srStr, "right", " ", _FREQ_PAD_LENGTH] call milsim_util_fnc_padString, + [_role, "right", " ", _FREQ_PAD_LENGTH] call EFUNC(util,padString), + [_srStr, "right", " ", _FREQ_PAD_LENGTH] call EFUNC(util,padString), _lrStr ]; } forEach (getArray (_cfg >> "frequencies")); diff --git a/framework/fbcb2/radioFrequencies/fn_generateElementFrequencyRecordText.sqf b/framework/fbcb2_main/util/fn_generateElementFrequencyRecordText.sqf similarity index 77% rename from framework/fbcb2/radioFrequencies/fn_generateElementFrequencyRecordText.sqf rename to framework/fbcb2_main/util/fn_generateElementFrequencyRecordText.sqf index b7a8986..ee57bbe 100644 --- a/framework/fbcb2/radioFrequencies/fn_generateElementFrequencyRecordText.sqf +++ b/framework/fbcb2_main/util/fn_generateElementFrequencyRecordText.sqf @@ -1,5 +1,8 @@ // called from milsim_fnc_processFBCB2RadioFrequencies ONLY // this function is called recursively to process all child elements of a battalion element in missionConfigFile + +#include "../script_component.hpp" + params [ ["_elementCfg", configNull, [configNull]], ["_shouldProcessChildCfgs", true] @@ -40,9 +43,9 @@ _freqLeadingSpace = _freqLeadingSpace joinString ""; private _headers = [ format[ "%4", - milsim_fbcb2_recordTitleSize, - milsim_fbcb2_recordTitleColor, - milsim_fbcb2_recordTitleFont, + GVAR(recordTitleSize), + GVAR(recordTitleColor), + GVAR(recordTitleFont), _recordTitle ], format[ @@ -51,8 +54,8 @@ private _headers = [ _ELEMENT_FREQ_SIZE, _ELEMENT_FREQ_FONT, _FREQ_TEXT_COLOR, - ["ROLE", "right", " ", _FREQ_PAD_LENGTH] call milsim_util_fnc_padString, - ["SR", "right", " ", _FREQ_PAD_LENGTH] call milsim_util_fnc_padString, + ["ROLE", "right", " ", _FREQ_PAD_LENGTH] call EFUNC(util,padString), + ["SR", "right", " ", _FREQ_PAD_LENGTH] call EFUNC(util,padString), "LR" ] ]; @@ -65,16 +68,28 @@ private _allText = []; // get all child elements recursively and format them if (_shouldProcessChildCfgs) then { + diag_log text format[ + "[%1] <%2> Processing %3", + QUOTE(PREFIX), + _fnc_scriptName, + configName _battalionElement + ]; [_battalionElement, { params ["_cfg", "_recurseCounter"]; // add config - private _lines = [_cfg, _recurseCounter+1] call milsim_fnc_formatRadioElementForDiary; + private _lines = [_cfg, _recurseCounter+1] call FUNC(formatRadioElementForDiary); // private _lines = [_cfg, _indentCount] call t; _allText pushBack (_lines joinString "
"); - }] call milsim_util_fnc_recurseSubclasses; + }] call EFUNC(util,recurseSubclasses); } else { + diag_log text format[ + "[%1] <%2> Processing %3", + QUOTE(PREFIX), + _fnc_scriptName, + configName _battalionElement + ]; // or if the param was false, just add the battalion element - private _lines = [_battalionElement, 1] call milsim_fnc_formatRadioElementForDiary; + private _lines = [_battalionElement, 1] call FUNC(formatRadioElementForDiary); // private _lines = [_cfg, _indentCount] call t; _allText pushBack (_lines joinString "
"); }; diff --git a/framework/init/functions/fn_initServer.sqf b/framework/init/functions/fn_initServer.sqf index 5ad0adf..2933428 100644 --- a/framework/init/functions/fn_initServer.sqf +++ b/framework/init/functions/fn_initServer.sqf @@ -2,7 +2,7 @@ if (!isServer) exitWith {}; -milsim_baseObjects = allMissionObjects "ModuleRespawnPosition_F"; +GVARMAIN(baseObjects) = allMissionObjects "ModuleRespawnPosition_F"; publicVariable "milsim_baseObjects"; // Initializes the Dynamic Groups framework and groups diff --git a/framework/reinsert/script_component.hpp b/framework/reinsert/script_component.hpp new file mode 100644 index 0000000..770e8d7 --- /dev/null +++ b/framework/reinsert/script_component.hpp @@ -0,0 +1,3 @@ +#define COMPONENT fbcb2_reinsert +#define COMPONENT_BEAUTIFIED FBCB2 - Reinsertion +#include "../script_mod.hpp" \ No newline at end of file diff --git a/framework/resupply/functions/fn_addCBASettings.sqf b/framework/resupply/functions/fn_addCBASettings.sqf index ec8a7f1..898f60d 100644 --- a/framework/resupply/functions/fn_addCBASettings.sqf +++ b/framework/resupply/functions/fn_addCBASettings.sqf @@ -22,4 +22,10 @@ ] call EFUNC(util,log); }, true // requires mission restart -] call CBA_fnc_addSetting; \ No newline at end of file +] call CBA_fnc_addSetting; + +[ + QUOTE(COMPONENT), + "CREATED SETTINGS", + [] +] call EFUNC(util,log); \ No newline at end of file diff --git a/framework/util/functions/fn_getApprovedAssetsCfg.sqf b/framework/util/functions/fn_getApprovedAssetsCfg.sqf new file mode 100644 index 0000000..a3c8a09 --- /dev/null +++ b/framework/util/functions/fn_getApprovedAssetsCfg.sqf @@ -0,0 +1,14 @@ +#include "../script_component.hpp" + +private _approvedAssetsCfg = (missionConfigFile >> "ApprovedAssets"); + +if (!IS_CONFIG(_approvedAssetsCfg) || {!isClass _approvedAssetsCfg}) exitWith { + [ + QUOTE(COMPONENT), + "ERROR: Approved assets config not found. Check that the config is present and correctly named in the mission config file. See defines/ApprovedAssets.hpp and framework/util/functions/getApprovedAssetsCfg.sqf.", + [] + ] call EFUNC(util,log); + configNull; +}; + +_approvedAssetsCfg; \ No newline at end of file diff --git a/framework/util/functions/fn_getBattalionCfg.sqf b/framework/util/functions/fn_getBattalionCfg.sqf index b239a24..9286427 100644 --- a/framework/util/functions/fn_getBattalionCfg.sqf +++ b/framework/util/functions/fn_getBattalionCfg.sqf @@ -1 +1,14 @@ -(missionConfigFile >> "BattalionInfo") \ No newline at end of file +#include "../script_component.hpp" + +private _battalionInfoCfg = (missionConfigFile >> "BattalionInfo"); + +if (!IS_CONFIG(_battalionInfoCfg) || {!isClass _battalionInfoCfg}) exitWith { + [ + QUOTE(COMPONENT), + "ERROR: Battalion config not found. Check that the battalion config is present and correctly named in the mission config file. See defines/BattalionInfo.hpp and framework/util/functions/getBattalionCfg.sqf.", + [] + ] call EFUNC(util,log); + configNull; +}; + +_battalionInfoCfg; \ No newline at end of file -- 2.37.3.windows.1 From 0a64d9e170e3a310f118abc37b2e26b7056ca32d Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Tue, 6 Feb 2024 01:52:25 -0800 Subject: [PATCH 13/16] big refactor, WIP! --- defines/SignalColors.hpp | 44 ++++ description.ext | 1 + framework/CfgFunctions.hpp | 119 +++++---- framework/client/fn_addClientStatsPFH.sqf | 18 -- framework/client/fn_calculateClientStats.sqf | 29 -- .../fn_addMedicalOverlayPFH.sqf | 0 .../{ => functions}/fn_addZenModules.sqf | 0 .../fn_bindEmptyGroupGarbageCleanup.sqf | 0 .../{ => functions}/fn_bindEventHandlers.sqf | 13 +- .../{ => functions}/fn_bindVehicleActions.sqf | 0 framework/client/script_component.hpp | 3 + .../common/functions/fn_addCBASettings.sqf | 50 ++++ .../functions/fn_addPlayerInfoToArray.sqf | 0 .../functions/fn_getApprovedAssetsCfg.sqf | 3 +- .../functions/fn_getBattalionCfg.sqf | 3 +- .../functions/fn_getNameOfBase.sqf | 0 .../functions/fn_getNearestBase.sqf | 0 .../{util => common}/functions/fn_log.sqf | 10 +- .../functions/fn_logMissionInfo.sqf | 0 .../functions}/fn_logPlayerInventory.sqf | 28 +- .../common/functions/fn_logSettingChanged.sqf | 16 ++ .../functions/fn_padString.sqf | 0 .../functions/fn_recurseSubclasses.sqf | 0 framework/common/script_component.hpp | 3 + .../functions/fn_addCBASettings.sqf | 16 +- .../functions/fn_getCallsignFromClassname.sqf | 2 +- .../functions/fn_hintAllApprovedAssets.sqf | 5 +- .../fbcb2_assets/functions/fn_initClient.sqf | 7 + .../fbcb2_assets/functions/fn_initServer.sqf | 10 +- .../functions/fn_isAssetInRangeOfBase.sqf | 2 +- .../functions/fn_showMarkersOnMap.sqf | 2 +- .../functions/fn_updateAssetDiary.sqf | 3 +- .../functions/fn_updateAssetsByBase.sqf | 18 +- .../functions/fn_addEnvironmentRecord.sqf | 112 ++++++++ ...encies.sqf => fn_addFrequenciesRecord.sqf} | 8 +- .../functions/fn_addSignalColorsRecord.sqf | 59 +++++ framework/fbcb2_main/functions/fn_init.sqf | 21 +- .../functions/fn_processFBCB2Environment.sqf | 47 ---- .../functions/fn_processFBCB2SmokeColors.sqf | 43 --- .../util/fn_createOrUpdateDiaryRecord.sqf | 4 +- .../util/fn_formatRadioElementForDiary.sqf | 4 +- .../fn_generateElementFrequencyRecordText.sqf | 31 +-- .../init/functions/fn_addAARChatHandler.sqf | 16 ++ .../functions}/fn_addRespawnChatHandler.sqf | 16 +- .../init/functions/fn_initPlayerLocal.sqf | 9 + framework/init/functions/fn_initServer.sqf | 13 +- framework/init/functions/fn_setDefaults.sqf | 34 +++ .../functions/fn_addCBASettings.sqf | 105 ++++++++ .../functions/fn_addClientStatsPFH.sqf | 38 +++ .../functions}/fn_addDNI_PlayerFPS.sqf | 2 + .../functions}/fn_addServerStatsPFH.sqf | 42 ++- .../functions/fn_calculateClientStats.sqf | 40 +++ .../functions}/fn_calculateServerStats.sqf | 0 framework/performance/script_component.hpp | 3 + .../reinsert/client/fn_addAceSelfActions.sqf | 32 +-- .../client/fn_addCheckQueueSelfAction.sqf | 16 +- framework/reinsert/client/fn_initClient.sqf | 37 ++- .../reinsert/client/fn_requestShowQueue.sqf | 4 +- .../reinsert/functions/fn_addCBASettings.sqf | 83 ++++++ framework/reinsert/script_component.hpp | 4 +- framework/reinsert/server/fn_addToQueue.sqf | 43 +-- .../reinsert/server/fn_globalShowQueue.sqf | 39 +-- framework/reinsert/server/fn_initServer.sqf | 35 +-- .../reinsert/server/fn_removeFromQueue.sqf | 18 +- .../fn_returnReinsertQueueNotification.sqf | 8 +- .../reinsert/server/fn_validateQueue.sqf | 43 +-- .../resupply/functions/fn_addCBASettings.sqf | 16 +- framework/script_macros.hpp | 5 + framework/script_mod.hpp | 7 + framework/server/script_component.hpp | 3 + framework/settings/fn_addAARChatHandler.sqf | 11 - framework/settings/fn_addCBASettings.sqf | 247 ------------------ framework/settings/fn_setDefaults.sqf | 19 -- framework/util/script_component.hpp | 3 - 74 files changed, 1024 insertions(+), 701 deletions(-) create mode 100644 defines/SignalColors.hpp delete mode 100644 framework/client/fn_addClientStatsPFH.sqf delete mode 100644 framework/client/fn_calculateClientStats.sqf rename framework/client/{ => functions}/fn_addMedicalOverlayPFH.sqf (100%) rename framework/client/{ => functions}/fn_addZenModules.sqf (100%) rename framework/client/{ => functions}/fn_bindEmptyGroupGarbageCleanup.sqf (100%) rename framework/client/{ => functions}/fn_bindEventHandlers.sqf (82%) rename framework/client/{ => functions}/fn_bindVehicleActions.sqf (100%) create mode 100644 framework/client/script_component.hpp create mode 100644 framework/common/functions/fn_addCBASettings.sqf rename framework/{util => common}/functions/fn_addPlayerInfoToArray.sqf (100%) rename framework/{util => common}/functions/fn_getApprovedAssetsCfg.sqf (87%) rename framework/{util => common}/functions/fn_getBattalionCfg.sqf (87%) rename framework/{util => common}/functions/fn_getNameOfBase.sqf (100%) rename framework/{util => common}/functions/fn_getNearestBase.sqf (100%) rename framework/{util => common}/functions/fn_log.sqf (70%) rename framework/{util => common}/functions/fn_logMissionInfo.sqf (100%) rename framework/{server => common/functions}/fn_logPlayerInventory.sqf (89%) create mode 100644 framework/common/functions/fn_logSettingChanged.sqf rename framework/{util => common}/functions/fn_padString.sqf (100%) rename framework/{util => common}/functions/fn_recurseSubclasses.sqf (100%) create mode 100644 framework/common/script_component.hpp create mode 100644 framework/fbcb2_main/functions/fn_addEnvironmentRecord.sqf rename framework/fbcb2_main/functions/{fn_processFBCB2RadioFrequencies.sqf => fn_addFrequenciesRecord.sqf} (93%) create mode 100644 framework/fbcb2_main/functions/fn_addSignalColorsRecord.sqf delete mode 100644 framework/fbcb2_main/functions/fn_processFBCB2Environment.sqf delete mode 100644 framework/fbcb2_main/functions/fn_processFBCB2SmokeColors.sqf create mode 100644 framework/init/functions/fn_addAARChatHandler.sqf rename framework/{settings => init/functions}/fn_addRespawnChatHandler.sqf (53%) create mode 100644 framework/init/functions/fn_setDefaults.sqf create mode 100644 framework/performance/functions/fn_addCBASettings.sqf create mode 100644 framework/performance/functions/fn_addClientStatsPFH.sqf rename framework/{client => performance/functions}/fn_addDNI_PlayerFPS.sqf (97%) rename framework/{server => performance/functions}/fn_addServerStatsPFH.sqf (51%) create mode 100644 framework/performance/functions/fn_calculateClientStats.sqf rename framework/{server => performance/functions}/fn_calculateServerStats.sqf (100%) create mode 100644 framework/performance/script_component.hpp create mode 100644 framework/reinsert/functions/fn_addCBASettings.sqf create mode 100644 framework/server/script_component.hpp delete mode 100644 framework/settings/fn_addAARChatHandler.sqf delete mode 100644 framework/settings/fn_addCBASettings.sqf delete mode 100644 framework/settings/fn_setDefaults.sqf delete mode 100644 framework/util/script_component.hpp diff --git a/defines/SignalColors.hpp b/defines/SignalColors.hpp new file mode 100644 index 0000000..f6c3393 --- /dev/null +++ b/defines/SignalColors.hpp @@ -0,0 +1,44 @@ +class SignalColors { + class White { + name = "White"; + hexCode = "#FFFFFF"; + usage = "Concealment, Light"; + itemExamples[] = {"SmokeShell", "1Rnd_Smoke_Grenade_shell", "ACE_Chemlight_White"}; + }; + class Green { + name = "Green"; + hexCode = "#00FF00"; + usage = "Friendly Forces"; + itemExamples[] = {"SmokeShellGreen", "1Rnd_SmokeGreen_Grenade_shell", "Chemlight_green"}; + }; + class Blue { + name = "Blue"; + hexCode = "#0000FF"; + usage = "LZ Marking"; + itemExamples[] = {"SmokeShellBlue", "1Rnd_SmokeBlue_Grenade_shell", "Chemlight_blue"}; + }; + class Red { + name = "Red"; + hexCode = "#FF0000"; + usage = "Enemy Location"; + itemExamples[] = {"SmokeShellRed", "1Rnd_SmokeRed_Grenade_shell", "Chemlight_red"}; + }; + class Orange { + name = "Orange"; + hexCode = "#FFA500"; + usage = "Resupply Marker"; + itemExamples[] = {"SmokeShellOrange", "1Rnd_SmokeOrange_Grenade_shell", "ACE_Chemlight_Orange"}; + }; + class Yellow { + name = "Yellow"; + hexCode = "#FFFF00"; + usage = "Medical Emergency"; + itemExamples[] = {"SmokeShellYellow", "1Rnd_SmokeYellow_Grenade_shell", "Chemlight_yellow"}; + }; + class Purple { + name = "Purple"; + hexCode = "#800080"; + usage = "Broken Arrow - 100m radius"; + itemExamples[] = {"SmokeShellPurple", "1Rnd_SmokePurple_Grenade_shell"}; + }; +}; \ No newline at end of file diff --git a/description.ext b/description.ext index 6355ab9..b23393f 100644 --- a/description.ext +++ b/description.ext @@ -23,6 +23,7 @@ #include "defines\DisallowedEquipment.hpp" #include "defines\SupplyCrates.hpp" #include "defines\VehicleFlags.hpp" +#include "defines\SignalColors.hpp" //-------------------------------------------MISSION INFO-------------------------------------------------------------------- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/framework/CfgFunctions.hpp b/framework/CfgFunctions.hpp index b2690ff..57a566e 100644 --- a/framework/CfgFunctions.hpp +++ b/framework/CfgFunctions.hpp @@ -1,51 +1,14 @@ #include "script_mod.hpp" class CfgFunctions { - class PREFIX - { - class settings - { - file = "framework\settings"; - class setDefaults { postInit = 1; }; - class addCBASettings { preInit = 1; }; - class addAARChatHandler { postInit = 1; }; - class addRespawnChatHandler { postInit = 1; }; - }; - - class init - { - file = "framework\init\functions"; - class initServer { postInit = 1;}; //needs refactor - class initPlayerLocal { postInit = 1;}; - }; - - class client { - file = "framework\client"; - class addZenModules { postInit = 1; }; - class addDNI_PlayerFPS { postInit = 1; }; // needs refactor - class bindEventHandlers { postInit = 1; }; - class bindVehicleActions { postInit = 1; }; - class addClientStatsPFH {}; - class addMedicalOverlayPFH { postInit = 1; }; - class calculateClientStats {}; - class bindEmptyGroupGarbageCleanup { postInit = 1; }; - }; - - class server { - file = "framework\server"; - class addServerStatsPFH {}; - class calculateServerStats {}; - class logPlayerInventory {}; - }; - + class PREFIX { class ambience { file = "framework\ambience"; class flakInitVehicle {}; class flakEH {}; }; - class map - { + class map { file = "framework\map"; class initMapCopy { postInit = 1; }; class copyMapFromPlayer {}; //needs refactor @@ -56,7 +19,35 @@ class CfgFunctions { }; }; + class DOUBLES(PREFIX,client) { + class functions { + file = "framework\client\functions"; + class addMedicalOverlayPFH { postInit = 1; }; + class addZenModules { postInit = 1; }; + class bindEmptyGroupGarbageCleanup { postInit = 1; }; + class bindEventHandlers { postInit = 1; }; + class bindVehicleActions { postInit = 1; }; + }; + }; + + class DOUBLES(PREFIX,common) { + class functions { + file = "framework\common\functions"; + class addCBASettings { preInit = 1; }; + class logMissionInfo { postInit = 1; }; + class addPlayerInfoToArray {}; + class getApprovedAssetsCfg {}; + class getBattalionCfg {}; + class getNameOfBase {}; + class getNearestBase {}; + class log {}; + class logPlayerInventory {}; + class logSettingChanged {}; + class padString {}; + class recurseSubclasses {}; + }; + }; class DOUBLES(PREFIX,fbcb2_assets) { class functions { @@ -86,10 +77,9 @@ class CfgFunctions { class functions { file = "framework\fbcb2_main\functions"; class init { postInit = 1; }; - - class processFBCB2Environment {}; - class processFBCB2RadioFrequencies {}; - class processFBCB2SmokeColors {}; + class addEnvironmentRecord {}; + class addFrequenciesRecord {}; + class addSignalColorsRecord {}; }; class util { file = "framework\fbcb2_main\util"; @@ -99,7 +89,33 @@ class CfgFunctions { }; }; + class DOUBLES(PREFIX,init) { + file = "framework\init\functions"; + class addAARChatHandler { postInit = 1; }; + class addRespawnChatHandler { postInit = 1; }; + class initServer { postInit = 1;}; + class initPlayerLocal { postInit = 1;}; + class setDefaults { postInit = 1; }; + }; + + class DOUBLES(PREFIX,performance) { + class functions { + file = "framework\performance\functions"; + class addCBASettings {preInit=1;}; + class init {postInit=1;}; + class addDNI_PlayerFPS { postInit = 1; }; + class addClientStatsPFH {}; + class calculateClientStats {}; + class addServerStatsPFH {}; + class calculateServerStats {}; + }; + }; + class DOUBLES(PREFIX,reinsert) { + class functions { + file = "framework\reinsert\functions"; + class addCBASettings {preInit=1;}; + }; class server { file = "framework\reinsert\server"; class initServer { postInit = 1; }; @@ -129,21 +145,6 @@ class CfgFunctions { }; }; - class DOUBLES(PREFIX,util) { - class functions { - file = "framework\util\functions"; - class logMissionInfo { postInit = 1; }; - class addPlayerInfoToArray {}; - class log {}; - class padString {}; - class recurseSubclasses {}; - class getBattalionCfg {}; - class getNameOfBase {}; - class getNearestBase {}; - class getApprovedAssetsCfg {}; - }; - }; - class DOUBLES(PREFIX,vehicleFlags) { class functions { file = "framework\vehicleFlags\functions"; @@ -153,6 +154,4 @@ class CfgFunctions { class isClassExcluded {}; }; }; - - }; \ No newline at end of file diff --git a/framework/client/fn_addClientStatsPFH.sqf b/framework/client/fn_addClientStatsPFH.sqf deleted file mode 100644 index f85603e..0000000 --- a/framework/client/fn_addClientStatsPFH.sqf +++ /dev/null @@ -1,18 +0,0 @@ -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/framework/client/fn_calculateClientStats.sqf b/framework/client/fn_calculateClientStats.sqf deleted file mode 100644 index accf498..0000000 --- a/framework/client/fn_calculateClientStats.sqf +++ /dev/null @@ -1,29 +0,0 @@ -[] 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/framework/client/fn_addMedicalOverlayPFH.sqf b/framework/client/functions/fn_addMedicalOverlayPFH.sqf similarity index 100% rename from framework/client/fn_addMedicalOverlayPFH.sqf rename to framework/client/functions/fn_addMedicalOverlayPFH.sqf diff --git a/framework/client/fn_addZenModules.sqf b/framework/client/functions/fn_addZenModules.sqf similarity index 100% rename from framework/client/fn_addZenModules.sqf rename to framework/client/functions/fn_addZenModules.sqf diff --git a/framework/client/fn_bindEmptyGroupGarbageCleanup.sqf b/framework/client/functions/fn_bindEmptyGroupGarbageCleanup.sqf similarity index 100% rename from framework/client/fn_bindEmptyGroupGarbageCleanup.sqf rename to framework/client/functions/fn_bindEmptyGroupGarbageCleanup.sqf diff --git a/framework/client/fn_bindEventHandlers.sqf b/framework/client/functions/fn_bindEventHandlers.sqf similarity index 82% rename from framework/client/fn_bindEventHandlers.sqf rename to framework/client/functions/fn_bindEventHandlers.sqf index 55d4781..ed2ee97 100644 --- a/framework/client/fn_bindEventHandlers.sqf +++ b/framework/client/functions/fn_bindEventHandlers.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + if ( !hasInterface ) exitWith {}; player addEventHandler["Respawn", @@ -6,10 +8,11 @@ player addEventHandler["Respawn", private _killer = _corpse getVariable ["ace_medical_causeOfDeath", "#scripted"]; if (_killer == "respawn_button") then { [ - "client", + LEVEL_INFO + QUOTE(COMPONENT), "RESPAWNED WHILE UNCONSCIOUS", - [_unit] call milsim_util_fnc_addPlayerInfoToArray - ] remoteExec ["milsim_util_fnc_log", 2]; + [_unit] call EFUNC(common,addPlayerInfoToArray) + ] remoteExec [QEFUNC(common,log), 2]; // format["%1 was unconscious then clicked the respawn button", name _unit] remoteExec["systemChat", 0]; }; } @@ -43,11 +46,11 @@ addMissionEventHandler ["HandleChatMessage", ["ace_arsenal_displayClosed", { - [player] remoteExec ["milsim_util_fnc_logPlayerInventory", 2]; + [player] remoteExec [QEFUNC(common,logPlayerInventory), 2]; }] call CBA_fnc_addEventHandler; [missionNamespace, "arsenalClosed", { - [player] remoteExec ["milsim_util_fnc_logPlayerInventory", 2]; + [player] remoteExec [QEFUNC(common,logPlayerInventory), 2]; }] call BIS_fnc_addScriptedEventHandler; diag_log text "[MILSIM] (client) event handlers bound"; diff --git a/framework/client/fn_bindVehicleActions.sqf b/framework/client/functions/fn_bindVehicleActions.sqf similarity index 100% rename from framework/client/fn_bindVehicleActions.sqf rename to framework/client/functions/fn_bindVehicleActions.sqf diff --git a/framework/client/script_component.hpp b/framework/client/script_component.hpp new file mode 100644 index 0000000..3186ff3 --- /dev/null +++ b/framework/client/script_component.hpp @@ -0,0 +1,3 @@ +#define COMPONENT client +#define COMPONENT_BEAUTIFIED Client +#include "../script_mod.hpp" \ No newline at end of file diff --git a/framework/common/functions/fn_addCBASettings.sqf b/framework/common/functions/fn_addCBASettings.sqf new file mode 100644 index 0000000..9457034 --- /dev/null +++ b/framework/common/functions/fn_addCBASettings.sqf @@ -0,0 +1,50 @@ +#include "..\script_component.hpp" + +//--------------------- +// Side Chat +//--------------------- + +[ + QGVARMAIN(sideChat), + "CHECKBOX", + "Side Chat Text Enabled", + [QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)], + false, // default value + true, // requires restart + { + params ["_value"]; + [ + QGVARMAIN(sideChat), + _value + ] call EFUNC(common,logSettingChanged); + } +] call CBA_fnc_addSetting; + +[QGVARMAIN(sideChat), false] call CBA_settings_fnc_set; + + +//--------------------- +// Medical Overlay +//--------------------- + +[ + "milsim_client_medState3D_enabled", // variable + "CHECKBOX", // type + ["Enable 3D Triage Card State", "Draws a colored dot over units within 10m indicating current ACE Triage State"], // title + ["17th Battalion", "Medical"], // category + true // default value +] call CBA_fnc_addSetting; + +[ + "milsim_client_medState3D_drawRange", // variable + "LIST", // type + ["Range To Draw Icons", "Determines range at which dots are visible"], // title + ["17th Battalion", "Medical"], // category + [[2, 4, 6, 8, 10], ["2", "4", "6", "8", "10"], 4] // option values, option labels, default index +] call CBA_fnc_addSetting; + + + +diag_log text "[MILSIM] (settings) Custom CBA settings initialized"; + +nil; \ No newline at end of file diff --git a/framework/util/functions/fn_addPlayerInfoToArray.sqf b/framework/common/functions/fn_addPlayerInfoToArray.sqf similarity index 100% rename from framework/util/functions/fn_addPlayerInfoToArray.sqf rename to framework/common/functions/fn_addPlayerInfoToArray.sqf diff --git a/framework/util/functions/fn_getApprovedAssetsCfg.sqf b/framework/common/functions/fn_getApprovedAssetsCfg.sqf similarity index 87% rename from framework/util/functions/fn_getApprovedAssetsCfg.sqf rename to framework/common/functions/fn_getApprovedAssetsCfg.sqf index a3c8a09..bb18e61 100644 --- a/framework/util/functions/fn_getApprovedAssetsCfg.sqf +++ b/framework/common/functions/fn_getApprovedAssetsCfg.sqf @@ -4,10 +4,11 @@ private _approvedAssetsCfg = (missionConfigFile >> "ApprovedAssets"); if (!IS_CONFIG(_approvedAssetsCfg) || {!isClass _approvedAssetsCfg}) exitWith { [ + LEVEL_ERROR, QUOTE(COMPONENT), "ERROR: Approved assets config not found. Check that the config is present and correctly named in the mission config file. See defines/ApprovedAssets.hpp and framework/util/functions/getApprovedAssetsCfg.sqf.", [] - ] call EFUNC(util,log); + ] call EFUNC(common,log); configNull; }; diff --git a/framework/util/functions/fn_getBattalionCfg.sqf b/framework/common/functions/fn_getBattalionCfg.sqf similarity index 87% rename from framework/util/functions/fn_getBattalionCfg.sqf rename to framework/common/functions/fn_getBattalionCfg.sqf index 9286427..cfac05c 100644 --- a/framework/util/functions/fn_getBattalionCfg.sqf +++ b/framework/common/functions/fn_getBattalionCfg.sqf @@ -4,10 +4,11 @@ private _battalionInfoCfg = (missionConfigFile >> "BattalionInfo"); if (!IS_CONFIG(_battalionInfoCfg) || {!isClass _battalionInfoCfg}) exitWith { [ + LEVEL_ERROR, QUOTE(COMPONENT), "ERROR: Battalion config not found. Check that the battalion config is present and correctly named in the mission config file. See defines/BattalionInfo.hpp and framework/util/functions/getBattalionCfg.sqf.", [] - ] call EFUNC(util,log); + ] call EFUNC(common,log); configNull; }; diff --git a/framework/util/functions/fn_getNameOfBase.sqf b/framework/common/functions/fn_getNameOfBase.sqf similarity index 100% rename from framework/util/functions/fn_getNameOfBase.sqf rename to framework/common/functions/fn_getNameOfBase.sqf diff --git a/framework/util/functions/fn_getNearestBase.sqf b/framework/common/functions/fn_getNearestBase.sqf similarity index 100% rename from framework/util/functions/fn_getNearestBase.sqf rename to framework/common/functions/fn_getNearestBase.sqf diff --git a/framework/util/functions/fn_log.sqf b/framework/common/functions/fn_log.sqf similarity index 70% rename from framework/util/functions/fn_log.sqf rename to framework/common/functions/fn_log.sqf index 80639e0..975633c 100644 --- a/framework/util/functions/fn_log.sqf +++ b/framework/common/functions/fn_log.sqf @@ -5,18 +5,22 @@ Used to log messages to the server RPT file. Parameters: - 0: STRING - component name. - 1: STRING - message to log. - 2: ARRAY - Key value pairs of data to log. + 0: NUMBER - log level. + 1: STRING - component name. + 2: STRING - message to log. + 3: ARRAY - key value pairs of data to log. */ #include "..\script_component.hpp" params [ + ["_logLevel", 1, [-1,0,1,2,3]], // script_mod.hpp ["_component", "", [""]], ["_message", "", [""]], ["_data", [], [[]]] ]; +if (_logLevel < LOG_LEVEL) exitWith {}; + private _hash = createHashMapFromArray _data; // Replace square brackets with round brackets to avoid parsing issues. diff --git a/framework/util/functions/fn_logMissionInfo.sqf b/framework/common/functions/fn_logMissionInfo.sqf similarity index 100% rename from framework/util/functions/fn_logMissionInfo.sqf rename to framework/common/functions/fn_logMissionInfo.sqf diff --git a/framework/server/fn_logPlayerInventory.sqf b/framework/common/functions/fn_logPlayerInventory.sqf similarity index 89% rename from framework/server/fn_logPlayerInventory.sqf rename to framework/common/functions/fn_logPlayerInventory.sqf index 105b286..97951de 100644 --- a/framework/server/fn_logPlayerInventory.sqf +++ b/framework/common/functions/fn_logPlayerInventory.sqf @@ -13,16 +13,19 @@ - Array of strings to be logged. */ +#include "..\script_component.hpp" + params [ ["_player", objNull, [objNull]] ]; if (!isPlayer _player) exitWith { [ - "logPlayerInventory", + LEVEL_ERROR + QUOTE(COMPONENT), "PARAM PLAYER IS NOT A PLAYER", [["player", _player]] - ] call milsim_util_fnc_log; + ] call EFUNC(common,log); }; // testing @@ -53,10 +56,11 @@ _playerItems pushBack (uniform _player); [ - "logPlayerInventory", + LEVEL_INFO, + QUOTE(COMPONENT), "CHECKING PLAYER INVENTORY", - [_player] call milsim_util_fnc_addPlayerInfoToArray -] call milsim_util_fnc_log; + [_player] call EFUNC(common,addPlayerInfoToArray) +] call EFUNC(common,log); //////////////////////////////////////// // HARDCODED DISALLOWED ITEMS - see functions/definitions/DisallowedEquipment.hpp @@ -115,10 +119,11 @@ private _thermalItems = _playerItems select { // Only log compliance message if no non-compliant items were found if (count _allFoundItemsSoFar isEqualTo 0) exitWith { [ - "logPlayerInventory", + LEVEL_INFO, + QUOTE(COMPONENT), "PLAYER INVENTORY IS COMPLIANT", - [_player] call milsim_util_fnc_addPlayerInfoToArray - ] call milsim_util_fnc_log; + [_player] call EFUNC(common,addPlayerInfoToArray) + ] call EFUNC(common,log); }; // Log all non-compliant items @@ -132,13 +137,14 @@ if (count _allFoundItemsSoFar isEqualTo 0) exitWith { private _itemConfig = _itemClassName call CBA_fnc_getItemConfig; // Log to RPT [ - "logPlayerInventory", + LEVEL_WARNING, + QUOTE(COMPONENT), "NON-COMPLIANT ITEM", [_player, [ ["category", _categoryLabel], ["className", _itemClassName], ["displayName", [_itemConfig] call BIS_fnc_displayName] - ]] call milsim_util_fnc_addPlayerInfoToArray - ] call milsim_util_fnc_log; + ]] call EFUNC(common,addPlayerInfoToArray) + ] call EFUNC(common,log); } forEach _items; } forEach _foundItemsKeyValue; \ No newline at end of file diff --git a/framework/common/functions/fn_logSettingChanged.sqf b/framework/common/functions/fn_logSettingChanged.sqf new file mode 100644 index 0000000..c8a31e2 --- /dev/null +++ b/framework/common/functions/fn_logSettingChanged.sqf @@ -0,0 +1,16 @@ +#include "..\script_component.hpp" + +params [ + ["_settingName", "", [""]], + "_newValue" +]; + +[ + LEVEL_INFO, + QUOTE(COMPONENT), + "SETTING CHANGED", + [ + ["setting", _settingName], + ["newValue", _value] + ] +] call EFUNC(common,log); \ No newline at end of file diff --git a/framework/util/functions/fn_padString.sqf b/framework/common/functions/fn_padString.sqf similarity index 100% rename from framework/util/functions/fn_padString.sqf rename to framework/common/functions/fn_padString.sqf diff --git a/framework/util/functions/fn_recurseSubclasses.sqf b/framework/common/functions/fn_recurseSubclasses.sqf similarity index 100% rename from framework/util/functions/fn_recurseSubclasses.sqf rename to framework/common/functions/fn_recurseSubclasses.sqf diff --git a/framework/common/script_component.hpp b/framework/common/script_component.hpp new file mode 100644 index 0000000..282e7ad --- /dev/null +++ b/framework/common/script_component.hpp @@ -0,0 +1,3 @@ +#define COMPONENT common +#define COMPONENT_BEAUTIFIED Common +#include "../script_mod.hpp" \ No newline at end of file diff --git a/framework/fbcb2_assets/functions/fn_addCBASettings.sqf b/framework/fbcb2_assets/functions/fn_addCBASettings.sqf index fe0e0fc..efad170 100644 --- a/framework/fbcb2_assets/functions/fn_addCBASettings.sqf +++ b/framework/fbcb2_assets/functions/fn_addCBASettings.sqf @@ -13,21 +13,15 @@ { params ["_value"]; [ - QUOTE(COMPONENT), - "SETTING CHANGED", - [ - [ - "setting", - "milsim_fbcb2_assets_setting_detectionRangeFromBase" - ], - ["newValue", _value] - ] - ] call EFUNC(util,log); + QGVAR(setting_detectionRangeFromBase), + _value + ] call EFUNC(common,logSettingChanged); } ] call CBA_fnc_addSetting; [ + LEVEL_INFO, QUOTE(COMPONENT), "CREATED SETTINGS", [] -] call EFUNC(util,log); \ No newline at end of file +] call EFUNC(common,log); \ No newline at end of file diff --git a/framework/fbcb2_assets/functions/fn_getCallsignFromClassname.sqf b/framework/fbcb2_assets/functions/fn_getCallsignFromClassname.sqf index 866331c..09a7d17 100644 --- a/framework/fbcb2_assets/functions/fn_getCallsignFromClassname.sqf +++ b/framework/fbcb2_assets/functions/fn_getCallsignFromClassname.sqf @@ -5,7 +5,7 @@ params [ ]; // Get the approved assets config -private _approvedAssetsCfg = call EFUNC(util,getApprovedAssetsCfg); +private _approvedAssetsCfg = call EFUNC(common,getApprovedAssetsCfg); if (isNull _approvedAssetsCfg) exitWith {""}; // Get the asset definition diff --git a/framework/fbcb2_assets/functions/fn_hintAllApprovedAssets.sqf b/framework/fbcb2_assets/functions/fn_hintAllApprovedAssets.sqf index 7a851fe..f419db3 100644 --- a/framework/fbcb2_assets/functions/fn_hintAllApprovedAssets.sqf +++ b/framework/fbcb2_assets/functions/fn_hintAllApprovedAssets.sqf @@ -15,13 +15,14 @@ private _distinctStartingAssetsClassNames = []; } forEach _startingAssets; // get the approved assets config to identify callsigns -private _approvedAssetsCfg = call EFUNC(util,getApprovedAssetsCfg); +private _approvedAssetsCfg = call EFUNC(common,getApprovedAssetsCfg); if (isNull _approvedAssetsCfg) exitWith { [ + LEVEL_ERROR, QUOTE(COMPONENT), "No approved assets defined.", [] - ] call EFUNC(util,log); + ] call EFUNC(common,log); [ "ERROR: No approved assets defined. See defines/ApprovedAssets.hpp" ] call BIS_fnc_error; diff --git a/framework/fbcb2_assets/functions/fn_initClient.sqf b/framework/fbcb2_assets/functions/fn_initClient.sqf index 28f1103..57d6474 100644 --- a/framework/fbcb2_assets/functions/fn_initClient.sqf +++ b/framework/fbcb2_assets/functions/fn_initClient.sqf @@ -7,3 +7,10 @@ if (!hasInterface) exitWith {}; [{missionNamespace getVariable [QGVAR(serverAssetsReady), false]}, { call FUNC(updateAssetDiary); }] call CBA_fnc_waitUntilAndExecute; + +[ + LEVEL_DEBUG, + QUOTE(COMPONENT), + "postInit complete", + [] +] call EFUNC(common,log); \ No newline at end of file diff --git a/framework/fbcb2_assets/functions/fn_initServer.sqf b/framework/fbcb2_assets/functions/fn_initServer.sqf index 70acbed..15dab32 100644 --- a/framework/fbcb2_assets/functions/fn_initServer.sqf +++ b/framework/fbcb2_assets/functions/fn_initServer.sqf @@ -20,4 +20,12 @@ missionNamespace setVariable [QGVAR(serverAssetsReady), true, true]; addMissionEventHandler ["MPEnded", { // log the "current" asset counts to RPT [false, true] call FUNC(updateAssetsByBase); -}]; \ No newline at end of file +}]; + + +[ + LEVEL_DEBUG, + QUOTE(COMPONENT), + "postInit complete", + [] +] call EFUNC(common,log); \ No newline at end of file diff --git a/framework/fbcb2_assets/functions/fn_isAssetInRangeOfBase.sqf b/framework/fbcb2_assets/functions/fn_isAssetInRangeOfBase.sqf index c858c14..e4c80df 100644 --- a/framework/fbcb2_assets/functions/fn_isAssetInRangeOfBase.sqf +++ b/framework/fbcb2_assets/functions/fn_isAssetInRangeOfBase.sqf @@ -2,7 +2,7 @@ params [["_asset", objNull, [objNull]]]; -private _closestBase = [_asset] call EFUNC(util,getNearestBase); +private _closestBase = [_asset] call EFUNC(common,getNearestBase); if (isNull _closestBase) exitWith {false}; (_asset distance2D _closestBase) <= GVAR(setting_detectionRangeFromBase) \ No newline at end of file diff --git a/framework/fbcb2_assets/functions/fn_showMarkersOnMap.sqf b/framework/fbcb2_assets/functions/fn_showMarkersOnMap.sqf index 265f0b6..4ca1825 100644 --- a/framework/fbcb2_assets/functions/fn_showMarkersOnMap.sqf +++ b/framework/fbcb2_assets/functions/fn_showMarkersOnMap.sqf @@ -63,7 +63,7 @@ if (not (count _baseMarkerStore > 0)) then { _newMarker setMarkerTypeLocal "mil_flag"; _newMarker setMarkerColorLocal "ColorGreen"; _newMarker setMarkerSizeLocal [0.7, 0.7]; - _newMarker setMarkerTextLocal ([_base] call EFUNC(util,getNameOfBase)); + _newMarker setMarkerTextLocal ([_base] call EFUNC(common,getNameOfBase)); _baseMarkerStore pushBack [ _base, diff --git a/framework/fbcb2_assets/functions/fn_updateAssetDiary.sqf b/framework/fbcb2_assets/functions/fn_updateAssetDiary.sqf index 9d5cc7e..72e516d 100644 --- a/framework/fbcb2_assets/functions/fn_updateAssetDiary.sqf +++ b/framework/fbcb2_assets/functions/fn_updateAssetDiary.sqf @@ -248,6 +248,7 @@ private _randomColors = [ // log to RPT [ + LEVEL_INFO, QUOTE(COMPONENT), "UPDATED ASSET DIARY", [ @@ -255,6 +256,6 @@ private _randomColors = [ ["startingAssetCountDistinct", count _distinctVehiclesClassNames], ["currentassetCount", count _currentAssets] ] -] call EFUNC(util,log); +] call EFUNC(common,log); true; \ No newline at end of file diff --git a/framework/fbcb2_assets/functions/fn_updateAssetsByBase.sqf b/framework/fbcb2_assets/functions/fn_updateAssetsByBase.sqf index c775bbe..d48bc5a 100644 --- a/framework/fbcb2_assets/functions/fn_updateAssetsByBase.sqf +++ b/framework/fbcb2_assets/functions/fn_updateAssetsByBase.sqf @@ -17,7 +17,7 @@ private _allSaved = []; private _assetsAtThisBaseVar = QGVAR(assetsAtThisBase); private _assetsStartedAtThisBaseVar = QGVAR(assetsStartedAtThisBase); -private _approvedAssetsCfg = call EFUNC(util,getApprovedAssetsCfg); +private _approvedAssetsCfg = call EFUNC(common,getApprovedAssetsCfg); if (isNull _approvedAssetsCfg) exitWith {}; { @@ -34,7 +34,7 @@ if (isNull _approvedAssetsCfg) exitWith {}; // add to base's assets list - private _closestBase = [_asset] call EFUNC(util,getNearestBase); + private _closestBase = [_asset] call EFUNC(common,getNearestBase); private _baseAssets = _closestBase getVariable [_assetsAtThisBaseVar, []]; _baseAssets pushBackUnique [ _asset call BIS_fnc_netId, @@ -69,7 +69,7 @@ if (isNull _approvedAssetsCfg) exitWith {}; // add to base's assets list - private _closestBase = [_asset] call EFUNC(util,getNearestBase); + private _closestBase = [_asset] call EFUNC(common,getNearestBase); private _baseAssets = _closestBase getVariable [_assetsAtThisBaseVar, []]; _baseAssets pushBackUnique [ _asset call BIS_fnc_netId, @@ -142,13 +142,14 @@ if !(_isInit || _logCurrentAssets) exitWith {}; if (_logCurrentAssets) then { { [ + LEVEL_INFO, QUOTE(COMPONENT), "CURRENT ASSETS", [ - ["baseName", [[_base] call EFUNC(util,getNameOfBase)]], + ["baseName", [[_base] call EFUNC(common,getNameOfBase)]], ["asset", _x] ] - ] call EFUNC(util,log); + ] call EFUNC(common,log); } forEach _baseAssetsHashes; }; @@ -156,13 +157,14 @@ if !(_isInit || _logCurrentAssets) exitWith {}; if (_isInit) then { { [ - "fbcb2_assets", + LEVEL_INFO, + QUOTE(COMPONENT), "STARTING ASSETS", [ - ["baseName", [[_base] call EFUNC(util,getNameOfBase)]], + ["baseName", [[_base] call EFUNC(common,getNameOfBase)]], ["asset", _x] ] - ] call EFUNC(util,log); + ] call EFUNC(common,log); } forEach _baseAssetsHashes; }; } forEach GVARMAIN(baseObjects); \ No newline at end of file diff --git a/framework/fbcb2_main/functions/fn_addEnvironmentRecord.sqf b/framework/fbcb2_main/functions/fn_addEnvironmentRecord.sqf new file mode 100644 index 0000000..3cc7dda --- /dev/null +++ b/framework/fbcb2_main/functions/fn_addEnvironmentRecord.sqf @@ -0,0 +1,112 @@ +#include "..\script_component.hpp" + +private _recordTitle = "ENVIRONMENTAL CONDITIONS"; + +private _text = [ + format[ + "%4", + GVAR(recordTitleSize), + GVAR(recordTitleColor), + GVAR(recordTitleFont), + _recordTitle + ] +]; + +private _sunriseColor = "#4A86E8"; +private _sunsetColor = "#6AA84F"; +private _whiteColor = "#FFFFFF"; + +private _sunTimes = date call BIS_fnc_sunriseSunsetTime; +private _nearestBase = [player] call EFUNC(common,getNearestBase); + +if (isNull _nearestBase) exitWith { + [ + LEVEL_WARNING, + QUOTE(COMPONENT), + "WARNING: No bases found nearby to report weather!", + [player, [ + ["position", getPos player] + ]] call EFUNC(common,addPlayerInfoToArray) + ] call EFUNC(common,log); + ["WARNING: No bases found nearby to report weather!"] call BIS_fnc_error; +}; + +_text pushBack format[ + "Current conditions at nearest weather station: %2
", + GVAR(recordTextBodySize), + [_nearestBase] call EFUNC(common,getNameOfBase) +]; + +private _weatherData = []; + +if (isClass (configFile >> "CfgPatches" >> "ace_weather")) then { + // get ace_weather data + private _barometricPressure = ((getPosASL _nearestBase)#2) call ace_weather_fnc_calculateBarometricPressure; + private _relHumidity = missionNamespace getVariable ["ace_weather_currentHumidity", 0.5]; + private _temperature = ((getPosASL _nearestBase)#2) call ace_weather_fnc_calculateTemperatureAtHeight; + private _dewPoint = [_temperature, _relHumidity] call ace_weather_fnc_calculateDewPoint; + private _windSpeed = [getPosASL _nearestBase, false, false, false] call ace_weather_fnc_calculateWindSpeed; + private _windChill = [_temperature, _windSpeed] call ace_weather_fnc_calculateWindChill; + private _heatIndex = [_temperature, _relHumidity] call ace_weather_fnc_calculateHeatIndex; + + toFixed 2; + private _aceData = [ + ["Temperature", format["%1°C / %2°F", _temperature, _temperature * (9/5) + 32]], + ["Wind Chill", format["%1°C / %2°F", _windChill, _windChill * (9/5) + 32]], + ["Heat Index", format["%1°C / %2°F", _heatIndex, _heatIndex * (9/5) + 32]], + ["Dew Point", format["%1°C / %2°F", _dewPoint, _dewPoint * (9/5) + 32]], + ["Wind Speed", format["%1mph / %2kph / %3kts", _windSpeed * 2.237, _windSpeed * 3.6, _windSpeed * 1.944]], + ["Wind Direction", ""], + ["Barometric Pressure", format["%1 hPA", _barometricPressure]], + ["Relative Humidity", format["%1%2", _relHumidity * 100, "%"]], + ["Fog Cover", ""], + ["Rain", ""], + ["Overcast", ""] + ]; + toFixed -1; + + { + _x params ["_name", "_value"]; + [_weatherData, _name, _value] call BIS_fnc_setToPairs; + } forEach _aceData; +}; + +// always add built-in weather +toFixed 2; +private _vanillaData = [ + ["Temperature", format["%1°C", (ambientTemperature)#0]], + ["Fog Cover", format["%1%2", fog * 100, "%"]], + ["Overcast", format["%1%2", overcast * 100, "%"]], + ["Rain", format["%1%2", rain * 100, "%"]], + ["Wind Speed", format["%1m/s", windStr]], + ["Wind Direction", format["%1°", windDir]] +]; +toFixed -1; + +_vanillaData pushBack ["Sunrise", ([_sunTimes select 0, "HH:MM"] call BIS_fnc_timeToString)]; +_vanillaData pushBack ["Sunset", ([_sunTimes select 1, "HH:MM"] call BIS_fnc_timeToString)]; + +// override or set keys for vanilla data into weather data +{ + _x params ["_name", "_value"]; + [_weatherData, _name, _value] call BIS_fnc_setToPairs; +} forEach _vanillaData; + +// write lines +{ + _x params ["_name", "_value"]; + _text pushBack format[ + "%2%3", + GVAR(recordTextBodySize)-4, + [_name, "right", " ", 23] call EFUNC(common,padString), + _value + ]; +} forEach _weatherData; + +_text = _text joinString "
"; + +[ + GVAR(subjectIntelID), + _recordTitle, + _text +] call FUNC(createOrUpdateDiaryRecord); \ No newline at end of file diff --git a/framework/fbcb2_main/functions/fn_processFBCB2RadioFrequencies.sqf b/framework/fbcb2_main/functions/fn_addFrequenciesRecord.sqf similarity index 93% rename from framework/fbcb2_main/functions/fn_processFBCB2RadioFrequencies.sqf rename to framework/fbcb2_main/functions/fn_addFrequenciesRecord.sqf index 3a633da..64f1ca4 100644 --- a/framework/fbcb2_main/functions/fn_processFBCB2RadioFrequencies.sqf +++ b/framework/fbcb2_main/functions/fn_addFrequenciesRecord.sqf @@ -6,22 +6,24 @@ //////////////////////////////////////// // Get info from missionConfigFile //////////////////////////////////////// -private _battalionInfoCfg = call EFUNC(util,getBattalionCfg); +private _battalionInfoCfg = call EFUNC(common,getBattalionCfg); if (isNull _battalionInfoCfg) exitWith { [ + LEVEL_ERROR, QUOTE(COMPONENT), "Null Battalion Config", [] - ] call EFUNC(util,log); + ] call EFUNC(common,log); }; private _battalionElementCfgs = [_battalionInfoCfg >> "Command"] call BIS_fnc_returnChildren; if (count _battalionElementCfgs == 0) exitWith { [ + LEVEL_ERROR, QUOTE(COMPONENT), "ERROR: No battalion elements found. Check that the battalion config is correctly structured. See defines/BattalionInfo.hpp and framework/util/functions/getBattalionCfg.sqf.", [] - ] call EFUNC(util,log); + ] call EFUNC(common,log); }; //////////////////////////////////////// diff --git a/framework/fbcb2_main/functions/fn_addSignalColorsRecord.sqf b/framework/fbcb2_main/functions/fn_addSignalColorsRecord.sqf new file mode 100644 index 0000000..078c72f --- /dev/null +++ b/framework/fbcb2_main/functions/fn_addSignalColorsRecord.sqf @@ -0,0 +1,59 @@ +#include "../script_component.hpp" + +private _recordTitle = "SIGNAL COLORS"; + +private _text = [ + // Title + format[ + "%4", + GVAR(recordTitleSize), + GVAR(recordTitleColor), + GVAR(recordTitleFont), + _recordTitle + ] +]; + +private _signalColorDefs = (missionConfigFile >> "SignalColors") call BIS_fnc_returnChildren; + +{ + private _cfg = _x; + private _color = getText(_cfg >> "hexCode"); + private _name = getText(_cfg >> "name"); + private _usage = getText(_cfg >> "usage"); + private _itemExamples = getArray(_cfg >> "itemExamples"); + + private _thisText = []; + + _thisText pushBack format[ + "%3 - %4", + GVAR(recordTextHeaderSize), + _color, + _name, + _usage + ]; + + private _imagesLine = []; + + { + private _itemClassname = _x; + private _itemCfg = [_itemClassname] call CBA_fnc_getItemConfig; + private _itemName = getText(_itemCfg >> "displayName"); + private _itemImage = getText(_itemCfg >> "picture"); + _imagesLine pushBack format[ + "", + _itemImage, + _itemName + ]; + } forEach _itemExamples; + + _thisText pushBack (_imagesLine joinString " "); + _text pushBack (_thisText joinString "
"); +} forEach _signalColorDefs; + +_text = _text joinString "

"; + +[ + GVAR(subjectIntelID), + _recordTitle, + _text +] call FUNC(createOrUpdateDiaryRecord); \ No newline at end of file diff --git a/framework/fbcb2_main/functions/fn_init.sqf b/framework/fbcb2_main/functions/fn_init.sqf index fe1f55f..473123d 100644 --- a/framework/fbcb2_main/functions/fn_init.sqf +++ b/framework/fbcb2_main/functions/fn_init.sqf @@ -34,6 +34,21 @@ player createDiarySubject[GVAR(subjectAssetsGroundID), "FBCB2 Ground"]; GVAR(diaryRecords) = createHashMap; // run main inits - assets handled in that component -[] call FUNC(processFBCB2RadioFrequencies); -[] call FUNC(processFBCB2SmokeColors); -[] call FUNC(processFBCB2Environment); \ No newline at end of file +[] call FUNC(addFrequenciesRecord); +[] call FUNC(addSignalColorsRecord); +[] call FUNC(addEnvironmentRecord); + +// starting 5 minutes after postInit, update weather diary record every 5 minutes +[{ + [ + {call FUNC(addEnvironmentRecord);}, + 60*5 + ] call CBA_fnc_addPerFrameHandler; +}, 60*5] call CBA_fnc_waitAndExecute; + +[ + LEVEL_DEBUG, + QUOTE(COMPONENT), + "postInit complete", + [] +] call EFUNC(common,log); \ No newline at end of file diff --git a/framework/fbcb2_main/functions/fn_processFBCB2Environment.sqf b/framework/fbcb2_main/functions/fn_processFBCB2Environment.sqf deleted file mode 100644 index 1bc6612..0000000 --- a/framework/fbcb2_main/functions/fn_processFBCB2Environment.sqf +++ /dev/null @@ -1,47 +0,0 @@ -#include "..\script_component.hpp" - -private _recordTitle = "MDS - INTEL - ENVIRONMENT"; - -private _text = [ - format[ - "%4

", - GVAR(recordTitleSize), - GVAR(recordTitleColor), - GVAR(recordTitleFont), - _recordTitle - ] -]; - -private _sunriseColor = "#4A86E8"; -private _sunsetColor = "#6AA84F"; -private _whiteColor = "#FFFFFF"; - -private _sunTimes = date call BIS_fnc_sunriseSunsetTime; - -_text pushBack format[ - "Local Sunrise
- %5

", - GVAR(recordTextHeaderSize), - _sunriseColor, - GVAR(recordTextBodySize), - _whiteColor, - ([_sunTimes select 0, "HH:MM"] call BIS_fnc_timeToString) -]; - -_text pushBack format[ - "Local Sunset
- %5

", - GVAR(recordTextHeaderSize), - _sunsetColor, - GVAR(recordTextBodySize), - _whiteColor, - ([_sunTimes select 1, "HH:MM"] call BIS_fnc_timeToString) -]; - -_text = _text joinString ""; - -[ - GVAR(subjectIntelID), - _recordTitle, - _text -] call FUNC(createOrUpdateDiaryRecord); \ No newline at end of file diff --git a/framework/fbcb2_main/functions/fn_processFBCB2SmokeColors.sqf b/framework/fbcb2_main/functions/fn_processFBCB2SmokeColors.sqf deleted file mode 100644 index 7622d46..0000000 --- a/framework/fbcb2_main/functions/fn_processFBCB2SmokeColors.sqf +++ /dev/null @@ -1,43 +0,0 @@ -#include "../script_component.hpp" - -private _recordTitle = "MDS - INTEL - SMOKES"; - -private _text = [ - // Title - format[ - "%4", - GVAR(recordTitleSize), - GVAR(recordTitleColor), - GVAR(recordTitleFont), - _recordTitle - ] -]; - -private _smokeColors = [ - ["#FFFFFF", "WHITE", "Concealment"], - ["#008800", "GREEN", "Friendly Forces"], - ["#0000FF", "BLUE", "LZ Markers"], - ["#FF0000", "RED", "Enemy Location"], - ["#FFA500", "ORANGE", "Resupply Marker"], - ["#FFFF00", "YELLOW", "Medical Emergency"], - ["#800080", "PURPLE", "Broken Arrow - 100m radius"] -]; - -{ - _x params ["_color", "_name", "_description"]; - _text pushBack format[ - "%3 - %4", - GVAR(recordTextHeaderSize), - _color, - _name, - _description - ]; -} forEach _smokeColors; - -_text = _text joinString "

"; - -[ - GVAR(subjectIntelID), - _recordTitle, - _text -] call FUNC(createOrUpdateDiaryRecord); \ No newline at end of file diff --git a/framework/fbcb2_main/util/fn_createOrUpdateDiaryRecord.sqf b/framework/fbcb2_main/util/fn_createOrUpdateDiaryRecord.sqf index e828493..824c271 100644 --- a/framework/fbcb2_main/util/fn_createOrUpdateDiaryRecord.sqf +++ b/framework/fbcb2_main/util/fn_createOrUpdateDiaryRecord.sqf @@ -15,7 +15,9 @@ private _existingRecord = _subjectRecords getOrDefault [_recordTitle, diaryRecor if (!isNull _existingRecord) then { player setDiaryRecordText [[_subjectID, _existingRecord], [_recordTitle, _recordText, _recordIcon]]; - systemChat format ["Updated diary record: %1", _recordTitle]; + if (DEBUG_ENABLED) then { + systemChat format ["Updated diary record: %1", _recordTitle]; + }; } else { private _new = player createDiaryRecord [ _subjectID, diff --git a/framework/fbcb2_main/util/fn_formatRadioElementForDiary.sqf b/framework/fbcb2_main/util/fn_formatRadioElementForDiary.sqf index 223de2a..055ea6e 100644 --- a/framework/fbcb2_main/util/fn_formatRadioElementForDiary.sqf +++ b/framework/fbcb2_main/util/fn_formatRadioElementForDiary.sqf @@ -64,8 +64,8 @@ _freqLeadingSpace = _freqLeadingSpace joinString ""; _ELEMENT_FREQ_SIZE, _ELEMENT_FREQ_FONT, _FREQ_TEXT_COLOR, - [_role, "right", " ", _FREQ_PAD_LENGTH] call EFUNC(util,padString), - [_srStr, "right", " ", _FREQ_PAD_LENGTH] call EFUNC(util,padString), + [_role, "right", " ", _FREQ_PAD_LENGTH] call EFUNC(common,padString), + [_srStr, "right", " ", _FREQ_PAD_LENGTH] call EFUNC(common,padString), _lrStr ]; } forEach (getArray (_cfg >> "frequencies")); diff --git a/framework/fbcb2_main/util/fn_generateElementFrequencyRecordText.sqf b/framework/fbcb2_main/util/fn_generateElementFrequencyRecordText.sqf index ee57bbe..d63b328 100644 --- a/framework/fbcb2_main/util/fn_generateElementFrequencyRecordText.sqf +++ b/framework/fbcb2_main/util/fn_generateElementFrequencyRecordText.sqf @@ -54,8 +54,8 @@ private _headers = [ _ELEMENT_FREQ_SIZE, _ELEMENT_FREQ_FONT, _FREQ_TEXT_COLOR, - ["ROLE", "right", " ", _FREQ_PAD_LENGTH] call EFUNC(util,padString), - ["SR", "right", " ", _FREQ_PAD_LENGTH] call EFUNC(util,padString), + ["ROLE", "right", " ", _FREQ_PAD_LENGTH] call EFUNC(common,padString), + ["SR", "right", " ", _FREQ_PAD_LENGTH] call EFUNC(common,padString), "LR" ] ]; @@ -68,26 +68,27 @@ private _allText = []; // get all child elements recursively and format them if (_shouldProcessChildCfgs) then { - diag_log text format[ - "[%1] <%2> Processing %3", - QUOTE(PREFIX), - _fnc_scriptName, - configName _battalionElement - ]; + [ + LEVEL_TRACE, + QUOTE(COMPONENT), + "Processing child elements for battalion element %1" + ] call EFUNC(common,log); + [_battalionElement, { params ["_cfg", "_recurseCounter"]; // add config private _lines = [_cfg, _recurseCounter+1] call FUNC(formatRadioElementForDiary); // private _lines = [_cfg, _indentCount] call t; _allText pushBack (_lines joinString "
"); - }] call EFUNC(util,recurseSubclasses); + }] call EFUNC(common,recurseSubclasses); } else { - diag_log text format[ - "[%1] <%2> Processing %3", - QUOTE(PREFIX), - _fnc_scriptName, - configName _battalionElement - ]; + [ + LEVEL_TRACE, + QUOTE(COMPONENT), + "Skipping processing of child elements for battalion element %1", + [] + ] call EFUNC(common,log); + // or if the param was false, just add the battalion element private _lines = [_battalionElement, 1] call FUNC(formatRadioElementForDiary); // private _lines = [_cfg, _indentCount] call t; diff --git a/framework/init/functions/fn_addAARChatHandler.sqf b/framework/init/functions/fn_addAARChatHandler.sqf new file mode 100644 index 0000000..a0e8135 --- /dev/null +++ b/framework/init/functions/fn_addAARChatHandler.sqf @@ -0,0 +1,16 @@ +[ + "saveaar", + { + [] remoteExec["ocap_fnc_exportData", 2]; + }, + "admin" +] call CBA_fnc_registerChatCommand; + +[ + LEVEL_INFO, + QUOTE(COMPONENT), + "OCAP chat handler registered", + [player] call EFUNC(common,addPlayerInfoToArray) +] call EFUNC(common,log); + +nil; \ No newline at end of file diff --git a/framework/settings/fn_addRespawnChatHandler.sqf b/framework/init/functions/fn_addRespawnChatHandler.sqf similarity index 53% rename from framework/settings/fn_addRespawnChatHandler.sqf rename to framework/init/functions/fn_addRespawnChatHandler.sqf index 9c9f8f6..b2d0007 100644 --- a/framework/settings/fn_addRespawnChatHandler.sqf +++ b/framework/init/functions/fn_addRespawnChatHandler.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + [ "respawn", { @@ -6,10 +8,11 @@ // log to server RPT [ - "init", + LEVEL_INFO, + QUOTE(COMPONENT), "CHAT COMMAND RESPAWN", - [player] call milsim_util_fnc_addPlayerInfoToArray - ] remoteExec ["milsim_util_fnc_log", 2]; + [player] call EFUNC(common,addPlayerInfoToArray) + ] remoteExec [QEFUNC(common,log), 2]; // systemChat to all remote machines format["%1 claims they were glitched and respawned (%2)", name player, netID player] remoteExec["systemChat", -_clientID]; @@ -18,6 +21,11 @@ [clientOwner] ] call CBA_fnc_registerChatCommand; -diag_log text "[MILSIM] (settings) respawn chat handler registered"; +[ + LEVEL_INFO, + QUOTE(COMPONENT), + "Respawn chat handler registered", + [player] call EFUNC(common,addPlayerInfoToArray) +] call EFUNC(common,log); nil; \ No newline at end of file diff --git a/framework/init/functions/fn_initPlayerLocal.sqf b/framework/init/functions/fn_initPlayerLocal.sqf index d72495f..e1bf330 100644 --- a/framework/init/functions/fn_initPlayerLocal.sqf +++ b/framework/init/functions/fn_initPlayerLocal.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + if ( !hasInterface ) exitWith {}; if (!isServer) then { @@ -11,4 +13,11 @@ if (!isServer) then { ["InitializePlayer", [player, true]] call BIS_fnc_dynamicGroups; +[ + LEVEL_DEBUG, + QUOTE(COMPONENT), + "postInit complete", + [] +] call EFUNC(common,log); + nil; \ No newline at end of file diff --git a/framework/init/functions/fn_initServer.sqf b/framework/init/functions/fn_initServer.sqf index 2933428..0b0e4cb 100644 --- a/framework/init/functions/fn_initServer.sqf +++ b/framework/init/functions/fn_initServer.sqf @@ -2,6 +2,8 @@ if (!isServer) exitWith {}; + +// array of all respawn modules in the mission representing "bases" GVARMAIN(baseObjects) = allMissionObjects "ModuleRespawnPosition_F"; publicVariable "milsim_baseObjects"; @@ -16,11 +18,18 @@ publicVariable "milsim_baseObjects"; }] call CBA_fnc_addEventHandler; missionNamespace setVariable [QGVARMAIN(complete), true]; +publicVariable QGVARMAIN(complete); [ + LEVEL_INFO, QUOTE(COMPONENT), format["%1: version %2", QGVARMAIN(complete), QUOTE(VERSION_STR)], [["version", QUOTE(VERSION_STR)]] -] call EFUNC(util,log); +] call EFUNC(common,log); -publicVariable "milsim_complete"; +[ + LEVEL_DEBUG, + QUOTE(COMPONENT), + "postInit complete", + [] +] call EFUNC(common,log); \ No newline at end of file diff --git a/framework/init/functions/fn_setDefaults.sqf b/framework/init/functions/fn_setDefaults.sqf new file mode 100644 index 0000000..45a18d3 --- /dev/null +++ b/framework/init/functions/fn_setDefaults.sqf @@ -0,0 +1,34 @@ +#include "..\script_component.hpp" + +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]; + +[ + LEVEL_INFO, + QUOTE(COMPONENT), + "Defaults set", + [ + ["enableSaving", [false, false]], + ["enableRadio", false], + ["enableSentences", false], + ["ACE_maxWeightDrag", 2400], + ["ACE_maxWeightCarry", 1800], + ["rhs_vehicleRadioChatter", 0], + ["enableEnvironment", [false, true]] + ] +] call EFUNC(common,log); + +nil; \ No newline at end of file diff --git a/framework/performance/functions/fn_addCBASettings.sqf b/framework/performance/functions/fn_addCBASettings.sqf new file mode 100644 index 0000000..e1564d7 --- /dev/null +++ b/framework/performance/functions/fn_addCBASettings.sqf @@ -0,0 +1,105 @@ +#include "..\script_component.hpp" + +//--------------------- +// Server CPS +//--------------------- + +[ + QGVAR(server_cps_enable), + "CHECKBOX", + "Server CPS Metrics Enabled", + ["17th Battalion", "Server Metrics"], + true, + true, + { + params ["_value"]; + [ + QGVAR(cps_enable), + _value + ] call EFUNC(common,logSettingChanged); + } +] call CBA_fnc_addSetting; + +[QGVAR(cps_enable), true] call CBA_settings_fnc_set; + +[ + QGVAR(server_cps_interval), + "TIME", + "Server CPS Metrics Interval", + [QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)], + [60,300,120], + true, + { + if (!isServer) exitWith {}; + + params ["_value"]; + + [ + QGVAR(cps_interval), + _value + ] call EFUNC(common,logSettingChanged); + + _cpsPFH = missionNamespace getVariable [QGVAR(server_cps_handler), ObjNull]; + if (!isNull _cpsPFH) then { + _cpsPFH call CBA_fnc_deletePerFrameHandlerObject; + }; + + [] call FUNC(addServerStatsPFH); + } +] call CBA_fnc_addSetting; + + +//--------------------- +// Client CPS +//--------------------- + +[ + QGVAR(client_cps_enable), + "CHECKBOX", + "Client CPS Metrics Enabled", + [QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)], + true, + true, + { + params ["_value"]; + [ + QGVAR(client_cps_enable), + _value + ] call EFUNC(common,logSettingChanged); + } +] call CBA_fnc_addSetting; + +[QGVAR(client_cps_enable), true] call CBA_settings_fnc_set; + +[ + QGVAR(client_cps_interval), + "TIME", + "Client CPS Metrics Interval", + [QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)], + [60,300,120], + true, + { + if (!hasInterface) exitWith {}; + + params ["_value"]; + + [ + QGVAR(client_cps_interval), + _value + ] call EFUNC(common,logSettingChanged); + + _cpsPFH = player getVariable [QGVAR(client_cps_handler), ObjNull]; + if (!isNull _cpsPFH) then { + _cpsPFH call CBA_fnc_deletePerFrameHandlerObject; + }; + + [] call FUNC(addClientStatsPFH); + } +] call CBA_fnc_addSetting; + +[ + LEVEL_INFO, + QUOTE(COMPONENT), + "CREATED SETTINGS", + [] +] call EFUNC(common,log); \ No newline at end of file diff --git a/framework/performance/functions/fn_addClientStatsPFH.sqf b/framework/performance/functions/fn_addClientStatsPFH.sqf new file mode 100644 index 0000000..bc466b7 --- /dev/null +++ b/framework/performance/functions/fn_addClientStatsPFH.sqf @@ -0,0 +1,38 @@ +#include "..\script_component.hpp" + +if (!hasInterface) exitWith {}; + +[ + LEVEL_INFO, + QUOTE(COMPONENT), + "Initializing client stats PFH", + [] +] call EFUNC(common,log); + +_cpsPFH = [ + { + [] call FUNC(calculateClientStats); + }, + QGVAR(client_cps_interval) call CBA_settings_fnc_get, + [], + { + [ + LEVEL_INFO, + QUOTE(COMPONENT), + "Client PFH loaded", + [["pfhInterval", QGVAR(client_cps_interval) call CBA_settings_fnc_get]] + ] call EFUNC(common,log); + }, + { [ + LEVEL_INFO, + QUOTE(COMPONENT), + "Client PFH unloaded", + [] + ] call EFUNC(common,log); + }, + { QGVAR(client_cps_enable) call CBA_settings_fnc_get }, + { false }, + [] +] call CBA_fnc_createPerFrameHandlerObject; + +player setVariable [QGVAR(client_cps_handler), _cpsPFH]; diff --git a/framework/client/fn_addDNI_PlayerFPS.sqf b/framework/performance/functions/fn_addDNI_PlayerFPS.sqf similarity index 97% rename from framework/client/fn_addDNI_PlayerFPS.sqf rename to framework/performance/functions/fn_addDNI_PlayerFPS.sqf index e1bea9f..94d8e56 100644 --- a/framework/client/fn_addDNI_PlayerFPS.sqf +++ b/framework/performance/functions/fn_addDNI_PlayerFPS.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + if ( !hasInterface ) exitWith {}; diag_log text "[MILSIM] (DNI) writing variable loop"; diff --git a/framework/server/fn_addServerStatsPFH.sqf b/framework/performance/functions/fn_addServerStatsPFH.sqf similarity index 51% rename from framework/server/fn_addServerStatsPFH.sqf rename to framework/performance/functions/fn_addServerStatsPFH.sqf index 237c171..21ea60c 100644 --- a/framework/server/fn_addServerStatsPFH.sqf +++ b/framework/performance/functions/fn_addServerStatsPFH.sqf @@ -1,28 +1,48 @@ +#include "..\script_component.hpp" + if (!isServer) exitWith {}; -missionNamespace setVariable["milsim_raw_cps", 0]; -missionNamespace setVariable["milsim_cps", 0]; +missionNamespace setVariable[QGVAR(raw_cps), 0]; +missionNamespace setVariable[QGVAR(cps), 0]; -publicVariable "milsim_raw_cps"; -publicVariable "milsim_cps"; +publicVariable QGVAR(raw_cps); +publicVariable QGVAR(cps); -diag_log text format ["[MILSIM] (server) initializing Server Stats PFH"]; +[ + LEVEL_INFO, + QUOTE(COMPONENT), + "Initializing server stats PFH", + [] +] call EFUNC(common,log); _serverCpsPFH = [ { - [] call milsim_fnc_calculateServerStats; + [] call FUNC(calculateServerStats); }, - "milsim_server_cps_interval" call CBA_settings_fnc_get, + QGVAR(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 }, + { + [ + LEVEL_INFO, + QUOTE(COMPONENT), + "Server PFH loaded", + [["pfhInterval", QGVAR(server_cps_interval) call CBA_settings_fnc_get]] + ] call EFUNC(common,log); + }, + { [ + LEVEL_INFO, + QUOTE(COMPONENT), + "Server PFH unloaded", + [] + ] call EFUNC(common,log); + }, + { QGVAR(server_cps_enable) call CBA_settings_fnc_get }, { false }, [] ] call CBA_fnc_createPerFrameHandlerObject; -missionNamespace setVariable ["milsim_server_cps_handler", _serverCpsPFH]; +missionNamespace setVariable [QGVAR(server_cps_handler), _serverCpsPFH]; _playerCpsPFH = [ { diff --git a/framework/performance/functions/fn_calculateClientStats.sqf b/framework/performance/functions/fn_calculateClientStats.sqf new file mode 100644 index 0000000..0db20a2 --- /dev/null +++ b/framework/performance/functions/fn_calculateClientStats.sqf @@ -0,0 +1,40 @@ +#include "..\script_component.hpp" + +[] 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! + [ + LEVEL_INFO, + QUOTE(COMPONENT), + format ["Average Execution: %1 times per frame", _counter / (diag_frameNo - _frameNo)], + [["playerRawCPS", _counter / (diag_frameNo - _frameNo)]] + ] call EFUNC(common,log); + player setVariable [QGVAR(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 + [ + LEVEL_INFO, + QUOTE(COMPONENT), + format ["Average Execution: %1 times per frame", _counter / (diag_frameNo - _frameNo)], + [["playerCPS", _counter / (diag_frameNo - _frameNo)]] + ] call EFUNC(common,log); + player setVariable [QGVAR(player_cps), _counter / (diag_frameNo - _frameNo), true]; +}; + +nil; \ No newline at end of file diff --git a/framework/server/fn_calculateServerStats.sqf b/framework/performance/functions/fn_calculateServerStats.sqf similarity index 100% rename from framework/server/fn_calculateServerStats.sqf rename to framework/performance/functions/fn_calculateServerStats.sqf diff --git a/framework/performance/script_component.hpp b/framework/performance/script_component.hpp new file mode 100644 index 0000000..5cc7549 --- /dev/null +++ b/framework/performance/script_component.hpp @@ -0,0 +1,3 @@ +#define COMPONENT performance +#define COMPONENT_BEAUTIFIED Performance Monitoring +#include "../script_mod.hpp" \ No newline at end of file diff --git a/framework/reinsert/client/fn_addAceSelfActions.sqf b/framework/reinsert/client/fn_addAceSelfActions.sqf index f587af7..a6f66de 100644 --- a/framework/reinsert/client/fn_addAceSelfActions.sqf +++ b/framework/reinsert/client/fn_addAceSelfActions.sqf @@ -1,36 +1,38 @@ +#include "..\script_component.hpp" + params ["_type"]; // string of the object's classname if (!(_type isKindOf "CAManBase")) exitWith {}; if ( - (localNamespace getVariable ["milsim_reinsert_fileForReinsertClassesAdded", []]) + (localNamespace getVariable [QGVAR(fileForReinsertClassesAdded), []]) find _type != -1 ) exitWith {}; private _fileForReinsertAction = [ - "milsim_reinsert_fileReinsertRequest", + QGVAR(fileReinsertRequestAction), "File Re-insert Request", "\A3\ui_f\data\igui\cfg\simpleTasks\types\takeoff_ca.paa", { // statement params ["_target", "_player", "_params"]; // find nearest base or location - private _base = [_player] call milsim_util_fnc_getNearestBase; - private _baseName = [_base] call milsim_util_fnc_getNameOfBase; + private _base = [_player] call EFUNC(common,getNearestBase); + private _baseName = [_base] call EFUNC(common,getNameOfBase); // send event to server - ["milsim_reinsert_fileReinsertRequest", [_player, _base]] call CBA_fnc_serverEvent; + [QGVAR(fileReinsertRequest), [_player, _base]] call CBA_fnc_serverEvent; // notify player their request was filed [["Re-insert Request Filed"], [format["Location: %1", _baseName]]] call CBA_fnc_notify; }, { // condition params ["_target", "_player", "_params"]; // find nearest base or location - private _base = [_player] call milsim_util_fnc_getNearestBase; + private _base = [_player] call EFUNC(common,getNearestBase); private _baseDistance = _player distance _base; - private _maxRangeToReady = missionNamespace getVariable ["milsim_reinsert_setting_reinsertion_maxRangeToReady", 400]; - private _existingQueue = missionNamespace getVariable ["milsim_reinsert_reinsertionQueue", []]; + private _maxRangeToReady = missionNamespace getVariable [QGVAR(setting_maxRangeToReady), 400]; + private _existingQueue = missionNamespace getVariable [QGVAR(reinsertionQueue), []]; // check if module is enabled, player is near a base, and player is not already in the queue - // (serverTime - milsim_reinsert_missionStartServerTime) > 60*5 && // only allow after 15 minutes + // (serverTime - GVAR(missionStartServerTime)) > 60*5 && // only allow after 15 minutes missionNamespace getVariable ["milsim_reinsert_setting_reinsertion_enabled", true] && (_baseDistance < _maxRangeToReady) && not (_player in (_existingQueue apply {_x#0})) @@ -39,29 +41,29 @@ private _fileForReinsertAction = [ [_type, 1, ["ACE_SelfActions"], _fileForReinsertAction, true] call ace_interact_menu_fnc_addActionToClass; private _removeFileForReinsertAction = [ - "milsim_reinsert_removeReinsertRequest", + QGVAR(removeReinsertRequestAction), "Remove Re-insert Request", "\A3\ui_f\data\igui\cfg\simpleTasks\types\land_ca.paa", { // statement params ["_target", "_player", "_params"]; // send event to server - ["milsim_reinsert_removeReinsertRequest", [_player]] call CBA_fnc_serverEvent; + [QGVAR(removeReinsertRequest), [_player]] call CBA_fnc_serverEvent; // notify player their request was rescinded "Re-insert Request Rescinded" call CBA_fnc_notify; }, { // condition params ["_target", "_player", "_params"]; - private _existingQueue = missionNamespace getVariable ["milsim_reinsert_reinsertionQueue", []]; + private _existingQueue = missionNamespace getVariable [QGVAR(reinsertionQueue), []]; // check if module is enabled, player is in the queue - // (serverTime - milsim_reinsert_missionStartServerTime) > 60*5 && // only allow after 15 minutes + // (serverTime - GVAR(missionStartServerTime)) > 60*5 && // only allow after 15 minutes missionNamespace getVariable ["milsim_reinsert_setting_reinsertion_enabled", true] && (_player in (_existingQueue apply {_x#0})) } ] call ace_interact_menu_fnc_createAction; [_type, 1, ["ACE_SelfActions"], _removeFileForReinsertAction, true] call ace_interact_menu_fnc_addActionToClass; -private _classesActionsAddedTo = (localNamespace getVariable ["milsim_reinsert_fileForReinsertClassesAdded", []]); +private _classesActionsAddedTo = (localNamespace getVariable [QGVAR(fileForReinsertClassesAdded), []]); _classesActionsAddedTo pushBackUnique _type; -localNamespace setVariable ["milsim_reinsert_fileForReinsertClassesAdded", _classesActionsAddedTo]; +localNamespace setVariable [QGVAR(fileForReinsertClassesAdded), _classesActionsAddedTo]; diff --git a/framework/reinsert/client/fn_addCheckQueueSelfAction.sqf b/framework/reinsert/client/fn_addCheckQueueSelfAction.sqf index 5897b53..341e09f 100644 --- a/framework/reinsert/client/fn_addCheckQueueSelfAction.sqf +++ b/framework/reinsert/client/fn_addCheckQueueSelfAction.sqf @@ -1,28 +1,30 @@ +#include "..\script_component.hpp" + params ["_type"]; // string of the object's classname if (!(_type isKindOf "CAManBase")) exitWith {}; if ( - (localNamespace getVariable ["milsim_reinsert_checkReinsertQueueClassesAdded", []]) + (localNamespace getVariable [QGVAR(checkReinsertQueueClassesAdded), []]) find _type != -1 ) exitWith {}; private _checkReinsertQueueAction = [ - "milsim_reinsert_checkReinsertQueue", + QGVAR(checkReinsertQueue), "[PILOT] Check Re-insert Queue", "\A3\ui_f\data\igui\cfg\simpleTasks\types\land_ca.paa", { params ["_target", "_player", "_params"]; // request notification from the server - call milsim_reinsert_fnc_requestShowQueue; + call FUNC(requestShowQueue); // reset last check time - localNamespace setVariable ["milsim_reinsert_lastReinsertQueueCheck", diag_tickTime]; + localNamespace setVariable [QGVAR(lastReinsertQueueCheck), diag_tickTime]; }, { - missionNamespace getVariable ["milsim_reinsert_setting_reinsertion_enabled", true] + missionNamespace getVariable [QGVAR(setting_enabled), true] } // always allow ] call ace_interact_menu_fnc_createAction; [_type, 1, ["ACE_SelfActions"], _checkReinsertQueueAction, true] call ace_interact_menu_fnc_addActionToClass; -private _classesActionsAddedTo = (localNamespace getVariable ["milsim_reinsert_checkReinsertQueueClassesAdded", []]); +private _classesActionsAddedTo = (localNamespace getVariable [QGVAR(checkReinsertQueueClassesAdded), []]); _classesActionsAddedTo pushBackUnique _type; -localNamespace setVariable ["milsim_reinsert_checkReinsertQueueClassesAdded", _classesActionsAddedTo]; \ No newline at end of file +localNamespace setVariable [QGVAR(checkReinsertQueueClassesAdded), _classesActionsAddedTo]; \ No newline at end of file diff --git a/framework/reinsert/client/fn_initClient.sqf b/framework/reinsert/client/fn_initClient.sqf index cdee922..f262ffe 100644 --- a/framework/reinsert/client/fn_initClient.sqf +++ b/framework/reinsert/client/fn_initClient.sqf @@ -1,26 +1,28 @@ +#include "..\script_component.hpp" + if (!hasInterface) exitWith {}; // ACE SELF-INTERACTIONS FOR FILING AND RESCINDING REINSERT REQUESTS NEAR BASE - ALL PLAYERS -localNamespace setVariable ["milsim_reinsert_fileForReinsertClassesAdded", []]; +localNamespace setVariable [QGVAR(fileForReinsertClassesAdded), []]; // add actions to current class -[typeOf player] call milsim_reinsert_fnc_addAceSelfActions; +[typeOf player] call FUNC(addAceSelfActions); // add actions to future classes ["ace_interact_menu_newControllableObject", { - _this call milsim_reinsert_fnc_addAceSelfActions; + _this call FUNC(addAceSelfActions); }] call CBA_fnc_addEventHandler; ///////////////////////////////////////////////////// // PILOTS ONLY // ACE SELF-INTERACTIONS FOR CHECKING REINSERT QUEUE - ONLY FOR PILOTS if ((typeOf player) in ["B_Helipilot_F", "B_helicrew_F"]) then { - localNamespace setVariable ["milsim_reinsert_checkReinsertQueueClassesAdded", []]; - localNamespace setVariable ["milsim_reinsert_lastReinsertQueueCheck", diag_tickTime]; + localNamespace setVariable [QGVAR(checkReinsertQueueClassesAdded), []]; + localNamespace setVariable [QGVAR(lastReinsertQueueCheck), diag_tickTime]; // add actions to current class - [typeOf player] call milsim_reinsert_fnc_addCheckQueueSelfAction; + [typeOf player] call FUNC(addCheckQueueSelfAction); // add actions to future classes ["ace_interact_menu_newControllableObject", { - _this call milsim_reinsert_fnc_addCheckQueueSelfAction; + _this call FUNC(addCheckQueueSelfAction); }] call CBA_fnc_addEventHandler; }; ///////////////////////////////////////////////////// @@ -31,13 +33,13 @@ if ((typeOf player) in ["B_Helipilot_F", "B_helicrew_F"]) then { [{ // if module not enabled and pilot forced check not enabled, exit if (not ( - missionNamespace getVariable ["milsim_reinsert_setting_reinsertion_enabled", true] && - missionNamespace getVariable ["milsim_reinsert_setting_reinsertion_pilotForcedCheckEnabled", true] + missionNamespace getVariable [QGVAR(setting_enabled), true] && + missionNamespace getVariable [QGVAR(setting_pilotForcedCheckEnabled), true] )) exitWith {}; // if last check was less than X minutes ago, skip - private _lastCheck = localNamespace getVariable ["milsim_reinsert_lastReinsertQueueCheck", diag_tickTime]; - private _requiredCheckInterval = missionNamespace getVariable ["milsim_reinsert_setting_reinsertion_pilotForcedCheckInterval", 60*20]; + private _lastCheck = localNamespace getVariable [QGVAR(lastReinsertQueueCheck), diag_tickTime]; + private _requiredCheckInterval = missionNamespace getVariable [QGVAR(setting_pilotForcedCheckInterval), 60*20]; if ( diag_tickTime - _lastCheck < _requiredCheckInterval @@ -45,9 +47,16 @@ if ((typeOf player) in ["B_Helipilot_F", "B_helicrew_F"]) then { // last check was greater than X minutes ago // reset last check time - localNamespace setVariable ["milsim_reinsert_lastReinsertQueueCheck", diag_tickTime]; + localNamespace setVariable [QGVAR(lastReinsertQueueCheck), diag_tickTime]; // request notification from the server - call milsim_reinsert_fnc_requestShowQueue; + call FUNC(requestShowQueue); }, 30] call CBA_fnc_addPerFrameHandler; }; -///////////////////////////////////////////////////// \ No newline at end of file +///////////////////////////////////////////////////// + +[ + LEVEL_DEBUG, + QUOTE(COMPONENT), + "postInit complete", + [] +] call EFUNC(common,log); \ No newline at end of file diff --git a/framework/reinsert/client/fn_requestShowQueue.sqf b/framework/reinsert/client/fn_requestShowQueue.sqf index 1afed4e..afb4f03 100644 --- a/framework/reinsert/client/fn_requestShowQueue.sqf +++ b/framework/reinsert/client/fn_requestShowQueue.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + if (!hasInterface) exitWith {}; -[] remoteExec ["milsim_reinsert_fnc_returnReinsertQueueNotification", 2]; \ No newline at end of file +[] remoteExec [QFUNC(returnReinsertQueueNotification), 2]; \ No newline at end of file diff --git a/framework/reinsert/functions/fn_addCBASettings.sqf b/framework/reinsert/functions/fn_addCBASettings.sqf new file mode 100644 index 0000000..f00dcdf --- /dev/null +++ b/framework/reinsert/functions/fn_addCBASettings.sqf @@ -0,0 +1,83 @@ +#include "..\script_component.hpp" + +//--------------------- +// Respawn Settings +[ + QGVAR(setting_enabled), // variable + "CHECKBOX", // type + ["Enabled", "Whether or not players can file for reinsert and pilots can check the reinsert queue"], // title + [QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)], // category + true, // default value + true, // global setting + { + params ["_value"]; + [ + QGVAR(setting_enabled), + _value + ] call EFUNC(common,logSettingChanged); + } +] call CBA_fnc_addSetting; + +[ + QGVAR(setting_maxRangeToReady), // variable + "SLIDER", // type + ["Max Request Filing Range", "Maximum distance from a respawn point a player can be to ready up"], // title + [QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)], // category + [0, 1000, 400, 0, false], // [_min, _max, _default, _trailingDecimals, _isPercentage] + true, // global setting + { + params ["_value"]; + [ + QGVAR(setting_maxRangeToReady), + _value + ] call EFUNC(common,logSettingChanged); + } +] call CBA_fnc_addSetting; + +[ + QGVAR(setting_pilotForcedCheckEnabled), // variable + "CHECKBOX", // type + ["Enabled", "Whether or not pilots are forced to view the contents of the reinsertion queue per interval"], // title + [QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)], // category + false, // default value + true, // global setting + { + params ["_value"]; + [ + QGVAR(setting_pilotForcedCheckEnabled), + _value + ] call EFUNC(common,logSettingChanged); + } +] call CBA_fnc_addSetting; + +[ + QGVAR(setting_pilotForcedCheckInterval), // variable + "TIME", // type + ["Pilot Forced Check Interval", "Pilots will be force shown the queue if they haven't checked it in X seconds"], // title + [QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)], // category + [60*5, 60*30, 60*10], // [_min, _max, _default] + true, + { + params ["_value"]; + [ + QGVAR(setting_pilotForcedCheckInterval), + _value + ] call EFUNC(common,logSettingChanged); + } +] call CBA_fnc_addSetting; + +[ + QGVAR(setting_maxWait), // variable + "TIME", // type + ["Max Wait Threshold", "How long should at least one person be waiting before prompting a global notification."], // title + [QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)], // category + [60*5, 60*30, 60*20], // [_min, _max, _default] + true, + { + params ["_value"]; + [ + QGVAR(setting_maxWait), + _value + ] call EFUNC(common,logSettingChanged); + } +] call CBA_fnc_addSetting; diff --git a/framework/reinsert/script_component.hpp b/framework/reinsert/script_component.hpp index 770e8d7..3525b55 100644 --- a/framework/reinsert/script_component.hpp +++ b/framework/reinsert/script_component.hpp @@ -1,3 +1,3 @@ -#define COMPONENT fbcb2_reinsert -#define COMPONENT_BEAUTIFIED FBCB2 - Reinsertion +#define COMPONENT reinsert +#define COMPONENT_BEAUTIFIED Reinsertion #include "../script_mod.hpp" \ No newline at end of file diff --git a/framework/reinsert/server/fn_addToQueue.sqf b/framework/reinsert/server/fn_addToQueue.sqf index 1df3fc1..6642f98 100644 --- a/framework/reinsert/server/fn_addToQueue.sqf +++ b/framework/reinsert/server/fn_addToQueue.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + params [ ["_player", objNull, [objNull]], ["_base", objNull, [objNull]], @@ -6,51 +8,54 @@ params [ if (!isServer) exitWith { [ - "respawn_reinsertion", + LEVEL_ERROR, + QUOTE(COMPONENT), "ATTEMPTED RUN ON CLIENT", [ ["player", _player], ["base", _base] ] - ] call milsim_util_fnc_log; + ] call EFUNC(common,log); + ["ATTEMPTED RUN ON CLIENT"] call BIS_fnc_error; }; if ( isNull _player || isNull _base ) exitWith { [ - "respawn_reinsertion", + LEVEL_ERROR, + QUOTE(COMPONENT), "NULL PARAMETERS", [ ["player", _player], ["base", _base] ] - ] call milsim_util_fnc_log; + ] call EFUNC(common,log); + ["NULL PARAMETERS"] call BIS_fnc_error; }; -private _maxRangeToReady = missionNamespace getVariable ["milsim_reinsert_setting_reinsertion_maxRangeToReady", 400]; +private _maxRangeToReady = missionNamespace getVariable [QGVAR(setting_maxRangeToReady), 400]; // nearest base here is the same as the base sent private _nearestBase = _base; -milsim_reinsert_reinsertionQueue pushBackUnique [ +GVAR(reinsertionQueue) pushBackUnique [ _player, _base, _timeFiled ]; // broadcast new list to all machines -publicVariable "milsim_reinsert_reinsertionQueue"; +publicVariable QGVAR(reinsertionQueue); // log to rpt -private _logParams = [ - ["filedAtBase", [_base] call milsim_util_fnc_getNameOfBase], - ["filedAtBaseDistance", _player distance _base], - ["closestBase", [_nearestBase] call milsim_util_fnc_getNameOfBase], - ["closestBaseDistance", _player distance _nearestBase], - ["maxDistanceSetting", _maxRangeToReady], - ["inQueueDuration", diag_tickTime - _timeFiled] -]; -_logParams = [_player, _logParams] call milsim_util_fnc_addPlayerInfoToArray; [ - "respawn_reinsertion", + LEVEL_INFO, + QUOTE(COMPONENT), "PLAYER FILED REQUEST", - _logParams -] call milsim_util_fnc_log; \ No newline at end of file + [_player, [ + ["filedAtBase", [_base] call EFUNC(common,getNameOfBase)], + ["filedAtBaseDistance", _player distance _base], + ["closestBase", [_nearestBase] call EFUNC(common,getNameOfBase)], + ["closestBaseDistance", _player distance _nearestBase], + ["maxDistanceSetting", _maxRangeToReady], + ["inQueueDuration", diag_tickTime - _timeFiled] + ]] call EFUNC(common,addPlayerInfoToArray) +] call EFUNC(common,log); \ No newline at end of file diff --git a/framework/reinsert/server/fn_globalShowQueue.sqf b/framework/reinsert/server/fn_globalShowQueue.sqf index ac5eb7b..1300266 100644 --- a/framework/reinsert/server/fn_globalShowQueue.sqf +++ b/framework/reinsert/server/fn_globalShowQueue.sqf @@ -1,8 +1,10 @@ +#include "..\script_component.hpp" + if (!isServer) exitWith {}; // if at least 1 player in the queue has been waiting longer than the configured timeout, notify all players -private _timeout = missionNamespace getVariable ["milsim_reinsert_setting_reinsertion_max_wait", 60*20]; // default 20 minutes -private _timeoutPlayers = milsim_reinsert_reinsertionQueue select { +private _timeout = missionNamespace getVariable [QGVAR(setting_maxWait), 60*20]; // default 20 minutes +private _timeoutPlayers = GVAR(reinsertionQueue) select { _x params ["_player", "_base", "_timeFiled"]; alive (_player) && (diag_tickTime - (_timeFiled)) > _timeout @@ -10,10 +12,10 @@ private _timeoutPlayers = milsim_reinsert_reinsertionQueue select { if (count _timeoutPlayers > 0) then { // GLOBAL CBA NOTIFY private _playerLines = [["Players are still waiting for Re-insert!", 1.2, [1, 0.64, 0, 1]]]; - private _maxRangeToReady = missionNamespace getVariable ["milsim_reinsert_setting_reinsertion_maxRangeToReady", 400]; + private _maxRangeToReady = missionNamespace getVariable [QGVAR(setting_maxRangeToReady), 400]; // get base objects from queue - private _basesWithPeople = (missionNamespace getVariable ["milsim_reinsert_reinsertionQueue", []]) apply {_x#1}; + private _basesWithPeople = (missionNamespace getVariable [QGVAR(reinsertionQueue), []]) apply {_x#1}; // get unique base objects private _basesWithPeople = _basesWithPeople arrayIntersect _basesWithPeople; @@ -21,7 +23,7 @@ if (count _timeoutPlayers > 0) then { private _thisBase = _x; // Add line for base name - _playerLines pushBack ([[_thisBase] call milsim_util_fnc_getNameOfBase, 1, [0,1,0,1]]); + _playerLines pushBack ([[_thisBase] call EFUNC(common,getNameOfBase), 1, [0,1,0,1]]); // Get players under this base private _thisBasePlayers = _timeoutPlayers select {_x#1 isEqualTo _thisBase}; @@ -35,7 +37,7 @@ if (count _timeoutPlayers > 0) then { { // for each player under this base, add a line _x params ["_player", "_base", "_timeFiled"]; // get the closest base to the player - private _nearestBase = [_player] call milsim_util_fnc_getNearestBase; + private _nearestBase = [_player] call EFUNC(common,getNearestBase); // add player to array of players under bases _playerLines pushBack ([format [ @@ -46,25 +48,24 @@ if (count _timeoutPlayers > 0) then { ], 0.8, [0.8, 0.8, 0.8, 1]]); // log to rpt - private _logParams = [ - ["filedAtBase", [_base] call milsim_util_fnc_getNameOfBase], - ["filedAtBaseDistance", _player distance _base], - ["closestBase", [_nearestBase] call milsim_util_fnc_getNameOfBase], - ["closestBaseDistance", _player distance _nearestBase], - ["maxDistanceSetting", _maxRangeToReady], - ["inQueueDuration", diag_tickTime - _timeFiled] - ]; - _logParams = [_player, _logParams] call milsim_util_fnc_addPlayerInfoToArray; [ - "respawn_reinsertion", + LEVEL_WARNING, + QUOTE(COMPONENT), "PLAYER WAITING OVER TIMEOUT", - _logParams - ] call milsim_util_fnc_log; + [_player, [ + ["filedAtBase", [_base] call EFUNC(common,getNameOfBase)], + ["filedAtBaseDistance", _player distance _base], + ["closestBase", [_nearestBase] call EFUNC(common,getNameOfBase)], + ["closestBaseDistance", _player distance _nearestBase], + ["maxDistanceSetting", _maxRangeToReady], + ["inQueueDuration", diag_tickTime - _timeFiled] + ]] call EFUNC(common,addPlayerInfoToArray) + ] call EFUNC(common,log); } forEach _thisBasePlayers; } forEach _basesWithPeople; // SEND NOTIFY _playerLines remoteExec ["CBA_fnc_notify", [0, -2] select isDedicated]; // RESET NOTIFICATION TIMER - milsim_reinsert_reinsertionOverTimeoutLastNotificationTime = diag_tickTime; + GVAR(overTimeoutLastNotificationTime) = diag_tickTime; }; \ No newline at end of file diff --git a/framework/reinsert/server/fn_initServer.sqf b/framework/reinsert/server/fn_initServer.sqf index 03370a0..2bd94ce 100644 --- a/framework/reinsert/server/fn_initServer.sqf +++ b/framework/reinsert/server/fn_initServer.sqf @@ -3,48 +3,51 @@ // if a player's time in the queue exceeds the configured timeout, a message will be posted every 5 minutes on a cycle based around // the player's time in the queue stating how long they have been waiting, their name, and their group's name +#include "..\script_component.hpp" + if (!isServer) exitWith {}; -// array of all respawn modules in the mission, used as 'base' locations for reinsertion -milsim_baseObjects = allMissionObjects "ModuleRespawnPosition_F"; -publicVariable "milsim_baseObjects"; - // register queue -milsim_reinsert_reinsertionQueue = []; -publicVariable "milsim_reinsert_reinsertionQueue"; - +GVAR(reinsertionQueue) = []; +publicVariable QGVAR(reinsertionQueue); // server mission start time -milsim_reinsert_missionStartServerTime = serverTime; +GVAR(missionStartServerTime) = serverTime; // FILE REQUEST CBA HANDLER -["milsim_reinsert_fileReinsertRequest", { +[QGVAR(fileReinsertRequest), { params ["_player", "_base"]; - [_player, _base] call milsim_reinsert_fnc_addToQueue; + [_player, _base] call FUNC(addToQueue); }] call CBA_fnc_addEventHandler; // REMOVE REQUEST CBA HANDLER -["milsim_reinsert_removeReinsertRequest", { +[QGVAR(removeReinsertRequest), { params ["_player"]; - [_player] call milsim_reinsert_fnc_removeFromQueue; + [_player] call FUNC(removeFromQueue); }] call CBA_fnc_addEventHandler; // automated wait threshold timer -milsim_reinsert_reinsertionOverTimeoutLastNotificationTime = 0; +GVAR(overTimeoutLastNotificationTime) = 0; [{ // every 60 seconds // validate queue - call milsim_reinsert_fnc_validateQueue; + call FUNC(validateQueue); // check if last overTimeout notification was sent more than X minutes ago if ( - diag_tickTime - milsim_reinsert_reinsertionOverTimeoutLastNotificationTime > 60*5 + diag_tickTime - GVAR(overTimeoutLastNotificationTime) > 60*5 ) then { // show global queue notification with any players that are over timeout - call milsim_reinsert_fnc_globalShowQueue; + call FUNC(globalShowQueue); }; }, 60] call CBA_fnc_addPerFrameHandler; +[ + LEVEL_DEBUG, + QUOTE(COMPONENT), + "postInit complete", + [] +] call EFUNC(common,log); diff --git a/framework/reinsert/server/fn_removeFromQueue.sqf b/framework/reinsert/server/fn_removeFromQueue.sqf index 5fc5bbd..dc73e27 100644 --- a/framework/reinsert/server/fn_removeFromQueue.sqf +++ b/framework/reinsert/server/fn_removeFromQueue.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + params [["_player", objNull, [objNull]]]; if (!isServer) exitWith { @@ -20,16 +22,16 @@ if (isNull _player) exitWith { }; // get entries for this player from queue -private _unitArrs = milsim_reinsert_reinsertionQueue select {_x#0 isEqualTo _player}; +private _unitArrs = GVAR(reinsertionQueue) select {_x#0 isEqualTo _player}; // if player not in queue, skip if (count _unitArrs isEqualTo 0) exitWith {}; -private _maxRangeToReady = missionNamespace getVariable ["milsim_reinsert_setting_reinsertion_maxRangeToReady", 400]; +private _maxRangeToReady = missionNamespace getVariable [QGVAR(setting_maxRangeToReady), 400]; // remove player from queue -milsim_reinsert_reinsertionQueue = milsim_reinsert_reinsertionQueue - _unitArrs; +GVAR(reinsertionQueue) = GVAR(reinsertionQueue) - _unitArrs; // broadcast new list to all machines -publicVariable "milsim_reinsert_reinsertionQueue"; +publicVariable QGVAR(reinsertionQueue); // sort _unitArrs by time in queue, descending, to get longest wait (if for some reason there's a duplicate) [_unitArrs, [], { @@ -39,17 +41,17 @@ publicVariable "milsim_reinsert_reinsertionQueue"; // get first entry (longest wait) (_unitArrs#0) params ["_player", "_base", "_timeFiled"]; // _unitArr = [unit, base, timeInQueue] // get the closest base to the player -private _nearestBase = [_player] call milsim_util_fnc_getNearestBase; +private _nearestBase = [_player] call EFUNC(common,getNearestBase); // log to rpt private _logParams = [ - ["filedAtBase", [_base] call milsim_util_fnc_getNameOfBase], + ["filedAtBase", [_base] call EFUNC(common,getNameOfBase)], ["filedAtBaseDistance", _player distance _base], - ["closestBase", [_nearestBase] call milsim_util_fnc_getNameOfBase], + ["closestBase", [_nearestBase] call EFUNC(common,getNameOfBase)], ["closestBaseDistance", _player distance _nearestBase], ["maxDistanceSetting", _maxRangeToReady], ["inQueueDuration", diag_tickTime - _timeFiled] ]; -_logParams = [_player, _logParams] call milsim_util_fnc_addPlayerInfoToArray; +_logParams = [_player, _logParams] call EFUNC(common,addPlayerInfoToArray); [ "respawn_reinsertion", "PLAYER RESCINDED REQUEST", diff --git a/framework/reinsert/server/fn_returnReinsertQueueNotification.sqf b/framework/reinsert/server/fn_returnReinsertQueueNotification.sqf index fcda7b5..4dacf3c 100644 --- a/framework/reinsert/server/fn_returnReinsertQueueNotification.sqf +++ b/framework/reinsert/server/fn_returnReinsertQueueNotification.sqf @@ -25,16 +25,16 @@ if (isNull _userObject) exitWith { }; // log to rpt -private _logParams = [_userObject, []] call milsim_util_fnc_addPlayerInfoToArray; +private _logParams = [_userObject, []] call EFUNC(common,addPlayerInfoToArray); [ "respawn_reinsertion", "SHOW QUEUE REQUESTED", _logParams ] call milsim_util_fnc_log; -private _queue = missionNamespace getVariable ["milsim_reinsert_reinsertionQueue", []]; +private _queue = missionNamespace getVariable [QGVAR(reinsertionQueue), []]; // get base objects from queue -private _basesWithPeople = (missionNamespace getVariable ["milsim_reinsert_reinsertionQueue", []]) apply {_x#1}; +private _basesWithPeople = (missionNamespace getVariable [QGVAR(reinsertionQueue), []]) apply {_x#1}; // get unique base objects private _basesWithPeople = _basesWithPeople arrayIntersect _basesWithPeople; @@ -48,7 +48,7 @@ if (count _basesWithPeople isEqualTo 0) then { // forEach _basesWithPeople { private _thisBase = _x; - private _baseName = [_thisBase] call milsim_util_fnc_getNameOfBase; + private _baseName = [_thisBase] call EFUNC(common,getNameOfBase); // generate player lines for this base private _playerLines = _queue select { diff --git a/framework/reinsert/server/fn_validateQueue.sqf b/framework/reinsert/server/fn_validateQueue.sqf index 546768b..2ea508b 100644 --- a/framework/reinsert/server/fn_validateQueue.sqf +++ b/framework/reinsert/server/fn_validateQueue.sqf @@ -1,32 +1,35 @@ // revalidate any players in the queue // compare their distance to the nearest base, and remove them if they're too far away (or dead) +#include "..\script_component.hpp" + private _stillValid = []; -private _maxRangeToReady = missionNamespace getVariable ["milsim_reinsert_setting_reinsertion_maxRangeToReady", 400]; +private _maxRangeToReady = missionNamespace getVariable [QGVAR(setting_maxRangeToReady), 400]; { _x params ["_player", "_base", "_timeFiled"]; // _unitArr = [unit, baseName, timeInQueue] private _distanceToOriginalBase = _player distance _base; // get the closest base to the player - private _nearestBase = [_player] call milsim_util_fnc_getNearestBase; + private _nearestBase = [_player] call EFUNC(common,getNearestBase); private _isCloseEnoughToAnyBase = (_player distance _nearestBase) < _maxRangeToReady; if (not _isCloseEnoughToAnyBase || not (alive _player)) then { // don't include player in updated queue // log to rpt - private _logParams = [ - ["filedAtBase", [_base] call milsim_util_fnc_getNameOfBase], - ["filedAtBaseDistance", _player distance _base], - ["closestBase", [_nearestBase] call milsim_util_fnc_getNameOfBase], - ["closestBaseDistance", _player distance _nearestBase], - ["maxDistanceSetting", _maxRangeToReady], - ["inQueueDuration", diag_tickTime - _timeFiled] - ]; - _logParams = [_player, _logParams] call milsim_util_fnc_addPlayerInfoToArray; + private _logParams = ; + _logParams = ; [ - "respawn_reinsertion", + LEVEL_INFO, + QUOTE(COMPONENT), "PLAYER DEQUEUED AUTOMATICALLY", - _logParams - ] call milsim_util_fnc_log; + [_player, [ + ["filedAtBase", [_base] call EFUNC(common,getNameOfBase)], + ["filedAtBaseDistance", _player distance _base], + ["closestBase", [_nearestBase] call EFUNC(common,getNameOfBase)], + ["closestBaseDistance", _player distance _nearestBase], + ["maxDistanceSetting", _maxRangeToReady], + ["inQueueDuration", diag_tickTime - _timeFiled] + ]] call EFUNC(common,addPlayerInfoToArray) + ] call EFUNC(common,log); // continue loop continue }; @@ -36,22 +39,22 @@ private _maxRangeToReady = missionNamespace getVariable ["milsim_reinsert_settin // if player's base has changed, log to rpt if (_base != _nearestBase) then { private _logParams = [ - ["filedAtBase", [_base] call milsim_util_fnc_getNameOfBase], + ["filedAtBase", [_base] call EFUNC(common,getNameOfBase)], ["filedAtBaseDistance", _player distance _base], - ["closestBase", [_nearestBase] call milsim_util_fnc_getNameOfBase], + ["closestBase", [_nearestBase] call EFUNC(common,getNameOfBase)], ["closestBaseDistance", _player distance _nearestBase], ["maxDistanceSetting", _maxRangeToReady], ["inQueueDuration", diag_tickTime - _timeFiled] ]; - _logParams = [_player, _logParams] call milsim_util_fnc_addPlayerInfoToArray; + _logParams = [_player, _logParams] call EFUNC(common,addPlayerInfoToArray); [ "respawn_reinsertion", "PLAYER BASE WAS UPDATED", _logParams ] call milsim_util_fnc_log; }; -} forEach milsim_reinsert_reinsertionQueue; +} forEach GVAR(reinsertionQueue); // broadcast new list to all machines -milsim_reinsert_reinsertionQueue = _stillValid; -publicVariable "milsim_reinsert_reinsertionQueue"; \ No newline at end of file +GVAR(reinsertionQueue) = _stillValid; +publicVariable QGVAR(reinsertionQueue); \ No newline at end of file diff --git a/framework/resupply/functions/fn_addCBASettings.sqf b/framework/resupply/functions/fn_addCBASettings.sqf index 898f60d..7a664fc 100644 --- a/framework/resupply/functions/fn_addCBASettings.sqf +++ b/framework/resupply/functions/fn_addCBASettings.sqf @@ -10,22 +10,16 @@ { params ["_value"]; [ - QUOTE(COMPONENT), - "SETTING CHANGED", - [ - [ - "setting", - QGVAR(setting_allowSupplyBoxScrollWheelSpawning) - ], - ["newValue", _value] - ] - ] call EFUNC(util,log); + QGVAR(setting_allowSupplyBoxScrollWheelSpawning), + _value + ] call EFUNC(common,logSettingChanged); }, true // requires mission restart ] call CBA_fnc_addSetting; [ + LEVEL_INFO, QUOTE(COMPONENT), "CREATED SETTINGS", [] -] call EFUNC(util,log); \ No newline at end of file +] call EFUNC(common,log); \ No newline at end of file diff --git a/framework/script_macros.hpp b/framework/script_macros.hpp index 840c73f..430b810 100644 --- a/framework/script_macros.hpp +++ b/framework/script_macros.hpp @@ -1,5 +1,10 @@ // all text before cba include #define SETTINGS_GROUP_NAME 17th Battalion +#define LEVEL_TRACE -1 +#define LEVEL_DEBUG 0 +#define LEVEL_INFO 1 +#define LEVEL_WARNING 2 +#define LEVEL_ERROR 3 #include "\x\cba\addons\main\script_macros_mission.hpp" \ No newline at end of file diff --git a/framework/script_mod.hpp b/framework/script_mod.hpp index cdbf23f..cb0aa97 100644 --- a/framework/script_mod.hpp +++ b/framework/script_mod.hpp @@ -6,5 +6,12 @@ #define VERSION_STR MAJOR.MINOR.PATCHLVL #define VERSION_AR MAJOR,MINOR,PATCHLVL +// #define DEBUG_MODE -1 // TRACE +#define DEBUG_MODE 0 // DEBUG +// #define DEBUG_MODE 1 // INFO +// #define DEBUG_MODE 2 // WARNING +// #define DEBUG_MODE 3 // ERROR + + // should always be last #include "script_macros.hpp" \ No newline at end of file diff --git a/framework/server/script_component.hpp b/framework/server/script_component.hpp new file mode 100644 index 0000000..d7cf7de --- /dev/null +++ b/framework/server/script_component.hpp @@ -0,0 +1,3 @@ +#define COMPONENT server +#define COMPONENT_BEAUTIFIED Server +#include "../script_mod.hpp" \ No newline at end of file diff --git a/framework/settings/fn_addAARChatHandler.sqf b/framework/settings/fn_addAARChatHandler.sqf deleted file mode 100644 index b419a0e..0000000 --- a/framework/settings/fn_addAARChatHandler.sqf +++ /dev/null @@ -1,11 +0,0 @@ -[ - "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/framework/settings/fn_addCBASettings.sqf b/framework/settings/fn_addCBASettings.sqf deleted file mode 100644 index 6e4a56e..0000000 --- a/framework/settings/fn_addCBASettings.sqf +++ /dev/null @@ -1,247 +0,0 @@ -//--------------------- -// Side Chat -//--------------------- - -[ - "milsim_sideChat", - "CHECKBOX", - "Side Chat Text Enabled", - ["17th Battalion", "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 Battalion", "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 Battalion", "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 Battalion", "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 Battalion", "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; - -//--------------------- -// Medical Overlay -//--------------------- - -[ - "milsim_client_medState3D_enabled", // variable - "CHECKBOX", // type - ["Enable 3D Triage Card State", "Draws a colored dot over units within 10m indicating current ACE Triage State"], // title - ["17th Battalion", "Medical"], // category - true // default value -] call CBA_fnc_addSetting; - -[ - "milsim_client_medState3D_drawRange", // variable - "LIST", // type - ["Range To Draw Icons", "Determines range at which dots are visible"], // title - ["17th Battalion", "Medical"], // category - [[2, 4, 6, 8, 10], ["2", "4", "6", "8", "10"], 4] // option values, option labels, default index -] call CBA_fnc_addSetting; - - -//--------------------- -// Respawn Settings -[ - "milsim_reinsert_setting_reinsertion_enabled", // variable - "CHECKBOX", // type - ["Enabled", "Whether or not players can file for reinsert and pilots can check the reinsert queue"], // title - ["17th Battalion", "Re-insert Queue"], // category - true, // default value - true, // global setting - { - params ["_value"]; - [ - "respawn_reinsertion", - "SETTING CHANGED", - [ - [ - "setting", - "milsim_reinsert_setting_reinsertion_enabled" - ], - ["newValue", _value] - ] - ] call milsim_util_fnc_log; - } -] call CBA_fnc_addSetting; - -[ - "milsim_reinsert_setting_reinsertion_maxRangeToReady", // variable - "SLIDER", // type - ["Max Request Filing Range", "Maximum distance from a respawn point a player can be to ready up"], // title - ["17th Battalion", "Re-insert Queue"], // category - [0, 1000, 400, 0, false], // [_min, _max, _default, _trailingDecimals, _isPercentage] - true, // global setting - { - params ["_value"]; - [ - "respawn_reinsertion", - "SETTING CHANGED", - [ - [ - "setting", - "milsim_reinsert_setting_reinsertion_maxRangeToReady" - ], - ["newValue", _value] - ] - ] call milsim_util_fnc_log; - } -] call CBA_fnc_addSetting; - -[ - "milsim_reinsert_setting_reinsertion_pilotForcedCheckEnabled", // variable - "CHECKBOX", // type - ["Enabled", "Whether or not pilots are forced to view the contents of the reinsertion queue per interval"], // title - ["17th Battalion", "Re-insert Queue"], // category - true, // default value - true, // global setting - { - params ["_value"]; - [ - "respawn_reinsertion", - "SETTING CHANGED", - [ - [ - "setting", - "milsim_reinsert_setting_reinsertion_pilotForcedCheckEnabled" - ], - ["newValue", _value] - ] - ] call milsim_util_fnc_log; - } -] call CBA_fnc_addSetting; - -[ - "milsim_reinsert_setting_reinsertion_pilotForcedCheckInterval", // variable - "TIME", // type - ["Pilot Forced Check Interval", "Pilots will be force shown the queue if they haven't checked it in X seconds"], // title - ["17th Battalion", "Re-insert Queue"], // category - [60*5, 60*30, 60*10], // [_min, _max, _default] - true, - { - params ["_value"]; - [ - "respawn_reinsertion", - "SETTING CHANGED", - [ - [ - "setting", - "milsim_reinsert_setting_reinsertion_pilotForcedCheckInterval" - ], - ["newValue", _value] - ] - ] call milsim_util_fnc_log; - } -] call CBA_fnc_addSetting; - -[ - "milsim_reinsert_setting_reinsertion_max_wait", // variable - "TIME", // type - ["Max Wait Threshold", "How long should at least one person be waiting before prompting a global notification."], // title - ["17th Battalion", "Re-insert Queue"], // category - [60*5, 60*30, 60*20], // [_min, _max, _default] - true, - { - params ["_value"]; - [ - "respawn_reinsertion", - "SETTING CHANGED", - [ - [ - "setting", - "milsim_reinsert_setting_reinsertion_max_wait" - ], - ["newValue", _value] - ] - ] call milsim_util_fnc_log; - } -] call CBA_fnc_addSetting; - -diag_log text "[MILSIM] (settings) Custom CBA settings initialized"; - -nil; \ No newline at end of file diff --git a/framework/settings/fn_setDefaults.sqf b/framework/settings/fn_setDefaults.sqf deleted file mode 100644 index 2302972..0000000 --- a/framework/settings/fn_setDefaults.sqf +++ /dev/null @@ -1,19 +0,0 @@ -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 diff --git a/framework/util/script_component.hpp b/framework/util/script_component.hpp deleted file mode 100644 index 36f9a27..0000000 --- a/framework/util/script_component.hpp +++ /dev/null @@ -1,3 +0,0 @@ -#define COMPONENT util -#define COMPONENT_BEAUTIFIED Utilities -#include "../script_mod.hpp" \ No newline at end of file -- 2.37.3.windows.1 From 91b982e06eacf2b7a4124e8993a68e8b2b1aebb8 Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Tue, 6 Feb 2024 17:36:01 -0800 Subject: [PATCH 14/16] ready for dedi -- improvements to resupply, triageIcons too --- framework/CfgFunctions.hpp | 63 +++++--- .../functions/fn_addMedicalOverlayPFH.sqf | 99 ------------- .../fn_bindEmptyGroupGarbageCleanup.sqf | 26 +++- .../client/functions/fn_bindEventHandlers.sqf | 6 +- .../functions/fn_bindVehicleActions.sqf | 2 +- .../common/functions/fn_addCBASettings.sqf | 23 --- .../functions/fn_addPlayerInfoToArray.sqf | 4 +- ...entory.sqf => fn_checkPlayerInventory.sqf} | 4 +- framework/common/functions/fn_log.sqf | 8 +- .../common/functions/fn_logMissionInfo.sqf | 1 + ...Base.sqf => fn_getCurrentAssetsByBase.sqf} | 0 .../fn_getStartingAndCurrentAssets.sqf | 2 +- .../fbcb2_assets/functions/fn_initClient.sqf | 20 ++- .../fbcb2_assets/functions/fn_initServer.sqf | 2 - .../functions/fn_updateAssetsByBase.sqf | 65 +++------ .../functions/fn_addFrequenciesRecord.sqf | 14 +- .../{fn_init.sqf => fn_initClient.sqf} | 8 +- .../util/fn_createOrUpdateDiaryRecord.sqf | 23 ++- .../fn_generateElementFrequencyRecordText.sqf | 3 +- .../init/functions/fn_addAARChatHandler.sqf | 2 + framework/init/functions/fn_initClient.sqf | 34 +++++ .../init/functions/fn_initPlayerLocal.sqf | 23 --- framework/init/functions/fn_initServer.sqf | 27 ++-- .../functions/fn_addCBASettings.sqf | 2 +- .../functions/fn_calculateClientStats.sqf | 31 ++-- .../functions/fn_calculateServerStats.sqf | 36 ++++- .../reinsert/functions/fn_addCBASettings.sqf | 34 ++--- .../reinsert/server/fn_globalShowQueue.sqf | 2 +- .../reinsert/server/fn_removeFromQueue.sqf | 33 +++-- .../fn_returnReinsertQueueNotification.sqf | 10 +- .../reinsert/server/fn_validateQueue.sqf | 25 ++-- .../fn_addArsenalObjectSpawnBoxActions.sqf | 21 ++- .../resupply/functions/fn_addCBASettings.sqf | 4 + framework/resupply/functions/fn_init.sqf | 12 -- .../resupply/functions/fn_initClient.sqf | 13 ++ framework/script_mod.hpp | 4 +- framework/server/script_component.hpp | 3 - .../functions/fn_addCBASettings.sqf | 138 ++++++++++++++++++ .../functions/fn_addDrawIconsPFH.sqf | 62 ++++++++ .../functions/fn_addGetEntitiesPFH.sqf | 18 +++ .../triageIcons/functions/fn_initClient.sqf | 12 ++ .../triageIcons/functions/fn_updateColors.sqf | 18 +++ framework/triageIcons/script_component.hpp | 3 + .../{fn_init.sqf => fn_initClient.sqf} | 0 44 files changed, 586 insertions(+), 354 deletions(-) delete mode 100644 framework/client/functions/fn_addMedicalOverlayPFH.sqf rename framework/common/functions/{fn_logPlayerInventory.sqf => fn_checkPlayerInventory.sqf} (97%) rename framework/fbcb2_assets/functions/{fn_getAssetsByBase.sqf => fn_getCurrentAssetsByBase.sqf} (100%) rename framework/fbcb2_main/functions/{fn_init.sqf => fn_initClient.sqf} (92%) create mode 100644 framework/init/functions/fn_initClient.sqf delete mode 100644 framework/init/functions/fn_initPlayerLocal.sqf delete mode 100644 framework/resupply/functions/fn_init.sqf create mode 100644 framework/resupply/functions/fn_initClient.sqf delete mode 100644 framework/server/script_component.hpp create mode 100644 framework/triageIcons/functions/fn_addCBASettings.sqf create mode 100644 framework/triageIcons/functions/fn_addDrawIconsPFH.sqf create mode 100644 framework/triageIcons/functions/fn_addGetEntitiesPFH.sqf create mode 100644 framework/triageIcons/functions/fn_initClient.sqf create mode 100644 framework/triageIcons/functions/fn_updateColors.sqf create mode 100644 framework/triageIcons/script_component.hpp rename framework/vehicleFlags/functions/{fn_init.sqf => fn_initClient.sqf} (100%) diff --git a/framework/CfgFunctions.hpp b/framework/CfgFunctions.hpp index 57a566e..d9e5f96 100644 --- a/framework/CfgFunctions.hpp +++ b/framework/CfgFunctions.hpp @@ -1,6 +1,19 @@ #include "script_mod.hpp" class CfgFunctions { + + class DOUBLES(PREFIX,init) { + class functions { + file = "framework\init\functions"; + class initServer { postInit = 1;}; + class initClient { postInit = 1;}; + class setDefaults { postInit = 1; }; + class addAARChatHandler { postInit = 1; }; + class addRespawnChatHandler { postInit = 1; }; + }; + }; + + class PREFIX { class ambience { file = "framework\ambience"; @@ -22,7 +35,6 @@ class CfgFunctions { class DOUBLES(PREFIX,client) { class functions { file = "framework\client\functions"; - class addMedicalOverlayPFH { postInit = 1; }; class addZenModules { postInit = 1; }; class bindEmptyGroupGarbageCleanup { postInit = 1; }; class bindEventHandlers { postInit = 1; }; @@ -35,14 +47,14 @@ class CfgFunctions { class functions { file = "framework\common\functions"; class addCBASettings { preInit = 1; }; - class logMissionInfo { postInit = 1; }; + class logMissionInfo {}; class addPlayerInfoToArray {}; class getApprovedAssetsCfg {}; class getBattalionCfg {}; class getNameOfBase {}; class getNearestBase {}; class log {}; - class logPlayerInventory {}; + class checkPlayerInventory {}; class logSettingChanged {}; class padString {}; class recurseSubclasses {}; @@ -53,30 +65,30 @@ class CfgFunctions { class functions { file = "framework\fbcb2_assets\functions"; class addCBASettings {preInit=1;}; - class initClient {postInit=1;}; - class initServer {postInit=1;}; - class getAssetsByBase {}; + class initServer {}; + class initClient {}; + class getCallsignFromClassname {}; + class getCurrentAssetsByBase {}; class getInventory {}; class getMagsForWeapon {}; + class getStartingAndCurrentAssets {}; class getStartingAssetsByBase {}; class getVehicleData {}; class getWeaponry {}; class hintAllApprovedAssets {}; + class isAssetInRangeOfBase {}; class removeAssetDiaryRecords {}; class removeMarkersOnMap {}; class showMarkersOnMap {}; class updateAssetDiary {}; class updateAssetsByBase {}; - class getCallsignFromClassname {}; - class getStartingAndCurrentAssets {}; - class isAssetInRangeOfBase {}; }; }; class DOUBLES(PREFIX,fbcb2_main) { class functions { file = "framework\fbcb2_main\functions"; - class init { postInit = 1; }; + class initClient {}; class addEnvironmentRecord {}; class addFrequenciesRecord {}; class addSignalColorsRecord {}; @@ -89,21 +101,13 @@ class CfgFunctions { }; }; - class DOUBLES(PREFIX,init) { - file = "framework\init\functions"; - class addAARChatHandler { postInit = 1; }; - class addRespawnChatHandler { postInit = 1; }; - class initServer { postInit = 1;}; - class initPlayerLocal { postInit = 1;}; - class setDefaults { postInit = 1; }; - }; - class DOUBLES(PREFIX,performance) { class functions { file = "framework\performance\functions"; class addCBASettings {preInit=1;}; - class init {postInit=1;}; class addDNI_PlayerFPS { postInit = 1; }; + + // PFHs managed in addCBASettings onChange code class addClientStatsPFH {}; class calculateClientStats {}; class addServerStatsPFH {}; @@ -118,7 +122,7 @@ class CfgFunctions { }; class server { file = "framework\reinsert\server"; - class initServer { postInit = 1; }; + class initServer {}; class addToQueue {}; class globalShowQueue {}; class removeFromQueue {}; @@ -127,7 +131,7 @@ class CfgFunctions { }; class client { file = "framework\reinsert\client"; - class initClient { postInit = 1; }; + class initClient {}; class addAceSelfActions {}; class addCheckQueueSelfAction {}; class requestShowQueue {}; @@ -138,17 +142,28 @@ class CfgFunctions { class functions { file = "framework\resupply\functions"; class addCBASettings {preInit=1;}; - class init {postInit=1;}; + class initClient {}; class createBox {}; class getSupplyCratesCfg {}; class addArsenalObjectSpawnBoxActions {}; }; }; + class DOUBLES(PREFIX,triageIcons) { + class functions { + file = "framework\triageIcons\functions"; + class addCBASettings {preInit=1;}; + class initClient {}; + class addDrawIconsPFH {}; + class addGetEntitiesPFH {}; + class updateColors {}; + }; + }; + class DOUBLES(PREFIX,vehicleFlags) { class functions { file = "framework\vehicleFlags\functions"; - class init {postInit=1;}; + class initClient {}; class getActionsFlagCategories {}; class getVehicleFlagsCfg {}; class isClassExcluded {}; diff --git a/framework/client/functions/fn_addMedicalOverlayPFH.sqf b/framework/client/functions/fn_addMedicalOverlayPFH.sqf deleted file mode 100644 index bf3d6b3..0000000 --- a/framework/client/functions/fn_addMedicalOverlayPFH.sqf +++ /dev/null @@ -1,99 +0,0 @@ -/* - -milsim_fnc_addMedicalOverlayPFH - -Author: IndigoFox - -Description: - Affects players with medical permissions. Will see a 3D colored dot over nearby (5-10m) - unconscious players who are not in a vehicle - which indicates their current ACE Triage Card status. - Designed to increase efficiency of CCPs. - -*/ - -// Force setting if CBA doesn't work? -if (isNil "milsim_client_medState3D_enabled") then { - milsim_client_medState3D_enabled = true; -}; -if (isNil "milsim_client_medState3D_drawRange") then { - milsim_client_medState3D_drawRange = 10; -}; - -// List of units to draw icons for -milsim_client_medState3D_drawTargets = []; - -// ACE Triage colors, for consistency across UIs and functions -// #define TRIAGE_COLOR_NONE 0.5, 0.5, 0.5, 0.1 -// #define TRIAGE_COLOR_MINIMAL 0, 0.5, 0, 0.9 -// #define TRIAGE_COLOR_DELAYED 1, 0.84, 0, 0.9 -// #define TRIAGE_COLOR_IMMEDIATE 1, 0, 0, 0.9 -// #define TRIAGE_COLOR_DECEASED 0, 0, 0, 0.9 - -// ACE Triage colors, for consistency across UIs and functions -milsim_client_medState3D_colors = [ - [0, 0.5, 0, 0.9], // TRIAGE_COLOR_MINIMAL - [1, 0.84, 0, 0.9], // TRIAGE_COLOR_DELAYED - [1, 0, 0, 0.9], // TRIAGE_COLOR_IMMEDIATE - [0.15, 0.15, 0.15, 0.9], // TRIAGE_COLOR_DECEASED - [0.5, 0.5, 0.5, 0] // TRIAGE_COLOR_NONE -]; - -// Per-frame handler to draw icons -// cleanup -if (!isNil "milsim_client_medState3D_pfh") then { - [milsim_client_medState3D_pfh] call CBA_fnc_removePerFrameHandler; -}; -// add pfh -milsim_client_medState3D_pfh = [{ - // if disabled, skip processing - if (!milsim_client_medState3D_enabled) exitWith {false}; - // if no targets, skip processing - if (count milsim_client_medState3D_drawTargets == 0) exitWith {false}; - if !([player] call ace_medical_treatment_fnc_isMedic) exitWith {false}; - { - // distance within 10 meters - if (player distance _x > milsim_client_medState3D_drawRange) then {continue}; - // check unit not null, not conscious, and not in a vehicle - if ( - !(_x getVariable ["ACE_isUnconscious", false]) || - !isNull (objectParent _x) - ) then {continue}; - - // color based on triage level - private _triageLevel = _x getVariable ["ace_medical_triageLevel", -1]; - if (_triageLevel == -1) then {continue}; - private _color = milsim_client_medState3D_colors select ( - (_x getVariable ["ace_medical_triageLevel", -1]) -1 - ); - // draw position, slightly above the prone unit - private _drawPos = (visiblePosition _x) vectorAdd [0, 0, 0.5]; - // draw icon - drawIcon3D [ - "\A3\ui_f\data\map\markers\military\dot_CA.paa", // icon texture - _color, // color - _drawPos, // position AGL - 1, // width - 1, // height - 0 // angle - // further params optional, omitted - ]; - } forEach milsim_client_medState3D_drawTargets; -}, 0, []] call CBA_fnc_addPerFrameHandler; - -// subroutine to gather nearest 50 units every 5 seconds and store in milsim_client_medState3D_drawTargets -// cleanup -if (!isNil "milsim_client_medState3D_drawTargetsPfh") then { - [milsim_client_medState3D_drawTargetsPfh] call CBA_fnc_removePerFrameHandler; -}; -// add pfh -milsim_client_medState3D_drawTargetsPfh = [{ - milsim_client_medState3D_drawTargets = ( - (allUnits + allDeadMen) select { - _x isKindOf "CAManBase" && - player distance _x < 50 && - !isNull _x && - player isNotEqualTo _x - } - ); -}, 5, false] call CBA_fnc_addPerFrameHandler; diff --git a/framework/client/functions/fn_bindEmptyGroupGarbageCleanup.sqf b/framework/client/functions/fn_bindEmptyGroupGarbageCleanup.sqf index 7cb7771..4833821 100644 --- a/framework/client/functions/fn_bindEmptyGroupGarbageCleanup.sqf +++ b/framework/client/functions/fn_bindEmptyGroupGarbageCleanup.sqf @@ -1,4 +1,11 @@ -diag_log text format ["[MILSIM] (client) initializing empty group deletion PFH"]; +#include "..\script_component.hpp" + +[ + LEVEL_INFO, + QUOTE(COMPONENT), + "Initializing empty group deletion PFH", + [] +] call EFUNC(common,log); _emptyGroupPFH = [ { @@ -12,8 +19,21 @@ _emptyGroupPFH = [ }, 300, [], - { diag_log text format ["[MILSIM] (client) Empty Group Deletion PFH loaded"] }, - { diag_log text format ["[MILSIM] (client) Empty Group Deletion"] }, + { + [ + LEVEL_INFO, + QUOTE(COMPONENT), + "Empty group deletion PFH loaded", + [] + ] call EFUNC(common,log); + }, + { [ + LEVEL_INFO, + QUOTE(COMPONENT), + "Empty group deletion PFH unloaded", + [] + ] call EFUNC(common,log); + }, { true }, { false }, [] diff --git a/framework/client/functions/fn_bindEventHandlers.sqf b/framework/client/functions/fn_bindEventHandlers.sqf index ed2ee97..802c2c5 100644 --- a/framework/client/functions/fn_bindEventHandlers.sqf +++ b/framework/client/functions/fn_bindEventHandlers.sqf @@ -8,7 +8,7 @@ player addEventHandler["Respawn", private _killer = _corpse getVariable ["ace_medical_causeOfDeath", "#scripted"]; if (_killer == "respawn_button") then { [ - LEVEL_INFO + LEVEL_INFO, QUOTE(COMPONENT), "RESPAWNED WHILE UNCONSCIOUS", [_unit] call EFUNC(common,addPlayerInfoToArray) @@ -46,11 +46,11 @@ addMissionEventHandler ["HandleChatMessage", ["ace_arsenal_displayClosed", { - [player] remoteExec [QEFUNC(common,logPlayerInventory), 2]; + [player] remoteExec [QEFUNC(common,checkPlayerInventory), 2]; }] call CBA_fnc_addEventHandler; [missionNamespace, "arsenalClosed", { - [player] remoteExec [QEFUNC(common,logPlayerInventory), 2]; + [player] remoteExec [QEFUNC(common,checkPlayerInventory), 2]; }] call BIS_fnc_addScriptedEventHandler; diag_log text "[MILSIM] (client) event handlers bound"; diff --git a/framework/client/functions/fn_bindVehicleActions.sqf b/framework/client/functions/fn_bindVehicleActions.sqf index ccf502f..6947457 100644 --- a/framework/client/functions/fn_bindVehicleActions.sqf +++ b/framework/client/functions/fn_bindVehicleActions.sqf @@ -56,7 +56,7 @@ _patchTire = "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] ) } + { ( alive _target ) && ( [_player, "ToolKit"] call ace_common_fnc_hasItem ) && ( damage _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; diff --git a/framework/common/functions/fn_addCBASettings.sqf b/framework/common/functions/fn_addCBASettings.sqf index 9457034..700f1ae 100644 --- a/framework/common/functions/fn_addCBASettings.sqf +++ b/framework/common/functions/fn_addCBASettings.sqf @@ -22,29 +22,6 @@ [QGVARMAIN(sideChat), false] call CBA_settings_fnc_set; - -//--------------------- -// Medical Overlay -//--------------------- - -[ - "milsim_client_medState3D_enabled", // variable - "CHECKBOX", // type - ["Enable 3D Triage Card State", "Draws a colored dot over units within 10m indicating current ACE Triage State"], // title - ["17th Battalion", "Medical"], // category - true // default value -] call CBA_fnc_addSetting; - -[ - "milsim_client_medState3D_drawRange", // variable - "LIST", // type - ["Range To Draw Icons", "Determines range at which dots are visible"], // title - ["17th Battalion", "Medical"], // category - [[2, 4, 6, 8, 10], ["2", "4", "6", "8", "10"], 4] // option values, option labels, default index -] call CBA_fnc_addSetting; - - - diag_log text "[MILSIM] (settings) Custom CBA settings initialized"; nil; \ No newline at end of file diff --git a/framework/common/functions/fn_addPlayerInfoToArray.sqf b/framework/common/functions/fn_addPlayerInfoToArray.sqf index 3035094..353410c 100644 --- a/framework/common/functions/fn_addPlayerInfoToArray.sqf +++ b/framework/common/functions/fn_addPlayerInfoToArray.sqf @@ -1,6 +1,6 @@ #include "..\script_component.hpp" -params [["_playerObj", objNull], ["_arrayToModify", [], [[]]]]; +params [["_playerObj", objNull, [nil, objNull]], ["_arrayToModify", [], [[]]]]; if (isNull _playerObj) exitWith {_arrayToModify}; @@ -10,7 +10,7 @@ if (isNull _playerObj) exitWith {_arrayToModify}; ["playerName", name _playerObj], ["playerUID", getPlayerUID _playerObj], ["playerGroup", groupId (group _playerObj)], - ["playerNetID", [_playerObj] call BIS_fnc_netId] + ["playerNetID", _playerObj call BIS_fnc_netId] ]; _arrayToModify; \ No newline at end of file diff --git a/framework/common/functions/fn_logPlayerInventory.sqf b/framework/common/functions/fn_checkPlayerInventory.sqf similarity index 97% rename from framework/common/functions/fn_logPlayerInventory.sqf rename to framework/common/functions/fn_checkPlayerInventory.sqf index 97951de..14874ae 100644 --- a/framework/common/functions/fn_logPlayerInventory.sqf +++ b/framework/common/functions/fn_checkPlayerInventory.sqf @@ -1,5 +1,5 @@ /* - Function: milsim_util_fnc_logPlayerInventory + Function: milsim_common_fnc_checkPlayerInventory Description: Checks a player's inventory for non-compliant items and logs results to all machines. @@ -21,7 +21,7 @@ params [ if (!isPlayer _player) exitWith { [ - LEVEL_ERROR + LEVEL_ERROR, QUOTE(COMPONENT), "PARAM PLAYER IS NOT A PLAYER", [["player", _player]] diff --git a/framework/common/functions/fn_log.sqf b/framework/common/functions/fn_log.sqf index 975633c..716c0df 100644 --- a/framework/common/functions/fn_log.sqf +++ b/framework/common/functions/fn_log.sqf @@ -1,5 +1,5 @@ /* - Function: milsim_util_fnc_log + Function: milsim_common_fnc_log Description: Used to log messages to the server RPT file. @@ -19,13 +19,13 @@ params [ ["_data", [], [[]]] ]; -if (_logLevel < LOG_LEVEL) exitWith {}; +if (_logLevel < DEBUG_MODE) exitWith {}; private _hash = createHashMapFromArray _data; // Replace square brackets with round brackets to avoid parsing issues. -_message regexReplace ["\[", "("]; -_message regexReplace ["\]", ")"]; +_message regexReplace ['(\[)', "("]; +_message regexReplace ['(\])', ")"]; private _json = [_hash] call CBA_fnc_encodeJSON; _log = format ["[%1] [%2] [%3] [%4] :: %5", QUOTE(PREFIX), _component, _fnc_scriptNameParent, _message, _json]; diff --git a/framework/common/functions/fn_logMissionInfo.sqf b/framework/common/functions/fn_logMissionInfo.sqf index 1da141c..ecba52c 100644 --- a/framework/common/functions/fn_logMissionInfo.sqf +++ b/framework/common/functions/fn_logMissionInfo.sqf @@ -1,6 +1,7 @@ #include "..\script_component.hpp" [ + LEVEL_INFO, QUOTE(COMPONENT), "MISSION INFO", [ diff --git a/framework/fbcb2_assets/functions/fn_getAssetsByBase.sqf b/framework/fbcb2_assets/functions/fn_getCurrentAssetsByBase.sqf similarity index 100% rename from framework/fbcb2_assets/functions/fn_getAssetsByBase.sqf rename to framework/fbcb2_assets/functions/fn_getCurrentAssetsByBase.sqf diff --git a/framework/fbcb2_assets/functions/fn_getStartingAndCurrentAssets.sqf b/framework/fbcb2_assets/functions/fn_getStartingAndCurrentAssets.sqf index a939818..76daf37 100644 --- a/framework/fbcb2_assets/functions/fn_getStartingAndCurrentAssets.sqf +++ b/framework/fbcb2_assets/functions/fn_getStartingAndCurrentAssets.sqf @@ -8,7 +8,7 @@ private _startingAssets = []; } forEach _startingAssetsByBase; // get all current assets at each base and combine to array -private _assetsByBase = call FUNC(getAssetsByBase); +private _assetsByBase = call FUNC(getCurrentAssetsByBase); private _assets = []; { _assets append (_x#1); diff --git a/framework/fbcb2_assets/functions/fn_initClient.sqf b/framework/fbcb2_assets/functions/fn_initClient.sqf index 57d6474..62dfbf3 100644 --- a/framework/fbcb2_assets/functions/fn_initClient.sqf +++ b/framework/fbcb2_assets/functions/fn_initClient.sqf @@ -2,15 +2,27 @@ if (!hasInterface) exitWith {}; +call FUNC(updateAssetDiary); + // once the server has published that assets have been gathered and distributed to bases (respawn modules), // we can update the asset diary on our end using that data -[{missionNamespace getVariable [QGVAR(serverAssetsReady), false]}, { - call FUNC(updateAssetDiary); -}] call CBA_fnc_waitUntilAndExecute; +[QGVAR(assetsGathered), { + [ + LEVEL_DEBUG, + QUOTE(COMPONENT), + "Received gathered base asset data from server", + [] + ] call EFUNC(common,log); + + // update the asset diary with the data we've received + FUNC(updateAssetDiary); +}] call CBA_fnc_addEventHandlerArgs; [ LEVEL_DEBUG, QUOTE(COMPONENT), "postInit complete", [] -] call EFUNC(common,log); \ No newline at end of file +] call EFUNC(common,log); + +localNamespace setVariable [QGVAR(complete), true]; \ No newline at end of file diff --git a/framework/fbcb2_assets/functions/fn_initServer.sqf b/framework/fbcb2_assets/functions/fn_initServer.sqf index 15dab32..14dfcbd 100644 --- a/framework/fbcb2_assets/functions/fn_initServer.sqf +++ b/framework/fbcb2_assets/functions/fn_initServer.sqf @@ -5,8 +5,6 @@ if (!isServer) exitWith {}; // init asset stores at bases [true] call FUNC(updateAssetsByBase); -missionNamespace setVariable [QGVAR(serverAssetsReady), true, true]; - // starting 5 minutes after postInit, update asset stores every 5 minutes [{ [ diff --git a/framework/fbcb2_assets/functions/fn_updateAssetsByBase.sqf b/framework/fbcb2_assets/functions/fn_updateAssetsByBase.sqf index d48bc5a..dc0e2e7 100644 --- a/framework/fbcb2_assets/functions/fn_updateAssetsByBase.sqf +++ b/framework/fbcb2_assets/functions/fn_updateAssetsByBase.sqf @@ -7,6 +7,8 @@ params [ if (!isServer) exitWith {}; +GVARMAIN(baseObjects) = allMissionObjects "ModuleRespawnPosition_F"; + // Get all approved assets on map, find the closest base // Then determine if it's within range // If it is, add it to the base's assets list @@ -14,12 +16,14 @@ if (!isServer) exitWith {}; private _allVehicles = vehicles; private _allSaved = []; -private _assetsAtThisBaseVar = QGVAR(assetsAtThisBase); private _assetsStartedAtThisBaseVar = QGVAR(assetsStartedAtThisBase); +private _assetsAtThisBaseVar = QGVAR(assetsAtThisBase); private _approvedAssetsCfg = call EFUNC(common,getApprovedAssetsCfg); if (isNull _approvedAssetsCfg) exitWith {}; +private _currentBaseAssetsGathered = GVARMAIN(baseObjects) apply {[_x, []]};; + { private _className = configName _x; private _callsign = getText(_x >> "callsign"); @@ -27,68 +31,34 @@ if (isNull _approvedAssetsCfg) exitWith {}; { private _asset = _x; - // avoid duplicates - if (_asset in _allSaved) then {continue}; - + // ignore assets beyond the range of bases if (not ([_asset] call FUNC(isAssetInRangeOfBase))) then {continue}; // add to base's assets list private _closestBase = [_asset] call EFUNC(common,getNearestBase); - private _baseAssets = _closestBase getVariable [_assetsAtThisBaseVar, []]; - _baseAssets pushBackUnique [ + private _closestBaseCurrentAssets = (_currentBaseAssetsGathered select { _x select 0 isEqualTo _closestBase })#0#1; + _closestBaseCurrentAssets pushBackUnique [ _asset call BIS_fnc_netId, configOf _asset ]; - // broadcast later so we're not spamming network - _closestBase setVariable [ - _assetsAtThisBaseVar, - _baseAssets - ]; - - // if this is the init, set the base's assets started at this base - if (_isInit) then { - // broadcast later so we're not spamming network - _closestBase setVariable [ - _assetsStartedAtThisBaseVar, - _baseAssets - ]; - }; - - _allSaved pushBack _asset; } forEach _found; } forEach (_approvedAssetsCfg call BIS_fnc_returnChildren); // Add all ground vehicles (LandVehicle) { private _asset = _x; - // avoid duplicates - if (_asset in _allSaved) then {continue}; + // ignore assets beyond the range of bases if (not ([_asset] call FUNC(isAssetInRangeOfBase))) then {continue}; - // add to base's assets list private _closestBase = [_asset] call EFUNC(common,getNearestBase); - private _baseAssets = _closestBase getVariable [_assetsAtThisBaseVar, []]; - _baseAssets pushBackUnique [ + private _closestBaseCurrentAssets = (_currentBaseAssetsGathered select { _x select 0 isEqualTo _closestBase })#0#1; + _closestBaseCurrentAssets pushBackUnique [ _asset call BIS_fnc_netId, configOf _asset ]; - // broadcast later so we're not spamming network - _closestBase setVariable [ - _assetsAtThisBaseVar, - _baseAssets - ]; - - // if this is the init, set the base's assets started at this base - if (_isInit) then { - // broadcast later so we're not spamming network - _closestBase setVariable [ - _assetsStartedAtThisBaseVar, - _baseAssets - ]; - }; } forEach (_allVehicles select { _x isKindOf "LandVehicle" }); //////////////////////////////////////////////////////////////////////// @@ -97,16 +67,17 @@ if (isNull _approvedAssetsCfg) exitWith {}; { private _base = _x; - // save current assets - private _baseAssets = _base getVariable [_assetsAtThisBaseVar, []]; - _base setVariable [_assetsAtThisBaseVar, _baseAssets, true]; + private _thisBaseCurrentAssets = (_currentBaseAssetsGathered select { _x select 0 isEqualTo _base })#0#1; + _base setVariable [_assetsAtThisBaseVar, _thisBaseCurrentAssets, true]; - // if init, save starting assets if (_isInit) then { - _base setVariable [_assetsStartedAtThisBaseVar, _baseAssets, true]; + _base setVariable [_assetsStartedAtThisBaseVar, _thisBaseCurrentAssets, true]; }; } forEach GVARMAIN(baseObjects); +// send a CBA event to let other scripts know that assets have been gathered +[{[QGVAR(assetsGathered)] call CBA_fnc_globalEvent;}, 2] call CBA_fnc_waitAndExecute; + //////////////////////////////////////////////////////////////////////// // log starting assets if init // log current assets if requested (for end of mission counts) @@ -117,7 +88,7 @@ if !(_isInit || _logCurrentAssets) exitWith {}; private _base = _x; // get current assets - private _baseAssets = _base getVariable [_assetsAtThisBaseVar, []]; + private _baseAssets = (_currentBaseAssetsGathered select { _x select 0 isEqualTo _base })#0#1; // prepare key value for logging private _baseAssetsHashesPrep = _baseAssets apply { diff --git a/framework/fbcb2_main/functions/fn_addFrequenciesRecord.sqf b/framework/fbcb2_main/functions/fn_addFrequenciesRecord.sqf index 64f1ca4..9f5cccb 100644 --- a/framework/fbcb2_main/functions/fn_addFrequenciesRecord.sqf +++ b/framework/fbcb2_main/functions/fn_addFrequenciesRecord.sqf @@ -14,6 +14,7 @@ if (isNull _battalionInfoCfg) exitWith { "Null Battalion Config", [] ] call EFUNC(common,log); + ["Null Battalion Config"] call BIS_fnc_error; }; private _battalionElementCfgs = [_battalionInfoCfg >> "Command"] call BIS_fnc_returnChildren; @@ -24,6 +25,7 @@ if (count _battalionElementCfgs == 0) exitWith { "ERROR: No battalion elements found. Check that the battalion config is correctly structured. See defines/BattalionInfo.hpp and framework/util/functions/getBattalionCfg.sqf.", [] ] call EFUNC(common,log); + ["ERROR: No battalion elements found. Check that the battalion config is correctly structured. See defines/BattalionInfo.hpp and framework/util/functions/getBattalionCfg.sqf."] call BIS_fnc_error; }; //////////////////////////////////////// @@ -48,12 +50,12 @@ private _FREQ_TEXT_COLOR = "#CCCCCC"; reverse _battalionElementCfgs; { - diag_log text format[ - "[%1] <%2> Processing battalion element %3", - QUOTE(PREFIX), - _fnc_scriptName, - configName _x - ]; + [ + LEVEL_TRACE, + QUOTE(COMPONENT), + format["Processing battalion element %1", configName _x], + [] + ] call EFUNC(common,log); // recursively generate diary text for all child elements of battalion-level elements private _diaryTitleText = [_x, true] call FUNC(generateElementFrequencyRecordText); [ diff --git a/framework/fbcb2_main/functions/fn_init.sqf b/framework/fbcb2_main/functions/fn_initClient.sqf similarity index 92% rename from framework/fbcb2_main/functions/fn_init.sqf rename to framework/fbcb2_main/functions/fn_initClient.sqf index 473123d..b2f717b 100644 --- a/framework/fbcb2_main/functions/fn_init.sqf +++ b/framework/fbcb2_main/functions/fn_initClient.sqf @@ -2,8 +2,6 @@ if ( !hasInterface ) exitWith {}; -waitUntil { !isNil QGVARMAIN(complete) }; - GVAR(recordTitleColor) = "#ff6666"; GVAR(recordTitleFont) = "PuristaMedium"; GVAR(recordTitleSize) = 20; @@ -33,7 +31,7 @@ player createDiarySubject[GVAR(subjectAssetsGroundID), "FBCB2 Ground"]; // ]] GVAR(diaryRecords) = createHashMap; -// run main inits - assets handled in that component +// run main inits [] call FUNC(addFrequenciesRecord); [] call FUNC(addSignalColorsRecord); [] call FUNC(addEnvironmentRecord); @@ -51,4 +49,6 @@ GVAR(diaryRecords) = createHashMap; QUOTE(COMPONENT), "postInit complete", [] -] call EFUNC(common,log); \ No newline at end of file +] call EFUNC(common,log); + +localNamespace setVariable [QGVAR(complete), true]; \ No newline at end of file diff --git a/framework/fbcb2_main/util/fn_createOrUpdateDiaryRecord.sqf b/framework/fbcb2_main/util/fn_createOrUpdateDiaryRecord.sqf index 824c271..7f04abb 100644 --- a/framework/fbcb2_main/util/fn_createOrUpdateDiaryRecord.sqf +++ b/framework/fbcb2_main/util/fn_createOrUpdateDiaryRecord.sqf @@ -15,9 +15,16 @@ private _existingRecord = _subjectRecords getOrDefault [_recordTitle, diaryRecor if (!isNull _existingRecord) then { player setDiaryRecordText [[_subjectID, _existingRecord], [_recordTitle, _recordText, _recordIcon]]; - if (DEBUG_ENABLED) then { - systemChat format ["Updated diary record: %1", _recordTitle]; - }; + + [ + LEVEL_DEBUG, + QUOTE(COMPONENT), + format ["Updated diary record: %1", _recordTitle], + [ + ["subjectID", _subjectID], + ["recordTitle", _recordTitle] + ] + ] call EFUNC(common,log); } else { private _new = player createDiaryRecord [ _subjectID, @@ -29,4 +36,14 @@ if (!isNull _existingRecord) then { ]; _subjectRecords set [_recordTitle, _new]; GVAR(diaryRecords) set [_subjectID, _subjectRecords]; + + [ + LEVEL_DEBUG, + QUOTE(COMPONENT), + format ["Created diary record: %1", _recordTitle], + [ + ["subjectID", _subjectID], + ["recordTitle", _recordTitle] + ] + ] call EFUNC(common,log); }; \ No newline at end of file diff --git a/framework/fbcb2_main/util/fn_generateElementFrequencyRecordText.sqf b/framework/fbcb2_main/util/fn_generateElementFrequencyRecordText.sqf index d63b328..b329279 100644 --- a/framework/fbcb2_main/util/fn_generateElementFrequencyRecordText.sqf +++ b/framework/fbcb2_main/util/fn_generateElementFrequencyRecordText.sqf @@ -71,7 +71,8 @@ if (_shouldProcessChildCfgs) then { [ LEVEL_TRACE, QUOTE(COMPONENT), - "Processing child elements for battalion element %1" + "Processing child elements for battalion element %1", + [] ] call EFUNC(common,log); [_battalionElement, { diff --git a/framework/init/functions/fn_addAARChatHandler.sqf b/framework/init/functions/fn_addAARChatHandler.sqf index a0e8135..10f3979 100644 --- a/framework/init/functions/fn_addAARChatHandler.sqf +++ b/framework/init/functions/fn_addAARChatHandler.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + [ "saveaar", { diff --git a/framework/init/functions/fn_initClient.sqf b/framework/init/functions/fn_initClient.sqf new file mode 100644 index 0000000..a7d106a --- /dev/null +++ b/framework/init/functions/fn_initClient.sqf @@ -0,0 +1,34 @@ +#include "..\script_component.hpp" + +if ( !hasInterface ) exitWith {}; + +["milsim_logText", { + params [["_strArray", [""], [[]]]]; + { + diag_log text _x; + } forEach _strArray; +}] call CBA_fnc_addEventHandler; + +// make sure the server has finished init +waitUntil {!isNil QGVARMAIN(complete)}; + +["InitializePlayer", [player, true]] call BIS_fnc_dynamicGroups; + + +// initialize other modules +call EFUNC(reinsert,initClient); +call EFUNC(resupply,initClient); +call EFUNC(triageIcons,initClient); +call EFUNC(vehicleFlags,initClient); +call EFUNC(fbcb2_main,initClient); +call EFUNC(fbcb2_assets,initClient); + + +[ + LEVEL_DEBUG, + QUOTE(COMPONENT), + "postInit complete", + [] +] call EFUNC(common,log); + +nil; \ No newline at end of file diff --git a/framework/init/functions/fn_initPlayerLocal.sqf b/framework/init/functions/fn_initPlayerLocal.sqf deleted file mode 100644 index e1bf330..0000000 --- a/framework/init/functions/fn_initPlayerLocal.sqf +++ /dev/null @@ -1,23 +0,0 @@ -#include "..\script_component.hpp" - -if ( !hasInterface ) exitWith {}; - -if (!isServer) then { - ["milsim_logText", { - params [["_strArray", [""], [[]]]]; - { - diag_log text _x; - } forEach _strArray; - }] call CBA_fnc_addEventHandler; -}; - -["InitializePlayer", [player, true]] call BIS_fnc_dynamicGroups; - -[ - LEVEL_DEBUG, - QUOTE(COMPONENT), - "postInit complete", - [] -] call EFUNC(common,log); - -nil; \ No newline at end of file diff --git a/framework/init/functions/fn_initServer.sqf b/framework/init/functions/fn_initServer.sqf index 0b0e4cb..84e2666 100644 --- a/framework/init/functions/fn_initServer.sqf +++ b/framework/init/functions/fn_initServer.sqf @@ -2,23 +2,30 @@ if (!isServer) exitWith {}; - // array of all respawn modules in the mission representing "bases" GVARMAIN(baseObjects) = allMissionObjects "ModuleRespawnPosition_F"; -publicVariable "milsim_baseObjects"; +publicVariable QGVARMAIN(baseObjects); // Initializes the Dynamic Groups framework and groups ["Initialize", [true]] call BIS_fnc_dynamicGroups; -["milsim_logText", { - params [["_strArray", [""], [[]]]]; - { - diag_log text _x; - } forEach _strArray; -}] call CBA_fnc_addEventHandler; +if (isDedicated) then { + ["milsim_logText", { + params [["_strArray", [""], [[]]]]; + { + diag_log text _x; + } forEach _strArray; + }] call CBA_fnc_addEventHandler; +}; -missionNamespace setVariable [QGVARMAIN(complete), true]; -publicVariable QGVARMAIN(complete); + +// initialize other modules +call EFUNC(common,logMissionInfo); +call EFUNC(fbcb2_assets,initServer); +call EFUNC(reinsert,initServer); + +// declare init complete to other modules +missionNamespace setVariable [QGVARMAIN(complete), true, true]; [ LEVEL_INFO, diff --git a/framework/performance/functions/fn_addCBASettings.sqf b/framework/performance/functions/fn_addCBASettings.sqf index e1564d7..405e72c 100644 --- a/framework/performance/functions/fn_addCBASettings.sqf +++ b/framework/performance/functions/fn_addCBASettings.sqf @@ -8,7 +8,7 @@ QGVAR(server_cps_enable), "CHECKBOX", "Server CPS Metrics Enabled", - ["17th Battalion", "Server Metrics"], + [QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)], true, true, { diff --git a/framework/performance/functions/fn_calculateClientStats.sqf b/framework/performance/functions/fn_calculateClientStats.sqf index 0db20a2..24bd75c 100644 --- a/framework/performance/functions/fn_calculateClientStats.sqf +++ b/framework/performance/functions/fn_calculateClientStats.sqf @@ -10,13 +10,8 @@ _counter = _counter + 1; }; // in an empty mission, the _counter may go well over 2000 times per frame! - [ - LEVEL_INFO, - QUOTE(COMPONENT), - format ["Average Execution: %1 times per frame", _counter / (diag_frameNo - _frameNo)], - [["playerRawCPS", _counter / (diag_frameNo - _frameNo)]] - ] call EFUNC(common,log); - player setVariable [QGVAR(player_raw_cps), _counter / (diag_frameNo - _frameNo), true]; + private _rawCPS = _counter / (diag_frameNo - _frameNo); + player setVariable [QGVAR(player_raw_cps), _rawCPS, true]; // with suspension private _counter = 0; @@ -28,13 +23,23 @@ uiSleep 0.001; // waits at least 1 frame }; // _counter says one per frame, as expected + private _playerCPS = _counter / (diag_frameNo - _frameNo); + player setVariable [QGVAR(player_cps), _playerCPS, true]; + + // log to RPT [ - LEVEL_INFO, - QUOTE(COMPONENT), - format ["Average Execution: %1 times per frame", _counter / (diag_frameNo - _frameNo)], - [["playerCPS", _counter / (diag_frameNo - _frameNo)]] - ] call EFUNC(common,log); - player setVariable [QGVAR(player_cps), _counter / (diag_frameNo - _frameNo), true]; + + {_this call EFUNC(common,log);}, + [ + LEVEL_INFO, + QUOTE(COMPONENT), + format ["Average Execution: %1 times per frame", _playerCPS], + [ + ["playerRawCPS", _rawCPS], + ["playerCPS", _playerCPS] + ] + ] + ] call CBA_fnc_directCall; }; nil; \ No newline at end of file diff --git a/framework/performance/functions/fn_calculateServerStats.sqf b/framework/performance/functions/fn_calculateServerStats.sqf index 5f58b67..b0ec77d 100644 --- a/framework/performance/functions/fn_calculateServerStats.sqf +++ b/framework/performance/functions/fn_calculateServerStats.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + [] spawn { // warning: while loop without suspension executes multiple times per frame private _counter = 0; @@ -8,10 +10,9 @@ _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"; + private _rawCPS = _counter / (diag_frameNo - _frameNo); + missionNamespace setVariable [QGVAR(server_raw_cps), _rawCPS]; + publicVariable QGVAR(server_raw_cps); // with suspension private _counter = 0; @@ -23,12 +24,31 @@ 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)]; + private _serverCPS = _counter / (diag_frameNo - _frameNo); + missionNamespace setVariable [QGVAR(server_cps), _counter / (diag_frameNo - _frameNo)]; + publicVariable QGVAR(server_cps); - missionNamespace setVariable ["milsim_cps", _counter / (diag_frameNo - _frameNo)]; - publicVariable "milsim_cps"; + // log to RPT + [ + + {_this call EFUNC(common,log);}, + [ + LEVEL_INFO, + QUOTE(COMPONENT), + format ["Average Server Execution: %1 times per frame", _serverCPS], + [ + ["serverRawCPS", _rawCPS], + ["serverCPS", _serverCPS] + ] + ] + ] call CBA_fnc_directCall; - ["milsim_serverEfficiency", [ [ ["float", "milsim_raw_cps", missionNamespace getVariable ["milsim_raw_cps", -1]], ["float", "milsim_cps", missionNamespace getVariable ["milsim_cps", -1]] ] ] ] call CBA_fnc_localEvent; + [QGVARMAIN(serverEfficiency), [ + [ + ["float", QGVAR(server_raw_cps), missionNamespace getVariable [QGVAR(server_raw_cps), -1]], + ["float", QGVAR(server_cps), missionNamespace getVariable [QGVAR(server_cps), -1]] + ] + ]] call CBA_fnc_localEvent; }; nil; \ No newline at end of file diff --git a/framework/reinsert/functions/fn_addCBASettings.sqf b/framework/reinsert/functions/fn_addCBASettings.sqf index f00dcdf..b605d6a 100644 --- a/framework/reinsert/functions/fn_addCBASettings.sqf +++ b/framework/reinsert/functions/fn_addCBASettings.sqf @@ -34,10 +34,26 @@ } ] call CBA_fnc_addSetting; +[ + QGVAR(setting_maxWait), // variable + "TIME", // type + ["Max Wait Before Global Notify", "How long should at least one person be waiting before prompting a global notification."], // title + [QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)], // category + [60*5, 60*30, 60*20], // [_min, _max, _default] + true, + { + params ["_value"]; + [ + QGVAR(setting_maxWait), + _value + ] call EFUNC(common,logSettingChanged); + } +] call CBA_fnc_addSetting; + [ QGVAR(setting_pilotForcedCheckEnabled), // variable "CHECKBOX", // type - ["Enabled", "Whether or not pilots are forced to view the contents of the reinsertion queue per interval"], // title + ["Force Queue Checks for Pilots", "Whether or not pilots are forced to view the contents of the reinsertion queue per interval"], // title [QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)], // category false, // default value true, // global setting @@ -65,19 +81,3 @@ ] call EFUNC(common,logSettingChanged); } ] call CBA_fnc_addSetting; - -[ - QGVAR(setting_maxWait), // variable - "TIME", // type - ["Max Wait Threshold", "How long should at least one person be waiting before prompting a global notification."], // title - [QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)], // category - [60*5, 60*30, 60*20], // [_min, _max, _default] - true, - { - params ["_value"]; - [ - QGVAR(setting_maxWait), - _value - ] call EFUNC(common,logSettingChanged); - } -] call CBA_fnc_addSetting; diff --git a/framework/reinsert/server/fn_globalShowQueue.sqf b/framework/reinsert/server/fn_globalShowQueue.sqf index 1300266..def6061 100644 --- a/framework/reinsert/server/fn_globalShowQueue.sqf +++ b/framework/reinsert/server/fn_globalShowQueue.sqf @@ -43,7 +43,7 @@ if (count _timeoutPlayers > 0) then { _playerLines pushBack ([format [ "%1: %2 [%3]", groupID (group (_player)), - name (_player), + name _player, [diag_tickTime - (_timeFiled), "MM:SS"] call BIS_fnc_secondsToString ], 0.8, [0.8, 0.8, 0.8, 1]]); diff --git a/framework/reinsert/server/fn_removeFromQueue.sqf b/framework/reinsert/server/fn_removeFromQueue.sqf index dc73e27..4a76c82 100644 --- a/framework/reinsert/server/fn_removeFromQueue.sqf +++ b/framework/reinsert/server/fn_removeFromQueue.sqf @@ -4,21 +4,23 @@ params [["_player", objNull, [objNull]]]; if (!isServer) exitWith { [ - "respawn_reinsertion", + LEVEL_ERROR, + QUOTE(COMPONENT), "ATTEMPTED RUN ON CLIENT", [ ["player", _player] ] - ] call milsim_util_fnc_log; + ] call EFUNC(common,log); }; if (isNull _player) exitWith { [ - "respawn_reinsertion", + LEVEL_ERROR, + QUOTE(COMPONENT), "NULL PARAMETERS", [ ["player", _player] ] - ] call milsim_util_fnc_log; + ] call EFUNC(common,log); }; // get entries for this player from queue @@ -43,17 +45,16 @@ publicVariable QGVAR(reinsertionQueue); // get the closest base to the player private _nearestBase = [_player] call EFUNC(common,getNearestBase); // log to rpt -private _logParams = [ - ["filedAtBase", [_base] call EFUNC(common,getNameOfBase)], - ["filedAtBaseDistance", _player distance _base], - ["closestBase", [_nearestBase] call EFUNC(common,getNameOfBase)], - ["closestBaseDistance", _player distance _nearestBase], - ["maxDistanceSetting", _maxRangeToReady], - ["inQueueDuration", diag_tickTime - _timeFiled] -]; -_logParams = [_player, _logParams] call EFUNC(common,addPlayerInfoToArray); [ - "respawn_reinsertion", + LEVEL_INFO, + QUOTE(COMPONENT), "PLAYER RESCINDED REQUEST", - _logParams -] call milsim_util_fnc_log; \ No newline at end of file + [_player, [ + ["filedAtBase", [_base] call EFUNC(common,getNameOfBase)], + ["filedAtBaseDistance", _player distance _base], + ["closestBase", [_nearestBase] call EFUNC(common,getNameOfBase)], + ["closestBaseDistance", _player distance _nearestBase], + ["maxDistanceSetting", _maxRangeToReady], + ["inQueueDuration", diag_tickTime - _timeFiled] + ]] call EFUNC(common,addPlayerInfoToArray) +] call EFUNC(common,log); \ No newline at end of file diff --git a/framework/reinsert/server/fn_returnReinsertQueueNotification.sqf b/framework/reinsert/server/fn_returnReinsertQueueNotification.sqf index 4dacf3c..14c04df 100644 --- a/framework/reinsert/server/fn_returnReinsertQueueNotification.sqf +++ b/framework/reinsert/server/fn_returnReinsertQueueNotification.sqf @@ -7,6 +7,8 @@ Author: IndigoFox */ +#include "..\script_component.hpp" + if (not isRemoteExecuted) exitWith { diag_log text format ["[milsim] (respawn_reinsertion) SHOW QUEUE NOT REMOTE EXECUTED"]; }; @@ -25,12 +27,12 @@ if (isNull _userObject) exitWith { }; // log to rpt -private _logParams = [_userObject, []] call EFUNC(common,addPlayerInfoToArray); [ - "respawn_reinsertion", + LEVEL_INFO, + QUOTE(COMPONENT), "SHOW QUEUE REQUESTED", - _logParams -] call milsim_util_fnc_log; + [_userObject] call EFUNC(common,addPlayerInfoToArray) +] call EFUNC(common,log); private _queue = missionNamespace getVariable [QGVAR(reinsertionQueue), []]; // get base objects from queue diff --git a/framework/reinsert/server/fn_validateQueue.sqf b/framework/reinsert/server/fn_validateQueue.sqf index 2ea508b..9d3be7f 100644 --- a/framework/reinsert/server/fn_validateQueue.sqf +++ b/framework/reinsert/server/fn_validateQueue.sqf @@ -15,8 +15,6 @@ private _maxRangeToReady = missionNamespace getVariable [QGVAR(setting_maxRangeT if (not _isCloseEnoughToAnyBase || not (alive _player)) then { // don't include player in updated queue // log to rpt - private _logParams = ; - _logParams = ; [ LEVEL_INFO, QUOTE(COMPONENT), @@ -38,20 +36,19 @@ private _maxRangeToReady = missionNamespace getVariable [QGVAR(setting_maxRangeT _stillValid pushBackUnique [_player, _nearestBase, _timeFiled]; // if player's base has changed, log to rpt if (_base != _nearestBase) then { - private _logParams = [ - ["filedAtBase", [_base] call EFUNC(common,getNameOfBase)], - ["filedAtBaseDistance", _player distance _base], - ["closestBase", [_nearestBase] call EFUNC(common,getNameOfBase)], - ["closestBaseDistance", _player distance _nearestBase], - ["maxDistanceSetting", _maxRangeToReady], - ["inQueueDuration", diag_tickTime - _timeFiled] - ]; - _logParams = [_player, _logParams] call EFUNC(common,addPlayerInfoToArray); [ - "respawn_reinsertion", + LEVEL_INFO, + QUOTE(COMPONENT), "PLAYER BASE WAS UPDATED", - _logParams - ] call milsim_util_fnc_log; + [_player, [ + ["filedAtBase", [_base] call EFUNC(common,getNameOfBase)], + ["filedAtBaseDistance", _player distance _base], + ["closestBase", [_nearestBase] call EFUNC(common,getNameOfBase)], + ["closestBaseDistance", _player distance _nearestBase], + ["maxDistanceSetting", _maxRangeToReady], + ["inQueueDuration", diag_tickTime - _timeFiled] + ]] call EFUNC(common,addPlayerInfoToArray) + ] call EFUNC(common,log); }; } forEach GVAR(reinsertionQueue); diff --git a/framework/resupply/functions/fn_addArsenalObjectSpawnBoxActions.sqf b/framework/resupply/functions/fn_addArsenalObjectSpawnBoxActions.sqf index 1e9d62b..299b1b5 100644 --- a/framework/resupply/functions/fn_addArsenalObjectSpawnBoxActions.sqf +++ b/framework/resupply/functions/fn_addArsenalObjectSpawnBoxActions.sqf @@ -16,11 +16,29 @@ private _supplyCrateTypesCfgs = _supplyCratesCfg call BIS_fnc_returnChildren; { // add scroll wheel action to spawn different supply box types private _arsenalBox = _x; + + // always remove old actions if they exist + private _actionIDs = _arsenalBox getVariable [QGVAR(supplyCrateActionIDs), []]; { + _arsenalBox removeAction _x; + } forEach _actionIDs; + _arsenalBox setVariable [QGVAR(supplyCrateActionIDs), []]; + + + // if setting disabled, skip adding actions + if (not ( + [QGVAR(setting_allowSupplyBoxScrollWheelSpawning)] call CBA_settings_fnc_get + )) then {continue}; + + + { // add an action for each supply crate type private _cfg = _x; private _supplyCrateDisplayName = (_cfg >> "displayName") call BIS_fnc_getCfgData; - _arsenalBox addAction [format ["Spawn %1", _supplyCrateDisplayName], { + + + + private _actionID = _arsenalBox addAction [format ["Spawn %1", _supplyCrateDisplayName], { params ["_target", "_caller", "_actionId", "_arguments"]; _arguments params ["_supplyCrateCfg"]; [ @@ -29,5 +47,6 @@ private _supplyCrateTypesCfgs = _supplyCratesCfg call BIS_fnc_returnChildren; getPos _target ] call FUNC(createBox); }, [_cfg], 0, false, true, "", ""]; + (_arsenalBox getVariable [QGVAR(supplyCrateActionIDs), []]) pushBack _actionID; } forEach _supplyCrateTypesCfgs; } forEach _arsenalBoxes; \ No newline at end of file diff --git a/framework/resupply/functions/fn_addCBASettings.sqf b/framework/resupply/functions/fn_addCBASettings.sqf index 7a664fc..acfe0b9 100644 --- a/framework/resupply/functions/fn_addCBASettings.sqf +++ b/framework/resupply/functions/fn_addCBASettings.sqf @@ -13,6 +13,10 @@ QGVAR(setting_allowSupplyBoxScrollWheelSpawning), _value ] call EFUNC(common,logSettingChanged); + + if (_value && hasInterface && time > 0) then { + [] call FUNC(addArsenalObjectSpawnBoxActions); + }; }, true // requires mission restart ] call CBA_fnc_addSetting; diff --git a/framework/resupply/functions/fn_init.sqf b/framework/resupply/functions/fn_init.sqf deleted file mode 100644 index ddb55b6..0000000 --- a/framework/resupply/functions/fn_init.sqf +++ /dev/null @@ -1,12 +0,0 @@ -#include "..\script_component.hpp" - -// 5 seconds after the client is loaded, add the resupply action to all arsenal boxes -[ - {time > 5}, - { - if (missionNamespace getVariable [ - QGVAR(setting_allowSupplyBoxScrollWheelSpawning), - false - ]) then {call FUNC(addSpawnBoxActions)} - } -] call CBA_fnc_waitUntilAndExecute; \ No newline at end of file diff --git a/framework/resupply/functions/fn_initClient.sqf b/framework/resupply/functions/fn_initClient.sqf new file mode 100644 index 0000000..a78233f --- /dev/null +++ b/framework/resupply/functions/fn_initClient.sqf @@ -0,0 +1,13 @@ +#include "..\script_component.hpp" + +if (!hasInterface) exitWith {}; + +call FUNC(addArsenalObjectSpawnBoxActions); + +[ + LEVEL_DEBUG, + QUOTE(COMPONENT), + "postInit complete", + [] +] call EFUNC(common,log); +localNamespace setVariable [QGVAR(complete), true]; \ No newline at end of file diff --git a/framework/script_mod.hpp b/framework/script_mod.hpp index cb0aa97..21deabe 100644 --- a/framework/script_mod.hpp +++ b/framework/script_mod.hpp @@ -7,8 +7,8 @@ #define VERSION_AR MAJOR,MINOR,PATCHLVL // #define DEBUG_MODE -1 // TRACE -#define DEBUG_MODE 0 // DEBUG -// #define DEBUG_MODE 1 // INFO +// #define DEBUG_MODE 0 // DEBUG +#define DEBUG_MODE 1 // INFO // #define DEBUG_MODE 2 // WARNING // #define DEBUG_MODE 3 // ERROR diff --git a/framework/server/script_component.hpp b/framework/server/script_component.hpp deleted file mode 100644 index d7cf7de..0000000 --- a/framework/server/script_component.hpp +++ /dev/null @@ -1,3 +0,0 @@ -#define COMPONENT server -#define COMPONENT_BEAUTIFIED Server -#include "../script_mod.hpp" \ No newline at end of file diff --git a/framework/triageIcons/functions/fn_addCBASettings.sqf b/framework/triageIcons/functions/fn_addCBASettings.sqf new file mode 100644 index 0000000..c683fae --- /dev/null +++ b/framework/triageIcons/functions/fn_addCBASettings.sqf @@ -0,0 +1,138 @@ +#include "..\script_component.hpp" + +//--------------------- +// Medical Overlay +//--------------------- + +[ + QGVAR(setting_enabled), // variable + "CHECKBOX", // type + ["Enable 3D Triage Card State", "Draws a colored dot over units within Xm indicating current ACE Triage State"], // title + [QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)], // category + true, // default value + false, // isGlobal + { + params ["_value"]; + [ + QGVAR(setting_enabled), + _value + ] call EFUNC(common,logSettingChanged); + + call FUNC(addGetEntitiesPFH); + call FUNC(addDrawIconsPFH); + } +] call CBA_fnc_addSetting; + +[ + QGVAR(setting_drawRange), // variable + "LIST", // type + ["Range To Draw Icons", "Determines range at which dots are visible"], // title + [QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)], // category + [[2, 4, 6, 8, 10], ["2", "4", "6", "8", "10"], 4], // option values, option labels, default index + false, // isGlobal + { + params ["_value"]; + [ + QGVAR(setting_drawRange), + _value + ] call EFUNC(common,logSettingChanged); + } +] call CBA_fnc_addSetting; + +[ + QGVAR(setting_colorMinimal), // variable + "COLOR", // type + ["Minimal State Color", "Color of the dot for MINIMAL state"], // title + [QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)], // category + [0, 0.5, 0], // default value + false, // isGlobal + { + params ["_value"]; + [ + QGVAR(setting_colorMinimal), + str _value + ] call EFUNC(common,logSettingChanged); + + call FUNC(updateColors); + } +] call CBA_fnc_addSetting; + +[ + QGVAR(setting_colorDelayed), // variable + "COLOR", // type + ["Delayed State Color", "Color of the dot for DELAYED state"], // title + [QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)], // category + [1, 0.84, 0], // default value + false, // isGlobal + { + params ["_value"]; + [ + QGVAR(setting_colorDelayed), + str _value + ] call EFUNC(common,logSettingChanged); + + call FUNC(updateColors); + } +] call CBA_fnc_addSetting; + +[ + QGVAR(setting_colorImmediate), // variable + "COLOR", // type + ["Immediate State Color", "Color of the dot for IMMEDIATE state"], // title + [QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)], // category + [1, 0, 0], // default value + false, // isGlobal + { + params ["_value"]; + [ + QGVAR(setting_colorImmediate), + str _value + ] call EFUNC(common,logSettingChanged); + + call FUNC(updateColors); + } +] call CBA_fnc_addSetting; + +[ + QGVAR(setting_colorDeceased), // variable + "COLOR", // type + ["Deceased State Color", "Color of the dot for DECEASED state"], // title + [QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)], // category + [0.15, 0.15, 0.15], // default value + false, // isGlobal + { + params ["_value"]; + [ + QGVAR(setting_colorDeceased), + str _value + ] call EFUNC(common,logSettingChanged); + + call FUNC(updateColors); + } +] call CBA_fnc_addSetting; + +[ + QGVAR(setting_colorNone), // variable + "COLOR", // type + ["None State Color", "Color of the dot for NONE state, when a card is not set"], // title + [QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)], // category + [0.5, 0.5, 0.5], // default value + false, // isGlobal + { + params ["_value"]; + [ + QGVAR(setting_colorNone), + str _value + ] call EFUNC(common,logSettingChanged); + + call FUNC(updateColors); + } +] call CBA_fnc_addSetting; + + +[ + LEVEL_INFO, + QUOTE(COMPONENT), + "CREATED SETTINGS", + [] +] call EFUNC(common,log); \ No newline at end of file diff --git a/framework/triageIcons/functions/fn_addDrawIconsPFH.sqf b/framework/triageIcons/functions/fn_addDrawIconsPFH.sqf new file mode 100644 index 0000000..6478264 --- /dev/null +++ b/framework/triageIcons/functions/fn_addDrawIconsPFH.sqf @@ -0,0 +1,62 @@ +/* + +milsim_fnc_addMedicalOverlayPFH + +Author: IndigoFox + +Description: + Affects players with medical permissions. Will see a 3D colored dot over nearby (5-10m) + unconscious players who are not in a vehicle + which indicates their current ACE Triage Card status. + Designed to increase efficiency of CCPs. + +*/ + +#include "..\script_component.hpp" + + +// Per-frame handler to draw icons +// cleanup +if (!isNil QGVAR(drawIconsPfh)) then { + [GVAR(drawIconsPfh)] call CBA_fnc_removePerFrameHandler; +}; +// add pfh +GVAR(drawIconsPfh) = [{ + // if disabled, skip processing + if (!GVAR(setting_enabled)) exitWith {false}; + // if no targets, skip processing + if (count GVAR(drawTargets) == 0) exitWith {false}; + // if the player doesn't have medical perms, skip processing + if !([player] call ace_medical_treatment_fnc_isMedic) exitWith {false}; + { + private _unit = _x; + // distance within X meters + if (player distance _unit > GVAR(setting_drawRange)) then {continue}; + // check unit not null, not conscious, and not in a vehicle + if ( + !(_unit getVariable ["ACE_isUnconscious", false]) || + !isNull (objectParent _unit) + ) then {continue}; + + // color based on triage level + private _triageLevel = _unit getVariable ["ace_medical_triageLevel", 4]; + if (_triageLevel == -1) then {continue}; + private _color = GVAR(colors) select (_triageLevel - 1); + _color set [3, 0.9]; // set alpha + // draw position, slightly above the prone unit + private _drawPos = (visiblePosition _unit) vectorAdd [0, 0, 0.5]; + // draw icon + drawIcon3D [ + "\A3\ui_f\data\map\markers\military\dot_CA.paa", // icon texture + _color, // color + _drawPos, // position AGL + 1, // width + 1, // height + 0, // angle + "", // text + true // outline + // further params optional, omitted + ]; + } forEach GVAR(drawTargets); +}, 0, []] call CBA_fnc_addPerFrameHandler; + diff --git a/framework/triageIcons/functions/fn_addGetEntitiesPFH.sqf b/framework/triageIcons/functions/fn_addGetEntitiesPFH.sqf new file mode 100644 index 0000000..781227e --- /dev/null +++ b/framework/triageIcons/functions/fn_addGetEntitiesPFH.sqf @@ -0,0 +1,18 @@ +#include "..\script_component.hpp" + +// subroutine to gather nearest 50 units every 5 seconds and store in GVAR(drawTargets) +// cleanup +if (!isNil QGVAR(getEntitiesPFH)) then { + [GVAR(getEntitiesPFH)] call CBA_fnc_removePerFrameHandler; +}; +// add pfh +GVAR(getEntitiesPFH) = [{ + GVAR(drawTargets) = ( + (allUnits + allDeadMen) select { + _x isKindOf "CAManBase" && + player distance _x < 50 && + !isNull _x && + player isNotEqualTo _x + } + ); +}, 10] call CBA_fnc_addPerFrameHandler; diff --git a/framework/triageIcons/functions/fn_initClient.sqf b/framework/triageIcons/functions/fn_initClient.sqf new file mode 100644 index 0000000..79b48ec --- /dev/null +++ b/framework/triageIcons/functions/fn_initClient.sqf @@ -0,0 +1,12 @@ +#include "..\script_component.hpp" + +// List of units to draw icons for +GVAR(drawTargets) = []; + +[ + LEVEL_DEBUG, + QUOTE(COMPONENT), + "postInit complete", + [] +] call EFUNC(common,log); +localNamespace setVariable [QGVAR(complete), true]; \ No newline at end of file diff --git a/framework/triageIcons/functions/fn_updateColors.sqf b/framework/triageIcons/functions/fn_updateColors.sqf new file mode 100644 index 0000000..874c9b3 --- /dev/null +++ b/framework/triageIcons/functions/fn_updateColors.sqf @@ -0,0 +1,18 @@ +#include "..\script_component.hpp" + +// ACE Triage colors, for consistency across UIs and functions +// GVAR(colors) = [ +// (([QGVAR(setting_colorMinimal)] call CBA_settings_fnc_get) + 0.9), // TRIAGE_COLOR_MINIMAL +// (([QGVAR(setting_colorDelayed)] call CBA_settings_fnc_get) + 0.9), // TRIAGE_COLOR_DELAYED +// (([QGVAR(setting_colorImmediate)] call CBA_settings_fnc_get) + 0.9), // TRIAGE_COLOR_IMMEDIATE +// (([QGVAR(setting_colorDeceased)] call CBA_settings_fnc_get) + 0.9), // TRIAGE_COLOR_DECEASED +// (([QGVAR(setting_colorNone)] call CBA_settings_fnc_get) + 0) // TRIAGE_COLOR_NONE +// ]; + +GVAR(colors) = [ + ([QGVAR(setting_colorMinimal)] call CBA_settings_fnc_get), // TRIAGE_COLOR_MINIMAL + ([QGVAR(setting_colorDelayed)] call CBA_settings_fnc_get), // TRIAGE_COLOR_DELAYED + ([QGVAR(setting_colorImmediate)] call CBA_settings_fnc_get), // TRIAGE_COLOR_IMMEDIATE + ([QGVAR(setting_colorDeceased)] call CBA_settings_fnc_get), // TRIAGE_COLOR_DECEASED + ([QGVAR(setting_colorNone)] call CBA_settings_fnc_get) // TRIAGE_COLOR_NONE +]; \ No newline at end of file diff --git a/framework/triageIcons/script_component.hpp b/framework/triageIcons/script_component.hpp new file mode 100644 index 0000000..17b82f3 --- /dev/null +++ b/framework/triageIcons/script_component.hpp @@ -0,0 +1,3 @@ +#define COMPONENT triageIcons +#define COMPONENT_BEAUTIFIED Triage Icons +#include "../script_mod.hpp" \ No newline at end of file diff --git a/framework/vehicleFlags/functions/fn_init.sqf b/framework/vehicleFlags/functions/fn_initClient.sqf similarity index 100% rename from framework/vehicleFlags/functions/fn_init.sqf rename to framework/vehicleFlags/functions/fn_initClient.sqf -- 2.37.3.windows.1 From 8a27abe6c5ef4438c89a2c0fe3aa10d1a26538af Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Tue, 6 Feb 2024 18:14:23 -0800 Subject: [PATCH 15/16] add verbosity to 3d triageIcons tooltip under Enable, for clarity --- framework/triageIcons/functions/fn_addCBASettings.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/triageIcons/functions/fn_addCBASettings.sqf b/framework/triageIcons/functions/fn_addCBASettings.sqf index c683fae..775ff9b 100644 --- a/framework/triageIcons/functions/fn_addCBASettings.sqf +++ b/framework/triageIcons/functions/fn_addCBASettings.sqf @@ -7,7 +7,7 @@ [ QGVAR(setting_enabled), // variable "CHECKBOX", // type - ["Enable 3D Triage Card State", "Draws a colored dot over units within Xm indicating current ACE Triage State"], // title + ["Enable 3D Triage Card State", "For players with medic perms, a colored dot will be shown over unconscious units within Xm indicating current ACE Triage State"], // title [QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)], // category true, // default value false, // isGlobal -- 2.37.3.windows.1 From c44247061af6c5df4554fb7c666355e81489ab7f Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Tue, 6 Feb 2024 20:56:42 -0800 Subject: [PATCH 16/16] bug fixes from dedicated testing --- README.md | 25 ++++++++++++++----- defines/BattalionInfo.hpp | 2 +- .../client/functions/fn_addZenModules.sqf | 18 +++++++++---- .../functions/fn_checkPlayerInventory.sqf | 2 +- .../functions/fn_calculateServerStats.sqf | 4 +-- .../fn_addArsenalObjectSpawnBoxActions.sqf | 10 ++++++++ framework/script_macros.hpp | 1 + .../vehicleFlags/functions/fn_initClient.sqf | 10 ++++++-- 8 files changed, 55 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 655431a..d48d6bd 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,27 @@ # Installation Instructions -Once your mission has been created and saved in the Arma 3 Eden Editor, download the latest mission template zip and copy its contents to the folder where your mission file lives. +The only file which should be pre-existing in your mission folder is `mission.sqm`, once freshly saved from Arma 3's EDEN Editor. -The only file which should be pre-existing in your mission folder is `mission.sqm` +Download the latest mission template zip from the [latest release](https://17th-gs.iceberg-gaming.com:5443/hizumi/MissionTemplate/releases/latest) and copy its contents to the folder where your mission file lives. Once copied, the final structure should appear similar to the following: ```markdown -├── functions/ +├── aaFrameworkUtils/ +├── defines/ +├── framework/ ├── images/ ├── scripts/ ├── sounds/ ├── textures/ +├── CHANGELOG.md ├── description.ext +├── mission_settings.hpp ├── mission.jpg ├── mission.sqm -├── mission_settings.hpp ``` +If you're building a mission for use in an op, please delete "aaFrameworkUtils" and "framework\x". These are for the purposes of development and add size bloat to the mission download when players connect to your mission. + After the requisite configuration file edits have been made, your mission is ready to be packed into a pbo for deployment. # Files @@ -46,7 +51,7 @@ This directory is for organizational purposes for any images you wish to use in ## scripts/ -This directory is for organizational purposes for any custom scripts you wish to use in your mission. +This directory is for organizational purposes for any custom scripts you wish to use in your mission. > **Note**: Scripts may need to be edited to account for their new location ## sounds/ @@ -56,4 +61,12 @@ This directory is for organizational purposes for any custom scripts you wish to ## textures/ -This directory is for organizational purposes for textures files used by mission scripts \ No newline at end of file +This directory is for organizational purposes for textures files used by mission scripts. + +## DEV NOTES + +All modules are broken apart as such in /framework. Client and server inits are managed in /framework/init. + +Pay attention to framework/script_mod.hpp prior to deployment of releases, as the debug settings within will determine what is logged during prod missions. + +CfgFunctions is sensitive to the folder/script_component.hpp of each module. \ No newline at end of file diff --git a/defines/BattalionInfo.hpp b/defines/BattalionInfo.hpp index 58920bc..bcb4f8b 100644 --- a/defines/BattalionInfo.hpp +++ b/defines/BattalionInfo.hpp @@ -8,7 +8,7 @@ #define RRC_CALLSIGN TIGER #define MEDIC_CALLSIGN LIFELINE #define ALPHA_CALLSIGN BLACKJACK -#define ECHO_CALLSIGN ZOOMER +#define ECHO_CALLSIGN FIREBRAND #define WPN_CALLSIGN BLACKFOOT // Define the frequencies for the Battalion diff --git a/framework/client/functions/fn_addZenModules.sqf b/framework/client/functions/fn_addZenModules.sqf index 211aa43..0aeb533 100644 --- a/framework/client/functions/fn_addZenModules.sqf +++ b/framework/client/functions/fn_addZenModules.sqf @@ -1,12 +1,14 @@ +#include "..\script_component.hpp" + if ( !hasInterface ) exitWith {}; [ - "17th Battalion", + QUOTE(MODULE_CATEGORY_NAME), "Create Resupply Box", { params [["_pos", [0,0,0], [[]], 3], ["_target", objNull, [objNull]]]; // get parent definition - private _supplyCratesCfg = call milsim_resupply_fnc_getSupplyCratesCfg; + private _supplyCratesCfg = call EFUNC(resupply,getSupplyCratesCfg); // get the subclass names private _boxTypesAvailable = _supplyCratesCfg call BIS_fnc_getCfgSubClasses; @@ -36,11 +38,17 @@ if ( !hasInterface ) exitWith {}; _args params ["_pos", "_target", "_keysSorted"]; - private _box = [_target, _typeOptionSelected, _pos] call milsim_resupply_fnc_createBox; + private _box = [_target, _typeOptionSelected, _pos] call EFUNC(resupply,createBox); if (isNull _box) exitWith { ["Resupply Box", "WARNING: Failed to locate or create box!"] call BIS_fnc_curatorHint; }; - ["Resupply Box", format["Created box from class %1", _typeOptionSelected]] call BIS_fnc_curatorHint; + [ + "Resupply Box", + format[ + "Created %1", + getText((call EFUNC(resupply,getSupplyCratesCfg)) >> _typeOptionSelected >> "displayName") + ] + ] call BIS_fnc_curatorHint; }, {}, [_pos, _target] @@ -50,7 +58,7 @@ if ( !hasInterface ) exitWith {}; [ - "17th Battalion", + QUOTE(MODULE_CATEGORY_NAME), "Grounds Cleanup", { params [["_pos", [0,0,0], [[]], 3], ["_target", objNull, [objNull]]]; diff --git a/framework/common/functions/fn_checkPlayerInventory.sqf b/framework/common/functions/fn_checkPlayerInventory.sqf index 14874ae..ab30d33 100644 --- a/framework/common/functions/fn_checkPlayerInventory.sqf +++ b/framework/common/functions/fn_checkPlayerInventory.sqf @@ -56,7 +56,7 @@ _playerItems pushBack (uniform _player); [ - LEVEL_INFO, + LEVEL_DEBUG, QUOTE(COMPONENT), "CHECKING PLAYER INVENTORY", [_player] call EFUNC(common,addPlayerInfoToArray) diff --git a/framework/performance/functions/fn_calculateServerStats.sqf b/framework/performance/functions/fn_calculateServerStats.sqf index b0ec77d..f4a0a46 100644 --- a/framework/performance/functions/fn_calculateServerStats.sqf +++ b/framework/performance/functions/fn_calculateServerStats.sqf @@ -45,8 +45,8 @@ [QGVARMAIN(serverEfficiency), [ [ - ["float", QGVAR(server_raw_cps), missionNamespace getVariable [QGVAR(server_raw_cps), -1]], - ["float", QGVAR(server_cps), missionNamespace getVariable [QGVAR(server_cps), -1]] + ["float", QGVARMAIN(raw_cps), missionNamespace getVariable [QGVAR(server_raw_cps), -1]], + ["float", QGVARMAIN(cps), missionNamespace getVariable [QGVAR(server_cps), -1]] ] ]] call CBA_fnc_localEvent; }; diff --git a/framework/resupply/functions/fn_addArsenalObjectSpawnBoxActions.sqf b/framework/resupply/functions/fn_addArsenalObjectSpawnBoxActions.sqf index 299b1b5..74977f9 100644 --- a/framework/resupply/functions/fn_addArsenalObjectSpawnBoxActions.sqf +++ b/framework/resupply/functions/fn_addArsenalObjectSpawnBoxActions.sqf @@ -46,6 +46,16 @@ private _supplyCrateTypesCfgs = _supplyCratesCfg call BIS_fnc_returnChildren; configName _supplyCrateCfg, getPos _target ] call FUNC(createBox); + // log action use in server RPT + [ + LEVEL_INFO, + QUOTE(COMPONENT), + "Supply crate spawned", + [player, [ + ["supplyCrateType", _supplyCrateDisplayName], + ["position", getPos _target] + ]] call EFUNC(common,addPlayerInfoToArray) + ] remoteExec [QEFUNC(common,log), 2]; }, [_cfg], 0, false, true, "", ""]; (_arsenalBox getVariable [QGVAR(supplyCrateActionIDs), []]) pushBack _actionID; } forEach _supplyCrateTypesCfgs; diff --git a/framework/script_macros.hpp b/framework/script_macros.hpp index 430b810..09f2599 100644 --- a/framework/script_macros.hpp +++ b/framework/script_macros.hpp @@ -1,5 +1,6 @@ // all text before cba include #define SETTINGS_GROUP_NAME 17th Battalion +#define MODULE_CATEGORY_NAME 17th Battalion #define LEVEL_TRACE -1 #define LEVEL_DEBUG 0 diff --git a/framework/vehicleFlags/functions/fn_initClient.sqf b/framework/vehicleFlags/functions/fn_initClient.sqf index 061b456..7ebe0fd 100644 --- a/framework/vehicleFlags/functions/fn_initClient.sqf +++ b/framework/vehicleFlags/functions/fn_initClient.sqf @@ -22,6 +22,8 @@ private _flagCategoryCfgs = (_vehicleFlagsCfg >> "FlagCategories") call BIS_fnc_ //////////////////////////////////////////////////////////////////////// [_parentClass, "InitPost", { + + //////////////////////////////////////////////////////////////////////// // create the root action //////////////////////////////////////////////////////////////////////// @@ -46,13 +48,17 @@ private _flagCategoryCfgs = (_vehicleFlagsCfg >> "FlagCategories") call BIS_fnc_ // create the flag category actions (with nested flag actions) //////////////////////////////////////////////////////////////////////// params ["_target", "_player", "_params"]; - _params params ["_rootActionID", "_flagCategoryCfgs"]; + _params params ["_rootActionID"]; + + private _vehicleFlagsCfg = call FUNC(getVehicleFlagsCfg); + if (isNull _vehicleFlagsCfg) exitWith {[]}; + private _flagCategoryCfgs = (_vehicleFlagsCfg >> "FlagCategories") call BIS_fnc_returnChildren; // return category child actions with individual flag actions nested as children [_rootActionID, _flagCategoryCfgs] call FUNC(getActionsFlagCategories); }, // child code - [_rootActionID, _flagCategoryCfgs], // params + [_rootActionID], // params nil, // position 4, // distance [false, false, false, false, false], // other params -- 2.37.3.windows.1