locally tested, adds more features. ready for dedi
This commit is contained in:
@@ -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;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
16
functions/fbcb2/assets/fn_removeAssetDiaryRecords.sqf
Normal file
16
functions/fbcb2/assets/fn_removeAssetDiaryRecords.sqf
Normal file
@@ -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
|
||||
];
|
||||
@@ -1,13 +0,0 @@
|
||||
private _assetMarkerStore = localNamespace getVariable [
|
||||
"milsim_fbcb2_assets_markerStore",
|
||||
[]
|
||||
];
|
||||
|
||||
{
|
||||
deleteMarkerLocal _x;
|
||||
} forEach _assetMarkerStore;
|
||||
|
||||
localNamespace setVariable [
|
||||
"milsim_fbcb2_assets_markerStore",
|
||||
[]
|
||||
];
|
||||
@@ -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];
|
||||
@@ -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 "<br/>";
|
||||
_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[
|
||||
"<execute expression='[""%1"",""%2"",""%3"",%4] call milsim_fbcb2_assets_fnc_showMarkersOnMap'>SHOW MARKERS at vehicle positions</execute> (in %5)",
|
||||
_className,
|
||||
_markerType,
|
||||
_randomColor#0,
|
||||
(_vehiclesOfThisKind apply {getPosASL _x}),
|
||||
_vehiclesOfThisKind,
|
||||
format["<font color='%1'>%2</font>", _randomColor#1, _randomColor#2]
|
||||
];
|
||||
|
||||
// Link to hide markers
|
||||
_recordText pushBack "<execute expression=""call milsim_fbcb2_assets_fnc_removeMarkersOnMap"">REMOVE ALL MARKERS showing asset positions</execute>" + "<br/>";
|
||||
_recordText pushBack "<execute expression=""call milsim_fbcb2_assets_fnc_removeMarkersOnMap"">REMOVE ALL MARKERS showing asset positions</execute>";
|
||||
|
||||
// Link to update asset diary entries
|
||||
_recordText pushBack "<execute expression=""call milsim_fbcb2_assets_fnc_updateAssetDiary"">UPDATE ENTRIES for all assets</execute>" + "<br/>";
|
||||
_recordText pushBack "<execute expression=""call milsim_fbcb2_assets_fnc_updateAssetDiary"">UPDATE ENTRIES for all assets</execute>";
|
||||
|
||||
_recordText pushBack format[
|
||||
"<font size='10' color='#777777'>%1</font>",
|
||||
"Notes:<br/>
|
||||
- Markers are only displayed on your local machine.<br/>
|
||||
- The REMOVE ALL option will remove all assets' markers from the map.<br/>
|
||||
- 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;
|
||||
25
functions/fbcb2/assets/markers/fn_removeMarkersOnMap.sqf
Normal file
25
functions/fbcb2/assets/markers/fn_removeMarkersOnMap.sqf
Normal file
@@ -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,
|
||||
[]
|
||||
];
|
||||
123
functions/fbcb2/assets/markers/fn_showMarkersOnMap.sqf
Normal file
123
functions/fbcb2/assets/markers/fn_showMarkersOnMap.sqf
Normal file
@@ -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];
|
||||
Reference in New Issue
Block a user