ACE3/addons/medical_ai/functions/fnc_healUnit.sqf
PabstMirror 05e4f74e73
Medical AI - Adjust healing logic for rewrite (#6902)
* Medical AI - Adjust healing logic for rewrite

- move state machine from config to sqf
- move all healing logic to seperate func
- attempt to handle healing for new system

* prioritize unitReady medics

* move setting to subcategory under medical

* Use faster GET_WOUND_BLEEDING

* Update fnc_healingLogic.sqf

* Update for wound array changes

* Update treatment events changes

* Fractures/splint

* formating / use GET_OPEN_WOUNDS

* Use non-localized medical category
2019-07-03 09:59:28 -05:00

61 lines
1.8 KiB
Plaintext

#include "script_component.hpp"
/*
* Author: BaerMitUmlaut
* Makes a medic heal the next unit that needs treatment.
*
* Arguments:
* None
*
* Return Value:
* None
*
* Example:
* call ACE_medical_ai_fnc_healUnit
*
* Public: No
*/
// Player will have to do this manually of course
if ([_this] call EFUNC(common,isPlayer)) exitWith {};
// Can't heal other units when unconscious
if IS_UNCONSCIOUS(_this) exitWith {
_this setVariable [QGVAR(currentTreatment), nil];
};
// Find next unit to treat
private _healQueue = _this getVariable [QGVAR(healQueue), []];
private _target = _healQueue select 0;
// If unit died or was healed, be lazy and wait for the next tick
if (isNull _target || {!alive _target} || {!(_target call FUNC(isInjured))}) exitWith {
_this forceSpeed -1;
_target forceSpeed -1;
_healQueue deleteAt 0;
_this setVariable [QGVAR(healQueue), _healQueue];
// return to formation instead of going where the injured unit was if it healed itself in the mean time
_this doFollow leader _this;
_this setVariable [QGVAR(nextMoveOrder), nil];
_this setVariable [QGVAR(currentTreatment), nil];
#ifdef DEBUG_MODE_FULL
systemChat format ["%1 finished healing %2", _this, _target];
#endif
};
// Move to target...
if (_this distance _target > 2.5) exitWith {
_this setVariable [QGVAR(currentTreatment), nil];
if (CBA_missionTime >= (_this getVariable [QGVAR(nextMoveOrder), CBA_missionTime])) then {
_this setVariable [QGVAR(nextMoveOrder), CBA_missionTime + 10];
_this doMove getPosATL _target;
#ifdef DEBUG_MODE_FULL
systemChat format ["%1 moving to %2", _this, _target];
#endif
};
};
// ...and make sure medic and target don't move
_this forceSpeed 0;
_target forceSpeed 0;
[_this, _target] call FUNC(healingLogic);