Creating a Reload for a Reload

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
mapimapimap
Posts: 2
Joined: Mon Feb 04, 2019 2:31 pm

Creating a Reload for a Reload

Post by mapimapimap »

Hey Guys, I'm a bit new to making guns in ZDoom, and I need some help. I want to make a gun which has four barrels each with six bullets/shells.
In the attachment is a picture of a Nerf blaster which has the exact thing I described.
My idea is that every 6 shots, Doomguy uses the lever action and spins to the next barrel. Every fourth times he uses the lever action, he opens the gun and quickly loads each barrel. I want to know if this is possible and if it is possible to add a "reload" button make Doomguy quickly reload all four barrels, like he would if I shot the 6 bullets/shells in each of the four barrels.
Thanks in advance! :)
You do not have the required permissions to view the files attached to this post.
User avatar
hideousdestructor
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: Creating a Reload for a Reload

Post by hideousdestructor »

Here are the following state labels and A_WeaponReady flags for GZDoom's weapon controls:

Fire
Altfire
Reload, WRF_ALLOWRELOAD
Zoom, WRF_ALLOWZOOM
User1, WRF_ALLOWUSER1
User2, WRF_ALLOWUSER2
User3, WRF_ALLOWUSER3
User4, WRF_ALLOWUSER4

This tutorial is partially relevant.


For what you're describing I would have in the weapon definition an int array with 4 items.

Each time the lever is held, something like the following will happen:

Code: Select all

NRFG Z 4{
    int currentcylinder=invoker.cylinders[0];
    //you could use a for loop, but with only 4 things why bother
    invoker.cylinders[0]=invoker.cylinders[1];
    invoker.cylinders[1]=invoker.cylinders[2];
    invoker.cylinders[2]=invoker.cylinders[3];
    invoker.cylinders[3]=currentcylinder;
    A_PlaySound("sixfourneverforget/leverrotate",CHAN_WEAPON);
}
Similar manipulation of these values would apply for the reload.
mapimapimap
Posts: 2
Joined: Mon Feb 04, 2019 2:31 pm

Re: Creating a Reload for a Reload

Post by mapimapimap »

Thanks, I'll try it out!

Return to “Scripting”