2018-08-25 15:40:22 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
/*
|
|
|
|
* Author: Glowbal
|
|
|
|
* Sets a unit in the unconscious state.
|
|
|
|
* For Internal Use: Called from the state machine.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: The unit that will be put in an unconscious state <OBJECT>
|
|
|
|
* 1: Set unconscious <BOOL>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* Success <BOOL>
|
|
|
|
*
|
2019-08-06 13:10:33 +00:00
|
|
|
* Example:
|
2019-10-12 14:47:57 +00:00
|
|
|
* [player, true] call ace_medical_status_fnc_setUnconsciousState
|
2019-08-06 13:10:33 +00:00
|
|
|
*
|
2018-08-25 15:40:22 +00:00
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
|
|
|
params ["_unit", "_active"];
|
2019-10-12 14:47:57 +00:00
|
|
|
TRACE_2("setUnconsciousState",_unit,_active);
|
2018-08-25 15:40:22 +00:00
|
|
|
|
|
|
|
// No change to make
|
2019-08-06 13:10:33 +00:00
|
|
|
if (_active isEqualTo IS_UNCONSCIOUS(_unit)) exitWith { TRACE_2("no change",_active,IS_UNCONSCIOUS(_unit)); };
|
2018-08-25 15:40:22 +00:00
|
|
|
|
|
|
|
_unit setVariable [VAR_UNCON, _active, true];
|
|
|
|
|
|
|
|
// Toggle unit ragdoll state
|
|
|
|
[_unit, _active] call EFUNC(medical_engine,setUnconsciousAnim);
|
|
|
|
|
2019-06-27 22:11:51 +00:00
|
|
|
// Stop AI firing at unconscious units in most situations (global effect)
|
|
|
|
[_unit, "setHidden", "ace_unconscious", _active] call EFUNC(common,statusEffect_set);
|
|
|
|
|
2018-08-25 15:40:22 +00:00
|
|
|
if (_active) then {
|
|
|
|
// Don't bother setting this if not used
|
|
|
|
if (EGVAR(medical,spontaneousWakeUpChance) > 0) then {
|
2019-06-12 00:25:05 +00:00
|
|
|
private _lastWakeUpCheck = _unit getVariable [QEGVAR(medical,lastWakeUpCheck), 0]; // could be set higher from ace_medical_fnc_setUnconscious
|
2019-08-06 13:10:33 +00:00
|
|
|
TRACE_2("setting lastWakeUpCheck to max of",_lastWakeUpCheck,CBA_missionTime);
|
2019-06-12 00:25:05 +00:00
|
|
|
_unit setVariable [QEGVAR(medical,lastWakeUpCheck), _lastWakeUpCheck max CBA_missionTime];
|
2018-08-25 15:40:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if (_unit == ACE_player) then {
|
|
|
|
if (visibleMap) then {openMap false};
|
|
|
|
|
|
|
|
while {dialog} do {
|
|
|
|
closeDialog 0;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
// Unit has woken up, no longer need to track this
|
2019-03-21 18:33:51 +00:00
|
|
|
_unit setVariable [QEGVAR(medical,lastWakeUpCheck), nil];
|
2018-08-25 15:40:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// This event doesn't correspond to unconscious in statemachine
|
|
|
|
// It's for any time a unit changes consciousness (including cardiac arrest)
|
|
|
|
["ace_unconscious", [_unit, _active]] call CBA_fnc_globalEvent;
|