From 3f5c6c5a59b281d41e6980183d3faf2f5a420550 Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Fri, 2 Feb 2024 01:06:43 -0800 Subject: [PATCH 1/8] 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 = []; From b67888f4f1c22c2a093a1a0f8a5cf432e8cfee33 Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Fri, 2 Feb 2024 14:34:04 -0800 Subject: [PATCH 2/8] 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 From 8d93bb57439afab591b8cacab84e6e57a6b2c60a Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Fri, 2 Feb 2024 15:13:45 -0800 Subject: [PATCH 3/8] 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; From b8b8f1de224a27b66bb5dcd6c3832a0e134a9f35 Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Sat, 3 Feb 2024 13:53:28 -0800 Subject: [PATCH 4/8] 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]; From affc8ffb1f05e781bea7b92e1b7f43b1f7d54aa6 Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Sat, 3 Feb 2024 15:04:47 -0800 Subject: [PATCH 5/8] 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 From 7ef48ecaa2786424eb74b16fc37f01977677f5b9 Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Sat, 3 Feb 2024 18:40:18 -0800 Subject: [PATCH 6/8] 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 From 09dcde7471c606c5eca58267d55ad2b463dcc9b9 Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Sat, 3 Feb 2024 20:59:51 -0800 Subject: [PATCH 7/8] 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; From d7b8e5186e64b7e1c9d57a38d7c6e1b318d37f04 Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Sat, 3 Feb 2024 22:55:21 -0800 Subject: [PATCH 8/8] 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;