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

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!)

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: [SOLVED] Adding a spin alt-fire to a chaingun?

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

by Alexagon » Sun May 19, 2019 7:03 pm

Void Weaver wrote:Oh, no... The Pickup state Curse strikes again. :\

The "Pickup:" state works ONLY FOR CustomInventory items. And it was already mentioned in your previous thread.
Btw, looks that you have the same trouble as TS of this thread, check it.
Okay, so for the weapon would I make the code like this?:

Code: Select all

ACTOR MinigunGiver : WeaponGiver
{
Weapon.AmmoGive -1
Dropitem Minigun
Inventory.PickupMessage "You got the Minigun!"
States
{
Spawn:
MNIG A -1
}
}
And for the custom ammo thing, the custominventory flag doesn't work on added item drops, right? Just works on replacing what current ammo drops give you?

EDIT: The weapongiver thing didn't seem to do anything at all. I placed it at the bottom of the minigun txt file.

EDIT 2: I'm having an issue where when I fire the crossbow without any ammo, it does the dryfire animation then disappears and I can't switch weapons. Code:
Spoiler:

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

by Dan_The_Noob » Sun May 19, 2019 6:58 pm

Alexagon wrote: I tried that, it makes so it says "You got a pickup" and does nothing else. i know how to get it to give me ammo but how do i make it so that it gives me the actual weapon?

Also, do either of you know how to make a custom ammo drop? I'm trying to make a box of bolts for my cryobow, but when I do a randomspawner for the rocket box and box of bolts, it doesn't spawn the bolts. I made a custom ammo for single bolts with a randomspawner for single rockets and that works just fine. It's the box that doesn't work. Here's the code for that:
if you have 1 working example of an ammo pickup you can pretty much just copy it with different values to make another.
I did this to fix some wonky ammo types.

Here's one for a box of nails
Spoiler:

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

by Void Weaver » Sun May 19, 2019 6:52 pm

Oh, no... The Pickup state Curse strikes again. :\

The "Pickup:" state works ONLY FOR CustomInventory items. And it was already mentioned in your previous thread.
Btw, looks that you have the same trouble as TS of this thread, check it.

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

by Alexagon » Sun May 19, 2019 6:42 pm

Dan_The_Noob wrote:
Alexagon wrote: I added that first line.

I'm having an issue now: Chaingun drops from chaingunners can't be picked up anymore. I added the spawn function to the HoldChaingun actor to get them to even appear but now they don't do anything. I added a pickup line after the spawn one but that didn't do anything.
try add an "+ALWAYSPICKUP" flag to the chaingun?
I tried that, it makes so it says "You got a pickup" and does nothing else. i know how to get it to give me ammo but how do i make it so that it gives me the actual weapon?

Also, do either of you know how to make a custom ammo drop? I'm trying to make a box of bolts for my cryobow, but when I do a randomspawner for the rocket box and box of bolts, it doesn't spawn the bolts. I made a custom ammo for single bolts with a randomspawner for single rockets and that works just fine. It's the box that doesn't work. Here's the code for that:
Spoiler:

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

by Dan_The_Noob » Sun May 19, 2019 6:33 pm

Alexagon wrote: I added that first line.

I'm having an issue now: Chaingun drops from chaingunners can't be picked up anymore. I added the spawn function to the HoldChaingun actor to get them to even appear but now they don't do anything. I added a pickup line after the spawn one but that didn't do anything.
try add an "+ALWAYSPICKUP" flag to the chaingun?

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

by Void Weaver » Sun May 19, 2019 5:42 pm

What is HoldChaingun actor?
If it CustomInventory item then seems that you made a some mistake in its states.

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

by Alexagon » Sun May 19, 2019 5:33 pm

Void Weaver wrote:Glad to help. ^_^

But I forget to place else one "TNT1 A 0 A_TakeInventory("WindUpChecker")" line right after entering into "Hold" state of the 1st variant - without it a some glitch are possible.
Also "TNT1 A 0 A_JumpIfInventory("WindUpChecker",1,"Hold")" lines in both variants should be logically moved down and placed after "TNT1 A 0 A_PlaySound ("weapons/minig/start")".
I added that first line.

I'm having an issue now: Chaingun drops from chaingunners can't be picked up anymore. I added the spawn function to the HoldChaingun actor to get them to even appear but now they don't do anything. I added a pickup line after the spawn one but that didn't do anything.

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

by Void Weaver » Sun May 19, 2019 4:28 pm

Glad to help. ^_^

But I forget to place else one "TNT1 A 0 A_TakeInventory("WindUpChecker")" line right after entering into "Hold" state of the 1st variant - without it a some glitch are possible.
Also "TNT1 A 0 A_JumpIfInventory("WindUpChecker",1,"Hold")" lines in both variants should be logically moved down and placed after "TNT1 A 0 A_PlaySound ("weapons/minig/start")".

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

by Alexagon » Sun May 19, 2019 3:13 pm

Thanks, Void Weaver, that variation 1 worked perfectly.

Thanks so much! To all of you, I really appreciate the help.

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

by Void Weaver » Sun May 19, 2019 9:24 am

Alexagon wrote:
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.
Oh, got it. :) Well that's easy, even without any scripts. There are 2 variants:

VAR #1 - this is the same mechanics which you looking for. While you hold Alt-fire barrels are spin, if you press Fire at the same time it will immediately shoots.

Code: Select all

Actor WindUpChecker : Inventory {Inventory.MaxAmount 1}

Actor HoldChaingun : Chaingun replaces Chaingun
{
   Weapon.AmmoUse1 1
   Weapon.AmmoUse2 1
   Weapon.AmmoType1 "Clip"
   Weapon.AmmoType2 "Clip"
   Weapon.SlotNumber 4
   States
   {
Fire:
      TNT1 A 0 A_JumpIfNoAmmo("Dryfire")
      TNT1 A 0 A_PlaySound ("weapons/minig/start")
      TNT1 A 0 A_JumpIfInventory("WindUpChecker",1,"Hold")
      CHGG B 2 
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      CHGG CD 1 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      CHGG ABCD 1 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      TNT1 A 0 A_Refire
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      CHGG ABCD 1 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      CHGG ABC 2 A_WeaponReady
      CHGG DABCDAB 3 A_WeaponReady
      CHGG CD 4 A_WeaponReady
      Goto Ready
   Altfire:
      TNT1 A 0 A_TakeInventory("WindUpChecker")
	  TNT1 A 0 A_PlaySound ("weapons/minig/start")
   AltHold:
	  TNT1 A 0 A_PlaySound("weapons/minig/spin",6)
      CHGG ABCD 1 
	  {
	  A_WeaponReady(WRF_DISABLESWITCH|WRF_NOSWITCH|WRF_NOSECONDARY);
	  A_GiveInventory("WindUpChecker");
	  }
	  VLCN A 0 A_Refire
   AltWinddown:
      CHGG ABCDAABBCCDD 1
      TNT1 A 0 A_TakeInventory("WindUpChecker")
	  goto ready
    Hold:
      TNT1 A 0 A_TakeInventory("WindUpChecker")
      TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("ToggleMinigun")==0, "NoReloadHold")
      TNT1 A 0 A_JumpIfNoAmmo("EmptyWindDown")
      TNT1 A 0 A_AlertMonsters
      TNT1 A 0 A_PlaySound("weapons/minig/spin",6)
      TNT1 A 0 A_GunFlash
      CHGG A 1 Offset(0,35) A_FireBullets (5, 5, 1, 8, "BulletPuff")
      TNT1 A 0 Radius_Quake (1, 2, 0, 1, 0)
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      TNT1 A 0 A_SetPitch(pitch-1.0)
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      CHGG B 1 Offset(0,37) A_Firecustommissile("ChaingunCasingSpawner",0,0,-12,-18)
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      CHGG C 1 Offset(0,39) A_FireBullets (5, 5, 1, 8, "BulletPuff")
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      TNT1 A 0 A_SetPitch(pitch-0.6)
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      TNT1 A 0 A_Firecustommissile("ChaingunCasingSpawner",0,0,-12,-18)
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      CHGG D 1 Offset(0,37)
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      TNT1 A 0 A_SetPitch(pitch+1.6)
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      TNT1 A 0 A_ReFire
	  Goto Ready
	  }
}
VAR #2 - this a bit different mechanics. Alt-fire itself consist from 2 toggleable modes: spin on\spin off. While in spin mode it also will immediately shoots while Fire is pressed.

Code: Select all

Actor ToggleChaingun : Chaingun replaces Chaingun
{
   Weapon.AmmoUse1 1
   Weapon.AmmoUse2 1
   Weapon.AmmoType1 "Clip"
   Weapon.AmmoType2 "Clip"
   Weapon.SlotNumber 4
   States
   {
	Fire:
      TNT1 A 0 A_JumpIfNoAmmo("Dryfire")
      TNT1 A 0 A_PlaySound ("weapons/minig/start")
      TNT1 A 0 A_JumpIfInventory("WindUpChecker",1,"Hold")
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      CHGG B 2 
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      CHGG CD 1 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      CHGG ABCD 1 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      TNT1 A 0 A_Refire
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      CHGG ABCD 1 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      CHGG ABC 2 A_WeaponReady
      CHGG DABCDAB 3 A_WeaponReady
      CHGG CD 4 A_WeaponReady
      Goto Ready
   
	Altfire:
   	  CHGG ABCD 1
	  TNT1 A 0 A_JumpIfInventory("WindUpChecker",1,3)
	  TNT1 A 0 A_GiveInventory("WindUpChecker")
	  TNT1 A 0 A_PlaySound ("weapons/minig/start")
	  Goto AltHoldd
      TNT1 A 0 A_TakeInventory("WindUpChecker")
	  Goto AltWinddown
	AltHoldd:
	  TNT1 A 0 A_PlaySound("weapons/minig/spin",6)
      CHGG ABCD 1 
	  {
	  A_WeaponReady(WRF_DISABLESWITCH|WRF_NOSWITCH);
	  If(CountInv("WindUpChecker")==0){Return state("AltWinddown");}
      Else{Return state("");}
	  }
	  Loop
    AltWinddown:
      CHGG ABCDAABBCCDD 1
      CHGG AABBCCDD 2
	  Goto Ready
    Hold:
      TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("ToggleMinigun")==0, "NoReloadHold")
      TNT1 A 0 A_JumpIfNoAmmo("EmptyWindDown")
      TNT1 A 0 A_AlertMonsters
      TNT1 A 0 A_PlaySound("weapons/minig/spin",6)
      TNT1 A 0 A_GunFlash
      CHGG A 1 Offset(0,35) A_FireBullets (5, 5, 1, 8, "BulletPuff")
      TNT1 A 0 Radius_Quake (1, 2, 0, 1, 0)
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      TNT1 A 0 A_SetPitch(pitch-1.0)
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      CHGG B 1 Offset(0,37) A_Firecustommissile("ChaingunCasingSpawner",0,0,-12,-18)
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      CHGG C 1 Offset(0,39) A_FireBullets (5, 5, 1, 8, "BulletPuff")
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      TNT1 A 0 A_SetPitch(pitch-0.6)
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      TNT1 A 0 A_Firecustommissile("ChaingunCasingSpawner",0,0,-12,-18)
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      CHGG D 1 Offset(0,37)
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      TNT1 A 0 A_SetPitch(pitch+1.6)
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      TNT1 A 0 A_ReFire
	  TNT1 A 0 A_JumpIfInventory("WindUpChecker",1,"AltHoldd")
	  Goto Ready
	  }
}
I did use your basic code, so I have replace your sprites with vanilla CHgun ones.

EDIT:
Code bugs fixed.

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

by Matt » Sun May 19, 2019 1:09 am

Did you also do the "If you make ModWeapon (or whichever of its ancestors inherits from Weapon) inherit" part?

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

by Alexagon » Sat May 18, 2019 6:52 pm

Matt wrote:Did you do the other stuff in that post though? (and do *not* try to combine what I'm saying with what Dan is saying, I believe we are working at cross purposes here)
Spoiler:
I did, and this is what I get:

Script error, "li-wpnitm.pk3:actors/weapons/minigun.txt" line 149:
Invalid parameter 'a_jumpifpressingfire'

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

by Matt » Sat May 18, 2019 6:34 pm

Did you do the other stuff in that post though? (and do *not* try to combine what I'm saying with what Dan is saying, I believe we are working at cross purposes here)
Spoiler:

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

by Alexagon » Sat May 18, 2019 5:51 pm

Matt wrote:A ZScript lump is just a file called "zscript" like a Decorate lump is just a file called "decorate".
Okay, yeah I did that. I didn't seem to do anything ingame though.

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

by Matt » Sat May 18, 2019 8:47 am

A ZScript lump is just a file called "zscript" like a Decorate lump is just a file called "decorate".

Top