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 * Author: Glowbal, PabstMirror
* @Descr: Get the death animation for the unit at current time * Get the death animation for the unit at current time
* @Author: Glowbal
* *
* @Arguments: [unit OBJECT] * Arguments:
* @Return: STRING animation * 0: unit <OBJECT>
* @PublicAPI: true *
* Return Value:
* animation <STRING>
*
* Example:
* [bob] call ace_common_fnc_getDeathAnim;
*
* Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_unit", "_curAnim", "_animation", "_cfg","_unitAnimation", "_animationState"]; PARAMS_1(_unit);
_unit = _this select 0;
if (vehicle _unit != _unit) exitwith { private ["_returnAnimation", "_animationState", "_unitAnimationCfg", "_unitActionsCfg", "_interpolateArray", "_indexAnimation", "_index"];
_animation = "";
_animationState = (animationState _unit); _returnAnimation = "";
_unitAnimation = (configFile >> "CfgMovesMaleSdr" >> "States" >> _animationState);
if (isText (_unitAnimation >> "actions")) then { _animationState = (animationState _unit);
if ((vehicle _unit) != _unit) then { _unitAnimationCfg = (configFile >> "CfgMovesMaleSdr" >> "States" >> _animationState);
_cfg = (configFile >> "CfgMovesMaleSdr" >> "States" >> _animationState); _unitActionsCfg = (configFile >> "CfgMovesBasic" >> "Actions" >> (getText (_unitAnimationCfg >> "actions")));
if (isArray (_cfg >> "interpolateTo")) then {
_animation = getArray (_cfg >> "interpolateTo") select 0; TRACE_2("Animation/Action", configName _unitAnimationCfg, configName _unitActionsCfg);
};
} else { if ((vehicle _unit) != _unit) then {
_cfg = (configFile >> "CfgMovesBasic" >> "Actions" >> (getText (_unitAnimation >> "actions")) >> "die"); _interpolateArray = getArray (_unitAnimationCfg >> "interpolateTo");
if (isText _cfg) then { for "_index" from 0 to (count _interpolateArray - 1) step 2 do {
_animation = getText _cfg; _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 { } else {
_animation = ""; _returnAnimation = getText (_unitActionsCfg >> "die");
};
_animation;
}; };
"Unconscious"; _returnAnimation