ACE3/addons/medical_engine/functions/fnc_lockUnconsciousSeat.sqf
BaerMitUmlaut 52ed0fc6be
Medical Engine - Prevent automatic unloading of dead or unconscious units (#7959)
* Lock seats of unconscious or dead units

* disable pullOutBody if medical is loaded

* fix undefined var and switch to objectParent

---------

Co-authored-by: Salluci <salluci.lovi@gmail.com>
Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>
2023-07-22 09:41:20 +03:00

38 lines
1.0 KiB
Plaintext

#include "script_component.hpp"
/*
* Author: BaerMitUmlaut
* Locks the seat of an unconscious or dead unit to prevent automatic unloading.
*
* Arguments:
* 0: Unit <OBJECT>
*
* Return Value:
* None
*
* Public: No
*/
params ["_unit"];
private _vehicle = objectParent _unit;
if (alive _unit && {lifeState _unit != "INCAPACITATED"}) exitWith {};
switch (true) do {
case (_unit isEqualTo (driver _vehicle)): {
_vehicle lockDriver true;
_unit setVariable [QGVAR(lockedSeat), [_vehicle, "driver"], true];
};
case (_vehicle getCargoIndex _unit != -1): {
private _cargoIndex = _vehicle getCargoIndex _unit;
_vehicle lockCargo [_cargoIndex, true];
_unit setVariable [QGVAR(lockedSeat), [_vehicle, "cargo", _cargoIndex], true];
};
case ((_vehicle unitTurret _unit) isNotEqualTo []): {
private _turretPath = _vehicle unitTurret _unit;
_vehicle lockTurret [_turretPath, true];
_unit setVariable [QGVAR(lockedSeat), [_vehicle, "turret", _turretPath], true];
};
};