Actor M1 : Weapon
{
  obituary "%o was begded down by %k's M1."
  inventory.pickupmessage "You got the M1!"
  weapon.ammotype "M1Clip"
  weapon.ammouse 1
  weapon.ammogive2 999
  weapon.ammogive1 999
  weapon.ammotype2 "M1Ammo"
  Weapon.SelectionOrder 900  
  +WEAPON.NOAUTOFIRE
  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")
    M1GE A 1 A_WeaponReady
    Loop
  Deselect:
    M1GE A 0 A_Lower
    M1GE A 0 A_Lower
    M1GE A 1 A_Lower
    Loop
  Select:
    M1GE A 0 A_Raise
    M1GE A 0 A_Raise
    M1GE A 1 A_Raise
    Loop
  Fire:
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
    M1GE A 0 A_jumpifinventory("deadshot",1,"Fire_deadshot")
    M1GE A 0 A_jumpifinventory("Doubletap",1,"Fire_Doubletap")
    M1GE A 0 A_jumpifnoammo("Reload")
	TNTT A 0 A_playsound("M1/fire")
    M1GF A 1 bright A_FireBullets (1.5,1.5,1,random(450,450),"BulletPuff")
	TNTT A 0 A_FireCustomMissile("BulletCasingSpawner",0,0,-6,2)
    M1GF B 2 bright
    M1GE A 5
    M1GE A 0 A_jumpifnoammo("Reload")
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
    Goto Ready
  Fire_deadshot:
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
    M1GE A 0 A_jumpifinventory("Doubletap",1,"Fire_Doubletapdeadshot")
    M1GE A 0 A_jumpifnoammo("Reload")
	TNTT A 0 A_playsound("M1/fire")
    M1GF A 1 bright A_FireBullets (1.5,1.5,1,random(450,450),"BulletPuff")
	TNTT A 0 A_FireCustomMissile("BulletCasingSpawner",0,0,-6,2)
    M1GF B 2 bright
    M1GE A 5
    M1GE A 0 A_jumpifnoammo("Reload")
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
    Goto Ready
  Fire_Doubletapdeadshot:
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
    M1GE A 0 A_jumpifnoammo("Reload")
	TNTT A 0 A_playsound("M1/fire")
    M1GF A 1 bright A_FireBullets (1.5,1.5,1,random(450,450),"BulletPuff")
	TNTT A 0 A_FireCustomMissile("BulletCasingSpawner",0,0,-6,2)
    M1GF B 1 bright
    M1GE A 3
    M1GE A 0 A_jumpifnoammo("Reload")
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
    Goto Ready
  altfire:
    M1GE A 0 A_jumpifinventory("m1sights",1,"altfire2")
    M1GE A 0 A_giveinventory("m1sights",1)
    M1GE A 0 A_zoomfactor(1.3)
	goto ready
  altfire2:
    M1GE A 0 A_takeinventory("m1sights",1)
    M1GE A 0 A_zoomfactor(1.0)
	goto ready
  Fire_Doubletap:
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
    M1GE A 0 A_jumpifnoammo("Reload")
	TNTT A 0 A_playsound("M1/fire")
    M1GF A 1 bright A_FireBullets (1.5,1.5,1,random(450,450),"BulletPuff")
	TNTT A 0 A_FireCustomMissile("BulletCasingSpawner",0,0,-6,2)
    M1GF B 1 bright
    M1GE A 3
    M1GE A 0 A_jumpifnoammo("Reload")
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
    Goto Ready
  Reload:	
    PIRE A 0 A_takeinventory("IsReloading",1)
    M1GE A 0 A_takeinventory("m1sights",1)
    M1GE A 0 A_zoomfactor(1.0)
    M1RE A 0 A_jumpifinventory("speedcola",1,"Reload_speed")
    M1RE A 0 A_jumpifinventory("M1clip",8,"Ready")
    M1RE A 0 A_jumpifinventory("M1ammo",1,1)
	goto ready+1
    M1RE A 0 A_playsound("m1/clipout")
    M1RE ABCD 2
    M1RE D 20
    goto reload2 
  Reload2:
    M1RE D 0 A_giveinventory("M1clip",1)
    M1RE D 0 A_takeinventory("M1ammo",1)
    M1RE D 0 A_jumpifinventory("M1clip",8,"Reloaddone")
    M1RE D 0 A_jumpifinventory("M1ammo",1,"Reload2")
	goto reloaddone
  reloaddone:
    M1RE D 0 A_playsound("m1/clipin")
    M1RE D 20
    M1RE D 0 A_playsound("m1/bolt")
    M1RE D 10
	M1RE DCBA 2
	goto ready
  Reload_speed:
    M1RE A 0 A_jumpifinventory("M1clip",8,"Ready")
    M1RE A 0 A_jumpifinventory("M1ammo",1,1)
	goto ready+1
    M1RE A 0 A_playsound("m1/clipout")
    M1RE ABCD 1
    M1RE D 10
    goto reload2_speed 
  Reload2_speed:
    M1RE D 0 A_giveinventory("M1clip",1)
    M1RE D 0 A_takeinventory("M1ammo",1)
    M1RE D 0 A_jumpifinventory("M1clip",8,"Reloaddone_speed")
    M1RE D 0 A_jumpifinventory("M1ammo",1,"Reload2_speed")
	goto reloaddone_speed
  reloaddone_speed:
    M1RE D 0 A_playsound("m1/clipin")
    M1RE D 10
    M1RE D 0 A_playsound("m1/bolt")
    M1RE D 5
	M1RE 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:
    TNT1 A 2 bright
    Stop
  Spawn:
    M1GR A -1
    Stop
  }
}

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

actor M1sights : Ammo
{
    inventory.amount 0
    inventory.maxamount 1
}

actor PAPM1sights : Ammo
{
    inventory.amount 0
    inventory.maxamount 1
}

actor M1Ammo : Ammo
{
    inventory.icon "CLIPA0"
    inventory.amount 30
    inventory.maxamount 180
    ammo.backpackamount 30
    ammo.backpackmaxamount 180
    +IGNORESKILL
    inventory.pickupmessage "Got M1 rounds!"  
    States
    {
    Spawn:
      CLIP A -1
      Stop
    }
	}
	
	actor PAPM1Ammo : Ammo
{
    inventory.icon "CLIPA0"
    inventory.amount 16
    inventory.maxamount 320
    ammo.backpackamount 16
    ammo.backpackmaxamount 320
    +IGNORESKILL
    inventory.pickupmessage "Got M1 rounds!"  
    States
    {
    Spawn:
      CLIP A -1
      Stop
    }
	}
	
Actor PAPM1 : Weapon
{
  obituary "%o was begded down by %k's M1."
  inventory.pickupmessage "You got the M1!"
  weapon.ammotype "PAPM1Clip"
  weapon.ammouse 1
  weapon.ammogive2 999
  weapon.ammogive1 999
  weapon.ammotype2 "PAPM1Ammo"
  Weapon.SelectionOrder 1300  
  +WEAPON.NOAUTOFIRE
  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")
    M1GE A 1 A_WeaponReady
    loop
  Deselect:
    M1GE A 0 A_Lower
    M1GE A 0 A_Lower
    M1GE A 1 A_Lower
    Loop
  Select:
    M1GE A 0 A_Raise
    M1GE A 0 A_Raise
    M1GE 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") 
    M1GE A 0 A_jumpifinventory("Doubletap",1,"Fire_Doubletap")
    M1GE A 0 A_jumpifnoammo("Reload")
	TNTT A 0 A_playsound("M1/fire")
    M1GF A 1 bright A_FireBullets (1.5,1.5,1,random(900,900),"BulletPuff")
	TNTT A 0 A_FireCustomMissile("BulletCasingSpawner",0,0,-6,2)
    M1GF B 2 bright
    M1GE A 5
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
    M1GE A 0 A_jumpifnoammo("Reload")
    Goto Ready
  Fire_Doubletap:
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
    M1GE A 0 A_jumpifnoammo("Reload")
	TNTT A 0 A_playsound("M1/fire")
    M1GF A 1 bright A_FireBullets (1.5,1.5,1,random(900,900),"BulletPuff")
	TNTT A 0 A_FireCustomMissile("BulletCasingSpawner",0,0,-6,2)
    M1GF B 1 bright
    M1GE A 3
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
    M1GE A 0 A_jumpifnoammo("Reload")
    Goto Ready
  altfire:
    M1GE A 0 A_jumpifinventory("PAPm1sights",1,"altfire2")
    M1GE A 0 A_giveinventory("PAPm1sights",1)
    M1GE A 0 A_zoomfactor(1.3)
	goto ready
  altfire2:
    M1GE A 0 A_takeinventory("PAPm1sights",1)
    M1GE A 0 A_zoomfactor(1.0)
	goto ready
  Reload:	
    PIRE A 0 A_takeinventory("IsReloading",1)
    PIRE A 0 A_takeinventory("PAPm1sights",1)
    M1GE A 0 A_zoomfactor(1.0)
    M1RE A 0 A_jumpifinventory("speedcola",1,"Reload_speed")
    M1RE A 0 A_jumpifinventory("PAPM1clip",16,"Ready")
    M1RE A 0 A_jumpifinventory("PAPM1ammo",1,1)
	goto ready+1
    M1RE A 0 A_playsound("m1/clipout")
    M1RE ABCD 2
    M1RE D 20
    goto reload2 
  Reload2:
    M1RE D 0 A_giveinventory("PAPM1clip",1)
    M1RE D 0 A_takeinventory("PAPM1ammo",1)
    M1RE D 0 A_jumpifinventory("PAPM1clip",16,"Reloaddone")
    M1RE D 0 A_jumpifinventory("PAPM1ammo",1,"Reload2")
	goto reloaddone
  reloaddone:
    M1RE D 0 A_playsound("m1/clipin")
    M1RE D 20
    M1RE D 0 A_playsound("m1/bolt")
    M1RE D 10
	M1RE DCBA 2
	goto ready
  Reload_speed:
    M1RE A 0 A_jumpifinventory("PAPM1clip",16,"Ready")
    M1RE A 0 A_jumpifinventory("PAPM1ammo",1,1)
	goto ready+1
    M1RE A 0 A_playsound("m1/clipout")
    M1RE ABCD 1
    M1RE D 10
    goto reload2_speed 
  Reload2_speed:
    M1RE D 0 A_giveinventory("PAPM1clip",1)
    M1RE D 0 A_takeinventory("PAPM1ammo",1)
    M1RE D 0 A_jumpifinventory("PAPM1clip",16,"Reloaddone_speed")
    M1RE D 0 A_jumpifinventory("PAPM1ammo",1,"Reload2_speed")
	goto reloaddone_speed
  reloaddone_speed:
    M1RE D 0 A_playsound("m1/clipin")
    M1RE D 10
    M1RE D 0 A_playsound("m1/bolt")
    M1RE D 5
	M1RE 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:
    TNT1 A 2 bright
    Stop
  Spawn:
    M1GR A -1
    Stop
  }
}

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