ACTOR PDSuperDragon : Weapon
{
  Weapon.Kickback 100
  Scale 0.050
  
  Tag "SuperDragon"
        Weapon.Ammotype1 "SuperDragonClip"
  Weapon.Ammotype2 "PDRifleAmmo"
    Weapon.AmmoUse1 0
  Weapon.AmmoGive1 0
  Weapon.AmmoGive2 30
  +WEAPON.AMMO_OPTIONAL
  Inventory.PickupMessage "Picked up a SuperDragon."
  Obituary  "%k poured fire all over %o's screaming figure."
  	Inventory.PickupSound "PerfectDark/Items/PickupWeapon"
  States
  {
  Spawn:
    TKA4 L -1
    Loop
  Ready:
  TK01 A 0 A_JumpIfInventory ("SuperDragonGrenadeLauncherCheck",1,"Ready2")
  TNT1 A 0 A_PlaySound ("PerfectDark/Weapons/WeaponDraw","Weapon")
    TK71 A 2 
    TK71 B 2
    TK71 C 2
    TK71 D 2
    TK71 EFG 2
    TK71 H -1 A_WeaponReady(WRF_ALLOWRELOAD|WRF_ALLOWUSER1)
	goto ReloadCheck
	TK71 H 1 A_WeaponReady(WRF_ALLOWRELOAD|WRF_ALLOWUSER1)
    Goto Ready+9
	
	  ReloadCheck:
	 KLBG A 0 A_JumpIfInventory("SuperDragonClip",30,2)
	 KLBG A 0 A_JumpIfInventory("PDRifleAmmo",1,"ReloadStart")
	 KLBG A 0
	 Goto Ready+9

  ReloadStart:
	 KLBR A 0 A_PlayWeaponSound("PerfectDark/Weapons/DragonReload")
     TK71 YZ 2
	 TK72 ABCDEFGHIJKLMNOPQRS 1
	 goto ReloadAmmo

  ReloadAmmo:
	 TNT1 A 0 A_TakeInventory("PDRifleAmmo",1)
	 TNT1 A 0 A_GiveInventory("SuperDragonClip",1)
	 TNT1 A 0 A_JumpIfInventory("SuperDragonClip",30,"ReloadDone")
	 TNT1 A 0 A_JumpIfInventory("PDRifleAmmo",1,"ReloadAmmo")
	 goto ReloadDone
	 
	 ReloadDone:
	 TK72 TUVXYZ 1
	 TK73 ABCDEFGHIJKLMNOPQRSTUVXYZ 1
	 TK74 A 1
	 Goto Ready+9
	
  Deselect:
  TK01 A 0 A_JumpIfInventory ("SuperDragonGrenadeLauncherCheck",1,"Deselect2")
    TK71 TUVX 2
    TK08 A 0 A_Lower
    wait
  Select: 
    TK08 A 0 A_Raise 
    Loop  
  Fire: 
  TK01 A 0 A_JumpIfInventory ("SuperDragonGrenadeLauncherCheck",1,"FireGrenadeLauncher")
   NULL A 0 A_JumpIfInventory("SuperDragonClip",1,1)
	goto ReloadCheck
 	TNT1 A 0 A_PlayWeaponSound ("PerfectDark/Weapons/Dragon")
    TK71 I 1 BRIGHT A_FireBullets(1, 1, 1, 12, "BulletPuff",FBF_USEAMMO)
    TNT1 A 0 A_TakeInventory("SuperDragonClip",1)
	PP7G B 0 BRIGHT A_SpawnItemEx ("PDPointedBulletCasing", 25,cos(pitch)*4,sin(-pitch)*0+30, frandom(0.5,1.2),frandom(-2.5,1.2),frandom(1.5,2.5))
    TK71 J 2
	TK71 K 2 A_REFIRE
	TK71 L 2 
	TK71 M 2 
	TK71 N 2
	TK71 OPQRS 2 
    Goto Ready+9
		Reload:
		TK04 A 0
		goto ReloadCheck
		
		  Ready2:
		  TNT1 A 0 A_PlaySound ("PerfectDark/Weapons/WeaponDraw","Weapon")
       TK71 A 2 
    TK71 B 2
    TK71 C 2
    TK71 D 2
    TK71 EFGH 2
	TK74 ABCDEFGHIJKL 1
	TK74 M -1 A_WeaponReady
    loop
		
    Deselect2:
    TK74 LKJIHGFEDCBA 1
	TK71 TUVX 2
    TK08 A 0 A_Lower
    wait
	
	 AltFire:
    TK01 A 0 A_JumpIfInventory ("SuperDragonGrenadeLauncherCheck",1,"ComeBack")
    TK01 A 0 A_Giveinventory ("SuperDragonGrenadeLauncherCheck",1)
    TK74 ABCDEFGHIJKL 1
	TK74 M 1
    goto ready2+21
   FireGrenadeLauncher:
   NULL A 0 A_JumpIfInventory("SuperDragonAltClip",1,1)
	goto AltReloadCheck
   TNT1 A 0 A_PlayWeaponSound ("PerfectDark/Weapons/SuperDragonAlt")
    TK74 N 2 Bright A_FireCustomMissile ("PDSuperDragonGrenade")
	TNT1 A 0 A_TakeInventory("SuperDragonAltClip",1,TIF_NOTAKEINFINITE)
    TK74 OPQRSTUVXYZ 1
	TK75 ABCDEFG 1
    goto ready2+21
  ComeBack:
    TK01 A 0 A_TakeInventory ("SuperDragonGrenadeLauncherCheck",1)
    TK74 LKJIHGFEDCBA 1
    goto ready+8
	
     AltReloadCheck:
	 KLBG A 0 A_JumpIfInventory("SuperDragonAltClip",6,2)
	 KLBG A 0 A_JumpIfInventory("PDGrenadeRoundAmmo",1,"AltReloadStart")
	 KLBG A 0
	 Goto Ready+9

  AltReloadStart:
     TL73 ABCDEFGH 1
	 KLBR A 0 A_PlayWeaponSound("PerfectDark/Weapons/DragonReload")
	 TL73 IJKLMNOPQRSTUVXYZ 1
	 TL74 ABCDEF 1
	 goto AltReloadAmmo

  AltReloadAmmo:
	 TNT1 A 0 A_TakeInventory("PDGrenadeRoundAmmo",1)
	 TNT1 A 0 A_GiveInventory("SuperDragonAltClip",1)
	 TNT1 A 0 A_JumpIfInventory("SuperDragonAltClip",6,"AltReloadDone")
	 TNT1 A 0 A_JumpIfInventory("PDGrenadeRoundAmmo",1,"AltReloadAmmo")
	 goto AltReloadDone
	 
	 AltReloadDone:
	 TL74 GHIJKLMNOPQRSTUVXYZ 1
	 TL75 ABCD 1
	 Goto ready2+21
	
	User1:
	TK01 A 0 A_JumpIfInventory ("SuperDragonGrenadeLauncherCheck",1,"User1IfInGrenadeLauncher")
	TK04 A 0
	goto AltWithoutBeingInAltReloadCheck
	
	User1IfInGrenadeLauncher:
	TK04 A 0
	goto AltReloadCheck
	
  AltWithoutBeingInAltReloadCheck:
	 KLBG A 0 A_JumpIfInventory("SuperDragonAltClip",6,2)
	 KLBG A 0 A_JumpIfInventory("PDGrenadeRoundAmmo",1,"AltWithoutBeingInAltReloadStart")
	 KLBG A 0
	 Goto Ready+9

  AltWithoutBeingInAltReloadStart:
  TK74 ABCDEFGHIJKL 1
  TK74 M 1
     TL73 ABCDEFGH 1
	 KLBR A 0 A_PlayWeaponSound("PerfectDark/Weapons/DragonReload")
	 TL73 IJKLMNOPQRSTUVXYZ 1
	 TL74 ABCDEF 1
	 goto AltWithoutBeingInAltReloadAmmo

  AltWithoutBeingInAltReloadAmmo:
	 TNT1 A 0 A_TakeInventory("PDGrenadeRoundAmmo",1)
	 TNT1 A 0 A_GiveInventory("SuperDragonAltClip",1)
	 TNT1 A 0 A_JumpIfInventory("SuperDragonAltClip",6,"AltWithoutBeingInAltReloadDone")
	 TNT1 A 0 A_JumpIfInventory("PDGrenadeRoundAmmo",1,"AltWithoutBeingInAltReloadAmmo")
	 goto AltWithoutBeingInAltReloadDone
	 
	 AltWithoutBeingInAltReloadDone:
	 TL74 GHIJKLMNOPQRSTUVXYZ 1
	 TL75 ABCD 1
	 TK74 LKJIHGFEDCBA 1
	 goto ready+8
	
  }
}

Actor SuperDragonGrenadeLauncherCheck : Inventory
{
   Inventory.Amount 1
   Inventory.MaxAmount 1
}


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

ACTOR PDSuperDragonPickup : Custominventory
{
   Scale 0.050
  Inventory.PickupMessage "Picked up a SuperDragon."
  	Inventory.PickupSound "PerfectDark/Items/PickupWeapon"
   States
   {
   Spawn:
	  TKA4 L -1
	  loop
   Pickup:
	  TNT1 A 0 A_GiveInventory("PDSuperDragon")
	  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 SuperDragonAltClip : Ammo
{
Inventory.MaxAmount 6 // size of the clip
Ammo.BackpackAmount 0
Ammo.BackpackMaxAmount 6 //MUST be the same as Inventory.MaxAmmount
+INVENTORY.IGNORESKILL
}

actor PDSuperDragonGrenade
{
  Radius 8
  Height 8
  PROJECTILE
  Speed 20
  Damage 100
  Scale 0.030
  BounceCount 3
  BounceFactor 0.5
  Gravity 0.6
  DamageType Grenade
  +HEXENBOUNCE
  +FORCEXYBILLBOARD
  -NOGRAVITY
    Obituary  "%o took an express trip to hell thanks to %k's SuperDragon's Grenades."
  States
  {
  Spawn:
	TF04 A 0
	TF04 A 0 Thing_ChangeTID(0, 255)
	TF04 A 0 ThrustThingZ(0, 10, 0, 1)
	TF04 A 0 A_StopSound
	TF04 A 1 A_SpawnItemEx("PDSuperDragonGrenadeTrail", Random(-2,2), Random(-2,2), Random(-2,2), 0, 0, 0, 0, 128, 0)
	goto Spawn+4
  Death:
	MISL B 0 bright A_Explode(64, 128, 1)
	MISL B 0 A_NoGravity
	TNT1 A 0 radius_quake(2, 10, 0, 3, 0)
	TNT1 A 0 A_PlaySoundEx("PerfectDark/Weapons/Boom", "Auto", 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 ("RollingExplosion2", 0, 0, 0, 0, 0, 0, 0, 0, 0)
	TNT1 A 0 A_SpawnItemEx ("ExplosionSmoke2", Random(-44, 44), Random(-44, 44), Random(0, 38), 0, 0, 0, 0, 128, 0)
	TNT1 A 3 A_SpawnItemEx ("RollingExplosion2", Random(-24, 24), Random(-24, 24), Random(0, 38), 0, 0, 0, Random(-360, 360), 0, 0)
	TNT1 A 0 A_SpawnItemEx ("ExplosionSmoke2", Random(-44, 44), Random(-44, 44), Random(0, 38), 0, 0, 0, 0, 128, 0)
	TNT1 A 3 A_SpawnItemEx ("RollingExplosion2", Random(-24, 24), Random(-24, 24), Random(0, 38), 0, 0, 0, Random(-360, 360), 0, 0)
	TNT1 A 0 A_SpawnItemEx ("ExplosionSmoke2", Random(-44, 44), Random(-44, 44), Random(0, 38), 0, 0, 0, 0, 128, 0)
	TNT1 A 3 A_SpawnItemEx ("RollingExplosion2", Random(-24, 24), Random(-24, 24), Random(0, 38), 0, 0, 0, Random(-360, 360), 0, 0)
	TNT1 A 0 A_SpawnItemEx ("ExplosionSmoke2", Random(-44, 44), Random(-44, 44), Random(0, 38), 0, 0, 0, 0, 128, 0)
	TNT1 A 3 A_SpawnItemEx ("RollingExplosion2", Random(-24, 24), Random(-24, 24), Random(0, 38), 0, 0, 0, Random(-360, 360), 0, 0)
	TNT1 A 0 A_SpawnItemEx ("ExplosionSmoke2", Random(-44, 44), Random(-44, 44), Random(0, 38), 0, 0, 0, 0, 128, 0)
	TNT1 A 3 A_SpawnItemEx ("RollingExplosion2", Random(-24, 24), Random(-24, 24), Random(0, 38), 0, 0, 0, Random(-360, 360), 0, 0)
	TNT1 A 0 A_SpawnItemEx ("ExplosionSmoke2", Random(-44, 44), Random(-44, 44), Random(0, 38), 0, 0, 0, 0, 128, 0)
	TNT1 A 3 A_SpawnItemEx ("RollingExplosion2", Random(-24, 24), Random(-24, 24), Random(0, 38), 0, 0, 0, Random(-360, 360), 0, 0)
	TNT1 A 0 A_SpawnItemEx ("ExplosionSmoke2", Random(-44, 44), Random(-44, 44), Random(0, 38), 0, 0, 0, 0, 128, 0)
	TNT1 A 3 A_SpawnItemEx ("RollingExplosion2", Random(-24, 24), Random(-24, 24), Random(0, 38), 0, 0, 0, Random(-360, 360), 0, 0)
	TNT1 A 0 A_SpawnItemEx ("ExplosionSmoke2", Random(-44, 44), Random(-44, 44), Random(0, 38), 0, 0, 0, 0, 128, 0)
	TNT1 A 3 A_SpawnItemEx ("RollingExplosion2", Random(-24, 24), Random(-24, 24), Random(0, 38), 0, 0, 0, Random(-360, 360), 0, 0)
	TNT1 A 0 A_SpawnItemEx ("ExplosionSmoke2", Random(-44, 44), Random(-44, 44), Random(0, 38), 0, 0, 0, 0, 128, 0)
	TNT1 A 3 A_SpawnItemEx ("RollingExplosion2", Random(-24, 24), Random(-24, 24), Random(0, 38), 0, 0, 0, Random(-360, 360), 0, 0)
	TNT1 AAAAAAA 5 A_SpawnItemEx ("RollingExplosion2", Random(-24, 24), Random(-24, 24), Random(0, 38), 0, 0, 0, Random(-360, 360), 0, 0)
	stop
  }
}

actor PDSuperDragonGrenadeTrail
{
  Projectile
  Radius 1
  Height 1
  Damage 0
  Speed 0
  Scale 0.08
  RenderStyle Add
  Alpha 0.6
  +NOCLIP
  +FORCEXYBILLBOARD
  States
  {
   Spawn:
   TNT1 A 0
   TNT1 A 2
   SMOK ABCDEFGHIJKLMNOPQ 1
   stop
  }
}
