Jump to content
Sign in to follow this  
Drongo69

Force artillery to load a certain ammo type

Recommended Posts

I am trying to refine my artillery addon. A central part of this addon is telling AI-controlled artillery units to look at a certain point using doWatch, then firing their cannon using fire. This works fine for HE rounds, as they are the default warhead type. However, if I tell the arty to fire a different type (for example smoke), then the first round will have some errors. If the player is near the arty piece, the gun will play a firing animation, but no shell will fire. If the player is far from the arty piece, a shell will fire, but always at 0 degrees at a high angle. Subsequent rounds will fire properly, but the first round after a change of warhead type will behave strangely.

So, is it possible to use a script to force an artillery piece to load a certain magazine/warhead type before firing? Is there a way to check if the warhead is finished loading?

Share this post


Link to post
Share on other sites

Thanks, but that has nothing to do with forcing a certain magazine type to load or confirming that it has finished loading.

Share this post


Link to post
Share on other sites

Directly off the page I linked:

Description:

Orders a unit to reload defined magazine commence fire burst on the given position (via the radio).

Pretty sure "reloading a defined magazine" is the same as forcing the use of that type of ammo.

Share this post


Link to post
Share on other sites

Understood, I didn't know it worked with zero rounds. Thank you.

For reference purposes for anyone with similar trouble in the future, I used the following to check magazine loaded status:

_tube setWeaponReloadingTime [(gunner _tube),(currentMuzzle (gunner _tube)),0];
_loaded = false;
while{NOT(_loaded)} do {
_magazineClass = currentMagazine _tube;
if (dtaDebug) then {systemChat format ["M: %1",_magazineClass]};
if (_magazineClass == _warheadType) then {_loaded = true};
sleep 0.1;
};

where _warheadType is the desired magazine parsed from other scripts.

Share this post


Link to post
Share on other sites

This is now broken. Trying to tell arty to fire zero rounds now often makes them fire several rounds.

Are there any other ways to force a vehicle to load a magazine type before firing?

Share this post


Link to post
Share on other sites

Drongo, I don't know if this will help, or is exactly with what you need or could give idea, but this is working well in mission. Smoke and HE shells all landing where expected with no errors. Ammo is changed through each loop iteration.

It's an excerpt from BMR Insurgency Objectives/mortar_squad.sqf

		_shell_types = ["8Rnd_82mm_Mo_shells","8Rnd_82mm_Mo_Smoke_white","8Rnd_82mm_Mo_shells"];// 1 in 3 chance for smoke shell

	//next part is some is a small piece of larger section that runs in a loop
	_manArray = (getposatl objective_pos_logic) nearentities [["CAManBase"],_range];

	if (count _manArray > 0) then
	{			
		{
			private ["_mtarget","_type"];
			_type = _shell_types select (floor(random(count _shell_types)));
			_mtarget = _manArray select (floor random count _manArray);
			_pos = [(getPosatl _mtarget select 0) + (random 50) - 25, (getPosatl _mtarget select 1) + (random 50) - 25, (getPosatl _mtarget select 2)];
			_x lookAt _pos;
			_x reveal _mtarget;
			_x commandArtilleryFire [_pos, _type, floor (random 5)];
		} forEach (units mortar_grp);
	};
	sleep 20;

Edited by Jigsor

Share this post


Link to post
Share on other sites

Thanks for the help guys. Unfortunately even when I force the loading of shells (by a variety of methods), the next shot with the fire command has very strange results (going in a totally different direction to where the barrel is pointed). I think I will just accept that BIS bugs have defeated me yet again.

Share this post


Link to post
Share on other sites

If someone is inside the gunner seat:

https://community.bistudio.com/wiki/loadMagazine

 

If there is no gunner or it is not known:

  1. Remove all magazines of every shell type with https://community.bistudio.com/wiki/removeMagazinesTurret
  2. Add the magazine you want to load with https://community.bistudio.com/wiki/addMagazineTurret
  3. Add all the other magazines of other shell types back.

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
Sign in to follow this  

×