{"name":"Arma 3: Vehicle Weapon Switching","title":"Arma 3: Vehicle Weapon Switching","type":"topic","url":"https://community.bistudio.com/wiki/Arma_3:_Vehicle_Weapon_Switching","revid":258157,"updated":"2021-05-23T16:34:00Z","aliases":["Arma 3 Vehicle Weapon Switching"],"markdown":"Arma 3 v1.54\nAs part of Arma 3 release 1.54, four actions were added offering the ability to switch between vehicle weapons based on categorization, which avoided the need to cycle through every weapon.\nThe system was made fully configurable so developers can specify exactly where they want their weapons.\n\n### Config Defines\n\nThe weapon groups use enumerated data types and are defined in Arma 3’s basic defines as the following:\n\n```cpp\n#define WEAPONGROUP_CANNONS          1 // Cannons\n#define WEAPONGROUP_MGUNS          2 // Machine Guns\n#define WEAPONGROUP_ROCKETS          4 // Rockets\n#define WEAPONGROUP_AAMISSILES      8 // Anti-Air Missiles\n#define WEAPONGROUP_ATMISSILES     16 // Anti-Tank Missiles\n#define WEAPONGROUP_MISSILES     32 // All / Other Missiles\n#define WEAPONGROUP_BOMBS         64 // Bombs\n#define WEAPONGROUP_SPECIAL        128 // Laser Designator + Misc\n```\n\nWeapon category definitions can be added to iterative **weaponsGroup** parameters in the vehicle class structure, which simply adds that category to a specific weapons group, which can then be directly selected from the controls. All vehicles that inherit from Arma 3's base classes will already have some weapon grouping template.\n\n```cpp\nclass CfgVehicles\n{\n    class MyPrettyAirplane\n    {\n        weaponsGroup1 = WEAPONGROUP_CANNONS + WEAPONGROUP_MGUNS;                                // Adds Cannons and Machine Guns to Weapons Group 1\n        weaponsGroup2 = WEAPONGROUP_ROCKETS;                                                    // Adds Rockets to Weapons Group 2\n        weaponsGroup3 = WEAPONGROUP_AAMISSILES + WEAPONGROUP_ATMISSILES + WEAPONGROUP_MISSILES;    // Adds All Missile types to Weapons Group 3\n        weaponsGroup4 = WEAPONGROUP_BOMBS + WEAPONGROUP_SPECIAL;                                // Adds Bombs and Laser Designators to Weapons Group 4\n    };\n};\n```\n\nOnce this is defined, the \"Switch to Weapons Group\" actions will correlate to the groups in the vehicle config, since the engine automatically determines the category for each weapon based on the ammo simulation.\n\n### Weapon Override\n\nIt is possible to override the engine's determination of weapon category by altering the **weaponType** parameter in the ammunition of the weapon, found in *CfgAmmo*:\n\n```cpp\nclass CfgAmmo\n{\n    class B_19mm_HE;\n    class B_30mm_HE : B_19mm_HE        { weaponType = \"cannon\"; };\n\n    class BulletBase;\n    class B_30mm_AP : BulletBase    { weaponType = \"cannon\"; };\n};\n```\n\nThe weapon category strings are:\n\n- \"cannon\"\n- \"mGun\"\n- \"rocket\"\n- \"missileAA\"\n- \"missileAT\"\n- \"missileAAAT\"\n- \"bomb\"\n- \"special\"","sections":[{"heading":null,"level":1,"markdown":"Arma 3 v1.54\nAs part of Arma 3 release 1.54, four actions were added offering the ability to switch between vehicle weapons based on categorization, which avoided the need to cycle through every weapon.\nThe system was made fully configurable so developers can specify exactly where they want their weapons."},{"heading":"Config Defines","level":3,"markdown":"The weapon groups use enumerated data types and are defined in Arma 3’s basic defines as the following:\n\n```cpp\n#define WEAPONGROUP_CANNONS          1 // Cannons\n#define WEAPONGROUP_MGUNS          2 // Machine Guns\n#define WEAPONGROUP_ROCKETS          4 // Rockets\n#define WEAPONGROUP_AAMISSILES      8 // Anti-Air Missiles\n#define WEAPONGROUP_ATMISSILES     16 // Anti-Tank Missiles\n#define WEAPONGROUP_MISSILES     32 // All / Other Missiles\n#define WEAPONGROUP_BOMBS         64 // Bombs\n#define WEAPONGROUP_SPECIAL        128 // Laser Designator + Misc\n```\n\nWeapon category definitions can be added to iterative **weaponsGroup** parameters in the vehicle class structure, which simply adds that category to a specific weapons group, which can then be directly selected from the controls. All vehicles that inherit from Arma 3's base classes will already have some weapon grouping template.\n\n```cpp\nclass CfgVehicles\n{\n    class MyPrettyAirplane\n    {\n        weaponsGroup1 = WEAPONGROUP_CANNONS + WEAPONGROUP_MGUNS;                                // Adds Cannons and Machine Guns to Weapons Group 1\n        weaponsGroup2 = WEAPONGROUP_ROCKETS;                                                    // Adds Rockets to Weapons Group 2\n        weaponsGroup3 = WEAPONGROUP_AAMISSILES + WEAPONGROUP_ATMISSILES + WEAPONGROUP_MISSILES;    // Adds All Missile types to Weapons Group 3\n        weaponsGroup4 = WEAPONGROUP_BOMBS + WEAPONGROUP_SPECIAL;                                // Adds Bombs and Laser Designators to Weapons Group 4\n    };\n};\n```\n\nOnce this is defined, the \"Switch to Weapons Group\" actions will correlate to the groups in the vehicle config, since the engine automatically determines the category for each weapon based on the ammo simulation."},{"heading":"Weapon Override","level":3,"markdown":"It is possible to override the engine's determination of weapon category by altering the **weaponType** parameter in the ammunition of the weapon, found in *CfgAmmo*:\n\n```cpp\nclass CfgAmmo\n{\n    class B_19mm_HE;\n    class B_30mm_HE : B_19mm_HE        { weaponType = \"cannon\"; };\n\n    class BulletBase;\n    class B_30mm_AP : BulletBase    { weaponType = \"cannon\"; };\n};\n```\n\nThe weapon category strings are:\n\n- \"cannon\"\n- \"mGun\"\n- \"rocket\"\n- \"missileAA\"\n- \"missileAT\"\n- \"missileAAAT\"\n- \"bomb\"\n- \"special\""}],"categories":["Arma 3: Vehicle Configuration","Introduced with Arma 3 version 1.54"],"groups":["Configuration"]}