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 = [];