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

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.

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

Postby Alexagon » Wed May 15, 2019 3:30 am

I'm not sure if this is the best place to post this. I'm also very very inexperienced at modding/scripting.

So I'm using a modified version of Led's generic weapons mod and I wanted to add an alt fire for the chaingun that lets you hold it to spin the barrel. Would this be possible to include in the script using only the resources the mod includes? Or would i need to download something else and add it in myself?

Would someone be able to guide me through on how I might be able to accomplish this?
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 Void Weaver » Wed May 15, 2019 4:50 am

As variant you can try wildweasel's nice sequence.

This is one of his possible examples:
Code: Select allExpand view
Actor WindUpGun : Chaingun replaces Chaingun
{
   Weapon.AmmoUse1 1
   Weapon.AmmoUse2 1
   Weapon.AmmoType1 "Clip"
   Weapon.AmmoType2 "Clip"
   Weapon.SlotNumber 4
   States
{
AltFire:
CHGG BBBBBBAAAAABBBBAAABB 1 // The wind-up. I've got this on one line because it's a bit cleaner-looking.
CHGG A 1 A_Refire // If the trigger hasn't been let go of by now, this'll go to Hold.
WindDown:
CHGG BBAAABBBBAAAAA 1 A_Refire // So the player can keep firing without waiting for the thing to spin down first.
CHGG A 1 A_Refire("AltFire") // Too late, can't do that anymore.
Goto Ready
AltHold:
CHGG A 0 A_GunFlash
CHGG A 0 A_PlaySound("weapons/chngun", CHAN_WEAPON)
CHGG A 1 Bright A_FireBullets(3, 3, -1, 6, "BulletPuff", 1)
CHGG B 0 A_GunFlash("Flash2")
CHGG B 0 A_PlaySound("weapons/chngun", CHAN_WEAPON)
CHGG B 1 Bright A_FireBullets(3, 3, -1, 6, "BulletPuff", 1)
CHGG A 0 A_GunFlash
CHGG A 0 A_PlaySound("weapons/chngun", CHAN_WEAPON)
CHGG A 1 Bright A_FireBullets(3, 3, -1, 6, "BulletPuff", 1)
CHGG B 0 A_GunFlash("Flash2")
CHGG B 0 A_PlaySound("weapons/chngun", CHAN_WEAPON)
CHGG B 1 Bright A_FireBullets(3, 3, -1, 6, "BulletPuff", 1)
CHGG A 1 A_Refire
Goto WindDown // Reuse the wind-down states we made Flash:
}
}

Also can be helpful A_CheckForReload and A_ResetReloadCounter f-tions for wind up cycles handling.
User avatar
Void Weaver
Keeper of Diablo bestiary storage
 
Joined: 18 Dec 2014

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

Postby Matt » Wed May 15, 2019 2:17 pm

I'm assuming we're doing some kind of TF2-style hold-to-spin sorta deal.

Here's an example in ZS that might be a bit more maintainable.
Spoiler:
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 » Wed May 15, 2019 8:21 pm

@Void Weaver: That method seems to just add a spin animation before firing, if I'm doing it right. I'm looking for an alt fire that primes the shots by spinning so you can shoot without the initial spin animation first.

Matt wrote:I'm assuming we're doing some kind of TF2-style hold-to-spin sorta deal.

Here's an example in ZS that might be a bit more maintainable.
Spoiler:


This is more what I'm looking for. I only used the altfire and winddown sections and it seemed to help but it wouldnt let me fire from the spinning state. I only used those since I figured the whole thing you posted referred to the classic chaingun.

When I added the althold section i was told that "sprite names need to be exactly 4 character, but I didn't see any extra brackets or parentheses that need to be closed or opened so i have no clue how to fix that.

But it's on the right track!

EDIT: So I seemed to have gotten it to show the correct sprites and such for the alt fire spinning, but I can't get the initial click sound to only play once (it keeps looping as the button is helped), but I don't know how to get it to fire from the spinning state without it doing the regular startup spin animation it normally has.
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 Matt » Thu May 16, 2019 1:48 am

I won't be able to tell what happened without seeing the code, but from what you describe it sounds like you've taken some of the bits out of context into the old weapon code and didn't add in the vital stuff that made everything work.

It would probably be easier to take what I posted and add in the other weapon's resources, edit the windup/down animations (and that click would probably go into the windup animation somewhere), etc. until it looks like Led's weapon but with this extra feature.

And do note that this is ZScript not Decorate, it needs to be place in zscript lump not decorate lump.
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 » Thu May 16, 2019 4:23 am

Matt wrote:I won't be able to tell what happened without seeing the code, but from what you describe it sounds like you've taken some of the bits out of context into the old weapon code and didn't add in the vital stuff that made everything work.

It would probably be easier to take what I posted and add in the other weapon's resources, edit the windup/down animations (and that click would probably go into the windup animation somewhere), etc. until it looks like Led's weapon but with this extra feature.

And do note that this is ZScript not Decorate, it needs to be place in zscript lump not decorate lump.


I only know how to work with decorate atm, with what little know how I have. Mind if I share the decorate code I have and see if you can't spot the flaws?
Spoiler:
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 » Thu May 16, 2019 6:38 am

I only know how to work with decorate atm, with what little know how I have. Mind if I share the decorate code I have and see if you can't spot the flaws?
Code: Select allExpand view
   Altfire:
      TNT1 A 0 A_PlaySound ("weapons/minig/start")
      TNT1 A 0 A_PlaySound("weapons/minig/spin",6)
        VLCN ABCD 1
        VLCN A 0 A_Refire
        goto altwinddown
   
[/quote]

change to this?

Code: Select allExpand view
Altfire:
      TNT1 A 0 A_PlaySound ("weapons/minig/start")
AltHold:
      TNT1 A 0 A_PlaySound("weapons/minig/spin",6)
        VLCN ABCD 1
        VLCN A 0 A_Refire
        goto altwinddown
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 Matt » Thu May 16, 2019 9:28 am

Yeah, you've just deleted (or rather omitted) the one thing that makes the entire code work! The anonymous function in the althold state contains the detection code for the player pressing the Fire key so you don't need to call a bunch of A_WeaponReady/A_Refire jump to catch each different possible firing frame.

Create a zscript.txt and copypaste my code and build from there, in the long run it's infinitely more rewarding than drowning in a thousand convoluted goto/refire hacks because "ZScript is too hard".
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 » Thu May 16, 2019 4:53 pm

Matt wrote:Yeah, you've just deleted (or rather omitted) the one thing that makes the entire code work! The anonymous function in the althold state contains the detection code for the player pressing the Fire key so you don't need to call a bunch of A_WeaponReady/A_Refire jump to catch each different possible firing frame.

Create a zscript.txt and copypaste my code and build from there, in the long run it's infinitely more rewarding than drowning in a thousand convoluted goto/refire hacks because "ZScript is too hard".

Alright, I added the althold in there but it doesn't seem to fixing my issue. I still can't hold the spinning and fire at the same time.

Also, I'll look into zscript for next time. I really don't want to go through the trouble of changing it all for this project. I appreciate the heads up though.
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 » Thu May 16, 2019 5:47 pm

Alexagon wrote:
Matt wrote:Yeah, you've just deleted (or rather omitted) the one thing that makes the entire code work! The anonymous function in the althold state contains the detection code for the player pressing the Fire key so you don't need to call a bunch of A_WeaponReady/A_Refire jump to catch each different possible firing frame.

Create a zscript.txt and copypaste my code and build from there, in the long run it's infinitely more rewarding than drowning in a thousand convoluted goto/refire hacks because "ZScript is too hard".

Alright, I added the althold in there but it doesn't seem to fixing my issue. I still can't hold the spinning and fire at the same time.

Also, I'll look into zscript for next time. I really don't want to go through the trouble of changing it all for this project. I appreciate the heads up though.


i think the problem is that you can't hold 2 functions for 1 actor at the same time?

you could make a toggled barrel spin like other mods? but i don't think you can hold both Alt and Primary on 1 weapon.
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 » Thu May 16, 2019 6:10 pm

Dan_The_Noob wrote:
Alexagon wrote:
Matt wrote:Yeah, you've just deleted (or rather omitted) the one thing that makes the entire code work! The anonymous function in the althold state contains the detection code for the player pressing the Fire key so you don't need to call a bunch of A_WeaponReady/A_Refire jump to catch each different possible firing frame.

Create a zscript.txt and copypaste my code and build from there, in the long run it's infinitely more rewarding than drowning in a thousand convoluted goto/refire hacks because "ZScript is too hard".

Alright, I added the althold in there but it doesn't seem to fixing my issue. I still can't hold the spinning and fire at the same time.

Also, I'll look into zscript for next time. I really don't want to go through the trouble of changing it all for this project. I appreciate the heads up though.


i think the problem is that you can't hold 2 functions for 1 actor at the same time?

you could make a toggled barrel spin like other mods? but i don't think you can hold both Alt and Primary on 1 weapon.


Gah. Well that sucks. How do I go about making it toggle then?
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 Matt » Thu May 16, 2019 7:26 pm

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.
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 » Thu May 16, 2019 7:42 pm

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.

Okay. Again, sorry for being somewhat stubborn about the decorate thing I just want to do this small thing then be done with it. Here's the entire entry I have for the minigun:

Spoiler:
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 Matt » Thu May 16, 2019 9:24 pm

....yikes. I see why redoing from the example isn't really an option.

Don't have time to try out a solution just this moment, but this can be solved without a wacky refire loop by going into having ModWeapon inherit, instead of Weapon, from a child class of Weapon that has the following functions defined:

A_JumpIfPressingFire
A_JumpIfPressingAltfire

Will write something up later.
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 » Thu May 16, 2019 9:33 pm

Matt wrote:....yikes. I see why redoing from the example isn't really an option.

Don't have time to try out a solution just this moment, but this can be solved without a wacky refire loop by going into having ModWeapon inherit, instead of Weapon, from a child class of Weapon that has the following functions defined:

A_JumpIfPressingFire
A_JumpIfPressingAltfire

Will write something up later.

Okay, I really appreciate the help.
Alexagon
 
Joined: 22 Apr 2019
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia (Modern GZDoom)

Next

Return to Scripting

Who is online

Users browsing this forum: No registered users and 2 guests