Jump to content
gc8

Fast reload magazine

Recommended Posts

Hi

I am trying to reload fast the first magazine but for some reason my code doesn't work.

 

Here's what I got (m is the mortar, player's in):

[] spawn
{

{ 
  m removeMagazines _x; 
 
} foreach (magazines m); 


m addmagazine "8Rnd_82mm_Mo_shells"; 


sleep 0.5;
reload (gunner m);
sleep 0.5;

m setWeaponReloadingTime [gunner m, currentMuzzle (gunner m), 0.0];

};

 

so I want to reload the mag after addmagazine but reloading is slow despite the setWeaponReloadingTime

 

I've got the setWeaponReloadingTime working in different circumstances but not on this one

 

what am I doing wrong?

 

thx!

Share this post


Link to post
Share on other sites

setWeaponReloadingTime is to re-set the re-chambering time, not the reload magazine time. So the thing you wanted to do is impossible right now.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
44 minutes ago, POLPOX said:

setWeaponReloadingTime is to re-set the re-chambering time, not the reload magazine time. So the thing you wanted to do is impossible right now.

 

ok I guess that makes sense. I was able to use setWeaponReloadingTime  to get new round in instantly but loading new mag is different then

Share this post


Link to post
Share on other sites

GC8, did you ever find a way to do what you want?

 

I want to do something similar but with cluster munitions for the M5 MLRS. When I take away the regular rocket magazines and add the cluster magazines the AI, or the vehicle itself begins the reload process for the cluster rockets. The reload time is very long, like must be a minute or two. I haven't found a way to interrupt it. I tried setAmmo and setVehicleAmmo but neither of them seem to interrupt the reload process once it starts. There are no reload animations for a vehicle as far as I know so I can't find a way to just override it and just fill it up with ammo right away.


The result is that I have to wait a few minutes for the cluster ammo to load up. It isn't that big of a deal if they are not going to be engaging anything in the first few minutes in a scenario but it is annoying nevertheless when I am debugging a scripted battery attack.

 

Edit: I can't tell if these replies I am posting are going through. It keeps telling me to log back in. Kind of annoying.

Share this post


Link to post
Share on other sites

@Fluxion I hear ya and I have pretty much the same problem.. but no I haven't figured out a solution. hopefully someone else does.

Share this post


Link to post
Share on other sites

I don't know if my replies are being moderated or something but they don't show when I submit them right away. Here we go again...

 

I have to be honest, I don't really know the Arma 3 engine very well. Programming isn't the problem, the problem is that it is hard to do stuff if you don't know how the big machine works. Kind of operating blind. The documentation only tells you so much.  It is hard to find a good overview. A lot of documentation doesn't go into a lot of detail.

 

I am not sure if this helps you but I am able to instantly reload the ammo in the MLRS. The issue is that my entire MLRS battery's attack is scripted. If you want to achieve an instant reload while firing the weapon manually you might have to figure out if you can attach some kind of event handler that checks when you fire, or find out if there is way to detect when a mag goes empty.

 

This was a snippet that was inside some loops that got the battery's units firing. This basically give me an infinite barrage of cluster bombs so long as I keep assigning targets.

	if(alive _currentUnit)then{
		waitUntil {unitReady gunner _currentUnit};
		gunner _currentUnit doArtilleryFire [getPos _x, currentMagazine _currentUnit, 1]; 
		_magAmmo = magazinesAmmo _currentUnit select 0 select 1, true;
		if(isNil "_magAmmo")then{
			_currentUnit setAmmo[currentWeapon _currentUnit, 12];
		};

So when a magazine is empty it returns nil rather than 0. Nil is represented by the string "any".

There is an event handler for when a weapon is fired I believe... https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#Fired

this addEventHandler ["Fired", {
	params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];
}];

I have never used an event handler in Arma. I don't really spend loads of time on this stuff. Once every few months I get interested and start dabbling again. It's not like I am getting paid.

So, perhaps you could check to see if the magazineAmmo is nil, then reload immediately by topping up the ammo. I don't mean to send you on a wild goose chase though. It is just an idea. Of course it all depends on how Arma handles these things sequentially and how it affects performance. Also, from what I understand, that method won't give you fine control because if you want to control the length of time of the reload you would probably have to create the delay in an scheduled environment using spawn or something to that effect.

 

My own issue is kind of annoying... I was out for a walk and thinking... hmm, if I can't control an event then I might be able to stop it from precipitating so I tried to load an empty mag of cluster munitions into the MLRS but when I top up the ammo, it begins the loading process because it is switching ammunition types. So, I couldn't use that as a work around.

 

I figure my best bet is to find out more about class inheritance. I don't really know much about it in Arma. There is some documentation but it is largely abstract. It would be nice to see a few concrete examples  and explanations of how to determine exactly how to arrange the classes. I am making a lot of assumptions about how it works from some of the stuff I have read. I was hoping to find a tutorial but no luck yet. I am hoping I can just alter a config and just get the MLRS to initialize with the proper ammo. I bet it is a simple thing to do but I just don't know how.

 

Of course, I have to ask myself... why the fuck am I wasting my time doing this? 😛

Share this post


Link to post
Share on other sites

I tried out the event handler for when a weapon is fired. If you enter this into a unit's init box it tops up their mag giving them infinite ammo. It is a bit wonky though. If you wait until the mag is completely empty, then for some reason only lets me top up to 1 less than the capacity of the mag. I didn't spend too much time fiddling with it but it gives the effect of infinite ammo for a soldier with a weapon. The ammo count in the mag counts down properly, and when it gets to the last round it fills it back up.

 

When I applied this to the mortar operator it had no effect on the mortar system's ammo. I tried applying it to the actual mortar's init box directly. For some reason the ammo count never goes down. I am not sure exactly why it is functioning like that.

There may be unforeseen side effects from using this but it effectively gives the 82mm mortars infinite ammo. :shrug: Seems to solve your problem but it is a bit wonky. Kind of odd but it gets rid of the depletion of mortars and no more reload. 

this addEventHandler ["Fired", {  
params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];  
 
if(_unit ammo currentMuzzle _unit <= 0)then{   
   _unit setAmmo[currentWeapon _unit, 8];   
  }; 
  
}];

I figure the conditional is always returning true when firing so the ammo keeps getting set back to 8.

Share this post


Link to post
Share on other sites

One trick I learned that helps a bit is to first remove the mortar weapon and then add mags and add the weapon back. this makes the first reload faster

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

×