Skip to content

Commit

Permalink
Cancel healing at vehicles
Browse files Browse the repository at this point in the history
  • Loading branch information
johnb432 committed Aug 9, 2024
1 parent 34be857 commit f4572d9
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions addons/medical_engine/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#include "script_component.hpp"

["CBA_settingsInitialized", {
if !(GETEGVAR(medical,enabled,false)) exitWith {};
if !(GETEGVAR(medical,enabled,false)) exitWith {
// Call manually (see CfgFunctions.hpp)
// https://community.bistudio.com/wiki/Arma_3:_Functions_Library#Config_Levels
["postInit", didJIP] spawn BIS_fnc_reviveInit;
};

[QGVAR(updateDamageEffects), LINKFUNC(updateDamageEffects)] call CBA_fnc_addEventHandler;

Expand All @@ -28,18 +32,26 @@
_unit addEventHandler ["HandleDamage", {_this call FUNC(handleDamage)}]
];

// Fires where healer is local
_unit addEventHandler ["HandleHeal", {
params ["_injured", "_healer"];
params ["", "_healer", "", "_atVehicle"];

// Replace the items so that the unit can't heal
_healer call EFUNC(common,replaceRegisteredItems);

AISFinishHeal [_injured, _healer, true];
// AI stay in healing loop if they have healing items available
if (isNull _atVehicle) then {
_healer call EFUNC(common,replaceRegisteredItems);
} else {
if (_healer call EFUNC(common,isPlayer)) exitWith {};

// This resets their action
private _assignedTeam = assignedTeam _healer;
private _groupInfo = [group _healer, groupId _healer];
[_healer] joinSilent grpNull; // If unit doesn't leave group first, it will take the lowest Id when joinAsSilent is run, regardless of parameters
_healer joinAsSilent _groupInfo;
_healer assignTeam _assignedTeam;
};

// Set animation to what it was before starting the healing animation
[{"dnon_medic" in animationState (_this select 0)}, {
[_this select 0, _this select 1, 2] call EFUNC(common,doAnimation);
}, [_healer, _healer call EFUNC(common,getDefaultAnim)], 5] call CBA_fnc_waitUntilAndExecute;
true
}];
}, nil, [IGNORE_BASE_UAVPILOTS], true] call CBA_fnc_addClassEventHandler;

Expand Down

0 comments on commit f4572d9

Please sign in to comment.