LittleInferno Posted April 30, 2015 I was making a weapon, and I was going to make it like Hacx's Uzi, where you could fire half your ammunition and it would play a sequence of reloading frames. Or you could fire 2 bullets and it would do the same. How would I make it be able to do that without the gun fire looping or reloading after 4 shots? 0 Share this post Link to post
scifista42 Posted April 30, 2015 You need a dummy inventory counter. Make a dummy inventory item with a certain maximum amount, like this:actor dummy : inventory { inventory.maxamount 50 }Then, each time the weapon shots, use A_GiveInventory to give 1 dummy to the player:TNT1 A 0 A_GiveInventory("dummy",1)Also, each time the weapon shots, use A_JumpIfInventory to check whether the player already has full amount of the dummy inventory, and if so, perform a jump to your custom reloading animation:TNT1 A 0 A_JumpIfInventory("dummy",50,"Reload")Finally, inside your Reload animation, don't forget to take all dummies from the player, so that the counter will start from 0 again:TNT1 A 0 A_TakeInventory("dummy",50)Take all 50 of them - don't worry, the number will never go to negative values. If you try to take more inventory from the player than how much he has, he will end up having 0 of this item. 0 Share this post Link to post
LittleInferno Posted April 30, 2015 Thanks. But apparently while trying to figure out where to implement that code (I'm no smarter than a coconut), I found a seemingly simpler way. Fire: UZGN B 4 BRIGHT A_FireCGun BRHT A 2 BRIGHT A_FIRECGun UZGN C 3 BRIGHT A_FireCGun BRHT B 2 BRIGHT A_FireCGun UZGN A 0 A_ReFire // You know Goto Reload //Goes to reloading frames after you are done firing Reload: UZGN D 6 UZGN E 6 UZGN F 6 UZGN G 6 UZGN H 6 Goto Ready } } No more hurdles to go through now, Other than a reloading sound to use, better sprite positioning, and maybe a custom firing sound, which all I know how to do. Also, a YouTube video: https://www.youtube.com/watch?v=mS6ziYtrIIU&feature=youtu.be 0 Share this post Link to post
scifista42 Posted April 30, 2015 If you actually wanted it that simple, you could have looked at the code of Doom's Plasma Rifle. The "Reload" state is not even needed! :) I was under an impression that you wanted the gun to automatically reload if the player would keep firing for too long time. 0 Share this post Link to post
LittleInferno Posted April 30, 2015 Haven't played Hacx, eh? Heh. Fun fact: I take pictures of toy guns to use when I'm making a custom weapon because I have the drawing skills of a quadruple amputee. 0 Share this post Link to post
scifista42 Posted May 1, 2015 LittleInferno said:Haven't play Hacx, eh? Heh.Actually, I did check out HacX 2.0 after reading your original post - and weapon 4 actually behaved exactly as I've assumed in ZDoom, with the counter! That made me assured that I understood what you were talking about, and so I've advised you as I did. 0 Share this post Link to post
LittleInferno Posted May 2, 2015 Oh, you were talking about 2.0's version. I was thinking of 1.2 & below, where you could fire all the bullets you wanted and it would still play reloading frames. 0 Share this post Link to post
scifista42 Posted May 2, 2015 Well, as I said, that's how Doom's Plasmagun normally works. And technically, every Doom weapon that used A_Refire - any code after A_Refire is basically "Reload" performed when you stop firing. 0 Share this post Link to post