2017-06-05 16:42:46 +00:00
|
|
|
/*
|
|
|
|
* 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 unconsciouns <BOOL>
|
|
|
|
*
|
|
|
|
* ReturnValue:
|
|
|
|
* Success? <BOOLEAN>
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [bob, true] call ace_medical_fnc_setUnconsciousStatemachine
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
#define DEBUG_MODE_FULL
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
|
|
|
params ["_unit", "_knockOut"];
|
|
|
|
TRACE_2("setUnconsciousStatemachine",_unit,_knockOut);
|
|
|
|
|
2017-06-15 19:35:33 +00:00
|
|
|
if (_knockOut isEqualTo (_unit getVariable ["ACE_isUnconscious", false])) exitWith {TRACE_1("No Change - Exiting",_knockOut);};
|
2017-06-05 16:42:46 +00:00
|
|
|
|
2017-06-15 19:35:33 +00:00
|
|
|
_unit setVariable ["ACE_isUnconscious", _knockOut, true];
|
2017-06-05 16:42:46 +00:00
|
|
|
["ace_unconscious", [_unit, _knockOut]] call CBA_fnc_globalEvent;
|
|
|
|
[_unit, _knockOut] call EFUNC(medical_engine,setUnconsciousAnim);
|
|
|
|
|
|
|
|
|
|
|
|
if (_knockOut) then {
|
|
|
|
// --- knock out
|
|
|
|
if (GVAR(spontaneousWakeUpChance) > 0) then { // Don't bother setting this if not used
|
|
|
|
private _lastWakeUpCheck = CBA_missiontime max (_unit getVariable [QGVAR(lastWakeUpCheck), 0]);
|
|
|
|
TRACE_2("setting lastWakeUpCheck",_lastWakeUpCheck,(_lastWakeUpCheck - CBA_missiontime));
|
|
|
|
_unit setVariable [QGVAR(lastWakeUpCheck), _lastWakeUpCheck];
|
|
|
|
};
|
|
|
|
|
|
|
|
if (_unit == ACE_player) then {
|
|
|
|
if (visibleMap) then {openMap false};
|
|
|
|
|
|
|
|
while {dialog} do {
|
|
|
|
closeDialog 0;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
[QGVAR(Unconscious), _unit] call CBA_fnc_localEvent;
|
|
|
|
} else {
|
|
|
|
// --- wake up
|
|
|
|
_unit setVariable [QGVAR(lastWakeUpCheck), nil]; // clear this now (min wait time could be set to a very high value)
|
|
|
|
};
|