actor BeatSupport : BaseMM8BDMUseItem 11105
{
//$Category MM8BDM-Assists
//$Title Beat Support
//$Sprite WEA4O0
//Inventory.RespawnTics 300
inventory.amount 1
inventory.maxamount 1
inventory.pickupmessage "$PU_BEATSUPPORT"
Tag "$TAG_BEATSUPPORT"
inventory.icon "BEATI"
Inventory.PickupSound "item/1up"
scale 2.0
+COUNTITEM
+INVBAR
+NOBLOOD
states
{
SpawnLoop:
WEA4 O -1
loop
Use:
WEAP B 0 A_JumpIfInventory("BeatSupportActivated", 1, "Failed")
WEAP B 0 A_PlaySoundEx("item/refill","Voice")
WEAP B 0 A_SpawnItemEx("BeatSupportChecker")
WEAP B 0 A_SpawnItemEx("BeatSupportWarper")
WEAP B 0 ACS_ExecuteAlways(300,0,0)
stop
Failed:
WEAP B 0
fail
}
}

actor BeatSupportChecker
{
+MISSILE
+NOINTERACTION
+DONTBLAST
Reactiontime 984
states
{
Spawn:
TNT1 A 0 A_Countdown
TNT1 A 1 A_JumpIfInTargetInventory("IsDead", 1, "Death")
TNT1 A 0 A_JumpIfInTargetInventory("BeatSupportFired",1,"Skip")
TNT1 A 0 A_JumpIfInTargetInventory("BeatSupportRefresh",1,"Skip")
TNT1 A 0 A_GiveToTarget("BeatSupportRefresher",1)
loop
Skip:
TNT1 A 0
goto Spawn
Death:
TNT1 A 0 A_TakeFromTarget("BeatSupportActivated")
TNT1 A 0 A_TakeFromTarget("BeatSupportFired")
TNT1 A 0 A_TakeFromTarget("BeatSupportRefresh")
stop
}
}

actor BeatSupportWarper
{
	Scale 2.5
	Height 0
	Radius 0
	+NOINTERACTION
	+CLIENTSIDEONLY
	-SOLID
	+NOGRAVITY
	+MISSILE
	+DONTBLAST
	States
	{
	Spawn:
		TNT1 A 1
		Goto SpawnA
	SpawnA:
		BEAT A 0 A_JumpIfInTargetInventory("BeatSupportFired", 1, "Firing")
		BEAT AA 1 A_Warp(AAPTR_TARGET, -32, -32, 52, 0, WARPF_COPYINTERPOLATION|WARPF_NOCHECKPOSITION)
		BEAT A 0 A_JumpIfInTargetInventory("BeatSupportActivated", 1, "SpawnB")
		BEAT A 1 A_JumpIf(true, "Death")
		wait
	SpawnB:
		BEAT A 0 A_JumpIfInTargetInventory("BeatSupportFired", 1, "Firing")
		BEAT BB 1 A_Warp(AAPTR_TARGET, -32, -32, 52, 0, WARPF_COPYINTERPOLATION|WARPF_NOCHECKPOSITION)
		BEAT A 0 A_JumpIfInTargetInventory("BeatSupportActivated", 1, "SpawnC")
		BEAT B 1 A_JumpIf(true, "Death")
		wait
	SpawnC:
		BEAT A 0 A_JumpIfInTargetInventory("BeatSupportFired", 1, "Firing")
		BEAT CC 1 A_Warp(AAPTR_TARGET, -32, -32, 52, 0, WARPF_COPYINTERPOLATION|WARPF_NOCHECKPOSITION)
		BEAT A 0 A_JumpIfInTargetInventory("BeatSupportActivated", 1, "SpawnA")
		BEAT C 1 A_JumpIf(true, "Death")
		wait
	Firing:
		TNT1 A 35
		TNT1 A 1 A_Warp(AAPTR_TARGET, -32 - 48 + 48, -32 + 32, 52 - 32, 0, WARPF_COPYINTERPOLATION|WARPF_NOCHECKPOSITION)
		BEAT A 1 A_Warp(AAPTR_TARGET, -32 - 40 + 64, -32 + 48, 52 - 28, 0, WARPF_COPYINTERPOLATION|WARPF_NOCHECKPOSITION)
		BEAT B 1 A_Warp(AAPTR_TARGET, -32 - 32 + 48, -32 + 64, 52 - 24, 0, WARPF_COPYINTERPOLATION|WARPF_NOCHECKPOSITION)
		BEAT B 1 A_Warp(AAPTR_TARGET, -32 - 24 + 32, -32 + 48, 52 - 20, 0, WARPF_COPYINTERPOLATION|WARPF_NOCHECKPOSITION)
		BEAT C 1 A_Warp(AAPTR_TARGET, -32 - 16 + 16, -32 + 32, 52 - 16, 0, WARPF_COPYINTERPOLATION|WARPF_NOCHECKPOSITION)
		BEAT C 1 A_Warp(AAPTR_TARGET, -32 - 8 + 0, -32 + 16, 52 - 12, 0, WARPF_COPYINTERPOLATION|WARPF_NOCHECKPOSITION)
		BEAT A 1 A_Warp(AAPTR_TARGET, -32 - 0 - 16, -32 + 0, 52 - 10, 0, WARPF_COPYINTERPOLATION|WARPF_NOCHECKPOSITION)
		BEAT A 1 A_Warp(AAPTR_TARGET, -32 - 0 - 32, -32 - 16, 52 - 6, 0, WARPF_COPYINTERPOLATION|WARPF_NOCHECKPOSITION)
		BEAT B 1 A_Warp(AAPTR_TARGET, -32 - 0 - 16, -32 - 32, 52 - 4, 0, WARPF_COPYINTERPOLATION|WARPF_NOCHECKPOSITION)
		BEAT B 1 A_Warp(AAPTR_TARGET, -32 - 0 - 0, -32 - 16, 52 - 0, 0, WARPF_COPYINTERPOLATION|WARPF_NOCHECKPOSITION)
		Goto SpawnA
	Death:
		TNT1 A 0
		stop
	}
}
/*
actor BeatSupportGFX1
{
+NOINTERACTION
Scale 2.5
states
{
spawn:
BEAT A 4
stop
}
}

actor BeatSupportGFX2 : BeatSupportGFX1
{
states
{
spawn:
BEAT B 4
stop
}
}

actor BeatSupportGFX3 : BeatSupportGFX1
{
states
{
spawn:
BEAT C 4
stop
}
}
*/
actor BeatSupportActivated : Once {}

actor BeatSupportFired : Powerup 
{
powerup.duration 45
}


actor BeatSupportRefresh : Once {}

actor BeatSupportRefresher : CustomInventory
{
states
{
Pickup:
TNT1 A 0 A_GiveInventory("BeatSupportRefresh",1)
WEAP B 0 A_PlaySound("item/beat")
stop
}
}

actor BeatSupportFire : CustomInventory
{
states
{
Pickup:
WEAP B 0 A_FireCustomMissile("BeatSupportProjectile",0,0,8,0)
WEAP B 0 A_GiveInventory("BeatSupportFired",1)
stop
}
}

actor BeatSupportProjectile
{
PROJECTILE
Radius 16
Height 16
scale 2.5
damage (24)
Obituary "$OB_BEATSUPPORT"
//+RIPPER
+THRUGHOST
+SKYEXPLODE
damagetype "Beat"
speed 44
States
{
Spawn:
BEAT ABCABCABCABC 2 A_SpawnItemEx("BeatSupportTrailFX")
goto Death
Death:
BEAT A 0 A_CustomMissile("BeatSupportReturn",0,0,0,0)
stop
}
}

actor BeatSupportTrailFX
{
scale 2.5
+NOINTERACTION
+NOGRAVITY
-SOLID
height 0
radius 0
renderstyle stencil
stencilcolor "Cyan"
states
{
Spawn:
TNT1 A 0
TNT1 A 1 A_Jump(256,1,2,3)
Spawn1:
BEAT A 2 A_FadeOut(0.15)
loop
Spawn2:
BEAT B 2 A_FadeOut(0.15)
loop
Spawn3:
BEAT C 2 A_FadeOut(0.15)
loop
}
}

actor BeatSupportReturn
{
PROJECTILE
Radius 5
Height 5
scale 2.5
damage (0)
+RIPPER
+NOINTERACTION
+DONTBLAST
+SKYEXPLODE
speed 50
States
{
Spawn:
BEAT AABBCC 1 A_JumpIfCloser(64,"Returned")
BEAT A 0 A_CustomMissile("BeatSupportReturn",0,0,0,0)
stop
Death:
XDeath:
Returned:
BEAT A 0 //A_TakeFromTarget("BeatSupportFired",1)
stop
}
}