Arma 3
Jarlsberg Apr 22, 2017 @ 6:24pm
Useful code for adding every weapon in-game to a vehicle with one or more mounted turret. (Arma3)
So, we've all been there. Messing around in the editor and finding it quite boring to only have a couple of weapons in your vehicle. So why not just add every missile, cannon and launcher in the game to it?

To insert the code(paste from below), right-click the vehicle with any sort of turret, it could be the commanders seat in a Strider or the "gunners" camera in the Darter. From that menu select "Attributes..." and click inside the box called "init". Proceed to paste the code. If you want to have a specific weapon in a different turret, for example you want to have most weapons for the gunners seat and a cannon for commanders seat, you replace the number "0" with 1, 2 or 3 depending on the turret. Note that missiles will not always go in the direction your turret is heading; instead it may be launched in front of the vehicle. Vehicles like the Strider will however have missiles being launched in the direction you're aiming.

The IDs for the weapons and ammo can be found at this page: https://community.bistudio.com/wiki/Arma_3_CfgWeapons_Vehicle_Weapons

I also added a code that gives you infinite ammo(the "addEventHandler" above the rest).
All types of ammo are also included, for example when using the Howitzer you can use the mouse wheel and select "reload cluster shells/HE/AT mine cluster" or whatever it is.
When using Artillery computer you can only fire ammo dedicated to mortars or such artillery weapons.

Here's the code, enjoy:

this addEventHandler ["Fired",{(_this select 0) setVehicleAmmo 1}]

this addWeaponTurret ["LMG_RCWS",[0]];
this addMagazineTurret ["2000Rnd_65x39_Belt_Tracer_Red",[0]];

this addWeaponTurret ["HMG_127",[0]];
this addMagazineTurret ["500Rnd_127x99_mag_Tracer_Red",[0]];

this addWeaponTurret ["HMG_NSVT",[0]];
this addMagazineTurret ["450Rnd_127x108_Ball",[0]];

this addWeaponTurret ["SmokeLauncher",[0]];
this addMagazineTurret ["SmokeLauncherMag",[0]];
this addMagazineTurret ["SmokeLauncherMag_boat",[0]];

this addWeaponTurret ["CMFlareLauncher",[0]];
this addMagazineTurret ["300Rnd_CMFlare_Chaff_Magazine",[0]];
this addMagazineTurret ["240Rnd_CMFlareMagazine",[0]];

this addWeaponTurret ["M134_minigun",[0]];
this addMagazineTurret ["5000Rnd_762x51_Belt",[0]];

this addWeaponTurret ["mortar_82mm",[0]];
this addMagazineTurret ["8Rnd_82mm_Mo_shells",[0]];
this addMagazineTurret ["8Rnd_82mm_Mo_Flare_white",[0]];
this addMagazineTurret ["8Rnd_82mm_Mo_Smoke_white",[0]];
this addMagazineTurret ["8Rnd_82mm_Mo_guided",[0]];
this addMagazineTurret ["8Rnd_82mm_Mo_LG",[0]];

this addWeaponTurret ["missiles_DAGR",[0]];
this addMagazineTurret ["24Rnd_PG_missiles",[0]];

this addWeaponTurret ["missiles_DAR",[0]];
this addMagazineTurret ["24Rnd_missiles",[0]];

this addWeaponTurret ["GMG_20mm",[0]];
this addMagazineTurret ["200Rnd_20mm_G_belt",[0]];

this addWeaponTurret ["autocannon_40mm_CTWS",[0]];
this addMagazineTurret ["60Rnd_40mm_GPR_shells",[0]];
this addMagazineTurret ["40Rnd_40mm_APFSDS_shells",[0]];

this addWeaponTurret ["gatling_20mm",[0]];
this addMagazineTurret ["2000Rnd_20mm_shells",[0]];

this addWeaponTurret ["gatling_30mm",[0]];
this addMagazineTurret ["250Rnd_30mm_HE_shells",[0]];
this addMagazineTurret ["250Rnd_30mm_APDS_shells",[0]];

this addWeaponTurret ["missiles_ASRAAM",[0]];
this addMagazineTurret ["4Rnd_AAA_missiles",[0]];
this addMagazineTurret ["4Rnd_AAA_missiles_MI02",[0]];


this addWeaponTurret ["missiles_SCALPEL",[0]];
this addMagazineTurret ["8Rnd_LG_scalpel",[0]];

this addWeaponTurret ["missiles_titan",[0]];
this addMagazineTurret ["5Rnd_GAT_missiles",[0]];
this addMagazineTurret ["4Rnd_GAA_missiles",[0]];
this addMagazineTurret ["4Rnd_Titan_long_missiles",[0]];

this addWeaponTurret ["rockets_Skyfire",[0]];
this addMagazineTurret ["38Rnd_80mm_rockets",[0]];

this addWeaponTurret ["cannon_120mm",[0]];
this addMagazineTurret ["32Rnd_120mm_APFSDS_shells",[0]];
this addMagazineTurret ["30Rnd_120mm_HE_shells",[0]];

this addWeaponTurret ["cannon_125mm",[0]];
this addMagazineTurret ["24Rnd_125mm_APFSDS",[0]];
this addMagazineTurret ["12Rnd_125mm_HE",[0]];
this addMagazineTurret ["12Rnd_125mm_HEAT",[0]];

this addWeaponTurret ["cannon_105mm",[0]];
this addMagazineTurret ["40Rnd_105mm_APFSDS",[0]];
this addMagazineTurret ["20Rnd_105mm_HEAT_MP",[0]];

this addWeaponTurret ["gatling_25mm",[0]];
this addMagazineTurret ["1000Rnd_25mm_shells",[0]];

this addWeaponTurret ["autocannon_35mm",[0]];
this addMagazineTurret ["680Rnd_35mm_AA_shells",[0]];

this addWeaponTurret ["mortar_155mm_AMOS",[0]];
this addMagazineTurret ["32Rnd_155mm_Mo_shells",[0]];
this addMagazineTurret ["6Rnd_155mm_Mo_smoke",[0]];
this addMagazineTurret ["2Rnd_155mm_Mo_guided",[0]];
this addMagazineTurret ["2Rnd_155mm_Mo_LG",[0]];
this addMagazineTurret ["6Rnd_155mm_Mo_mine",[0]];
this addMagazineTurret ["2Rnd_155mm_Mo_Cluster",[0]];
this addMagazineTurret ["6Rnd_155mm_Mo_AT_mine",[0]];

this addWeaponTurret ["missiles_Zephyr",[0]];
this addMagazineTurret ["4Rnd_GAA_missiles",[0]];

this addWeaponTurret ["missiles_titan_static",[0]];
this addMagazineTurret ["1Rnd_GAT_missiles",[0]];
this addMagazineTurret ["1Rnd_GAA_missiles",[0]];

this addWeaponTurret ["GBU12BombLauncher",[0]];
this addMagazineTurret ["2Rnd_GBU12_LGB",[0]];
this addMagazineTurret ["2Rnd_GBU12_LGB_MI10",[0]];

this addWeaponTurret ["Mk82BombLauncher",[0]];
this addMagazineTurret ["2Rnd_Mk82",[0]];
this addMagazineTurret ["2Rnd_Mk82_MI08",[0]];

this addWeaponTurret ["rockets_230mm_GAT",[0]];
this addMagazineTurret ["12Rnd_230mm_rockets",[0]];
this addWeaponTurret ["LMG_coax",[0]];
this addMagazineTurret ["2000Rnd_762x51_Belt",[0]];

this addWeaponTurret ["autocannon_30mm",[0]];
this addMagazineTurret ["140Rnd_30mm_MP_shells",[0]];
this addMagazineTurret ["60Rnd_30mm_APFSDS_shells",[0]];

this addWeaponTurret ["cannon_120mm_long",[0]];
this addMagazineTurret ["28Rnd_120mm_APFSDS_shells",[0]];
this addMagazineTurret ["14Rnd_120mm_HE_shells",[0]];

this addWeaponTurret ["Twin_Cannon_20mm",[0]];
this addMagazineTurret ["2000Rnd_20mm_shells",[0]];

this addWeaponTurret ["Gatling_30mm_Plane_CAS_01_F",[0]];
this addMagazineTurret ["1000Rnd_Gatling_30mm_Plane_CAS_01_F",[0]];

this addWeaponTurret ["Missile_AA_04_Plane_CAS_01_F",[0]];
this addMagazineTurret ["2Rnd_Missile_AA_04_F",[0]];

this addWeaponTurret ["Missile_AGM_02_Plane_CAS_01_F",[0]];
this addMagazineTurret ["6Rnd_Missile_AGM_02_F",[0]];

this addWeaponTurret ["Rocket_04_HE_Plane_CAS_01_F",[0]];
this addMagazineTurret ["7Rnd_Rocket_04_HE_F",[0]];

this addWeaponTurret ["Rocket_04_AP_Plane_CAS_01_F",[0]];
this addMagazineTurret ["7Rnd_Rocket_04_AP_F",[0]];


this addWeaponTurret ["Bomb_04_Plane_CAS_01_F",[0]];
this addMagazineTurret ["4Rnd_Bomb_04_F",[0]];

this addWeaponTurret ["Cannon_30mm_Plane_CAS_02_F",[0]];
this addMagazineTurret ["500Rnd_Cannon_30mm_Plane_CAS_02_F",[0]];

this addWeaponTurret ["Missile_AA_03_Plane_CAS_02_F",[0]];
this addMagazineTurret ["2Rnd_Missile_AA_03_F",[0]];

this addWeaponTurret ["Missile_AGM_01_Plane_CAS_02_F",[0]];
this addMagazineTurret ["4Rnd_Missile_AGM_01_F",[0]];

this addWeaponTurret ["Rocket_03_HE_Plane_CAS_02_F",[0]];
this addMagazineTurret ["20Rnd_Rocket_03_HE_F",[0]];

this addWeaponTurret ["Rocket_03_AP_Plane_CAS_02_F",[0]];
this addMagazineTurret ["20Rnd_Rocket_03_AP_F",[0]];

this addWeaponTurret ["Bomb_03_Plane_CAS_02_F",[0]];
this addMagazineTurret ["2Rnd_Bomb_03_F",[0]];

this addWeaponTurret ["HMG_127_MBT",[0]];
this addMagazineTurret ["500Rnd_127x99_mag",[0]];

this addWeaponTurret ["HMG_127_LSV_01",[0]];
this addMagazineTurret ["500Rnd_127x99_mag",[0]];

this addWeaponTurret ["MMG_02_vehicle",[0]];
this addMagazineTurret ["130Rnd_338_Mag",[0]];

this addWeaponTurret ["gatling_20mm_VTOL_01",[0]];
this addMagazineTurret ["4000Rnd_20mm_Tracer_Red_shells",[0]];

this addWeaponTurret ["autocannon_40mm_VTOL_01",[0]];
this addMagazineTurret ["240Rnd_40mm_GPR_Tracer_Red_shells",[0]];
this addMagazineTurret ["160Rnd_40mm_APFSDS_Tracer_Red_shells",[0]];

this addWeaponTurret ["cannon_105mm_VTOL_01",[0]];
this addMagazineTurret ["40Rnd_105mm_APFSDS",[0]];
this addMagazineTurret ["100Rnd_105mm_HEAT_MP",[0]];

this addWeaponTurret ["gatling_30mm_VTOL_02",[0]];
this addMagazineTurret ["250Rnd_30mm_HE_shells",[0]];
this addMagazineTurret ["250Rnd_30mm_APDS_shells",[0]];

this addWeaponTurret ["missiles_Jian",[0]];
this addMagazineTurret ["4Rnd_LG_Jian",[0]];
< >
Showing 1-15 of 19 comments
IM SORRY BUFFALO Apr 22, 2017 @ 9:02pm 
wouldnt it be more effcient to have it check if the ammo in the turret is below a certain amount and then set the ammo to full if its below that amount instead of setting the ammo to max each shot
Jarlsberg Apr 23, 2017 @ 11:23am 
Originally posted by Sec8gokitty199:
wouldnt it be more effcient to have it check if the ammo in the turret is below a certain amount and then set the ammo to full if its below that amount instead of setting the ammo to max each shot
No, to do that you'll have to use a loop, which requires more performance than a trigger. The ammo code is pretty simple, and it works for every kind of ammo which makes it very useful. By having it activated only when necessary you can have the code inside several vehicles which are not being used without any negative effect on your FPS.
Reiskorn Feb 10, 2018 @ 4:37am 
Can you post this as a guide pls its hard to find a disscusion again
IM SORRY BUFFALO Feb 10, 2018 @ 10:27am 
Originally posted by Reiskorn:
Can you post this as a guide pls its hard to find a disscusion again
it would be easier to get them all from the weapon configs and store them into an array, then just run this to add the weapons and do the same for magazines.
{ vehicle addWeaponTurret [_x, [0]]; } forEach arrayName;

heres the script i wrote to spawn random weapons with their magazines in houses, just adjust it for vehicles and save it somewhere to use later if needed. you can ignore things such as the backpacks/helmets and such and the houses and building position spawns as well as the triggers and stuff so you only really need a few lines

_spawnChanceWeapons = 13; _spawnChanceItems = 7; _magazineArry = [1, 2, 3, 4]; _houseMarker = getPos spawnArea; _rifleArray = ["arifle_TRG21_F"]; _pistolArray = ["hgun_ACPC2_F", "hgun_Pistol_heavy_01_F", "hgun_P07_F", "hgun_Pistol_heavy_02_F"]; _backpackArray = ["B_AssaultPack_khk", "B_Kitbag_mcamo", "B_Carryall_cbr"]; _vestArray = ["V_TacVestIR_blk"]; _helmetArray = ["H_HelmetB_light"]; _attachmentArray = ["muzzle_snds_M", "muzzle_snds_B", "muzzle_snds_93mmg", "optic_Holosight", "optic_MRCO", "optic_LRPS"]; _triggerSize = triggerArea spawnArea; _sizeX = _triggerSize select 0; _sizeY = _triggerSize select 1; _areaSize = _sizeX; if (_sizeY > _sizeX) then { _areaSize = _sizeY; }; _houses = _houseMarker nearObjects ["house", _areaSize]; { _buildingPos = [_x] call BIS_fnc_buildingPositions; { if (_spawnChanceWeapons > random 100) then //weapons { _rifle = _rifleArray call BIS_fnc_selectRandom; _magazineCount = _magazineArry call BIS_fnc_selectRandom; _holder = "WeaponHolderSimulated" createVehicle [0,0,0]; _holder setPos _x; _holder addWeaponCargoGlobal [_rifle, 1]; _wepMagazines = getArray (configFile >> "CfgWeapons" >> _rifle >> "magazines"); _magazines = _wepMagazines select 0; _holder addMagazineCargoGlobal [_magazines, _magazineCount]; }; } forEach _buildingPos; { if (_spawnChanceWeapons > random 100) then //weapons { _pistol = _pistolArray call BIS_fnc_selectRandom; _magazineCount = _magazineArry call BIS_fnc_selectRandom; _holder = "WeaponHolderSimulated" createVehicle [0,0,0]; _holder setPos _x; _holder addWeaponCargoGlobal [_pistol, 1]; _wepMagazines = getArray (configFile >> "CfgWeapons" >> _pistol >> "magazines"); _magazines = _wepMagazines select 0; _holder addMagazineCargoGlobal [_magazines, _magazineCount]; }; } forEach _buildingPos; { if (_spawnChanceItems > random 100) then //backpacks { _backpack = _backpackArray call BIS_fnc_selectRandom; _holder = "WeaponHolderSimulated" createVehicle [0,0,0]; _holder setPos _x; _holder addbackpackCargoGlobal [_backpack, 1]; }; } forEach _buildingPos; { if (_spawnChanceItems > random 100) then //vests { _vest = _vestArray call BIS_fnc_selectRandom; _holder = "WeaponHolderSimulated" createVehicle [0,0,0]; _holder setPos _x; _holder additemCargoGlobal [_vest, 1]; }; } forEach _buildingPos; { if (_spawnChanceItems > random 100) then //helmets { _helmet = _helmetArray call BIS_fnc_selectRandom; _holder = "WeaponHolderSimulated" createVehicle [0,0,0]; _holder setPos _x; _holder additemCargoGlobal [_helmet, 1]; }; } forEach _buildingPos; { if (_spawnChanceItems > random 100) then //attachments { _attachment = _attachmentArray call BIS_fnc_selectRandom; _holder = "WeaponHolderSimulated" createVehicle [0,0,0]; _holder setPos _x; _holder additemCargoGlobal [_attachment, 1]; }; } forEach _buildingPos; } forEach _houses;
Do you know how to addweaponturret to V44 armed as the gunner and make it fire through the side turret? Also would it be possible to add the ranging feature from optics view so shots go where you aim?
The WoWNerd Feb 18, 2020 @ 5:20pm 
Do you know any way to add the targeting camera to the desired crewman. Right now I'm trying to give the co-pilot (0) access to the laser designator turret. but ctl + rightclick doesn't pull up the camera. I need that to aim, otherwise, it just fires straight forward. Thanks.
Spidy Feb 18, 2020 @ 6:06pm 
:steamfacepalm:
Twiznak Jun 11, 2020 @ 10:16pm 
DUDE, this is a true, diamond in the ruff. THANK. YOU. for posting this. After 5000 hours of arma, you think you have seen it all. Then I find this post and I add an automatic grenade launcher to the mini sub and its like a whole new game. F'n Awesome! Thank you.
Jarlsberg Jun 11, 2020 @ 10:28pm 
Originally posted by Twiznak:
DUDE, this is a true, diamond in the ruff. THANK. YOU. for posting this. After 5000 hours of arma, you think you have seen it all. Then I find this post and I add an automatic grenade launcher to the mini sub and its like a whole new game. F'n Awesome! Thank you.
This still works? Awesome, glad someone found it useful
Aipo Jun 12, 2020 @ 4:20pm 
on enhanced zeus mod you need to add an underline before "this"
dr boom Feb 23, 2021 @ 1:46pm 
hello, i'm currently running this script for adding rockets to an AN-2 (armed) but i cannot reload them after rockets have been fired with the ACE rearm vehicle, it works for the standard pylons but not the added weapon.
Jarlsberg Feb 25, 2021 @ 3:58am 
Originally posted by dr boom:
hello, i'm currently running this script for adding rockets to an AN-2 (armed) but i cannot reload them after rockets have been fired with the ACE rearm vehicle, it works for the standard pylons but not the added weapon.
This script was made a long time ago, so weapons added after that are probably not included in the code. You could go to the wiki and get the id of the weapon/ammo and add it
dr boom Feb 25, 2021 @ 4:11am 
Originally posted by jnj01:
Originally posted by dr boom:
hello, i'm currently running this script for adding rockets to an AN-2 (armed) but i cannot reload them after rockets have been fired with the ACE rearm vehicle, it works for the standard pylons but not the added weapon.
This script was made a long time ago, so weapons added after that are probably not included in the code. You could go to the wiki and get the id of the weapon/ammo and add it
the issue i've been having is that the rockets are from RHSRF, they work perfectly fine i am just unable to reload them once they've been fired with the ACE3 rearm interaction
Aipo Feb 25, 2021 @ 5:49pm 
Originally posted by dr boom:
the issue i've been having is that the rockets are from RHSRF, they work perfectly fine i am just unable to reload them once they've been fired with the ACE3 rearm interaction

Did you install the ace compatibility mod?
dr boom Feb 25, 2021 @ 11:18pm 
yes, i have the compatibility mod installed
< >
Showing 1-15 of 19 comments
Per page: 1530 50

Date Posted: Apr 22, 2017 @ 6:24pm
Posts: 19