2015-02-08 12:18:08 +00:00
|
|
|
/*
|
|
|
|
* Author: Glowbal
|
|
|
|
* Either kills a unit or puts the unit in a revivable state, depending on the settings.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: The unit that will be killed <OBJECT>
|
2015-11-21 17:11:13 +00:00
|
|
|
* 1: Force Dead (ignore revive setting) <BOOL>
|
|
|
|
* 1: Delay setDamage for a frame <BOOL>
|
2015-02-08 12:18:08 +00:00
|
|
|
*
|
|
|
|
* ReturnValue:
|
2015-11-21 17:11:13 +00:00
|
|
|
* Did he died? <BOOL>
|
2015-02-08 12:18:08 +00:00
|
|
|
*
|
|
|
|
* Public: yes
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-11-21 17:11:13 +00:00
|
|
|
private ["_reviveVal", "_lifesLeft"];
|
|
|
|
params ["_unit", ["_force", false], ["_delaySetDamage", false]];
|
2015-02-08 12:18:08 +00:00
|
|
|
|
2015-11-21 17:11:13 +00:00
|
|
|
if ((!alive _unit) || {_unit getVariable ["ACE_isDead", false]}) exitWith {true};
|
2015-02-08 12:18:08 +00:00
|
|
|
if (!local _unit) exitwith {
|
2016-05-24 13:13:11 +00:00
|
|
|
["ace_setDead", [_unit, _force], _unit] call CBA_fnc_targetEvent;
|
2015-04-03 19:49:46 +00:00
|
|
|
false;
|
2015-02-08 12:18:08 +00:00
|
|
|
};
|
|
|
|
|
2015-04-29 20:04:46 +00:00
|
|
|
_reviveVal = _unit getVariable [QGVAR(enableRevive), GVAR(enableRevive)];
|
|
|
|
if (((_reviveVal == 1 && {[_unit] call EFUNC(common,isPlayer)} || _reviveVal == 2)) && !_force) exitwith {
|
2015-11-30 16:53:57 +00:00
|
|
|
if (_unit getVariable [QGVAR(inReviveState), false]) exitwith {
|
2015-04-03 21:56:32 +00:00
|
|
|
if (GVAR(amountOfReviveLives) > 0) then {
|
2015-11-30 16:53:57 +00:00
|
|
|
_lifesLeft = _unit getVariable[QGVAR(amountOfReviveLives), GVAR(amountOfReviveLives)];
|
2015-04-03 21:56:32 +00:00
|
|
|
if (_lifesLeft == 0) then {
|
|
|
|
[_unit, true] call FUNC(setDead);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
false;
|
|
|
|
};
|
|
|
|
|
2015-11-30 16:53:57 +00:00
|
|
|
_unit setVariable [QGVAR(inReviveState), true, true];
|
2016-03-02 10:01:39 +00:00
|
|
|
_unit setVariable [QGVAR(reviveStartTime), CBA_missionTime];
|
2015-04-03 19:49:46 +00:00
|
|
|
[_unit, true] call FUNC(setUnconscious);
|
2015-03-09 21:27:01 +00:00
|
|
|
|
2016-02-29 02:08:25 +00:00
|
|
|
// Run the loop that tracks the revive state
|
|
|
|
[_unit ] call FUNC(reviveStateLoop);
|
2015-04-03 19:49:46 +00:00
|
|
|
false;
|
2015-02-08 12:18:08 +00:00
|
|
|
};
|
|
|
|
|
2015-11-30 16:53:57 +00:00
|
|
|
_unit setVariable ["ACE_isDead", true, true];
|
2015-02-08 12:18:08 +00:00
|
|
|
if (isPLayer _unit) then {
|
2015-11-30 16:53:57 +00:00
|
|
|
_unit setVariable ["isDeadPlayer", true, true];
|
2015-02-08 12:18:08 +00:00
|
|
|
};
|
2015-06-06 02:03:27 +00:00
|
|
|
|
2016-06-03 18:22:34 +00:00
|
|
|
[QGVAR(killed), [_unit]] call CBA_fnc_localEvent;
|
2015-06-06 02:03:27 +00:00
|
|
|
|
2016-02-18 01:54:43 +00:00
|
|
|
//Delay a frame before killing the unit via scripted damage
|
2015-11-21 17:11:13 +00:00
|
|
|
//to avoid triggering the "Killed" Event twice (and having the wrong killer)
|
|
|
|
|
|
|
|
if (!_delaySetDamage) then {
|
|
|
|
[_unit, 1] call FUNC(setStructuralDamage);
|
|
|
|
} else {
|
2016-05-22 13:27:24 +00:00
|
|
|
[FUNC(setStructuralDamage), [_unit, 1]] call CBA_fnc_execNextFrame;
|
2015-11-21 17:11:13 +00:00
|
|
|
};
|
|
|
|
|
2015-04-03 19:49:46 +00:00
|
|
|
true;
|