From e38845bf45b866f5616b8848f8062768c6e5b110 Mon Sep 17 00:00:00 2001 From: commy2 Date: Wed, 12 Oct 2016 23:20:22 +0200 Subject: [PATCH] add ace_kill event handler --- addons/medical/XEH_PREP.hpp | 1 + .../functions/fnc_handleUnitVitals.sqf | 2 +- addons/medical/functions/fnc_setDead.sqf | 30 +++++++++++++++++++ .../medical/functions/fnc_setUnconscious.sqf | 1 - .../functions/fnc_handleDamage.sqf | 5 +++- 5 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 addons/medical/functions/fnc_setDead.sqf diff --git a/addons/medical/XEH_PREP.hpp b/addons/medical/XEH_PREP.hpp index 6c48674199..a438e5f964 100644 --- a/addons/medical/XEH_PREP.hpp +++ b/addons/medical/XEH_PREP.hpp @@ -29,3 +29,4 @@ PREP(handleMedications); PREP(addPain); PREP(setUnconscious); +PREP(setDead); diff --git a/addons/medical/functions/fnc_handleUnitVitals.sqf b/addons/medical/functions/fnc_handleUnitVitals.sqf index 54f7682ee6..9341fee12c 100644 --- a/addons/medical/functions/fnc_handleUnitVitals.sqf +++ b/addons/medical/functions/fnc_handleUnitVitals.sqf @@ -76,7 +76,7 @@ if (_painStatus > (_unit getVariable [QGVAR(painSuppress), 0])) then { }; if (_bloodVolume < BLOOD_VOLUME_DEAD) exitWith { - [_unit] call FUNC(setDead); + [_unit, "bloodloss"] call FUNC(setDead); }; if ([_unit] call EFUNC(common,isAwake)) then { diff --git a/addons/medical/functions/fnc_setDead.sqf b/addons/medical/functions/fnc_setDead.sqf new file mode 100644 index 0000000000..6ffaddfc4d --- /dev/null +++ b/addons/medical/functions/fnc_setDead.sqf @@ -0,0 +1,30 @@ +/* + * Author: commy2 + * Kills a local unit. + * + * Arguments: + * 0: The unit + * 1: Reason for death + * + * ReturnValue: + * None + * + * Example: + * [bob, "bloodloss"] call ace_medical_fnc_setDead; + * + * Public: No + */ +#include "script_component.hpp" + +params ["_unit", ["_reason", "unknown"]]; + +// kill +_unit setDamage 1; + +// reset textures +[_unit, "All"] call EFUNC(medical_engine,updateBodyPartVisuals); + +private _lastShooter = _unit getVariable [QEGVAR(medical_engine,lastShooter), objNull]; +private _lastInstigator = _unit getVariable [QEGVAR(medical_engine,lastInstigator), objNull]; + +["ace_killed", [_unit, _reason, _lastShooter, _lastInstigator]] call CBA_fnc_globalEvent; diff --git a/addons/medical/functions/fnc_setUnconscious.sqf b/addons/medical/functions/fnc_setUnconscious.sqf index 55e108efef..65eadf6e85 100644 --- a/addons/medical/functions/fnc_setUnconscious.sqf +++ b/addons/medical/functions/fnc_setUnconscious.sqf @@ -16,7 +16,6 @@ * * Public: yes */ - #include "script_component.hpp" // only run this after the settings are initialized diff --git a/addons/medical_engine/functions/fnc_handleDamage.sqf b/addons/medical_engine/functions/fnc_handleDamage.sqf index 4876047432..f9f5ace1d2 100644 --- a/addons/medical_engine/functions/fnc_handleDamage.sqf +++ b/addons/medical_engine/functions/fnc_handleDamage.sqf @@ -15,7 +15,7 @@ // for travis #define HIT_STRUCTURAL QGVAR($#structural) -params ["_unit", "_selection", "_damage", "_shooter", "_ammo", "_hitPointIndex"]; +params ["_unit", "_selection", "_damage", "_shooter", "_ammo", "_hitPointIndex", "_instigator"]; //diag_log _this; // HD sometimes triggers for remote units - ignore. @@ -41,6 +41,9 @@ if (_hitPoint in ["hithead", "hitbody", "hithands", "hitlegs"]) exitWith {_oldDa // Add injury if (_hitPoint isEqualTo "ace_hdbracket") exitWith { + _unit setVariable [QGVAR(lastShooter), _shooter]; + _unit setVariable [QGVAR(lastInstigator), _instigator]; + private _damageStructural = _unit getVariable [HIT_STRUCTURAL, 0]; // --- Head