big refactor, WIP!

This commit is contained in:
2024-02-06 01:52:25 -08:00
parent f588ffa4a0
commit 0a64d9e170
74 changed files with 1024 additions and 701 deletions

View File

@@ -0,0 +1,99 @@
/*
milsim_fnc_addMedicalOverlayPFH
Author: IndigoFox
Description:
Affects players with medical permissions. Will see a 3D colored dot over nearby (5-10m)
unconscious players who are not in a vehicle
which indicates their current ACE Triage Card status.
Designed to increase efficiency of CCPs.
*/
// Force setting if CBA doesn't work?
if (isNil "milsim_client_medState3D_enabled") then {
milsim_client_medState3D_enabled = true;
};
if (isNil "milsim_client_medState3D_drawRange") then {
milsim_client_medState3D_drawRange = 10;
};
// List of units to draw icons for
milsim_client_medState3D_drawTargets = [];
// ACE Triage colors, for consistency across UIs and functions
// #define TRIAGE_COLOR_NONE 0.5, 0.5, 0.5, 0.1
// #define TRIAGE_COLOR_MINIMAL 0, 0.5, 0, 0.9
// #define TRIAGE_COLOR_DELAYED 1, 0.84, 0, 0.9
// #define TRIAGE_COLOR_IMMEDIATE 1, 0, 0, 0.9
// #define TRIAGE_COLOR_DECEASED 0, 0, 0, 0.9
// ACE Triage colors, for consistency across UIs and functions
milsim_client_medState3D_colors = [
[0, 0.5, 0, 0.9], // TRIAGE_COLOR_MINIMAL
[1, 0.84, 0, 0.9], // TRIAGE_COLOR_DELAYED
[1, 0, 0, 0.9], // TRIAGE_COLOR_IMMEDIATE
[0.15, 0.15, 0.15, 0.9], // TRIAGE_COLOR_DECEASED
[0.5, 0.5, 0.5, 0] // TRIAGE_COLOR_NONE
];
// Per-frame handler to draw icons
// cleanup
if (!isNil "milsim_client_medState3D_pfh") then {
[milsim_client_medState3D_pfh] call CBA_fnc_removePerFrameHandler;
};
// add pfh
milsim_client_medState3D_pfh = [{
// if disabled, skip processing
if (!milsim_client_medState3D_enabled) exitWith {false};
// if no targets, skip processing
if (count milsim_client_medState3D_drawTargets == 0) exitWith {false};
if !([player] call ace_medical_treatment_fnc_isMedic) exitWith {false};
{
// distance within 10 meters
if (player distance _x > milsim_client_medState3D_drawRange) then {continue};
// check unit not null, not conscious, and not in a vehicle
if (
!(_x getVariable ["ACE_isUnconscious", false]) ||
!isNull (objectParent _x)
) then {continue};
// color based on triage level
private _triageLevel = _x getVariable ["ace_medical_triageLevel", -1];
if (_triageLevel == -1) then {continue};
private _color = milsim_client_medState3D_colors select (
(_x getVariable ["ace_medical_triageLevel", -1]) -1
);
// draw position, slightly above the prone unit
private _drawPos = (visiblePosition _x) vectorAdd [0, 0, 0.5];
// draw icon
drawIcon3D [
"\A3\ui_f\data\map\markers\military\dot_CA.paa", // icon texture
_color, // color
_drawPos, // position AGL
1, // width
1, // height
0 // angle
// further params optional, omitted
];
} forEach milsim_client_medState3D_drawTargets;
}, 0, []] call CBA_fnc_addPerFrameHandler;
// subroutine to gather nearest 50 units every 5 seconds and store in milsim_client_medState3D_drawTargets
// cleanup
if (!isNil "milsim_client_medState3D_drawTargetsPfh") then {
[milsim_client_medState3D_drawTargetsPfh] call CBA_fnc_removePerFrameHandler;
};
// add pfh
milsim_client_medState3D_drawTargetsPfh = [{
milsim_client_medState3D_drawTargets = (
(allUnits + allDeadMen) select {
_x isKindOf "CAManBase" &&
player distance _x < 50 &&
!isNull _x &&
player isNotEqualTo _x
}
);
}, 5, false] call CBA_fnc_addPerFrameHandler;

View File

@@ -0,0 +1,88 @@
if ( !hasInterface ) exitWith {};
[
"17th Battalion",
"Create Resupply Box",
{
params [["_pos", [0,0,0], [[]], 3], ["_target", objNull, [objNull]]];
// get parent definition
private _supplyCratesCfg = call milsim_resupply_fnc_getSupplyCratesCfg;
// get the subclass names
private _boxTypesAvailable = _supplyCratesCfg call BIS_fnc_getCfgSubClasses;
_boxTypesAvailable sort true;
_comboOptions = _boxTypesAvailable apply {
[
// display name
[_supplyCratesCfg >> _x >> "displayName", "STRING", "ERROR"] call CBA_fnc_getConfigEntry,
// tooltip
[_supplyCratesCfg >> _x >> "tooltip", "STRING", "ERROR"] call CBA_fnc_getConfigEntry,
// icon
[_supplyCratesCfg >> _x >> "icon", "STRING", "ERROR"] call CBA_fnc_getConfigEntry
]
};
[
"Resupply Box Options",
[
// [ "COMBO", "Box Type", [[1,2,3], [["Ammo"],["Weapons"],["Medical"]],0] ]
["COMBO", "Box Type", [_boxTypesAvailable, _comboOptions, 0]]
],
{
params ["_dialog", "_args"];
_dialog params ["_typeOptionSelected"];
_args params ["_pos", "_target", "_keysSorted"];
private _box = [_target, _typeOptionSelected, _pos] call milsim_resupply_fnc_createBox;
if (isNull _box) exitWith {
["Resupply Box", "WARNING: Failed to locate or create box!"] call BIS_fnc_curatorHint;
};
["Resupply Box", format["Created box from class %1", _typeOptionSelected]] call BIS_fnc_curatorHint;
},
{},
[_pos, _target]
] call zen_dialog_fnc_create;
}
] call zen_custom_modules_fnc_register;
[
"17th Battalion",
"Grounds Cleanup",
{
params [["_pos", [0,0,0], [[]], 3], ["_target", objNull, [objNull]]];
_pos = [_pos#0, _pos#1, 0];
[
"Cleanup Area",
[
[ "SLIDER:RADIUS", "Radius (meters)", [50, 500, 100, 0, _pos, [0.8, 0.2, 0.2, 1.0]], true ]
],
{
params ["_dialog", "_args"];
_dialog params ["_radius"];
_args params ["_pos", "_target"];
_objects = _pos nearObjects ["GroundWeaponHolder", _radius];
{
deleteVehicle _x;
} forEach _objects
},
{},
[_pos, _target]
] call zen_dialog_fnc_create;
}
] call zen_custom_modules_fnc_register;
diag_log text "[MILSIM] (client) zeus modules added";
nil;

View File

@@ -0,0 +1,23 @@
diag_log text format ["[MILSIM] (client) initializing empty group deletion PFH"];
_emptyGroupPFH = [
{
{
if (local _x) then {
if ((count units _x) == 0) then {
deleteGroup _x;
};
};
} forEach allGroups;
},
300,
[],
{ diag_log text format ["[MILSIM] (client) Empty Group Deletion PFH loaded"] },
{ diag_log text format ["[MILSIM] (client) Empty Group Deletion"] },
{ true },
{ false },
[]
] call CBA_fnc_createPerFrameHandlerObject;

View File

@@ -0,0 +1,58 @@
#include "..\script_component.hpp"
if ( !hasInterface ) exitWith {};
player addEventHandler["Respawn",
{
params ["_unit", "_corpse"];
private _killer = _corpse getVariable ["ace_medical_causeOfDeath", "#scripted"];
if (_killer == "respawn_button") then {
[
LEVEL_INFO
QUOTE(COMPONENT),
"RESPAWNED WHILE UNCONSCIOUS",
[_unit] call EFUNC(common,addPlayerInfoToArray)
] remoteExec [QEFUNC(common,log), 2];
// format["%1 was unconscious then clicked the respawn button", name _unit] remoteExec["systemChat", 0];
};
}
];
[
{
params ["_unit", "_object", "_cost"];
private _return = (count nearestObjects [_unit, ["B_APC_Tracked_01_CRV_F", "rhsusf_M1239_M2_Deploy_socom_d", "rhsusf_stryker_m1132_m2_wd", "rhsusf_m113_usarmy_supply", "rhsusf_M1078A1P2_B_WD_CP_fmtv_usarmy", "B_Slingload_01_Cargo_F"], 120]) > 0;
_return
}
] call ace_fortify_fnc_addDeployHandler;
addMissionEventHandler ["HandleChatMessage",
{
params ["_channel", "_owner", "_from", "_text", "_person", "_name", "_strID", "_forcedDisplay", "_isPlayerMessage", "_sentenceType", "_chatMessageType"];
if ( missionNamespace getVariable ["milsim_sideChat", false] ) exitWith{ false };
if (_channel != 1) exitWith { false };
if ( ( admin _owner ) != 0 ) exitWith { false };
if ( !isNull ( getAssignedCuratorLogic _person ) ) exitWith { false };
true;
}
];
["ace_arsenal_displayClosed", {
[player] remoteExec [QEFUNC(common,logPlayerInventory), 2];
}] call CBA_fnc_addEventHandler;
[missionNamespace, "arsenalClosed", {
[player] remoteExec [QEFUNC(common,logPlayerInventory), 2];
}] call BIS_fnc_addScriptedEventHandler;
diag_log text "[MILSIM] (client) event handlers bound";
nil;

View File

@@ -0,0 +1,67 @@
if ( !hasInterface ) exitWith {};
_checkFuel =
[
"CheckFuel",
"Check Fuel",
"",
{
hint format ["Fuel: %1%2", floor (fuel _target *100), "%"];
},
{true}
] call ace_interact_menu_fnc_createAction;
["LandVehicle", 0, ["ACE_MainActions"], _checkFuel, true] call ace_interact_menu_fnc_addActionToClass;
_unflip =
[
"Unfuck",
"Flip Vehicle",
"",
{
_target setpos [(getpos _target) select 0,(getpos _target) select 1, 0.5];
_target setVectorUp surfaceNormal position _target;
},
{true}
] call ace_interact_menu_fnc_createAction;
["LandVehicle", 0, ["ACE_MainActions"], _unflip, true] call ace_interact_menu_fnc_addActionToClass;
_patchTire =
[
"patchTire",
"Patch Tire",
"\a3\ui_f\data\IGUI\Cfg\Actions\repair_ca.paa",
{
[_player, "AinvPknlMstpSnonWnonDr_medic5", 0] call ace_common_fnc_doAnimation;
[
30,
[_player, _target],
{
params ["_args"];
_args params ["_player", "_target"];
hint "Tire Patched";
_target setDamage 0.2;
_target setVariable["milsim_ace_repair_wheel_canPatch", false];
},
{
params ["_args"];
_args params ["_player", "_target"];
hint "Stopped repair";
[_player, "", 0] call ace_common_fnc_doAnimation;
},
"Patching"
] call ace_common_fnc_progressBar
},
{ ( alive _target ) && ( [_player, "ToolKit"] call ace_common_fnc_hasItem ) && ( getDammage _target > 0.2 ) && ( _target getVariable["milsim_ace_repair_wheel_canPatch", true] ) }
] call ace_interact_menu_fnc_createAction;
["ACE_Wheel", 0, ["ACE_MainActions"], _patchTire, true] call ace_interact_menu_fnc_addActionToClass;
diag_log text "[MILSIM] (client) vehicle actions bound";
nil;