mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
fixes #699
This commit is contained in:
parent
eb731b1169
commit
008c36ac76
@ -97,6 +97,7 @@ PREP(moduleAssignMedicalFacility);
|
|||||||
PREP(moduleTreatmentConfiguration);
|
PREP(moduleTreatmentConfiguration);
|
||||||
PREP(copyDeadBody);
|
PREP(copyDeadBody);
|
||||||
PREP(requestWoundSync);
|
PREP(requestWoundSync);
|
||||||
|
PREP(unconsciousPFH);
|
||||||
|
|
||||||
GVAR(injuredUnitCollection) = [];
|
GVAR(injuredUnitCollection) = [];
|
||||||
GVAR(IVBags) = [];
|
GVAR(IVBags) = [];
|
||||||
|
@ -22,4 +22,14 @@ if (_local) then {
|
|||||||
if (_unit getvariable[QGVAR(addedToUnitLoop),false]) then {
|
if (_unit getvariable[QGVAR(addedToUnitLoop),false]) then {
|
||||||
[_unit, true] call FUNC(addToInjuredCollection);
|
[_unit, true] call FUNC(addToInjuredCollection);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (count (_unit getvariable [QGVAR(unconsciousArguments), []]) >= 7) then {
|
||||||
|
private "_arguments";
|
||||||
|
_arguments = (_unit getvariable [QGVAR(unconsciousArguments), []]);
|
||||||
|
_arguments set [ 3, time];
|
||||||
|
|
||||||
|
[DFUNC(unconsciousPFH), 0.1, _arguments ] call CBA_fnc_addPerFrameHandler;
|
||||||
|
|
||||||
|
_unit setvariable [QGVAR(unconsciousArguments), nil, true];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
@ -80,81 +80,6 @@ _unit setUnitPos "DOWN";
|
|||||||
|
|
||||||
_startingTime = time;
|
_startingTime = time;
|
||||||
|
|
||||||
[{
|
[DFUNC(unconsciousPFH), 0.1, [_unit,_animState, _originalPos, _startingTime, _minWaitingTime, false, vehicle _unit isKindOf "ParachuteBase"] ] call CBA_fnc_addPerFrameHandler;
|
||||||
private ["_unit", "_vehicleOfUnit","_minWaitingTime", "_oldAnimation", "_captiveSwitch", "_hasMovedOut", "_parachuteCheck"];
|
|
||||||
_args = _this select 0;
|
|
||||||
_unit = _args select 0;
|
|
||||||
_oldAnimation = _args select 1;
|
|
||||||
_originalPos = _args select 2;
|
|
||||||
_startingTime = _args select 3;
|
|
||||||
_minWaitingTime = _args select 4;
|
|
||||||
_hasMovedOut = _args select 5;
|
|
||||||
_parachuteCheck = _args select 6;
|
|
||||||
|
|
||||||
if (!alive _unit) exitwith {
|
|
||||||
[_unit, QGVAR(unconscious), false] call EFUNC(common,setCaptivityStatus);
|
|
||||||
[_unit, false] call EFUNC(common,disableAI);
|
|
||||||
//_unit setUnitPos _originalPos;
|
|
||||||
_unit setUnconscious false;
|
|
||||||
["medical_onUnconscious", [_unit, false]] call EFUNC(common,globalEvent);
|
|
||||||
|
|
||||||
[(_this select 1)] call cba_fnc_removePerFrameHandler;
|
|
||||||
};
|
|
||||||
|
|
||||||
// In case the unit is no longer in an unconscious state, we are going to check if we can already reset the animation
|
|
||||||
if !(_unit getvariable ["ACE_isUnconscious",false]) exitwith {
|
|
||||||
|
|
||||||
// TODO, handle this with carry instead, so we can remove the PFH here.
|
|
||||||
// Wait until the unit isn't being carried anymore, so we won't end up with wierd animations
|
|
||||||
if !(([_unit] call FUNC(isBeingCarried)) || ([_unit] call FUNC(isBeingDragged))) then {
|
|
||||||
if (vehicle _unit == _unit) then {
|
|
||||||
if (animationState _unit == "AinjPpneMstpSnonWrflDnon") then {
|
|
||||||
[_unit,"AinjPpneMstpSnonWrflDnon_rolltofront", 2] call EFUNC(common,doAnimation);
|
|
||||||
[_unit,"amovppnemstpsnonwnondnon", 1] call EFUNC(common,doAnimation);
|
|
||||||
} else {
|
|
||||||
[_unit,"amovppnemstpsnonwnondnon", 2] call EFUNC(common,doAnimation);
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
// Switch to the units original animation, assuming
|
|
||||||
// TODO: what if the unit switched vehicle?
|
|
||||||
[_unit, _oldAnimation, 2] call EFUNC(common,doAnimation);
|
|
||||||
};
|
|
||||||
["medical_onUnconscious", [_unit, false]] call EFUNC(common,globalEvent);
|
|
||||||
// EXIT PFH
|
|
||||||
[(_this select 1)] call cba_fnc_removePerFrameHandler;
|
|
||||||
};
|
|
||||||
if (!_hasMovedOut) then {
|
|
||||||
// Reset the unit back to the previous captive state.
|
|
||||||
[_unit, QGVAR(unconscious), false] call EFUNC(common,setCaptivityStatus);
|
|
||||||
|
|
||||||
// Swhich the unit back to its original group
|
|
||||||
//Unconscious units shouldn't be put in another group #527:
|
|
||||||
// [_unit, false, "ACE_isUnconscious", side group _unit] call EFUNC(common,switchToGroupSide);
|
|
||||||
|
|
||||||
[_unit, false] call EFUNC(common,disableAI);
|
|
||||||
_unit setUnitPos _originalPos; // This is not position but stance (DOWN, MIDDLE, UP)
|
|
||||||
|
|
||||||
_unit setUnconscious false;
|
|
||||||
|
|
||||||
// ensure this statement runs only once
|
|
||||||
_args set [5, true];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
if (_parachuteCheck) then {
|
|
||||||
if !(vehicle _unit isKindOf "ParachuteBase") then {
|
|
||||||
[_unit, [_unit] call EFUNC(common,getDeathAnim), 1, true] call EFUNC(common,doAnimation);
|
|
||||||
_args set [6, false];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
// Ensure we are waiting at least a minimum period before checking if we can wake up the unit again, allows for temp knock outs
|
|
||||||
if ((time - _startingTime) >= _minWaitingTime) exitwith {
|
|
||||||
|
|
||||||
if (!([_unit] call FUNC(getUnconsciousCondition))) then {
|
|
||||||
_unit setvariable ["ACE_isUnconscious", false, true];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}, 0.1, [_unit,_animState, _originalPos, _startingTime, _minWaitingTime, false, vehicle _unit isKindOf "ParachuteBase"] ] call CBA_fnc_addPerFrameHandler;
|
|
||||||
|
|
||||||
["medical_onUnconscious", [_unit, true]] call EFUNC(common,globalEvent);
|
["medical_onUnconscious", [_unit, true]] call EFUNC(common,globalEvent);
|
||||||
|
93
addons/medical/functions/fnc_unconsciousPFH.sqf
Normal file
93
addons/medical/functions/fnc_unconsciousPFH.sqf
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
/*
|
||||||
|
* Author: Glowbal
|
||||||
|
* PFH logic for unconscious state
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: The unit that will be put in an unconscious state <OBJECT>
|
||||||
|
*
|
||||||
|
* ReturnValue:
|
||||||
|
* nil
|
||||||
|
*
|
||||||
|
* Public: yes
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
private ["_unit", "_vehicleOfUnit","_minWaitingTime", "_oldAnimation", "_captiveSwitch", "_hasMovedOut", "_parachuteCheck"];
|
||||||
|
_args = _this select 0;
|
||||||
|
_unit = _args select 0;
|
||||||
|
_oldAnimation = _args select 1;
|
||||||
|
_originalPos = _args select 2;
|
||||||
|
_startingTime = _args select 3;
|
||||||
|
_minWaitingTime = _args select 4;
|
||||||
|
_hasMovedOut = _args select 5;
|
||||||
|
_parachuteCheck = _args select 6;
|
||||||
|
|
||||||
|
if (!alive _unit) exitwith {
|
||||||
|
[_unit, QGVAR(unconscious), false] call EFUNC(common,setCaptivityStatus);
|
||||||
|
[_unit, false] call EFUNC(common,disableAI);
|
||||||
|
//_unit setUnitPos _originalPos;
|
||||||
|
_unit setUnconscious false;
|
||||||
|
["medical_onUnconscious", [_unit, false]] call EFUNC(common,globalEvent);
|
||||||
|
|
||||||
|
[(_this select 1)] call cba_fnc_removePerFrameHandler;
|
||||||
|
};
|
||||||
|
|
||||||
|
// In case the unit is no longer in an unconscious state, we are going to check if we can already reset the animation
|
||||||
|
if !(_unit getvariable ["ACE_isUnconscious",false]) exitwith {
|
||||||
|
// TODO, handle this with carry instead, so we can remove the PFH here.
|
||||||
|
// Wait until the unit isn't being carried anymore, so we won't end up with wierd animations
|
||||||
|
if !(([_unit] call FUNC(isBeingCarried)) || ([_unit] call FUNC(isBeingDragged))) then {
|
||||||
|
if (vehicle _unit == _unit) then {
|
||||||
|
if (animationState _unit == "AinjPpneMstpSnonWrflDnon") then {
|
||||||
|
[_unit,"AinjPpneMstpSnonWrflDnon_rolltofront", 2] call EFUNC(common,doAnimation);
|
||||||
|
[_unit,"amovppnemstpsnonwnondnon", 1] call EFUNC(common,doAnimation);
|
||||||
|
} else {
|
||||||
|
[_unit,"amovppnemstpsnonwnondnon", 2] call EFUNC(common,doAnimation);
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
// Switch to the units original animation, assuming
|
||||||
|
// TODO: what if the unit switched vehicle?
|
||||||
|
[_unit, _oldAnimation, 2] call EFUNC(common,doAnimation);
|
||||||
|
};
|
||||||
|
["medical_onUnconscious", [_unit, false]] call EFUNC(common,globalEvent);
|
||||||
|
// EXIT PFH
|
||||||
|
[(_this select 1)] call cba_fnc_removePerFrameHandler;
|
||||||
|
};
|
||||||
|
if (!_hasMovedOut) then {
|
||||||
|
// Reset the unit back to the previous captive state.
|
||||||
|
[_unit, QGVAR(unconscious), false] call EFUNC(common,setCaptivityStatus);
|
||||||
|
|
||||||
|
// Swhich the unit back to its original group
|
||||||
|
//Unconscious units shouldn't be put in another group #527:
|
||||||
|
// [_unit, false, "ACE_isUnconscious", side group _unit] call EFUNC(common,switchToGroupSide);
|
||||||
|
|
||||||
|
[_unit, false] call EFUNC(common,disableAI);
|
||||||
|
_unit setUnitPos _originalPos; // This is not position but stance (DOWN, MIDDLE, UP)
|
||||||
|
|
||||||
|
_unit setUnconscious false;
|
||||||
|
|
||||||
|
// ensure this statement runs only once
|
||||||
|
_args set [5, true];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
if (_parachuteCheck) then {
|
||||||
|
if !(vehicle _unit isKindOf "ParachuteBase") then {
|
||||||
|
[_unit, [_unit] call EFUNC(common,getDeathAnim), 1, true] call EFUNC(common,doAnimation);
|
||||||
|
_args set [6, false];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!local _unit) exitwith {
|
||||||
|
_args set [ 4, _minWaitingTime - (time - _startingTime)];
|
||||||
|
_unit setvariable [QGVAR(unconsciousArguments), _args, true];
|
||||||
|
[(_this select 1)] call cba_fnc_removePerFrameHandler;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Ensure we are waiting at least a minimum period before checking if we can wake up the unit again, allows for temp knock outs
|
||||||
|
if ((time - _startingTime) >= _minWaitingTime) exitwith {
|
||||||
|
if (!([_unit] call FUNC(getUnconsciousCondition))) then {
|
||||||
|
_unit setvariable ["ACE_isUnconscious", false, true];
|
||||||
|
};
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user