Skip to content

Commit

Permalink
Medical - Use HandleHeal instead of making Vanilla FAKs and Medikit…
Browse files Browse the repository at this point in the history
…s unusable (#10401)

* Use `handleHeal` to intercept healing attempts

* Update XEH_postInit.sqf

* Update addons/medical_engine/XEH_postInit.sqf

---------

Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>
  • Loading branch information
johnb432 and LinkIsGrim authored Nov 15, 2024
1 parent 4bb7d3c commit 4d927b6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 14 deletions.
11 changes: 0 additions & 11 deletions addons/medical_engine/CfgWeapons.hpp

This file was deleted.

28 changes: 28 additions & 0 deletions addons/medical_engine/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,34 @@
QEGVAR(medical,HandleDamageEHID),
_unit addEventHandler ["HandleDamage", {_this call FUNC(handleDamage)}]
];

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

AISFinishHeal [_injured, _healer, _isMedic];

// AI stay in healing loop if they have healing items available (they try to heal once every second)
if (isNull _atVehicle && {!isNil {TYPE_FIRST_AID_KIT call EFUNC(common,getItemReplacements)} || {!isNil {TYPE_MEDIKIT call EFUNC(common,getItemReplacements)}}}) then {
// Replace the items (if possible) so that the unit can't heal
_healer call EFUNC(common,replaceRegisteredItems);
} else {
// If there are no replacements available, interrupt healing command by forcing the unit to leave and rejoin the group
if (_healer call EFUNC(common,isPlayer)) exitWith {};

// This resets their command/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;

if (_assignedTeam != "") then {
_healer assignTeam _assignedTeam;
};
};

true
}];
}, nil, [IGNORE_BASE_UAVPILOTS], true] call CBA_fnc_addClassEventHandler;

#ifdef DEBUG_MODE_FULL
Expand Down
1 change: 0 additions & 1 deletion addons/medical_engine/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,5 @@ class CfgPatches {
#include "CfgFunctions.hpp"
#include "CfgMoves.hpp"
#include "CfgVehicles.hpp"
#include "CfgWeapons.hpp"

#endif
2 changes: 0 additions & 2 deletions addons/medical_treatment/CfgWeapons.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ class CfgWeapons {
class MedikitItem;

class FirstAidKit: ItemCore {
type = 0;
ACE_isMedicalItem = 1;
class ItemInfo: InventoryFirstAidKitItem_Base_F {
mass = 4;
};
};
class Medikit: ItemCore {
type = 0;
ACE_isMedicalItem = 1;
class ItemInfo: MedikitItem {
mass = 60;
Expand Down

0 comments on commit 4d927b6

Please sign in to comment.