actor Rifle : Weapon
{
  obituary "%o was mowed down by %k's chaingun."
  weapon.ammotype1 "RifleClip"
  weapon.ammouse 1
  weapon.ammogive2 999
  weapon.ammogive1 999
  Weapon.SelectionOrder 1700  
  weapon.ammotype2 "RifleAmmo"
  states
  {
  Ready:
	M1GE A 0 A_JumpIfInventory("thrownade",1,"ThrowGrenade")
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
	AK47 A 0 A_JumpIfInventory("Kinfeammo",1,"UseKnife")
    RFGG A 1 A_WeaponReady
    loop
  Deselect: 
    RFGG A 0 A_Lower
    RFGG A 0 A_Lower
    RFGG A 1 A_Lower
    loop
  Select:
    RFGG A 0 A_Raise
    RFGG A 0 A_Raise
    RFGG A 1 A_Raise
    loop
  Fire:
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
    RFGG A 0 A_jumpifinventory("doubletap",1,"Fire_doubletap")
    RFGG B 4
    RFGG B 0 A_playsound("Rifle/fire")
    RFGG B 0 A_Firebullets(3,3,1,random(750,750),"Bulletpuff")
	TNTT A 0 A_FireCustomMissile("BulletCasingSpawner",0,0,-6,2)
    RFGG C 4 
    RFGG A 3 
    RFGG A 0 A_Jumpifnoammo("Reload")
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
    RFGG A 0 A_Refire 
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
    RFGG A 0 A_Jumpifnoammo("Reload")
	goto ready
  Fire_doubletap:
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
    RFGG B 3
    RFGG B 0 A_playsound("Rifle/fire")
    RFGG B 0 A_Firebullets(3,3,1,random(750,750),"Bulletpuff")
	TNTT A 0 A_FireCustomMissile("BulletCasingSpawner",0,0,-6,2)
    RFGG C 3 
    RFGG A 2 
    RFGG A 0 A_Jumpifnoammo("Reload")
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
    RFGG A 0 A_Refire 
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
    RFGG A 0 A_Jumpifnoammo("Reload")
	goto ready
  Reload:
	AUG1 A 0 A_TakeInventory("IsReloading",1)
    RFRE A 0 A_jumpifinventory("SpeedCola",1,"Reload_speed")
    RFRE A 0 A_JumpIfInventory("Rifleclip", 10, "Ready")
    RFRE A 0 A_JumpIfInventory("Rifleammo", 1, 1)
	goto ready+1
	RFRE E 0 A_Playsound("Rifle/clipout")
    RFRE ABCD 2
    RFRE E 20
  Goto Reload2
  Reload2:
	RFRE E 0 A_GiveInventory("RifleClip",1)
	RFRE E 0 A_TakeInventory("Rifleammo",1)
	RFRE E 0
	RFRE E 0
	RFRE E 0 A_jumpifInventory("RifleClip",10,"ReloadDone")
	RFRE E 0 A_JumpIfInventory("Rifleammo", 1, "Reload2")
    Goto Reloaddone
  ReloadDone:
	RFRE E 0 A_Playsound("Rifle/clipin")
    RFRE E 16
	RFRE E 0 A_Playsound("Rifle/bolt")
    RFRE E 17
    RFRE DCBA 2
    Goto Ready
  Reload_speed:
    RFRE A 0 A_JumpIfInventory("Rifleclip", 10, "Ready")
    RFRE A 0 A_JumpIfInventory("Rifleammo", 1, 1)
	goto ready+1
	RFRE E 0 A_Playsound("Rifle/clipout")
    RFRE ABCD 1
    RFRE E 15
  Goto Reload2_speed
  Reload2_speed:
	RFRE E 0 A_GiveInventory("RifleClip",1)
	RFRE E 0 A_TakeInventory("Rifleammo",1)
	RFRE E 0
	RFRE E 0
	RFRE E 0 A_jumpifInventory("RifleClip",10,"ReloadDone_speed")
	RFRE E 0 A_JumpIfInventory("Rifleammo", 1, "Reload2_speed")
    Goto Reloaddone_speed
  ReloadDone_speed:
	RFRE E 0 A_Playsound("Rifle/clipin")
    RFRE E 11
	RFRE E 0 A_Playsound("Rifle/bolt")
    RFRE E 12
    RFRE DCBA 1
    Goto Ready
  ThrowGrenade:
     HNDG BCD 1
     HNDG E 1 A_PlaySound("weapons/grenadepin")
     HNDG FGHH 1
     HNDG I 1 A_PlaySound("weapons/grenadethr") 
     HNDG J 0 A_FireCustomMissile("ThrownGrenade",0,0,0,0)
     HNDG J 0 A_PlaySound("weapons/grenadethr")
     HNDG JKLMNOPQ 1
     HNDG Q 0 A_TakeInventory("thrownade")
     Goto Ready
  Useknife:
     KNFG A 0 A_jumpifinventory("Machete",1,"UseMachete")
     KNFG ABC 2
	 KNFG C 0 A_CustomPunch (110,1,0,"KnifePuff")
	 KNFG DEF 2
	 KNFG F 0 A_TakeInventory("Kinfeammo")
	 goto ready
  UseMachete:
     MHT4 ABC 2
	 MHT4 C 0 A_CustomPunch (450,1,0,"Machetepuff")
	 MHT4 DEFG 2
	 MHT4 G 0 A_TakeInventory("Kinfeammo")
	 goto ready
  Flash:
    TNTT A 1
    stop
  Spawn:
    RFUN A -1
    stop
  }
}

actor RifleClip : Ammo
{
    inventory.icon "CLIPA0"
    inventory.amount 0
    inventory.maxamount 10
    ammo.backpackamount 0
    ammo.backpackmaxamount 10
    +IGNORESKILL
}


actor RifleAmmo : Ammo
{
    inventory.icon "CLIPA0"
    inventory.amount 20
    inventory.maxamount 120
    ammo.backpackamount 20
    ammo.backpackmaxamount 120
    +IGNORESKILL
    inventory.pickupmessage "Got A Rifle Clip!"  
    States
    {
    Spawn:
      CLIP A -1
      Stop
    }
}

actor PAPRifleAmmo : Ammo
{
    inventory.icon "CLIPA0"
    inventory.amount 20
    inventory.maxamount 240
    ammo.backpackamount 20
    ammo.backpackmaxamount 240
    +IGNORESKILL
    inventory.pickupmessage "Got A Rifle Clip!"  
    States
    {
    Spawn:
      CLIP A -1
      Stop
    }
}

actor PAPRifle : Weapon
{
  obituary "%o was mowed down by %k's chaingun."
  weapon.ammotype1 "PAPRifleClip"
  weapon.ammouse 1
  weapon.ammogive2 999
  weapon.ammogive1 999
  Weapon.SelectionOrder 1300  
  weapon.ammotype2 "RifleAmmo"
  states
  {
  Ready:
	M1GE A 0 A_JumpIfInventory("thrownade",1,"ThrowGrenade")
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload")  
	AK47 A 0 A_JumpIfInventory("Kinfeammo",1,"UseKnife")
    RFGG A 1 A_WeaponReady
    loop
  Deselect: 
    RFGG A 0 A_Lower
    RFGG A 0 A_Lower
    RFGG A 1 A_Lower
    loop
  Select:
    RFGG A 0 A_Raise
    RFGG A 0 A_Raise
    RFGG A 1 A_Raise
    loop
  Useknife:
     KNFG A 0 A_jumpifinventory("Machete",1,"UseMachete")
     KNFG ABC 2
	 KNFG C 0 A_CustomPunch (110,1,0,"KnifePuff")
	 KNFG DEF 2
	 KNFG F 0 A_TakeInventory("Kinfeammo")
	 goto ready
  UseMachete:
     MHT4 ABC 2
	 MHT4 C 0 A_CustomPunch (450,1,0,"Machetepuff")
	 MHT4 DEFG 2
	 MHT4 G 0 A_TakeInventory("Kinfeammo")
	 goto ready
  Fire:
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
    RFGG A 0 A_jumpifinventory("doubletap",1,"Fire_doubletap")
    RFGG B 4
    RFGG B 0 A_playsound("Rifle/fire")
    RFGG B 0 A_Firebullets(2,3,1,random(1500,1500),"Bulletpuff")
	TNTT A 0 A_FireCustomMissile("BulletCasingSpawner",0,0,-6,2)
    RFGG C 4 
    RFGG A 3 
    RFGG A 0 A_Jumpifnoammo("Reload")
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
    RFGG A 0 A_Refire 
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
    RFGG A 0 A_Jumpifnoammo("Reload")
	goto ready
  Fire_doubletap:
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
    RFGG B 3
    RFGG B 0 A_playsound("Rifle/fire")
    RFGG B 0 A_Firebullets(2,3,1,random(1500,1500),"Bulletpuff")
	TNTT A 0 A_FireCustomMissile("BulletCasingSpawner",0,0,-6,2)
    RFGG C 3 
    RFGG A 2 
    RFGG A 0 A_Jumpifnoammo("Reload")
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
    RFGG A 0 A_Refire 
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
    RFGG A 0 A_Jumpifnoammo("Reload")
	goto ready
  Reload:
	AUG1 A 0 A_TakeInventory("IsReloading",1)
    RFRE A 0 A_jumpifinventory("SpeedCola",1,"Reload_speed")
    RFRE A 0 A_JumpIfInventory("PAPRifleclip", 15, "Ready")
    RFRE A 0 A_JumpIfInventory("PAPRifleammo", 1, 1)
	goto ready+1
	RFRE E 0 A_Playsound("Rifle/clipout")
    RFRE ABCD 2
    RFRE E 20
  Goto Reload2
  Reload2:
	RFRE E 0 A_GiveInventory("PAPRifleClip",1)
	RFRE E 0 A_TakeInventory("PAPRifleammo",1)
	RFRE E 0
	RFRE E 0
	RFRE E 0 A_jumpifInventory("PAPRifleClip",15,"ReloadDone")
	RFRE E 0 A_JumpIfInventory("PAPRifleammo", 1, "Reload2")
    Goto Reloaddone
  ReloadDone:
	RFRE E 0 A_Playsound("Rifle/clipin")
    RFRE E 16
	RFRE E 0 A_Playsound("Rifle/bolt")
    RFRE E 17
    RFRE DCBA 2
    Goto Ready
  Reload_speed:
    RFRE A 0 A_JumpIfInventory("PAPRifleclip", 15, "Ready")
    RFRE A 0 A_JumpIfInventory("PAPRifleammo", 1, 1)
	goto ready+1
	RFRE E 0 A_Playsound("Rifle/clipout")
    RFRE ABCD 1
    RFRE E 15
  Goto Reload2_speed
  Reload2_speed:
	RFRE E 0 A_GiveInventory("PAPRifleClip",1)
	RFRE E 0 A_TakeInventory("PAPRifleammo",1)
	RFRE E 0
	RFRE E 0
	RFRE E 0 A_jumpifInventory("PAPRifleClip",15,"ReloadDone_speed")
	RFRE E 0 A_JumpIfInventory("PAPRifleammo", 1, "Reload2_speed")
    Goto Reloaddone_speed
  ReloadDone_speed:
	RFRE E 0 A_Playsound("Rifle/clipin")
    RFRE E 11
	RFRE E 0 A_Playsound("Rifle/bolt")
    RFRE E 12
    RFRE DCBA 1
    Goto Ready
  ThrowGrenade:
     HNDG BCD 1
     HNDG E 1 A_PlaySound("weapons/grenadepin")
     HNDG FGHH 1
     HNDG I 1 A_PlaySound("weapons/grenadethr") 
     HNDG J 0 A_FireCustomMissile("ThrownGrenade",0,0,0,0)
     HNDG J 0 A_PlaySound("weapons/grenadethr")
     HNDG JKLMNOPQ 1
     HNDG Q 0 A_TakeInventory("thrownade")
     Goto Ready
  Flash:
    TNTT A 1
    stop
  Spawn:
    MGUN A -1
    stop
  }
}

actor PAPRifleClip : Ammo
{
    inventory.icon "CLIPA0"
    inventory.amount 0
    inventory.maxamount 15
    ammo.backpackamount 0
    ammo.backpackmaxamount 15
    +IGNORESKILL
}