ACTOR Weapon_Serbu : Weapon_Base
{
  Weapon.AmmoUse 1
  Weapon.AmmoGive 3
  Weapon.AmmoType "Weapon_Serbu_Mag"
  Obituary "$OB_MPPISTOL"
  +WEAPON.NOAUTOFIRE
  +WEAPON.AMMO_OPTIONAL

  Weapon.SlotNumber 3
  
  States
  {
  Ready:
	PISG A 0
	PISG A 0 A_PlaySound("weapons/equip",CHAN_6)
	  PISG A 1 Offset(0,8)
	  PISG A 1 Offset(0,12)
	  PISG A 1 Offset(0,18)
	  PISG A 1 Offset(0,24)
	  PISG A 1 Offset(0,28)
	  PISG A 0 Offset(0,32)
	  PISG A 1 A_WeaponReady
	  Goto Idle
  
  Idle:
	PISG A 0 A_GiveInventory("YouPlayer_HoldingRifle",1)
    PISG A 1 A_WeaponReady(WRF_ALLOWRELOAD)
    Loop
	
	Empty:
	PISG A 1
	PISG A 0 A_PlaySound("weapons/empty",CHAN_VOICE)
	Goto Reload
	
  Fire:
	PISG A 0 A_JumpIfNoAmmo("Empty")
    PISG A 0
	PISG A 0 A_FireBullets (5, 5, 6, 7, "BulletPuff")
	PISG A 0 A_PlaySound("weapons/serbu/fire", CHAN_WEAPON, 1.0, false, 0.8)
	PISG A 0 A_PlaySound ("weapons/serbu/pump",CHAN_7)
	
	PISG A 0 A_FireCustomMissile ("MuzzleFlash_ShotgunHandler",0,false,30,5)
	PISG A 0 A_SetPitch(pitch-6.5,SPF_INTERPOLATE)
	
	MDL1 FG 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
    MDL1 H 2 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	MDL1 I 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	MDL1 JKLM 2 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	MDL1 NOPQRST 2 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	MDL1 UVWXYZ 2 A_WeaponReady(WRF_ALLOWRELOAD)
	MDL2 ABC 2 A_WeaponReady(WRF_ALLOWRELOAD)
	PISG A 0
    Goto Idle

	Reload:
	PISG A 1 A_WeaponReady
	PISG A 0 A_JumpIfInventory("Weapon_Serbu_Mag",0,"Idle")
	PISG A 0 A_JumpIfInventory("Weapon_Shotgun_Ammo",1,"ReloadYes")
	Goto Idle
	ReloadYes:
	PISG A 0
	MDL2 GHIJKLMNOP 1 A_WeaponReady(WRF_NOFIRE)
	MDL2 T 0
	Goto ReloadLoop
	ReloadLoop:
	MDL2 TVW 2 A_WeaponReady(WRF_NOFIRE)
	MDL2 X 0 A_PlaySound ("weapons/shotgun/reload",CHAN_7)
	MDL2 X 2 A_WeaponReady(WRF_NOFIRE)
	MDL3 AB 2 A_WeaponReady(WRF_NOFIRE)
	MDL3 C 0 A_GiveInventory("Weapon_Serbu_Mag",1)
	MDL3 C 0 A_TakeInventory("Weapon_Shotgun_Ammo",1)
	MDL3 CDE 1 A_WeaponReady(WRF_NOFIRE)
	MDL3 FHJLM 2 A_WeaponReady(WRF_NOFIRE)
	MDL2 T 0 A_JumpIfInventory("Weapon_Serbu_Mag",0,"ReloadEnd")
	MDL2 T 0 A_JumpIfInventory("Weapon_Shotgun_Ammo",1,"ReloadLoop")
	Goto ReloadEnd
	ReloadEnd:
	MDL2 T 0
	MDL2 PONMLKJIHG 1 A_WeaponReady(WRF_NOFIRE)
	PISG A 0
	Goto Idle
  Spawn:
    PIST A -1
    Stop
	Done:
	MDL1 A 0
	MDL2 A 0
	MDL3 A 0
	MDL4 A 0
	MDL5 A 0
	MDL6 A 0
	MDL7 A 0
	MDL8 A 0
	MDL9 A 0
	Stop
  }
}

ACTOR Weapon_Serbu_Mag : Ammo
{
	Inventory.Amount 1
	Inventory.MaxAmount 3
}

ACTOR Weapon_Shotgun_Ammo : Ammo
{
	Inventory.Amount 4
	Inventory.MaxAmount 30
}

ACTOR AmmoPkup_Shotgun_shells : CustomInventory Replaces RocketAmmo
{
	Scale 0.5
	+QUIET
	+COUNTITEM
	States
	{
	Spawn:
	AMMO E -1
	Stop
	Pickup:
	TNT1 A 0 A_JumpIfInventory("Weapon_Shotgun_Ammo",0,"FailPickup")
	TNT1 A 0 A_GiveInventory("Weapon_Shotgun_Ammo",4)
	TNT1 A 0 ACS_NamedExecute("PlayerPickupMessage",0,4)
	Stop
	FailPickup:
	TNT1 A 1
	Fail
	}
}

ACTOR GunPkup_Serbu : CustomInventory Replaces Shotgun
{
	Scale 0.5
	+QUIET
	+COUNTITEM
	States
	{
	Spawn:
	GUNN B -1
	Stop
	Pickup:
	TNT1 A 0 A_JumpIfInventory("Weapon_Serbu",0,"FailPickup")
	TNT1 A 0 A_GiveInventory("Weapon_Serbu",1)
	TNT1 A 0 ACS_NamedExecute("PlayerPickupMessage",0,6)
	Fail
	FailPickup:
	TNT1 A 1
	Fail
	}
}