wip, fbcb2_assets, init, util

This commit is contained in:
2024-02-04 22:18:06 -08:00
parent 4cfa159ee9
commit f450f4611b
32 changed files with 2066 additions and 100 deletions

View File

@@ -1,4 +1,6 @@
class milsim
#include "script_mod.hpp"
class PREFIX
{
class settings
{
@@ -11,7 +13,7 @@ class milsim
class init
{
file = "framework\init";
file = "framework\init\functions";
class initServer { postInit = 1;}; //needs refactor
class initPlayerLocal { postInit = 1;};
};
@@ -71,9 +73,9 @@ class milsim
};
};
class milsim_util {
class DOUBLES(PREFIX,util) {
class functions {
file = "framework\util";
file = "framework\util\functions";
class logMissionInfo { postInit = 1; };
class addPlayerInfoToArray {};
class log {};
@@ -85,7 +87,7 @@ class milsim_util {
};
};
class milsim_resupply {
class DOUBLES(PREFIX,resupply) {
class functions {
file = "framework\resupply\functions";
class init {postInit=1;};
@@ -96,30 +98,25 @@ class milsim_resupply {
};
};
class milsim_fbcb2_assets {
class DOUBLES(PREFIX,fbcb2_assets) {
class functions {
file = "framework\fbcb2\assets";
file = "framework\fbcb2_assets\functions";
class init {postInit=1;};
class updateAssetDiary {};
class removeAssetDiaryRecords {};
class getMagsForWeapon {};
class getWeaponry {};
class getInventory {};
class getVehicleData {};
};
class assetsByBase {
file = "framework\fbcb2\assets\byBase";
class getAssetsByBase {};
class getStartingAssetsByBase {};
class updateAssetsByBase {};
};
class markers {
file = "framework\fbcb2\assets\markers";
class showMarkersOnMap {};
class removeMarkersOnMap {};
};
};
class milsim_vehicleFlags {
class DOUBLES(PREFIX,vehicleFlags) {
class functions {
file = "framework\vehicleFlags\functions";
class init {postInit=1;};
@@ -129,7 +126,7 @@ class milsim_vehicleFlags {
};
};
class milsim_reinsert {
class DOUBLES(PREFIX,reinsert) {
class server {
file = "framework\reinsert\server";
class initServer { postInit = 1; };

View File

@@ -0,0 +1,27 @@
#include "..\script_component.hpp"
//---------------------
// Asset Diary and Markers Settings
[
QGVAR(setting_detectionRangeFromBase), // variable
"SLIDER", // type
["Detection Range From Base", "The range from a base that assets will be detected"], // title
[QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)], // category
[0, 1000, 750, 0, false], // [_min, _max, _default, _trailingDecimals, _isPercentage]
true, // global setting
{
params ["_value"];
[
"fbcb2_assets",
"SETTING CHANGED",
[
[
"setting",
"milsim_fbcb2_assets_setting_detectionRangeFromBase"
],
["newValue", _value]
]
] call milsim_util_fnc_log;
}
] call CBA_fnc_addSetting;

View File

@@ -0,0 +1,9 @@
#include "..\script_component.hpp"
if (!hasInterface) exitWith {};
// once the server has published that assets have been gathered and distributed to bases (respawn modules),
// we can update the asset diary on our end using that data
[{missionNamespace getVariable [QGVAR(serverAssetsReady), false]}, {
call FUNC(updateAssetDiary);
}] call CBA_fnc_waitUntilAndExecute;

View File

@@ -0,0 +1,23 @@
#include "..\script_component.hpp"
if (!isServer) exitWith {};
// init asset stores at bases
[true] call FUNC(updateAssetsByBase);
missionNamespace setVariable [QGVAR(serverAssetsReady), true, true];
// starting 5 minutes after postInit, update asset stores every 5 minutes
[{
[
{[false] call FUNC(updateAssetsByBase);},
60*5
] call CBA_fnc_addPerFrameHandler;
}, 60*5] call CBA_fnc_waitAndExecute;
// add end mission EH
addMissionEventHandler ["MPEnded", {
// log the "current" asset counts to RPT
[false, true] call FUNC(updateAssetsByBase);
}];

View File

@@ -1,16 +1,17 @@
#include "..\script_component.hpp"
if (!hasInterface) exitWith {};
// create diary records
// remove any existing asset map markers
call milsim_fbcb2_assets_fnc_removeMarkersOnMap;
call FUNC(removeMarkersOnMap);
// remove existing asset records
call milsim_fbcb2_assets_fnc_removeAssetDiaryRecords;
call FUNC(removeAssetDiaryRecords);
// get all vehicles by base
private _vehiclesByBase = call milsim_fbcb2_assets_fnc_getAssetsByBase;
private _vehiclesByBase = call FUNC(getAssetsByBase);
if (count _vehiclesByBase isEqualTo 0) exitWith {false};
// put vehicles from each base into a single array
@@ -38,7 +39,7 @@ private _distinctVehiclesClassNames = [];
private _vehicleCfg = configOf _representativeVehicle;
private _vehicleCallsign = toUpper (
_representativeVehicle getVariable [
"milsim_fbcb2_assets_callsign",
QGVAR(callsign),
"NONE ASSIGNED"
]
);
@@ -51,7 +52,7 @@ private _distinctVehiclesClassNames = [];
) then {continue};
// Get the vehicle data
private _processed = [_representativeVehicle] call milsim_fbcb2_assets_fnc_getVehicleData;
private _processed = [_representativeVehicle] call FUNC(getVehicleData);
if (isNil "_processed") then {continue};
_processed params ["_vehicleCfg", "_displayName", "_diaryTextSections"];
@@ -113,7 +114,7 @@ private _distinctVehiclesClassNames = [];
// Link to show markers
private _showMarkersText = format[
"<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 FUNC(showMarkersOnMap'>SHOW MARKERS at vehicle positions</execute> (in %5)",
_className,
_markerType,
_randomColor#0,
@@ -125,10 +126,10 @@ private _distinctVehiclesClassNames = [];
_recordText pushBack _showMarkersText;
// Link to hide markers
_recordText pushBack "<execute expression=""call milsim_fbcb2_assets_fnc_removeMarkersOnMap"">REMOVE ALL MARKERS showing asset positions</execute>";
_recordText pushBack "<execute expression=""call FUNC(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>";
_recordText pushBack "<execute expression=""call FUNC(updateAssetDiary"">UPDATE ENTRIES for all assets</execute>";
_recordText pushBack format[
"<font size='10' color='#777777'>%1</font>",
@@ -148,13 +149,13 @@ private _distinctVehiclesClassNames = [];
private _subjectID = "";
switch (true) do {
case (_representativeVehicle isKindOf "Helicopter"): {
_subjectID = milsim_fbcb2_subjectAssetsRotaryID;
_subjectID = EGVAR(fbcb2,subjectAssetsRotaryID);
};
case (_representativeVehicle isKindOf "Air"): {
_subjectID = milsim_fbcb2_subjectAssetsFixedWingID;
_subjectID = EGVAR(fbcb2,subjectAssetsFixedWingID);
};
default {
_subjectID = milsim_fbcb2_subjectAssetsGroundID;
_subjectID = EGVAR(fbcb2,subjectAssetsGroundID);
};
};
@@ -174,12 +175,12 @@ private _distinctVehiclesClassNames = [];
// log to RPT
[
"fbcb2_assets",
QUOTE(COMPONENT),
"UPDATED ASSET DIARY",
[
["assetCount", count _vehicles],
["distinctAssetCount", count _distinctVehiclesClassNames]
]
] call milsim_util_fnc_log;
] call EFUNC(util,log);
true;

View File

@@ -1,3 +1,5 @@
#include "..\script_component.hpp"
params [
["_isInit", false, [false]],
["_logCurrentAssets", false, [false]]
@@ -12,8 +14,8 @@ if (!isServer) exitWith {};
private _allVehicles = vehicles;
private _allSaved = [];
private _assetsAtThisBaseVar = "milsim_fbcb2_assets_assetsAtThisBase";
private _assetsStartedAtThisBaseVar = "milsim_fbcb2_assets_assetsStartedAtThisBase";
private _assetsAtThisBaseVar = QGVAR(assetsAtThisBase);
private _assetsStartedAtThisBaseVar = QGVAR(assetsStartedAtThisBase);
{
private _className = configName _x;
@@ -23,7 +25,7 @@ private _assetsStartedAtThisBaseVar = "milsim_fbcb2_assets_assetsStartedAtThisBa
private _asset = _x;
// avoid duplicates
if (_asset in _allSaved) then {continue};
private _closestBase = [_asset] call milsim_util_fnc_getNearestBase;
private _closestBase = [_asset] call EFUNC(util,getNearestBase);
if (isNull _closestBase) then {
// no base found
continue;
@@ -36,7 +38,7 @@ private _assetsStartedAtThisBaseVar = "milsim_fbcb2_assets_assetsStartedAtThisBa
continue;
};
_asset setVariable ["milsim_fbcb2_assets_callsign", _callsign, true];
_asset setVariable [QGVAR(callsign), _callsign, true];
// add to base's assets list
private _baseAssets = _closestBase getVariable [_assetsAtThisBaseVar, []];
@@ -66,7 +68,7 @@ private _assetsStartedAtThisBaseVar = "milsim_fbcb2_assets_assetsStartedAtThisBa
// avoid duplicates
if (_asset in _allSaved) then {continue};
private _closestBase = [_asset] call milsim_util_fnc_getNearestBase;
private _closestBase = [_asset] call EFUNC(util,getNearestBase);
if (isNull _closestBase) then {
// no base found
continue;
@@ -74,7 +76,7 @@ private _assetsStartedAtThisBaseVar = "milsim_fbcb2_assets_assetsStartedAtThisBa
if (
_asset distance _closestBase >
milsim_fbcb2_assets_setting_detectionRangeFromBase
GVAR(setting_detectionRangeFromBase)
) then {
// not within range
continue;
@@ -132,7 +134,7 @@ if !(_isInit || _logCurrentAssets) exitWith {};
private _asset = _x;
[
["callsign", _asset getVariable [
"milsim_fbcb2_assets_callsign",
QGVAR(callsign),
"N/A"
]],
["className", typeOf _asset],

View File

@@ -0,0 +1,3 @@
#define COMPONENT fbcb2_assets
#define COMPONENT_BEAUTIFIED FBCB2 - Assets
#include "../script_mod.hpp"

View File

@@ -1,35 +0,0 @@
if (!isServer) exitWith {};
milsim_baseObjects = allMissionObjects "ModuleRespawnPosition_F";
publicVariable "milsim_baseObjects";
// init asset stores at bases
[true] call milsim_fbcb2_assets_fnc_updateAssetsByBase;
// starting 5 minutes after postInit, update asset stores every 5 minutes
[{
[
{[false] call milsim_fbcb2_assets_fnc_updateAssetsByBase;},
60*5
] call CBA_fnc_addPerFrameHandler;
}, 60*5] call CBA_fnc_waitAndExecute;
// add end mission EH
addMissionEventHandler ["MPEnded", {
// log the "current" asset counts to RPT
[false, true] call milsim_fbcb2_assets_fnc_updateAssetsByBase;
}];
// Initializes the Dynamic Groups framework and groups
["Initialize", [true]] call BIS_fnc_dynamicGroups;
["milsim_logText", {
params [["_strArray", [""], [[]]]];
{
diag_log text _x;
} forEach _strArray;
}] call CBA_fnc_addEventHandler;
missionNamespace setVariable ["milsim_complete", true];
diag_log text "[MILSIM] (initServer) milsim_complete: version 2.3";
publicVariable "milsim_complete";

View File

@@ -0,0 +1,26 @@
#include "..\script_component.hpp"
if (!isServer) exitWith {};
milsim_baseObjects = allMissionObjects "ModuleRespawnPosition_F";
publicVariable "milsim_baseObjects";
// Initializes the Dynamic Groups framework and groups
["Initialize", [true]] call BIS_fnc_dynamicGroups;
["milsim_logText", {
params [["_strArray", [""], [[]]]];
{
diag_log text _x;
} forEach _strArray;
}] call CBA_fnc_addEventHandler;
missionNamespace setVariable [QGVARMAIN(complete), true];
[
QUOTE(COMPONENT),
format["%1: version %2", QGVARMAIN(complete), QUOTE(VERSION_STR)],
[["version", QUOTE(VERSION_STR)]]
] call EFUNC(util,log);
publicVariable "milsim_complete";

View File

@@ -0,0 +1,3 @@
#define COMPONENT init
#define COMPONENT_BEAUTIFIED Init
#include "../script_mod.hpp"

View File

@@ -242,32 +242,6 @@
}
] call CBA_fnc_addSetting;
//---------------------
// Asset Diary and Markers Settings
[
"milsim_fbcb2_assets_setting_detectionRangeFromBase", // variable
"SLIDER", // type
["Detection Range From Base", "The range from a base that assets will be detected"], // title
["17th Battalion", "Asset Diary and Markers"], // category
[0, 1000, 750, 0, false], // [_min, _max, _default, _trailingDecimals, _isPercentage]
true, // global setting
{
params ["_value"];
[
"fbcb2_assets",
"SETTING CHANGED",
[
[
"setting",
"milsim_fbcb2_assets_setting_detectionRangeFromBase"
],
["newValue", _value]
]
] call milsim_util_fnc_log;
}
] call CBA_fnc_addSetting;
diag_log text "[MILSIM] (settings) Custom CBA settings initialized";
nil;

View File

@@ -1,3 +1,5 @@
#include "..\script_component.hpp"
params [["_playerObj", objNull], ["_arrayToModify", [], [[]]]];
if (isNull _playerObj) exitWith {_arrayToModify};

View File

@@ -1,3 +1,5 @@
#include "..\script_component.hpp"
params [["_base", objNull, [objNull]]];
if (_base == objNull) exitWith {""};

View File

@@ -1,3 +1,5 @@
#include "..\script_component.hpp"
params [["_object", objNull, [objNull]]];
if (isNull _object) exitWith {objNull};

View File

@@ -9,6 +9,7 @@
1: STRING - message to log.
2: ARRAY - Key value pairs of data to log.
*/
#include "..\script_component.hpp"
params [
["_component", "", [""]],
@@ -23,6 +24,6 @@ _message regexReplace ["\[", "("];
_message regexReplace ["\]", ")"];
private _json = [_hash] call CBA_fnc_encodeJSON;
_log = format ["[milsim] [%1] [%2] [%3] :: %4", _component, _fnc_scriptNameParent, _message, _json];
_log = format ["[%1] [%2] [%3] [%4] :: %5", QUOTE(PREFIX), _component, _fnc_scriptNameParent, _message, _json];
diag_log text _log;

View File

@@ -1,5 +1,7 @@
#include "..\script_component.hpp"
[
"init",
QUOTE(COMPONENT),
"MISSION INFO",
[
["serverName", serverName],
@@ -20,4 +22,4 @@
["LOGIC", playableSlotsNumber sideLogic] // 5 is LOGIC side
]]
]
] call milsim_util_fnc_log;
] call FUNC(log);

View File

@@ -1,3 +1,5 @@
#include "..\script_component.hpp"
params [
["_text", "", [""]],
["_padSide", "left", ["left", "right"]],

View File

@@ -1,3 +1,5 @@
#include "..\script_component.hpp"
params [
["_cfg", configNull, [configNull]],
["_code", {}, [{}]]

View File

@@ -0,0 +1,3 @@
#define COMPONENT util
#define COMPONENT_BEAUTIFIED Utilities
#include "../script_mod.hpp"

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,85 @@
#include "script_macros_common.hpp"
/*
Header: script_macros_mission.hpp
Description:
Modifies script_common_macros.hpp for compatiblity with missions.
Some addon specific functionality might be lost.
Authors:
Muzzleflash
Changes from script_macros_mission.hpp:
Follows Standard:
Object variables: PREFIX_COMPONENT
Main-object variables: PREFIX_main
Paths: PREFIX\COMPONENT\SCRIPTNAME.sqf
Or if CUSTOM_FOLDER is defined:
CUSTOM_FOLDER\SCRIPTNAME.sqf
eg. six\sys_menu\fDate.sqf
Usage:
Define PREFIX and COMPONENT, then include this file:
*/
/*
CUSTOM_FOLDER
Custom folder to search for files in. Will not change variable names.
Default is PREFIX\COMPONENT
Example:
(begin example)
#define CUSTOM_FOLDER MyPackage\ScriptA
(end)
(begin example)
#define CUSTOM_FOLDER COMPONENT\functions
(end)
*/
#undef PATHTO_SYS
#undef PATHTOF_SYS
#undef PATHTOF2_SYS
#ifdef CUSTOM_FOLDER
#define PATHTO_SYS(var1,var2,var3) ##CUSTOM_FOLDER\##var3.sqf
#define PATHTOF_SYS(var1,var2,var3) ##CUSTOM_FOLDER\##var3
#define PATHTOF2_SYS(var1,var2,var3) ##CUSTOM_FOLDER\##var3
#else
#define PATHTO_SYS(var1,var2,var3) ##var1\##var2\##var3.sqf
#define PATHTOF_SYS(var1,var2,var3) ##var1\##var2\##var3
#define PATHTOF2_SYS(var1,var2,var3) ##var1\##var2\##var3
#endif
/************************** REMOVAL OF MACROS ***********************/
#undef MAINPREFIX
#undef SUBPREFIX
#undef VERSION_AR
#undef VERSION_CONFIG
#undef VERSIONING_SYS
#undef VERSIONING
#undef PRELOAD_ADDONS
#undef BWC_CONFIG
#undef XEH_DISABLED
#undef XEH_PRE_INIT
#undef XEH_PRE_CINIT
#undef XEH_PRE_SINIT
#undef XEH_POST_INIT
#undef XEH_POST_CINIT
#undef XEH_POST_SINIT
#undef PATHTO_FNC
#define PATHTO_FNC(func) class func {\
file = QUOTE(DOUBLES(fnc,func).sqf);\
RECOMPILE;\
}