• Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/

Code Automatic gun with no reloading?

Hello, I've been banging my head on this since last night, so I decided to ask for help.

Is there any way to make a fully automatic gun not have to reload magazines but directly use the ammo pool, like the Crossbow/M79/Huskgun/etc. do?

I tried setting MagCapacity to 1, but then the gun will not fire fully automatically and will require me to click for each shot. I tried to instead set the MagCapacity to the same number as MaxAmmo and to do MagAmmoRemaining = Ammo[m].AmmoAmount at the end of GiveAmmo(), hoping that the magazine will act as the ammo pool, but it didn't do anything, when buying ammo or picking up an ammo pickup the added ammo isn't automatically added to the magazine...
 
Any chance of showing the code for any viewers that may later want to use the same thing?

Well, there was a simulated event Tick(float dt) in the weapon's main class, used for other stuff, and I just added at the bottom MagAmmoRemaining = AmmoAmount(0); But if I understand it correctly this is now probably executed at each server frame, I wish it would have been executed only once, when you receive ammo from the trader or an ammo box, would have been more efficient, not that it causes any visible slowdowns or anything now...
 
Upvote 0