diff --git a/addons/medical_ai/XEH_postInit.sqf b/addons/medical_ai/XEH_postInit.sqf index d8676e9695..432846cbeb 100644 --- a/addons/medical_ai/XEH_postInit.sqf +++ b/addons/medical_ai/XEH_postInit.sqf @@ -9,6 +9,11 @@ _unit setVariable [QGVAR(lastFired), CBA_missionTime]; }] call CBA_fnc_addEventHandler; + ["CAManBase", "Hit", { + params ["_unit"]; + _unit setVariable [QGVAR(lastHit), CBA_missionTime]; + }] call CBA_fnc_addClassEventHandler; + #include "stateMachine.sqf" }] call CBA_fnc_addEventHandler; diff --git a/addons/medical_ai/XEH_preInit.sqf b/addons/medical_ai/XEH_preInit.sqf index 9361d05015..8dcb0111d7 100644 --- a/addons/medical_ai/XEH_preInit.sqf +++ b/addons/medical_ai/XEH_preInit.sqf @@ -8,4 +8,8 @@ PREP_RECOMPILE_END; #include "initSettings.sqf" +// default time values for AI being ready to heal, used in fnc_isSafe +if (isNil QGVAR(timeSafe_shoot)) then { GVAR(timeSafe_shoot) = 30; }; +if (isNil QGVAR(timeSafe_hit)) then { GVAR(timeSafe_hit) = 30; }; + ADDON = true; diff --git a/addons/medical_ai/functions/fnc_isSafe.sqf b/addons/medical_ai/functions/fnc_isSafe.sqf index 3c6c9f5dca..93ac425602 100644 --- a/addons/medical_ai/functions/fnc_isSafe.sqf +++ b/addons/medical_ai/functions/fnc_isSafe.sqf @@ -16,5 +16,6 @@ */ (getSuppression _this == 0) -&& {CBA_missionTime - (_this getVariable [QGVAR(lastFired), -30]) > 30} +&& {CBA_missionTime - (_this getVariable [QGVAR(lastFired), -999999]) > GVAR(timeSafe_shoot)} +&& {CBA_missionTime - (_this getVariable [QGVAR(lastHit), -999999]) > GVAR(timeSafe_hit)} && {!(_this getVariable [QEGVAR(captives,isHandcuffed), false])}