Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Medical AI - Fix splints not being applied in special circumstance & setting adding multiple EH #10141

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions addons/medical_ai/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@
_unit setVariable [QGVAR(lastSuppressed), CBA_missionTime];
}] call CBA_fnc_addClassEventHandler;

if (GVAR(requireItems) == 2) then {
["CAManBase", "InitPost", {
[{
params ["_unit"];
if ((!local _unit) || {!alive _unit} || {isPlayer _unit}) exitWith {};
TRACE_2("replacing medical items on AI",_unit,typeOf _unit);
[_unit] call EFUNC(common,replaceRegisteredItems);
}, _this] call CBA_fnc_execNextFrame; // need to delay a frame before modifying items in a backpack
}, nil, [IGNORE_BASE_UAVPILOTS], true] call CBA_fnc_addClassEventHandler;
};

#include "stateMachine.inc.sqf"

}] call CBA_fnc_addEventHandler;
4 changes: 2 additions & 2 deletions addons/medical_ai/functions/fnc_healUnit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ if IS_UNCONSCIOUS(_this) exitWith {

// Find next unit to treat
private _healQueue = _this getVariable [QGVAR(healQueue), []];
private _target = _healQueue select 0;
private _target = _healQueue param [0, objNull];

// If unit died or was healed, be lazy and wait for the next tick
if (isNull _target || {!alive _target} || {!(_target call FUNC(isInjured))}) exitWith {
if (!alive _target || {!(_target call FUNC(isInjured))}) exitWith {
_this forceSpeed -1;
_target forceSpeed -1;
_healQueue deleteAt 0;
Expand Down
6 changes: 3 additions & 3 deletions addons/medical_ai/functions/fnc_healingLogic.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ switch (true) do {
_treatmentArgs = [_target, selectRandom ["leftarm", "rightarm", "leftleg", "rightleg"], "SalineIV"];
_treatmentItem = "@iv";
};
case ((count (_target getVariable [VAR_MEDICATIONS, []])) >= 6): {
_treatmentEvent = "#tooManyMeds";
};
case (((_fractures select 4) == 1)
&& {([_healer, "splint"] call FUNC(itemCheck)) # 0}): {
_treatmentEvent = QEGVAR(medical_treatment,splintLocal);
Expand All @@ -104,6 +101,9 @@ switch (true) do {
_treatmentArgs = [_healer, _target, "rightleg"];
_treatmentItem = "splint";
};
case ((count (_target getVariable [VAR_MEDICATIONS, []])) >= 6): {
_treatmentEvent = "#tooManyMeds";
};
case ((IS_UNCONSCIOUS(_target) || {_heartRate <= 50})
&& {([_healer, "epinephrine"] call FUNC(itemCheck)) # 0}): {
if (CBA_missionTime < (_target getVariable [QGVAR(nextEpinephrine), -1])) exitWith {
Expand Down
18 changes: 5 additions & 13 deletions addons/medical_ai/initSettings.inc.sqf
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
private _categoryArray = [ELSTRING(medical,Category), "STR_TEAM_SWITCH_AI"];

[
QGVAR(enabledFor), "LIST",
QGVAR(enabledFor),
"LIST",
[LLSTRING(enableFor_title), LLSTRING(enableFor_desc)],
_categoryArray,
[
Expand All @@ -15,7 +16,8 @@ private _categoryArray = [ELSTRING(medical,Category), "STR_TEAM_SWITCH_AI"];
] call CBA_fnc_addSetting;

[
QGVAR(requireItems), "LIST",
QGVAR(requireItems),
"LIST",
[LSTRING(requireItems_title), LSTRING(requireItems_desc)],
_categoryArray,
[
Expand All @@ -24,16 +26,6 @@ private _categoryArray = [ELSTRING(medical,Category), "STR_TEAM_SWITCH_AI"];
0
],
true, // isGlobal
{
if (GVAR(requireItems) != 2) exitWith {};
["CAManBase", "initPost", {
[{
params ["_unit"];
if ((!local _unit) || {!alive _unit} || {isPlayer _unit}) exitWith {};
TRACE_2("replacing medical items on AI",_unit,typeOf _unit);
[_unit] call EFUNC(common,replaceRegisteredItems);
}, _this] call CBA_fnc_execNextFrame; // need to delay a frame before modifying items in a backpack
}, nil, [IGNORE_BASE_UAVPILOTS], true] call CBA_fnc_addClassEventHandler;
},
{[QGVAR(requireItems), _this] call EFUNC(common,cbaSettings_settingChanged)},
true // Needs mission restart
] call CBA_fnc_addSetting;