fixed prevent instant death setting

This commit is contained in:
Glowbal 2015-04-03 21:49:46 +02:00
parent d4a6dd1038
commit ecf16ad9f1
4 changed files with 20 additions and 12 deletions

View File

@ -172,7 +172,7 @@ class CfgVehicles {
defaultValue = 1;
};
class maxReviveTime {
displayName = "MAx Revive time";
displayName = "Max Revive time";
description = "Max amount of seconds a unit can spend in revive state";
typeName = "NUMBER";
defaultValue = 1;

View File

@ -60,6 +60,8 @@ if (GVAR(level) >= 2) then {
if ((_minLethalDamage <= _newDamage) && {[_unit, [_selection] call FUNC(selectionNameToNumber), _newDamage] call FUNC(determineIfFatal)}) then {
if ([_unit] call FUNC(setDead)) then {
_damageReturn = 1;
} else {
_damageReturn = 0.89;
};
} else {
_damageReturn = 0.89;
@ -68,7 +70,7 @@ if (GVAR(level) >= 2) then {
};
[_unit] call FUNC(addToInjuredCollection);
if (_unit getVariable [QGVAR(preventDeath), false] && {_damageReturn >= 0.9} && {_selection in ["", "head", "body"]}) exitWith {
if (_unit getVariable [QGVAR(preventDeath), GVAR(preventInstaDeath)] && {_damageReturn >= 0.9} && {_selection in ["", "head", "body"]}) exitWith {
if (vehicle _unit != _unit and {damage _vehicle >= 1}) then {
// @todo
// [_unit] call FUNC(unload);

View File

@ -24,7 +24,6 @@ if !(_activated) exitWith {};
[_logic, QGVAR(medicSetting), "medicSetting"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(maxRevives), "maxRevives"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(maxReviveTime), "maxReviveTime"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(enableOverdosing), "enableOverdosing"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(bleedingCoefficient), "bleedingCoefficient"] call EFUNC(common,readSettingFromModule);

View File

@ -13,39 +13,45 @@
#include "script_component.hpp"
private ["_unit"];
private ["_unit", "_force"];
_unit = _this select 0;
_force = false;
if (count _this >= 2) then {
_force = _this select 1;
};
if (!alive _unit) exitwith{};
if (!alive _unit) exitwith{true};
if (!local _unit) exitwith {
[[_unit, _force], QUOTE(DFUNC(setDead)), _unit, false] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */
false;
};
if (GVAR(preventInstaDeath) && !_force) exitwith {
if (_unit getvariable [QGVAR(inReviveState), false]) exitwith {}; // already in revive state
if ((_unit getVariable [QGVAR(preventDeath), GVAR(preventInstaDeath)]) && !_force) exitwith {
if (_unit getvariable [QGVAR(inReviveState), false]) exitwith {false}; // already in revive state
_unit setvariable [QGVAR(inReviveState), true, true];
[_unit] call FUNC(setUnconscious);
_unit setvariable [QGVAR(reviveStartTime), time];
[_unit, true] call FUNC(setUnconscious);
[{
private ["_args","_unit","_startTime"];
_args = _this select 0;
_unit = _args select 0;
_startTime = _args select 1;
_startTime = _unit getvariable [QGVAR(reviveStartTime), 0];
if (time - _startTime > GVAR(maxReviveTime)) exitwith {
[(_this select 1)] call cba_fnc_removePerFrameHandler;
[_unit, true] call FUNC(setDead);
_unit setvariable [QGVAR(inReviveState), nil, true];
_unit setvariable [QGVAR(reviveStartTime), nil];
[_unit, true] call FUNC(setDead);
};
if !(_unit getvariable [QGVAR(inReviveState), false]) exitwith {
_unit setvariable [QGVAR(reviveStartTime), nil];
[(_this select 1)] call cba_fnc_removePerFrameHandler;
};
}, 1, [_unit, time] ] call CBA_fnc_addPerFrameHandler;
}, 1, [_unit] ] call CBA_fnc_addPerFrameHandler;
false;
};
_unit setvariable ["ACE_isDead", true, true];
@ -53,3 +59,4 @@ if (isPLayer _unit) then {
_unit setvariable ["isDeadPlayer", true, true];
};
_unit setdamage 1;
true;