Add maximum unconsciousness time option

This commit is contained in:
KoffeinFlummi 2015-04-23 11:31:27 +02:00
parent 84e1937515
commit d1c95ba8a1
5 changed files with 37 additions and 1 deletions

View File

@ -63,6 +63,10 @@ class ACE_Settings {
typeName = "BOOL";
value = 0;
};
class GVAR(maxUnconsciousTime) {
typeName = "SCALAR";
value = -1;
};
class GVAR(maxReviveTime) {
typeName = "SCALAR";
value = 120;

View File

@ -122,6 +122,12 @@ class CfgVehicles {
typeName = "BOOL";
defaultValue = 0;
};
class maxUnconsciousTime {
displayName = "Max. Uncon. Time";
description = "Maximum time a unit can be unconscious before dying. Negative Values disable this.";
typeName = "NUMBER";
defaultValue = -1;
};
class bleedingCoefficient {
displayName = "Bleeding coefficient";
description = "Coefficient to modify the bleeding speed";

View File

@ -8,7 +8,13 @@ if !(local _unit) exitWith {};
[_unit] call FUNC(init);
//Reset captive status for respawning unit
// Reset captive status for respawning unit
if (!(_unit getVariable ["ACE_isUnconscious", false])) then {
[_unit, QGVAR(unconscious), false] call EFUNC(common,setCaptivityStatus);
};
// Remove maximum unconsciousness time handler
_maxUnconHandle = _unit getVariable [QGVAR(maxUnconTimeHandle), -1];
if (_maxUnconHandle > 0) then {
[_maxUnconHandle] call CBA_fnc_removePerFrameHandler;
};

View File

@ -33,6 +33,7 @@ if !(_activated) exitWith {};
[_logic, QGVAR(AIDamageThreshold), "AIDamageThreshold"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(enableUnsconsiousnessAI), "enableUnsconsiousnessAI"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(preventInstaDeath), "preventInstaDeath"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(maxUnconsciousTime), "maxUnconsciousTime"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(bleedingCoefficient), "bleedingCoefficient"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(painCoefficient), "painCoefficient"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(keepLocalSettingsSynced), "keepLocalSettingsSynced"] call EFUNC(common,readSettingFromModule);

View File

@ -22,6 +22,15 @@ _unit = _this select 0;
_set = if (count _this > 1) then {_this select 1} else {true};
_minWaitingTime = if (count _this > 2) then {_this select 2} else {DEFAULT_DELAY};
// No change, fuck off. (why is there no xor?)
if (_set isEqualTo (_unit getVariable ["ACE_isUnconscious", false])) exitWith {};
// Remove maximum unconsciousness time handler
_maxUnconHandle = _unit getVariable [QGVAR(maxUnconTimeHandle), -1];
if (_maxUnconHandle > 0) then {
[_maxUnconHandle] call CBA_fnc_removePerFrameHandler;
};
if !(_set) exitwith {
_unit setvariable ["ACE_isUnconscious", false, true];
};
@ -86,4 +95,14 @@ _startingTime = time;
[DFUNC(unconsciousPFH), 0.1, [_unit,_animState, _originalPos, _startingTime, _minWaitingTime, false, vehicle _unit isKindOf "ParachuteBase"] ] call CBA_fnc_addPerFrameHandler;
// Maximum unconsciousness time
_maxUnconTime = _unit getVariable [QGVAR(maxUnconsciousTime), GVAR(maxUnconsciousTime)];
if (_maxUnconTime >= 0) then {
_handle = [{
_unit = _this select 0;
[_unit] call FUNC(setDead);
}, [_unit], _maxUnconTime, 0.5] call EFUNC(common,waitAndExecute);
_unit setVariable [QGVAR(maxUnconTimeHandle), _handle];
};
["medical_onUnconscious", [_unit, true]] call EFUNC(common,globalEvent);