locally tested, adds more features. ready for dedi

This commit is contained in:
2024-02-02 14:34:04 -08:00
parent 3f5c6c5a59
commit b67888f4f1
24 changed files with 416 additions and 163 deletions

View File

@@ -16,8 +16,6 @@ class milsim
class fbcb2 { class fbcb2 {
class initFBCB2 { postInit = 1; }; class initFBCB2 { postInit = 1; };
class processFBCB2FixedWingAssets {};
class processFBCB2RotaryAssets {};
class processFBCB2RadioFrequencies {}; class processFBCB2RadioFrequencies {};
class processFBCB2SmokeColors {}; class processFBCB2SmokeColors {};
class processFBCB2Environment {}; class processFBCB2Environment {};
@@ -85,6 +83,8 @@ class milsim
class padString {}; class padString {};
class recurseSubclasses {}; class recurseSubclasses {};
class getBattalionCfg {}; class getBattalionCfg {};
class getNameOfBase {};
class getNearestBase {};
}; };
}; };
@@ -92,12 +92,11 @@ class milsim_fbcb2_assets {
class functions { class functions {
file = "functions\fbcb2\assets"; file = "functions\fbcb2\assets";
class updateAssetDiary {}; class updateAssetDiary {};
class removeAssetDiaryRecords {};
class getMagsForWeapon {}; class getMagsForWeapon {};
class getWeaponry {}; class getWeaponry {};
class getInventory {}; class getInventory {};
class getVehicleData {}; class getVehicleData {};
class showMarkersOnMap {};
class removeMarkersOnMap {};
}; };
class assetsByBase { class assetsByBase {
file = "functions\fbcb2\assets\byBase"; file = "functions\fbcb2\assets\byBase";
@@ -105,14 +104,14 @@ class milsim_fbcb2_assets {
class getStartingAssetsByBase {}; class getStartingAssetsByBase {};
class updateAssetsByBase {}; class updateAssetsByBase {};
}; };
class markers {
file = "functions\fbcb2\assets\markers";
class showMarkersOnMap {};
class removeMarkersOnMap {};
}
}; };
class milsim_reinsert { class milsim_reinsert {
class functions {
file = "functions\reinsert";
class getBaseName {};
class getNearestBase {};
};
class server { class server {
file = "functions\reinsert\server"; file = "functions\reinsert\server";
class initServer { postInit = 1; }; class initServer { postInit = 1; };

View File

@@ -1,15 +1,106 @@
params [["_isInit", false, [false]]]; params [["_isInit", false, [false]]];
{ // find approved assets at each base
private _base = _x; // Get all approved assets on map, find the closest base
private _baseAssets = _base getVariable ["milsim_fbcb2_assets_assetsAtThisBase", []]; // Then determine if it's within range
{ // If it is, add it to the base's assets list
private _className = configName _x; // This is to ensure bases with overlapping detection range don't have duplicate assets
_a = _base nearEntities [_className, 750]; private _allVehicles = vehicles;
_baseAssets append _a; private _allSaved = [];
} forEach ((missionConfigFile >> "ApprovedAssets") call BIS_fnc_returnChildren);
_base setVariable ["milsim_fbcb2_assets_assetsAtThisBase", _baseAssets, true]; private _assetsAtThisBaseVar = "milsim_fbcb2_assets_assetsAtThisBase";
if (_isInit) then { private _assetsStartedAtThisBaseVar = "milsim_fbcb2_assets_assetsStartedAtThisBase";
_base setVariable ["milsim_fbcb2_assets_assetsStartedAtThisBase", _baseAssets, true]; {
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;

View 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
];

View File

@@ -1,13 +0,0 @@
private _assetMarkerStore = localNamespace getVariable [
"milsim_fbcb2_assets_markerStore",
[]
];
{
deleteMarkerLocal _x;
} forEach _assetMarkerStore;
localNamespace setVariable [
"milsim_fbcb2_assets_markerStore",
[]
];

View File

@@ -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];

View File

@@ -1,7 +1,19 @@
if (!hasInterface) exitWith {};
// create diary records // 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; private _vehiclesByBase = call milsim_fbcb2_assets_fnc_getAssetsByBase;
if (count _vehiclesByBase isEqualTo 0) exitWith {false}; if (count _vehiclesByBase isEqualTo 0) exitWith {false};
// put vehicles from each base into a single array
private _vehicles = []; private _vehicles = [];
{ {
_vehicles append (_x#1); _vehicles append (_x#1);
@@ -24,6 +36,12 @@ private _distinctVehiclesClassNames = [];
// Take the first vehicle as a representative // Take the first vehicle as a representative
private _representativeVehicle = _vehiclesOfThisKind#0; private _representativeVehicle = _vehiclesOfThisKind#0;
private _vehicleCfg = configOf _representativeVehicle; private _vehicleCfg = configOf _representativeVehicle;
private _vehicleCallsign = toUpper (
_representativeVehicle getVariable [
"milsim_fbcb2_assets_callsign",
"NONE ASSIGNED"
]
);
// Process the vehicle for extended info // Process the vehicle for extended info
// Exclusion list for display names // Exclusion list for display names
@@ -53,6 +71,10 @@ private _distinctVehiclesClassNames = [];
_recordText pushBack _title; _recordText pushBack _title;
_recordText pushBack _image; _recordText pushBack _image;
_recordText pushBack "<br/>"; _recordText pushBack "<br/>";
_recordText pushBack format[
"CALLSIGN: %1",
_vehicleCallsign
];
_recordText pushBack format[ _recordText pushBack format[
"COUNT ACTIVE: %1", "COUNT ACTIVE: %1",
count _vehiclesOfThisKind count _vehiclesOfThisKind
@@ -78,32 +100,63 @@ private _distinctVehiclesClassNames = [];
case (_representativeVehicle isKindOf "Air"): { case (_representativeVehicle isKindOf "Air"): {
_markerType = "loc_plane"; _markerType = "loc_plane";
}; };
case (_representativeVehicle isKindOf "Ship"): {
_markerType = "loc_boat";
};
case (_representativeVehicle isKindOf "Car"): {
_markerType = "loc_car";
};
default { default {
_markerType = "loc_truck"; _markerType = "loc_truck";
}; };
}; };
// Link to show markers
_recordText pushBack format[ _recordText pushBack format[
"<execute expression='[""%1"",""%2"",""%3"",%4] call milsim_fbcb2_assets_fnc_showMarkersOnMap'>SHOW MARKERS at vehicle positions</execute> (in %5)", "<execute expression='[""%1"",""%2"",""%3"",%4] call milsim_fbcb2_assets_fnc_showMarkersOnMap'>SHOW MARKERS at vehicle positions</execute> (in %5)",
_className, _className,
_markerType, _markerType,
_randomColor#0, _randomColor#0,
(_vehiclesOfThisKind apply {getPosASL _x}), _vehiclesOfThisKind,
format["<font color='%1'>%2</font>", _randomColor#1, _randomColor#2] format["<font color='%1'>%2</font>", _randomColor#1, _randomColor#2]
]; ];
// Link to hide markers // 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 // 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 // Add info and capacity sections
_recordText pushBack _info; _recordText pushBack _info;
_recordText pushBack _capacity; _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[ format[
"%1x %2", "%1x %2",
count _vehiclesOfThisKind, count _vehiclesOfThisKind,
@@ -116,4 +169,14 @@ private _distinctVehiclesClassNames = [];
// "\A3\ui_f\data\igui\cfg\simpleTasks\types\car_ca.paa" // "\A3\ui_f\data\igui\cfg\simpleTasks\types\car_ca.paa"
} forEach _distinctVehiclesClassNames; } forEach _distinctVehiclesClassNames;
// log to RPT
[
"fbcb2_assets",
"UPDATED ASSET DIARY",
[
["assetCount", count _vehicles],
["distinctAssetCount", count _distinctVehiclesClassNames]
]
] call milsim_fnc_log;
true; true;

View 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,
[]
];

View 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];

View File

@@ -14,13 +14,17 @@ milsim_fbcb2_subjectStatusID = "FBCB2_Status";
milsim_fbcb2_subjectIntelID = "FBCB2_Intel"; milsim_fbcb2_subjectIntelID = "FBCB2_Intel";
milsim_fbcb2_subjectMessagesID = "FBCB2_Messages"; milsim_fbcb2_subjectMessagesID = "FBCB2_Messages";
milsim_fbcb2_subjectFrequenciesID = "FBCB2_Frequencies"; 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_subjectStatusID, "FBCB2 - Status"];
player createDiarySubject[milsim_fbcb2_subjectMessagesID, "FBCB2 - Messages"]; player createDiarySubject[milsim_fbcb2_subjectMessagesID, "FBCB2 - Messages"];
player createDiarySubject[milsim_fbcb2_subjectIntelID, "FBCB2 - Intel"]; player createDiarySubject[milsim_fbcb2_subjectIntelID, "FBCB2 - Intel"];
player createDiarySubject[milsim_fbcb2_subjectFrequenciesID, "FBCB2 - Frequencies"]; 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: // store records in format:
// [subject, [ // [subject, [
@@ -29,8 +33,6 @@ player createDiarySubject[milsim_fbcb2_subjectAssetsID, "FBCB2 - Assets"];
milsim_fbcb2_diaryRecords = createHashMap; milsim_fbcb2_diaryRecords = createHashMap;
// populate diary // populate diary
[] call milsim_fnc_processFBCB2FixedWingAssets;
[] call milsim_fnc_processFBCB2RotaryAssets;
[] call milsim_fnc_processFBCB2RadioFrequencies; [] call milsim_fnc_processFBCB2RadioFrequencies;
[] call milsim_fnc_processFBCB2SmokeColors; [] call milsim_fnc_processFBCB2SmokeColors;
[] call milsim_fnc_processFBCB2Environment; [] call milsim_fnc_processFBCB2Environment;

View File

@@ -1,26 +0,0 @@
private _recordTitle = "MDS - ASSETS - FIXED";
private _assetList = missionNamespace getVariable "milsim_var_fixedAssets";
_text = "<font size='24' color='#ff0000'>=======------ Mission Data Set ------=======</font>";
{
_callSign = _x select 0;
_asset = _x select 1;
_assigned = _x select 2;
_name = getText(configFile >> "CfgVehicles" >> _asset >> "displayName");
_data = "<t size='2'>Callsign: " + _callsign + "</t><br/><t size='1'>Asset: " + _name + "</t><br/><t size='1'>Assigned: " + str _assigned + "</t>";
_text = _text + "<br/><br/>" + _data;
} foreach _assetList;
_text = _text + "<br/><br/><execute expression='[missionNamespace getVariable ""milsim_var_fixedAssets""] call milsim_fnc_hintFBCB2AssetStatus'>Run Report on local node?</execute>";
[
milsim_fbcb2_subjectStatusID,
_recordTitle,
_text
] call milsim_fnc_createOrUpdateDiaryRecord;

View File

@@ -1,26 +0,0 @@
private _recordTitle = "MDS - ASSETS - ROTARY";
_assetList = missionNamespace getVariable "milsim_var_rotaryAssets";
_text = "<font size='24' color='#ff0000'>=======------ Mission Data Set ------=======</font>";
{
_callSign = _x select 0;
_asset = _x select 1;
_assigned = _x select 2;
_name = getText(configFile >> "CfgVehicles" >> _asset >> "displayName");
_data = "<t size='2'>Callsign: " + _callsign + "</t><br/><t size='1'>Asset: " + _name + "</t><br/><t size='1'>Assigned: " + str _assigned + "</t>";
_text = _text + "<br/><br/>" + _data;
} foreach _assetList;
_text = _text + "<br/><br/><execute expression='[missionNamespace getVariable ""milsim_var_rotaryAssets""] call milsim_fnc_hintFBCB2AssetStatus'>Run Report on local node?</execute>";
[
milsim_fbcb2_subjectStatusID,
_recordTitle,
_text
] call milsim_fnc_createOrUpdateDiaryRecord;

View File

@@ -1,3 +1,5 @@
if (!hasInterface) exitWith {};
params [ params [
["_subjectID", milsim_fbcb2_subjectStatusID, [""]], ["_subjectID", milsim_fbcb2_subjectStatusID, [""]],
["_recordTitle", "", [""]], ["_recordTitle", "", [""]],
@@ -10,7 +12,7 @@ private _subjectRecords = milsim_fbcb2_diaryRecords getOrDefault [_subjectID, cr
private _existingRecord = _subjectRecords getOrDefault [_recordTitle, diaryRecordNull, true]; private _existingRecord = _subjectRecords getOrDefault [_recordTitle, diaryRecordNull, true];
if (!isNull _existingRecord) then { if (!isNull _existingRecord) then {
player setDiaryRecordText [[_subjectID, _existingRecord], [_recordTitle, _recordText]]; player setDiaryRecordText [[_subjectID, _existingRecord], [_recordTitle, _recordText, _recordIcon]];
systemChat format ["Updated diary record: %1", _recordTitle]; systemChat format ["Updated diary record: %1", _recordTitle];
} else { } else {
private _new = player createDiaryRecord [ private _new = player createDiaryRecord [

View File

@@ -9,7 +9,7 @@ publicVariable "milsim_baseObjects";
// init asset stores at bases // init asset stores at bases
[true] call milsim_fbcb2_assets_fnc_updateAssetsByBase; [true] call milsim_fbcb2_assets_fnc_updateAssetsByBase;
// run update every 5 minutes // 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 // Initializes the Dynamic Groups framework and groups
["Initialize", [true]] call BIS_fnc_dynamicGroups; ["Initialize", [true]] call BIS_fnc_dynamicGroups;

View File

@@ -13,8 +13,8 @@ private _fileForReinsertAction = [
{ // statement { // statement
params ["_target", "_player", "_params"]; params ["_target", "_player", "_params"];
// find nearest base or location // find nearest base or location
private _base = [_player] call milsim_reinsert_fnc_getNearestBase; private _base = [_player] call milsim_fnc_getNearestBase;
private _baseName = [_base] call milsim_reinsert_fnc_getBaseName; private _baseName = [_base] call milsim_fnc_getNameOfBase;
// send event to server // send event to server
["milsim_reinsert_fileReinsertRequest", [_player, _base]] call CBA_fnc_serverEvent; ["milsim_reinsert_fileReinsertRequest", [_player, _base]] call CBA_fnc_serverEvent;
// notify player their request was filed // notify player their request was filed
@@ -23,7 +23,7 @@ private _fileForReinsertAction = [
{ // condition { // condition
params ["_target", "_player", "_params"]; params ["_target", "_player", "_params"];
// find nearest base or location // 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 _baseDistance = _player distance _base;
private _maxRangeToReady = missionNamespace getVariable ["milsim_reinsert_setting_reinsertion_maxRangeToReady", 400]; private _maxRangeToReady = missionNamespace getVariable ["milsim_reinsert_setting_reinsertion_maxRangeToReady", 400];

View File

@@ -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;

View File

@@ -41,9 +41,9 @@ publicVariable "milsim_reinsert_reinsertionQueue";
// log to rpt // log to rpt
private _logParams = [ private _logParams = [
["filedAtBase", [_base] call milsim_reinsert_fnc_getBaseName], ["filedAtBase", [_base] call milsim_fnc_getNameOfBase],
["filedAtBaseDistance", _player distance _base], ["filedAtBaseDistance", _player distance _base],
["closestBase", [_nearestBase] call milsim_reinsert_fnc_getBaseName], ["closestBase", [_nearestBase] call milsim_fnc_getNameOfBase],
["closestBaseDistance", _player distance _nearestBase], ["closestBaseDistance", _player distance _nearestBase],
["maxDistanceSetting", _maxRangeToReady], ["maxDistanceSetting", _maxRangeToReady],
["inQueueDuration", diag_tickTime - _timeFiled] ["inQueueDuration", diag_tickTime - _timeFiled]

View File

@@ -21,7 +21,7 @@ if (count _timeoutPlayers > 0) then {
private _thisBase = _x; private _thisBase = _x;
// Add line for base name // 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 // Get players under this base
private _thisBasePlayers = _timeoutPlayers select {_x#1 isEqualTo _thisBase}; 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 { // for each player under this base, add a line
_x params ["_player", "_base", "_timeFiled"]; _x params ["_player", "_base", "_timeFiled"];
// get the closest base to the player // 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 // add player to array of players under bases
_playerLines pushBack ([format [ _playerLines pushBack ([format [
@@ -47,9 +47,9 @@ if (count _timeoutPlayers > 0) then {
// log to rpt // log to rpt
private _logParams = [ private _logParams = [
["filedAtBase", [_base] call milsim_reinsert_fnc_getBaseName], ["filedAtBase", [_base] call milsim_fnc_getNameOfBase],
["filedAtBaseDistance", _player distance _base], ["filedAtBaseDistance", _player distance _base],
["closestBase", [_nearestBase] call milsim_reinsert_fnc_getBaseName], ["closestBase", [_nearestBase] call milsim_fnc_getNameOfBase],
["closestBaseDistance", _player distance _nearestBase], ["closestBaseDistance", _player distance _nearestBase],
["maxDistanceSetting", _maxRangeToReady], ["maxDistanceSetting", _maxRangeToReady],
["inQueueDuration", diag_tickTime - _timeFiled] ["inQueueDuration", diag_tickTime - _timeFiled]

View File

@@ -39,12 +39,12 @@ publicVariable "milsim_reinsert_reinsertionQueue";
// get first entry (longest wait) // get first entry (longest wait)
(_unitArrs#0) params ["_player", "_base", "_timeFiled"]; // _unitArr = [unit, base, timeInQueue] (_unitArrs#0) params ["_player", "_base", "_timeFiled"]; // _unitArr = [unit, base, timeInQueue]
// get the closest base to the player // 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 // log to rpt
private _logParams = [ private _logParams = [
["filedAtBase", [_base] call milsim_reinsert_fnc_getBaseName], ["filedAtBase", [_base] call milsim_fnc_getNameOfBase],
["filedAtBaseDistance", _player distance _base], ["filedAtBaseDistance", _player distance _base],
["closestBase", [_nearestBase] call milsim_reinsert_fnc_getBaseName], ["closestBase", [_nearestBase] call milsim_fnc_getNameOfBase],
["closestBaseDistance", _player distance _nearestBase], ["closestBaseDistance", _player distance _nearestBase],
["maxDistanceSetting", _maxRangeToReady], ["maxDistanceSetting", _maxRangeToReady],
["inQueueDuration", diag_tickTime - _timeFiled] ["inQueueDuration", diag_tickTime - _timeFiled]

View File

@@ -48,7 +48,7 @@ if (count _basesWithPeople isEqualTo 0) then {
// forEach _basesWithPeople // forEach _basesWithPeople
{ {
private _thisBase = _x; private _thisBase = _x;
private _baseName = [_thisBase] call milsim_reinsert_fnc_getBaseName; private _baseName = [_thisBase] call milsim_fnc_getNameOfBase;
// generate player lines for this base // generate player lines for this base
private _playerLines = _queue select { private _playerLines = _queue select {

View File

@@ -7,16 +7,16 @@ private _maxRangeToReady = missionNamespace getVariable ["milsim_reinsert_settin
private _distanceToOriginalBase = _player distance _base; private _distanceToOriginalBase = _player distance _base;
// get the closest base to the player // 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; private _isCloseEnoughToAnyBase = (_player distance _nearestBase) < _maxRangeToReady;
if (not _isCloseEnoughToAnyBase || not (alive _player)) then { if (not _isCloseEnoughToAnyBase || not (alive _player)) then {
// don't include player in updated queue // don't include player in updated queue
// log to rpt // log to rpt
private _logParams = [ private _logParams = [
["filedAtBase", [_base] call milsim_reinsert_fnc_getBaseName], ["filedAtBase", [_base] call milsim_fnc_getNameOfBase],
["filedAtBaseDistance", _player distance _base], ["filedAtBaseDistance", _player distance _base],
["closestBase", [_nearestBase] call milsim_reinsert_fnc_getBaseName], ["closestBase", [_nearestBase] call milsim_fnc_getNameOfBase],
["closestBaseDistance", _player distance _nearestBase], ["closestBaseDistance", _player distance _nearestBase],
["maxDistanceSetting", _maxRangeToReady], ["maxDistanceSetting", _maxRangeToReady],
["inQueueDuration", diag_tickTime - _timeFiled] ["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 player's base has changed, log to rpt
if (_base != _nearestBase) then { if (_base != _nearestBase) then {
private _logParams = [ private _logParams = [
["filedAtBase", [_base] call milsim_reinsert_fnc_getBaseName], ["filedAtBase", [_base] call milsim_fnc_getNameOfBase],
["filedAtBaseDistance", _player distance _base], ["filedAtBaseDistance", _player distance _base],
["closestBase", [_nearestBase] call milsim_reinsert_fnc_getBaseName], ["closestBase", [_nearestBase] call milsim_fnc_getNameOfBase],
["closestBaseDistance", _player distance _nearestBase], ["closestBaseDistance", _player distance _nearestBase],
["maxDistanceSetting", _maxRangeToReady], ["maxDistanceSetting", _maxRangeToReady],
["inQueueDuration", diag_tickTime - _timeFiled] ["inQueueDuration", diag_tickTime - _timeFiled]

View File

@@ -242,6 +242,32 @@
} }
] call CBA_fnc_addSetting; ] 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"; diag_log text "[MILSIM] (settings) Custom CBA settings initialized";
nil; nil;

View File

@@ -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;

View File

@@ -1,10 +1,10 @@
params [["_player", objNull, [objNull]]]; params [["_object", objNull, [objNull]]];
if (isNull _player) exitWith {objNull}; if (isNull _object) exitWith {objNull};
private _bases = missionNamespace getVariable ["milsim_baseObjects", []]; private _bases = missionNamespace getVariable ["milsim_baseObjects", []];
if (count _bases == 0) exitWith {objNull}; if (count _bases == 0) exitWith {objNull};
// get nearest base (Module_Respawn_F) // 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}; if (isNull _closestBase) exitWith {objNull};
_closestBase; _closestBase;