Actor PlasmaRepeater : Weapon
{
  Inventory.PickupSound "PlasmaRepeater/Pickup"
  Weapon.Upsound "PlasmaRepeater/Draw"
  Inventory.PickupMessage "You got the Plasma Repeater!"
  Obituary "%o was disintegrated by %k's Plasma Repeater."
  Weapon.AmmoType1 "NewCell"
  Weapon.AmmoType2 "NewCell"
  Weapon.AmmoUse1 1
  Weapon.AmmoGive1 20
  Tag "Plasma Repeater"
  +Weapon.Explosive
  States
  {
  Spawn:
    REPP A -1
    Loop
  Ready:
    REPG A 0 A_TakeInventory("RepeaterSpin", 3)
    REPG A 0 A_GiveInventory("RepeaterFrameA", 1)
    REPG A 1 A_WeaponReady
    Loop
  Deselect:
	TNT1 A 0 A_TakeInventory("HandGrenadeAction",1)
	TNT1 A 0 A_TakeInventory("MineAction",1)
	TNT1 A 0 A_TakeInventory("RailgunAction",1)
	TNT1 A 0 A_PlayWeaponSound("weapons/weapondown")
    REPG A 0 A_TakeInventory("RepeaterSpin", 3)
    REPG A 0 A_GiveInventory("RepeaterFrameA", 1)
    REPG A 1 A_Lower
    Goto Deselect+4
  Select:
    REPG A 1 A_Raise
    Loop
  Fire:
    //===========Spinup
    REPG A 0 A_PlaySound("PlasmaRepeater/Spin")
    REPG A 0 A_JumpIfInventory("RepeaterSpin", 1, 8)
    REPG A 0 A_JumpIfInventory("RepeaterB", 1, 4)
    REPG A 0 A_JumpIfInventory("RepeaterC", 1, 4)
    REPG A 0 A_JumpIfInventory("RepeaterD", 1, 4)
    REPG A 4
    REPG B 4
    REPG C 4
    REPG D 4 A_GiveInventory("RepeaterFrameA")
    REPG A 0 A_JumpIfInventory("RepeaterSpin", 2, 9)
    REPG A 0 A_GiveInventory("RepeaterSpin", 1)
    REPG A 0 A_JumpIfInventory("RepeaterB", 1, 4)
    REPG A 0 A_JumpIfInventory("RepeaterC", 1, 4)
    REPG A 0 A_JumpIfInventory("RepeaterD", 1, 4)
    REPG A 3
    REPG B 3
    REPG C 3
    REPG D 3 A_GiveInventory("RepeaterFrameA")
    REPG A 0 A_JumpIfInventory("RepeaterB", 1, 4)
    REPG A 0 A_JumpIfInventory("RepeaterC", 1, 4)
    REPG A 0 A_JumpIfInventory("RepeaterD", 1, 4)
    REPG A 2
    REPG B 2
    REPG C 2
    REPG D 2 A_GiveInventory("RepeaterFrameA")
    //===========Fire
    REPG A 0 A_Refire
    //===========Spindown
    REPG A 0 A_PlaySound("PlasmaRepeater/Down")
    REPG A 0 A_GiveInventory("RepeaterFrameA", 1)
    REPG AA 1 A_WeaponReady(11)
    REPG A 0 A_GiveInventory("RepeaterFrameB", 1)
    REPG BB 1 A_WeaponReady(11)
    REPG A 0 A_GiveInventory("RepeaterFrameC", 1)
    REPG CC 1 A_WeaponReady(11)
    REPG A 0 A_GiveInventory("RepeaterFrameD", 1)
    REPG DD 1 A_WeaponReady(11)
    REPG A 0 A_TakeInventory("RepeaterSpin", 1)
    REPG A 0 A_GiveInventory("RepeaterFrameA", 1)
    REPG AAA 1 A_WeaponReady(11)
    REPG A 0 A_GiveInventory("RepeaterFrameB", 1)
    REPG BBB 1 A_WeaponReady(11)
    REPG A 0 A_GiveInventory("RepeaterFrameC", 1)
    REPG CCC 1 A_WeaponReady(11)
    REPG A 0 A_GiveInventory("RepeaterFrameD", 1)
    REPG DDD 1 A_WeaponReady(11)
    REPG A 0 A_TakeInventory("RepeaterSpin", 1)
    REPG A 0 A_GiveInventory("RepeaterFrameA", 1)
    REPG AAAA 1 A_WeaponReady(11)
    REPG A 0 A_GiveInventory("RepeaterFrameB", 1)
    REPG BBBB 1 A_WeaponReady(11)
    REPG A 0 A_GiveInventory("RepeaterFrameC", 1)
    REPG CCCC 1 A_WeaponReady(11)
    REPG A 0 A_GiveInventory("RepeaterFrameD", 1)
    REPG DDDD 1 A_WeaponReady(11)
    REPG A 0 A_GiveInventory("RepeaterFrameA", 1)
    REPG AAAA 1 A_WeaponReady(11)
    REPG A 0 A_GiveInventory("RepeaterFrameB", 1)
    REPG BBBB 1 A_WeaponReady(11)
    REPG A 0 A_GiveInventory("RepeaterFrameC", 1)
    REPG CCCC 1 A_WeaponReady(11)
    REPG A 0 A_GiveInventory("RepeaterFrameD", 1)
    REPG DDDD 1 A_WeaponReady(11)
    Goto Ready
  Hold:
    //===========Fire
    REPG E 0 Bright A_Gunflash
    REPG E 0 Bright A_AlertMonsters
	TNT1 A 0 Radius_Quake(4,2,0,1,0)
    REPG E 1 Bright A_FireCustomMissile("PlayerRepeaterPlasma",frandom(-6,6),1,0,-8)
    REPG F 1 Bright
    REPG G 0 Bright A_AlertMonsters
	TNT1 A 0 Radius_Quake(4,2,0,1,0)
    REPG G 1 Bright A_FireCustomMissile("PlayerRepeaterPlasma",frandom(-6,6),1,0,-8)
    REPG H 1 Bright
    REPG A 0 A_Refire
    //===========Spindown
    REPG A 0 A_PlaySound("PlasmaRepeater/Down")
    REPG A 0 A_GiveInventory("RepeaterFrameA", 1)
    REPG AA 1 A_WeaponReady(11)
    REPG A 0 A_GiveInventory("RepeaterFrameB", 1)
    REPG BB 1 A_WeaponReady(11)
    REPG A 0 A_GiveInventory("RepeaterFrameC", 1)
    REPG CC 1 A_WeaponReady(11)
    REPG A 0 A_GiveInventory("RepeaterFrameD", 1)
    REPG DD 1 A_WeaponReady(11)
    REPG A 0 A_TakeInventory("RepeaterSpin", 1)
    REPG A 0 A_GiveInventory("RepeaterFrameA", 1)
    REPG AAA 1 A_WeaponReady(11)
    REPG A 0 A_GiveInventory("RepeaterFrameB", 1)
    REPG BBB 1 A_WeaponReady(11)
    REPG A 0 A_GiveInventory("RepeaterFrameC", 1)
    REPG CCC 1 A_WeaponReady(11)
    REPG A 0 A_GiveInventory("RepeaterFrameD", 1)
    REPG DDD 1 A_WeaponReady(11)
    REPG A 0 A_TakeInventory("RepeaterSpin", 1)
    REPG A 0 A_GiveInventory("RepeaterFrameA", 1)
    REPG AAAA 1 A_WeaponReady(11)
    REPG A 0 A_GiveInventory("RepeaterFrameB", 1)
    REPG BBBB 1 A_WeaponReady(11)
    REPG A 0 A_GiveInventory("RepeaterFrameC", 1)
    REPG CCCC 1 A_WeaponReady(11)
    REPG A 0 A_GiveInventory("RepeaterFrameD", 1)
    REPG DDDD 1 A_WeaponReady(11)
    REPG A 0 A_GiveInventory("RepeaterFrameA", 1)
    REPG AAAA 1 A_WeaponReady(11)
    REPG A 0 A_GiveInventory("RepeaterFrameB", 1)
    REPG BBBB 1 A_WeaponReady(11)
    REPG A 0 A_GiveInventory("RepeaterFrameC", 1)
    REPG CCCC 1 A_WeaponReady(11)
    REPG A 0 A_GiveInventory("RepeaterFrameD", 1)
    REPG DDDD 1 A_WeaponReady(11)
    Goto Ready
  Flash:
    TNT1 A 2 A_Light2
    TNT1 A 2 A_Light1
    TNT1 A 0 A_Light0
    Stop
  }
}

Actor RepeaterSpin : Inventory { Inventory.MaxAmount 2 }
Actor RepeaterB : Inventory { Inventory.MaxAmount 1 }
Actor RepeaterC : Inventory { Inventory.MaxAmount 1 }
Actor RepeaterD : Inventory { Inventory.MaxAmount 1 }

Actor RepeaterFrameA : CustomInventory
{
  Inventory.MaxAmount 0
  +Inventory.AutoActivate
  States
  {
  Spawn:
    TNT1 A 1
    Stop
  Use:
    TNT1 A 0 A_TakeInventory("RepeaterB", 1)
    TNT1 A 0 A_TakeInventory("RepeaterC", 1)
    TNT1 A 0 A_TakeInventory("RepeaterD", 1)
    Stop
  }
}

Actor RepeaterFrameB : RepeaterFrameA
{
  States
  {
  Spawn:
    TNT1 A 1
    Stop
  Use:
    TNT1 A 0 A_GiveInventory("RepeaterB", 1)
    TNT1 A 0 A_TakeInventory("RepeaterC", 1)
    TNT1 A 0 A_TakeInventory("RepeaterD", 1)
    Stop
  }
}

Actor RepeaterFrameC : RepeaterFrameA
{
  States
  {
  Spawn:
    TNT1 A 1
    Stop
  Use:
    TNT1 A 0 A_TakeInventory("RepeaterB", 1)
    TNT1 A 0 A_GiveInventory("RepeaterC", 1)
    TNT1 A 0 A_TakeInventory("RepeaterD", 1)
    Stop
  }
}

Actor RepeaterFrameD : RepeaterFrameA
{
  States
  {
  Spawn:
    TNT1 A 1
    Stop
  Use:
    TNT1 A 0 A_TakeInventory("RepeaterB", 1)
    TNT1 A 0 A_TakeInventory("RepeaterC", 1)
    TNT1 A 0 A_GiveInventory("RepeaterD", 1)
    Stop
  }
}



ACTOR PlayerRepeaterPlasma : OverseerPlasma
{
Damage 8  
+THRUSPECIES
Species "Player"
Damagetype "Player"
States
	{
	Death:
		TNT1 A 0
		TNT1 A 0 A_Explode(20,80)
		TNT1 A 0 A_SpawnItemEx("GreenParticleSpawner",0,0,0,0,0,0,0,SXF_CLIENTSIDE|SXF_NOCHECKPOSITION,0)
		TNT1 AAA 0 A_CustomMissile("Kaboom7",0,0,random(0,360),CMF_AIMDIRECTION,random(0,360))
		TNT1 AAA 0 A_CustomMissile("SmokeFX4",0,0,random(0,360),CMF_AIMDIRECTION,random(0,360))
		OVPL HIJ 3 Bright
		Stop
	}
}