Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
R3vo

How to change the current magazine of a vehicle?

Recommended Posts

Hey folks,

I'm currently adding new functions to bakerman's AIS script.

Tanks now use their smoke launcher after beeing hit by a rocket, but I also want them to fire their 120/125mm cannon at the attacker.

The firing of the weapon works fine, but I'm unable to figure out how to change the magazine from APFSDS to HEAT shells.

if (typeOf (_this select 0) == "B_MBT_01_cannon_F" || typeOf (_this select 0) == "O_MBT_02_cannon_F" || typeOf (_this select 0) == "I_MBT_03_cannon_F" || typeOf (_this select 0) == "B_MBT_01_TUSK_F") then
{
  (_this select 0) selectWeapon (weapons (_this select 0) select 0);
  (_this select 0) fire (weapons (_this select 0) select 0);
};		

That's the part of the code where I need to add the magazine change. Since it should work with 4 different tanks I would need a general solution, which works for all for of them.

Any ideas are apprechiated!

R3vo

Share this post


Link to post
Share on other sites

Damn, that easy ?

I wish the search function on the Wiki would return all commands with "magazines" in their name once you search for "magazines".

Thanks Larrow.

Edit: Works splendidly, tanks are not attacking enemy infantry with HE ammo and are more deadly than ever.

Edited by R3vo

Share this post


Link to post
Share on other sites
Yep this is what i do, although i have find as you type turned on for firefox so i just load that page type what i want to find and just press F3 to flick through all the options.

Quick a dirty swap function for changing MBT cannon mag

swapAmmo = {
_vehicle = _this select 0;
_wanted = "_" + ( _this select 1 ) ;  //"HE" or "AP"

_mainWeapon = ( _vehicle weaponsTurret [0] ) select 0;
_vehicle selectWeaponTurret [ _mainWeapon, [0] ];
_currentMagazine = _vehicle currentMagazineTurret [0];

if !( [ _wanted, _currentMagazine ] call BIS_fnc_inString ) then {
	_availableMags = _vehicle magazinesTurret [0];
	_swapTo = "";
	{
		if ( [ _wanted, _x ] call BIS_fnc_inString ) exitWith {
			_swapTo = _x;
		};
	}forEach _availableMags;
	if !( _swapTo isEqualTo "" ) then {
		_vehicle loadMagazine [ [0], _mainWeapon, _swapTo ];
		true
	}else{
		false
	};
}else{
	true
};	
};

Edited by Larrow

Share this post


Link to post
Share on other sites
The search is pretty terrible, in my opinion.

Or use this: http://commandsearch.craigvg.com/

:)

That's fantastic, that's how it should be on the wiki page.

@Larrow, thanks for that script, I'll take a look at it.

Share this post


Link to post
Share on other sites
Sign in to follow this  

×