mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Move the pfh from setDead to a waitAndExecute loop: reviveStepLoop
This commit is contained in:
parent
12895e7983
commit
94e8bee348
@ -64,6 +64,7 @@ PREP(onWoundUpdateRequest);
|
||||
PREP(onPropagateWound);
|
||||
PREP(parseConfigForInjuries);
|
||||
PREP(playInjuredSound);
|
||||
PREP(reviveStateLoop);
|
||||
PREP(selectionNameToNumber);
|
||||
PREP(serverRemoveBody);
|
||||
PREP(setCardiacArrest);
|
||||
|
56
addons/medical/functions/fnc_reviveStateLoop.sqf
Normal file
56
addons/medical/functions/fnc_reviveStateLoop.sqf
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Author: Glowbal, esteldunedain
|
||||
* Loop that handles a unit in the revive state.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
*
|
||||
* ReturnValue:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit"]
|
||||
|
||||
// If locality changed finish the local loop
|
||||
// @todo: reinitiate the loop elsewhere
|
||||
if (!local _unit) exitWith {};
|
||||
|
||||
private _startTime = _unit getVariable [QGVAR(reviveStartTime), 0];
|
||||
|
||||
// Remove heartbeat
|
||||
if (GVAR(level) >= 2) then {
|
||||
if (_unit getVariable [QGVAR(heartRate), 60] > 0) then {
|
||||
_unit setVariable [QGVAR(heartRate), 0];
|
||||
};
|
||||
};
|
||||
|
||||
// If we are in revive state in a blown up vehicle, try to unload so that people can access the body
|
||||
if ((alive _unit) && {(vehicle _unit) != _unit} && {!alive (vehicle _unit)}) then {
|
||||
TRACE_2("Unloading", _unit, vehicle _unit);
|
||||
[_unit] call EFUNC(common,unloadPerson);
|
||||
};
|
||||
|
||||
// If the timer run out, let the unit die and exit the loop
|
||||
if (GVAR(maxReviveTime) > 0 && {ACE_time - _startTime > GVAR(maxReviveTime)}) exitwith {
|
||||
_unit setVariable [QGVAR(inReviveState), nil, true];
|
||||
_unit setVariable [QGVAR(reviveStartTime), nil];
|
||||
[_unit, true] call FUNC(setDead);
|
||||
};
|
||||
|
||||
// If the unit was taken out from revive state, exit the loop
|
||||
if !(_unit getVariable [QGVAR(inReviveState), false]) exitwith {
|
||||
// Revived without dieing, so in case we have lifes, remove one.
|
||||
if (GVAR(amountOfReviveLives) > 0) then {
|
||||
_lifesLeft = _unit getVariable[QGVAR(amountOfReviveLives), GVAR(amountOfReviveLives)];
|
||||
_unit setVariable [QGVAR(amountOfReviveLives), _lifesLeft - 1, true];
|
||||
};
|
||||
|
||||
_unit setVariable [QGVAR(reviveStartTime), nil];
|
||||
};
|
||||
|
||||
// Schedule the loop to be executed again 1 sec later
|
||||
[DFUNC(reviveStateLoop), [_unit], 1] call EFUNC(common,waitAndExecute);
|
@ -41,41 +41,8 @@ if (((_reviveVal == 1 && {[_unit] call EFUNC(common,isPlayer)} || _reviveVal ==
|
||||
_unit setVariable [QGVAR(reviveStartTime), ACE_time];
|
||||
[_unit, true] call FUNC(setUnconscious);
|
||||
|
||||
[{
|
||||
private "_startTime";
|
||||
params ["_args", "_idPFH"];
|
||||
_args params ["_unit"];
|
||||
_startTime = _unit getVariable [QGVAR(reviveStartTime), 0];
|
||||
|
||||
//If we are in reivie state in a blown up vehicle, try to unload so that people can access the body
|
||||
if ((alive _unit) && {(vehicle _unit) != _unit} && {!alive (vehicle _unit)}) then {
|
||||
TRACE_2("Unloading", _unit, vehicle _unit);
|
||||
[_unit] call EFUNC(common,unloadPerson);
|
||||
};
|
||||
|
||||
if (GVAR(maxReviveTime) > 0 && {ACE_time - _startTime > GVAR(maxReviveTime)}) exitwith {
|
||||
[_idPFH] call CBA_fnc_removePerFrameHandler;
|
||||
_unit setVariable [QGVAR(inReviveState), nil, true];
|
||||
_unit setVariable [QGVAR(reviveStartTime), nil];
|
||||
[_unit, true] call FUNC(setDead);
|
||||
};
|
||||
|
||||
if !(_unit getVariable [QGVAR(inReviveState), false]) exitwith {
|
||||
// revived without dieing, so in case we have lifes, remove one.
|
||||
if (GVAR(amountOfReviveLives) > 0) then {
|
||||
_lifesLeft = _unit getVariable[QGVAR(amountOfReviveLives), GVAR(amountOfReviveLives)];
|
||||
_unit setVariable [QGVAR(amountOfReviveLives), _lifesLeft - 1, true];
|
||||
};
|
||||
|
||||
_unit setVariable [QGVAR(reviveStartTime), nil];
|
||||
[_idPFH] call CBA_fnc_removePerFrameHandler;
|
||||
};
|
||||
if (GVAR(level) >= 2) then {
|
||||
if (_unit getVariable [QGVAR(heartRate), 60] > 0) then {
|
||||
_unit setVariable [QGVAR(heartRate), 0];
|
||||
};
|
||||
};
|
||||
}, 1, [_unit] ] call CBA_fnc_addPerFrameHandler;
|
||||
// Run the loop that tracks the revive state
|
||||
[_unit ] call FUNC(reviveStateLoop);
|
||||
false;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user