weaponsTurret: Difference between revisions
Jump to navigation
Jump to search
m (Text replace - "{{uc:{{PAGENAME}}}}" to "{{uc:{{PAGENAME}}}} {{uc:{{PAGENAME}}}}") |
No edit summary |
||
Line 39: | Line 39: | ||
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. | 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. | ||
<dd class="notedate">Posted on 11 March 2011 | |||
<dt class="note> | |||
<dd class="note"> | |||
Returns information (including the turrets paths) about all weapons on turrets | |||
<pre><nowiki> | |||
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; | |||
};</nowiki></pre> | |||
This call: | |||
"M1A2_US_TUSK_MG_EP1" call funcGetTurretsWeapons | |||
will return all turrets weapons, its magazines and its paths: | |||
<pre><nowiki> | |||
[ | |||
["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"] | |||
] | |||
</nowiki></pre> | |||
[[User:DenV|denisko.redisko (denvdmj)]] | |||
<!-- Note Section END --> | <!-- Note Section END --> |
Revision as of 16:26, 30 May 2012
Description
- Description:
- Returns all weapons of given turret. Use turret path [-1] for driver's turret.
- Groups:
- Uncategorised
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:
- addMagazineTurretmagazinesTurretremoveMagazinesTurretremoveMagazineTurretweaponsassignedVehicleRole
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
Notes
- 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
-
Returns information (including the turrets paths) about all weapons on turrets
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; };
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"] ]
Bottom Section
Categories:
- Scripting Commands
- Introduced with Arma 2: Operation Arrowhead version 1.52
- Arma 2: Operation Arrowhead: New Scripting Commands
- Arma 2: Operation Arrowhead: Scripting Commands
- Command Group: Uncategorised
- ArmA 2 OA: New Scripting Commands List
- Scripting Commands ArmA2
- Scripting Commands Take On Helicopters