2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2019-09-05 20:56:14 +00:00
|
|
|
/*
|
|
|
|
* Author: PabstMirror
|
|
|
|
* Vanilla Killed EH, attempts to set correct source/killer for other killed event handlers (vanilla and XEH)
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Unit <OBJECT>
|
|
|
|
* 1: Killer <OBJECT>
|
|
|
|
* 2: Instigator <OBJECT>
|
|
|
|
* 3: Use Effects <BOOL>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [cursorObject, player, player, true] call ace_medical_status_fnc_handleKilled
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
|
|
|
params ["_unit", "_killer", "_instigator", "_useEffects"];
|
|
|
|
TRACE_4("handleKilled",_unit,_killer,_instigator,_useEffects);
|
|
|
|
|
2020-02-29 22:09:00 +00:00
|
|
|
// ensure event is only called once
|
|
|
|
if (_unit isEqualTo (_unit getVariable [QGVAR(killed), objNull])) exitWith {
|
|
|
|
_this set [0, objNull];
|
|
|
|
_this set [1, objNull];
|
|
|
|
_this set [2, objNull];
|
|
|
|
};
|
|
|
|
_unit setVariable [QGVAR(killed), _unit];
|
|
|
|
|
2019-09-05 20:56:14 +00:00
|
|
|
private _causeOfDeath = _unit getVariable [QEGVAR(medical,causeOfDeath), "#scripted"];
|
2021-11-15 15:31:56 +00:00
|
|
|
private _modifyKilledArray = missionNamespace getVariable [QEGVAR(medical,modifyKilledArray), true]; // getVar so this can be disabled
|
2019-09-05 20:56:14 +00:00
|
|
|
|
2021-11-15 15:31:56 +00:00
|
|
|
// if undefined then it's a death not caused by ace's setDead (mission setDamage, disconnect, forced respawn while conscious)
|
2019-09-05 20:56:14 +00:00
|
|
|
if (_causeOfDeath != "#scripted") then {
|
|
|
|
_killer = _unit getVariable [QEGVAR(medical,lastDamageSource), _killer]; // vehicle
|
|
|
|
_instigator = _unit getVariable [QEGVAR(medical,lastInstigator), _instigator]; // unit in the turret
|
2021-11-15 15:31:56 +00:00
|
|
|
} else {
|
|
|
|
// call setDead manually to prevent any issues
|
2021-10-10 14:24:10 +00:00
|
|
|
[_unit, "#scripted"] call FUNC(setDead);
|
2019-09-05 20:56:14 +00:00
|
|
|
};
|
2021-11-15 15:31:56 +00:00
|
|
|
|
|
|
|
// All Killed EHs uses the same array, so we can modify it now to pass the correct killer/instigator
|
|
|
|
if (_modifyKilledArray) then {
|
|
|
|
_this set [1, _killer];
|
|
|
|
_this set [2, _instigator];
|
|
|
|
};
|
2019-09-05 20:56:14 +00:00
|
|
|
TRACE_3("killer info",_killer,_instigator,_causeOfDeath);
|
|
|
|
|
2020-02-05 23:09:58 +00:00
|
|
|
if (_unit == player) then {
|
2020-02-04 11:15:45 +00:00
|
|
|
// Enable user input before respawn, in case mission is using respawnTemplates
|
|
|
|
["unconscious", false] call EFUNC(common,setDisableUserInputStatus);
|
|
|
|
};
|
|
|
|
|
2023-08-18 17:16:20 +00:00
|
|
|
// Remove status effects before respawn, in case mission is using spectator
|
|
|
|
[_unit, false] call FUNC(setStatusEffects);
|
|
|
|
|
2019-09-05 20:56:14 +00:00
|
|
|
["ace_killed", [_unit, _causeOfDeath, _killer, _instigator]] call CBA_fnc_globalEvent;
|