Save and replay valid awake animations

This commit is contained in:
PabstMirror 2015-05-01 12:12:13 -05:00
parent 0f736ae684
commit 8d1ac26e24
4 changed files with 50 additions and 14 deletions

View File

@ -31,7 +31,7 @@ if ((vehicle _unit) != _unit) then {
_interpolateArray = getArray (_unitAnimationCfg >> "interpolateTo");
for "_index" from 0 to (count _interpolateArray - 1) step 2 do {
_indexAnimation = _interpolateArray select _index;
//No guarentee that first animation will be right so scan for the first scan for the first "terminal" animation
//No guarentee that first animation will be right so scan for the first "terminal" animation
//E.G.: interpolateTo[] = {"passenger_apc_generic04still",1,"KIA_passenger_apc_generic04",1};
if ((getNumber ((configFile >> "CfgMovesMaleSdr" >> "States" >> _indexAnimation) >> "terminal")) == 1) exitWith {

View File

@ -30,6 +30,12 @@ if (!([_unit] call FUNC(isAwake))) then {
_vehicle = _this select 1;
waituntil {vehicle _unit == _vehicle};
sleep 0.5;
//Save the "awake" animation before applying the death animation
if (vehicle _unit == _vehicle) then {
_unit setVariable [QEGVAR(medical,vehicleAwakeAnim), [_vehicle, (animationState _unit)]];
};
[_unit,([_unit] call FUNC(getDeathAnim)), 1] call FUNC(doAnimation);
};
} else {

View File

@ -17,7 +17,7 @@
#define DEFAULT_DELAY (round(random(10)+5))
private ["_unit", "_set", "_animState", "_originalPos", "_startingTime","_minWaitingTime"];
private ["_unit", "_set", "_originalPos", "_startingTime","_minWaitingTime"];
_unit = _this select 0;
_set = if (count _this > 1) then {_this select 1} else {true};
_minWaitingTime = if (count _this > 2) then {_this select 2} else {DEFAULT_DELAY};
@ -67,7 +67,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";
@ -84,7 +88,7 @@ if (GVAR(moveUnitsFromGroupOnUnconscious)) then {
_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);

View File

@ -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;