// Railgun (Skulltag / Quake 2/3)

ACTOR IDMRailgun : IDMWeapon
{
  Weapon.KickBack 200
  Weapon.Selectionorder 400
  Weapon.AmmoUse 10
  Weapon.AmmoGive 40
  Weapon.AmmoType "IDMCell"
  //Weapon.PreferredSkin "RailgunMarine"
  Weapon.SisterWeapon "RailgunLevel2"
  Inventory.Pickupmessage "Railgun! (Slot 6)"
  Obituary "%o was railed by %k."
  Decal RailScorch
  DamageType "Railgun"
  Tag "Railgun"
  +WEAPON.NOAUTOAIM
  +WEAPON.NOLMS
  States
  {
  Ready:
	RLGG A 1 A_Weaponready
    Loop
  Deselect:
    RLGG A 0 A_Lower
    RLGG A 0 A_Lower
    RLGG A 1 A_Lower
    Loop
  Select:
	TNT1 A 0 A_PlaySound("weapons/wswitch",CHAN_WEAPON)
  Sloop:
    RLGG A 0 A_Raise
    RLGG A 0 A_Raise
    RLGG A 1 A_Raise
    Loop
  Fire:
	TNT1 A 0 A_JumpIfInventory("PowerQuadDamage",1,"Quad")
	Goto Normal
  Quad:
	TNT1 A 0 A_Playsound("misc/qdmg",CHAN_AUTO,1)
  Normal:
	RLGG D 0 A_GunFlash
	RLGG D 0 A_RailAttack(random(200,300))
	TNT1 A 0 A_FireBullets(0,0,1,0,"RailPuff",FBF_NORANDOMPUFFZ)
	RLGG D 2 Bright Offset(0,45) A_Playsound("weapons/railgun", CHAN_WEAPON)
    RLGG C 2 Bright Offset(0,40)
	RLGG B 2 Bright Offset(0,35)
	RLGG A 2 Bright
	RLGG E 3
    RLGG F 3 A_Playsound("weapons/railclip",CHAN_AUTO,0.75)
	RLGG G 4
	RLGG H 9 A_CheckReload
	RLGG I 3
	RLGG J 3
	RLGG K 4 A_Playsound("weapons/railreload",CHAN_AUTO)
	RLGG L 4
	RLGG A 4
    TNT1 A 0 A_ReFire
    Goto Ready
  Flash:
	TNT1 A 6 A_Light1
    Goto LightDone
  Spawn:
    RAIL A -1 Bright
    Stop
  }
}

ACTOR RailgunLevel2 : IDMRailgun
{
  Weapon.AmmoUse 5
  Weapon.Sisterweapon "IDMRailgun"
  +POWERED_UP
  States
  {
  Fire:
	TNT1 A 0 A_JumpIfInventory("PowerQuadDamage",1,"Quad")
	Goto Normal
  Quad:
	TNT1 A 0 A_Playsound("misc/qdmg",CHAN_AUTO,1)
  Normal:
	RLGG D 0 A_GunFlash
	RLGG A 0 A_StopSound(CHAN_6)
	RLGG D 0 A_RailAttack(random(200,300),0,1,"Cyan","LightBlue",RGF_FULLBRIGHT,random(0,2),"BulletPuff",0,0,8192,10)
	RLGG D 0 A_RailAttack(random(200,300),0,0,"Cyan","LightBlue",RGF_FULLBRIGHT|RGF_EXPLICITANGLE,random(0,2),"BulletPuff",-5,0,8192,10)
	RLGG D 0 A_RailAttack(random(200,300),0,0,"Cyan","LightBlue",RGF_FULLBRIGHT|RGF_EXPLICITANGLE,random(0,2),"BulletPuff",5,0,8192,10)
	TNT1 A 0 A_FireBullets(0,0,1,0,"RailPuffLevel2",FBF_NORANDOMPUFFZ)
	TNT1 A 0 A_FireBullets(-5,0,1,0,"RailPuffLevel2",FBF_NORANDOMPUFFZ|FBF_EXPLICITANGLE)
	TNT1 A 0 A_FireBullets(5,0,1,0,"RailPuffLevel2",FBF_NORANDOMPUFFZ|FBF_EXPLICITANGLE)
	RLGG D 2 Bright Offset(0,45) A_Playsound("weapons/railgun", CHAN_WEAPON)
    RLGG C 2 Bright Offset(0,40)
	RLGG B 2 Bright Offset(0,35)
	RLGG A 2 Bright
/*	TNT1 A 0 A_CheckForReload(4,"Recoil")
	Goto FireEnd
  Recoil:*/
	RLGG A 6 Offset(0,34)
	RLGG A 4 Offset(0,33)
	Goto Ready
/*  FireEnd:
	RLGG E 3
    RLGG F 3 A_Playsound("weapons/railclip",CHAN_AUTO,0.75)
	RLGG G 4
	RLGG H 12 A_CheckReload
	RLGG IJ 3
	RLGG K 4 A_Playsound("weapons/railreload",CHAN_AUTO)
	RLGG L 4
	RLGG A 4 A_ResetReloadCounter
    RLGG M 0 A_ReFire
    Goto Ready*/
	}
}

ACTOR Railgun : IDMWeapon // Railgun for the Instagib modifier
{
  Weapon.KickBack 200
  Weapon.SelectionOrder 1
  Weapon.AmmoUse 0
  Weapon.AmmoGive 0
  Weapon.AmmoType None
  //Weapon.PreferredSkin "RailgunMarine"
  Inventory.Pickupmessage "Railgun!"
  Obituary "%o was railed by %k."
  Decal RailScorch
  DamageType "Railgun"
  Tag "Railgun (Instagib)"
  +WEAPON.NOAUTOAIM
  +WEAPON.NOLMS
  +WEAPON.CHEATNOTWEAPON
  +WEAPON.ALLOW_WITH_RESPAWN_INVUL
  States
  {
  Ready:
	RLGG A 1 A_Weaponready
    Loop
  Deselect:
    TNT1 A 0 A_Lower
    Loop
  Select:
    TNT1 A 0 A_PlaySound("weapons/wswitch",CHAN_WEAPON)
  Sloop:
    TNT1 A 0 A_Raise
    Loop
  Fire:
	RLGG D 0 A_GunFlash
	TNT1 A 0 A_FireBullets(0,0,1,0,"RailPuff",FBF_NORANDOMPUFFZ)
	RLGG D 0 A_RailAttack(999)
	RLGG D 2 Bright Offset(0,45) A_Playsound("weapons/railgun", CHAN_WEAPON)
    RLGG C 2 Bright Offset(0,40)
	RLGG B 2 Bright Offset(0,35)
	RLGG A 2 Bright
	RLGG E 3
    RLGG F 3 A_Playsound("weapons/railclip",CHAN_AUTO,0.75)
	RLGG G 4
	RLGG H 9 A_CheckReload
	RLGG I 3
	RLGG J 3
	RLGG K 4 A_Playsound("weapons/railreload",CHAN_AUTO)
	RLGG L 4
	RLGG A 4
    TNT1 A 0 A_ReFire
    Goto Ready
  }
}

ACTOR RailPuff : BulletPuff
{
  +NOBLOCKMAP
  +NOGRAVITY
  +ALWAYSPUFF
  +ALLOWPARTICLES
  -RANDOMIZE
  +CLIENTSIDEONLY
  RenderStyle Translucent
  VSpeed 0
  Alpha 0.5
  DamageType "Railgun"
  States
  {
  Spawn:
  See:
	TNT1 A 0
	TNT1 A 0 A_Playsound("weapons/railimpact",CHAN_AUTO,0.9)
    RPUF A 3 A_Playsound("weapons/railhit",CHAN_AUTO,0.9)
    RPUF BCD 2
    Stop
  XDeath:
	TNT1 A 0
	TNT1 A 0 A_Playsound("weapons/railimpact",CHAN_AUTO,0.9)
    RPUF A 3 A_Playsound("weapons/railhit",CHAN_AUTO,0.9)
    RPUF BCD 2
    Stop
  }
}

ACTOR RailPuffLevel2 : RailPuff
{
  States
  {
  Spawn:
  See:
	TNT1 A 0
	TNT1 A 0 A_Playsound("weapons/railimpact",CHAN_AUTO,0.3)
	RPUF A 3 A_Playsound("weapons/railhit",CHAN_AUTO,0.3)
	RPUF BCD 2
	Stop
  XDeath:
	TNT1 A 0
	TNT1 A 0 A_Playsound("weapons/railimpact",CHAN_AUTO,0.3)
    RPUF A 3 A_Playsound("weapons/railhit",CHAN_AUTO,0.3)
    RPUF BCD 2
    Stop
  }
}