diff --git a/addons/medical_ai/XEH_postInit.sqf b/addons/medical_ai/XEH_postInit.sqf index 518d540478..248c634156 100644 --- a/addons/medical_ai/XEH_postInit.sqf +++ b/addons/medical_ai/XEH_postInit.sqf @@ -20,5 +20,16 @@ _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; diff --git a/addons/medical_ai/functions/fnc_healUnit.sqf b/addons/medical_ai/functions/fnc_healUnit.sqf index 4f941efc0a..3635088820 100644 --- a/addons/medical_ai/functions/fnc_healUnit.sqf +++ b/addons/medical_ai/functions/fnc_healUnit.sqf @@ -24,10 +24,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; diff --git a/addons/medical_ai/functions/fnc_healingLogic.sqf b/addons/medical_ai/functions/fnc_healingLogic.sqf index aff69d7865..811ef8d14d 100644 --- a/addons/medical_ai/functions/fnc_healingLogic.sqf +++ b/addons/medical_ai/functions/fnc_healingLogic.sqf @@ -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); @@ -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 { diff --git a/addons/medical_ai/initSettings.inc.sqf b/addons/medical_ai/initSettings.inc.sqf index a2b06519a4..b8ff7e6134 100644 --- a/addons/medical_ai/initSettings.inc.sqf +++ b/addons/medical_ai/initSettings.inc.sqf @@ -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, [ @@ -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, [ @@ -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;