2015-04-17 19:27:57 +00:00
|
|
|
/*
|
|
|
|
* Author: Glowbal
|
|
|
|
* PFH logic for unconscious state
|
|
|
|
*
|
|
|
|
* Arguments:
|
2015-05-02 03:42:43 +00:00
|
|
|
* 0: PFEH - Args
|
|
|
|
* 0: The unit that will be put in an unconscious state <OBJECT>
|
|
|
|
* 1: unitPos (stance) <STRING>
|
|
|
|
* 2: Starting Time <NUMBER>
|
|
|
|
* 3: Minimum Waiting Time <NUMBER>
|
|
|
|
* 4: Has Moved Out <BOOL>
|
|
|
|
* 5: Parachute Check <BOOL>
|
|
|
|
* 1: PFEH ID <NUMBER>
|
2015-04-17 19:27:57 +00:00
|
|
|
*
|
|
|
|
* ReturnValue:
|
|
|
|
* nil
|
|
|
|
*
|
|
|
|
* Public: yes
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-05-01 20:03:05 +00:00
|
|
|
private ["_unit", "_minWaitingTime", "_slotInfo", "_hasMovedOut", "_parachuteCheck", "_args", "_originalPos", "_startingTime", "_awakeInVehicleAnimation", "_oldVehicleAnimation", "_vehicle"];
|
2015-04-17 19:27:57 +00:00
|
|
|
_args = _this select 0;
|
|
|
|
_unit = _args select 0;
|
2015-05-01 20:03:05 +00:00
|
|
|
_originalPos = _args select 1;
|
|
|
|
_startingTime = _args select 2;
|
|
|
|
_minWaitingTime = _args select 3;
|
|
|
|
_hasMovedOut = _args select 4;
|
|
|
|
_parachuteCheck = _args select 5;
|
2015-04-17 19:27:57 +00:00
|
|
|
|
|
|
|
if (!alive _unit) exitwith {
|
2015-04-20 19:37:30 +00:00
|
|
|
if (GVAR(moveUnitsFromGroupOnUnconscious)) then {
|
|
|
|
[_unit, false, "ACE_isUnconscious", side group _unit] call EFUNC(common,switchToGroupSide);
|
|
|
|
};
|
2015-04-17 19:27:57 +00:00
|
|
|
[_unit, QGVAR(unconscious), false] call EFUNC(common,setCaptivityStatus);
|
|
|
|
[_unit, false] call EFUNC(common,disableAI);
|
|
|
|
//_unit setUnitPos _originalPos;
|
|
|
|
_unit setUnconscious false;
|
2015-04-26 14:47:36 +00:00
|
|
|
|
|
|
|
[_unit, "isUnconscious"] call EFUNC(common,unmuteUnit);
|
2015-04-17 19:27:57 +00:00
|
|
|
["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 {
|
2015-05-01 20:03:05 +00:00
|
|
|
_vehicle = vehicle _unit;
|
|
|
|
_oldVehicleAnimation = _unit getVariable [QGVAR(vehicleAwakeAnim), []];
|
|
|
|
_awakeInVehicleAnimation = "";
|
|
|
|
if (((count _oldVehicleAnimation) > 0) && {(_oldVehicleAnimation select 0) == _vehicle}) then {
|
|
|
|
_awakeInVehicleAnimation = _oldVehicleAnimation select 1;
|
|
|
|
};
|
|
|
|
//Make sure we have a valid, non-terminal animation:
|
|
|
|
if ((_awakeInVehicleAnimation != "") && {(getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> _awakeInVehicleAnimation >> "terminal")) == 0}) then {
|
|
|
|
[_unit, _awakeInVehicleAnimation, 2] call EFUNC(common,doAnimation);
|
|
|
|
} else {
|
|
|
|
//Don't have a valid animation saved, reset the unit animation with a moveInXXX
|
|
|
|
TRACE_1("No Valid Animation, doing seat reset", _awakeInVehicleAnimation);
|
|
|
|
_slotInfo = [];
|
|
|
|
{if ((_x select 0) == _unit) exitWith {_slotInfo = _x;};} forEach (fullCrew _vehicle);
|
|
|
|
if (_slotInfo isEqualTo []) exitWith {ERROR("No _slotInfo?");};
|
|
|
|
//Move the unit out:
|
|
|
|
_unit setPosASL ((getPosASL _unit) vectorAdd [0,0,100]);
|
|
|
|
//Move the unit back into old seat:
|
|
|
|
if ((_slotInfo select 1) == "driver") then {
|
|
|
|
_unit moveInDriver _vehicle;
|
|
|
|
} else {
|
|
|
|
if ((_slotInfo select 1) == "cargo") then {
|
|
|
|
_unit moveInCargo [_vehicle, (_slotInfo select 2)];
|
|
|
|
} else {
|
|
|
|
_unit moveInTurret [_vehicle, (_slotInfo select 3)];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2015-04-17 19:27:57 +00:00
|
|
|
};
|
2015-05-01 20:03:05 +00:00
|
|
|
_unit setVariable [QGVAR(vehicleAwakeAnim), nil];
|
|
|
|
|
2015-04-17 19:27:57 +00:00
|
|
|
["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:
|
2015-04-20 19:37:30 +00:00
|
|
|
if (GVAR(moveUnitsFromGroupOnUnconscious)) then {
|
|
|
|
[_unit, false, "ACE_isUnconscious", side group _unit] call EFUNC(common,switchToGroupSide);
|
|
|
|
};
|
2015-04-17 19:27:57 +00:00
|
|
|
[_unit, false] call EFUNC(common,disableAI);
|
|
|
|
_unit setUnitPos _originalPos; // This is not position but stance (DOWN, MIDDLE, UP)
|
|
|
|
|
|
|
|
_unit setUnconscious false;
|
|
|
|
|
2015-04-26 14:47:36 +00:00
|
|
|
[_unit, "isUnconscious"] call EFUNC(common,unmuteUnit);
|
|
|
|
|
2015-04-17 19:27:57 +00:00
|
|
|
// ensure this statement runs only once
|
2015-05-02 03:42:43 +00:00
|
|
|
_args set [4, true];
|
2015-04-17 19:27:57 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
if (_parachuteCheck) then {
|
|
|
|
if !(vehicle _unit isKindOf "ParachuteBase") then {
|
|
|
|
[_unit, [_unit] call EFUNC(common,getDeathAnim), 1, true] call EFUNC(common,doAnimation);
|
2015-05-02 03:42:43 +00:00
|
|
|
_args set [5, false];
|
2015-04-17 19:27:57 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!local _unit) exitwith {
|
2015-05-21 16:42:44 +00:00
|
|
|
_args set [3, _minWaitingTime - (ACE_time - _startingTime)];
|
2015-04-17 19:27:57 +00:00
|
|
|
_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
|
2015-05-21 16:42:44 +00:00
|
|
|
if ((ACE_time - _startingTime) >= _minWaitingTime) exitwith {
|
2015-04-17 19:27:57 +00:00
|
|
|
if (!([_unit] call FUNC(getUnconsciousCondition))) then {
|
|
|
|
_unit setvariable ["ACE_isUnconscious", false, true];
|
|
|
|
};
|
|
|
|
};
|