actor Gyroman_W : BaseMM8BDMWep_CBM 
{
tag "$TAGC_5D"
dropitem "GyroAttackWep"
Weapon.AmmoUse 0
Weapon.AmmoGive 56
Obituary "$OB_GYROATTACK"
weapon.ammotype "GiveItAWhirlAmmo"
States
{
Spawn:
C_05 D 1
loop

Deselect:
GYAR A 0 A_GiveInventory("CBM_AviationOff_P")
GYAR A 0 A_TakeInventory("GyroTrigger")
GYAR A 0 A_TakeInventory("GyroTrigger2")
goto DeselectSwap
Select:
GYAR A 0
goto SelectSwap

Ready:
GYAR A 0 ACS_NamedExecuteWithResult("core_weaponcolor",DYE_GYROMAN)
GYAR A 0 A_GunFlash("Flash",1)
goto Ready2
Ready2:
GYAR A 0 A_JumpIfInventory("GyroTrigger2", 1, "Ready3")
//GYAR A 0 //A_JumpIfInventory("GiveItAWhirlAmmo",1,"Ready2HasAmmo")
GYAR A 5 A_WeaponReady//(8)
GYAR A 0 A_GiveInventory("GiveItAWhirlAmmo",1)
loop
Ready2HasAmmo:
GYAR A 5 A_WeaponReady
GYAR A 0 A_GiveInventory("GiveItAWhirlAmmo",1)
Goto Ready2
Ready3:
GYAR A 1 A_WeaponReady
Goto Ready2

Fire:
//GYAR A 0 A_JumpIfInventory("GyroTrigger2", 1, "Fire2")
GYAR B 2 Offset(1,32)A_FireCustomMissile("GyroAttackClass",0,0,8,0)
GYAR B 2 Offset(-70,42)
GYAR B 2 Offset(-121,114)
GYAR C 2 Offset(1,32)
GYAR C 0 A_JumpIfInventory("GyroTrigger2",1,2)
GYAR C 0 A_GiveInventory("GiveItAWhirlAmmo",1)
GYAR C 2 Offset(-21,56)
GYAR C 2 Offset(-33,84)
TNT1 A 4
TNT1 A 0 A_JumpIfInventory("GyroTrigger2",1,2)
TNT1 A 0 A_GiveInventory("GiveItAWhirlAmmo",1)
TNT1 A 2
GYAR A 2 Offset(-9,92)
GYAR A 2 Offset(-5,68)
GYAR A 2 Offset(-2,48)
GYAR A 0 A_JumpIfInventory("GyroTrigger2",1,2)
GYAR A 0 A_GiveInventory("GiveItAWhirlAmmo",1)
GYAR A 0 A_Refire
Goto Ready2

Altfire:
GYAR D 0 A_JumpIfInventory("GyroTrigger2",1,"FallCheck")
GYAR D 1 A_JumpIfInventory("GiveItAWhirlAmmo",1,"Fly")
GYAR D 0
goto Fall
Fly:
GYAR D 0 A_GiveInventory("GyroTrigger",1)
GYAR D 0 A_GiveInventory("GyroTrigger2",1)
//GYAR D 1
GYAR D 0 A_ReFire("FlyHold")
Goto Ready3
FlyAgain:
GYAR D 0 A_GiveInventory("GyroTrigger",1)
GYAR D 0 A_ReFire("FlyHold")
Goto Ready3
FlyHold:
GYAR D 1 A_GiveInventory("VivifyCycle1",1)
GYAR D 0 A_ReFire(2)
GYAR D 0 A_TakeInventory("VivifyCycle1")
goto Ready3
GYAR D 0 A_JumpIfInventory("GyroTrigger", 1,"FlyHold")
GYAR D 0 A_TakeInventory("VivifyCycle1")
goto Ready3
FallCheck:
GYAR D 0 A_JumpIfInventory("GyroTrigger",1,"Fall")
GYAR D 0 A_JumpIfInventory("GiveItAWhirlAmmo",1,"FlyAgain")
goto Fall
Fall:
GYAR D 0 A_GiveInventory("CBM_AviationOff_P")
GYAR D 0 A_TakeInventory("GyroTrigger",999)
GYAR D 0 A_ReFire("FallHold")
goto Ready2
FallHold:
GYAR D 1 A_RailWait
GYAR D 0 A_ReFire("FallHold")
goto Ready2

Flash:
TNT1 A 1 A_GiveInventory("GyroM_FlashState_P")
loop
}
}

actor GiveItAWhirlAmmo : Ammo
{
inventory.amount 1
inventory.maxamount 28
+INVENTORY.IGNORESKILL 
}


actor GyroTrigger : OnceC{}//Flying Toggle
actor GyroTrigger2 : OnceC{}//Still midair Toggle

actor GyroM_AmmoDelay : Inventory
{
inventory.amount 1
inventory.maxamount 50
}

actor GyroM_FlySndDelay : Powerup
{
Powerup.Duration 5
}

actor GyroM_FlashState_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_JumpIfInventory("GyroTrigger",1,"PickupFly")
TNT1 A 0 A_JumpIfInventory("GyroTrigger2",1,"LookingForGround")
stop
PickupFly:
TNT1 A 0 A_GiveInventory("CBM_AviationOn_P")
TNT1 A 0 A_GiveInventory("GyroM_AmmoDrain_P")
TNT1 A 0
TNT1 A 0 A_JumpIfInventory("GiveItAWhirlAmmo",1,"No")
TNT1 A 0 A_GiveInventory("CBM_AviationOff_P")
TNT1 A 0 A_TakeInventory("GyroTrigger",1)
goto LookingForGround
LookingForGround:
TNT1 A 0 A_JumpIfInventory("GyroTrigger",1,"No")
TNT1 A 0 A_JumpIf(z-floorz==0,"FoundGround")
TNT1 A 0 A_JumpIfInventory("PowerMomZVerify",1,"CheckMomZ")
TNT1 A 0 A_JumpIf(momz==0,"MomZVerify")
stop
CheckMomZ:
TNT1 A 0 A_JumpIf(momz==0,"FoundGround")
stop
MomZVerify:
TNT1 A 0 A_GiveInventory("PowerMomZVerify")
stop
FoundGround:
TNT1 A 0 A_TakeInventory("GyroTrigger")
TNT1 A 0 A_TakeInventory("GyroTrigger2")
stop
No:
TNT1 A 0
stop
}
}

actor GyroM_AmmoDrain_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_JumpIfInventory("GyroM_FlySndDelay",1,3)
TNT1 A 0 A_GiveInventory("GyroM_FlySndDelay")
TNT1 A 0 A_PlaySoundEx("Classes/Hind","Body")
TNT1 A 0
TNT1 A 0 A_JumpIfInventory("GyroM_AmmoDelay",8,"AmmoTake")
TNT1 A 0 A_JumpIfInventory("VivifyCycle1",1,2)
TNT1 A 0 A_GiveInventory("GyroM_AmmoDelay",2)
stop
TNT1 A 0 A_GiveInventory("GyroM_AmmoDelay",1)
stop
AmmoTake:
TNT1 A 0 A_TakeInventory("GyroM_AmmoDelay")
TNT1 A 0 A_JumpIfInventory("EndlessAmmoCycle_F",1,3)
TNT1 A 0 A_GiveInventory("EndlessAmmoCycle_F",1)
TNT1 A 0 A_TakeInventory("GiveItAWhirlAmmo",1)
stop
TNT1 A 0 A_TakeInventory("EndlessAmmoCycle_F")
TNT1 A 0 A_TakeInventory("GiveItAWhirlAmmo",1,1)
stop



}
}

actor GyroAttackClass : ProjSpawnFuncActor
{
SeeSound "weapon/GyroM_Attack"
//DeathSound ""
PROJECTILE
Obituary "$OB_GYROATTACK"
damagetype "GyroM_Shot"
+SKYEXPLODE
+EXPLODEONWATER
damage (150)
Radius 16
Height 8
speed 40
scale 2.5
States
{
Spawn:
GYAR G 0 A_PlaySoundEx("weapon/GyroM_Attack","Voice")
//GYAR GH 2
GYAR GHGHGHGHGHG 2
GYAR H 0 A_PlaySoundEx("weapon/GyroM_Attack","Voice")
GYAR HGHGHGHGHGH 2
loop
Death:
GYAR G 0 A_JumpIf(z-floorz==0,"Floor")
GYAR G 0 A_JumpIf(z-ceilingz==0-8, "Ceiling")
GYAR G 0 //A_SpawnItemEx("GyroAttackClass3",0,0,0,0,0,0,180,1)
stop
Floor:
GYAR G 0 A_SpawnItemEx("GyroAttackClass2",0,0,1,40,0,0,0,1)
stop
Ceiling:
GYAR G 0 A_SpawnItemEx("GyroAttackClass2",0,0,-1,40,0,0,0,1)
stop
XDeath:
GYAR G 0
stop
}
}

actor GyroAttackClass2 : GyroAttackClass
{
SeeSound ""
States
{
Spawn:
GYAR G 0
goto GyroAttackClass::Spawn
Death:
goto XDeath
}
}

actor GyroAttackClass3 : GyroAttackClass
{
+SEEKERMISSILE
States
{
Spawn:
GYAR G 0
GYAR G 0 A_JumpIf(!CallACS("cbm_PointerExists",AAPTR_TARGET),2)
GYAR G 0 A_RearrangePointers(0,0,2)
GYAR G 0 A_FaceTarget(0,0)
GYAR G 0 A_ChangeVelocity(Cos(pitch)*40,0,sin(pitch)*40,3)
GYAR GG 0 A_SeekerMissile(90,90,SMF_PRECISE)
goto GyroAttackClass::Spawn
Death:
goto XDeath
}
}

actor Gyroman_W_NormalBar : NormalBar {Args 4,128}//110