/*
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've 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
   Weapon.BobStyle InverseSmooth
   Weapon.BobSpeed 1.5
   Weapon.BobRangeY 0.6
   Weapon.BobRangeX 1.2
   attacksound "Weapons/MP40Fire"
   +WEAPON.CHEATNOTWEAPON
   +NOALERT
   Scale 0.5
   States
   {
   Ready:
     MP4G A 0 A_JumpIfInventory("MP40Counter",2,"ZweiReady")
     MP4G A 1 A_WeaponReady
     Loop
   Deselect:
     MP4G A 0 A_JumpIfInventory("MP40Counter",2,"ZweiDeselect")
     MP4G A 0 A_Lower
     MP4G A 1 A_Lower
     Loop
   Select:
     MP4G A 0 A_JumpIfInventory("MP40Counter",2,"ZweiSelect")
     MP4G A 0 A_Raise    
     MP4G A 1 A_Raise
     Loop
   Fire:
     MP4G A 0 A_AlertMonsters
     MP4G A 0 A_GiveInventory("BooletCasing")
     MP4G A 0 A_PlaySound("Weapons/MP40AddFire",5,0.2)
     MP4G A 0 A_JumpIfInventory("CaliberUpgrade",1,3)
     MP4G A 0 A_FireBullets (3.0, 1.0, 1, 40, "BulletPuff")
	 MP4G A 0 A_Jump(256,3)
     MP4G A 0 A_PlaySound("Weapons/WolgirHEndFire",6,0.8)
     MP4G A 0 A_FireBullets (3.0, 1.0, 1, 80, "CaliberPuff")
	 MPRF A 0 A_SetAngle(Angle-0.1)
	 MPRF A 0 A_SetPitch(Pitch-0.3)
     MP4F A 1 Bright
     MP4F B 1 Bright
     MP4G BC 1
     MP4G A 0 A_Jump(48,"Frame")
     MP4G A 1 A_ReFire
     Goto Ready
   Frame:
     MP4G D 1
     Goto Ready
     
   ZweiSelect:
     MP2G A 0 A_Raise
     MP2G A 1 A_Raise
     Loop
   ZweiDeselect:
	 TNT1 A 0 A_TakeInventory("SynthFireActive",1)
	 TNT1 A 0 A_TakeInventory("SynthFireLeft",1)
	 TNT1 A 0 A_TakeInventory("SynthFireRight",1)
	 TNT1 A 0 A_GunFlash("Nullify",GFF_NOEXTCHANGE)
   Zweihander:
	 MP2G A 0 A_Lower
	 MP2G A 1 A_Lower
	 Loop
   ZweiReady:
	 MP2G A 0 A_GiveInventory("SynthFireActive",1)
	 MP2G A 0 ACS_NamedExecuteAlways("SynthLeft")
	 MP2G A 0 ACS_NamedExecuteAlways("SynthRight")
	 MP2G A 0 A_Gunflash("Flash",GFF_NOEXTCHANGE)
	 Goto LIdle

   LIdle:
	 MPLG A 0 A_JumpIfInventory("SynthFireLeft",1,"LFire")
	 MPLG A 1 A_WeaponReady(WRF_NOFIRE)
	 Loop
   LFire:
	 MPLG A 1 A_JumpIfInventory("Boolet",1,1)
	 Goto LIdle
     MPLF A 0 A_GiveInventory("BooletCasing")
     MPLF A 0 A_PlaySound("Weapons/MP40AddFire",5,0.2)
     MPLF A 0 A_JumpIfInventory("CaliberUpgrade",1,3)
     MPLF A 0 A_FireBullets (3.0, 1.0, -1, 40, "BulletPuff")
	 MPLF A 0 A_Jump(256,3)
     MPLF A 0 A_PlaySound("Weapons/WolgirHEndFire",6,0.8)
     MPLF A 0 A_FireBullets (3.0, 1.0, -1, 80, "CaliberPuff")
	 MPLF A 0 A_SetAngle(Angle+0.1)
	 MPLF A 0 A_SetPitch(Pitch-0.3)
     MPLF A 1 Bright
     MPLF B 1 Bright
     MPLF CD 1
     MPLF A 0 A_Jump(48,1)
	 Goto LIdle
     MPLF E 1
	 Goto LIdle
   Nullify:
	 TNT1 A 0
	 Stop
   Flash:
	 TNT1 A 0 A_Light0
   RIdle:
	 MPRG A 0 A_JumpIfInventory("SynthFireRight",1,"RFire")
	 MPRG A 1
	 Loop
   RFire:
	 MPRG A 1 A_JumpIfInventory("Boolet",1,1)
	 Goto RIdle
     MPRF A 0 A_GiveInventory("BooletCasing")
     MPRF A 0 A_PlaySound("Weapons/MP40AddFire",5,0.2)
     MPRF A 0 A_JumpIfInventory("CaliberUpgrade",1,3)
     MPRF A 0 A_FireBullets (3.0, 1.0, -1, 40, "BulletPuff")
	 MPRF A 0 A_Jump(256,3)
     MPRF A 0 A_PlaySound("Weapons/WolgirHEndFire",6,0.8)
     MPRF A 0 A_FireBullets (3.0, 1.0, -1, 80, "CaliberPuff")
	 MPRF A 0 A_SetAngle(Angle-0.1)
	 MPRF A 0 A_SetPitch(Pitch-0.3)
     MPRF A 1 Bright
     MPRF B 1 Bright
     MPRF CD 1
     MPRF A 0 A_Jump(48,1)
	 Goto RIdle
     MPRF E 1
	 Goto RIdle
   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
   //+WEAPONSPAWN
   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
}
