Removed last remaining spawns and sleeps in medical.

This commit is contained in:
Thomas Kooi 2015-01-25 15:41:29 +01:00
parent 8045ebb6ab
commit 5f8a00a45f
2 changed files with 35 additions and 18 deletions

View File

@ -72,24 +72,35 @@ if (count _attributes > 1) then {
if (_totalUsed > 10) then {
[_target] call EFUNC(common,setDead);
};
_wearOff = _wearOff + (round(random(30)));
[{
_target = _this select 0;
_wearOff = _this select 1;
_var = _this select 2;
[_target,_wearOff,_var] spawn {
sleep ((_this select 1) + (round(random(30))));
_amountDecreased = 0;
_usedMed = [_this select 0, _this select 2] call EFUNC(common,getDefinedVariable);
if (typeName _usedMed != typeName 0) then {
_usedMed = 0;
};
while {(_usedMed > 0.000000 && _amountDecreased < 1.000000)} do {
_usedMed = ([_this select 0, _this select 2] call EFUNC(common,getDefinedVariable));
if ( typeName _usedMed != typeName 0) then {
_usedMed = 0;
};
[_this select 0, _this select 2,_usedMed - 0.001] call EFUNC(common,setDefinedVariable);
_amountDecreased = _amountDecreased + 0.001;
sleep 1;
if (_usedMed > 0) then {
[{
_args = _this select 0;
_amountDecreased = _args select 3;
_usedMed = ([_args select 0, _args select 2] call EFUNC(common,getDefinedVariable));
[_args select 0, _args select 2,_usedMed - 0.001] call EFUNC(common,setDefinedVariable);
_amountDecreased = _amountDecreased + 0.001;
if (_amountDecreased >= 1 || (_usedMed - 0.001 <= 0)) then {
[(_this select 1)] call cba_fnc_removePerFrameHandler;
};
_args set [3, _amountDecreased];
}, 1, [_target, _wearOff,_var, 0] ] call CBA_fnc_addPerFrameHandler;
};
};
}, [_target, _wearOff, _var], _wearOff, _wearOff] call EFUNC(common,waitAndExecute);
};
private ["_heartRate","_pain"];

View File

@ -23,17 +23,23 @@ _unit setvariable [QGVAR(inCardiacArrest), true,true];
[_unit] call EFUNC(common,setUnconsciousState);
_counter = 120 + round(random(600));
_timer = 0;
while {(_timer < _counter && alive _unit)} do {
[{
_args = _this select 0;
_unit = _args select 0;
_timer = _args select 1;
_counter = _args select 2;
_heartRate = [_unit,QGVAR(heartRate)] call EFUNC(common,getDefinedVariable);
if (_heartRate > 0) exitwith {
[format["%1 is moved out of cardiac: %2",_unit, _heartRate]] call EFUNC(common,debug);
if (_heartRate > 0 || !alive _unit) exitwith {
_unit setvariable [QGVAR(inCardiacArrest), nil,true];
[(_this select 1)] call cba_fnc_removePerFrameHandler;
};
if (_counter - _timer < 1) exitwith {
[_unit] call FUNC(setDead);
[(_this select 1)] call cba_fnc_removePerFrameHandler;
_unit setvariable [QGVAR(inCardiacArrest), nil,true];
};
sleep 1;
_timer = _timer + 1;
};
_args set[1, _timer + 1];
}, 1, [_unit, _timer, _counter] ] call CBA_fnc_addPerFrameHandler;
_unit setvariable [QGVAR(inCardiacArrest), nil,true];