ACE3/addons/medical_status/functions/fnc_setUnconscious.sqf

62 lines
1.5 KiB
Plaintext
Raw Normal View History

/*
* Author: Glowbal
* Sets a unit in the unconscious state.
*
* Arguments:
* 0: The unit that will be put in an unconscious state <OBJECT>
* 1: Set unconsciouns <BOOL> (default: true)
*
* ReturnValue:
2016-10-12 19:59:32 +00:00
* Success? <BOOLEAN>
*
* Example:
* [bob, true] call ace_medical_fnc_setUnconscious;
*
* Public: yes
*/
#include "script_component.hpp"
// only run this after the settings are initialized
if !(EGVAR(common,settingsInitFinished)) exitWith {
EGVAR(common,runAtSettingsInitialized) pushBack [FUNC(setUnconscious), _this];
};
2016-12-05 20:34:20 +00:00
params ["_unit", ["_knockOut", true]];
2016-10-12 19:59:32 +00:00
if (isNull _unit || {!(_unit isKindOf "CAManBase")}) exitWith {false};
if (!local _unit) exitWith {
2016-12-05 20:34:20 +00:00
[QGVAR(setUnconscious), [_unit, _knockOut], _unit] call CBA_fnc_targetEvent;
2016-10-12 19:59:32 +00:00
true
};
if (_knockOut isEqualTo (_unit getVariable [QGVAR(isUnconscious), false])) exitWith {false};
2016-10-12 19:59:32 +00:00
// --- wake up
if !(_knockOut) exitWith {
_unit setVariable [QGVAR(isUnconscious), false, true];
[_unit, false] call EFUNC(medical_engine,setUnconsciousAnim);
["ace_unconscious", [_unit, false]] call CBA_fnc_globalEvent;
2016-10-12 19:59:32 +00:00
true
};
2016-10-12 19:59:32 +00:00
// --- knock out
_unit setVariable [QGVAR(isUnconscious), true, true];
2016-12-05 20:34:20 +00:00
_unit setVariable [QGVAR(lastWakeUpCheck), CBA_missiontime];
if (_unit == ACE_player) then {
if (visibleMap) then {openMap false};
while {dialog} do {
closeDialog 0;
};
};
[_unit, true] call EFUNC(medical_engine,setUnconsciousAnim);
2016-11-07 22:44:33 +00:00
[QGVAR(Unconscious), _unit] call CBA_fnc_localEvent;
["ace_unconscious", [_unit, true]] call CBA_fnc_globalEvent;
2016-10-12 19:59:32 +00:00
true