weaponsTurret: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) |
Lou Montana (talk | contribs) m (Text replacement - "user= kju" to "user= .kju") |
||
(68 intermediate revisions by the same user not shown) | |||
Line 14: | Line 14: | ||
|gr1= Turrets | |gr1= Turrets | ||
|descr= Returns all weapons of given turret. Use turret path [-1] for driver's turret. | |descr= Returns all weapons of a given turret. Use turret path [-1] for driver's turret. | ||
|s1= vehicle [[weaponsTurret]] turretPath | |s1= vehicle [[weaponsTurret]] turretPath | ||
Line 20: | Line 20: | ||
|p1= vehicle: [[Object]] | |p1= vehicle: [[Object]] | ||
|p2= turretPath: [[Array]] | |p2= turretPath: [[Array]] format [[Turret Path]] | ||
|r1= [[Array]] of [[String]]s | |r1= [[Array]] of [[String]]s | ||
|x1= < | |x1= <sqf>_weapons = vehicle player weaponsTurret [0,0];</sqf> | ||
|seealso= [[addMagazineTurret]] [[magazinesTurret]] | |x2= <sqf>_weapons = _tank weaponsTurret [0];</sqf> | ||
|x3= <sqf>_driverWeapon = _ka50pilot weaponsTurret [-1];</sqf> | |||
|x4= <sqf>_weaponsForAnyTurrentPosition = (vehicle player) weaponsTurret ((assignedVehicleRole player) select 1);</sqf> | |||
|seealso= [[addMagazineTurret]] [[magazinesTurret]] [[removeMagazinesTurret]] [[removeMagazineTurret]] [[weapons]] [[assignedVehicleRole]] [[addWeaponTurret]] [[removeWeaponTurret]] [[turretLocal]] | |||
}} | }} | ||
{{Note | |||
|user= .kju | |||
|timestamp= 20110311074900 | |||
|text= 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. | |||
}} | |||
{{Note | |||
|user= DenV | |||
|timestamp= 20120530162600 | |||
|text= Returns information (including the turrets paths) about all weapons on turrets | |||
<sqf> | |||
funcGetTurretsWeapons = { | |||
private ["_result", "_getAnyMagazines", "_findRecurse", "_class"]; | |||
Returns information (including the turrets paths) about all weapons on turrets | |||
< | |||
_result = []; | _result = []; | ||
_getAnyMagazines = { | _getAnyMagazines = { | ||
private ["_weapon", "_mags"]; | |||
_weapon = | _weapon = configFile >> "CfgWeapons" >> _this; | ||
_mags = []; | _mags = []; | ||
{ | { | ||
_mags = _mags + | _mags = _mags + getArray ( | ||
(if (_x == "this") | (if (_x == "this") then { _weapon } else { _weapon >> _x }) >> "magazines" | ||
) | ) | ||
} | } forEach getArray (_weapon >> "muzzles"); | ||
_mags | _mags | ||
}; | }; | ||
_findRecurse = { | _findRecurse = { | ||
private ["_root", "_class", "_path", "_currentPath"]; | |||
_root = ( | _root = (_this select 0); | ||
_path = +( | _path = +(_this select 1); | ||
for "_i" from 0 to count _root -1 do { | |||
_class = _root | _class = _root select _i; | ||
if (isClass _class) then { | |||
_currentPath = _path + [_i]; | _currentPath = _path + [_i]; | ||
{ | { | ||
_result | _result set [count _result, [_x, _x call _getAnyMagazines, _currentPath, str _class]]; | ||
} | } forEach getArray (_class >> "weapons"); | ||
_class = _class >> "turrets"; | _class = _class >> "turrets"; | ||
if (isClass _class) then { | |||
[_class, _currentPath] | [_class, _currentPath] call _findRecurse; | ||
}; | }; | ||
}; | }; | ||
Line 77: | Line 79: | ||
}; | }; | ||
_class = ( | _class = ( | ||
configFile >> "CfgVehicles" >> ( | |||
switch (typeName _this) do { | |||
case "STRING" : {_this}; | |||
case "OBJECT" : {typeOf _this}; | |||
default {nil} | |||
} | } | ||
) >> "turrets" | ) >> "turrets" | ||
); | ); | ||
[_class, []] | [_class, []] call _findRecurse; | ||
_result; | _result; | ||
};</ | }; | ||
</sqf> | |||
This call: | This call: | ||
< | <sqf>"M1A2_US_TUSK_MG_EP1" call funcGetTurretsWeapons;</sqf> | ||
will return all turrets weapons, | |||
< | will return all turrets weapons, their magazines and their paths: | ||
<pre>[ | |||
["M256", ["20Rnd_120mmSABOT_M1A2", "20Rnd_120mmHE_M1A2"], [0], "bin\config.bin/CfgVehicles/M1A2_US_TUSK_MG_EP1/Turrets/MainTurret"], | ["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"], | ["M240_veh", ["100Rnd_762x51_M240", "1200Rnd_762x51_M240"], [0], "bin\config.bin/CfgVehicles/M1A2_US_TUSK_MG_EP1/Turrets/MainTurret"], | ||
Line 97: | Line 102: | ||
["SmokeLauncher", ["SmokeLauncherMag"], [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"] | ["M240_veh_2", ["100Rnd_762x51_M240", "1200Rnd_762x51_M240"], [0, 1], "bin\config.bin/CfgVehicles/M1A2_US_TUSK_MG_EP1/Turrets/MainTurret/Turrets/LoaderTurret"] | ||
]</ | ]</pre> | ||
}} | |||
Latest revision as of 20:33, 3 May 2024
Description
- Description:
- Returns all weapons of a given turret. Use turret path [-1] for driver's turret.
- Groups:
- Turrets
Syntax
- Syntax:
- vehicle weaponsTurret turretPath
- Parameters:
- vehicle: Object
- turretPath: Array format Turret Path
- Return Value:
- Array of Strings
Examples
- Example 1:
- Example 2:
- Example 3:
- Example 4:
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 Mar 11, 2011 - 07:49 (UTC)
- 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 May 30, 2012 - 16:26 (UTC)
-
Returns information (including the turrets paths) about all weapons on turrets
This call:funcGetTurretsWeapons = { 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 select 1); for "_i" from 0 to count _root -1 do { _class = _root select _i; if (isClass _class) then { _currentPath = _path + [_i]; { _result set [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 _this) do { case "STRING" : {_this}; case "OBJECT" : {typeOf _this}; default {nil} } ) >> "turrets" ); [_class, []] call _findRecurse; _result; };will return all turrets weapons, their magazines and their 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"] ]