weaponsTurret: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - "[[Category:Scripting_Commands_Take_On_Helicopters" to "[[Category:Scripting Commands Take On Helicopters") |
Lou Montana (talk | contribs) m (Some wiki formatting) |
||
Line 12: | Line 12: | ||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
| vehicle | | vehicle [[weaponsTurret]] turretPath|SYNTAX= | ||
|p1= vehicle: [[Object]] |PARAMETER1= | |p1= vehicle: [[Object]] |PARAMETER1= | ||
|p2= turretPath: [[Array]] |PARAMETER2= | |p2= turretPath: [[Array]] |PARAMETER2= | ||
| [[Array]] of [[String | | [[Array]] of [[String]]s |RETURNVALUE= | ||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
|x1= <code>_weapons | |x1= <code>_weapons = vehicle player [[weaponsTurret]] [0,0]</code> |EXAMPLE1= | ||
|x2= <code>_weapons | |x2= <code>_weapons = _tank [[weaponsTurret]] [0]</code> |EXAMPLE2= | ||
|x3= <code>_driverWeapon | |x3= <code>_driverWeapon = _ka50pilot [[weaponsTurret]] [-1]</code> |EXAMPLE3= | ||
|x4= <code>_weaponsForAnyTurrentPosition | |x4= <code>_weaponsForAnyTurrentPosition = ([[vehicle]] [[player]]) [[weaponsTurret]] (([[assignedVehicleRole]] [[player]]) [[select]] 1)</code> |EXAMPLE4= | ||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
Line 35: | Line 36: | ||
<dd class="notedate">Posted on 11 March 2011 | <dd class="notedate">Posted on 11 March 2011 | ||
<dt class="note> | <dt class="note">[[User:kju|kju]] | ||
<dd class="note"> | <dd class="note"> | ||
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 | <dd class="notedate">Posted on 11 March 2011 | ||
<dt class="note> | <dt class="note">[[User:DenV|DenV]] | ||
<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 = { | ||
[[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]] [<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]] [[_this]]) [[do]] { | |||
[[case]] "STRING" : {[[_this]]}; | |||
[[case]] "OBJECT" : {[[typeOf]] [[_this]]}; | |||
[[default]] {[[nil]]} | |||
} | |||
) >> "turrets" | |||
); | |||
[_class, []] [[call]] _findRecurse; | |||
_result; | |||
};</code> | |||
This call: | This call: | ||
<code>"M1A2_US_TUSK_MG_EP1" [[call]] funcGetTurretsWeapons</code> | |||
will return all turrets weapons, its magazines and its paths: | will return all turrets weapons, its magazines and its paths: | ||
< | <code>[ | ||
["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"] | |||
]</code> | |||
</ | |||
<!-- Note Section END --> | <!-- Note Section END --> |
Revision as of 19:46, 22 June 2020
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:
- addMagazineTurretmagazinesTurretremoveMagazinesTurretremoveMagazineTurretweaponsassignedVehicleRoleaddWeaponTurretremoveWeaponTurretturretLocal
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
- DenV
-
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: Operation Arrowhead: New Scripting Commands List
- Scripting Commands Arma 2
- Scripting Commands Arma 3
- Scripting Commands Take On Helicopters