ACE3/addons/common/functions/fnc_getDeathAnim.sqf

55 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 ACE_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:
2015-09-20 22:28:25 +00:00
* [bob] call ace_common_fnc_getDeathAnim
2015-05-01 08:13:26 +00:00
*
* Public: No
2015-01-16 23:21:47 +00:00
*/
#include "script_component.hpp"
2015-09-20 22:28:25 +00:00
params ["_unit"];
2015-05-01 08:13:26 +00:00
2015-09-20 22:28:25 +00:00
private ["_returnAnimation", "_animationState", "_unitAnimationCfg", "_unitActionsCfg", "_interpolateArray", "_indexAnimation"];
2015-05-01 08:13:26 +00:00
_returnAnimation = "";
2015-09-20 22:28:25 +00:00
_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
2015-09-20 22:28:25 +00:00
if (getNumber (_unitAnimationCfg >> "terminal") == 1) exitWith {_animationState};
2015-05-01 17:58:56 +00:00
2015-09-20 22:28:25 +00:00
_unitActionsCfg = configFile >> "CfgMovesBasic" >> "Actions" >> getText (_unitAnimationCfg >> "actions");
2015-05-01 08:13:26 +00:00
TRACE_2("Animation/Action", configName _unitAnimationCfg, configName _unitActionsCfg);
2015-09-20 22:28:25 +00:00
if (vehicle _unit != _unit) then {
2015-05-01 08:13:26 +00:00
_interpolateArray = getArray (_unitAnimationCfg >> "interpolateTo");
2015-09-20 22:28:25 +00:00
2015-05-01 08:13:26 +00:00
for "_index" from 0 to (count _interpolateArray - 1) step 2 do {
_indexAnimation = _interpolateArray select _index;
2015-09-20 22:28:25 +00:00
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};
2015-09-20 22:28:25 +00:00
if (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> _indexAnimation >> "terminal") == 1) exitWith {
2015-05-01 08:13:26 +00:00
_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