Added revive state / prevent death and unconscious conditions

This commit is contained in:
Glowbal 2015-03-08 12:27:52 +01:00
parent d016874583
commit e6042ca04f
3 changed files with 34 additions and 3 deletions

View File

@ -64,4 +64,8 @@ class ACE_Settings {
typeName = "BOOL";
value = false;
};
class GVAR(maxReviveTime) {
typeName = "NUMBER";
value = 120;
};
};

View File

@ -219,7 +219,7 @@ if (isNil QGVAR(level)) then {
}, 0, []] call CBA_fnc_addPerFrameHandler;
// broadcast injuries to JIP clients in a MP session
if (isMultiplayer && !isDedicated) then {
if (isMultiplayer) then {
[QGVAR(onPlayerConnected), "onPlayerConnected", {
if (isNil QGVAR(InjuredCollection)) then {
GVAR(InjuredCollection) = [];
@ -234,3 +234,11 @@ if (isMultiplayer && !isDedicated) then {
}foreach GVAR(InjuredCollection);
}, []] call BIS_fnc_addStackedEventHandler;
};
[
{(((_this select 0) getvariable [QGVAR(bloodVolume), 0]) < 65)},
{(((_this select 0) getvariable [QGVAR(pain), 0]) > 48)},
{(((_this select 0) call FUNC(getBloodLoss)) > 0.25)},
{((_this select 0) getvariable [QGVAR(inReviveState), false])}
] call FUNC(registerUnconsciousCondition);

View File

@ -25,8 +25,27 @@ if (!local _unit) exitwith {
[[_unit, _force], QUOTE(DFUNC(setDead)), _unit, false] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */
};
if (missionNamespace getVariable [QGVAR(enableRevive), false]) exitwith {
// TODO Implement the revive state
if (GVAR(preventInstaDeath) && !_force) exitwith {
if (_unit getvariable [QGVAR(inReviveState), false]) exitwith {}; // already in revive state
_unit setvariable [QGVAR(inReviveState), true, true];
[_unit] call FUNC(setUnconscious);
[{
private ["_args","_unit","_startTime"];
_args = _this select 0;
_unit = _args select 0;
_startTime = _args select 1;
if (time - _startTime > GVAR(maxReviveTime)) exitwith {
[(_this select 1)] call cba_fnc_removePerFrameHandler;
[_unit, true] call FUNC(setDead);
_unit setvariable [QGVAR(inReviveState), nil, true];
};
if !(_unit getvariable [QGVAR(inReviveState), false]) exitwith {
[(_this select 1)] call cba_fnc_removePerFrameHandler;
};
}, 1, [_unit, time] ] call CBA_fnc_addPerFrameHandler;
};
_unit setvariable ["ACE_isDead", true, true];