// Made by Yholl because I was bored and couldn't think of anything else to do.
// Also because I wanted to make a thingy with cool footstep noises.
// ALSO GRADIUS PEW PEW
// Also Mischief Makers ftw
// Also die pls


//MAKE WAY FOR THE KING CRIMERA HAX FUCKER, FOR HE IS ABOUT
//TO UNLEASH SOME SERIOUS SHIT ON THIS MONSTER AGAIN
//what a meggit

actor Cybermancer : Cyberdemon replaces Cyberdemon
{
	+NOFEAR
	+DONTHARMSPECIES
	MinMissileChance 10
	PainThreshold 30
	PainChance 60
	Mass 100000
	Speed 22
	SeeSound ""
	health 13000
	ActiveSound "cyberdemony/idle"
	PainSound "cybermancer/pain"
	DeathSound "cybermancer/death" //"cyberdemony/kablooie"
	Obituary "%o was obliterated by the cybermancer."
  
	var int user_gmotabossexplosiontimer;
	var int user_gmotacyberdemonzap;
	var int user_gmotacyberdemonlasertimer;
	var int user_gmotacyberdemonlaserangle;
	var int user_gmotacyberdemonlaseranger;
	States
	{
	Spawn:
		CYMN A 0
		TNT1 A 0 A_JumpIfInventory("CyberdemonIsAwake", 1, "IdleTaunt")
		CYMN AB 10 A_Look
		TNT1 A 0 a_giveinventory ("HighstunCD",1)
		TNT1 A 0 a_giveinventory ("dontpullme",1)
		Loop
// If Cybermancer has the "CyberdemonIsAwake" item, he's already been woken up,
// so if he's re-entered his spawn state it's usually because he's killed
// something. So let's have him mouth off a bit.
	IdleTaunt:
		CYMN A 0
		TNT1 A 0 A_SetUserVar("user_gmotacyberdemonlaseranger", 0)
		CYMN A 0 A_TakeInventory("CyberdemonIsAwake", 999)
		CYMN A 10
		CYMN E 10 A_PlaySound("cybermancer/taunt", CHAN_VOICE, 1, 0, 0)
		CYMN GEGE 10
		goto Spawn
		
	See:
// This is a hacky way of making him play a specific see sound only once.
// Just to make sure Zandromeda can use it.
		TNT1 A 0 A_JumpIfInventory("CyberdemonIsAwake", 1, "HuntinDownMagets")
		TNT1 A 0 A_GiveInventory("CyberdemonIsAwake", 1)
		TNT1 A 0 A_JumpIfInventory("CyberdemonIsApproachingAtFullThrottleNOREFUGE", 1, "AlreadyActive")
		TNT1 A 0 A_GiveInventory("CyberdemonIsApproachingAtFullThrottleNOREFUGE", 1)
		TNT1 A 0 A_PlaySound("cybermancer/spawn", CHAN_VOICE, 1, 0, 0)
		Goto HuntinDownMagets
	AlreadyActive:
		TNT1 A 0 A_PlaySound("cybermancer/see", CHAN_VOICE, 1, 0,0.5)
		Goto HuntinDownMagets
	HuntinDownMagets:
// This part should be very obvious.
		CYMN DD 4 A_Chase
		TNT1 A 0 a_giveinventory ("HighstunCD",1)
		TNT1 A 0 a_giveinventory ("dontpullme",1)
		TNT1 A 0 A_PlaySound("cyberdemony/step", 7, 1, 0, 0.7)
		TNT1 A 0 A_Quake(2, 6, 0, 512, "")
		CYMN AA 4 A_Chase ("Missile", "Missile", CHF_DONTMOVE)
		TNT1 A 0 A_PlaySound("cyberdemony/startmetalstep", 5, 1, 0, 1.2)
		CYMN BB 4 A_Chase
		TNT1 A 0 A_PlaySound("cyberdemony/metalstep", 5, 1, 0, 0.7)
		TNT1 A 0 A_Quake(2, 6, 0, 512, "")
		CYMN CC 4 A_Chase ("Missile", "Missile", CHF_DONTMOVE)
		Loop
		
	Missile:
// Plays a stepping sound as he moves his legs into the firing position.
// Then he chooses an attack to use.
		TNT1 A 0 A_StopSound(5)
		TNT1 A 0 A_PlaySound("cyberdemony/firingstep", 7, 1, 0, 0.7)
		TNT1 A 0 A_JumpIfCloser(1024, "CloseCombat")
		Goto LongRange
	LongRange:
		TNT1 A 0
		TNT1 A 0 A_Jump(220, "FireMissile") // a fast, long range missile explosive
		Goto ChargeMainLaser // gigantic explosive energy beam
	CloseCombat:
		TNT1 A 0
		TNT1 A 0 A_JumpIfCloser(512, "CloserCombat")
		TNT1 A 0 A_Jump(200, "PulseShots2") // accurate but slow energy blasts
		TNT1 A 0 A_Jump(200, "ChargeScatterLaser") // huge swarm of inaccurate weak energy blasts
		Goto ChargeMainLaser // gigantic explosive energy beam
	CloserCombat:
		TNT1 A 0
		TNT1 A 0 A_Jump(120, "CloseEyeBeam") // low-tracking eye beam that knocks things upwards and speeds up the more in a row it fires
		TNT1 A 0 A_Jump(220, "PulseShots") // inaccurate but slow energy blasts
		TNT1 A 0 A_JumpIfCloser(300, "SpinEyeBeam") // slow chargeup melee attack that will kill you if you are in it
		Goto PulseShots // inaccurate but slow energy blasts
		
	PulseShots:
// Slightly inaccurate pew pew blasts. Far weaker than rockets, but whatever.
		TNT1 A 0 A_SetUserVar("user_gmotacyberdemonlaseranger", 0)
		CYMN E 6 A_FaceTarget
		CYMN F 4 Bright A_CustomMissile("CyberdemonPulseBlastMain", 55, -25, 0)
		CYMN E 2 A_FaceTarget
		CYMN F 4 Bright A_CustomMissile("CyberdemonPulseBlast", 55, -25, frandom(15,0))
		CYMN E 2 A_FaceTarget
		CYMN F 4 Bright A_CustomMissile("CyberdemonPulseBlast", 55, -25, frandom(0,-15))
		CYMN E 2 A_FaceTarget
		CYMN F 4 Bright A_CustomMissile("CyberdemonPulseBlast", 55, -25, frandom(15,0))
		CYMN E 2 A_FaceTarget
		CYMN F 4 Bright A_CustomMissile("CyberdemonPulseBlast", 55, -25, frandom(0,-15))
		CYMN E 12 A_FaceTarget
		TNT1 A 0 A_MonsterRefire (0, "See")
		TNT1 A 0 A_Jump(128, "PulseShots", "PulseShots2")
		Goto See
	PulseShots2:
// accurate pew pew blasts. Far weaker than rockets, but whatever.
		TNT1 A 0 A_SetUserVar("user_gmotacyberdemonlaseranger", 0)
		CYMN E 6 A_FaceTarget
		CYMN F 4 Bright A_CustomMissile("CyberdemonPulseBlastMain", 55, -25, 0)
		CYMN E 2 A_FaceTarget
		CYMN F 4 Bright A_CustomMissile("CyberdemonPulseBlastMain", 55, -25, 0)
		CYMN E 2 A_FaceTarget
		CYMN F 4 Bright A_CustomMissile("CyberdemonPulseBlastMain", 55, -25, 0)
		CYMN E 2 A_FaceTarget
		TNT1 A 0 A_MonsterRefire (0, "See")
		TNT1 A 0 A_Jump(128, "PulseShots", "PulseShots2")
		Goto See
		
	FireMissile:
// You know what Nappa, on second thought, catch it. Catch it with your teeth.
		TNT1 A 0 A_SetUserVar("user_gmotacyberdemonlaseranger", 0)
		TNT1 A 0 a_playsound ("Cybermancer/attack", CHAN_VOICE, 1, 0, 0.3)
		CYMN EEEEEE 6 A_FaceTarget
		CYMN F 12 Bright A_CustomMissile("Cybermancermissile", 53, -23)
		CYMN E 12 A_FaceTarget
		Goto See
		
	ChargeMainLaser:
// Here comes the pain express! All aboard the laser train to hell!
		TNT1 A 0 A_SetUserVar("user_gmotacyberdemonlaseranger", 0)
		TNT1 A 0 A_PlaySound("cyberdemony/chargemainlaser", CHAN_WEAPON, 1, 0, 0.5)
		TNT1 A 0 a_playsound ("Cybermancer/attack", CHAN_VOICE, 1, 0, 0.3)
		CYMN EEEEEE 6 A_FaceTarget
		TNT1 A 0 A_SetUserVar("user_gmotacyberdemonlasertimer", 20)
		TNT1 A 0 A_PlaySound("cyberdemony/mainlaser", CHAN_WEAPON, 1, 0, 0.1)
		TNT1 A 0 A_ChangeFlag("NOPAIN", 1)
		CYMN E 1 Bright A_CustomMissile("CyberdemonMainLaserStart", 55, -25)
		Goto FireMainLaser
	FireMainLaser:
		TNT1 A 0 A_JumpIf (user_gmotacyberdemonlasertimer <= 0, "CeaseLaseringFacesOff")
		TNT1 A 0 A_FaceTarget
		CYMN F 1 Bright A_CustomMissile("CyberdemonMainLaserCore", 55, -25)
		CYMN E 1 A_FaceTarget
		TNT1 A 0 A_SetUserVar("user_gmotacyberdemonlasertimer", user_gmotacyberdemonlasertimer - 1)
		Goto FireMainLaser
		
	ChargeScatterLaser:
// Embrace the wind! Oh wait no that's a dispersal laser don't do that.
		TNT1 A 0 A_SetUserVar("user_gmotacyberdemonlaseranger", 0)
		TNT1 A 0 A_PlaySound("cyberdemony/chargescatterlaser", CHAN_WEAPON, 1, 0, 0.5)
		TNT1 A 0 a_playsound ("Cybermancer/attack", CHAN_VOICE, 1, 0, 0.3)
		CYMN EEEEEE 6 A_FaceTarget
		TNT1 A 0 A_SetUserVar("user_gmotacyberdemonlasertimer", 40)
		TNT1 A 0 A_PlaySound("cyberdemony/scatterlaser", CHAN_WEAPON, 1, 0, 0.1)
		TNT1 A 0 A_ChangeFlag("NOPAIN", 1)
		Goto FireScatterLaser
	FireScatterLaser:
		TNT1 A 0 A_JumpIf (user_gmotacyberdemonlasertimer <= 0, "CeaseLaseringFacesOff")
		TNT1 A 0 A_FaceTarget
		TNT1 A 0 A_Jump (128, 2)
		TNT1 AA 0 A_CustomMissile("CyberdemonScatterBlast", 55, -25, frandom(8,-8))
		CYMN F 1 Bright A_CustomMissile("CyberdemonScatterLaserCore", 55, -25)
		TNT1 A 0 A_Jump (128, 2)
		TNT1 AA 0 A_CustomMissile("CyberdemonScatterBlast", 55, -25, frandom(8,-8))
		CYMN E 1 A_FaceTarget
		TNT1 A 0 A_SetUserVar("user_gmotacyberdemonlasertimer", user_gmotacyberdemonlasertimer - 1)
		Goto FireScatterLaser
	CeaseLaseringFacesOff:
		TNT1 A 0 A_ChangeFlag("NOPAIN", 0)
		CYMN E 12 A_FaceTarget
		Goto See

	CloseEyeBeam:
// Try not to let him stare at you too much, it's bad for your health.
		TNT1 A 0 A_FaceTarget
		CYMN G 1 A_JumpIf (user_gmotacyberdemonlaseranger >= 1, 1)
		CYMN G 1 A_JumpIf (user_gmotacyberdemonlaseranger >= 2, 1)
		CYMN G 1 A_JumpIf (user_gmotacyberdemonlaseranger >= 3, 1)
		CYMN G 1 A_JumpIf (user_gmotacyberdemonlaseranger >= 4, 1)
		CYMN G 1 A_JumpIf (user_gmotacyberdemonlaseranger >= 5, 1)
		CYMN G 1 A_JumpIf (user_gmotacyberdemonlaseranger >= 6, 1)
		CYMN G 1
		TNT1 A 0 A_ChangeFlag("NOPAIN", 1)
		TNT1 A 0 A_SetUserVar("user_gmotacyberdemonlasertimer", 13)
		TNT1 A 0 A_PlaySound("cybermancer/eyebeam", CHAN_WEAPON, 1, 0, 0.8)
		TNT1 A 0 A_JumpIfCloser(100, "CloseEyeBeamFiringAngle8")
		TNT1 A 0 A_JumpIfCloser(150, "CloseEyeBeamFiringAngle7")
		TNT1 A 0 A_JumpIfCloser(200, "CloseEyeBeamFiringAngle6")
		TNT1 A 0 A_JumpIfCloser(250, "CloseEyeBeamFiringAngle5")
		TNT1 A 0 A_JumpIfCloser(300, "CloseEyeBeamFiringAngle4")
		TNT1 A 0 A_JumpIfCloser(350, "CloseEyeBeamFiringAngle3")
		TNT1 A 0 A_JumpIfCloser(400, "CloseEyeBeamFiringAngle2")
		TNT1 A 0 A_JumpIfCloser(450, "CloseEyeBeamFiringAngle1")
		TNT1 A 0 A_SetUserVar("user_gmotacyberdemonlaserangle", -10)
//		TNT1 A 0 A_Log ("range 512")
		Goto CloseEyeBeamFiring
	CloseEyeBeamFiringAngle1:
		TNT1 A 0 A_SetUserVar("user_gmotacyberdemonlaserangle", -15)
//		TNT1 A 0 A_Log ("range 450")
		Goto CloseEyeBeamFiring
	CloseEyeBeamFiringAngle2:
		TNT1 A 0 A_SetUserVar("user_gmotacyberdemonlaserangle", -20)
//		TNT1 A 0 A_Log ("range 400")
		Goto CloseEyeBeamFiring
	CloseEyeBeamFiringAngle3:
		TNT1 A 0 A_SetUserVar("user_gmotacyberdemonlaserangle", -25)
//		TNT1 A 0 A_Log ("range 350")
		Goto CloseEyeBeamFiring
	CloseEyeBeamFiringAngle4:
		TNT1 A 0 A_SetUserVar("user_gmotacyberdemonlaserangle", -32)
//		TNT1 A 0 A_Log ("range 300")
		Goto CloseEyeBeamFiring
	CloseEyeBeamFiringAngle5:
		TNT1 A 0 A_SetUserVar("user_gmotacyberdemonlaserangle", -36)
//		TNT1 A 0 A_Log ("range 250")
		Goto CloseEyeBeamFiring
	CloseEyeBeamFiringAngle6:
		TNT1 A 0 A_SetUserVar("user_gmotacyberdemonlaserangle", -41)
//		TNT1 A 0 A_Log ("range 200")
		Goto CloseEyeBeamFiring
	CloseEyeBeamFiringAngle7:
		TNT1 A 0 A_SetUserVar("user_gmotacyberdemonlaserangle", -46)
//		TNT1 A 0 A_Log ("range 150")
		Goto CloseEyeBeamFiring
	CloseEyeBeamFiringAngle8:
		TNT1 A 0 A_SetUserVar("user_gmotacyberdemonlaserangle", -50)
//		TNT1 A 0 A_Log ("range 100")
		Goto CloseEyeBeamFiring
	CloseEyeBeamFiring:
		TNT1 A 0 A_JumpIf (user_gmotacyberdemonlasertimer <= 0, "EyeBeamFinish")
		CYMN H 1 BRIGHT A_CustomMissile("CybermancerEyeBeam", 104, -3, 0, CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH, user_gmotacyberdemonlaserangle)
		CYMN G 1 A_CustomMissile("CybermancerEyeBeam", 104, -3, 0, CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH, user_gmotacyberdemonlaserangle)
		TNT1 A 0 A_SetUserVar("user_gmotacyberdemonlasertimer", user_gmotacyberdemonlasertimer - 1)
		Goto CloseEyeBeamFiring
	EyeBeamFinish:
		TNT1 A 0 A_CustomMissile("CybermancerEyeBeamFinal", 104, -3, 0, CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH, user_gmotacyberdemonlaserangle)
		TNT1 A 0 A_ChangeFlag("NOPAIN", 0)
		CYMN G 2 A_JumpIf (user_gmotacyberdemonlaseranger >= 1, 1)
		CYMN G 2 A_JumpIf (user_gmotacyberdemonlaseranger >= 2, 1)
		CYMN G 2 A_JumpIf (user_gmotacyberdemonlaseranger >= 3, 1)
		CYMN G 2 A_JumpIf (user_gmotacyberdemonlaseranger >= 4, 1)
		CYMN G 2 A_JumpIf (user_gmotacyberdemonlaseranger >= 5, 1)
		CYMN G 2 A_JumpIf (user_gmotacyberdemonlaseranger >= 6, 1)
		TNT1 A 0 A_SetUserVar("user_gmotacyberdemonlaseranger", user_gmotacyberdemonlaseranger+1)
		CYMN G 1
//		TNT1 A 0 A_Jump(256, "CloseEyeBeam") // Used for testing
		TNT1 A 0 A_JumpIfCloser(320, 2)
		Goto See
		TNT1 A 0 A_Jump(200, "CloseEyeBeam")
		Goto See
		
	SpinEyeBeam:
// You'd best not stick around, y'know?
		TNT1 A 0 A_PlaySound("cybermancer/eyebeamcharge", CHAN_WEAPON, 1, 0, 0.5)
		TNT1 A 0 a_playsound ("Cybermancer/attack", CHAN_VOICE, 1, 0, 0.3)
		TNT1 A 0 A_ChangeFlag("NOPAIN", 1)
		TNT1 A 0 A_Quake(1, 72, 0, 512, "")
		CYMN GGGGGGGGGGGGGGGGGGGGGGGG 3 A_SpawnItemEx ("CybermancerEyeBeamSpinCharge", random(-128,128),random(-128,128),random(0,32), 0,0,random(1,7), 0, SXF_NOCHECKPOSITION) // 72 tics
		TNT1 A 0 A_SetUserVar("user_gmotacyberdemonlasertimer", 13)
		TNT1 A 0 A_PlaySound("cybermancer/eyebeam", CHAN_WEAPON, 1, 0, 0.8)
	SpinEyeBeamFiring:
		TNT1 A 0 A_JumpIf (user_gmotacyberdemonlasertimer <= 0, "SpinEyeBeamFinish")
		CYMN H 1 BRIGHT A_CustomMissile("CybermancerEyeBeamSpin", 104, -3, 0, CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH, -35)
		TNT1 A 0 A_SetAngle (angle+20)
		CYMN G 1 A_CustomMissile("CybermancerEyeBeamSpin", 104, -3, 0, CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH, -35)
		TNT1 A 0 A_SetAngle (angle+20)
		TNT1 A 0 A_SetUserVar("user_gmotacyberdemonlasertimer", user_gmotacyberdemonlasertimer - 1)
		Goto SpinEyeBeamFiring
	SpinEyeBeamFinish:
		TNT1 A 0 A_CustomMissile("CybermancerEyeBeamSpinFinal", 104, -3, 0, CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH, -35)
		TNT1 A 0 A_CustomMissile("CybermancerEyeBeamSpinFinal", 104, -3, 20, CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH, -35)
		TNT1 A 0 A_CustomMissile("CybermancerEyeBeamSpinFinal", 104, -3, 40, CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH, -35)
		TNT1 A 0 A_CustomMissile("CybermancerEyeBeamSpinFinal", 104, -3, 60, CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH, -35)
		TNT1 A 0 A_CustomMissile("CybermancerEyeBeamSpinFinal", 104, -3, 80, CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH, -35)
		TNT1 A 0 A_CustomMissile("CybermancerEyeBeamSpinFinal", 104, -3, 100, CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH, -35)
		TNT1 A 0 A_CustomMissile("CybermancerEyeBeamSpinFinal", 104, -3, 120, CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH, -35)
		TNT1 A 0 A_CustomMissile("CybermancerEyeBeamSpinFinal", 104, -3, 140, CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH, -35)
		TNT1 A 0 A_CustomMissile("CybermancerEyeBeamSpinFinal", 104, -3, 160, CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH, -35)
		TNT1 A 0 A_CustomMissile("CybermancerEyeBeamSpinFinal", 104, -3, 180, CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH, -35)
		TNT1 A 0 A_CustomMissile("CybermancerEyeBeamSpinFinal", 104, -3, 200, CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH, -35)
		TNT1 A 0 A_CustomMissile("CybermancerEyeBeamSpinFinal", 104, -3, 220, CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH, -35)
		TNT1 A 0 A_CustomMissile("CybermancerEyeBeamSpinFinal", 104, -3, 240, CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH, -35)
		TNT1 A 0 A_CustomMissile("CybermancerEyeBeamSpinFinal", 104, -3, 260, CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH, -35)
		TNT1 A 0 A_CustomMissile("CybermancerEyeBeamSpinFinal", 104, -3, 280, CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH, -35)
		TNT1 A 0 A_CustomMissile("CybermancerEyeBeamSpinFinal", 104, -3, 300, CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH, -35)
		TNT1 A 0 A_CustomMissile("CybermancerEyeBeamSpinFinal", 104, -3, 320, CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH, -35)
		TNT1 A 0 A_CustomMissile("CybermancerEyeBeamSpinFinal", 104, -3, 340, CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH, -35)
		TNT1 A 0 A_ChangeFlag("NOPAIN", 0)
		CYMN G 2 A_JumpIf (user_gmotacyberdemonlaseranger >= 1, 1)
		CYMN G 2 A_JumpIf (user_gmotacyberdemonlaseranger >= 2, 1)
		CYMN G 2 A_JumpIf (user_gmotacyberdemonlaseranger >= 3, 1)
		CYMN G 2 A_JumpIf (user_gmotacyberdemonlaseranger >= 4, 1)
		CYMN G 2 A_JumpIf (user_gmotacyberdemonlaseranger >= 5, 1)
		CYMN G 2 A_JumpIf (user_gmotacyberdemonlaseranger >= 6, 1)
		TNT1 A 0 A_SetUserVar("user_gmotacyberdemonlaseranger", user_gmotacyberdemonlaseranger+1)
		TNT1 A 0 A_JumpIfCloser(256, 0)
		Goto See
		TNT1 A 0 A_Jump(128, "CloseEyeBeam")
		Goto See
		
// Weird Laser Eye Attack That Nobody's Satisfied With. Hopefully Something
// Better Emerges In The Future. Why Am I Typing Like This.
/*	FireEyeAttack:
		CYMN G 8 A_FaceTarget
		TNT1 A 0 a_playsound ("Cybermancer/attack", CHAN_VOICE, 1, 0, 0.3)
		CYMN H 0 A_CustomMissile("EyeShot",100,0,8)
		CYMN H 0 A_CustomMissile("EyeShot",100,0,-8)
		CYMN H 8 BRIGHT A_CustomMissile("EyeShot",100)
		CYMN G 8
		Goto See*/
		
	Pain:
		TNT1 A 0 A_StopSound(CHAN_WEAPON)
		TNT1 A 0 A_JumpIf (user_gmotacyberdemonzap > 0, "Zapped")
		TNT1 A 0 ACS_NamedExecuteAlways("GMOTA_BossFlinch", 0)
		CYMN I 10 A_PlaySound("cybermancer/pain",CHAN_VOICE,1.0,0,0.3)
		TNT1 A 0 A_Jump(192, "See")
		TNT1 A 0 A_JumpIfCloser(256, "SpinEyeBeam")
		Goto See
//  Pain.Lightning:
/* Okay sooooooooooooo...
Basically I was trying to make the Cyberdemon short-circuit if hit with lightning
attacks or whatever. Unfortunately Zandybam has crap all railgun support.
If you come up with some cool lightning stuff for this, feel free to reenable the
state and stuff, but I can't be bothered, honestly. Gah.
*/
		TNT1 A 0 A_SetUserVar("user_gmotacyberdemonzap", user_gmotacyberdemonzap + 105)
		TNT1 A 0 A_PlaySound("cyberdemony/electrocuted", 7, 1, 0, 0.8)
	Zapped:
		TNT1 A 0 A_JumpIf (user_gmotacyberdemonzap <= 0, "Pain")
//    TNT1 AA 0 A_CustomRailgun (0, 0, "None", "LightBlue", RGF_SILENT | RGF_FULLBRIGHT, 0, 45, "NoDamagePuff", frandom(0,359), frandom(-90,90), frandom(128,512), 1, 0.2, 0, "None", frandom(40,50))
//    VCYB G 1 Bright A_CustomRailgun (0, 0, "None", "LightBlue", RGF_SILENT | RGF_FULLBRIGHT, 0, 45, "NoDamagePuff", frandom(0,359), frandom(-90,90), frandom(128,512), 1, 0.2, 0, "None", frandom(40,50))
    TNT1 A 0 A_SetUserVar("user_gmotacyberdemonzap", user_gmotacyberdemonzap - 1)
    Goto Zapped
	
	Death:
		CYMN J 0
		CYMN J 0 A_Jump(16, "Death_Silly") // Rare SILLY DEATH
// Supaaa explodo tiem.
		TNT1 A 0 A_NoBlocking
		TNT1 A 0 A_PlaySound("cybermancer/death",CHAN_VOICE,1.0,0,ATTN_NONE)
		TNT1 A 0 A_BossDeath
		TNT1 A 0 A_SetUserVar("user_gmotabossexplosiontimer", 40)
	DeathExplosionLoop:
		TNT1 A 0 A_JumpIf (user_gmotabossexplosiontimer <= 0, "DeathFinish")
		TNT1 A 0 A_Quake(4, 4, 0, 768, "")
		CYMN J 1 Bright
		TNT1 A 0 A_Jump (10, 3)
		TNT1 A 0 A_PlaySound("cyberdemony/blowingup", 7, 1, 0, 0.3)
		TNT1 A 0 A_SpawnItemEx ("MMBossExplosion", frandom(-56,56),frandom(-56,56),frandom(4,90), 0,0,0, 0, SXF_NOCHECKPOSITION)
		TNT1 A 1
		CYMN J 1 Bright
		TNT1 A 1
		TNT1 A 0 A_SetUserVar("user_gmotabossexplosiontimer", user_gmotabossexplosiontimer - 1)
		Goto DeathExplosionLoop
	DeathFinish:
		TNT1 AAAAAAAAAAAA 0 A_SpawnItemEx ("MMBossExplosionSlow", frandom(-56,56),frandom(-56,56),frandom(4,32), 0,0,0, 0, SXF_NOCHECKPOSITION)
		TNT1 AAAAAAAAAAAA 0 A_SpawnItemEx ("MMBossExplosionSlow", frandom(-56,56),frandom(-56,56),frandom(33,64), 0,0,0, 0, SXF_NOCHECKPOSITION)
		TNT1 AAAAAAAAAAAA 0 A_SpawnItemEx ("MMBossExplosionSlow", frandom(-56,56),frandom(-56,56),frandom(65,128), 0,0,0, 0, SXF_NOCHECKPOSITION)
		TNT1 A 0 A_Quake(7, 25, 0, 1024, "")
		CYMN J 6 Bright A_PlaySound("cyberdemony/kablooie",CHAN_AUTO,1.0,0,ATTN_NONE)
		TNT1 A 0 A_FaceTarget
		TNT1 A 0 A_CustomMissile ("CybermancerHand", 32, 16, -90, 2, 150)
		TNT1 A 0 A_CustomMissile ("CybermancerGunArm", 32, -16, 90, 2, 150)
		CYMN KL 6 Bright
		TNT1 A 0 A_Quake(4, 18, 0, 1024, "")
		CYMN M 6 Bright A_NoBlocking
		CYMN M 6
		CYMN M 30
		goto ded
	ded:
		TNT1 A 0
		TNT1 A 0
		CYMN M -1 A_BossDeath
		Stop
// A rare "silly death". It's strange, implementing other people's in-jokes
// without being at ground zero for their creation... It's like being an
// archeologist who finds a cave drawing of a dong.
	Death_Silly:
		CYMN JK 8
		CYMN L 32 A_PlaySound("cybermancer/headhands",CHAN_BODY,1.0,0,ATTN_NONE)
		CYMN L 64 A_PlaySound("cybermancer/sorryimdead",CHAN_VOICE,1.0,0,ATTN_NONE)
		TNT1 A 0 A_FaceTarget
		TNT1 A 0 A_SpawnItem("MMBossExplosionSilly",0,16)
		TNT1 A 0 a_playsound ("treeboom",5)
		TNT1 A 0 Radius_Quake (3,20,0,32,0)
		TNT1 A 0 A_NoBlocking
		TNT1 A 0 A_CustomMissile ("CybermancerHand", 32, 16, -90, 2, 150)
		TNT1 A 0 A_CustomMissile ("CybermancerGunArm", 32, -16, 90, 2, 150)
		CYMN M 6
		CYMN M 30
		goto ded
		
	}
}


//Cybermancer attacks
ACTOR CyberdemonPulseBlast
{
	Radius 10
	Height 8
	Speed 19
	Damage (40)
	Projectile
	+THRUGHOST
	+DONTHARMSPECIES
	Decal "Scorch"
	Species "enemyshot"
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 0 ThrustThingZ (0, random(0,3), random(0,1), 1)
		TNT1 A 0 A_PlaySound("cyberdemony/pulseshot", CHAN_VOICE, 1, 0, 0.7)
		Goto SpawnLoop
	SpawnLoop:
		TNT1 A 0 A_SpawnItemEx ("CyberdemonPulseBlastTrail", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION)
		CYS2 A 1 Bright
		Loop
	Death:
		TNT1 A 0 A_PlaySound("cyberdemony/pulseshothit", CHAN_VOICE, 1, 0, 0.6)
		TNT1 A 0 A_SpawnItemEx ("CyberdemonPulseBlastHit", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION)
		TNT1 A 10
		Stop
	}
}

ACTOR CyberdemonScatterBlast : CyberdemonPulseBlast
{
	Speed 35
	Damage (15)
	Decal ""
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 0 ThrustThingZ (0, random(0,8), random(0,1), 1)
		Goto SpawnLoop
	Death:
		TNT1 A 0 A_PlaySound("cyberdemony/pulseshothit", CHAN_VOICE, 1, 0, 0.6)
		TNT1 A 0 A_SpawnItemEx ("CyberdemonPulseBlastHit", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION)
		TNT1 A 10
		Stop
	}
}

ACTOR CyberdemonPulseBlastMain : CyberdemonPulseBlast
{
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 0 A_PlaySound("cyberdemony/pulseshot", CHAN_VOICE, 1, 0, 0.7)
		Goto SpawnLoop
	}
}

ACTOR CyberdemonPulseBlastTrail
{
	Radius 4
	Height 4
	+NOCLIP
	+NOGRAVITY
	+CLIENTSIDEONLY
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 2
		CYS2 BC 2 Bright
		Stop
	}
}

ACTOR CyberdemonPulseBlastHit
{
	Radius 4
	Height 4
	Scale 3.25
	+NOCLIP
	+NOGRAVITY
	+CLIENTSIDEONLY
	States
	{
	Spawn:
		TNT1 A 0
		CYS3 ABCDE 3 Bright
		Stop
	}
}

ACTOR CyberdemonScatterLaserCore
{
	Radius 4
	Height 4
	Speed 35
	Damage (0)
	RenderStyle Add
	Alpha 0.10
	Scale 4.0
	Projectile
	+THRUACTORS
	+CLIENTSIDEONLY
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 0 A_SpawnItemEx ("CyberdemonScatterLaserCoreTrail", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION)
		CYS1 A 1 Bright
		Loop
	Death:
		TNT1 A 5
		Stop
	}
}

ACTOR CyberdemonScatterLaserCoreTrail
{
	Radius 4
	Height 4
	RenderStyle Add
	Alpha 0.05
	Scale 4.0
	+NOCLIP
	+NOGRAVITY
	+CLIENTSIDEONLY
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 2
		CYS1 ABCDEFGHIJ 1 Bright
		Stop
	}
}

ACTOR CyberdemonMainLaserCore
{
	Radius 16
	Height 12
	Speed 45
	Damage (4)
	RenderStyle Add
	Alpha 0.98
	Scale 3.0
	Projectile
	+RIPPER
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 0 A_SpawnItemEx ("CyberdemonMainLaserCoreTrail", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION)
		CYS1 A 1 Bright
		Loop
	Death:
		TNT1 A 5
		Stop
	}
}

ACTOR CyberdemonMainLaserStart : CyberdemonMainLaserCore
{
	Damage (100)
	Scale 4.0
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 0 A_SpawnItemEx ("CyberdemonMainLaserCoreTrail", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION)
		CYS1 A 1 Bright
		Loop
	Death:
		TNT1 A 0 A_Explode (25,256)
		TNT1 A 0 A_PlaySound("cyberdemony/mainlaserhit", CHAN_VOICE, 1, 0, 0.1)
		TNT1 A 0 A_SpawnItemEx ("CyberdemonMainLaserHit", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION)
		TNT1 A 5
		Stop
	}
}

ACTOR CyberdemonMainLaserCoreTrail
{
	Radius 4
	Height 4
	RenderStyle Add
	Alpha 0.65
	Scale 3.0
	+NOCLIP
	+NOGRAVITY
	+CLIENTSIDEONLY
	States
	{
	Spawn:
		TNT1 A 0
		CYS1 ABCDEFGHIJ 1 Bright
		Stop
	}
}

ACTOR CyberdemonMainLaserHit
{
	Radius 4
	Height 4
	Scale 6.75
	+NOCLIP
	+NOGRAVITY
	+CLIENTSIDEONLY
	States
	{
	Spawn:
		TNT1 A 0
		MMXP ABCDEFGHIJKL 2 Bright
		Stop
	}
}

ACTOR MMBossExplosion
{
	Radius 4
	Height 4
	Scale 1.75
	+NOCLIP
	+NOGRAVITY
	+CLIENTSIDEONLY
	States
	{
	Spawn:
		TNT1 A 0
		MMXP ABCDEFGHIJKL 1 Bright
		Stop
	}
}

// aaaaaaagh the lowercase everything it burns it buuuuuuurns
actor Cybermancermissile : fastprojectile
{
	alpha 1
	height 12
	radius 5
	speed 25
	damage (35)
	scale 2.5
	species "enemyshot"
	+NOTIMEFREEZE
	+FORCEXYBILLBOARD	
	+LOOKALLAROUND
	seesound ""
	deathsound ""
	states
	{
	spawn:
		TNT1 A 0
		TNT1 A 0 A_PlaySound("cyberdemony/missile", CHAN_VOICE, 1, 0, 0.5)
	SpawnLoop:
		TNT1 A 0 A_ScaleVelocity (1.05)
		MGMS A 2 Bright a_spawnitem ("missiletrail")
		MGMS B 2 Bright a_spawnitem ("missiletrail")
		loop
	death:
		TNT1 A 0 A_PlaySound("cyberdemony/missilehit", CHAN_VOICE, 1, 0, 0.3)
		TNT1 A 0 a_explode (50,180,0,0,50)
		TNT1 A 0 Radius_Quake (5,10,0,30,0)
		TNT1 AAAAAAA 0 a_spawndebris ("missiledebris1")
		TNT1 AAAAAAAAAAAA 0 a_spawnitemex ("missiledebris2",random(-16,16),random(-16,16),random(-10,10),random(-100,100)/20.0,random(-100,100)/20.0,random(-100,100)/20.0,0,160)
		MMXP ABCDEFGHIJKL 2 Bright
		stop
	}
}

ACTOR NoDamagePuff : BulletPuff
{
	-ALLOWPARTICLES
	-RANDOMIZE
	+PUFFONACTORS
	+ALWAYSPUFF
	+PUFFGETSOWNER
	+THRUGHOST
	+MTHRUSPECIES
	+BLOODLESSIMPACT
	VSpeed 0
	Mass 5
	Decal ""
	States
	{
	Spawn:
		TNT1 A 1
		Stop
	Melee:
		Stop
	}
}

ACTOR CyberdemonIsApproachingAtFullThrottleNOREFUGE : Inventory{}



// Eye attack junk. Basically, it's a rocket that doesn't hurt as much, but
// flings you up into the air. Kegan's original plan was for the Cybermancer to
// laser the ground at the player's feet, then have the lasered ground explode
// after a delay, but pre-ZScript monster aiming is... inflexible, to say the
// least... points for trying, at least
ACTOR CybermancerEyeBeam
{
	Radius 16
	Height 16
	Speed 40
	Damage (15)
	RenderStyle Add
	Projectile
	scale 0.7
	Obituary "%o gazed into the Cybermancer's eye"
	projectilekickback 3000
//	translation "112:127=192:198", "160:167=192:194", "224:231=192:192", "64:79=192:207", "128:143=192:197"
	States
	{
	Spawn:
		CYS1 JJIIHHGGFFEEDDCCBBAA 1 Bright A_SpawnItemEx("CybermancerEyeBeamTrail", frandom(-0.3,0.3),frandom(-0.3,0.3),frandom(-0.3,0.3), 0,0,0, 0, SXF_NOCHECKPOSITION)
		Stop
	Death:
		TNT1 A 0
		TNT1 A 0 A_Explode (10, 60, 0)
		CYS1 A 3 Bright A_RadiusGive ("CybermancerEyeBeamEffect", 64, RGF_PLAYERS|RGF_MONSTERS, 1)
	DeathLoop:
		TNT1 A 0 A_SetScale (scalex - 0.1)
		CYS1 A 3 Bright A_FadeOut (0.1)
		Loop
	}
}

ACTOR CybermancerEyeBeamSpin : CybermancerEyeBeam
{
	Damage (50)
	scale 1.5
	States
	{
	Spawn:
		CYS1 A 1 Bright A_SpawnItemEx("CybermancerEyeBeamTrail", frandom(-0.3,0.3),frandom(-0.3,0.3),frandom(-0.3,0.3), 0,0,0, 0, SXF_NOCHECKPOSITION)
		Loop
	Death:
		TNT1 A 0
		TNT1 A 0 A_Explode (10, 60, 0)
		CYS1 A 3 Bright A_RadiusGive ("CybermancerEyeBeamEffect", 90, RGF_PLAYERS|RGF_MONSTERS, 1)
	DeathLoop:
		TNT1 A 0 A_SetScale (scalex - 0.1)
		CYS1 A 3 Bright A_FadeOut (0.1)
		Loop
	}
}

ACTOR CybermancerEyeBeamFinal : CybermancerEyeBeam
{
	Speed 40
	Damage (0)
	+THRUACTORS
	States
	{
	Spawn:
		TNT1 A 20
		Stop
	Death:
		TNT1 A 0
		TNT1 A 0 A_PlaySound("cybermancer/eyebeamboom", CHAN_VOICE, 1, 0, 0.3)
		TNT1 A 0 A_SpawnItemEx("CybermancerEyeBeamBoom", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION)
		TNT1 A 0 A_RadiusGive ("CybermancerEyeBeamEffect", 160, RGF_PLAYERS|RGF_MONSTERS, 1)
		Stop
	}
}

ACTOR CybermancerEyeBeamSpinFinal : CybermancerEyeBeamFinal
{
	States
	{
	Death:
		TNT1 A 0
		TNT1 A 0 A_PlaySound("cybermancer/eyebeamboom", CHAN_VOICE, 1, 0, 0.3)
		TNT1 A 0 A_Explode (50, 128, 0)
		TNT1 A 0 A_SpawnItemEx("CybermancerEyeBeamBoom", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION)
		TNT1 A 0 A_RadiusGive ("CybermancerEyeBeamEffect", 160, RGF_PLAYERS|RGF_MONSTERS, 1)
		Stop
	}
}

ACTOR CybermancerEyeBeamTrail
{
	Radius 4
	Height 4
	scale 0.5
	+NOCLIP
	+NOGRAVITY
	+CLIENTSIDEONLY
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 0 A_SetScale(scalex * frandom(0.8,1.2))
		TNT1 A 0 A_Jump (256, 1,2,3,4,5)
		CYS1 A 1 Bright A_FadeOut(0.1)
		Wait
		CYS1 B 1 Bright A_FadeOut(0.1)
		Wait
		CYS1 C 1 Bright A_FadeOut(0.1)
		Wait
		CYS1 D 1 Bright A_FadeOut(0.1)
		Wait
		CYS1 E 1 Bright A_FadeOut(0.1)
		Wait
	}
}

ACTOR CybermancerEyeBeamSpinCharge : CybermancerEyeBeamTrail
{
	scale 1.8
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 0 A_SetScale(scalex * frandom(0.8,1.2))
		TNT1 A 0 A_Jump (256, 1,2,3,4,5)
		CYS3 A 1 Bright A_FadeOut(0.1)
		Wait
		CYS3 B 1 Bright A_FadeOut(0.1)
		Wait
		CYS3 C 1 Bright A_FadeOut(0.1)
		Wait
		CYS3 D 1 Bright A_FadeOut(0.1)
		Wait
		CYS3 E 1 Bright A_FadeOut(0.1)
		Wait
	}
}

actor CybermancerEyeBeamEffect : CustomInventory
{
	states
	{
	Spawn:
		TNT1 A 0
		TNT1 A 1
		stop
	Pickup:
		TNT1 A 0 
		TNT1 A 0 A_CheckFlag ("BOSS", "NoThrust")
		TNT1 A 0 ThrustThingZ(0,45,0,0)
		stop
	NoThrust:
		TNT1 A 0 
		stop
	}
}

ACTOR MMBossExplosionSlow
{
	Radius 4
	Height 4
	Scale 1.75
	+NOCLIP
	+NOGRAVITY
	+CLIENTSIDEONLY
	States
	{
	Spawn:
		TNT1 A 0
		MMXP ABCDEFGHIJKL 4 Bright
		Stop
	}
}

ACTOR MMBossExplosionSilly
{
	Radius 4
	Height 4
	Scale 2
	+NOCLIP
	+NOGRAVITY
	+CLIENTSIDEONLY
	States
	{
	Spawn:
		TNT1 A 0
		RPGX BCDEFGHIJKLMNOPQRSTUV 2 Bright
		Stop
	}
}

ACTOR CybermancerEyeBeamBoom : MMBossExplosionSilly
{
	XScale 0.4
	YScale 0.8
	States
	{
	Spawn:
		TNT1 A 0
		RPGX BCDEFGHIJKLMNOPQRSTUV 1 Bright
		Stop
	}
}

// Gibs for the Death Sequence
actor CybermancerHand
{
    +DOOMBOUNCE
    PROJECTILE
    -NOGRAVITY
    -NOBLOCKMAP
    -NOTELEPORT
    -SOLID
    Radius 3
    Damage 0
    bouncefactor 0.4
    Decal BloodSplat
    SeeSound "gibbage/xpart"
    Speed 12
    States
    {
    Spawn:
        CYHN A 0 
        CYHN A 0 ThrustThingZ (0, 45, 0, 1)
		CYHN A 0 A_Jump(64, "SeeRare")
        goto See 
    See:
        CYHN A 5 A_Custommissile("Blood", -5,0,0)
        CYHN B 5 ThrustThingZ(0,6,1,1)
        CYHN CD 5 
		CYHN E 5 A_Custommissile("Blood", -5,0,0)
        CYHN F 5 ThrustThingZ(0,6,1,1)
        CYHN GH 5 
        loop
    SeeRare: // rude
        CYHN I 5 A_Custommissile("Blood", -5,0,0)
        CYHN J 5 ThrustThingZ(0,6,1,1)
        CYHN KL 5 
		CYHN M 5 A_Custommissile("Blood", -5,0,0)
        CYHN N 5 ThrustThingZ(0,6,1,1)
        CYHN OP 5 
        loop
    Death:
        CYHN A -1 
        Stop
    }
}

actor CybermancerGunArm
{
    +DOOMBOUNCE
    PROJECTILE
    -NOGRAVITY
    -NOBLOCKMAP
    -NOTELEPORT
    -SOLID
    Radius 3
    Damage 0
    bouncefactor 0.4
    Decal BloodSplat
    SeeSound "gibbage/xpart"
    Speed 16
    States
    {
    Spawn:
        CYHN Q 0 
        CYHN Q 0 ThrustThingZ (0, 45, 0, 1)
        goto See 
    See:
        CYHN Q 5 A_Custommissile("Blood", -5,0,0)
        CYHN R 5 ThrustThingZ(0,6,1,1)
        CYHN ST 5 
		CYHN U 5 A_Custommissile("Blood", -5,0,0)
        CYHN V 5 ThrustThingZ(0,6,1,1)
        CYHN WX 5 
        loop
    Death:
        CYHN U -1 
        Stop
    }
}


ACTOR BallsofSteel : CustomInventory
{
	-COUNTITEM
	+INVENTORY.ALWAYSPICKUP
	Inventory.PickupMessage ""
	Inventory.PickupSound ""
	States
	{
	Spawn:
		TNT1 A 1
		Stop
	Pickup:
		TNT1 A 0
		TNT1 A 1 A_ChangeFlag("NOPAIN", 1)
		Stop
	}
}	

Actor Owmyballs : Ballsofsteel
{
	States
	{
	Pickup:
		TNT1 A 0
		TNT1 A 1 A_ChangeFlag("NOPAIN", 0)
		Stop
	}
}	

ACTOR CyberdemonIsAwake : Inventory{}