actor MP40 : Weapon
{
   Weapon.SelectionOrder 1200
   Inventory.PickupMessage "You got the MP40"
   Obituary "%o was riddled by %k's MP40."
   weapon.ammotype "MP40Clip"
   weapon.ammouse 1
  weapon.ammogive2 999
  weapon.ammogive1 999
   weapon.ammotype2 "MP40Ammo"
   Scale 0.5
   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")
     MP40 A 1 A_WeaponReady
     Loop
  Deselect:
    MP40 A 0 A_Lower
    MP40 A 0 A_Lower
    MP40 A 1 A_Lower
    Loop
  Select:
    MP40 A 0 A_Raise
    MP40 A 0 A_Raise
    MP40 A 1 A_Raise
    Loop
   Fire:
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
     MP40 A 0 A_jumpifinventory("deadshot",1,"Fire_deadshot")
     MP40 A 0 A_jumpifinventory("Doubletap",1,"Fire_Doubletap")
     MP40 A 0 A_jumpifnoammo("Reload")
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
	TNTT A 0 A_playsound("MP40/fire")
     MP40 B 2 Bright A_FireBullets (5, 4, 1, random(850,850), "BulletPuff")
	TNTT A 0 A_FireCustomMissile("BulletCasingSpawner",0,0,-6,2)
     MP40 B 0 A_GunFlash
     MP40 D 2
     MP40 CA 2
     MP40 A 0 A_jumpifnoammo("Reload")
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
     MP40 A 0 A_ReFire
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
     MP40 A 0 A_jumpifnoammo("Reload")
     Goto Ready
   Fire_deadshot:
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
     MP40 A 0 A_jumpifinventory("Doubletap",1,"Fire_Doubletapdeadshot")
     MP40 A 0 A_jumpifnoammo("Reload")
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
	TNTT A 0 A_playsound("MP40/fire")
     MP40 B 2 Bright A_FireBullets (2, 1, 1, random(850,850), "BulletPuff")
	TNTT A 0 A_FireCustomMissile("BulletCasingSpawner",0,0,-6,2)
     MP40 B 0 A_GunFlash
     MP40 D 2
     MP40 CA 2
     MP40 A 0 A_jumpifnoammo("Reload")
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
     MP40 A 0 A_ReFire
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
     MP40 A 0 A_jumpifnoammo("Reload")
     Goto Ready
   Fire_Doubletapdeadshot:
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
     MP40 A 0 A_jumpifnoammo("Reload")
	TNTT A 0 A_playsound("MP40/fire")
     MP40 B 1 Bright A_FireBullets (2, 1, 1, random(850,850), "BulletPuff")
	TNTT A 0 A_FireCustomMissile("BulletCasingSpawner",0,0,-6,2)
     MP40 B 0 A_GunFlash
     MP40 D 1
     MP40 CA 1
     MP40 A 0 A_jumpifnoammo("Reload")
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
     MP40 A 0 A_ReFire
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
     MP40 A 0 A_jumpifnoammo("Reload")
     Goto Ready
   Fire_doubletap:
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
     MP40 A 0 A_jumpifnoammo("Reload")
	TNTT A 0 A_playsound("MP40/fire")
     MP40 B 1 Bright A_FireBullets (5, 4, 1, random(850,850), "BulletPuff")
	TNTT A 0 A_FireCustomMissile("BulletCasingSpawner",0,0,-6,2)
     MP40 B 0 A_GunFlash
     MP40 D 1
     MP40 CA 1
     MP40 A 0 A_jumpifnoammo("Reload")
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
     MP40 A 0 A_ReFire
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
     MP40 A 0 A_jumpifnoammo("Reload")
     Goto Ready
   Reload:	
    PIRE A 0 A_takeinventory("IsReloading",1)
     MP40 A 0 A_jumpifinventory("Speedcola",1,"Reload_speed")
     MPRE A 0 A_jumpifinventory("MP40Clip",32,"Ready")
	 MPRE A 0 A_jumpifinventory("MP40ammo",1,1)
	 goto ready+1
	 MPRE A 0 A_playsound("MP40/clipout")
	 MPRE ABCDE 2
	 MPRE E 20
	 goto reload2
   Reload2:
     MPRE E 0 A_giveinventory("MP40Clip",1)
     MPRE E 0 A_takeinventory("MP40ammo",1)
     MPRE E 0 A_jumpifinventory("MP40Clip",32,"Reloaddone")
	 MPRE E 0 A_jumpifinventory("MP40ammo",1,"Reload2")
	 goto reloaddone
   Reloaddone:
     MPRE E 0 A_playsound("MP40/Clipin")
	 MPRE E 20
	 MPRE E 0 A_playsound("MP40/Bolt")
	 MPRE E 10
	 MPRE EDCBA 2
	 goto ready
   Reload_speed:
     MPRE A 0 A_jumpifinventory("MP40Clip",32,"Ready")
	 MPRE A 0 A_jumpifinventory("MP40ammo",1,1)
	 goto ready+1
	 MPRE A 0 A_playsound("MP40/clipout")
	 MPRE ABCDE 1
	 MPRE E 10
	 goto reload2_speed
   Reload2_speed:
     MPRE E 0 A_giveinventory("MP40Clip",1)
     MPRE E 0 A_takeinventory("MP40ammo",1)
     MPRE E 0 A_jumpifinventory("MP40Clip",32,"Reloaddone_speed")
	 MPRE E 0 A_jumpifinventory("MP40ammo",1,"Reload2_speed")
	 goto reloaddone_speed
   Reloaddone_speed:
     MPRE E 0 A_playsound("MP40/Clipin")
	 MPRE E 10
	 MPRE E 0 A_playsound("MP40/Bolt")
	 MPRE E 5
	 MPRE EDCBA 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 5 Bright A_Light1
     Goto LightDone
     TNT1 A 5 Bright A_Light1
     Goto LightDone
   Spawn:
     MP40 E -1
     Stop
   }
}

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

actor PAPMP40 : Weapon
{
   Weapon.SelectionOrder 700
   Inventory.PickupMessage "You got the MP40"
   Obituary "%o was riddled by %k's MP40."
   weapon.ammotype "PAPMP40Clip"
   weapon.ammouse 1
  weapon.ammogive2 999
  weapon.ammogive1 999
   weapon.ammotype2 "PAPMP40Ammo"
   Scale 0.5
   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")
     MP40 A 1 A_WeaponReady
     Loop
  Deselect:
    MP40 A 0 A_Lower
    MP40 A 0 A_Lower
    MP40 A 1 A_Lower
    Loop
  Select:
    MP40 A 0 A_Raise
    MP40 A 0 A_Raise
    MP40 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") 
     MP40 A 0 A_jumpifinventory("deadshot",1,"Fire_deadshot")
     MP40 A 0 A_jumpifinventory("Doubletap",1,"Fire_Doubletap")
     MP40 A 0 A_jumpifnoammo("Reload")
	TNTT A 0 A_playsound("MP40/fire")
     MP40 B 1 Bright A_FireBullets (2.5, 2.2, -1, random(1700,1700), "BulletPuff")
	TNTT A 0 A_FireCustomMissile("BulletCasingSpawner",0,0,-6,2)
     MP40 B 0 A_GunFlash
     MP40 D 2
     MP40 CA 1
     MP40 A 0 A_jumpifnoammo("Reload")
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
     MP40 A 0 A_ReFire
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
     MP40 A 0 A_jumpifnoammo("Reload")
     Goto Ready
   Fire_deadshot:
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
     MP40 A 0 A_jumpifinventory("Doubletap",1,"Fire_Doubletapdeadshot")
     MP40 A 0 A_jumpifnoammo("Reload")
	TNTT A 0 A_playsound("MP40/fire")
     MP40 B 1 Bright A_FireBullets (2, 1, -1, random(1700,1700), "BulletPuff")
	TNTT A 0 A_FireCustomMissile("BulletCasingSpawner",0,0,-6,2)
     MP40 B 0 A_GunFlash
     MP40 D 2
     MP40 CA 1
     MP40 A 0 A_jumpifnoammo("Reload")
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
     MP40 A 0 A_ReFire
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
     MP40 A 0 A_jumpifnoammo("Reload")
     Goto Ready
   Fire_Doubletapdeadshot:
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
     MP40 A 0 A_jumpifnoammo("Reload")
	TNTT A 0 A_playsound("MP40/fire")
     MP40 B 1 Bright A_FireBullets (2, 1, -1, random(1700,1700), "BulletPuff")
	TNTT A 0 A_FireCustomMissile("BulletCasingSpawner",0,0,-6,2)
     MP40 B 0 A_GunFlash
     MP40 D 1
     MP40 CA 1
     MP40 A 0 A_jumpifnoammo("Reload")
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
     MP40 A 0 A_ReFire
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
     MP40 A 0 A_jumpifnoammo("Reload")
     Goto Ready
   Fire_doubletap:
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
     MP40 A 0 A_jumpifnoammo("Reload")
	TNTT A 0 A_playsound("MP40/fire")
     MP40 B 1 Bright A_FireBullets (2.5, 2.2, -1, random(1700,1700), "BulletPuff")
	TNTT A 0 A_FireCustomMissile("BulletCasingSpawner",0,0,-6,2)
     MP40 B 0 A_GunFlash
     MP40 D 1
     MP40 CA 1
     MP40 A 0 A_jumpifnoammo("Reload")
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
     MP40 A 0 A_ReFire
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
     MP40 A 0 A_jumpifnoammo("Reload")
     Goto Ready
   Reload:	
    PIRE A 0 A_takeinventory("IsReloading",1)
     MP40 A 0 A_jumpifinventory("Speedcola",1,"Reload_speed")
     MPRE A 0 A_jumpifinventory("PAPMP40Clip",64,"Ready")
	 MPRE A 0 A_jumpifinventory("PAPMP40ammo",1,1)
	 goto ready+1
	 MPRE A 0 A_playsound("MP40/clipout")
	 MPRE ABCDE 2
	 MPRE E 20
	 goto reload2
   Reload2:
     MPRE E 0 A_giveinventory("PAPMP40Clip",1)
     MPRE E 0 A_takeinventory("PAPMP40ammo",1)
     MPRE E 0 A_jumpifinventory("PAPMP40Clip",64,"Reloaddone")
	 MPRE E 0 A_jumpifinventory("PAPMP40ammo",1,"Reload2")
	 goto reloaddone
   Reloaddone:
     MPRE E 0 A_playsound("MP40/Clipin")
	 MPRE E 20
	 MPRE E 0 A_playsound("MP40/Bolt")
	 MPRE E 10
	 MPRE EDCBA 2
	 goto ready
   Reload_speed:
     MPRE A 0 A_jumpifinventory("PAPMP40Clip",64,"Ready")
	 MPRE A 0 A_jumpifinventory("PAPMP40ammo",1,1)
	 goto ready+1
	 MPRE A 0 A_playsound("MP40/clipout")
	 MPRE ABCDE 1
	 MPRE E 10
	 goto reload2_speed
   Reload2_speed:
     MPRE E 0 A_giveinventory("PAPMP40Clip",1)
     MPRE E 0 A_takeinventory("PAPMP40ammo",1)
     MPRE E 0 A_jumpifinventory("PAPMP40Clip",64,"Reloaddone_speed")
	 MPRE E 0 A_jumpifinventory("PAPMP40ammo",1,"Reload2_speed")
	 goto reloaddone_speed
   Reloaddone_speed:
     MPRE E 0 A_playsound("MP40/Clipin")
	 MPRE E 10
	 MPRE E 0 A_playsound("MP40/Bolt")
	 MPRE E 5
	 MPRE EDCBA 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 5 Bright A_Light1
     Goto LightDone
     TNT1 A 5 Bright A_Light1
     Goto LightDone
   Spawn:
     MP40 E -1
     Stop
   }
}

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

actor MP40Ammo : Ammo
{
    inventory.icon "CLIPA0"
    inventory.amount 32
    inventory.maxamount 196
    ammo.backpackamount 32
    ammo.backpackmaxamount 196
    +IGNORESKILL
    inventory.pickupmessage "Got MP40 rounds!"  
    States
    {
    Spawn:
      CLIP A -1
      Stop
    }
}


actor PAPMP40Ammo : Ammo
{
    inventory.icon "CLIPA0"
    inventory.amount 64
    inventory.maxamount 256
    ammo.backpackamount 64
    ammo.backpackmaxamount 256
    +IGNORESKILL
    inventory.pickupmessage "Got MP40 rounds!"  
    States
    {
    Spawn:
      CLIP A -1
      Stop
    }
}
