Minigun Spindown Help

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
User avatar
Kinsie
Posts: 7402
Joined: Fri Oct 22, 2004 9:22 am
Graphics Processor: nVidia with Vulkan support
Location: MAP33
Contact:

Minigun Spindown Help

Post by Kinsie »

I have a minigun that has a spinup and spindown animation as appopriate, but I can't seem to figure out how to get it to spindown before being deselected when the player runs out of ammo. Any ideas?

Code: Select all

ACTOR NewMinigun : Weapon
{
	Inventory.PickupMessage "$GOTMINIGUN"
	Tag "$TAGMINIGUN"
	Inventory.PickupSound "misc/w_pkup"
	Weapon.SelectionOrder 400
	Weapon.Kickback 90
	Weapon.AmmoType "DoomClip"
	Weapon.AmmoGive 100
	Weapon.AmmoUse 1
	States
	{
	Spawn:
		TSSX A 1600 BRIGHT
		TNT1 A 0 A_SpawnItemEx ("DespawnCloudPart", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION)
		Stop
	Ready:
		TSSN A 1 A_WeaponReady
		Loop
	Deselect:
		TSSN A 0 A_StopSoundEx("SoundSlot6")
		TSSN A 0 A_PlaySound("weapons/in")
		TSSN A 1 A_Lower
		goto Deselect+2
	Select:
		TSSN A 0 A_StopSoundEx("SoundSlot6")
		TSSN A 0 A_PlaySound("weapons/miniout")
		TSSN A 1 A_Raise
		goto Select+2
	Fire:
		TSSN A 0 A_PlaySoundEx("weapons/minigunup", "SoundSlot6", 0)
		TSSN B 6 
		TSSN C 5 
		TSSN D 4 
		TSSN A 3
		TSSN B 2 
		TSSN C 1 
		TSSN DABCDABCDABCDABC 1
		TSSN D 0 A_ReFire
	WindDown:
		TSSN A 0 A_PlaySoundEx("weapons/minigundown", "SoundSlot6", 0)
		TSSN A 1
		TSSN B 2 
		TSSN C 3
		TSSN D 4 
		TSSN A 5
		TSSN BCD 6
		Goto Ready
	Hold:
		TSSN D 0 A_JumpIfNoAmmo("WindDown")
		TSSF A 0 A_GunFlash
		TSSF A 0 A_Quake(8,2,0,128,"null")
		TSSF A 0 A_PlayweaponSound("weapons/minigun")
		TSSF A 0 A_PlaySoundEx("weapons/minigunhold", "SoundSlot6", 1)
		TSSF B 1 BRIGHT A_FireBullets (5.6, 0, 2, 5, "HandgunPuff") 
		TSSN D 1 A_FireCustomMissile("BulletCasingSpawn",5,0,8,-9)
		TSSN D 0 A_ReFire
		Goto WindDown
	}
}
User avatar
VICE
Posts: 405
Joined: Wed Mar 28, 2012 4:03 am
Location: The Shadow Realm (no cap)
Contact:

Re: Minigun Spindown Help

Post by VICE »

You can do it with an inventory check like this:

Code: Select all

	
Prepfire:
  CHNP IHGFEDCBA 2 //The animation itself
  TNT1 A 0 A_TakeInventory ("GatlingSpinUp",1)
  TNT1 A 0 A_PlaySound("weapons/cycle")
  Goto Fire
Endfire:
  CHNP ABCDEFGHI 2 //The animation itself
  TNT1 A 0 A_GiveInventory ("GatlingSpinUp",1)
  TNT1 A 0 A_PlaySound("weapons/cycle")
  Goto Ready

Fire:
  CHNG A 0 A_JumpIfInventory ("GatlingSpinUp",1,"Prepfire")
  etc. etc. //Fire bullets, play sound, alert monsters...
  CHNG A 0 A_Refire
  Goto Endfire


Select:
  TNT1 A 0 A_GiveInventory ("GatlingSpinUp",1)
  etc. etc. //Play selection animation, raise...
And at the start of the fire state, it checks if it has a dummy item. If it does, it jumps to the "prepfire" and does the spinning animation.
At the end of the fire state, after the A_Refire, it jumps to the "endfire" state and gives the "GatlingSpinUp" back, so that as soon as you stop firing it spins back down again.
The "endfire" state is when it plays the spinning animation and gives you the dummy back. The dummy is also given when the weapon is selected (so that you still need to spin it up even if you just switched to the minigun).

Just make sure that the Inventory.MaxAmount of the dummy is 1. ;)

Edit: Btw I didn't actually look at your code, I don't really feel like looking at it. I just copy pasted something I did before that works... ^^
User avatar
Z86
Posts: 101
Joined: Mon Jan 24, 2011 5:22 pm

Re: Minigun Spindown Help

Post by Z86 »

AFAIK A_Refire causes the gun to deselect automatically when out of ammo.

In your case:
- It checks if it has ammo: it has 1.
- shoots, expends last ammo
- A_Refire is called, no ammo -> goto deselect

Placing the JumpIfNoAmmo right before the A_Refire should solve the problem.
User avatar
Kinsie
Posts: 7402
Joined: Fri Oct 22, 2004 9:22 am
Graphics Processor: nVidia with Vulkan support
Location: MAP33
Contact:

Re: Minigun Spindown Help

Post by Kinsie »

Z86 wrote:AFAIK A_Refire causes the gun to deselect automatically when out of ammo.

In your case:
- It checks if it has ammo: it has 1.
- shoots, expends last ammo
- A_Refire is called, no ammo -> goto deselect

Placing the JumpIfNoAmmo right before the A_Refire should solve the problem.
Works perfectly. Thanks!
Locked

Return to “Editing (Archive)”