Jump to content

How to add reloading to weapons?


ironmanmine12

Recommended Posts

So, I've never actually used this "feature", in fact, I removed or modified this feature from a custom weapon from realm667, but thanks to this, I can help you a bit.

 

I recommend you to look directly at some custom weapon/wad that has reload mechanics.

 

I have in example the railgun.
The creator used several function to obtain the weapon to reload: first you create (in the DECORATE, I don't properly know zscript yet) a new state (for example "Reloaded"), that you will use to check if the weapon has been reloaded and it's ready to fire (using A_ReFire function and pointing to the Ready state at the end)


Then, in the Fire state, you have to use the function A_CheckForReload, which uses as parameters 1) the counter calling for this function, or how many (x) projectile your weapon wants to shoot (basically) and 2) the state at which it will jump if the function hasn't been called x time yet (you won't reload as long as you have projectiles in the "magazine").
In this function you use your new "Reloaded" state.

 

Then you play your reload animation and sound and lastly you reset the counter with the A_ResetReloadCounter.

 

And that's it.
Obviously you won't get any HUD display for the magazine or anything else here, you have to create it from scratch and, unfortunately, you will only be able to reload when you finish your "magazine", you won't get any reload key, unless, again, you set it yourself, but right now I don't know how to do it.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...