[SOLVED] Adding a spin alt-fire to a chaingun?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

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!)
User avatar
Matt
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
Contact:

Re: Adding a spin alt-fire to a chaingun? Is it possible?

Post by Matt »

If you make ModWeapon (or whichever of its ancestors inherits from Weapon) inherit from this ZS-defined actor instead:

Code: Select all

class JumpButtonWeapon:Weapon{
    action void A_JumpIfPressing(int button,statelabel stt,int layer=PSP_WEAPON){
        if(player.cmd.buttons&button)player.setpsprite(layer,invoker.findstate(stt));
    }
    action void A_JumpIfPressingFire(statelabel stt){
        A_JumpIfPressing(BT_ATTACK,stt);
    }
    action void A_JumpIfPressingAltfire(statelabel stt){
        A_JumpIfPressing(BT_ALTATTACK,stt);
    }
} 
and then in althold replace "VLCN ABCD 1" with

Code: Select all

VLCN ABCD 1 A_JumpIfPressingFire("hold")
and then in hold, just before the A_Refire line, add

Code: Select all

TNT1 A 0 A_JumpIfPressingAltfire("althold")
I think you can approximate what you need.
Alexagon
Posts: 74
Joined: Mon Apr 22, 2019 2:58 am
Graphics Processor: nVidia (Modern GZDoom)

Re: Adding a spin alt-fire to a chaingun? Is it possible?

Post by Alexagon »

Not to sound like a moron, but I have no idea where to place that first bit of code you posted. Like I may need some ELI5 for this type of thing.
User avatar
Dan_The_Noob
Posts: 872
Joined: Tue May 07, 2019 12:24 pm
Graphics Processor: nVidia with Vulkan support
Contact:

Re: Adding a spin alt-fire to a chaingun? Is it possible?

Post by Dan_The_Noob »

Matt wrote:Dan please stop posting about things you know nothing about. What I posted was literally a complete, functioning solution to the problem you're claiming is unsurmountable. (One of several possible solutions and not all of them needing ZScript if one is willing to put up with the spaghetti)

Alexagon you'll need to post the entire actor code for us to see what went wrong.
HE IS THE ONE NOT WANTING TO USE SCRIPT
So i am informing that it probably can't work because I already looked into this type of thing using Decorate.
Alexagon wrote:Not to sound like a moron, but I have no idea where to place that first bit of code you posted. Like I may need some ELI5 for this type of thing.
first part goes during the spinny bit
Spoiler:
second part goes after the shooty bit
Spoiler:
User avatar
Void Weaver
Posts: 724
Joined: Thu Dec 18, 2014 7:15 am
Contact:

Re: Adding a spin alt-fire to a chaingun? Is it possible?

Post by Void Weaver »

Alexagon, maybe my english are too bad but I still don't understand what (alt-)firing effects you want to achieve? Should is Altfire mode supposed to be are sorta of toggleable (by alt-fire button) wind-up "awaited-for-Fire-button" state?
User avatar
Matt
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
Contact:

Re: Adding a spin alt-fire to a chaingun? Is it possible?

Post by Matt »

Alexagon wrote:Not to sound like a moron, but I have no idea where to place that first bit of code you posted. Like I may need some ELI5 for this type of thing.
Here's an entire functioning ZSCRIPT lump:

Code: Select all

version "4.1"

class JumpButtonWeapon:Weapon{
    action void A_JumpIfPressing(int button,statelabel stt,int layer=PSP_WEAPON){
        if(player.cmd.buttons&button)player.setpsprite(layer,invoker.findstate(stt));
    }
    action void A_JumpIfPressingFire(statelabel stt){
        A_JumpIfPressing(BT_ATTACK,stt);
    }
    action void A_JumpIfPressingAltfire(statelabel stt){
        A_JumpIfPressing(BT_ALTATTACK,stt);
    }
}  
Alexagon
Posts: 74
Joined: Mon Apr 22, 2019 2:58 am
Graphics Processor: nVidia (Modern GZDoom)

Re: Adding a spin alt-fire to a chaingun? Is it possible?

Post by Alexagon »

Dan_The_Noob wrote:
Matt wrote:Dan please stop posting about things you know nothing about. What I posted was literally a complete, functioning solution to the problem you're claiming is unsurmountable. (One of several possible solutions and not all of them needing ZScript if one is willing to put up with the spaghetti)

Alexagon you'll need to post the entire actor code for us to see what went wrong.
HE IS THE ONE NOT WANTING TO USE SCRIPT
So i am informing that it probably can't work because I already looked into this type of thing using Decorate.
Alexagon wrote:Not to sound like a moron, but I have no idea where to place that first bit of code you posted. Like I may need some ELI5 for this type of thing.
first part goes during the spinny bit
Spoiler:
second part goes after the shooty bit
Spoiler:
First off, I'm not a he.

Secondly, I got where to put those two lines of code but the first section with the class definition I don't know where to place. Same with what Matt just posted; I have no idea where in the code that goes.
Alexagon
Posts: 74
Joined: Mon Apr 22, 2019 2:58 am
Graphics Processor: nVidia (Modern GZDoom)

Re: Adding a spin alt-fire to a chaingun? Is it possible?

Post by Alexagon »

Void Weaver wrote:Alexagon, maybe my english are too bad but I still don't understand what (alt-)firing effects you want to achieve? Should is Altfire mode supposed to be are sorta of toggleable (by alt-fire button) wind-up "awaited-for-Fire-button" state?
I want it so that while holding the altfire key, the barrel on the minigun spins and only spins. Then if I press fire while the barrel is spinning, I want it to fire without any delay.

Essentially I want to be able to be prepared to shoot with the minigun instead of waiting for the first few frames to pass before actually firing.
User avatar
Dan_The_Noob
Posts: 872
Joined: Tue May 07, 2019 12:24 pm
Graphics Processor: nVidia with Vulkan support
Contact:

Re: Adding a spin alt-fire to a chaingun? Is it possible?

Post by Dan_The_Noob »

Alexagon wrote: First off, I'm not a he.
sorry, it was more of "until proven otherwise" situations.
Alexagon wrote:Secondly, I got where to put those two lines of code but the first section with the class definition I don't know where to place. Same with what Matt just posted; I have no idea where in the code that goes.
I believe if code comes up blue it's a ZScript (make seperate file to put in the WAD)
Alexagon
Posts: 74
Joined: Mon Apr 22, 2019 2:58 am
Graphics Processor: nVidia (Modern GZDoom)

Re: Adding a spin alt-fire to a chaingun? Is it possible?

Post by Alexagon »

No problem, was just pointing it out.

Do I just need to make a txt file for the zscript, paste what Matt posted, then just place it in the directory where the decorate txt file is? I've never done anything with zscript before.
User avatar
Dan_The_Noob
Posts: 872
Joined: Tue May 07, 2019 12:24 pm
Graphics Processor: nVidia with Vulkan support
Contact:

Re: Adding a spin alt-fire to a chaingun? Is it possible?

Post by Dan_The_Noob »

I would assume so? I haven't used Zscript because i made my mod for Zandronum which i don't think supports it.

but there is an option in SLADE for it to highlight in Zscript so i guess you jus put it in as a txt file like decorate does.
Alexagon
Posts: 74
Joined: Mon Apr 22, 2019 2:58 am
Graphics Processor: nVidia (Modern GZDoom)

Re: Adding a spin alt-fire to a chaingun? Is it possible?

Post by Alexagon »

Dan_The_Noob wrote:I would assume so? I haven't used Zscript because i made my mod for Zandronum which i don't think supports it.

but there is an option in SLADE for it to highlight in Zscript so i guess you jus put it in as a txt file like decorate does.
I made the file and put it in with the rest of the main pk3 directory. First thing, when I tried to luanch from ZDL it said only version 4.0 is supported. So I changed that in the script and when I launched it, the script did nothing to solve my issue.
User avatar
Dan_The_Noob
Posts: 872
Joined: Tue May 07, 2019 12:24 pm
Graphics Processor: nVidia with Vulkan support
Contact:

Re: Adding a spin alt-fire to a chaingun? Is it possible?

Post by Dan_The_Noob »

update your GZDoom to 4.1.1?
Alexagon
Posts: 74
Joined: Mon Apr 22, 2019 2:58 am
Graphics Processor: nVidia (Modern GZDoom)

Re: Adding a spin alt-fire to a chaingun? Is it possible?

Post by Alexagon »

Dan_The_Noob wrote:update your GZDoom to 4.1.1?
Did that, changed the code back. No difference.
User avatar
Dan_The_Noob
Posts: 872
Joined: Tue May 07, 2019 12:24 pm
Graphics Processor: nVidia with Vulkan support
Contact:

Re: Adding a spin alt-fire to a chaingun? Is it possible?

Post by Dan_The_Noob »

you may just have to make the barrel spin a toggle unless Matt can help with the code not working.
Alexagon
Posts: 74
Joined: Mon Apr 22, 2019 2:58 am
Graphics Processor: nVidia (Modern GZDoom)

Re: Adding a spin alt-fire to a chaingun? Is it possible?

Post by Alexagon »

Dan_The_Noob wrote:you may just have to make the barrel spin a toggle unless Matt can help with the code not working.
Yeah, that's what I'm thinking. I wouldn't mind too much if I could at least make it a toggle, As long as it would work!
Post Reply

Return to “Scripting”