2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2016-09-04 09:25:03 +00:00
|
|
|
/*
|
|
|
|
* Author: BaerMitUmlaut
|
|
|
|
* Makes a medic heal the next unit that needs treatment.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Return Value:
|
2017-06-08 13:31:51 +00:00
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* call ACE_medical_ai_fnc_healUnit
|
2016-09-04 09:25:03 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2019-07-03 14:59:28 +00:00
|
|
|
// Player will have to do this manually of course
|
|
|
|
if ([_this] call EFUNC(common,isPlayer)) exitWith {};
|
2016-09-04 09:25:03 +00:00
|
|
|
// Can't heal other units when unconscious
|
2019-07-03 14:59:28 +00:00
|
|
|
if IS_UNCONSCIOUS(_this) exitWith {
|
|
|
|
_this setVariable [QGVAR(currentTreatment), nil];
|
|
|
|
};
|
2016-09-04 09:25:03 +00:00
|
|
|
|
|
|
|
// 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 {
|
2019-07-03 14:59:28 +00:00
|
|
|
_this forceSpeed -1;
|
2016-09-04 09:25:03 +00:00
|
|
|
_target forceSpeed -1;
|
|
|
|
_healQueue deleteAt 0;
|
2019-07-03 14:59:28 +00:00
|
|
|
_this setVariable [QGVAR(healQueue), _healQueue];
|
2016-09-04 09:25:03 +00:00
|
|
|
// return to formation instead of going where the injured unit was if it healed itself in the mean time
|
|
|
|
_this doFollow leader _this;
|
2019-07-03 14:59:28 +00:00
|
|
|
_this setVariable [QGVAR(nextMoveOrder), nil];
|
|
|
|
_this setVariable [QGVAR(currentTreatment), nil];
|
2016-09-04 09:25:03 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG_MODE_FULL
|
2019-07-03 14:59:28 +00:00
|
|
|
systemChat format ["%1 finished healing %2", _this, _target];
|
2016-09-04 09:25:03 +00:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
// Move to target...
|
2019-07-03 14:59:28 +00:00
|
|
|
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];
|
2016-09-04 09:25:03 +00:00
|
|
|
_this doMove getPosATL _target;
|
2019-07-03 14:59:28 +00:00
|
|
|
#ifdef DEBUG_MODE_FULL
|
|
|
|
systemChat format ["%1 moving to %2", _this, _target];
|
|
|
|
#endif
|
2016-09-04 09:25:03 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
// ...and make sure medic and target don't move
|
|
|
|
_this forceSpeed 0;
|
|
|
|
_target forceSpeed 0;
|
|
|
|
|
2019-07-03 14:59:28 +00:00
|
|
|
[_this, _target] call FUNC(healingLogic);
|