GetDeathAnim

This commit is contained in:
PabstMirror 2015-05-01 03:13:26 -05:00
parent 6115b8d23e
commit 0f736ae684

View File

@ -1,38 +1,45 @@
/**
* 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);
_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 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";
_returnAnimation