mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
more common code cleanup
This commit is contained in:
parent
1d4eb209a4
commit
1679235b51
@ -9,35 +9,38 @@
|
||||
* animation <STRING>
|
||||
*
|
||||
* Example:
|
||||
* [bob] call ace_common_fnc_getDeathAnim;
|
||||
* [bob] call ace_common_fnc_getDeathAnim
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_1(_unit);
|
||||
params ["_unit"];
|
||||
|
||||
private ["_returnAnimation", "_animationState", "_unitAnimationCfg", "_unitActionsCfg", "_interpolateArray", "_indexAnimation", "_index"];
|
||||
private ["_returnAnimation", "_animationState", "_unitAnimationCfg", "_unitActionsCfg", "_interpolateArray", "_indexAnimation"];
|
||||
|
||||
_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};
|
||||
_animationState = animationState _unit;
|
||||
_unitAnimationCfg = configFile >> "CfgMovesMaleSdr" >> "States" >> _animationState;
|
||||
|
||||
_unitActionsCfg = (configFile >> "CfgMovesBasic" >> "Actions" >> (getText (_unitAnimationCfg >> "actions")));
|
||||
//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 {
|
||||
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 {
|
||||
if (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> _indexAnimation >> "terminal") == 1) exitWith {
|
||||
_returnAnimation = _indexAnimation;
|
||||
};
|
||||
};
|
||||
|
@ -1,29 +1,47 @@
|
||||
// by commy2
|
||||
/*
|
||||
* Author: commy2
|
||||
* Get the Defualt animation for the unit
|
||||
*
|
||||
* Arguments:
|
||||
* 0: unit <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* animation <STRING>
|
||||
*
|
||||
* Example:
|
||||
* [bob] call ace_common_fnc_getDefaultAnim;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit"];
|
||||
|
||||
private ["_anim", "_stance"];
|
||||
|
||||
PARAMS_1(_unit);
|
||||
_anim = toLower (animationState _unit);
|
||||
_anim = toLower animationState _unit;
|
||||
|
||||
// stance is broken for some animations.
|
||||
_stance = stance _unit;
|
||||
|
||||
if (_anim find "ppne" == 4) then {
|
||||
_stance = "PRONE";
|
||||
_stance = "PRONE";
|
||||
};
|
||||
|
||||
if (_anim find "pknl" == 4) then {
|
||||
_stance = "CROUCH";
|
||||
_stance = "CROUCH";
|
||||
};
|
||||
|
||||
if (_anim find "perc" == 4) then {
|
||||
_stance = "STAND";
|
||||
_stance = "STAND";
|
||||
};
|
||||
|
||||
_anim = format ["AmovP%1M%2S%3W%4D%5",
|
||||
["erc", "knl", "pne"] select (["STAND", "CROUCH", "PRONE"] find _stance) max 0,
|
||||
["stp", "run"] select (vectorMagnitude velocity _unit > 1),
|
||||
[["ras", "low"] select weaponLowered _unit, "non"] select (currentWeapon _unit == ""),
|
||||
["non", "rfl", "lnr", "pst", "bin"] select (["", primaryWeapon _unit, secondaryWeapon _unit, handgunWeapon _unit, binocular _unit] find currentWeapon _unit) max 0,
|
||||
["non", _anim select [count _anim - 1, 1]] select (_anim select [count _anim - 2, 2] in ["df", "db", "dl", "dr"])
|
||||
["erc", "knl", "pne"] select (["STAND", "CROUCH", "PRONE"] find _stance) max 0,
|
||||
["stp", "run"] select (vectorMagnitude velocity _unit > 1),
|
||||
[["ras", "low"] select weaponLowered _unit, "non"] select (currentWeapon _unit == ""),
|
||||
["non", "rfl", "lnr", "pst", "bin"] select (["", primaryWeapon _unit, secondaryWeapon _unit, handgunWeapon _unit, binocular _unit] find currentWeapon _unit) max 0,
|
||||
["non", _anim select [count _anim - 1, 1]] select (_anim select [count _anim - 2, 2] in ["df", "db", "dl", "dr"])
|
||||
];
|
||||
|
||||
["", _anim] select isClass (configFile >> "CfgMovesMaleSdr" >> "States" >> _anim)
|
||||
|
@ -1,33 +1,38 @@
|
||||
/**
|
||||
* fn_getVariable.sqf
|
||||
* @Descr: Grabs a variable. If variable has not been set, attempts to use default defined value
|
||||
* @Author: Glowbal
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Grabs a variable. If variable has not been set, attempts to use default defined value
|
||||
*
|
||||
* @Arguments: [unit OBJECT, variableName STRING]
|
||||
* @Return: ANY
|
||||
* @PublicAPI: true
|
||||
* Arguments:
|
||||
* 0: unit <OBJECT>
|
||||
* 1: Variable Name <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* Value of variable or default value, if the variable is undefined <ANY>
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
#define UNIT (_this select 0)
|
||||
#define VARIABLE (_this select 1)
|
||||
params ["_unit", "_variable", "_defaultValue"];
|
||||
|
||||
private "_value";
|
||||
_value = _unit getvariable _variable;
|
||||
|
||||
_value = UNIT getvariable VARIABLE;
|
||||
if (isnil "_value") then {
|
||||
if (count _this >2) then {
|
||||
_value = _this select 2;
|
||||
if (isNil "_value") then {
|
||||
if (!isNil "_defaultValue") then {
|
||||
_value = _defaultValue;
|
||||
} else {
|
||||
private "_definedVariable";
|
||||
_definedVariable = ([VARIABLE] call FUNC(getDefinedVariableInfo));
|
||||
_definedVariable = [_variable] call FUNC(getDefinedVariableInfo);
|
||||
|
||||
if (count _definedVariable > 1) then {
|
||||
_value = _definedVariable select 1;
|
||||
};
|
||||
};
|
||||
if (isnil "_value") then {
|
||||
|
||||
if (isNil "_value") then {
|
||||
_value = 0;
|
||||
};
|
||||
};
|
||||
_value
|
||||
|
||||
_value
|
||||
|
@ -1,19 +1,24 @@
|
||||
/**
|
||||
* fn_getvariableDefault.sqf
|
||||
* @Descr: Get the variable default value
|
||||
* @Author: Glowbal
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Get the variable default value
|
||||
*
|
||||
* @Arguments: [variableName STRING]
|
||||
* @Return: ANY
|
||||
* @PublicAPI: true
|
||||
* Arguments:
|
||||
* 0: Variable Name <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* Default value of variable <ANY>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_varName"];
|
||||
|
||||
private "_variableDefinition";
|
||||
_variableDefinition = ([_this select 0] call FUNC(getDefinedVariableInfo));
|
||||
if (count _variableDefinition > 0) exitwith {
|
||||
_variableDefinition = [_varName] call FUNC(getDefinedVariableInfo);
|
||||
|
||||
if !(_variableDefinition isEqualTo []) exitwith {
|
||||
_variableDefinition select 1;
|
||||
};
|
||||
|
||||
nil;
|
||||
nil
|
||||
|
@ -1,12 +1,17 @@
|
||||
/**
|
||||
* fn_getvariableInfo.sqf
|
||||
* @Descr: N/A
|
||||
* @Author: Glowbal
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Get the variable Informations
|
||||
*
|
||||
* @Arguments: []
|
||||
* @Return:
|
||||
* @PublicAPI: false
|
||||
* Arguments:
|
||||
* 0: Variable Name <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* Variable Metadata <ARRAY>
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
+(missionNamespace getvariable [QGVAR(OBJECT_VARIABLES_STORAGE_) + (_this select 0),[]])
|
||||
|
||||
params ["_varName"];
|
||||
|
||||
+ (missionNamespace getVariable [format [QGVAR(OBJECT_VARIABLES_STORAGE_%1), _varName], []])
|
||||
|
@ -1,15 +1,31 @@
|
||||
// by commy2
|
||||
/*
|
||||
* Author: commy2
|
||||
* Get display classnames from config with given idd.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Display ID (idd) <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* Display Classnames <ARRAY>
|
||||
*
|
||||
* Public: Yes
|
||||
*
|
||||
* Note: Really slow due to iteration through whole config. Meant for debugging.
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_configName", "_index", "_config"];
|
||||
params ["_idd"];
|
||||
|
||||
_configName = "";
|
||||
private ["_configNames", "_config"];
|
||||
|
||||
_configNames = [];
|
||||
|
||||
for "_index" from 0 to (count configFile - 1) do {
|
||||
_config = configFile select _index;
|
||||
if (isClass _config && {isNumber (_config >> "idd")} && {getNumber (_config >> "idd") == _this}) exitWith {
|
||||
_configName = configName _config;
|
||||
|
||||
if (isClass _config && {isNumber (_config >> "idd")} && {getNumber (_config >> "idd") == _idd}) then {
|
||||
_configNames pushBack configName _config;
|
||||
};
|
||||
};
|
||||
|
||||
_configName
|
||||
_configNames
|
||||
|
@ -1,19 +1,20 @@
|
||||
/*
|
||||
* Author: bux578
|
||||
* Returns all turret indecies of door gunners.
|
||||
*
|
||||
* Gets the turret index of door gunners
|
||||
* Arguments:
|
||||
* 0: Vehicle <OBJECT>
|
||||
*
|
||||
* Argument:
|
||||
* 0: Vehicle (Object)
|
||||
* Return Value:
|
||||
* All turret indecies of the Vehicle <ARRAY>
|
||||
*
|
||||
* Return value:
|
||||
* Turret indexes of the door gunner. Empty array means no gunner position. (Array)
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_turrets", "_doorTurrets", "_config"];
|
||||
params ["_vehicle"];
|
||||
|
||||
PARAMS_1(_vehicle);
|
||||
private ["_turrets", "_doorTurrets", "_config"];
|
||||
|
||||
_turrets = allTurrets [_vehicle, true];
|
||||
|
||||
@ -21,11 +22,13 @@ _doorTurrets = [];
|
||||
|
||||
{
|
||||
_config = configFile >> "CfgVehicles" >> typeOf _vehicle;
|
||||
|
||||
_config = [_config, _x] call FUNC(getTurretConfigPath);
|
||||
|
||||
if ((getNumber (_config >> "isCopilot") == 0) && count (getArray (_config >> "weapons")) > 0 ) then {
|
||||
if (getNumber (_config >> "isCopilot" == 0) && {count getArray (_config >> "weapons") > 0}) then {
|
||||
_doorTurrets pushBack _x;
|
||||
};
|
||||
} forEach _turrets;
|
||||
false
|
||||
} count _turrets;
|
||||
|
||||
_doorTurrets
|
||||
|
@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Author: Nou
|
||||
*
|
||||
* Execute a global event on all clients, including self.
|
||||
*
|
||||
* Arguments:
|
||||
|
Loading…
Reference in New Issue
Block a user