/*
CREDITS:
Sprite - Marty Kirra
Pickup - Apogee (ROTT)

Sounds:
Up, Fire - ID (RTCW)
Add - ?
*/

actor MP40 : DoomWeapon 24543
{
   //$Category Weapons
   //$Title MP40
   //$Sprite MP40X0
   Inventory.PickupSound "misc/w_pkup"
   Inventory.PickupMessage "You got the MP40! HALT! *PEWPEWPEW-PEWPEW* (2)"
   Obituary "%o was grammar-nazi'd by %k's MP40."
   Weapon.UpSound "Weapons/MP40Up"
   Weapon.SelectionOrder 5
   Weapon.AmmoType "Boolet"
   Weapon.AmmoGive 0
   Weapon.AmmoUse 1
   Weapon.AmmoType2 "Boolet"
   Weapon.AmmoUse2 1
   Weapon.SlotNumber 2
   attacksound "Weapons/MP40Fire"
   +WEAPON.CHEATNOTWEAPON
   +NOALERT
   Scale 0.5
   States
   {
   Ready:
     MP4G A 0 A_JumpIfInventory("MP40Counter",2,"AkimboReady")
     MP4G A 1 A_WeaponReady
     Loop
   Deselect:
     MP4G A 0 A_JumpIfInventory("MP40Counter",2,"AkimboDeselect")
     MP4G A 0 A_Lower
     MP4G A 1 A_Lower
     Loop
   Select:
     MP4G A 0 A_JumpIfInventory("MP40Counter",2,"AkimboSelect")
     MP4G A 0 A_Raise    
     MP4G A 1 A_Raise
     Loop
   Fire:
   Hold:
     MP4G A 0 A_AlertMonsters
     MP4G A 0 A_GiveInventory("BooletCasing")
     MP4G A 0 A_JumpIfInventory("MP40Counter",2,"AkimboFire")
     MP4G A 0 A_GunFlash
     MP4G A 0 A_PlaySound("Weapons/MP40AddFire",5,0.2)
     MP4G A 0 A_JumpIfInventory("CaliberUpgrade",1,"CFire")
     MP4G A 0 A_FireBullets (5, 2, 1, 40, "BulletPuff")
     MP4F A 1 Bright ACS_Execute(851,0,15+random(5,-5),10+random(5,-5))
     MP4F B 1 Bright
     MP4G BC 1
     MP4G A 0 A_Jump(48,"Clunky")
     MP4G A 4 A_ReFire
     Goto Ready
   CFire:
     MP4G A 0 A_PlaySound("Weapons/WolgirHEndFire",6,0.8)
     MP4G A 0 A_FireBullets (5, 2, 1, 80, "CaliberPuff")
     MP4F A 1 Bright ACS_Execute(851,0,15+random(5,-5),10+random(5,-5))
     MP4F B 1 Bright
     MP4G BC 1
     MP40 A 0 A_Jump(48,"Clunky")
     MP40 A 0 A_ReFire
     Goto Ready
   AltFire:
     MP4G A 0 A_JumpIfInventory("MP40Counter",2,"AkimboAltFire")
     MP4G A 1 A_WeaponReady
     Goto Ready
   AltHold:
     MP4G A 0 A_JumpIfInventory("MP40Counter",2,"AkimboAltHold")
     MP4G A 1 A_WeaponReady
     Goto Ready
   Clunky:
     MP4G D 1
     Goto Ready
     
   AkimboReady:
     MP2G A 1 A_WeaponReady
     Loop
   AkimboDeselect:
     MP2G A 0 A_Lower
     MP2G A 1 A_Lower
     Loop
   AkimboSelect:
     MP2G A 0 A_Raise
     MP2G A 1 A_Raise
     MP2G A 0 A_Raise
     MP2G A 1 A_Raise
     MP2G A 0 A_PlaySoundEx("Weapons/MP40Up","SoundSlot5",0,-1)
   Looper:
     MP2G A 0 A_Raise
     MP2G A 1 A_Raise
     Loop
     
   AkimboFire:
     MP2G A 0 A_JumpIfInventory("MP40Side",1,"FireLeft")
   //FireRight:
     MP2R A 0 A_GiveInventory("MP40Side",1)
     MP2R A 0 A_GunFlash
     MP2R A 0 A_PlaySound("Weapons/MP40AddFire",5,0.2)
     MP2R A 0 A_JumpIfInventory("CaliberUpgrade",1,"CFireRight")
     MP2R A 0 A_FireBullets (5.5, 2.25, 1, 40, "BulletPuff")
     MP2R A 1 Bright ACS_Execute(851,0,15+random(5,-5),10+random(5,-5))
     MP2R B 1 Bright
     MP2R CD 1
     MP2R A 0 A_ReFire
     MP2R A 0 A_Jump(48,"AkimboClunky")
     Goto Ready
   CFireRight:
     MP2T A 0 A_PlaySound("Weapons/WolgirHEndFire",6,0.8)
     MP2R A 0 A_PlaySound("Weapons/MP40AddFire",5,0.2)
     MP2R A 0 A_FireBullets (5.5, 2.25, 1, 80, "CaliberPuff")
     MP2R A 1 Bright ACS_Execute(851,0,15+random(5,-5),10+random(5,-5))
     MP2R B 1 Bright
     MP2R CD 1
     MP2R A 0 A_ReFire
     MP2R A 0 A_Jump(48,"AkimboClunky")
     Goto Ready
   FireLeft:
     MP2L A 0 A_TakeInventory("MP40Side",1)
     MP2L A 0 A_GunFlash
     MP2L A 0 A_PlaySound("Weapons/MP40AddFire",5,0.2)
     MP2L A 0 A_JumpIfInventory("CaliberUpgrade",1,"CFireLeft")
     MP2L A 0 A_FireBullets (5.5, 2.25, 1, 40, "BulletPuff")
     MP2L A 1 Bright ACS_Execute(851,0,15+random(5,-5),-10+random(5,-5))
     MP2L B 1 Bright
     MP2L CD 1
     MP2L A 0 A_ReFire
     MP2L A 0 A_Jump(48,"AkimboClunky")
     Goto Ready
   CFireLeft:
     MP2L A 0 A_PlaySound("Weapons/WolgirHEndFire",6,0.8)
     MP2L A 0 A_FireBullets (5.5, 2.25, 1, 80, "CaliberPuff")
     MP2L A 1 Bright ACS_Execute(851,0,15+random(5,-5),-10+random(5,-5))
     MP2L B 1 Bright
     MP2L CD 1
     MP2L A 0 A_ReFire
     MP2L A 0 A_Jump(48,"AkimboClunky")
     Goto Ready
   AkimboAltFire:
     MP4G A 0 A_AlertMonsters
     MP4G A 0 A_GiveInventory("BooletCasing")
     MP2G A 0 A_JumpIfInventory("MP40Side",1,"AltFireLeft")
   //AltFireRight:
     MP2R A 0 A_GiveInventory("MP40Side",1)
     MP2R A 0 A_GunFlash
     MP2R A 0 A_PlaySound("Weapons/MP40AddFire",5,0.2)
     MP2R A 0 A_JumpIfInventory("CaliberUpgrade",1,"CFireRight")
     MP2R A 0 A_FireBullets (7.5, 4.25, 1, 40, "BulletPuff")
     MP2R A 1 Bright ACS_Execute(851,0,15+random(5,-5),10+random(5,-5))
     MP2R B 1 Bright
     MP2R D 1
     MP2R A 0 A_ReFire
     MP2R A 0 A_Jump(48,"AkimboClunky")
     Goto Ready
   CAltFireRight:
     MP2R A 0 A_PlaySound("Weapons/WolgirHEndFire",6,0.8)
     MP2R A 0 A_FireBullets (7.5, 4.25, 1, 80, "CaliberPuff")
     MP2R A 1 Bright ACS_Execute(851,0,15+random(5,-5),10+random(5,-5))
     MP2R B 1 Bright
     MP2R D 1
     MP2R A 0 A_ReFire
     MP2R A 0 A_Jump(48,"AkimboClunky")
     Goto Ready
   AltFireLeft:
     MP2L A 0 A_TakeInventory("MP40Side",1)
     MP2L A 0 A_GunFlash
     MP2L A 0 A_PlaySound("Weapons/MP40AddFire",5,0.2)
     MP2L A 0 A_JumpIfInventory("CaliberUpgrade",1,"CFireLeft")
     MP2L A 0 A_FireBullets (7.5, 4.25, 1, 40, "BulletPuff")
     MP2L A 1 Bright ACS_Execute(851,0,15+random(5,-5),-10+random(5,-5))
     MP2L B 1 Bright
     MP2L D 1
     MP2L A 0 A_ReFire
     MP2L A 0 A_Jump(48,"AkimboClunky")
     Goto Ready
   CAltFireLeft:
     MP2L A 0 A_PlaySound("Weapons/WolgirHEndFire",6,0.8)
     MP2L A 0 A_FireBullets (7.5, 4.25, 1, 80, "CaliberPuff")
     MP2L A 1 Bright ACS_Execute(851,0,15+random(5,-5),-10+random(5,-5))
     MP2L B 1 Bright
     MP2L CD 1
     MP2L A 0 A_ReFire
     MP2L A 0 A_Jump(48,"AkimboClunky")
     Goto Ready
   AkimboAltHold:
     MP4G A 0 A_GiveInventory("BooletCasing")
     MP42 A 0 A_JumpIfInventory("MP40Side",1,"Fire2")
   //Fire1:
     MP2R A 0 A_GiveInventory("MP40Side",1)
     MP2R A 0 A_GunFlash
     MP2R A 0 A_PlaySound("Weapons/MP40AddFire",5,0.2)
     MP2R A 0 A_JumpIfInventory("CaliberUpgrade",1,"CFire1")
     MP2R A 0 A_FireBullets (11, 5, 1, 40, "BulletPuff")
     MP2R A 1 Bright ACS_Execute(851,0,15+random(5,-5),10+random(5,-5))
     MP2R B 1 Bright
     MP2R B 0 A_ReFire
     MP2R CD 1
     MP2G A 0 A_Jump(32,"AkimboClunky")
     Goto Ready
   CFire1:
     MP2L A 0 A_PlaySound("Weapons/WolgirHEndFire",6,0.8)
     MP2R A 0 A_FireBullets (11, 5, 1, 80, "CaliberPuff")
     MP2R A 1 Bright ACS_Execute(851,0,15+random(5,-5),10+random(5,-5))
     MP2R B 1 Bright
     MP2R B 0 A_ReFire
     MP2R CD 1
     MP2G A 0 A_Jump(32,"AkimboClunky")
     Goto Ready
   Fire2:
     MP2L A 0 A_TakeInventory("MP40Side",1)
     MP2L A 0 A_GunFlash
     MP2L A 0 A_PlaySound("Weapons/MP40AddFire",5,0.2)
     MP2L A 0 A_JumpIfInventory("CaliberUpgrade",1,"CFire2")
     MP2L A 0 A_FireBullets (11, 5, 1, 40, "BulletPuff")
     MP2L A 1 Bright ACS_Execute(851,0,15+random(5,-5),-10+random(5,-5))
     MP2L B 1 Bright
     MP2L B 0 A_ReFire
     MP2L CD 1
     MP2G A 0 A_Jump(32,"AkimboClunky")
     Goto Ready
   CFire2:
     MP2L A 0 A_PlaySound("Weapons/WolgirHEndFire",6,0.8)
     MP2L A 0 A_FireBullets (11, 5, 1, 80, "CaliberPuff")
     MP2L A 1 Bright ACS_Execute(851,0,15+random(5,-5),-10+random(5,-5))
     MP2L B 1 Bright
     MP2L B 0 A_ReFire
     MP2L CD 1
     MP2G A 0 A_Jump(32,"AkimboClunky")
     Goto Ready
   AkimboClunky:
     MP2G A 0 A_JumpIfInventory("MP40Side",1,"Clunk2")
   //Clunk1:
     MP2R E 1
     Goto Ready
   Clunk2:
     MP2L E 1
     Goto Ready
   Flash:
     TNT1 A 4 Bright A_Light1
     Goto LightDone
   Spawn:
     MP40 X -1
     Stop
   }
}

ACTOR MP40Pickup : CustomInventory //Pickup
{
   Inventory.PickupSound "misc/w_pkup"
   Inventory.PickupMessage "You got the MP40! HALT! *PEWPEWPEW-PEWPEW* (2)"
   Scale 0.5
   States
   {
   Spawn:
     MP40 X -1
     Stop
   Pickup:
     TNT1 A 0 A_JumpIfInventory("MP40Counter",2,3)
     TNT1 A 0 A_GiveInventory("MP40")
     TNT1 A 0 A_GiveInventory("MP40Counter")
     TNT1 A 0 A_GiveInventory("Boolet",30)
     Stop
   }
}

ACTOR MP40Counter : Inventory
{
     Inventory.MaxAmount 2
}

ACTOR MP40Side : Inventory
{
     Inventory.MaxAmount 1
}
