Jump to content
gc8

Refill vehicle ammo

Recommended Posts

Hi

I'm trying to refill the ammo of vehicle (namely A164 wipeout) but don't seem to find the right commands. I tried setAmmo but that only gives one AA missile back to the plane when it should have two of them.

Any one knows how to do this properly?

 

Edit: allTurrets command also returns empty array and I cant find alternative.

 

thx!

Share this post


Link to post
Share on other sites

Well I seem to have find solution, this script:

 

refillMags =
{
  params ["_veh"];

 _mags = _veh getVariable "mags";

 _magsOld = magazinesAllTurrets _veh;
 
 {
  _mag = _x select 0;
  _tur = _x select 1;
  _ammo = _x select 2;
  
  _veh removeMagazinesTurret [_mag, _tur];
  
 } forEach _magsOld;
 
 
 {
  _mag = _x select 0;
  _tur = _x select 1;
  //_ammo = _x select 2;
  
  _veh addMagazineTurret [_mag, _tur];
 } forEach _mags;

};

 

But it requires this line to be run at the start of the mission:

 

_veh setVariable ["mags",magazinesAllTurrets _veh];

 

Share this post


Link to post
Share on other sites
4 minutes ago, gc8 said:

Hi

I'm trying to refill the ammo of vehicle (namely A164 wipeout) but don't seem to find the right commands. I tried setAmmo but that only gives one AA missile back to the plane when it should have two of them.

Any one knows how to do this properly?

 

Edit: allTurrets command also returns empty array and I cant find alternative.

 

thx!

Try setVehicleAmmoDef.

Also try to improve your search game, since you can easily stumble upon this command by using ctrl+f on the scripting command wiki page and searching for either "ammo" or "vehicle".

 

Cheers

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
2 minutes ago, Grumpy Old Man said:

Try setVehicleAmmoDef.

Also try to improve your search game, since you can easily stumble upon this command by using ctrl+f on the scripting command wiki page and searching for either "ammo" or "vehicle".

 

Cheers

 

Thanks Grumpy. And sorry about that, my mind was too focused to finding turrets and googling :)

 

  • Like 1

Share this post


Link to post
Share on other sites
On 10/14/2018 at 2:31 PM, gc8 said:

setVehicleAmmoDef

 

I think this command is broken when used on blackfoot, it removes all the missiles and leaves the heli armed only with minigun

Share this post


Link to post
Share on other sites
(vehicle player) setvehicleammo 1

Seems to work too

Share this post


Link to post
Share on other sites

I would like to continue this thread by asking how do you detect if there's any ammo missing or are the weapons fully loaded?

 

there's ammo command but that's only for current weapon

Share this post


Link to post
Share on other sites

I had done this last year:

tag_fnc_PylonArray =
{	// predefine the return value
	private _returnArray = [];
	// read all existing magazines in the pylons
	_arrPylonMagazines = getPylonMagazines _this;
	// create the return array using the config
	{	_returnArray pushback
		[	// pylon name
			_x,
			// pylon magazine
			_arrPylonMagazines select _forEachIndex,
			// amount of ammunition
			_this ammoOnPylon _x
		]
	} forEach ("true" configClasses (configFile>>"CfgVehicles">>typeOf _this>>"Components">>"TransportPylonsComponent">>"pylons") apply {configName _x});
	_returnArray
};

Call e.g. with: vehicle player call tag_fnc_PylonArray;

The function gives you e.g. the following array back:

[	["Pylons1","PylonRack_1Rnd_Missile_AA_04_F",1],
	["Pylons2","PylonRack_7Rnd_Rocket_04_HE_F",7],
	["Pylons3","PylonRack_3Rnd_Missile_AGM_02_F",3],
	["Pylons4","PylonMissile_1Rnd_Bomb_04_F",1],
	["Pylons5","PylonMissile_1Rnd_Bomb_04_F",1],
	["Pylons6","PylonMissile_1Rnd_Bomb_04_F",1],
	["Pylons7","PylonMissile_1Rnd_Bomb_04_F",1],
	["Pylons8","PylonRack_3Rnd_Missile_AGM_02_F",3],
	["Pylons9","PylonRack_7Rnd_Rocket_04_AP_F",7],
	["Pylons10","PylonRack_1Rnd_Missile_AA_04_F",1]
]

[ ["pylon name","pylon magazine",amount of ammunition], ...]

With the help of the array you can quickly see which ammunition needs to be filled up.

 

  • Like 1

Share this post


Link to post
Share on other sites

Hi @Lucullus thanks for sharing your script!

 

3 minutes ago, Lucullus said:

With the help of the array you can quickly see which ammunition needs to be filled up.

shouldn't there be max ammo stored in somewhere also? Or do I get that with some other command? So that I know when there's ammo missing

Share this post


Link to post
Share on other sites

The max number is in the pylon magazine text.

 

"PylonRack_3Rnd_Missile_AGM_02_F"

 

edit:

You can also get the max ammunition with:

getNumber (configfile >> "CfgMagazines" >> "PylonRack_3Rnd_Missile_AGM_02_F" >> "count");

 

Edited by Lucullus
  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

i guess you could also call that function at creation of the vehicle and get the max ammo like that

Share this post


Link to post
Share on other sites

For vehicles you could do it like this:

tag_fnc_used_mags =
{	_mags = magazinesAllTurrets _this;
	private _used_mags = [];
	{	_x params ["_mag","_turret","_count"];
		if (getNumber (configfile >> "CfgMagazines" >> _mag >> "count") > _count) then
		{	_used_mags pushBack _mag
		};
	} forEach _mags;
	_used_mags
};

Call e.g. with: vehicle player call tag_fnc_used_mags

Spits out an array of used magazines.

So many ways to do something...

 

  • Like 2

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×