mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge pull request #954 from acemod/medicalFixVehAnimation
Medical fix veh animation
This commit is contained in:
commit
07ec7b96c4
@ -1,38 +1,51 @@
|
||||
/**
|
||||
* fn_getDeathAnim.sqf
|
||||
* @Descr: Get the death animation for the unit at current time
|
||||
* @Author: Glowbal
|
||||
/*
|
||||
* Author: Glowbal, PabstMirror
|
||||
* Get the death animation for the unit at current time
|
||||
*
|
||||
* @Arguments: [unit OBJECT]
|
||||
* @Return: STRING animation
|
||||
* @PublicAPI: true
|
||||
* Arguments:
|
||||
* 0: unit <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* animation <STRING>
|
||||
*
|
||||
* Example:
|
||||
* [bob] call ace_common_fnc_getDeathAnim;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_unit", "_curAnim", "_animation", "_cfg","_unitAnimation", "_animationState"];
|
||||
_unit = _this select 0;
|
||||
PARAMS_1(_unit);
|
||||
|
||||
if (vehicle _unit != _unit) exitwith {
|
||||
_animation = "";
|
||||
_animationState = (animationState _unit);
|
||||
_unitAnimation = (configFile >> "CfgMovesMaleSdr" >> "States" >> _animationState);
|
||||
if (isText (_unitAnimation >> "actions")) then {
|
||||
if ((vehicle _unit) != _unit) then {
|
||||
_cfg = (configFile >> "CfgMovesMaleSdr" >> "States" >> _animationState);
|
||||
if (isArray (_cfg >> "interpolateTo")) then {
|
||||
_animation = getArray (_cfg >> "interpolateTo") select 0;
|
||||
};
|
||||
} else {
|
||||
_cfg = (configFile >> "CfgMovesBasic" >> "Actions" >> (getText (_unitAnimation >> "actions")) >> "die");
|
||||
if (isText _cfg) then {
|
||||
_animation = getText _cfg;
|
||||
};
|
||||
private ["_returnAnimation", "_animationState", "_unitAnimationCfg", "_unitActionsCfg", "_interpolateArray", "_indexAnimation", "_index"];
|
||||
|
||||
_returnAnimation = "";
|
||||
|
||||
_animationState = (animationState _unit);
|
||||
_unitAnimationCfg = (configFile >> "CfgMovesMaleSdr" >> "States" >> _animationState);
|
||||
//If we're already in a terminal animation just return current
|
||||
if ((getNumber (_unitAnimationCfg >> "terminal")) == 1) exitWith {_animationState};
|
||||
|
||||
_unitActionsCfg = (configFile >> "CfgMovesBasic" >> "Actions" >> (getText (_unitAnimationCfg >> "actions")));
|
||||
|
||||
TRACE_2("Animation/Action", configName _unitAnimationCfg, configName _unitActionsCfg);
|
||||
|
||||
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 "terminal" animation
|
||||
//E.G.: interpolateTo[] = {"passenger_apc_generic04still",1,"KIA_passenger_apc_generic04",1};
|
||||
|
||||
if ((getNumber ((configFile >> "CfgMovesMaleSdr" >> "States" >> _indexAnimation) >> "terminal")) == 1) exitWith {
|
||||
_returnAnimation = _indexAnimation;
|
||||
};
|
||||
};
|
||||
if (isnil "_animation") then {
|
||||
_animation = "";
|
||||
};
|
||||
_animation;
|
||||
} else {
|
||||
_returnAnimation = getText (_unitActionsCfg >> "die");
|
||||
};
|
||||
|
||||
"Unconscious";
|
||||
//Fallback if nothing valid found:
|
||||
if (_returnAnimation == "") then {_returnAnimation = "Unconscious"};
|
||||
|
||||
_returnAnimation
|
||||
|
@ -30,7 +30,12 @@ if (!([_unit] call FUNC(isAwake))) then {
|
||||
_vehicle = _this select 1;
|
||||
waituntil {vehicle _unit == _vehicle};
|
||||
sleep 0.5;
|
||||
[_unit,([_unit] call FUNC(getDeathAnim)), 1] call FUNC(doAnimation);
|
||||
|
||||
//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, true] call FUNC(doAnimation);
|
||||
};
|
||||
} else {
|
||||
if ([_unit] call FUNC(isArrested)) then {
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user