// BOSSES

///////////
// TERRA //		
///////////

actor VBossFlags : CustomInventory
{
	states
	{
	Pickup:
	TNT1 A 0 A_GiveInventory("CanBeGrabBustered", 1)
	TNT1 A 0 A_GiveInventory("CanBeMegaArmed", 1)
	stop
	}
}

actor TerraBoss
{
//$Category MM8BDM-Bosses
Height 58
Radius 34
Scale 2.5
Obituary "%o was executed by \cdTerra\c-."
Translation "192:192=117:117", "198:198=74:74"
//+INVULNERABLE
Health 1000
mass 99999999
damagefactor "Misc", 0.0
damagefactor "Buster", 1.0

MONSTER
floatspeed 0
-COUNTKILL
-SOLID
-CANPASS
+NOBLOOD
+LOOKALLAROUND
+SLIDESONWALLS
//+NOTARGETSWITCH
+NOPAIN
+NOGRAVITY
-DROPOFF
+BRIGHT
painchance 256
gravity 1.5

var int user_attackcount;
var int user_timeslow;

states
{
Spawn:
TNT1 A 0
TRR2 M 0 A_ChangeVelocity(0,0,-12, CVF_REPLACE)
TRR2 M 3 A_SpawnItemEx("TerraBossIntroFX", -1, 0, 0) 
loop
Talking:
TRR2 NMNMNMNMNMNMNMNMN 4
goto Hover
Hover:
TRR2 M 0 A_SpawnItemEx("TerraSpecialHitbox")
TRR2 M -1 A_SetUserVar("user_attackcount", 2)
stop
Look:
TNT1 A 0 A_GiveInventory("VBossFlags", 1)
TRR2 A 1 A_LookEx(0, 0, 0, 0, 360, "Tele")
loop

DBZ:
TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 1 A_SpawnItemEx("TerraDBZWarper")
TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 1 A_SpawnItemEx("TerraDBZWarper")
TNT1 A 35
TNT1 A -1 ACS_NamedExecuteAlways("TerraPort", 0)
Goto Seek
DBZEnd:
TRR2 M 35 A_FaceTarget
TRR2 Y 8 A_FaceTarget
TRR2 Y 0 A_PlaySoundEx("misc/terraclick", "Voice", 0, 1)
TRR2 Y 0 A_SpawnItemEx("TerraClickFX", 0, -48, 80, 0, -4, 4, 0)
TRR2 L 12 A_FaceTarget
TRR2 L 2 ACS_NamedExecuteAlwayS("TerraDBZFinish", 0)
TRR2 L 35 A_SpawnItemEx("TerraDBZDamager",0,0,0,0,0,0,0,0)
TRR2 I 20 A_ChangeFlag("NOGRAVITY", 0)
Goto Falling

Tele:
TRR2 H 0 A_TakeInventory("CanBeMegaArmed", 99999)
TRR2 H 0 A_GiveInventory("NoRemoteMineLatch", 1)
TRR2 H 0 A_TakeInventory("DeepDiggerAmmo", 99)
TRR2 M 0 A_ChangeFlag("NOPAIN", 1)
TRR2 IJIJ 2 A_FaceTarget
TTRA A 0 A_ChangeFlag("INVULNERABLE", 1)
TTRA A 0 A_ChangeFlag("SHOOTABLE", 0)
TTRA A 0 A_PlaySoundEx("misc/terrateleportout", "Voice")
TTRA I 0 A_SpawnItemEx("TerraBossTeleportFX", 5, 0, 32)
Vanish:
TNT1 A 90
TNT1 A 0 A_JumpIfInventory("MirrorBusterAmmo", 3, "DBZ")
TNT1 A -1 ACS_NamedExecuteAlways("TerraPort", 0)
stop
Seek:
TNT1 A 1 A_LookEx(0, 0, 0, 0, 360, "Reappear")
Reappear:
TRR2 H 0 A_GiveInventory("CanBeMegaArmed", 1)
TRR2 H 0 A_TakeInventory("NoRemoteMineLatch", 1)
TRR2 I 0 A_ChangeFlag("NOGRAVITY", 1)
TNT1 A 0 A_FaceTarget
TTRA A 0 A_PlaySoundEx("misc/terrateleportin", "Voice")
TNT1 A 6 A_SpawnItemEx("TerraBossTeleportFX2", 5, 0, 32)
TTRA A 0 A_ChangeFlag("INVULNERABLE", 0)
TTRA A 0 A_ChangeFlag("SHOOTABLE", 1)
TRR2 A 0 A_JumpIfInventory("MirrorBusterAmmo", 3, "DBZEnd")
TRR2 A 0 A_JumpIfInventory("AtomicFireAmmo", user_attackcount, "Amused")
TRR2 IIII 2 A_FaceTarget
TRR2 I 0 A_ChangeFlag("NOGRAVITY", 0)
Falling:
TRR2 I 0 A_FaceTarget
TRR2 I 1 A_JumpIf(z-floorz == 0, "Land")
loop
Land:
TRRA A 1 A_Stop
TRRA A 0 A_JumpIfInventory("TerraTimeStopped", 1, "Land")
TRRA AAA 3 A_FaceTarget
TRRA A 0 A_JumpIfInventory("AtomicFireAmmo", user_attackcount, "Tele")
Goto Attack
Attack:
TRR2 F 0 A_FaceTarget(0, 0)
TRR2 A 0 A_JumpIfInventory("SparkChaserAmmo", 1, "StunShot")
TRR2 A 0 A_JumpIfInventory("AtomicFireAmmo", user_attackcount + 1, "Tele")
SCHS E 0 A_PlaySoundEx("weapon/sparkchaser","Voice",0,1)
TRRA F 8 A_CustomMissile("TerraSparkChaser", 32, 0, 0)
TRRA A 10 A_GiveInventory("AtomicFireAmmo", 1)
TRR2 A 0 A_FaceTarget
TRR2 A 0 A_JumpIfInventory("AtomicFireAmmo", user_attackcount, "Tele")
TRR2 A 0 A_Jump(256, "Leap")
loop
Leap:
TRR2 I 15 A_ChangeVelocity(random(0, 10 - (user_timeslow / 5)), random(-20 + user_timeslow, 20 - user_timeslow), 20, CVF_RELATIVE|CVF_REPLACE)
TRR2 A 0 A_Jump(128, "AirAttack")
Goto Falling
AirAttack:
TRR2 A 0 A_JumpIfInventory("AtomicFireAmmo", user_attackcount, "Falling")
TRR2 F 0 A_FaceTarget(0, 0)
SCHS E 0 A_PlaySoundEx("weapon/sparkchaser","Voice")
TRR2 F 0 A_ChangeFlag("NOGRAVITY", 1)
TRR2 F 0 A_Stop
TRR2 A 0 A_GiveInventory("AtomicFireAmmo", 1)
TRR2 K 15 A_CustomMissile("TerraSparkChaser", 32, 0, 0)
TRR2 F 0 A_ChangeFlag("NOGRAVITY", 0)
Goto Falling
Pain:
TRR2 M 0 A_Jump(56, "Avoid")
Amused:
TRR2 M 0 A_GiveInventory("TerraBossWeakness", 1)
TRR2 M 0 A_ChangeFlag("NOPAIN", 0)
TRR2 M 15 A_GiveInventory("SparkChaserammo", 1)
TRRA A 0 A_JumpIfInventory("TerraTimeStopped", 1, "Amused")
TRR2 M 0 A_JumpIfInventory("SparkChaserammo", 10, "AmuseEnd")
TRR2 M 1 A_JumpIf(CallACS("TerraDodgeCheck"), "Avoid")
loop
Avoid:
TRR2 H 0 A_TakeInventory("CanBeMegaArmed", 1)
TRRA A 0 A_JumpIfInventory("TerraTimeStopped", 1, "Amused")
TRR2 M 0 A_ChangeFlag("NOPAIN", 1)
TRR2 M 0 A_FaceTarget
TRR2 M 0 A_Jump(128, "AvoidLeft")
AvoidRight:
TRR2 M 0 A_ChangeVelocity(0, 30 - (user_timeslow * 2), frandom(0, 5), CVF_REPLACE|CVF_RELATIVE)  
Goto Avoiding
AvoidLeft:
TRR2 M 0 A_ChangeVelocity(0, -30 + (user_timeslow * 2), frandom(0, 5), CVF_REPLACE|CVF_RELATIVE)  
Avoiding:
TRR2 M 0 A_FaceTarget
TRR2 M 3 A_SpawnItemEx("TerraBossIntroFX", -1, 0, 0) 
TRR2 M 0 A_FaceTarget
TRR2 M 3 A_SpawnItemEx("TerraBossIntroFX", -1, 0, 0) 
TRR2 M 0 A_FaceTarget
TRR2 M 3 A_SpawnItemEx("TerraBossIntroFX", -1, 0, 0) 
TRR2 M 0 A_FaceTarget
TRR2 M 3 A_SpawnItemEx("TerraBossIntroFX", -1, 0, 0) 
TRR2 M 0 A_FaceTarget
TRR2 M 3 A_SpawnItemEx("TerraBossIntroFX", -1, 0, 0) 
TRR2 H 0 A_GiveInventory("CanBeMegaArmed", 1)
TRR2 M 0 A_ChangeFlag("NOPAIN", 0)
TRR2 M 8 A_Stop
goto Amused
Pain.DeepDigger:
TRR2 H 0 A_PlaySoundEx("misc/criticalhit", "Voice", 0, 1)
TRR2 H 0 A_FaceTarget
TRR2 H 0 A_ChangeVelocity(-25, random(-22, 22), 5, CVF_REPLACE|CVF_RELATIVE)
TRRA H 10 A_GiveInventory("DeepDiggerAmmo", 1)
TRR2 I 0 A_JumpIfInventory("DeepDiggerAmmo", 2, "NotAmused")
TRR2 H 0 A_FaceTarget
TRR2 I 35 A_Stop
Goto AmuseEnd
NotAmused:
TRR2 M 0 A_ChangeFlag("NOPAIN", 1)
TRR2 H 0 A_FaceTarget
TRR2 I 10 A_Stop
AmuseEnd:
TRR2 M 0 A_TakeInventory("TerraBossWeakness", 999)
TRR2 M 0 A_TakeInventory("AtomicFireAmmo", 999)
TRR2 M 0 A_GiveInventory("MirrorBusterAmmo", 1)
Goto Tele

StunShot:
TRR2 I 0 A_Jump(28, "StunShotAir")
StunShotGround:
TRR2 I 0 A_PlaySoundEx("misc/terrastunshot", "Voice", 0, 1)
TRR2 IJIJIJI 2 A_FaceTarget
TRR2 K 25 A_SpawnItemEx("TerraSparkStunner", 20, 0, 48)
TRRA A 10
Goto StunLeap
StunShotAir:
TRR2 I 0 A_JumpIf(z>0, "StunShotGround")
TRR2 I 3 A_ChangeVelocity(0, 0, 20, CVF_RELATIVE|CVF_REPLACE)
TRR2 I 0 A_Stop
TRR2 I 0 A_ChangeFlag("NOGRAVITY", 1)
TRR2 I 0 A_PlaySoundEx("misc/terrastunshot", "Voice", 0, 1)
TRR2 IJIJIJI 2 A_FaceTarget
TRR2 K 25 A_SpawnItemEx("TerraSparkStunner", 20, 0, 48)
goto StunFall
StunFall:
TRR2 I 0 A_ChangeFlag("NOGRAVITY", 0)
TRR2 I 0 A_FaceTarget
TRR2 I 1 A_JumpIf(z-floorz == 0, "StunLeap")
loop
StunLeap:
TRRA AAAAA 5 A_FaceTarget
TRRA A 0 A_JumpIfInventory("TerraTimeStopped", 1, "StunLeap")
TRR2 A 0 A_TakeInventory("SparkChaserammo", 999)
Goto Leap

Death:
TRR2 A 0 A_FaceTarget
TRE2 A 0 A_GiveInventory("SkullBarrierAmmo", 1)
TRR2 A -1 A_SpawnItemEx("TerraDeath", 0, 0, 0, -20, 0, 0)
stop
}

damagefactor "ChargeBuster", 1.0
damagefactor "ArrowBuster", 1.0
damagefactor "BassBuster", 1.0
damagefactor "DuoFist1", 1.0
damagefactor "DuoFist2", 1.0
damagefactor "DuoFist3", 1.0
damagefactor "LaserBuster", 1.0
damagefactor "MegaArm", 1.3
damagefactor "Buster", 1.0
damagefactor "ProtoBuster", 1.0
damagefactor "ProtoBuster2", 1.0
damagefactor "ProtoBuster3", 1.0
damagefactor "SuperAdaptor", 1.0
damagefactor "TrebleBoost", 1.0

damagefactor "FireStorm", 1.0
damagefactor "FireSpin", 1.0
damagefactor "HyperBomb", 0.5
damagefactor "IceSlasher", 0.25
damagefactor "OilSlider", 1.0
damagefactor "OilFlame", 1.0
damagefactor "RollingCutter", 0.6
damagefactor "SuperArm", 1.0
damagefactor "ThunderBeam", 1.0
damagefactor "TimeSlow", 1.0

damagefactor "AirShooter", 1.0
damagefactor "AtomicFire1", 1.0
damagefactor "AtomicFire2", 1.0
damagefactor "AtomicFire3", 0.5
damagefactor "BubbleLead", 1.0
damagefactor "CrashBomb", 1.0
damagefactor "LeafShield", 1.0
damagefactor "MetalBlade", 0.8
damagefactor "Instagib", 1.0
damagefactor "QuickBoomerang", 0.8
damagefactor "TimeStopper", 1.0

damagefactor "GeminiLaser", 1.0
damagefactor "HardKnuckle", 1.0
damagefactor "MagnetMissile", 1.0
damagefactor "NeedleCannon", 1.0
damagefactor "SearchSnake", 1.0
damagefactor "ShadowBlade", 0.3
damagefactor "SparkShock", 1.0
damagefactor "TopSpin", 1.0

damagefactor "DiveMissile", 0.8
damagefactor "DrillBomb", 1.0
damagefactor "DustCrusher", 1.0
damagefactor "DustCrusherBit", 1.0
damagefactor "FlashStopper", 1.0
damagefactor "PharaohShot1", 1.0
damagefactor "PharaohShot2", 1.0
damagefactor "PharaohShot3", 1.0
damagefactor "PharaohShotHold", 1.0
damagefactor "RainFlush", 1.0
damagefactor "RingBoomerang", 1.0

damagefactor "ChargeKick", 1.0
damagefactor "CrystalEye", 1.0
damagefactor "CrystalEyeBit", 1.0
damagefactor "GravityHold", 1.0
damagefactor "GyroAttack", 1.0
damagefactor "NapalmBomb", 1.0
damagefactor "PowerStone", 1.0
damagefactor "StarCrash", 1.0
damagefactor "WaterWave", 1.0

damagefactor "BlizzardAttack", 1.0
damagefactor "CentaurFlash", 1.0
damagefactor "FlameBlast", 1.0
damagefactor "KnightCrush", 1.0
damagefactor "PlantBarrier", 1.0
damagefactor "SilverTomahawk", 1.0
damagefactor "WindStorm", 0.7
damagefactor "YamatoSpear", 0.5

damagefactor "DangerWrap", 1.0
damagefactor "FreezeCracker", 1.0
damagefactor "FreezeCrackerBit", 1.0
damagefactor "JunkShield", 1.0
damagefactor "NoiseCrush1", 1.0
damagefactor "NoiseCrush2", 1.0
damagefactor "ScorchWheel", 1.0
damagefactor "SlashClaw", 1.0
damagefactor "ThunderBolt", 1.0
damagefactor "WildCoil", 1.0
damagefactor "WildCoil2", 1.0

damagefactor "AstroCrush", 1.0
damagefactor "FlameSword", 0.8
damagefactor "FlameSwordSpark", 1.0
damagefactor "FlashBomb", 0.2
damagefactor "HomingSniper", 1.0
damagefactor "IceWave", 1.0
damagefactor "MegaBall", 1.0
damagefactor "ThunderClaw", 0.4
damagefactor "ThunderClawPegHelp", 0.0
damagefactor "TornadoHold", 1.0
damagefactor "WaterBalloon", 1.0

damagefactor "BlackHoleBomb", 1.0
damagefactor "ConcreteShot", 1.0
damagefactor "HornetChaser", 1.0
damagefactor "JewelSatellite", 1.0
damagefactor "LaserTrident", 0.5
damagefactor "MagmaBazooka1", 1.0
damagefactor "MagmaBazooka2", 1.0
damagefactor "PlugBall", 1.0
damagefactor "TornadoBlow", 1.0

damagefactor "CopyVision", 1.0
damagefactor "IceWall", 0.1
damagefactor "LightningBolt", 0.2
damagefactor "MagicCard", 0.7
damagefactor "RemoteMine", 0.4
damagefactor "SpreadDrill", 0.1
damagefactor "SpreadDrill2", 0.5
damagefactor "SpreadDrill3", 1.0
damagefactor "TenguBlade", 0.8
damagefactor "WaveBurner", 1.0

damagefactor "ChillShot", 1.0
damagefactor "ChillSpike", 1.0
damagefactor "CommandoBomb", 0.5
damagefactor "ReboundStriker", 1.0
damagefactor "SolarBlaze", 1.0
damagefactor "ThunderWool", 0.5
damagefactor "TripleBlade", 1.0
damagefactor "WaterShield", 1.0
damagefactor "WheelCutter", 1.0

damagefactor "BlackHole", 1.0
damagefactor "BreakDash", 1.0
damagefactor "BubbleBomb", 1.0
damagefactor "DeepDigger", 1.8
damagefactor "ElectricShock", 1.0
damagefactor "GrabBuster", 1.0
damagefactor "PhotonMissile", 1.0
damagefactor "SaltWater", 1.0
damagefactor "SparkChaser", 1.0

damagefactor "BalladeCracker", 1.0
damagefactor "MirrorBuster1", 1.0
damagefactor "MirrorBuster2", 1.0
damagefactor "MirrorBuster3", 1.0
damagefactor "Sakugarne", 1.0
damagefactor "ScrewCrusher", 1.0

damagefactor "WireAdaptor", 1.0
damagefactor "Beat", 1.0
damagefactor "EddieBomber", 1.0
damagefactor "Reggae", 1.0
damagefactor "Tango", 1.0
}

actor TerraClickFX
{
PROJECTILE
+NOINTERACTION
+BRIGHT
scale 2.5
states
{
Spawn:
TRR2 XWV 3
stop
}
}



actor TerraSpecialHitBox
{
Health 100
+SHOOTABLE
+NOGRAVITY
radius 32
height 32
-SOLID
+MISSILE
painchance 256
//+NOTARGETSWITCH
Damagefactor "Misc", 0.0
renderstyle none
+NODAMAGE
+THRUACTORS
states
{
Spawn:
PLAY A 0
PLAY A 0 A_ChangeFlag("MISSILE", 0)
PLAY A 0 A_JumpIfInTargetInventory("BossHealth2", 1, "Death")
PLAY A 1 A_GivetoTarget("BossHealth2", 1)
Warping:
PLAY A 0 A_JumpIfInTargetInventory("BossHealth2", 2, "Death")
PLAY A 1 A_Warp(AAPTR_TARGET, 0, 0, 0, 0, WARPF_COPYINTERPOLATION)
loop
Pain.TimeSlow:
//PLAY A 0 A_CheckFlag("INVULNERABLE", "Warping", AAPTR_TARGET)
PLAY A 0 A_CheckFlag("INVULNERABLE", "Warping", AAPTR_TARGET)
PLAY A 1 ACS_NamedExecute("BossTimeSlow", 0, 0)
TimeSlowed:
PLAY A 0 A_Warp(AAPTR_TARGET, 0, 0, 0, 0, WARPF_COPYINTERPOLATION)
PLAY A 0 A_CheckFlag("INVULNERABLE", 2, AAPTR_TARGET)
PLAY A 3 A_SpawnItemEx("TimeSlowGFX", random(16, 48), 0, Random(16,48), 0, 0, 0, random(0, 359))
PLAY A 1
PLAY A 0 A_JumpIfInTargetInventory("TimeSlowAmmo", 1, "TimeSlowed")
Goto Warping
Pain.TimeStopper:
PLAY A 0 A_CheckFlag("INVULNERABLE", "Warping", AAPTR_TARGET)
PLAY A 0 A_ChangeFlag("INVULNERABLE", 1)
PLAY A 0 A_GiveToTarget("TerraTimeStopped", 1)
TimeStopped:
PLAY A 1 A_Warp(AAPTR_TARGET, 0, 0, 0, 0, WARPF_COPYINTERPOLATION)
PLAY A 0 A_SpawnItemEx("TimeStopGFX", random(8, 64), 0, random(0, 74), 0, 0, 0, random(0, 359))
PLAY A 0 A_JumpIfInTargetInventory("TerraTimeStopped", 1, "TimeStopped")
PLAY A 0 A_ChangeFlag("INVULNERABLE", 0)
Goto Warping
Death:
PLAY A 0
stop
}
}

actor TerraTimeStopped : Powerup
{
powerup.duration -4
}

actor TerraDBZDamager
{
PROJECTILE
renderstyle none
+NOINTERACTION
+DONTREFLECT
+DONTBLAST
reactiontime 22
Damagetype "Misc"
health 999
states
{
Spawn:
PLAY A 0
PLAY A 0 ACS_NamedExecuteAlways("TerraDBZDamager", 0)
Chase:
PLAY A 0 A_Explode(2, 32, 0, 0, 2)
PLAY A 0 A_Countdown
PLAY A 1
loop
}
}

actor TerraDBZWarper
{
scale 2.5
PROJECTILE
+NOINTERACTION
height 0
radius 3
+BRIGHT
+SEEKERMISSILE
Speed 35
states
{
Spawn:
TRR2 A 0 
TRR2 A 0 ACS_NamedExecuteAlwayS("TerraDBZWarper", 0)
Appear:
TNT1 A 0 ACS_NamedExecute("TerraDBZSound", 0)
TNT1 A 1
TRR2 QRSTUVWX 2
Warping:
SCHS CCBB 1 A_JumpIfInventory("CutterFlag", 1, "Shoot")
loop
Empty:
TNT1 A -1
stop

Shoot:
TNT1 AAAA 1 A_LookEx(0, 0, 0, 0, 360, "See")
stop
See:
SCHS B 0 A_JumpIfInTargetInventory("IsDead", 1, "Empty")
TNT1 A 0 A_FaceTarget(0,0)
TNT1 A 1 A_CustomMissile("TerraDBZProjectile",0,0,0,2,pitch)
stop
}
}


actor TerraDBZProjectile
{
+BRIGHT
scale 2.5
PROJECTILE
Speed 30
States
{
Spawn:
	SCHS D 0 
	SCHS D 8 A_SpawnItemEx("TerraDBZProjectile", 0, 0, 0, velx, vely, velz, 0, SXF_ABSOLUTEVELOCITY)
	stop
}
}


actor TerraDeath
{
+BRIGHT
scale 2.5
Translation "192:192=117:117", "198:198=74:74"
-SOLID
states
{
Spawn:
TRRA H 12
Dying:
TRRA H 1 A_Jumpif(z==floorz, "Death")
loop
Death:
TRR2 H 0 A_Stop
TRR2 H 0 Thing_ChangeTID(0, 1130)
TRR2 G -1
stop
Talking:
TRR2 HGHGHGHGHGHGHGH 4
Goto Death+1
}
}


actor TerraBossWeakness : PowerProtection
{
damagefactor "DeepDigger", 2.5
}

actor TerraBossTeleportFX
{
-SOLID
+NOINTERACTION
+NOGRAVITY
+BRIGHT
scale 2.5
states
{
Spawn:
TRR2 QRSTUVWX 2
stop
}
}

actor TerraBossTeleportFX2 : TerraBossTeleportFX
{
states
{
Spawn:
TRR2 XWVUTSRQ 2
stop
}
}

actor TerraBossIntroFX
{
-SOLID
+NOINTERACTION
+NOGRAVITY
scale 2.5
renderstyle stencil
stencilcolor "Green"
+BRIGHT
states
{
Spawn:
TRR2 M 5 A_FadeOut(0.2)
loop
}
}


actor TerraSparkStunner
{
-SOLID
+NOINTERACTION
+NOGRAVITY
renderstyle none
var int user_spd;
states
{
Spawn:
TNT1 A 0
TNT1 A 0 A_GiveInventory("CutterFlag", 1)
TNT1 A 1 ACS_NamedExecute("TerraChaser", 0, 1)
See:
TNT1 A 0 A_SpawnItemEx("TerraSparkStunnerWarper")
Chase:
TNT1 A 0 A_FaceTracer
SCHS C 0 A_JumpIf(user_spd > 52, 2)
TNT1 A 0 A_SetUserVar("user_spd", user_spd+1)
PLAY A 1 A_ChangeVelocity(0.50 * user_spd, 0, 0, CVF_REPLACE|CVF_RELATIVE)
loop
Leave:
TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 2 A_ChangeVelocity(0.01 * user_spd, 0, 0, CVF_REPLACE|CVF_RELATIVE)
stop
}
}

actor TerraSparkStunnerWarper
{
+MISSILE
-SOLID
+NOINTERACTION
var int user_spd;
renderstyle none
states
{
Spawn:
SCHS C 0
SCHS C 1 A_RearrangePointers(AAPTR_NULL, AAPTR_TARGET)
Goto Chase
Chase:
SCHS C 0 A_JumpIf(user_spd > 54, 2)
SCHS C 0 A_SetuserVar("user_spd", user_spd + 1)
SCHS C 0 A_SpawnItemEx("TerraSparkStunnerFX1", 16 + (user_spd * 1), 0, 0, 0, 0, 0, 0)
SCHS C 0 A_SpawnItemEx("TerraSparkStunnerFX1", 16 + (user_spd * 1), 0, 0, 0, 0, 0, 120)
SCHS C 0 A_SpawnItemEx("TerraSparkStunnerFX1", 16 + (user_spd * 1), 0, 0, 0, 0, 0, 240)
SCHS C 0 A_SetAngle(angle + 12)
SCHS C 1 A_Warp(AAPTR_MASTER, 0, 0, 0, 0, WARPF_USECALLERANGLE|WARPF_NOCHECKPOSITION|WARPF_COPYINTERPOLATION)
SCHS C 0 A_JumpIfInventory("CutterFlag", 1, "Chase", AAPTR_MASTER)
Death:
TNT1 A 0
stop
}
}

actor TerraSparkStunnerFX1
{
-SOLID
scale 2.75
+MISSILE
+BRIGHT
+FORCEXYBILLBOARD
+NOINTERACTION
translation "96:139=205:205", "193:199=206:206"
states
{
Spawn:
SCHS C 2 bright
stop
}
}

actor TerraSparkChaser
{
PROJECTILE
+SEEKERMISSILE
+FORCEXYBILLBOARD
+RIPPER
+NOINTERACTION
Radius 4
Height 4
scale 2.5
damage (5)
speed 43
//Obituary "$OB_SPARKCHASER"
damagetype "Misc"
+BRIGHT
var int user_waittime;
States
{
Spawn:
	SCHS D 0 
	SCHS D 0 A_SetUservar("user_waittime", 4)
	SCHS D 0 ACS_NamedExecuteAlways("TerraChaser")
	//SCHS D 0 ACS_NamedExecuteAlways("core_targetyawpitch", 0, 0) // Set the starting pitch
	Seek:
	SCHS D 0 A_SeekerMissile(0, 90, 0)
	SCHS D 0 A_SpawnItemEx("TerraSparkDamager")
	SCHS D 1 A_SpawnItemEx("TerraSparkChaserTrail", 0, 0, 0)
	SCHS D 0 A_JumpIfTracerCloser(180, "SeekEnd")
	SCHS D 0 A_CheckFlag("CANTSEEK", "CountDown", AAPTR_TRACER)
	loop
	CountDown:
	SCHS D 0 A_JumpIfInventory("BossHealth8", 28, "SeekEnd")
	SCHS D 0 A_GiveInventory("BossHealth8", 1)
	goto Seek
	SeekEnd:
	SCHS D 0 A_TakeInventory("BossHealth8", 999)
	SCHS D 0 ACS_NamedExecuteAlways("core_targetyawpitch", 0, 0)
	SCHS D 0 A_GiveInventory("CutterFlag", 1)
	SCHS D 0 A_SpawnItemEx("TerraSparkDamager")
	SCHS D 1 A_SpawnItemEx("TerraSparkChaserTrail", 0, 0, 0)
	SCHS D 0 A_JumpIfInventory("CutterFlag", 10, "Pause")
	SCHS D 0 A_JumpIf(z<16, "EndZVel")
	loop
	EndZVel:
	SCHS D 0 A_ChangeVelocity(velx, vely, 0, CVF_REPLACE)
	goto SeekEnd
	Pause: 
	SCHS B 0 A_JumpIfInventory("AtomicFireAmmo", 3, "Death")
	SCHS B 0 A_PlaySoundEx("weapon/sparkchaserchase", "Voice")
	Paused:
	SCHS C 0 A_Stop
	SCHS CCBB 2 A_SpawnItemEx("TerraSparkChaserHoldFX", 0, 0, 0, 4, 0, random(-4, 4), random(0,360))
	SCHS D 0 A_GiveInventory("BotSightCounter", 1)
	SCHS D 0 A_JumpIfInventory("BotSightCounter", user_waittime*2, "ReSeek")
	loop
	ReSeek:
	SCHS B 0 A_JumpIfInTargetInventory("SkullBarrierAmmo", 1, "Death")
	SCHS E 0 A_FaceTracer
	SCHS E 0 A_PlaySoundEx("weapon/sparkchaser", "Voice", 0, 1)
	SCHS D 0 A_GiveInventory("AtomicFireAmmo", 1)
	SCHS D 0 A_TakeInventory("CutterFlag", 9999)
	SCHS D 0 A_TakeInventory("BotSightCounter", 9999)
	SCHS D 0 A_Recoil(-44)
	Goto Seek
	Death:
	SCHS CB 2
	stop
}
}

actor TerraSparkChaserHoldFX
{
PROJECTILE
+NOINTERACTION
+BRIGHT
states
{
Spawn:
TNT1 A 1
TRR2 WXV 2
stop
}
}

actor TerraStunPowerup : PowerSpeed
{
speed 0.0
powerup.colormap 1.0, 1.0, 1.0, 0.0, 0.0, 1.0
powerup.duration -100
}

actor TerraSparkChaserTrail : SparkChaserTrail
{
+BRIGHT
+MISSILE
-NOINTERACTION
Damage (0)
damagetype "Misc"
}

actor TerraSparkDamager
{
+MISSILE
Damage (8)
damagetype "Misc"
radius 16
height 5
states
{
Spawn:
TNT1 A 1
stop
}
}

actor TerraShipBreak
{
scale 2.5
PROJECTILE
+NOINTERACTION
states
{
Spawn:
ASEX ABCDEF 2
stop
}
}

actor TerraProp
{
Scale 2.5
Translation "192:192=117:117", "198:198=74:74"
states
{
Spawn:
TRRA A -1
stop 
ShipBreak:
TRR2 M 0 A_ChangeFlag("NOGRAVITY", 1)
TRR2 MMMMMMMMMMMMMMMMMMMMMMM 1 A_SpawnItemEx("TerraShipBreak", 184, random(-56, 56), random(-32, 32), 40)
Goto Hover
Hover:
TRR2 M -1 A_Stop
loop
Grab:
TRR2 E -1
stop
GrabTalk:
TRR2 FEFEFEFEFEFEFEF 4
Goto Grab
Throw:
TRR2 B 12 A_Recoil(12)
Goto Hover
}
}

actor WilyStarAttack
{
scale 1.5
+MISSILE
+NOINTERACTION
reactiontime 60
states
{
Spawn:
MMFX DCBDCBDCBDCBDCBDCBDCBDCBDCBDCBDCBDCBDCBDCB 2
MMFX D 0 A_PlaySoundEx("weapon/blackholeexplode", "Voice", 0, 1)
Big:
MMFX B 0 A_CountDown
MMFX B 1 A_SetScale(scalex + 2.1, scaley + 2.1)
loop
Death:
TNT1 A -1 ACS_NamedExecute("WilyStarBeam", 0)
stop
}
}

actor WilyStarAttackRockSpawner
{
states
{
Spawn:
TNT1 AAAAA 0 A_SpawnItemEx("WilyStarAttackRock", random(0, 32), 0, random(0, 48), 0, 0, 0, random(0,360))
TNT1 AAA 0 A_SpawnItemEx("WilyStarAttackRock", random(0, 16), 0, random(48, 64), 0, 0, 0, random(0,360))
TNT1 A 8
Rocks:
TNT1 A 2 A_SpawnItemEx("WilyStarAttackRock", random(0, 64), 0, 0, 0, 0, 0, random(0,360))
loop
}
}

actor WilyStarAttackRock
{
+NOINTERACTION
scale 2.5
translation "0:255=0:0"
states
{
Spawn:
TNT1 A 0
CNBR F 0 A_Jump(256, "Rock1", "Rock2", "Rock3", "Rock4") 
Rock1:
CNBR F 1 A_ChangeVelocity(0, 0, 0.5, CVF_RELATIVE) 
loop
Rock2:
CNBR G 1 A_ChangeVelocity(0, 0, 0.8, CVF_RELATIVE) 
loop
Rock3:
CNBR H 1 A_ChangeVelocity(0, 0, 0.8, CVF_RELATIVE) 
loop
Rock4:
CNBR I 1 A_ChangeVelocity(0, 0, 1.0, CVF_RELATIVE) 
loop
}
}