2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2016-10-12 21:20:22 +00:00
|
|
|
/*
|
|
|
|
* Author: commy2
|
|
|
|
* Kills a local unit.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: The unit <OBJECT>
|
|
|
|
* 1: Reason for death <STRING>
|
2021-11-15 15:31:56 +00:00
|
|
|
* 2: Killer <OBJECT>
|
2024-06-20 05:04:34 +00:00
|
|
|
* 3: Instigator <OBJECT>
|
2016-10-12 21:20:22 +00:00
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Return Value:
|
2016-10-12 21:20:22 +00:00
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
2024-06-20 05:04:34 +00:00
|
|
|
params ["_unit", ["_reason", "#setDead"], ["_source", objNull], ["_instigator", objNull]];
|
|
|
|
TRACE_4("setDead",_unit,_reason,_source,_instigator);
|
2024-04-07 01:20:51 +00:00
|
|
|
|
2018-08-25 15:40:22 +00:00
|
|
|
// No heart rate or blood pressure to measure when dead
|
|
|
|
_unit setVariable [VAR_HEART_RATE, 0, true];
|
|
|
|
_unit setVariable [VAR_BLOOD_PRESS, [0, 0], true];
|
|
|
|
|
2024-04-07 01:20:51 +00:00
|
|
|
// Clear uncon variable just to be safe
|
|
|
|
_unit setVariable [VAR_UNCON, nil, true];
|
|
|
|
|
2019-09-05 20:56:14 +00:00
|
|
|
_unit setVariable [QEGVAR(medical,causeOfDeath), _reason, true];
|
2016-10-12 21:20:22 +00:00
|
|
|
|
2019-09-05 20:56:14 +00:00
|
|
|
// Send a local event before death
|
|
|
|
[QEGVAR(medical,death), [_unit]] call CBA_fnc_localEvent;
|
2016-10-12 21:20:22 +00:00
|
|
|
|
2022-03-07 18:28:51 +00:00
|
|
|
// Update the state machine if necessary (forced respawn, scripted death, etc)
|
|
|
|
private _unitState = [_unit, EGVAR(medical,STATE_MACHINE)] call CBA_statemachine_fnc_getCurrentState;
|
|
|
|
if (_unitState isNotEqualTo "Dead") then {
|
|
|
|
[_unit, EGVAR(medical,STATE_MACHINE), _unitState, "Dead"] call CBA_statemachine_fnc_manualTransition;
|
|
|
|
};
|
|
|
|
|
2022-02-06 16:36:28 +00:00
|
|
|
// (#8803) Reenable damage if disabled to prevent having live units in dead state
|
|
|
|
// Keep this after death event for compatibility with third party hooks
|
2024-06-20 05:04:34 +00:00
|
|
|
if (!isDamageAllowed _unit) then {
|
2022-02-06 16:36:28 +00:00
|
|
|
WARNING_1("setDead executed on unit with damage blocked - %1",_this);
|
|
|
|
_unit allowDamage true;
|
|
|
|
};
|
|
|
|
|
2019-09-05 20:56:14 +00:00
|
|
|
// Kill the unit without changing visual apperance
|
2021-11-15 15:31:56 +00:00
|
|
|
private _prevDamage = _unit getHitPointDamage "HitHead";
|
|
|
|
|
2024-06-20 05:04:34 +00:00
|
|
|
_unit setHitPointDamage ["HitHead", 1, true, _source, _instigator];
|
2021-11-15 15:31:56 +00:00
|
|
|
|
2024-06-20 05:04:34 +00:00
|
|
|
_unit setHitPointDamage ["HitHead", _prevDamage, true, _source, _instigator];
|