2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2018-08-25 15:40:22 +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 unconscious <BOOL>
|
|
|
|
*
|
|
|
|
* Return Value:
|
2022-03-07 18:28:51 +00:00
|
|
|
* None
|
2018-08-25 15:40:22 +00:00
|
|
|
*
|
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
|
2022-03-07 18:28:51 +00:00
|
|
|
if (_active isEqualTo IS_UNCONSCIOUS(_unit) || {!alive _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);
|
|
|
|
|
2023-08-18 17:16:20 +00:00
|
|
|
// Handle hiding from AI and talking blocks.
|
|
|
|
[_unit, _active] call FUNC(setStatusEffects);
|
2022-05-08 18:20:15 +00:00
|
|
|
|
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;
|
|
|
|
};
|
2023-09-09 06:17:24 +00:00
|
|
|
|
|
|
|
if (EGVAR(medical,dropWeaponUnconsciousChance) != 0 && {random 1 <= EGVAR(medical,dropWeaponUnconsciousChance)}) then {
|
|
|
|
_unit call EFUNC(common,throwWeapon);
|
|
|
|
};
|
2018-08-25 15:40:22 +00:00
|
|
|
};
|
2020-02-19 16:05:05 +00:00
|
|
|
// Unlock controls for copilot if unit is pilot of aircraft
|
|
|
|
if (vehicle _unit isKindOf "Air" && {_unit == driver vehicle _unit}) then {
|
|
|
|
TRACE_1("pilot of air vehicle - unlocking controls",vehicle _unit);
|
|
|
|
// Do "Unlock controls" user action, co-pilot will then have to do the "Take Controls" actions
|
|
|
|
_unit action ["UnlockVehicleControl", vehicle _unit];
|
|
|
|
};
|
2020-11-08 22:27:10 +00:00
|
|
|
|
|
|
|
// Disable AI aiming
|
|
|
|
if (!isPlayer _unit && {_unit checkAIFeature "WEAPONAIM"}) then {
|
|
|
|
_unit disableAI "WEAPONAIM";
|
|
|
|
_unit setVariable [QGVAR(reenableWeaponAim), true, true];
|
|
|
|
};
|
2018-08-25 15:40:22 +00:00
|
|
|
} 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];
|
2020-11-08 22:27:10 +00:00
|
|
|
|
|
|
|
// Reenable AI aiming
|
|
|
|
if (_unit getVariable [QGVAR(reenableWeaponAim), false]) then {
|
|
|
|
_unit enableAI "WEAPONAIM";
|
|
|
|
};
|
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;
|