// Super Nailgun (Quake)

ACTOR SuperNailgun : IDMWeapon
{
	Weapon.AmmoUse 2
	Weapon.AmmoGive 80
	Weapon.AmmoType "IDMClip"
	Inventory.PickupSound "Misc/W_PkUp"
	Inventory.PickupMessage "Super Nailgun! (Slot 4)"
	//Weapon.PreferredSkin "SuperNailgunMarine"
	Weapon.Selectionorder 400
	Obituary "%o was punctured by %k's Super Nailgun."
	Tag "Super Nailgun"
	+WEAPON.NOLMS
	States
	{
	Spawn:
      NLMG F -1 Bright
      Loop
	Select:
	  TNT1 A 0 A_PlaySound("weapons/wswitch",CHAN_WEAPON)
	Sloop:
      TNT1 A 0 A_Raise
      TNT1 A 0 A_Raise
      SNAI E 1 A_Raise
      Loop
	Deselect:
      TNT1 A 0 A_Lower
      TNT1 A 0 A_Lower
      SNAI E 1 A_Lower
      Loop
	Ready:
      SNAI EEEEEDDDDDAAAAABBBBB 1 A_WeaponReady
      Loop
/* The Fire state of the Super Nailgun is a bit complicated. What it essentially
   does is it fluctuates its rate of fire every shot from slightly slower to
   slightly faster rate. Each shot's fire state has a 50% chance to jump to a
   firing state with a different rate of fire. */
	Fire:
      TNT1 A 0 A_JumpIfNoAmmo("FireEnd")
	Normal:
      TNT1 A 0 A_GunFlash
      TNT1 A 0 A_PlayWeaponSound("Weapons/SNailFire")
	  TNT1 A 0 A_JumpIfInventory("PowerIDMWeaponLevel2", 1, "Level2")
	  TNT1 A 0 A_JumpIfInventory("PowerQuadDamage", 1, "Quad")
      SNAI C 2 Bright A_FireCustomMissile("BigNail",0, 1)
      SNAI D 1 A_Jump(127,1)
      SNAI D 1
	Normal2:
      TNT1 A 0 A_JumpIfNoAmmo("FireEnd")
      TNT1 A 0 A_PlayWeaponSound("Weapons/SNailFire")
      TNT1 A 0 A_GunFlash
	  TNT1 A 0 A_JumpIfInventory("PowerIDMWeaponLevel2", 1, "Level22")
	  TNT1 A 0 A_JumpIfInventory("PowerQuadDamage", 1, "Quad2")
      SNAI H 2 Bright A_FireCustomMissile("BigNail", 0, 1)
	  SNAI B 1 A_Jump(127,1)
	  SNAI B 1
	  SNAI E 2 A_Refire
	  Goto FireEnd
	Level2:
	  TNT1 A 0 A_JumpIfInventory("PowerQuadDamage", 1, "QuadLevel2")
      TNT1 A 0 Bright A_FireCustomMissile("BigNail",0, 1,-3,-5)
      TNT1 A 0 Bright A_FireCustomMissile("BigNail",0, 0,3,-5)
      SNAI C 2 Bright A_FireCustomMissile("BigNail",0, 0)
	  Goto Normal+5
	Level22:
	  TNT1 A 0 A_JumpIfInventory("PowerQuadDamage", 1, "QuadLevel22")
      TNT1 A 0 A_JumpIfNoAmmo("FireEnd")
      TNT1 A 0 Bright A_FireCustomMissile("BigNail",0, 1,-3)
      TNT1 A 0 Bright A_FireCustomMissile("BigNail",0, 0,3)
      SNAI F 2 Bright A_FireCustomMissile("BigNail",0, 0, 0, -5)
	  Goto Normal2+6
	QuadLevel2:
	  TNT1 A 0 A_Playsound("misc/qdmg2",CHAN_5)
      TNT1 A 0 A_PlayWeaponSound("Weapons/SNailFire")
      TNT1 A 0 A_GunFlash
      TNT1 A 0 Bright A_FireCustomMissile("ExtremeBigNail",0, 1,-3,-5)
      TNT1 A 0 Bright A_FireCustomMissile("ExtremeBigNail",0, 0,3,-5)
      SNAI C 2 Bright A_FireCustomMissile("ExtremeBigNail",0, 0)
	  Goto Normal+5
	QuadLevel22:
      TNT1 A 0 A_JumpIfNoAmmo("FireEnd")
	  TNT1 A 0 A_Playsound("misc/qdmg2",CHAN_5)
      SNAI F 0 A_PlayWeaponSound("Weapons/SNailFire")
      SNAI F 0 A_GunFlash
      TNT1 A 0 Bright A_FireCustomMissile("ExtremeBigNail",0, 1,-3)
      TNT1 A 0 Bright A_FireCustomMissile("ExtremeBigNail",0, 0,3)
      SNAI F 2 Bright A_FireCustomMissile("ExtremeBigNail",0, 0,0,-5)
	  Goto Normal2+6
	Quad:
	  TNT1 A 0 A_Playsound("misc/qdmg2",CHAN_5)
      SNAI C 2 Bright A_FireCustomMissile("ExtremeBigNail",0, 1)
	  Goto Normal+5
	Quad2:
	  TNT1 A 0 A_Playsound("misc/qdmg2",CHAN_5)
      TNT1 A 0 A_PlayWeaponSound("Weapons/SNailFire")
      TNT1 A 0 A_GunFlash
      SNAI H 2 Bright A_FireCustomMissile("ExtremeBigNail", 0, 1)
	  Goto Normal2+6
	FireEnd:
      SNAI D 2 A_ReFire("Fire")
      SNAI A 2 A_ReFire("Fire")
      SNAI B 2 A_ReFire("Fire")
	  SNAI E 3 A_ReFire("Fire")
      SNAI D 3 A_ReFire("Fire")
      SNAI A 3 A_ReFire("Fire")
      SNAI B 4 A_ReFire("Fire")
      Goto Ready
	Flash:
      TNT1 A 5 Bright A_Light1
      Goto LightDone
  }
}

ACTOR BigNail : Nail
{
	Radius 9
	Height 9
	Damage (18 * random(1,4))
	Scale 0.85
	ProjectileKickback 100
	Missiletype "BigNailblur"
	Obituary "%o was punctured by %k's Super Nailgun."
}

ACTOR BigNailblur : Nailblur
{
	Scale 0.8
	+CLIENTSIDEONLY
}

ACTOR ExtremeBigNail : BigNail
{
	ProjectileKickback 200
	+EXTREMEDEATH
	States
	{
	XDeath:
	  TNT1 A 0 A_Playsound("misc/crit",CHAN_AUTO)
	  NLPJ B 0 A_PlaySound("Weapons/NailHit")
	  TNT1 A 1 A_SpawnItemEx("BloodSplatter",0,0,0,random(0,2.5),random(0,2.5),random(0,2.5),random(0,360))
      Stop
	}
}