ACTOR "Flak Cannon " : "Flak Cannon" Replaces "Flak Cannon"
{
  Tag "Flak Cannon"
  Weapon.SisterWeapon "Empowered Flak Cannon"
}

ACTOR "Empowered Flak Cannon" : "Flak Cannon"
{
	Tag "Empowered Flak Cannon"
    Radius 20
    Weapon.Kickback 50
	Weapon.SelectionOrder 400
	Weapon.AmmoGive 30
	Weapon.AmmoType "NewShell"
	Weapon.AmmoUse 1
	Weapon.AmmoType2 "Missile"
	Weapon.AmmoUse2 1
	Weapon.KickBack 5
	Weapon.SisterWeapon "Flak Cannon "
	DamageType SSG
	+WEAPON.NOAUTOFIRE
	+WEAPON.NOAUTOAIM
    +WEAPON.POWERED_UP
	+INVENTORY.UNDROPPABLE
	+FORCEXYBILLBOARD
	States
	{
	Spawn:
		DFKG Z -1
		Loop
	Ready:
		TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
		TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
		DFKG A 1 A_WeaponReady
		Loop
	Deselect:
		TNT1 A 0 A_PlayWeaponSound("weapons/weapondown")
		DFKG A 1 A_Lower
		Goto Deselect+1
	Select:
		TNT1 AAAAAAAAAAAA 0 A_Raise
		DFKG LMN 2
        TNT1 A 0 A_PlaySound("flak/select")
        DFKG A 8
		Goto Ready
    NoAmmo:
        DFKG A 4 A_PlaySound("Weapon/Empty", 2)
        Goto Ready+6
	Fire:
		TNT1 A 0 A_Recoil(10)
        DFKG B 1 BRIGHT A_playsound("Weapon/DFLAKFIRE", 5)
		DFKG B 1 BRIGHT Radius_Quake (16, 8, 0, 1, 0)
		TNT1 A 0 A_TakeInventory("NewShell",5,TIF_NOTAKEINFINITE)
		DFKG BBBBBBBB 0 A_FireCustomMissile("DFlak",frandom(6,-6),0,frandom(1,-1),frandom(1,-1),0,frandom(6,-6))
        DFKG B 1 BRIGHT A_ZoomFactor(0.85)
        DFKG C 1 A_ZoomFactor(0.9)
        DFKG C 1 A_ZoomFactor(0.910)
        DFKG C 1 A_ZoomFactor(0.920)
        DFKG C 1 A_ZoomFactor(0.930)
        DFKG C 1 A_ZoomFactor(0.940)
        DFKG C 1 A_ZoomFactor(0.950)
		DFKG C 1 A_ZoomFactor(0.960)
		DFKG C 2 A_ZoomFactor(0.980)
		DFKG C 2 A_ZoomFactor(1.0)
		//Don't go through reload if we don't have any ammo!
		TNT1 A 0 A_CheckReload

		DFKG DDEEFF 2
		DFKG G 2 A_PlaySound("Weapon/FLAKSNAP")
		DFKG HHOOII 2
		DFKG I 4
		DFKG JK 2
        TNT1 A 0 A_playsound("Weapon/FLAKRELD")
		DFKG L 6
		DFKG MNAA 2
		TNT1 A 0 A_ReFire
		DFKG A 2
        Goto Ready+7
		
	AltFire:
		DFKG A 0 A_GunFlash
		DFKG A 0 BRIGHT A_playsound("Weapon/FLAKAFIR", 5)
		DFKG B 1 BRIGHT Radius_Quake (8, 6, 0, 1, 0)
		TNT1 A 0 A_TakeInventory("Missile",4,TIF_NOTAKEINFINITE)
		DFKG B 3 BRIGHT A_FireCustomMissile("DementedFlakSlug",0,1,2,4,0)
        DFKG B 1 BRIGHT A_ZoomFactor(0.9)
        DFKG C 1 A_ZoomFactor(0.910)
        DFKG C 1 A_ZoomFactor(0.920)
        DFKG C 1 A_ZoomFactor(0.930)
        DFKG C 1 A_ZoomFactor(0.940)
        DFKG C 1 A_ZoomFactor(0.950)
        DFKG C 2 A_ZoomFactor(0.970)
		DFKG C 2 A_ZoomFactor(0.990)
		DFKG C 2 A_ZoomFactor(1.0)

		//Don't go through reload if we don't have any ammo!
		TNT1 A 0 A_CheckReload

		DFKG DDEEFF 2
		DFKG G 2 A_PlaySound("Weapon/FLAKSNAP")
		DFKG HHOOII 2
		DFKG I 4
		DFKG JK 2
        TNT1 A 0 A_playsound("Weapon/FLAKRELD")
		DFKG L 6
		DFKG MNAA 2
		TNT1 A 0 A_ReFire
		DFKG A 2
        Goto Ready+7

  GrenadeCheck:
	TNT1 A 0 A_JumpIfInventory("HandGrenadeAmmo",1,"GrenadeToss")
	TNT1 A 0 A_TakeInventory("HandGrenadeAction",1)
	Goto Ready
	
  GrenadeToss:
  	TNT1 A 0 A_PlayWeaponSound("weapons/weapondown") 
	DFKG A 1 Offset(0,30)
	DFKG A 1 Offset(0,40)
	DFKG A 1 Offset(0,50)
	DFKG A 1 Offset(0,60)
	DFKG A 1 Offset(0,70)
	TNT1 A 4 Offset(0,10)
	HGRN ABC 1 
	HGRN D 2
	HGRN EFG 1
	HGRN HI 2
	TNT1 A 15 A_PlayWeaponSound("weapons/hgrenadepin")
	TNT1 A 0 A_PlayWeaponSound("weapons/hgrenadethrow")
	TNT1 A 0 A_TakeInventory("HandGrenadeAmmo",1)
	HGNE A 1 A_FireCustomMissile("ThrownGrenade",0,0,0,0)
	HGRN J 1
	HGRN KLM 2
	HGRN NO 1
	TNT1 A 6
	TNT1 A 0 A_JumpIfInventory("HandGrenadeAmmo",1,2)
    TNT1 A 0 A_TakeInventory("Hand Grenade",1)
	TNT1 A 0 A_TakeInventory("HandGrenadeAction",1)
	TNT1 A 0
	DFKG A 1 Offset(0,70)
	DFKG A 1 Offset(0,60)
	DFKG A 1 Offset(0,50)
	DFKG A 1 Offset(0,40)
	DFKG A 1 Offset(0,30)
	Goto Ready
	
  MineCheck:
	TNT1 A 0 A_JumpIfInventory("MineAmmo",1,"MineToss")
	TNT1 A 0 A_TakeInventory("MineAction",1)
	Goto Ready
	
  MineToss:
  	TNT1 A 0 A_PlayWeaponSound("weapons/weapondown") 
	DFKG A 1 Offset(0,30)
	DFKG A 1 Offset(0,40)
	DFKG A 1 Offset(0,50)
	DFKG A 1 Offset(0,60)
	DFKG A 1 Offset(0,70)
	TNT1 A 8 Offset(0,10)
	TNT1 A 0 A_PlayWeaponSound("weapons/hgrenadethrow")
	MINE ABCDEF 1		
	TNT1 A 0 A_TakeInventory("MineAmmo",1)	  
	MINE G 1 A_FireCustomMissile("ThrownMine",0,0,0,0)
	MINE HI 1
	MINE JK 2
	TNT1 A 0 A_JumpIfInventory("MineAmmo",1,2)
    TNT1 A 0 A_TakeInventory("Land Mine",1)
	TNT1 A 0 A_TakeInventory("MineAction",1)
	TNT1 A 0
	TNT1 A 5
	DFKG A 1 Offset(0,70)
	DFKG A 1 Offset(0,60)
	DFKG A 1 Offset(0,50)
	DFKG A 1 Offset(0,40)
	DFKG A 1 Offset(0,30)
	Goto Ready
	}
}

actor DFlak
{
Projectile
Species "Player"
Decal BulletChip
Radius 5
Height 5
Damage (15*random(1,5))
Scale 0.45
DamageType "normal"
Speed 35
Gravity 0.75
BounceType doom
BounceFactor 0.75
WallBounceFactor 0.55
BounceSound "ricochet/hit"
-NOGRAVITY
+RANDOMIZE
+FORCEXYBILLBOARD
+NOBLOCKMAP
+RIPPER
+DONTSPLASH
+THRUSPECIES
+EXTREMEDEATH
States
{
Spawn:
DFKS ABCDABCD 1 BRIGHT Light("DFLAK1")
DFKS EFGHEFGHEFGH 1 BRIGHT Light("DFLAK2")
DFKS FGH 4 A_SpawnItem("ShrapnelSmoke",0)
Loop
Death:
FKSD IJKIJKIJK 1
TNT1 A 0 A_CustomMissile("FlakResidue",-5,0,0,CMF_AIMDIRECTION)
FKSD KKKK 1 A_FadeOut(0.50)
Stop
}
}

Actor DementedFlakSlug
{
  Radius 16
  Height 16
  Speed 30
  Damage 80
  DECAL LegRocketScorch
  Species "Player"
  +BLOODSPLATTER 
  +DONTSPLASH
  +BLOODLESSIMPACT
  +THRUSPECIES
  Deathsound "Weapon/FLAKEXPL"
  PROJECTILE
  Scale 0.4
  Reactiontime 8
  Gravity 0.4
  states
  {
  Spawn:
    FLK1 A 5
    FLK1 A 0 A_Gravity
    FLK1 A 6 A_SpawnItemEx("ShrapnelSmoke",0,0,0,0,0,2,0,128,0)
    goto Spawn+2
  Death:
	TNT1 A 0 A_Explode(110,140)
    TNT1 A 0 A_NoGravity
	TNT1 A 0 A_SpawnItemEx("BlueParticleSpawner", 0, 0, 0, 0, 0, 0, 0, 128) 
    TNT1 AAA 0 A_CustomMissile("BlueKaboom3", 0, 0, random(0,360), 2, random(0,360))
	TNT1 AAA 0 A_CustomMissile("LegendarySmokeFX2", 0, 0, random(0,360), 2, random(0,360))
    TNT1 AAAA 0 A_SpawnItemEx("LegendaryDebris",0,0,0,Random(4,-4),Random(4,-4),Random(4,8),0,128)
    TNT1 A 0 A_SpawnItemEx("BlueKaboom3", 0, 0, 0, 0, 0, 0, 0, 128, 0)
	TNT1 AAAAAAAAAA 0 A_CustomMissile("DFlak",0,0,random(0,359),6,random(-90,90))
    TNT1 AAAAAAAAAAAAA 8 A_SpawnItemEx("LegendarySmokeFX2",0,0,0,0,0,2,0,128,0)
    Stop
  }
}