[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.

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

Postby Matt » Fri May 17, 2019 12:09 am

If you make ModWeapon (or whichever of its ancestors inherits from Weapon) inherit from this ZS-defined actor instead:
Code: Select allExpand view
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 allExpand view
VLCN ABCD 1 A_JumpIfPressingFire("hold")


and then in hold, just before the A_Refire line, add
Code: Select allExpand view
TNT1 A 0 A_JumpIfPressingAltfire("althold")


I think you can approximate what you need.
User avatar
Matt
Putting the XD into *xdeath since 2007
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

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

Postby Alexagon » Fri May 17, 2019 2:09 am

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.
Alexagon
 
Joined: 22 Apr 2019
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia (Modern GZDoom)

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

Postby Dan_The_Noob » Fri May 17, 2019 4:15 am

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
Dan_The_Noob
 
Joined: 07 May 2019
Twitch ID: Dan_The_Noob
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia with Vulkan support

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

Postby Void Weaver » Fri May 17, 2019 4:44 am

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
Void Weaver
Keeper of the Diablo bestiary storage Also amateur DECORATE-spaghetti weaver ಠ_ಠ
 
Joined: 18 Dec 2014

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

Postby Matt » Fri May 17, 2019 9:32 am

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 allExpand view
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);
    }
}  
User avatar
Matt
Putting the XD into *xdeath since 2007
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

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

Postby Alexagon » Fri May 17, 2019 9:33 pm

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
 
Joined: 22 Apr 2019
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia (Modern GZDoom)

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

Postby Alexagon » Fri May 17, 2019 9:35 pm

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.
Alexagon
 
Joined: 22 Apr 2019
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia (Modern GZDoom)

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

Postby Dan_The_Noob » Fri May 17, 2019 10:38 pm

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)
User avatar
Dan_The_Noob
 
Joined: 07 May 2019
Twitch ID: Dan_The_Noob
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia with Vulkan support

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

Postby Alexagon » Fri May 17, 2019 11:18 pm

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.
Alexagon
 
Joined: 22 Apr 2019
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia (Modern GZDoom)

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

Postby Dan_The_Noob » Sat May 18, 2019 1:20 am

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.
User avatar
Dan_The_Noob
 
Joined: 07 May 2019
Twitch ID: Dan_The_Noob
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia with Vulkan support

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

Postby Alexagon » Sat May 18, 2019 1:41 am

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.
Alexagon
 
Joined: 22 Apr 2019
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia (Modern GZDoom)

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

Postby Dan_The_Noob » Sat May 18, 2019 1:41 am

update your GZDoom to 4.1.1?
User avatar
Dan_The_Noob
 
Joined: 07 May 2019
Twitch ID: Dan_The_Noob
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia with Vulkan support

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

Postby Alexagon » Sat May 18, 2019 2:04 am

Dan_The_Noob wrote:update your GZDoom to 4.1.1?

Did that, changed the code back. No difference.
Alexagon
 
Joined: 22 Apr 2019
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia (Modern GZDoom)

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

Postby Dan_The_Noob » Sat May 18, 2019 2:27 am

you may just have to make the barrel spin a toggle unless Matt can help with the code not working.
User avatar
Dan_The_Noob
 
Joined: 07 May 2019
Twitch ID: Dan_The_Noob
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia with Vulkan support

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

Postby Alexagon » Sat May 18, 2019 2:32 am

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!
Alexagon
 
Joined: 22 Apr 2019
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia (Modern GZDoom)

PreviousNext

Return to Scripting

Who is online

Users browsing this forum: Awario [RSS] and 0 guests