mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
e2ac18a05d
* advanced_ballistics * advanced_fatigue * advanced_throwing * ai * aircraft * arsenal * atragmx * attach * backpacks * ballistics * captives * cargo * chemlights * common * concertina_wire * cookoff * dagr * disarming * disposable * dogtags * dragging * explosives * fastroping * fcs * finger * frag * gestures * gforces * goggles * grenades * gunbag * hearing * hitreactions * huntir * interact_menu * interaction * inventory * kestrel4500 * laser * laserpointer * logistics_uavbattery * logistics_wirecutter * magazinerepack * map * map_gestures * maptools * markers * medical * medical_ai * medical_blood * medical_menu * microdagr * minedetector * missileguidance * missionmodules * mk6mortar * modules * movement * nametags * nightvision * nlaw * optics * optionsmenu * overheating * overpressure * parachute * pylons * quickmount * rangecard * rearm * recoil * refuel * reload * reloadlaunchers * repair * respawn * safemode * sandbag * scopes * slideshow * spectator * spottingscope * switchunits * tacticalladder * tagging * trenches * tripod * ui * vector * vehiclelock * vehicles * viewdistance * weaponselect * weather * winddeflection * yardage450 * zeus * arsenal defines.hpp * optionals * DEBUG_MODE_FULL 1 * DEBUG_MODE_FULL 2 * Manual fixes * Add SQF Validator check for #include after block comment * explosives fnc_openTimerUI * fix uniqueItems
100 lines
3.3 KiB
Plaintext
100 lines
3.3 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
|
|
*/
|
|
|
|
// Can't heal other units when unconscious
|
|
if IS_UNCONSCIOUS(_this) exitWith {};
|
|
// Check if we're still treating
|
|
if ((_this getVariable [QGVAR(treatmentOverAt), CBA_missionTime]) > CBA_missionTime) exitWith {};
|
|
|
|
// 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 {
|
|
_target forceSpeed -1;
|
|
_healQueue deleteAt 0;
|
|
_this getVariable [QGVAR(healQueue), _healQueue];
|
|
_this forceSpeed -1;
|
|
// 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(movingToInjured), false];
|
|
|
|
#ifdef DEBUG_MODE_FULL
|
|
systemChat format ["%1 finished healing %2", _this, _target];
|
|
#endif
|
|
};
|
|
|
|
// Move to target...
|
|
if (_this distance _target > 2) exitWith {
|
|
if !(_this getVariable [QGVAR(movingToInjured), false]) then {
|
|
_this setVariable [QGVAR(movingToInjured), true];
|
|
_this doMove getPosATL _target;
|
|
};
|
|
};
|
|
_this setVariable [QGVAR(movingToInjured), false];
|
|
|
|
// ...and make sure medic and target don't move
|
|
_this forceSpeed 0;
|
|
_target forceSpeed 0;
|
|
|
|
private _needsBandaging = GET_BLOOD_LOSS(_target) > 0;
|
|
private _needsMorphine = GET_PAIN(_target) > 0.2;
|
|
private _needsEpinephrine = IS_UNCONSCIOUS(_target);
|
|
|
|
switch (true) do {
|
|
case _needsBandaging: {
|
|
// Select first wound and bandage it
|
|
private _openWounds = _target getVariable [QEGVAR(medical,openWounds), []];
|
|
private _partIndex = {
|
|
_x params ["", "", "_index", "_amount", "_percentage"];
|
|
if (_amount * _percentage > 0) exitWith {
|
|
_index
|
|
};
|
|
} forEach _openWounds;
|
|
private _selection = ALL_BODY_PARTS select _partIndex;
|
|
[_target, "BasicBandage", _selection] call EFUNC(medical_treatment,treatmentBandageLocal);
|
|
|
|
#ifdef DEBUG_MODE_FULL
|
|
systemChat format ["%1 is bandaging selection %2 on %3", _this, _selection, _target];
|
|
#endif
|
|
|
|
// Play animation
|
|
[_this, true, false] call FUNC(playTreatmentAnim);
|
|
_this setVariable [QGVAR(treatmentOverAt), CBA_missionTime + 5];
|
|
};
|
|
case _needsMorphine: {
|
|
[_this, "Morphine", 2] call EFUNC(medical_treatment,treatmentMedicationLocal);
|
|
[_this, false, false] call FUNC(playTreatmentAnim);
|
|
_this setVariable [QGVAR(treatmentOverAt), CBA_missionTime + 2];
|
|
|
|
#ifdef DEBUG_MODE_FULL
|
|
systemChat format ["%1 is giving %2 morphine", _this, _target];
|
|
#endif
|
|
};
|
|
//ToDo - Figure out how to connect to new medical
|
|
// case _needsEpinephrine: {
|
|
// [_this, _target] call EFUNC(medical,treatmentBasic_epipen);
|
|
// [_this, false, false] call FUNC(playTreatmentAnim);
|
|
// _this setVariable [QGVAR(treatmentOverAt), CBA_missionTime + 2];
|
|
|
|
// #ifdef DEBUG_MODE_FULL
|
|
// systemChat format ["%1 is using an epipen on %2", _this, _target];
|
|
// #endif
|
|
// };
|
|
};
|