ACTOR TheCyberdemon: Cyberdemon Replaces Cyberdemon
{
    Health 5000
	PainSound "CYBPAIN"
    Scale 1.2
	Radius 40
	Height 108
	+MISSILEMORE
	+MISSILEEVENMORE
    +DONTRIP
    +NORADIUSDMG
	+QUICKTORETALIATE
	+DONTHARMSPECIES
	+DONTHARMCLASS
	+NOICEDEATH
	Damagefactor "Avoid", 0.0	Damagefactor "BHFTOnBarrel", 0.0	Damagefactor "Blood", 0.0
	Damagefactor "CancelTeleportFog", 0.0	Damagefactor "CauseWaterSplash", 0.0	DamageFactor "Crush", 10.0
	Damagefactor "GibRemoving", 0.0	Damagefactor "HangingHook", 0.0
	Damagefactor "Head", 1.0	Damagefactor "PussyGrab", 0.0	Damagefactor "Repair", 0.0
	Damagefactor "RevenantHitStomach", 0.0	Damagefactor "SpawnMarine", 0.0	Damagefactor "Stealth", 0.0
	Damagefactor "TeleportRemover", 0.0	Damagefactor "Use", 0.0	Damagefactor "ExtremePunches", 2.5
	Damagefactor "Fatality", 2.5	Damagefactor "HeadKick", 0.5	Damagefactor "HelperMarineFatallity", 2.5
	Damagefactor "Kick", 0.5	Damagefactor "Slide", 0.5
	Damagefactor "Melee", 0.5	Damagefactor "MonsterKnocked", 0.5	Damagefactor "Stomp", 0.5
	Damagefactor "Trample", 0.5	Damagefactor "Slide", 0.5
	Damagefactor "Burn", 0.5	Damagefactor "Fire", 0.5	Damagefactor "Flames", 0.5
	Damagefactor "GreenFire", 0.5	Damagefactor "HumanBBQ", 0.5	DamageFactor "TankWeakSpot", 0.0

	PainChance "Head", 16	PainChance "Taunt", 255	PainChance "Extremepunches", 4
	PainChance "Fatality", 4	PainChance "HelperMarineFatallity", 4	PainChance "Kick", 4
	PainChance "LowKick", 4	PainChance "Melee", 4	PainChance "MonsterKnocked", 4
	PainChance "Slide", 4	PainChance "Trample", 4
	PainChance "Burn", 4	PainChance "Fire", 4	PainChance "Flames", 4
	PainChance "GreenFire", 4	PainChance "HumanBBQ", 4
	MeleeRange 128
	Speed 11
	FastSpeed 16
	painchance 20
	mass 5000
	DropItem "64UnmakerUpgradeSpawner", 16
    BloodType "Brutal_Blood", "SawBlood", "SawBlood"
	Tag "Cyberdemon"
	Species "Cyberdemon"
	States
	{
    Spawn:
		CYBR C 1
		TNT1 A 0 A_GiveInventory("TargetIsACyberdemon")
		TNT1 A 0 ACS_NamedExecuteAlways("BDCHeckClassicMonsters", 0, 0, 0, 0)//Check if Vanilla Mode is activated
		CYBR A 2
		TNT1 A 0 A_JumpIf(x == -1472, "ReplaceForBOSS")
		TNT1 A 0 A_SpawnItem("CybersHitBox", 0, 96)
		Goto Stand

    ReplaceVanilla:
		TNT1 A 0 A_ChangeFlag("COUNTKILL", 0)
		TNT1 A 2 A_ChangeFlag("NOINTERACTION", 1)
		TNT1 A 0 A_SpawnItemEx ("VanillaCyberdemon",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION | SXF_TRANSFERAMBUSHFLAG,0,tid)
		TNT1 A 2 ACS_NamedExecuteAlways("Tag666VCyberdemon", 0, 0, 0, 0)//E4M6
		TNT1 A -1
		Stop

	ReplaceForBOSS:
		TNT1 A 0
		TNT1 A 0 A_JumpIf(y == 576, 1)
		Goto Stand
		TNT1 A 0 ACS_NamedExecuteAlways("MapEnhancementE2M8")
		TNT1 A 0 A_ChangeFlag("COUNTKILL", 0)
		TNT1 A 2 A_ChangeFlag("NOINTERACTION", 1)
		TNT1 A 0 A_SpawnItemEx ("CyberdemonBoss",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION | SXF_TRANSFERAMBUSHFLAG,0,tid)
		TNT1 A 2 ACS_NamedExecuteAlways("Tag666BCyberdemon", 0, 0, 0, 0)//E4M6
		TNT1 A -1
		Stop

	Special666:
		TNT1 A 0
		TNT1 A 2 A_Die("Vanish")
	Death.Vanish:
		TNT1 A 140
		TNT1 A -1 A_BossDeath
		Stop

	Stand:
	Idle:
		TNT1 A 0 A_SpawnItem("CybersHitBox", 0, 96)
        CYBR C 10 A_Look
		TNT1 A 0 A_SpawnItem("CybersHitBox", 0, 96)
		CYBR C 10 A_Look
        Loop

	See:
		TNT1 A 0 A_SpawnItem("CybersHitBox", 0, 96)
		CYBR A 2 A_Hoof
		CYBR AAA 2 A_Chase
		TNT1 A 0 A_SpawnItemEx("HeavyFootSteps",0,20)
		TNT1 A 0 A_JumpIfCloser(128, "Stomp")
		TNT1 A 0 A_SpawnItem("CybersHitBox", 0, 96)
		CYBR BBBB 2 A_Chase
		TNT1 A 0 A_JumpIfCloser(128, "Stomp")
		TNT1 A 0 A_SpawnItem("CybersHitBox", 0, 96)
        CYBR C 2 A_Metal
		CYBR CCC 2 A_Chase
		TNT1 A 0 A_SpawnItemEx("HeavyFootSteps",0,-20)
		TNT1 A 0 A_JumpIfCloser(128, "Stomp")
		TNT1 A 0 A_SpawnItem("CybersHitBox", 0, 96)
		CYBR DDDD 2 A_Chase
		Loop

	Missile:
		TNT1 A 0 A_JumpIfInventory("Enraged", 1, "SpecialAttack")
		TNT1 A 0 A_SpawnItem("CybersHitBox", 0, 96)
		CYBR E 12 A_FaceTarget
		TNT1 A 0 A_CustomMissile("Alerter", 60,-25)
		TNT1 A 0 A_SpawnItem("CybersHitBox", 0, 96)
		CYBR F 4 A_CustomMissile("CyberBalls",60,-25,0,0)

		TNT1 A 0 A_SpawnItem("CybersHitBox", 0, 96)
		CYBR E 12 A_FaceTarget
		TNT1 A 0 A_CustomMissile("Alerter", 60,-25,-7)
		TNT1 A 0 A_SpawnItem("CybersHitBox", 0, 96)
		CYBR F 4 A_CustomMissile("CyberBalls",60,-25,-7,0)

		TNT1 A 0 A_SpawnItem("CybersHitBox", 0, 96)
		CYBR E 12 A_FaceTarget
		TNT1 A 0 A_CustomMissile("Alerter", 60,-25,7)
		TNT1 A 0 A_SpawnItem("CybersHitBox", 0, 96)
		CYBR F 4 A_CustomMissile("CyberBalls",60,-25,7,0)

		TNT1 A 0 A_SpawnItem("CybersHitBox", 0, 96)
		CYBR E 12 A_FaceTarget
		TNT1 A 0 A_CustomMissile("Alerter", 60,-25)
		TNT1 A 0 A_SpawnItem("CybersHitBox", 0, 96)
		CYBR F 4 A_CustomMissile("CyberBalls",60,-25,0,0)

		TNT1 A 0 A_SpawnItem("CybersHitBox", 0, 96)
		CYBR E 12 A_FaceTarget
		Goto See

	Stomp:
	Melee:
		TNT1 A 0
		TNT1 A 0 A_JumpIfInTargetInventory("IsInATank", 1, "SpecialAttack")
		TNT1 A 0 A_JumpIfInTargetInventory("TargetIsACyberdemon", 1, "ForgetTarget")
		TNT1 A 0 A_SpawnItem("CybersHitBox", 0, 96)
		CYMA A 7 A_FaceTarget
		TNT1 A 0 A_SpawnItem("CybersHitBox", 0, 96)
	    CYMA A 7 A_FaceTarget
		TNT1 A 0 A_SpawnItem("CybersHitBox", 0, 96)
		TNT1 A 0 A_CustomMissile("CyberStomp",10,0,0,0)
		TNT1 A 0 A_Recoil(-5)
	    CYMA B 7
		TNT1 A 0 A_SpawnItem("CybersHitBox", 0, 96)
		CYMA B 7
		Goto See

	SpecialAttack:
		TNT1 A 0 A_SpawnItem("CybersHitBox", 0, 96)
		CYBR E 8 A_FaceTarget
		TNT1 A 0 A_CustomMissile("Alerter", 60,-25)
		TNT1 A 0 A_SpawnItem("CybersHitBox", 0, 96)
		CYBR F 4 A_CustomMissile("CyberBalls",60,-25,0,0)

		TNT1 A 0 A_SpawnItem("CybersHitBox", 0, 96)
		CYBR E 8 A_FaceTarget
		TNT1 A 0 A_CustomMissile("Alerter", 60,-25,-7)
		TNT1 A 0 A_SpawnItem("CybersHitBox", 0, 96)
		CYBR F 4 A_CustomMissile("CyberBalls",60,-25,-7,0)

		TNT1 A 0 A_SpawnItem("CybersHitBox", 0, 96)
		CYBR E 8 A_FaceTarget
		TNT1 A 0 A_CustomMissile("Alerter", 60,-25,7)
		TNT1 A 0 A_SpawnItem("CybersHitBox", 0, 96)
		CYBR F 4 A_CustomMissile("CyberBalls",60,-25,7,0)

		TNT1 A 0 A_SpawnItem("CybersHitBox", 0, 96)
		CYBR E 8 A_FaceTarget
		TNT1 A 0 A_CustomMissile("Alerter", 60,-25)
		TNT1 A 0 A_SpawnItem("CybersHitBox", 0, 96)
		CYBR F 4 A_CustomMissile("CyberBalls",60,-25,0,0)

		TNT1 A 0 A_SpawnItem("CybersHitBox", 0, 96)
		CYBR E 8 A_FaceTarget
		TNT1 A 0 A_CustomMissile("Alerter", 60,-25,-7)
		TNT1 A 0 A_SpawnItem("CybersHitBox", 0, 96)
		CYBR F 4 A_CustomMissile("CyberBalls",60,-25,-7,0)

		CYBR E 8 A_FaceTarget
		TNT1 A 0 A_CustomMissile("Alerter", 60,-25,7)
		TNT1 A 0 A_SpawnItem("CybersHitBox", 0, 96)
		CYBR F 4 A_CustomMissile("CyberBalls",60,-25,7,0)
		Goto See

	ForgetTarget:
		TNT1 A 0
		TNT1 A 0 A_ClearTarget
		Goto Idle

	Pain:
		TNT1 A 0 A_SpawnItem("CybersHitBox", 0, 96)
		CYBR G 8 A_Pain
		Goto See

	Death:
		CYBR H 0
		CYBR H 0 A_Scream
		CYBR H 10
		CYBR I 4
		CYBR J 4
		TNT1 AAAAAA 0 A_CustomMissile ("HighExplosiveFlames2", random (40, 90), 0, random (0, 360), 2, random (0, 360))
		CYBR J 4
		EXPL A 0 Radius_Quake (4, 35, 0, 10, 0)
		TNT1 A 0 A_CustomMissile("ExplosionSplashSpawner")
        TNT1 AA 0 A_SpawnItemEx ("DetectFloorCrater",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
	    TNT1 A 0 A_CustomMissile ("XDeathCyberdemonHead", 91, 0, random (0, 360), 2, random (0, 180))
		TNT1 A 0 A_CustomMissile ("XDeathCyberdemonArm", 91, 0, random (0, 360), 2, random (0, 180))
		TNT1 A 0 A_CustomMissile ("XDeathCyberdemonGun", 91, 0, random (0, 360), 2, random (0, 180))
		TNT1 A 0 A_CustomMissile ("XDeathCyberdemonPiece", 91, 0, random (0, 360), 2, random (0, 180))
		TNT1 A 0 A_CustomMissile ("XDeathCyberdemonTorso", 91, 0, random (0, 360), 2, random (0, 180))
		TNT1 AAA 0 A_CustomMissile ("BDExplosionparticles3", 74, 0, random (0, 360), 2, random (40, 90))
		TNT1 AAA 0 A_CustomMissile ("BDExplosionparticles4", 76, 0, random (0, 360), 2, random (40, 90))
		TNT1 AA 0 A_CustomMissile ("ExplosionSpawner", 40, 0, random (0, 360), 2, random (10, 90))
		EXPL AA 0 A_CustomMissile ("BigBlackSmokeLarger", 40, 0, random (0, 360), 2, random (10, 90))
        TNT1 A 0 A_CustomMissile ("CyberXDeath", 64, 0, random (0, 360), 2, random (0, 160))
		CYBR M 5 A_NoBlocking
		CYBR NOP 5
		CYBR P 105
		CYBR P -1 A_BossDeath
		Stop
	Death.Head:
		TNT1 A 0
		CYBR I 0 A_Fall
		TNT1 A 0 A_JumpIfInTargetInventory("HasCutingWeapon", 1, "Death.Decaptate")
		TNT1 AAA 0 A_CustomMissile ("Brains6Big", 91, 0, random (0, 360), 2, random (0, 160))
		TNT1 AAA 0 A_CustomMissile ("Brains7Big", 210, 0, random (0, 360), 2, random (0, 160))
		TNT1 AAAAA 0 A_CustomMissile ("XDeath3b", 91, 0, random (0, 360), 2, random (50, 90))
		TNT1 AAAAA 0 A_CustomMissile ("XDeath2b", 91, 0, random (0, 360), 2, random (50, 90))
		TNT1 AA 0 A_CustomMissile ("MeatDeath", 91, 0, random (0, 360), 2, random (50, 90))
		CYBB AAAA 6 A_SpawnItem("MuchBlood3", 0, 120)
		CYBB ABCABCB 8 A_SpawnItem("MuchBlood", 0, 120)
		EXPL A 0 Radius_Quake (4, 35, 0, 10, 0)
        TNT1 AAAA 0 A_CustomMissile ("ExplosionSpawner", 64, 0, random (0, 360), 2, random (0, 180))
        TNT1 AAAAAA 0 A_CustomMissile ("ExplosionSpawner", 64, 0, random (0, 360), 2, random (0, 180))
        TNT1 AAAA 0 A_CustomMissile ("UltraGoreSPawner", 64, 0, random (0, 360), 2, random (0, 180))
        TNT1 AAAAAA 0 A_CustomMissile ("UltraGoreSpawner", 64, 0, random (0, 360), 2, random (0, 180))
        TNT1 A 0 A_CustomMissile ("CyberXDeath", 91, 0, random (0, 360), 2, random (0, 160))
		CYBR JKL 0
		CYBR M 0 A_NoBlocking
		CYBR NOP 0
		CYBR P 105
		CYBR P -1 A_BossDeath
		Stop

	Death.Decaptate:
		CYBR I 0 A_Fall
	    TNT1 A 0 A_CustomMissile ("XDeathCyberdemonHead", 91, 0, random (0, 360), 2, random (0, 180))
		TNT1 AAAAAAAAA 0 A_CustomMissile ("XDeath1", 91, 0, random (0, 360), 2, random (0, 180))
		CYBB AAAA 0 A_SpawnItem("MuchBlood3", 0, 120)
		CYBB ABCABCB 8 A_SpawnItem("MuchBlood", 0, 120)
		EXPL A 0 Radius_Quake (4, 35, 0, 10, 0)
        TNT1 AAAA 0 A_CustomMissile ("ExplosionSpawner", 64, 0, random (0, 360), 2, random (0, 180))
        TNT1 AAAAAA 0 A_CustomMissile ("ExplosionSpawner", 64, 0, random (0, 360), 2, random (0, 180))
        TNT1 AAAA 0 A_CustomMissile ("UltraGoreSPawner", 64, 0, random (0, 360), 2, random (0, 180))
        TNT1 AAAAAA 0 A_CustomMissile ("UltraGoreSpawner", 64, 0, random (0, 360), 2, random (0, 180))
        TNT1 A 0 A_CustomMissile ("CyberXDeath", 91, 0, random (0, 360), 2, random (0, 160))
		CYBR JKL 0
		CYBR M 0 A_NoBlocking
		CYBR NOP 0
		CYBR P 105
		CYBR P -1 A_BossDeath
		Stop

	Pain.Taunt:
		TNT1 A 0
		TNT1 A 0 A_JumpIfInventory("Enraged", 1, "SpecialAttack")
		TNT1 A 0 A_ChangeFlag("FASTER", 1)
		TNT1 A 0 A_ChangeFlag("MISSILEMORE", 1)
		TNT1 A 0 A_ChangeFlag("MISSILEEVENMORE", 1)
		TNT1 A 0 A_ChangeFlag("NOPAIN", 1)
		SPOS B 0 A_Pain
		TNT1 A 0 HealThing(2)
		TNT1 A 0 A_PlaySound("demon/pain")
		CYBT A 1 A_FaceTarget
		CYBT ABCCBADE 4
		TNT1 A 0 A_PlaySound("CYBTAT", 1)
		CYBT FGHGFGHGFGHGFGHG 3
		CYBT EDA 4
		TNT1 A 0 A_GiveInventory("Enraged", 1)
		Goto Missile

	Pain.Killme:
		Goto Missile

	Death.Fatality:
	    TNT1 A 0
		TNT1 A 0 A_Pain
        TNT1 A 0 A_NoBlocking
		TNT1 A 0 A_JumpIfIntargetInventory("IsPlayer", 1, 1)
		Goto Death
		TNT1 A 0
		TNT1 A 0 A_FaceTarget
		TNT1 AAAAA 0 A_SpawnItemEx("HealthCrueltyBonus", 0, 0, 47, frandom (-2.5, 2.5), frandom (-2.5, 2.5), 5)
		TNT1 AAAAA 0 A_SpawnItemEx("ArmorCrueltyBonus", 0, 0, 47, frandom (-2.5, 2.5), frandom (-2.5, 2.5), 5)
		TNT1 A 0 A_GiveToTarget("GoFatality", 1)
		TNT1 A 0 A_GiveToTarget("CyberdemonFatality", 1)
		TNT1 A 105
		TNT1 A -1 A_BossDeath
        Stop
	}
}

ACTOR CyberdemonLegsFatality 17003
{
  Health 200
  Radius 16
  Height 56
  Mass 500
  Speed 12
  PainChance 0
  +BOSS
  +FLOORCLIP
  +DONTMORPH
  +BOSSDEATH
  +SOLID
  +SHOOTABLE
  +THRUACTORS
   DeathSound "world/barrelx"
  Tag "Cyberdemon's roaming legs"
  States
  {
  Spawn:
    PATA AABBCCDD 3 A_Wander
	TNT1 A 0 A_ChangeFlag("THRUACTORS", 0)
  See:
    PATA AABBCCDD 3 A_Wander
	PATA AABBCCDD 3 A_Wander
	PATA AABBCCDD 3 A_Wander
	PATA A 0 A_Die
  Death:
    PATA H 10
	TNT1 AA 0 A_SpawnItem("MeatDeath", 0, 32)
	TNT1 AA 0 A_SpawnItem("RipGuts", 0, 32)
	TNT1 A 0 A_SpawnItem("MuchBlood2", 0, 42)
    PATA IJKL 3
    PATA M 3 A_NoBlocking
    PATA NO 3
    PATA P 3
    PATA P -1
    Stop
  }
}

ACTOR CyberStomp
{
	Radius 12
	Height 8
	+MISSILE
	Speed 25
    Damage(random(106,106))
	renderstyle translucent
	alpha 0.9
	DamageType "Stomp"
    Gravity 1.0
    Decal "Cracks"
    -NOGRAVITY
    +EXTREMEDEATH
	+NOTELEPORT
	+DONTHARMSPECIES
	Obituary "%o was stepped on by a Cyberdemon."
	HitObituary "%o was stepped on by a Cyberdemon."
	Species "Cyberdemon"
	States
	{
	Spawn:
		TNT1 A 1
		TNT1 A 0 ThrustThingZ(0, -35, 0, 0)
		TNT1 A 10
		Stop
	Death:
		TNT1 A 0
        TNT1 A 0 A_PlaySound("CLAP", 1)
		TNT1 A 0 A_CustomMissile("ExplosionSplashSpawner")
		TNT1 A 0 Radius_Quake(2, 35, 0, 5, 0)
		TNT1 A 0 A_Explode
		TNT1 A 1
		Stop
	}
}

ACTOR CyberStompBig: Cyberstomp
{
	States
	{
	Spawn:
		TNT1 A 1
		TNT1 A 0 ThrustThingZ(0, -35, 0, 0)
		TNT1 A 10
		Stop
	Death:
		TNT1 A 0
        TNT1 A 0 A_PlaySound("CLAP", 1)
		TNT1 A 0 A_CustomMissile("ExplosionSplashSpawner")
		TNT1 A 0 Radius_Quake(4, 35, 0, 10, 0)
		TNT1 A 0 A_Explode(256,256)
		TNT1 A 1
		Stop
	}
}