[SOLVED] Adding a spin alt-fire to a chaingun?
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!)
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!)
[SOLVED] Adding a spin alt-fire to a chaingun?
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?
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?
Last edited by Alexagon on Sun Jun 09, 2019 8:32 pm, edited 1 time in total.
- 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?
As variant you can try wildweasel's nice sequence.
This is one of his possible examples:
Also can be helpful A_CheckForReload and A_ResetReloadCounter f-tions for wind up cycles handling.
This is one of his possible examples:
Code: Select all
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:
}
}
- 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?
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.
Here's an example in ZS that might be a bit more maintainable.
Spoiler:
Re: Adding a spin alt-fire to a chaingun? Is it possible?
@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.
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.
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.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:
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.
- 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?
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.
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.
Re: Adding a spin alt-fire to a chaingun? Is it possible?
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?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.
Spoiler:
- 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?
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?
[/quote]
change to this?
Code: Select all
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
change to this?
Code: Select all
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
- 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?
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".
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".
Re: Adding a spin alt-fire to a chaingun? Is it possible?
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.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".
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.
- 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?
i think the problem is that you can't hold 2 functions for 1 actor at the same time?Alexagon wrote: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.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".
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.
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.
Re: Adding a spin alt-fire to a chaingun? Is it possible?
Gah. Well that sucks. How do I go about making it toggle then?Dan_The_Noob wrote:i think the problem is that you can't hold 2 functions for 1 actor at the same time?Alexagon wrote: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.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".
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.
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.
- 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?
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.
Alexagon you'll need to post the entire actor code for us to see what went wrong.
Re: Adding a spin alt-fire to a chaingun? Is it possible?
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: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.
Spoiler:
- 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?
....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.
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.
Re: Adding a spin alt-fire to a chaingun? Is it possible?
Okay, I really appreciate the help.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.