weaponsTurret: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "<code>([^ ]*)\[\[([a-zA-Z][a-zA-Z0-9_]+)\]\]([^ ]*)<\/code>" to "<code>$1$2$3</code>")
m (Text replacement - "<code>([^<]*)\[\[([^|]+\|)?(.+)\]\]([^<]*)<\/code>" to "<code$1$3$4</code>")
Line 44: Line 44:
<dd class="note">
<dd class="note">
Returns information (including the turrets paths) about all weapons on turrets
Returns information (including the turrets paths) about all weapons on turrets
<code>funcGetTurretsWeapons = {
<codefuncGetTurretsWeapons = {
[[private]] ["_result", "_getAnyMagazines", "_findRecurse", "_class"];
[[private]] ["_result", "_getAnyMagazines", "_findRecurse", "_class"];
_result = [];
_result = [];
Line 61: Line 61:
[[private]] ["_root", "_class", "_path", "_currentPath"];
[[private]] ["_root", "_class", "_path", "_currentPath"];
_root = ([[Magic Variables#this|_this]] [[select]] 0);
_root = ([[Magic Variables#this|_this]] [[select]] 0);
_path = +([[Magic Variables#this|_this]] [[select]] 1);
_path = +([[Magic Variables#this|_this]] _this) [[do]] {
[[for]] "_i" [[from]] 0 [[to]] [[count]] _root -1 [[do]] {
_class = _root [[select]] _i;
[[if]] ([[isClass]] _class) [[then]] {
_currentPath = _path + [_i];
{
_result [[set]] [<nowiki/>[[count]] _result, [_x, _x [[call]] _getAnyMagazines, _currentPath, [[str]] _class]];
} [[forEach]] [[getArray]] (_class >> "weapons");
_class = _class >> "turrets";
[[if]] ([[isClass]] _class) [[then]] {
[_class, _currentPath] [[call]] _findRecurse;
};
};
};
};
_class = (
[[configFile]] >> "CfgVehicles" >> (
[[switch]] ([[typeName]] [[Magic Variables#this|_this]]) [[do]] {
[[case]] "STRING" : {[[Magic Variables#this|_this]]};
[[case]] "STRING" : {[[Magic Variables#this|_this]]};
[[case]] "OBJECT" : {[[typeOf]] [[Magic Variables#this|_this]]};
[[case]] "OBJECT" : {[[typeOf]] [[Magic Variables#this|_this]]};

Revision as of 08:39, 13 May 2022

Hover & click on the images for description

Description

Description:
Returns all weapons of given turret. Use turret path [-1] for driver's turret.
Groups:
Turrets

Syntax

Syntax:
vehicle weaponsTurret turretPath
Parameters:
vehicle: Object
turretPath: Array
Return Value:
Array of Strings

Examples

Example 1:
_weapons = vehicle player weaponsTurret [0,0]
Example 2:
_weapons = _tank weaponsTurret [0]
Example 3:
_driverWeapon = _ka50pilot weaponsTurret [-1]
Example 4:
_weaponsForAnyTurrentPosition = (vehicle player) weaponsTurret ((assignedVehicleRole player) select 1)

Additional Information

See also:
addMagazineTurret magazinesTurret removeMagazinesTurret removeMagazineTurret weapons assignedVehicleRole addWeaponTurret removeWeaponTurret turretLocal

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
Posted on 11 March 2011
kju
Use assignedVehicleRole in combination to easily determine the weapons for any vehicle position. You need to check for -1 if the unit is in the driver/pilot position. See example 3 and 4.
Posted on 11 March 2011
DenV
Returns information (including the turrets paths) about all weapons on turrets <codefuncGetTurretsWeapons = { private ["_result", "_getAnyMagazines", "_findRecurse", "_class"]; _result = []; _getAnyMagazines = { private ["_weapon", "_mags"]; _weapon = configFile >> "CfgWeapons" >> _this; _mags = []; { _mags = _mags + getArray ( (if (_x == "this") then { _weapon } else { _weapon >> _x }) >> "magazines" ) } forEach getArray (_weapon >> "muzzles"); _mags }; _findRecurse = { private ["_root", "_class", "_path", "_currentPath"]; _root = (_this select 0); _path = +(_this _this) do { case "STRING" : {_this}; case "OBJECT" : {typeOf _this}; default {nil} } ) >> "turrets" ); [_class, []] call _findRecurse; _result; }; This call: "M1A2_US_TUSK_MG_EP1" call funcGetTurretsWeapons will return all turrets weapons, its magazines and its paths: [ ["M256", ["20Rnd_120mmSABOT_M1A2", "20Rnd_120mmHE_M1A2"], [0], "bin\config.bin/CfgVehicles/M1A2_US_TUSK_MG_EP1/Turrets/MainTurret"], ["M240_veh", ["100Rnd_762x51_M240", "1200Rnd_762x51_M240"], [0], "bin\config.bin/CfgVehicles/M1A2_US_TUSK_MG_EP1/Turrets/MainTurret"], ["M2BC", ["100Rnd_127x99_M2"], [0, 0], "bin\config.bin/CfgVehicles/M1A2_US_TUSK_MG_EP1/Turrets/MainTurret/Turrets/CommanderOptics"], ["SmokeLauncher", ["SmokeLauncherMag"], [0, 0], "bin\config.bin/CfgVehicles/M1A2_US_TUSK_MG_EP1/Turrets/MainTurret/Turrets/CommanderOptics"], ["M240_veh_2", ["100Rnd_762x51_M240", "1200Rnd_762x51_M240"], [0, 1], "bin\config.bin/CfgVehicles/M1A2_US_TUSK_MG_EP1/Turrets/MainTurret/Turrets/LoaderTurret"] ]