weaponsTurret: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (template:command argument fix)
m (Text replacement - "user= kju" to "user= .kju")
 
(106 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Command|= Comments
{{RV|type=command
____________________________________________________________________________________________


| arma2oa |= Game name
|game1= arma2oa
|version1= 1.52


|1.52|= Game version
|game2= tkoh
|version2= 1.00


|arg= global |= Arguments in MP
|game3= arma3
____________________________________________________________________________________________
|version3= 0.50


| Returns all weapons of given turret. Use turret path [-1] for driver's turret. |DESCRIPTION=
|arg= global
____________________________________________________________________________________________


| vehicle '''weaponsTurret''' turretPath|SYNTAX=
|gr1= Turrets


|p1= vehicle: [[Object]] |PARAMETER1=
|descr= Returns all weapons of a given turret. Use turret path [-1] for driver's turret.
|p2= turretPath: [[Array]] |PARAMETER2=


| [[Array]] of [[String|Strings]] |RETURNVALUE=
|s1= vehicle [[weaponsTurret]] turretPath
____________________________________________________________________________________________
 
|x1= <code>_weapons <nowiki>=</nowiki> vehicle player '''weaponsTurret''' [0,0]</code> |EXAMPLE1=
|x2= <code>_weapons <nowiki>=</nowiki> _tank '''weaponsTurret''' [0]</code> |EXAMPLE2=
|x3= <code>_driverWeapon <nowiki>=</nowiki> _ka50pilot '''weaponsTurret''' [-1]</code> |EXAMPLE3=
|x4= <code>_weaponsForAnyTurrentPosition <nowiki>=</nowiki> (vehicle player) '''weaponsTurret''' ((assignedVehicleRole player) select 1)</code> |EXAMPLE4=
____________________________________________________________________________________________


| [[addMagazineTurret]], [[magazinesTurret]], [[removeMagazinesTurret]], [[removeMagazineTurret]], [[weapons]], [[assignedVehicleRole]], [[addWeaponTurret]], [[removeWeaponTurret]], [[turretLocal]]|SEEALSO=
|p1= vehicle: [[Object]]


}}
|p2= turretPath: [[Array]] format [[Turret Path]]
 
|r1= [[Array]] of [[String]]s
 
|x1= <sqf>_weapons = vehicle player weaponsTurret [0,0];</sqf>
 
|x2= <sqf>_weapons = _tank weaponsTurret [0];</sqf>


<h3 style="display:none">Notes</h3>
|x3= <sqf>_driverWeapon = _ka50pilot weaponsTurret [-1];</sqf>
<dl class="command_description">
<!-- Note Section BEGIN -->


<dd class="notedate">Posted on 11 March 2011
|x4= <sqf>_weaponsForAnyTurrentPosition = (vehicle player) weaponsTurret ((assignedVehicleRole player) select 1);</sqf>
<dt class="note>'''[[User:kju|kju]]'''
<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.


<dd class="notedate">Posted on 11 March 2011
|seealso= [[addMagazineTurret]] [[magazinesTurret]] [[removeMagazinesTurret]] [[removeMagazineTurret]] [[weapons]] [[assignedVehicleRole]] [[addWeaponTurret]] [[removeWeaponTurret]] [[turretLocal]]
<dt class="note>
}}
<dd class="note">


Returns information (including the turrets paths) about all weapons on turrets
{{Note
<pre><nowiki>
|user= .kju
funcGetTurretsWeapons = {
|timestamp= 20110311074900
    private ["_result", "_getAnyMagazines", "_findRecurse", "_class"];
|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.
    _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
</dl>
|user= DenV
|timestamp= 20120530162600
|text= Returns information (including the turrets paths) about all weapons on turrets
<sqf>
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;
};
</sqf>


<h3 style="display:none">Bottom Section</h3>
This call:
<sqf>"M1A2_US_TUSK_MG_EP1" call funcGetTurretsWeapons;</sqf>


[[Category:ArmA 2 OA: New Scripting Commands List|{{uc:{{PAGENAME}}}}]]
will return all turrets weapons, their magazines and their paths:
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]]
<pre>[
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
["M256", ["20Rnd_120mmSABOT_M1A2", "20Rnd_120mmHE_M1A2"], [0], "bin\config.bin/CfgVehicles/M1A2_US_TUSK_MG_EP1/Turrets/MainTurret"],
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]]
["M240_veh", ["100Rnd_762x51_M240", "1200Rnd_762x51_M240"], [0], "bin\config.bin/CfgVehicles/M1A2_US_TUSK_MG_EP1/Turrets/MainTurret"],
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]
["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"]
]</pre>
}}

Latest revision as of 21:33, 3 May 2024

Hover & click on the images for description

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:
_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
.kju - c
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.
DenV - c
Posted on May 30, 2012 - 16:26 (UTC)
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, 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"]
]