From bded34fa23777992af8807a70764680f29861cea Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Fri, 1 May 2015 15:03:05 -0500 Subject: [PATCH] I suck at git redo reverted stuff here --- .../medical/functions/fnc_setUnconscious.sqf | 8 +++- .../medical/functions/fnc_unconsciousPFH.sqf | 46 +++++++++++++++---- 2 files changed, 42 insertions(+), 12 deletions(-) diff --git a/addons/medical/functions/fnc_setUnconscious.sqf b/addons/medical/functions/fnc_setUnconscious.sqf index 0e0e6cf67e..72d297b2c8 100644 --- a/addons/medical/functions/fnc_setUnconscious.sqf +++ b/addons/medical/functions/fnc_setUnconscious.sqf @@ -69,7 +69,11 @@ if (vehicle _unit == _unit) then { }; // We are storing the current animation, so we can use it later on when waking the unit up inside a vehicle -_animState = animationState _unit; +if (vehicle _unit != _unit) then { + _unit setVariable [QGVAR(vehicleAwakeAnim), [(vehicle _unit), (animationState _unit)]]; +}; + +//Save current stance: _originalPos = unitPos _unit; _unit setUnitPos "DOWN"; @@ -94,7 +98,7 @@ _anim = [_unit] call EFUNC(common,getDeathAnim); _startingTime = time; -[DFUNC(unconsciousPFH), 0.1, [_unit,_animState, _originalPos, _startingTime, _minWaitingTime, false, vehicle _unit isKindOf "ParachuteBase"] ] call CBA_fnc_addPerFrameHandler; +[DFUNC(unconsciousPFH), 0.1, [_unit, _originalPos, _startingTime, _minWaitingTime, false, vehicle _unit isKindOf "ParachuteBase"] ] call CBA_fnc_addPerFrameHandler; // unconscious can't talk [_unit, "isUnconscious"] call EFUNC(common,muteUnit); diff --git a/addons/medical/functions/fnc_unconsciousPFH.sqf b/addons/medical/functions/fnc_unconsciousPFH.sqf index bf328648d5..0db57876c9 100644 --- a/addons/medical/functions/fnc_unconsciousPFH.sqf +++ b/addons/medical/functions/fnc_unconsciousPFH.sqf @@ -13,15 +13,14 @@ #include "script_component.hpp" -private ["_unit", "_minWaitingTime", "_oldAnimation", "_hasMovedOut", "_parachuteCheck", "_args", "_originalPos", "_startingTime"]; +private ["_unit", "_minWaitingTime", "_slotInfo", "_hasMovedOut", "_parachuteCheck", "_args", "_originalPos", "_startingTime", "_awakeInVehicleAnimation", "_oldVehicleAnimation", "_vehicle"]; _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; +_originalPos = _args select 1; +_startingTime = _args select 2; +_minWaitingTime = _args select 3; +_hasMovedOut = _args select 4; +_parachuteCheck = _args select 5; if (!alive _unit) exitwith { if (GVAR(moveUnitsFromGroupOnUnconscious)) then { @@ -51,10 +50,37 @@ if !(_unit getvariable ["ACE_isUnconscious",false]) exitwith { [_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); + _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)]; + }; + }; + }; }; + _unit setVariable [QGVAR(vehicleAwakeAnim), nil]; + ["medical_onUnconscious", [_unit, false]] call EFUNC(common,globalEvent); // EXIT PFH [(_this select 1)] call cba_fnc_removePerFrameHandler;