2016-07-30 12:00:42 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2019-05-12 04:13:59 +00:00
|
|
|
[QGVAR(updateDamageEffects), LINKFUNC(updateDamageEffects)] call CBA_fnc_addEventHandler;
|
|
|
|
["unit", {
|
|
|
|
params ["_new"];
|
|
|
|
[_new] call FUNC(updateDamageEffects); // Run on new controlled unit to update QGVAR(aimFracture)
|
|
|
|
}, true] call CBA_fnc_addPlayerEventHandler;
|
|
|
|
|
|
|
|
|
2016-07-30 12:00:42 +00:00
|
|
|
["CAManBase", "init", {
|
|
|
|
params ["_unit"];
|
|
|
|
|
|
|
|
// Check if last hit point is our dummy.
|
|
|
|
private _allHitPoints = getAllHitPointsDamage _unit param [0, []];
|
|
|
|
reverse _allHitPoints;
|
2023-06-27 16:41:10 +00:00
|
|
|
while {(_allHitPoints param [0, ""]) select [0,1] == "#"} do { WARNING_1("Ignoring Reflector hitpoint %1", _allHitPoints deleteAt 0); };
|
2016-07-30 12:00:42 +00:00
|
|
|
|
|
|
|
if (_allHitPoints param [0, ""] != "ACE_HDBracket") then {
|
2024-01-15 21:39:28 +00:00
|
|
|
if (unitIsUAV _unit) exitWith {TRACE_1("ignore UAV AI",typeOf _unit);};
|
|
|
|
if (getNumber ((configOf _unit) >> "isPlayableLogic") == 1) exitWith {TRACE_1("ignore logic unit",typeOf _unit)};
|
2016-10-02 15:50:17 +00:00
|
|
|
ERROR_1("Bad hitpoints for unit type ""%1""",typeOf _unit);
|
2016-07-30 12:00:42 +00:00
|
|
|
} else {
|
|
|
|
// Calling this function inside curly brackets allows the usage of
|
|
|
|
// "exitWith", which would be broken with "HandleDamage" otherwise.
|
2018-01-02 15:34:13 +00:00
|
|
|
_unit setVariable [
|
2018-01-02 15:36:17 +00:00
|
|
|
QEGVAR(medical,HandleDamageEHID),
|
2018-01-02 15:34:13 +00:00
|
|
|
_unit addEventHandler ["HandleDamage", {_this call FUNC(handleDamage)}]
|
|
|
|
];
|
2016-07-30 12:00:42 +00:00
|
|
|
};
|
2019-04-27 19:04:31 +00:00
|
|
|
}, nil, [IGNORE_BASE_UAVPILOTS], true] call CBA_fnc_addClassEventHandler;
|
2016-07-30 12:00:42 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG_MODE_FULL
|
2018-07-15 14:24:04 +00:00
|
|
|
[QEGVAR(medical,woundReceived), {
|
2022-02-17 20:03:12 +00:00
|
|
|
params ["_unit", "_damages", "_shooter", "_ammo"];
|
|
|
|
TRACE_4("wound",_unit,_damages, _shooter, _ammo);
|
2016-12-05 20:34:20 +00:00
|
|
|
//systemChat str _this;
|
2016-07-30 12:00:42 +00:00
|
|
|
}] call CBA_fnc_addEventHandler;
|
|
|
|
#endif
|
|
|
|
|
2016-10-05 22:54:57 +00:00
|
|
|
|
|
|
|
// this handles moving units into vehicles via load functions or zeus
|
|
|
|
// needed, because the vanilla INCAPACITATED state does not handle vehicles
|
|
|
|
["CAManBase", "GetInMan", {
|
2023-07-22 06:41:20 +00:00
|
|
|
params ["_unit", "", "_vehicle"];
|
2016-10-05 22:54:57 +00:00
|
|
|
|
2023-07-22 06:41:20 +00:00
|
|
|
if (local _unit && {lifeState _unit == "INCAPACITATED"}) then {
|
2016-10-05 22:54:57 +00:00
|
|
|
[_unit, true] call FUNC(setUnconsciousAnim);
|
|
|
|
};
|
2023-07-22 06:41:20 +00:00
|
|
|
|
|
|
|
if (local _vehicle) then {
|
|
|
|
[_unit] call FUNC(lockUnconsciousSeat);
|
|
|
|
};
|
|
|
|
}] call CBA_fnc_addClassEventHandler;
|
|
|
|
|
|
|
|
["CAManBase", "GetOutMan", {
|
|
|
|
params ["_unit", "", "_vehicle"];
|
|
|
|
|
|
|
|
if (local _vehicle) then {
|
|
|
|
[_unit] call FUNC(unlockUnconsciousSeat);
|
|
|
|
};
|
2016-10-05 22:54:57 +00:00
|
|
|
}] call CBA_fnc_addClassEventHandler;
|
2019-12-17 16:01:17 +00:00
|
|
|
|
2020-02-22 20:39:14 +00:00
|
|
|
// Fixes units being stuck in unconscious animation when being knocked over by a PhysX object
|
|
|
|
["CAManBase", "AnimDone", {
|
|
|
|
params ["_unit", "_anim"];
|
2021-11-24 18:22:17 +00:00
|
|
|
if (local _unit && {_anim find QUNCON_ANIM(face) != -1 && {lifeState _unit != "INCAPACITATED"}}) then {
|
2020-02-22 20:39:14 +00:00
|
|
|
[_unit, false] call FUNC(setUnconsciousAnim);
|
|
|
|
};
|
|
|
|
}] call CBA_fnc_addClassEventHandler;
|
2023-07-22 06:41:20 +00:00
|
|
|
|
|
|
|
["ace_unconscious", {
|
|
|
|
params ["_unit", "_unconscious"];
|
2023-08-02 05:59:46 +00:00
|
|
|
TRACE_3("unit uncon",_unit,objectParent _unit,local _unit);
|
|
|
|
if (!isNull objectParent _unit && {local objectParent _unit}) then {
|
2023-07-22 06:41:20 +00:00
|
|
|
if (_unconscious) then {
|
|
|
|
[_unit] call FUNC(lockUnconsciousSeat);
|
|
|
|
} else {
|
|
|
|
[_unit] call FUNC(unlockUnconsciousSeat);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}] call CBA_fnc_addEventHandler;
|
2023-08-02 05:59:46 +00:00
|
|
|
|
|
|
|
["ace_killed", { // global event
|
|
|
|
params ["_unit"];
|
|
|
|
TRACE_3("unit Killed",_unit,objectParent _unit,local _unit);
|
|
|
|
if (!isNull objectParent _unit && {local objectParent _unit}) exitWith {
|
|
|
|
[_unit] call FUNC(lockUnconsciousSeat);
|
|
|
|
};
|
|
|
|
}] call CBA_fnc_addEventHandler;
|
|
|
|
|
|
|
|
["CAManBase", "deleted", {
|
|
|
|
params ["_unit"];
|
|
|
|
TRACE_3("unit deleted",_unit,objectParent _unit,local _unit);
|
|
|
|
if ((!isNull objectParent _unit) && {local objectParent _unit}) then {
|
|
|
|
[_unit] call FUNC(unlockUnconsciousSeat);
|
|
|
|
};
|
|
|
|
}, true, []] call CBA_fnc_addClassEventHandler;
|