actor SuperAdaptorWep : BaseMM8BDMWep
{
	Weapon.AmmoUse 1
	Weapon.AmmoGive 3
	Weapon.SlotNumber 1
	Inventory.Pickupmessage "$PU_SUPERADAPTOR"
	Obituary "$OB_SUPERADAPTOR"
	Tag "$TAG_SUPERADAPTOR"
	weapon.ammotype "BusterAmmo"
	inventory.icon "NULLICON"
	Dropitem ""
	States
	{
	Spawn:
		WEA3 P 1
		stop
	Ready:
		SAPT A 0 A_GiveInventory("AdaptorFlag",1)
		TNT1 B 0 A_JumpIfInventory("BusterGiven",1,"TakeBusters")
		goto Ready2
	TakeBusters:
		TNT1 Q 0 A_GiveInventory("TakeBuster", 1)
		goto Ready2
	Ready2:
		SAPT A 0 ACS_ExecuteAlways(998,0,77)
		SAPT A 0 A_SpawnItemEx("AdaptorWings",0,0,0,0,0,0,0,0)
	Ready3:
		SAPT A 1 A_WeaponReady
		goto Ready3
	Deselect:
		SAPT A 1 A_StopSoundEx("Weapon")
		TNT1 A 0 //A_JumpIf(z-floorz!=0, "Deselect")
		TNT1 A 0 A_TakeInventory("AdaptorFlag",1)
		TNT1 AAAAAAAAAAAAAAAAAAAAAA 0 A_Lower
		SAPT A 1 A_Lower
		Loop
	Select:
		TNT1 AAAAAAAAAAAAAAAAAAAAAA 0 A_Raise
		SAPT A 1 A_Raise
		Loop
	Fire:
	Altfire:
		SAPT A 0 A_JumpIfNoAmmo("NoAmmo")
		SAPT A 0 A_PlaySoundEx("weapon/mbuster","Weapon")
		SAPT A 0 ACS_ExecuteAlways(991,0,77)
		SAPT A 0 A_FireCustomMissile("MegaShot",0,0,8,0)
		SAPT BC 3
		SAPT A 1 A_TakeInventory("WeaponCharge",999)
		SAPT B 0 A_Refire
		SAPT A 0 ACS_ExecuteAlways(998,0,77,1)
		goto Ready3
	Hold:
		SAPT D 0 A_JumpIfInventory("WeaponCharge",35,"Charge2")
		SAPT D 0 A_JumpIfInventory("WeaponCharge",18,"Charge")
		SAPT A 1 A_GiveInventory("WeaponCharge",1)
		SAPT D 0 A_Refire
		goto Fire
	Charge:
		SAPT D 0 A_JumpIfInventory("WeaponCharge",35,"Charge2")
		SAPT D 0 A_JumpIfInventory("WeaponCharge",19,"Charge1")
		SAPT D 0 A_PlaySoundEx("weapon/adaptercharge","Weapon")
		SAPT ADADAD 1
		goto Charge1
	Charge1:
		SAPT A 0 A_JumpIfInventory("WeaponCharge",35,"Charge2Start")
		SAPT A 0 ACS_ExecuteAlways(991,0,77)
		SAPT A 1 A_GiveInventory("WeaponCharge_RC",1)
		SAPT A 0 A_Refire("Charge1.a")
		goto Fire
	Charge1.a:
		SAPT A 0 ACS_ExecuteAlways(991,0,78)
		SAPT D 1 //A_GiveInventory("AdapterCharge",1)
		SAPT A 0 A_Refire("Charge1")
		goto Fire
	Charge2Start:
		SAPT G 0 A_GunFlash("Sound.BusterCharge", GFF_NOEXTCHANGE)
	Charge2:
		SAPT G 1 ACS_ExecuteAlways(991,0,79)
		SAPT A 0 A_Refire("Charge2.a")
		goto Fire2
	Charge2.a:
		SAPT H 1 ACS_ExecuteAlways(991,0,80)
		SAPT A 0 A_Refire("Charge2.b")
		goto Fire2
	Charge2.b:
		SAPT K 1 ACS_ExecuteAlways(991,0,77)
		SAPT A 0 A_Refire("Charge2.c")
		goto Fire2
	Charge2.c:
		SAPT K 0 A_JumpIfInventory("IsBot", 1, "BotFire")
		SAPT A 0 A_Refire("Charge2")
		goto Fire2
	BotFire:
		SAPT K 0 A_Jump(16, "Fire2")
		SAPT A 0 A_Refire
    Fire2:
        SAPT A 0 ACS_ExecuteAlways(991,0,77)
        SAPT I 0 A_TakeInventory("WeaponCharge",999)
        SAPT I 0 A_TakeInventory("FistFlag",1)
        SAPT I 0 A_PlaySoundEx("weapon/adapterfire", "Weapon")
        SAPT I 10 A_FireCustomMissile("AdaptorFist",1,0,8,0)
        goto FistWait
    FistWait:
        SAPT I 1 A_GiveInventory("AdapterWaitCount",1)
        SAPT I 0 A_JumpIfInventory("AdapterWaitCount",90,"FistFinish")
        SAPT I 0 A_JumpIfInventory("FistFlag",1,"FistFinish")
        loop
	FistFinish:
		SAPT I 0
		SAPT I 0 A_TakeInventory("AdapterWaitCount",999)
		SAPT I 0 A_PlaySoundEx("weapon/adapterreturn", "Voice")
		SAPT I 0 A_TakeInventory("FistFlag",1)
		//SAPT A 0 ACS_ExecuteAlways(998,0,77,1)
		goto Ready3
	NoFlash:
		TNT1 A 0
		stop
	NoAmmo:
		SAPT A 1
		goto Ready
	}
}

actor AdapterWaitCount : Inventory
{
	inventory.amount 1
	inventory.maxamount 100
}

actor AdaptorFist
{
	PROJECTILE
	+SEEKERMISSILE
	+SKYEXPLODE
	+SCREENSEEKER
	Radius 10
	Height 10
	scale 2.5
	damage (36)
	damagetype "SuperAdaptor"
	Obituary "$OB_SUPERADAPTOR"
	speed 50
	reactiontime 15
	States
	{
	Spawn:
		SAPT J 0
		SAPT J 1 A_SeekerMissile (2, 10, SMF_LOOK, 50, 10)
		SAPT J 0 A_SpawnItemEx("FistFX")
		SAPT J 0 A_CountDown
		SAPT J 1 A_SeekerMissile (2, 10, SMF_LOOK, 50, 10)
		SAPT J 0 A_CountDown
		loop
	Death:
		TNT1 A 1 A_CustomMissile("FistReturn",0,0,0,0)
		stop
	}
}

actor FistFX : ExplosionEffect1
{
	States
	{
	Spawn:
		goto Super::Spawn+3
	}
}

actor FistFlag : Once {}

actor FistReturn
{
	PROJECTILE
	+NOINTERACTION
	radius 0
	height 0
	speed 40
	damage 0
	scale 2.5
	states
	{
	Spawn:
		SAPT J 1 A_FaceTarget
		SAPT J 0 A_JumpIfCloser(60,"Return")
		SAPT J 1 A_FaceTarget
		SAPT J 0 A_JumpIfCloser(60,"Return")
		SAPT J 1 A_FaceTarget
		SAPT J 0 A_JumpIfCloser(60,"Return")
		SAPT J 1 A_FaceTarget
		SAPT J 0 A_JumpIfCloser(60,"Return")
		TNT1 A 0 A_CustomMissile("FistReturn",0,0,0,0)
		stop
	Return:
		SAPT J 0 A_GiveToTarget("FistFlag",1)
		stop
	}
}

actor AdaptorFlag : FistFlag {}

actor BoostCount : Inventory
{
	inventory.amount 1
	inventory.maxamount 30
}

actor BoostGive : CustomInventory
{
	inventory.amount 1
	inventory.maxamount 1
	States
	{
	Spawn:
		TNT1 A 0
		stop
	Pickup:
		TNT1 A 0
		TNT1 A 0 A_SpawnItemEx("BoosterFX",-10,-15,12,0,-2,-10,0)
		TNT1 A 0 A_SpawnItemEx("BoosterFX",-10, 15,12,0, 2,-10,0)
		TNT1 A 0 A_Recoil(-2)
		TNT1 A 0 ThrustThingZ(0,30,0,0)
		stop
	}
}

actor BoosterFX : ExplosionEffect1
{
	mass 1
	States
	{
	Spawn:
		TNT1 A 2
		goto Super::Spawn+1
	}
}

actor AdaptorWings : BaseShieldWarper
{
	translation "192:192=4:4", "198:198=42:42"
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 0 ACS_NamedExecuteAlways("core_shieldwarper", 0, 1)
		TNT1 A 0 A_Jump(256, "Shield")
		Goto Shield
	Shield:
		SAPT F 1 A_Warp(AAPTR_TARGET, -12, 0, 18, 0, WARPF_COPYINTERPOLATION|WARPF_NOCHECKPOSITION)
		loop
	}
}



actor Boosting : CustomInventory
{
	+INVENTORY.AUTOACTIVATE
	States
	{
	Use:
		TNT1 A 0
		TNT1 A 0 A_SpawnItemEx("BoostMan")
		TNT1 A 0 A_PlaySoundEx("weapon/superboost","Voice")
		stop
	}
}


actor BoostMan
{
	-SOLID
	+NOGRAVITY
	+MISSILE
	+NOBLOCKMAP
	Height 0
	Radius 0
	scale 2.5
	+NOINTERACTION
	States
	{
	Spawn:
	BoostLoop1:
		TNT1 A 2 A_GiveToTarget("BoostGive",1)
		TNT1 A 0 A_GiveInventory("BoostCount",1)
		TNT1 A 0 A_JumpIfInventory("BoostCount",9,"BoostEnd")
		TNT1 A 0 A_JumpIfInTargetInventory("AdaptorFlag",1,"BoostLoop1")
		stop
	BoostEnd:
		TNT1 A 0 A_TakeInventory("BoostCount",999)
		stop
	Death:
		TNT1 A 0
		stop
	}
}