// Screwgun

ACTOR Screwgun : IDMWeapon
{
	Weapon.SelectionOrder 400
	//Weapon.PreferredSkin "NailgunMarine"
	Weapon.AmmoUse 2
	Weapon.AmmoGive 8
	Weapon.Kickback 200
	Weapon.AmmoType "IDMShell"
	Inventory.PickupMessage "Screwgun! (Slot 3)"
	Tag "Screwgun"
	Decal BulletChip
	Damagetype "Bullet"
	+WEAPON.NOLMS
	States
	{
	Spawn:
	  NLSG D -1 Bright
	  Stop
	Ready:
	  NLSG A 1 A_WeaponReady
      Loop
	Deselect:
      TNT1 A 0 A_Lower
      TNT1 A 0 A_Lower
      NLSG A 1 A_Lower
      Loop
	Select:
	  TNT1 A 0 A_PlaySound("weapons/wswitch",CHAN_WEAPON)
	Sloop:
      TNT1 A 0 A_Raise
      TNT1 A 0 A_Raise
      NLSG A 1 A_Raise
      Loop
	Fire:
	  TNT1 A 0 A_GunFlash
	  TNT1 A 0 A_JumpIfInventory("PowerIDMWeaponLevel2",1,"Level2")
	  TNT1 A 0 A_JumpIfInventory("PowerQuadDamage",1,"Quad")
	  TNT1 A 0 A_FireCustomMissile("Screw",random(-9,9),1)
	  TNT1 AAAAA 0 A_FireCustomMissile("Screw",random(-9,9),0)
	  NLSG B 2 Bright Offset(0,43) A_Playsound("weapons/screwgfr",CHAN_WEAPON)
	  TNT1 AAAAAA 0 A_FireCustomMissile("Screw",random(-9,9),0)
	  NLSG C 2 Bright Offset(0,45) A_Playsound("weapons/screwgfr",CHAN_WEAPON)
	  TNT1 AAAAAA 0 A_FireCustomMissile("Screw",random(-9,9),0)
	FireEnd:
	  NLSG C 2 Bright Offset(0,47) A_Playsound("weapons/screwgfr",CHAN_WEAPON)
	  NLSG A 12 Offset(0,48)
	  NLSG A 2 Offset(0,44)
	  NLSG A 2 Offset(0,40)
	  NLSG A 2 Offset(0,38)
	  NLSG A 2 Offset(0,36)
	  NLSG A 2 Offset(0,34)
	  NLSG A 2 Offset(0,33)
	  TNT1 A 0 A_Refire
	  Goto Ready
	Quad:
	  TNT1 A 0 A_Playsound("misc/qdmg",CHAN_AUTO)
	  TNT1 A 0 A_FireCustomMissile("Screw",random(-9,9),1)
	  TNT1 AAAAA 0 A_FireCustomMissile("ExtremeScrew",random(-9,9),0)
	  NLSG B 2 Bright Offset(0,43) A_Playsound("weapons/screwgfr",CHAN_WEAPON)
	  TNT1 AAAAAA 0 A_FireCustomMissile("ExtremeScrew",random(-9,9),0)
	  NLSG C 2 Bright Offset(0,45) A_Playsound("weapons/screwgfr",CHAN_WEAPON)
	  TNT1 AAAAAA 0 A_FireCustomMissile("ExtremeScrew",random(-9,9),0)
	  Goto FireEnd
	Level2:
	  TNT1 A 0 A_JumpIfInventory("PowerQuadDamage",1,"QuadLevel2")
	  TNT1 A 0 A_FireCustomMissile("ScrewBall",random(-9,9),1)
	  TNT1 AAAAA 0 A_FireCustomMissile("ScrewBall",random(-9,9),0)
	  NLSG B 2 Bright Offset(0,43) A_Playsound("weapons/screwgfr",CHAN_WEAPON)
	  TNT1 AAAAAA 0 A_FireCustomMissile("ScrewBall",random(-9,9),0)
	  NLSG C 2 Bright Offset(0,45) A_Playsound("weapons/screwgfr",CHAN_WEAPON)
	  TNT1 AAAAAA 0 A_FireCustomMissile("ScrewBall",random(-9,9),0)
	  Goto FireEnd
	QuadLevel2:
	  TNT1 A 0 A_Playsound("misc/qdmg2",CHAN_5)
	  TNT1 A 0 A_FireCustomMissile("ExtremeScrewBall",random(-9,9),1)
	  TNT1 AAAAA 0 A_FireCustomMissile("ExtremeScrewBall",random(-9,9),0)
	  NLSG B 2 Bright Offset(0,43) A_Playsound("weapons/screwgfr",CHAN_WEAPON)
	  TNT1 AAAAAA 0 A_FireCustomMissile("ExtremeScrewBall",random(-9,9),0)
	  NLSG C 2 Bright Offset(0,45) A_Playsound("weapons/screwgfr",CHAN_WEAPON)
	  TNT1 AAAAAA 0 A_FireCustomMissile("ExtremeScrewBall",random(-9,9),0)
	  Goto FireEnd
	Flash:
	  TNT1 A 3 A_Light1
	  TNT1 A 3 A_Light2
	  Goto LightDone
	}
}

ACTOR Screw : FastProjectile
{
	ProjectileKickBack 50
	Radius 3
	Height 3
	Scale 0.55
	MissileHeight 8
	Missiletype "Screwblur"
	Speed 135
	Damage (10 * random(1,4))
	DamageType "Nail"
	+BloodSplatter
	-NOTELEPORT
	+SKYEXPLODE
	SeeSound ""
	DeathSound "weapons/screwimpct"
	Obituary "%o was screwed by %k's Screwgun."
	Decal BulletChip
	States
	{
	Spawn:
      NLPJ A 2 Bright A_Playsound("weapons/nailfly",CHAN_VOICE,0.2)
      Loop
	Crash:
	Death:
	  TNT1 A 0 A_SetScale(1.0)
	  TNT1 A 0 A_Jump(256,"Death1","Death2","Death3","Death4")
	Death1:
      PUFF A 3 Bright 
      PUFF BCD 2
	  Stop
	Death2:
      BPUF A 3 Bright
      BPUF BCD 2
	  Stop
    Death3:
      PUFY A 3 Bright
      PUFY BCD 2
	  Stop
    Death4:
      FPUF A 3 Bright
      FPUF BCD 2
	  Stop
	XDeath:
      TNT1 A 0 A_PlaySound("Weapons/NailHit",CHAN_VOICE,0.2)
	  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
    }
}

ACTOR Screwblur
{
	Scale 0.5
	+NOBLOCKMAP
	+NOGRAVITY
	+SHADOW
	+NOTELEPORT
	+CANNOTPUSH
	+NODAMAGETHRUST
	+CLIENTSIDEONLY
	RenderStyle Translucent
	Alpha 0.3
	States
	{
	Spawn:
	  NLPJ A 1 Bright A_FadeOut(0.1)
	  Loop
    }
}

ACTOR ExtremeScrew : Screw
{
	ProjectileKickback 100
	+EXTREMEDEATH
	States
	{
	XDeath:
	  TNT1 A 0 A_Playsound("misc/crit",CHAN_AUTO)
	  TNT1 A 0 A_PlaySound("Weapons/NailHit",CHAN_VOICE,0.2)
	  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
	}
}

ACTOR ScrewBall : Screw
{
	ProjectileKickBack 100
	Radius 6
	Height 6
	Scale 1.0
	Missiletype "ScrewBallBlur"
	Damage (15 * random(1,4))
	DamageType "Nail"
	+RIPPER
	States
	{
	Spawn:
      SPKB AB 2 Bright A_Playsound("weapons/nailfly",CHAN_VOICE,0.2)
      Loop
	Crash:
	Death:
	  TNT1 A 0 A_SetScale(1.0)
	  TNT1 A 0 A_Jump(256,"Death1","Death2","Death3","Death4")
	Death1:
      PUFF A 3 Bright 
      PUFF BCD 2
	  Stop
	Death2:
      BPUF A 3 Bright
      BPUF BCD 2
	  Stop
    Death3:
      PUFY A 3 Bright
      PUFY BCD 2
	  Stop
    Death4:
      FPUF A 3 Bright
      FPUF BCD 2
	  Stop
	XDeath:
      TNT1 A 0 A_PlaySound("Weapons/NailHit",CHAN_VOICE,0.2)
	  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
    }
}

ACTOR ScrewBallBlur : ScrewBlur
{
	Alpha 0.3
	States
	{
	Spawn:
	  TNT1 A 0
	  TNT1 A 0 A_Jump(128,"Spawn2")
	  SPKB A 1 Bright A_FadeOut(0.1)
	  Loop
	Spawn2:
	  SPKB B 1 Bright A_FadeOut(0.1)
	  Loop
    }
}

ACTOR ExtremeScrewBall : ScrewBall
{
	States
	{
	XDeath:
	  TNT1 A 0 A_Playsound("misc/crit",CHAN_AUTO)
	  TNT1 A 0 A_PlaySound("Weapons/NailHit",CHAN_VOICE,0.2)
	  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
	}
}