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
a98a45e5d1
commit
ffc5a16384
@ -1,30 +1,40 @@
|
||||
/**
|
||||
* fn_getAllSetVariables.sqf
|
||||
* @Descr: Returns an 2d array of all variables that have been set on the object
|
||||
* @Author: Glowbal
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Returns an 2d array of all variables that have been set on the object
|
||||
*
|
||||
* @Arguments: [unit OBJECT, category STRING (Optional. Only get the variables from the specified category. Default is "" == all)]
|
||||
* @Return: ARRAY REturns an array with the format [ [name STRING, typeName STRING, value ANY, publicFlag BOOL, peristentFlag BOOL] ]
|
||||
* @PublicAPI: true
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
* 1: Limiting Category (default: "") <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* Variable Data <ARRAY>
|
||||
* 0: Name <STRING>
|
||||
* 1: typeName <STRING>
|
||||
* 2: value <ANY>
|
||||
* 3: publicFlag <BOOL>
|
||||
* 4: peristentFlag <BOOL>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_return", "_val", "_category"];
|
||||
PARAMS_1(_object);
|
||||
_category = if (count _this > 1) then { _this select 1 } else { "" };
|
||||
params ["_object", ["_category", ""]];
|
||||
|
||||
if (isnil QGVAR(OBJECT_VARIABLES_STORAGE)) exitwith {
|
||||
[];
|
||||
};
|
||||
if (isNil QGVAR(OBJECT_VARIABLES_STORAGE)) exitwith {[]};
|
||||
|
||||
private ["_return", "_val"];
|
||||
|
||||
_return = [];
|
||||
|
||||
{
|
||||
_val = _object getvariable (_x select 0);
|
||||
if (!isnil "_val") then {
|
||||
|
||||
if (!isNil "_val") then {
|
||||
if (_category == "" || _category == _x select 3) then {
|
||||
_return pushback [_x select 0, typeName _val, _val, _x select 2, _x select 5];
|
||||
_return pushBack [_x select 0, typeName _val, _val, _x select 2, _x select 5];
|
||||
};
|
||||
};
|
||||
}foreach GVAR(OBJECT_VARIABLES_STORAGE);
|
||||
_return
|
||||
false
|
||||
} count GVAR(OBJECT_VARIABLES_STORAGE);
|
||||
|
||||
_return
|
||||
|
@ -1,28 +1,29 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Get the config path of a vehicles turret.
|
||||
*
|
||||
* Argument:
|
||||
* 0: vehicles config (Config)
|
||||
* 1: Turret index (Array)
|
||||
* Arguments:
|
||||
* 0: Vehicle Config <CONFIG>
|
||||
* 1: Turret indecies <ARRAY>
|
||||
*
|
||||
* Return value:
|
||||
* Turret config (Config)
|
||||
* Return Value:
|
||||
* Turret config <CONFIG>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_index", "_offset", "_config2", "_foundClasses", "_a"];
|
||||
params ["_config", "_turretIndex"];
|
||||
|
||||
PARAMS_2(_config,_turretIndex);
|
||||
private ["_offset", "_config2", "_foundClasses"];
|
||||
|
||||
for "_index" from 0 to (count _turretIndex - 1) do {
|
||||
_config = _config >> "Turrets";
|
||||
|
||||
_offset = 0;
|
||||
_config2 = _config select 0;
|
||||
|
||||
_foundClasses = 0;
|
||||
|
||||
for "_a" from 0 to (count _config - 1) do {
|
||||
if (isClass _config2) then {
|
||||
_foundClasses = _foundClasses + 1;
|
||||
@ -33,6 +34,8 @@ for "_index" from 0 to (count _turretIndex - 1) do {
|
||||
|
||||
if (_foundClasses == _turretIndex select _index) exitWith {};
|
||||
};
|
||||
|
||||
_config = _config2;
|
||||
};
|
||||
|
||||
_config
|
||||
|
@ -1,37 +1,47 @@
|
||||
/*
|
||||
* Author: jaynus
|
||||
*
|
||||
* Get the absolute turret direction for FOV/PIP turret.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Vehicle (Object)
|
||||
* 1: Turret Position
|
||||
* Arguments:
|
||||
* 0: Vehicle <OBJECT>
|
||||
* 1: Turret Position <ARRAY>
|
||||
*
|
||||
* Return value:
|
||||
* [position, direction]
|
||||
* Return Value:
|
||||
* 0: Position ASL <ARRAY>
|
||||
* 1: Direction <ARRAY>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_2(_vehicle,_position);
|
||||
private ["_turret", "_povPos", "_povDir", "_gunBeginPos", "_gunEndPos", "_pov", "_gunBeg", "_gunEnd", "_pipDir"];
|
||||
params ["_vehicle", "_position"];
|
||||
|
||||
private ["_turret", "_pov", "_gunBeg", "_gunEnd", "_povPos", "_povDir"];
|
||||
|
||||
_turret = [_vehicle, _position] call CBA_fnc_getTurret;
|
||||
|
||||
_pov = getText (_turret >> "memoryPointGunnerOptics");
|
||||
_gunBeg = getText (_turret >> "gunBeg");
|
||||
_gunEnd = getText (_turret >> "gunEnd");
|
||||
_gunEnd = getText (_turret >> "gunEnd");
|
||||
|
||||
TRACE_3("", _pov, _gunBeg, _gunEnd);
|
||||
|
||||
// Pull the PIP pov or barrel direction, depending on how the model is set up
|
||||
_povPos = ATLtoASL ( _vehicle modelToWorldVisual (_vehicle selectionPosition _pov ) );
|
||||
_povPos = ATLtoASL (_vehicle modelToWorldVisual (_vehicle selectionPosition _pov)); //@todo AGLToASL ?
|
||||
_povDir = [0,0,0];
|
||||
|
||||
if (_pov == "pip0_pos") then {
|
||||
_pipDir = ATLtoASL ( _vehicle modelToWorldVisual (_vehicle selectionPosition "pip0_dir" ) );
|
||||
private "_pipDir";
|
||||
_pipDir = ATLtoASL (_vehicle modelToWorldVisual (_vehicle selectionPosition "pip0_dir"));
|
||||
|
||||
_povDir = _pipDir vectorDiff _povPos;
|
||||
} else {
|
||||
_gunBeginPos = ATLtoASL ( _vehicle modelToWorldVisual (_vehicle selectionPosition _gunBeg ) );
|
||||
_gunEndPos = ATLtoASL ( _vehicle modelToWorldVisual (_vehicle selectionPosition _gunEnd ) );
|
||||
private ["_gunBeginPos", "_gunEndPos"];
|
||||
|
||||
_gunBeginPos = ATLtoASL (_vehicle modelToWorldVisual (_vehicle selectionPosition _gunBeg));
|
||||
_gunEndPos = ATLtoASL (_vehicle modelToWorldVisual (_vehicle selectionPosition _gunEnd));
|
||||
|
||||
_povDir = _gunBeginPos vectorDiff _gunEndPos;
|
||||
};
|
||||
|
||||
[_povPos, _povDir]
|
||||
[_povPos, _povDir]
|
||||
|
@ -1,19 +1,21 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Get the turret index of a units current turret.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Unit, not the vehicle (as in not a car but the player) (Object)
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
*
|
||||
* Return value:
|
||||
* Turret index array or config path. E.g: [0] for gunner or [0,0] for commander. Returns empty array if unit is not in a turret. (Array)
|
||||
* Return Value:
|
||||
* Turret Index <ARRAY>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit"];
|
||||
|
||||
private ["_vehicle", "_turrets", "_units", "_index"];
|
||||
|
||||
PARAMS_1(_unit);
|
||||
_vehicle = vehicle _unit;
|
||||
|
||||
if (_unit == _vehicle) exitWith {[]};
|
||||
@ -21,9 +23,11 @@ if (_unit == _vehicle) exitWith {[]};
|
||||
_turrets = allTurrets [_vehicle, true];
|
||||
|
||||
_units = [];
|
||||
|
||||
{
|
||||
_units pushBack (_vehicle turretUnit _x);
|
||||
} forEach _turrets;
|
||||
_units pushBack (_vehicle turretUnit _x);
|
||||
false
|
||||
} count _turrets;
|
||||
|
||||
_index = _units find _unit;
|
||||
|
||||
|
@ -1,37 +1,45 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
* Get all turret indicies of a vehicle type.
|
||||
*
|
||||
* Get all turret indicies of a vehicle.
|
||||
* Arguments:
|
||||
* 0: Vehicle type <STRING>
|
||||
*
|
||||
* Argument:
|
||||
* 0: Vehicle type (String)
|
||||
* Return Value:
|
||||
* Turret Indecies <ARRAY>
|
||||
*
|
||||
* Return value:
|
||||
* All turret index arrays of the vehicle. E.g: [[0], [0,0]] (Array)
|
||||
* Public: Yes
|
||||
*
|
||||
* Note: It's advised to use allTurrets [_vehicle, true] instead whenever possible
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_config", "_turrets", "_fnc_addTurret", "_varName"];
|
||||
params ["_type"];
|
||||
|
||||
PARAMS_1(_type);
|
||||
private ["_varName", "_turrets"];
|
||||
|
||||
_varName = format ["ACE_CachedTurrets_%1", _type];
|
||||
_varName = format [QGVAR(CachedTurrets_%1), _type];
|
||||
_turrets = + (uiNamespace getVariable _varName);
|
||||
|
||||
if (!isNil "_turrets") exitWith {_turrets};
|
||||
|
||||
private ["_config", "_fnc_addTurret"];
|
||||
|
||||
_config = configFile >> "CfgVehicles" >> _type;
|
||||
|
||||
_turrets = [];
|
||||
_fnc_addTurret = {
|
||||
private ["_count", "_offset", "_index", "_path2", "_config2"];
|
||||
|
||||
PARAMS_2(_config,_path);
|
||||
_fnc_addTurret = {
|
||||
params ["_config", "_path"];
|
||||
|
||||
_config = _config >> "Turrets";
|
||||
|
||||
private ["_count", "_offset", "_path2", "_config2"];
|
||||
|
||||
_count = count _config;
|
||||
|
||||
_offset = 0;
|
||||
|
||||
for "_index" from 0 to (_count - 1) do {
|
||||
_path2 = _path + [_index - _offset];
|
||||
_config2 = _config select _index;
|
||||
|
Loading…
Reference in New Issue
Block a user