ACE3/addons/common/functions/fnc_getDeathAnim.sqf

52 lines
1.7 KiB
Plaintext
Raw Normal View History

2015-05-01 08:13:26 +00:00
/*
* Author: Glowbal, PabstMirror
* Get the death animation for the unit at current time
2015-01-16 23:21:47 +00:00
*
2015-05-01 08:13:26 +00:00
* Arguments:
* 0: unit <OBJECT>
*
* Return Value:
* animation <STRING>
*
* Example:
* [bob] call ace_common_fnc_getDeathAnim;
*
* Public: No
2015-01-16 23:21:47 +00:00
*/
#include "script_component.hpp"
2015-05-01 08:13:26 +00:00
PARAMS_1(_unit);
private ["_returnAnimation", "_animationState", "_unitAnimationCfg", "_unitActionsCfg", "_interpolateArray", "_indexAnimation", "_index"];
_returnAnimation = "";
_animationState = (animationState _unit);
_unitAnimationCfg = (configFile >> "CfgMovesMaleSdr" >> "States" >> _animationState);
2015-05-01 17:58:56 +00:00
//If we're already in a terminal animation just return current
if ((getNumber (_unitAnimationCfg >> "terminal")) == 1) exitWith {_animationState};
2015-05-01 08:13:26 +00:00
_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;
2015-05-01 17:12:13 +00:00
//No guarentee that first animation will be right so scan for the first "terminal" animation
2015-05-01 08:13:26 +00:00
//E.G.: interpolateTo[] = {"passenger_apc_generic04still",1,"KIA_passenger_apc_generic04",1};
if ((getNumber ((configFile >> "CfgMovesMaleSdr" >> "States" >> _indexAnimation) >> "terminal")) == 1) exitWith {
_returnAnimation = _indexAnimation;
2015-01-18 19:09:19 +00:00
};
};
2015-05-01 08:13:26 +00:00
} else {
_returnAnimation = getText (_unitActionsCfg >> "die");
2015-01-16 23:21:47 +00:00
};
2015-01-17 12:54:44 +00:00
2015-05-01 17:58:56 +00:00
//Fallback if nothing valid found:
if (_returnAnimation == "") then {_returnAnimation = "Unconscious"};
2015-05-01 08:13:26 +00:00
_returnAnimation