ACTOR PDLaptopGun : Weapon
{
  Weapon.Kickback 100
  Scale 0.050
  
  Tag "Laptop Gun"
        Weapon.Ammotype1 "LaptopGunClip"
  Weapon.Ammotype2 "PDPistolAmmo"
    Weapon.AmmoUse1 1
  Weapon.AmmoGive1 0
  Weapon.AmmoGive2 50
  +WEAPON.AMMO_OPTIONAL
  Inventory.PickupMessage "Picked up a Laptop Gun."
  Obituary  "%o danced through %k's Laptop Gun lead."
  	Inventory.PickupSound "PerfectDark/Items/PickupWeapon"
  States
  {
  Spawn:
    TKA4 Q -1
    Loop
  Ready:
  TNT1 A 0 A_PlaySound ("PerfectDark/Weapons/LaptopGunSelect","Weapon")
    TK53 A 1 
    TK53 B 1
    TK53 C 1
    TK53 D 1
    TK53 EFGHIJKLMNOPQRS 2
    TK53 T -1 A_WeaponReady(WRF_ALLOWRELOAD)
	goto ReloadCheck
	TK53 T 1 A_WeaponReady(WRF_ALLOWRELOAD)
    Goto Ready+7
	
	  ReloadCheck:
	 KLBG A 0 A_JumpIfInventory("LaptopGunClip",50,2)
	 KLBG A 0 A_JumpIfInventory("PDPistolAmmo",1,"ReloadStart")
	 KLBG A 0
	 Goto Ready+20

  ReloadStart:
	 KLBR A 0 A_PlayWeaponSound("PerfectDark/Weapons/LaptopGunReload")
     TK55 OPQRSTUVXYZ 2
	 TK56 ABCDEFGHIJKLMNOPQRSTUVXYZ 1
	 TK57 ABCDE 1
	 goto ReloadAmmo

  ReloadAmmo:
	 TNT1 A 0 A_TakeInventory("PDPistolAmmo",1)
	 TNT1 A 0 A_GiveInventory("LaptopGunClip",1)
	 TNT1 A 0 A_JumpIfInventory("LaptopGunClip",50,"ReloadDone")
	 TNT1 A 0 A_JumpIfInventory("PDPistolAmmo",1,"ReloadAmmo")
	 goto ReloadDone
	 
	 ReloadDone:
	 TK57 FGHIJKLMNOPQRSTUVXYZ 1
	 TK58 A 1
	 Goto Ready+20
	
  Deselect:
  TNT1 A 0 A_PlaySound ("PerfectDark/Weapons/LaptopGunDeselect","Weapon")
    TK54 TUVXYZ 2
	TK55 ABCDEFGHIJKLM 1
    TK08 A 0 A_Lower
    wait
	  Deselect2:
    NULL A 1 A_Lower
    loop
  Select: 
    TK08 A 0 A_Raise 
    Loop  
  Fire: 
  KLBG A 0 A_JumpIfNoAmmo("ReloadCheck")
 	TNT1 A 0 A_PlayWeaponSound ("PerfectDark/Weapons/LaptopGun")
    TK53 U 2 BRIGHT A_FireBullets(1, 1, 1, 6, "BulletPuff",FBF_USEAMMO)
	TNT1 A 0 A_PlayWeaponSound ("PerfectDark/Weapons/LaptopGun")
    TK53 V 2 BRIGHT A_FireBullets(1, 1, 1, 6, "BulletPuff",FBF_USEAMMO)
	TNT1 A 0 A_PlayWeaponSound ("PerfectDark/Weapons/LaptopGun")
	TK53 X 2 BRIGHT A_FireBullets(1, 1, 1, 6, "BulletPuff",FBF_USEAMMO)
	TK53 YZ 2 A_REFIRE
	TK58 B 1 A_REFIRE
	TK54 ABCDEFGHIJKLMNOPQRS 1 
    Goto Ready+20
	AltFire:
	  TNT1 A 0 A_PlaySound ("PerfectDark/Weapons/LaptopGunDeselect","Weapon")
    TK54 TUVXYZ 2
	TK55 ABCDEFGHIJKLM 1
    NULL A 18
    NULL A 0 A_PlaySound ("PerfectDark/Weapons/Throw")
    NULL A 2 A_FireCustomMissile ("PDLaptopThrow",0,1,0,0,0)
    NULL A 20
    NULL A 2 A_TakeInventory ("PDLaptopGun",1)
	 goto deselect2
		Reload:
		TK04 A 0
		goto ReloadCheck
  }
}

ACTOR LaptopGunClip : Ammo
{
Inventory.MaxAmount 50 // size of the clip
Ammo.BackpackAmount 0
Ammo.BackpackMaxAmount 50 //MUST be the same as Inventory.MaxAmmount
+INVENTORY.IGNORESKILL
}

ACTOR PDLaptopGunPickup : Custominventory
{
   Scale 0.050
  Inventory.PickupMessage "Picked up a Laptop Gun."
  	Inventory.PickupSound "PerfectDark/Items/PickupWeapon"
   States
   {
   Spawn:
	  TKA4 Q -1
	  loop
   Pickup:
	  TNT1 A 0 A_GiveInventory("PDLaptopGun")
	  TNT1 A 0 A_JumpIfInventory("PlayingasPerfectKirby",1,"PickupPerfectKirby")
	  TNT1 A 0 A_JumpIfInventory("PlayingasRED",1,"PickupRED")
	  stop
	  PickupPerfectKirby:
	 	TNT1 A 0 A_PlaySound ("PerfectDark/Player/PerfectKirby/PerfectKirbyWeaponPickup")
		Stop
	  PickupRED:
	 	TNT1 A 0 A_PlaySound ("PerfectDark/Player/RED/REDWeaponPickup")
		Stop
   }
}

actor PDLaptopThrow
{
  radius 5
  height 1
  speed 25
  damage 0
  bouncecount 1
  scale 0.3
  PROJECTILE
  +RIPPER
  -NOGRAVITY
  +SKYEXPLODE
  +FORCEXYBILLBOARD
  states
  {
  Spawn:
    PCGU K 1
    loop
  Death:
    NULL A 1 A_NoBlocking
    NULL A 0 bright A_SpawnItem ("PDLaptopSentryGun",0,0,0,0) 
    stop
  }
}


actor PDLaptopSentryGun
{
  obituary "%o danced through Laptop Sentry Gun lead."
  health 150
  radius 4
  height 22
  mass 9999
  speed 0
  attacksound "PerfectDark/Weapons/LaptopGun"
  SCALE 0.3
  MONSTER
  -NOGRAVITY
  +STANDSTILL
  +NOBLOOD
  +QUICKTORETALIATE
  +DONTGIB
  -COUNTKILL
  +LOOKALLAROUND
  +MISSILEMORE
  +MISSILEEVENMORE
  states
  {
  Spawn:
    NULL A 1
    NULL A 0 A_CheckFloor ("SpawnDrop")
    NULL A 0 A_NoGravity
    NULL A 0 A_Stop
    PCGU M 10 A_Look
    goto Spawn+4
  See:
    NULL A 0 A_CheckFloor ("SeeDrop")
    PCGU M 3 A_Chase
    goto see+1
  Missile:
    NULL A 0 A_CheckFloor ("MissileDrop")
    PCGU N 5 A_FaceTarget
    PCGU NNNNNNNNNNNNNNNNNNN 3 bright A_CustomBulletAttack(1, 1, 1, 6,"BulletPuff",9999)
    goto Spawn+4
  Death:
	MISL B 0 bright A_Explode
	TNT1 A 0 radius_quake(2, 10, 0, 3, 0)
	TNT1 AAAAAAAAAAAA 0 A_SpawnItemEx("Debris1", Random(-8, 8), Random(-8, 8), Random(-8, 8), Random(-5, 5), Random(-5, 5), Random(-6, 7), Random(-360, 360), 128, 24)
	TNT1 AAAAAAAAAAAA 0 A_SpawnItemEx("Debris2", Random(-8, 8), Random(-8, 8), Random(-8, 8), Random(-5, 5), Random(-5, 5), Random(-6, 7), Random(-360, 360), 128, 24)
	TNT1 AAAAAAAAAAAA 0 A_SpawnItemEx("Debris3", Random(-8, 8), Random(-8, 8), Random(-8, 8), Random(-5, 5), Random(-5, 5), Random(-6, 7), Random(-360, 360), 128, 24)
	TNT1 AAAAAAAAAAAA 0 A_SpawnItemEx("Debris4", Random(-8, 8), Random(-8, 8), Random(-8, 8), Random(-5, 5), Random(-5, 5), Random(-6, 7), Random(-360, 360), 128, 24)
	TNT1 AAAAAAAAAAAA 0 A_SpawnItemEx("Debris5", Random(-8, 8), Random(-8, 8), Random(-8, 8), Random(-5, 5), Random(-5, 5), Random(-6, 7), Random(-360, 360), 128, 24)
	TNT1 AAAAAAAAAAAA 0 A_SpawnItemEx("Debris1", Random(-8, 8), Random(-8, 8), Random(-8, 8), Random(-3, 3), Random(-3, 3), Random(1, 6), Random(-360, 360), 128, 24)
	TNT1 AAAAAAAAAAAA 0 A_SpawnItemEx("Debris2", Random(-8, 8), Random(-8, 8), Random(-8, 8), Random(-3, 3), Random(-3, 3), Random(1, 6), Random(-360, 360), 128, 24)
	TNT1 AAAAAAAAAAAA 0 A_SpawnItemEx("Debris3", Random(-8, 8), Random(-8, 8), Random(-8, 8), Random(-3, 3), Random(-3, 3), Random(1, 6), Random(-360, 360), 128, 24)
	TNT1 AAAAAAAAAAAA 0 A_SpawnItemEx("Debris4", Random(-8, 8), Random(-8, 8), Random(-8, 8), Random(-3, 3), Random(-3, 3), Random(1, 6), Random(-360, 360), 128, 24)
	TNT1 AAAAAAAAAAAA 0 A_SpawnItemEx("Debris5", Random(-8, 8), Random(-8, 8), Random(-8, 8), Random(-3, 3), Random(-3, 3), Random(1, 6), Random(-360, 360), 128, 24)
	TNT1 A 3 A_SpawnItemEx ("RollingExplosion3", 0, 0, 0, 0, 0, 0, 0, 0, 0)
	TNT1 A 0 A_SpawnItemEx ("ExplosionSmoke", Random(-44, 44), Random(-44, 44), Random(0, 38), 0, 0, 0, 0, 128, 0)
	TNT1 A 3 A_SpawnItemEx ("RollingExplosion3", Random(-24, 24), Random(-24, 24), Random(0, 38), 0, 0, 0, Random(-360, 360), 0, 0)
	TNT1 A 0 A_SpawnItemEx ("ExplosionSmoke", Random(-44, 44), Random(-44, 44), Random(0, 38), 0, 0, 0, 0, 128, 0)
	TNT1 A 3 A_SpawnItemEx ("RollingExplosion3", Random(-24, 24), Random(-24, 24), Random(0, 38), 0, 0, 0, Random(-360, 360), 0, 0)
	TNT1 A 0 A_SpawnItemEx ("ExplosionSmoke", Random(-44, 44), Random(-44, 44), Random(0, 38), 0, 0, 0, 0, 128, 0)
	TNT1 A 3 A_SpawnItemEx ("RollingExplosion3", Random(-24, 24), Random(-24, 24), Random(0, 38), 0, 0, 0, Random(-360, 360), 0, 0)
	TNT1 A 0 A_SpawnItemEx ("ExplosionSmoke", Random(-44, 44), Random(-44, 44), Random(0, 38), 0, 0, 0, 0, 128, 0)
	TNT1 A 3 A_SpawnItemEx ("RollingExplosion3", Random(-24, 24), Random(-24, 24), Random(0, 38), 0, 0, 0, Random(-360, 360), 0, 0)
	TNT1 A 0 A_SpawnItemEx ("ExplosionSmoke", Random(-44, 44), Random(-44, 44), Random(0, 38), 0, 0, 0, 0, 128, 0)
	TNT1 A 3 A_SpawnItemEx ("RollingExplosion3", Random(-24, 24), Random(-24, 24), Random(0, 38), 0, 0, 0, Random(-360, 360), 0, 0)
	TNT1 A 0 A_SpawnItemEx ("ExplosionSmoke", Random(-44, 44), Random(-44, 44), Random(0, 38), 0, 0, 0, 0, 128, 0)
	TNT1 A 3 A_SpawnItemEx ("RollingExplosion3", Random(-24, 24), Random(-24, 24), Random(0, 38), 0, 0, 0, Random(-360, 360), 0, 0)
	TNT1 A 0 A_SpawnItemEx ("ExplosionSmoke", Random(-44, 44), Random(-44, 44), Random(0, 38), 0, 0, 0, 0, 128, 0)
	TNT1 A 3 A_SpawnItemEx ("RollingExplosion3", Random(-24, 24), Random(-24, 24), Random(0, 38), 0, 0, 0, Random(-360, 360), 0, 0)
	TNT1 A 0 A_SpawnItemEx ("ExplosionSmoke", Random(-44, 44), Random(-44, 44), Random(0, 38), 0, 0, 0, 0, 128, 0)
	TNT1 A 3 A_SpawnItemEx ("RollingExplosion3", Random(-24, 24), Random(-24, 24), Random(0, 38), 0, 0, 0, Random(-360, 360), 0, 0)
	TNT1 A 0 A_SpawnItemEx ("ExplosionSmoke", Random(-44, 44), Random(-44, 44), Random(0, 38), 0, 0, 0, 0, 128, 0)
	TNT1 A 3 A_SpawnItemEx ("RollingExplosion3", Random(-24, 24), Random(-24, 24), Random(0, 38), 0, 0, 0, Random(-360, 360), 0, 0)
	TNT1 AAAAAAA 5 A_SpawnItemEx ("RollingExplosion3", Random(-24, 24), Random(-24, 24), Random(0, 38), 0, 0, 0, Random(-360, 360), 0, 0)
	stop
  SpawnDrop:
    PCGU K 10 A_Look
    loop
  SeeDrop:
    PCGU K 3 A_Chase
    loop
  MissileDrop:
    PCGU L 5 A_FaceTarget
    PCGU LLLLLLLLLLLLLLLLLLL 3 bright A_CustomBulletAttack(1, 1, 1, 6,"BulletPuff",9999)
    goto SpawnDrop
  }
}
