Added support for locality switch and killed units

This commit is contained in:
Glowbal 2015-03-08 17:50:06 +01:00
parent c7edd83296
commit 85cbe5eb5f
5 changed files with 74 additions and 7 deletions

View File

@ -26,3 +26,19 @@ class Extended_Respawn_EventHandlers {
};
};
};
class Extended_Killed_EventHandlers {
class CAManBase {
class ADDON {
killed = QUOTE(call FUNC(handleKilled));
};
};
};
class Extended_Local_EventHandlers {
class CAManBase {
class ADDON {
local = QUOTE(call FUNC(handleLocal));
};
};
};

View File

@ -36,6 +36,8 @@ PREP(handleDamage_fractures);
PREP(handleDamage_internalInjuries);
PREP(handleDamage_wounds);
PREP(handleUnitVitals);
PREP(handleKilled);
PREP(handleLocal);
PREP(hasItem);
PREP(hasItems);
PREP(hasMedicalEnabled);

View File

@ -15,14 +15,14 @@
private "_unit";
_unit = _this select 0;
_force = if (count _this > 1) then {_this select 1} else {false};
if ([_unit] call FUNC(hasMedicalEnabled)) then {
if !(local _unit) exitwith{
[[_unit], QUOTE(DFUNC(addToInjuredCollection)), _unit] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */
if ([_unit] call FUNC(hasMedicalEnabled) || _force) then {
if ((_unit getvariable[QGVAR(addedToUnitLoop),false] || !alive _unit) && !_force) exitwith{};
if !(local _unit) exitwith {
[[_unit, _force], QUOTE(DFUNC(addToInjuredCollection)), _unit] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */
};
if (_unit getvariable[QGVAR(addedToUnitLoop),false]) exitwith{};
_unit setvariable [QGVAR(addedToUnitLoop),true, true];
_unit setvariable [QGVAR(addedToUnitLoop), true, true];
if (isNil QGVAR(InjuredCollection)) then {
GVAR(InjuredCollection) = [];
@ -56,5 +56,4 @@ if ([_unit] call FUNC(hasMedicalEnabled)) then {
};
};
}, 1, [_unit]] call CBA_fnc_addPerFrameHandler;
};

View File

@ -0,0 +1,25 @@
/*
* Author: Glowbal
* Called when a unit is killed
*
* Arguments:
* 0: The Unit <OBJECT>
*
* ReturnValue:
* None
*
* Public: No
*/
#include "script_component.hpp"
private["_unit"];
_unit = _this select 0;
if (!local _unit) exitwith {};
_unit setvariable [QGVAR(pain), 0];
if (GVAR(level) >= 2) then {
_unit setvariable [QGVAR(heartRate), 0];
_unit setvariable [QGVAR(bloodPressure), [0, 0]];
_unit setvariable [QGVAR(airwayStatus), 0];
};

View File

@ -0,0 +1,25 @@
/*
* Author: Glowbal
* Called when a unit switched locality
*
* Arguments:
* 0: The Unit <OBJECT>
* 1: Is local <BOOL>
*
* ReturnValue:
* None
*
* Public: No
*/
#include "script_component.hpp"
private["_unit", "_local"];
_unit = _this select 0;
_local = _this select 1;
if (_local) then {
if (_unit getvariable[QGVAR(addedToUnitLoop),false]) then {
[_unit, true] call FUNC(addToInjuredCollection);
};
};