//===========================================================================
//
// Spider boss
//
//===========================================================================
ACTOR TheSpiderMastermind Replaces SpiderMastermind
{
	+NOICEDEATH
	Game Doom
	SpawnID 7
	Health 4000
	Radius 128
	Height 100
    Scale 1.1
	Mass 6000
	Speed 8
	FastSpeed 12
	PainChance 30

	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 "TankWeakSpot", 0.0
	Damagefactor "Burn", 0.5	Damagefactor "Fire", 0.5	Damagefactor "Flames", 0.5
	Damagefactor "GreenFire", 0.5	Damagefactor "HumanBBQ", 0.5

	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

	Monster
	DeathHeight 0
	BurnHeight 0
	+BOSS
	+FLOORCLIP
    +DONTRIP
	+DONTMORPH
	+BOSSDEATH
    +NORADIUSDMG
	+MISSILEMORE
	+MISSILEEVENMORE
	+DONTHARMCLASS
	+DONTHARMSPECIES
	Bloodtype "MastermindBlood"
	DropItem "64UnmakerUpgradeSpawner", 16
	SeeSound "spider/sight"
	AttackSound "spider/attack"
	PainSound "SPIPAIN1"
	DeathSound "spider/death"
	ActiveSound "spider/active"
	obituary "$OB_SPIDER"
	Tag "Spiderdemon Mastermind"
	Species "SpiderMastermind"
	States
	{
    Spawn:
		SPID A 1
		TNT1 A 0 A_GiveInventory("TargetIsAMastermind")
		TNT1 A 0 ACS_NamedExecuteAlways("BDCheckStuff")//Check if new monsters are disabled
		TNT1 A 0 ACS_NamedExecuteAlways("BDCHeckClassicMonsters", 0, 0, 0, 0)//Check if Vanilla Mode is activated
		SPID A 2
		TNT1 A 0 A_JumpIfInventory("nonewenemies", 1, "Stand")
		TNT1 A 0 A_JumpIf(x == 1600, "ReplaceForBOSS")
		TNT1 A 0 A_JumpIf(x == -2720, "ReplaceForMotherdemonE4")
		TNT1 A 0 A_JumpIf(x == 2216, "ReplaceForSigil2")
		TNT1 A 0 A_Jump(2, "ReplaceMotherdemon")
		TNT1 A 0 A_Jump(4, "ReplaceJuggernaut")
		Goto Stand

	ReplaceVanilla:
		TNT1 A 0 A_ChangeFlag("COUNTKILL", 0)
		TNT1 A 2 A_ChangeFlag("NOINTERACTION", 1)
		TNT1 A 0 A_SpawnItemEx ("VanillaSpiderMastermind",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION | SXF_TRANSFERAMBUSHFLAG,0,tid)
		TNT1 A 2 ACS_NamedExecuteAlways("Tag666VMastermind", 0, 0, 0, 0)//E3M8
		TNT1 A -1
		Stop

	ReplaceForBOSS:
		TNT1 A 0
		TNT1 A 0 A_JumpIf(y == -768, 1)
		Goto Stand
		TNT1 A 0 ACS_NamedExecuteAlways("MapEnhancementE3M8")
		TNT1 A 0 A_ChangeFlag("COUNTKILL", 0)
		TNT1 A 2 A_ChangeFlag("NOINTERACTION", 1)
		TNT1 A 0 A_SpawnItemEx ("SuperMastermind",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION | SXF_TRANSFERAMBUSHFLAG,0,tid)
		TNT1 A 2 ACS_NamedExecuteAlways("Tag666BMastermind", 0, 0, 0, 0)//E3M8
		TNT1 A -1
		Stop

	ReplaceForMotherDemonE4:
		TNT1 A 0
		TNT1 A 0 A_JumpIf(y == 32, 1)
		Goto Stand
		TNT1 A 0 A_ChangeFlag("COUNTKILL", 0)
		TNT1 A 2 A_ChangeFlag("NOINTERACTION", 1)
		TNT1 A 0 A_SpawnItemEx ("MotherDemon",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION | SXF_TRANSFERAMBUSHFLAG,0,tid)
		TNT1 A 2 ACS_NamedExecuteAlways("Tag666MotherDemon", 0, 0, 0, 0)//E4M8
		TNT1 A -1
		Stop

	ReplaceForSigil2:
		TNT1 A 0
		TNT1 A 0 A_JumpIf(y == 96, 1)
		Goto Stand
		TNT1 A 0 A_ChangeFlag("COUNTKILL", 0)
		TNT1 A 2 A_ChangeFlag("NOINTERACTION", 1)
		TNT1 A 0 A_SpawnItemEx ("SigilMastermind",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION | SXF_TRANSFERAMBUSHFLAG,0,tid)
		TNT1 A 2 ACS_NamedExecuteAlways("Tag666SMastermind", 0, 0, 0, 0)//E6M8
		TNT1 A -1
		Stop

	ReplaceMotherdemon:
		TNT1 A 0
		TNT1 A 0 A_JumpIf((CeilingZ - FloorZ) < 114,"Stand")
		TNT1 A 0 A_ChangeFlag("COUNTKILL", 0)
		TNT1 A 2 A_ChangeFlag("NOINTERACTION", 1)
		TNT1 A 0 A_SpawnItemEx ("Motherdemon",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION | SXF_TRANSFERAMBUSHFLAG,0,tid)
		TNT1 A 2 ACS_NamedExecuteAlways("Tag666MotherDemon", 0, 0, 0, 0)//E3M8
		TNT1 A -1
		Stop

	ReplaceJuggernaut:
		TNT1 A 0
		TNT1 A 0 A_JumpIf((CeilingZ - FloorZ) < 138,"Stand")
		TNT1 A 0 A_ChangeFlag("COUNTKILL", 0)
		TNT1 A 2 A_ChangeFlag("NOINTERACTION", 1)
		TNT1 A 0 A_SpawnItemEx ("Juggernaut",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION | SXF_TRANSFERAMBUSHFLAG,0,tid)
		TNT1 A 2 ACS_NamedExecuteAlways("Tag666Juggernaut", 0, 0, 0, 0)//E3M8
		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:
		SPID A 10 A_Look
		Loop

	See:
		SPID AA 2 A_Chase
		SPID BB 2 A_Chase
		SPID C 2 A_Chase
		SPID C 2 A_Metal
		TNT1 A 0 A_SpawnItemEx("HeavyFootSteps2",0,75)
		SPID DD 2 A_Chase
		SPID EE 2 A_Chase
		SPID F 2 A_Chase
		SPID F 2 A_Metal
		TNT1 A 0 A_SpawnItemEx("HeavyFootSteps2",0,-75)
		Loop

	Missile:
	    TNT1 A 0 A_TakeInventory ("BrutalCounter2", 500)
		TNT1 A 0 A_ChangeFlag("NOPAIN", 0)
		TNT1 A 0 A_ChangeFlag("NODROPOFF", 0)
		SPID A 4 A_FaceTarget
		SPID A 4 A_FaceTarget
		SPID A 4 A_FaceTarget
        SPID G 4 A_FaceTarget

		SPID G 3 A_FaceTarget
		SPID H 2 A_CustomMissile("MastermindTracer", 47, 0, random(-3, 3), CMF_OFFSETPITCH, random(-2, 2))
		TNT1 A 0 A_CustomMissile("DistantFireSoundSSG", 47, 0, 0, 1, 0)
		TNT1 A 0 A_CustomMissile("Alerter",47)
		TNT1 A 0 A_SpawnItem ("MasterMindCaseSpawn", 0, 60,0)

		TNT1 A 0 A_GiveInventory ("BrutalCounter2", 1)
		TNT1 A 0 A_JumpIfInventory ("BrutalCounter2", 100, "StopFiring")
		SPID G 0 A_SpidRefire
		Goto Missile+7

	StopFiring:
		SPID A 6 A_FaceTarget
		Goto See

	Avoid:
		 TNT1 A 0
		 TNT1 A 0 A_ChangeFlag("NOPAIN", 1)
		 TNT1 A 0 A_ChangeFlag("NODROPOFF", 1)
         NULL A 0 A_FaceTarget
         SPID ABCD 1 A_FastChase
         NULL A 0 A_FaceTarget
         SPID ABCD 1 A_FastChase
		 NULL A 0 A_FaceTarget
		 TNT1 A 0 A_ChangeFlag("NOPAIN", 0)
		 TNT1 A 0 A_ChangeFlag("NODROPOFF", 0)
		 Goto Missile+6

	Pain:
		SPID I 4 A_Pain
        Goto See

	Pain.Killme:
	Pain.Taunt:
		TNT1 A 0
		TNT1 A 0 HealThing(2)
		Goto Missile

	Pain.Stomp:
		TNT1 A 0 A_FaceTarget
		TNT1 A 0 A_Recoil(10)
		SPID I 2 A_Pain
		Goto See

	Pain.Explosive:
		TNT1 A 0 A_FaceTarget
		TNT1 A 0 A_Recoil(10)
		SPID I 2 A_Pain
		Goto Avoid

	Death:
		SPID J 1
		SPID J 20 A_Scream
		tnt1 a 0 A_FaceTarget
		SPID K 10 A_NoBlocking
		TNT1 A 0 A_CustomMissile ("RidiculousExplosionSpawner", 30, 0, random (0, 360), 2, 90)
		SPID LM 5
		EXPL A 0 Radius_Quake (4, 35, 0, 10, 0)
		TNT1 AAAAAAAAAA 0 A_CustomMissile ("PEPart2SuperFast", 32, 0, random (0, 360), 2, random (0, 160))
		TNT1 AAAAAAA 0 A_CustomMissile ("BloodMistXXBig", 40, 0, random (0, 360), 2, random (40, 90))
		TNT1 AAAAAAAAAA 0 A_CustomMissile ("BloodMistXXBig", 100, 0, random (0, 360), 2, random (40, 90))
        TNT1 AAA 0 A_CustomMissile ("MastermindLeg", 40, 0, random (0, 360), 2, random (40, 90))
		TNT1 A 0 A_SpawnItem ("GiantBloodSpot")

		TNT1 A 0 A_ChangeFlag("NOTARGET", 1)
		SPID NOPQR 5
        SPID S 105
		SPID S -1 A_BossDeath
		Stop

	Death.Stomp:
	Death.Telefrag:
	Death.Massacre:
		SPID J 0 A_Stop
		TNT1 A 0 A_NoBlocking
		SPID J 5 A_Scream
		tnt1 a 0 A_FaceTarget
		SPID K 3
		SPID LM 3
		TNT1 AAA 0 A_CustomMissile ("XDeath2", 42, 0, random (0, 360), 2, random (0, 160))
		TNT1 AAA 0 A_CustomMissile ("XDeath3", 42, 0, random (0, 360), 2, random (0, 160))
		TNT1 AAAA 0 A_CustomMissile ("BloodMistXXBig", 50, 0, random (0, 360), 2, random (40, 90))
		TNT1 AAAAAAAAAA 0 A_CustomMissile ("BloodMistBig", 50, 0, random (0, 360), 2, random (40, 90))
		TNT1 A 0 A_SpawnItem ("GiantBloodSpot")
		TNT1 A 0 A_SpawnItem ("StompedMastermind")
		TNT1 A 105
		TNT1 A -1 A_BossDeath
		Stop

Death.Cut:
Death.Saw:
Death.decaptate:
		TNT1 AAAAAAAAAAAAAAAAA 0 A_CustomMissile ("XDeath1", 120, 0, random (0, 360), 2, random (50, 130))
		TNT1 A 0 A_CustomMissile ("XSpiderMastermindCuttedBrain", 120, 0, random (0, 360), 2, random (50, 130))
		SPIY AAAAAAAAAAA 8 A_SpawnItem("MuchBlood", 0, 120)

		EXPL A 0 Radius_Quake (4, 35, 0, 10, 0)
        TNT1 AAAAAA 0 A_CustomMissile ("ExplosionSpawner", 50, 0, random (0, 360), 2, random (0, 360))
        TNT1 AAAA 0 A_CustomMissile ("SuperGoreSPawner", 110, 0, random (0, 360), 2, random (0, 180))
        TNT1 AAAAAAA 0 A_CustomMissile ("BloodMistXXBig", 90, 0, random (0, 360), 2, random (70, 90))
		SPID K 10 A_NoBlocking
        TNT1 AAAAAA 0 A_CustomMissile ("ExplosionSpawner", 10, 0, random (0, 360), 2, random (0, 360))
        TNT1 AAAA 0 A_CustomMissile ("UltraGoreSPawner", 80, 0, random (0, 360), 2, random (0, 180))
        TNT1 AAAAAAA 0 A_CustomMissile ("BloodMistXXBig", 90, 0, random (0, 360), 2, random (70, 90))
		SPID L 5
        TNT1 AAAA 0 A_CustomMissile ("MuchMeatDeath", 0, 0, random (0, 360), 2, random (0, 160))
        TNT1 A 0 A_CustomMissile ("RidiculousExplosionSpawner", 30, 0, random (0, 360), 2, 90)
		TNT1 AAAAAAAAAAAA 0 A_CustomMissile ("PEPart2SuperFast", 32, 0, random (0, 360), 2, random (0, 160))
        TNT1 AAAA 0 A_CustomMissile ("UltraGoreSPawner", 30, 0, random (0, 360), 2, random (0, 180))
        TNT1 AAAAAA 0 A_CustomMissile ("UltraGoreSpawner", 30, 0, random (0, 360), 2, random (0, 180))
		TNT1 AAAAAAAAAAAAAA 0 A_CustomMissile ("BloodMistXXBig", 30, 0, random (0, 360), 2, random (70, 90))
		 TNT1 AAAAAAAAAAAAAAAAAAAAAAAA 0 A_CustomMissile ("BloodMistXXBig", 100, 0, random (0, 360), 2, random (20, 90))
        //SPID MNOPQR 5
		TNT1 AAA 0 A_CustomMissile ("MastermindLeg", 30, 0, random (0, 360), 2, random (40, 90))
		TNT1 A 0 A_CustomMissile ("MastermindLeg", 30, 0, 0, 2, 65)
		//TNT1 AAAAAAAAAAAA 0 A_CustomMissile ("PEPart2SuperFast", 32, 0, random (0, 360), 2, random (0, 160))
		TNT1 A 0 A_SpawnItem ("GiantBloodSpot")
        TNT1 A 105
		TNT1 A -1 A_BossDeath
		Stop

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

ACTOR XSpiderMastermindCuttedBrain
{
    Radius 8
    Height 8
    Speed 10
    Scale 1.1
	Mass 1
    +NOBLOCKMAP
	+MISSILE
    +NOTELEPORT
    +MOVEWITHSECTOR
    +CLIENTSIDEONLY
    +RIPPER
    +BLOODLESSIMPACT
	-DONTSPLASH
	+THRUGHOST
damagetype Blood
    SeeSound "misc/xdeath4"
    DeathSound "misc/xdeath1"
	Decal BrutalBloodSplat
    States
    {
    Spawn:
	    TNT1 A 0 A_JumpIf(waterlevel > 1, "Splash")
        SPIP ABCDEFGH 3 A_CustomMissile ("Brutal_FlyingBloodTrail", 0, 0, random (0, 360), 2, random (0, 360))
        Loop
    Death:
        TNT1 A 0 A_SpawnItem("Brutal_BloodSpot",0,0,0,1)
        SPIP I 1
		SPIP I -1
        Stop
     Splash:
        TNT1 A 0
        Stop
    }
}

ACTOR MastermindLeg
{
    Radius 8
    Height 8
    Speed 24
    Scale 1.1
	Gravity 0.8
	Mass 1
    +NOBLOCKMAP
	+MISSILE
    +NOTELEPORT
    +MOVEWITHSECTOR
	+THRUACTORS
	+FLOORCLIP
	-NOGRAVITY
	+FORCERADIUSDMG
	+SKYEXPLODE
    damagetype Stomp
    SeeSound "misc/xdeath4"
    DeathSound "misc/xdeath1"
	Decal BrutalBloodSplat
    States
    {
    Spawn:
	    TNT1 A 0 A_JumpIf(waterlevel > 1, "Underwater")
        SPP4 ABCDEFGH 5
        Loop
    Death:
	    TNT1 A 0 ThrustThingZ(0,50,0,1)
		TNT1 A 0 A_Explode(300, 100)
		EXPL AAAAAAA 0 A_CustomMissile ("ExplosionSMoke", 0, 0, random (0, 360), 2, random (0, 360))
		Goto KeepRotating
	KeepRotating:
        SPP4 AB 2
		SPP4 CDEFGH 2 A_CheckFloor("Rest")
		Loop
	Rest:
	    SPP4 A 1
		TNT1 A 0 A_Explode(50, 100)
		EXPL AAAAAAA 0 A_CustomMissile ("ExplosionSMoke", 0, 0, random (0, 360), 2, random (0, 360))
		SPP4 A -1
        Stop

     Underwater:
	 Splash:
	    SPP4 A 4
        Loop
    }
}

ACTOR StompedMastermind
{
    Radius 56
    Height 32
    Scale 1.1
	+SHOOTABLE
	+NOBLOOD
	DamageFactor "Trample", 0.0
	DamageFactor "Stomp", 0.0
	Health 100
	Mass 999999
    States
    {
     Spawn:
        FTS2 F 10
		TNT1 A 0 A_ChangeFlag("SOLID", 0)
		FTS2 F -1
        Stop

	Death:
		TNT1 A 0 A_NoBlocking
		TNT1 A 0 A_Explode(300, 400)
		TNT1 A 0 A_CustomMissile ("RidiculousExplosionSpawner", 30, 0, random (0, 360), 2, 90)
		EXPL A 0 Radius_Quake (4, 35, 0, 10, 0)
		TNT1 AAAAAAAAAA 0 A_CustomMissile ("PEPart2SuperFast", 32, 0, random (0, 360), 2, random (0, 160))
		TNT1 AAAAAAA 0 A_CustomMissile ("BloodMistXXBig", 40, 0, random (0, 360), 2, random (40, 90))
		TNT1 AAAAAAAAAA 0 A_CustomMissile ("BloodMistXXBig", 100, 0, random (0, 360), 2, random (40, 90))
        TNT1 AAA 0 A_CustomMissile ("MastermindLeg", 40, 0, random (0, 360), 2, random (40, 90))
		SPID S 1
		SPID S -1
		Stop
    }
}

ACTOR Titan
{
	Obituary "%o was destroyed by the Titan."
	+NOICEDEATH
	Game Doom
	Health 100000
	Radius 366//222px
	Height 815//247px
    Scale 3.3
	Mass 150000
	Speed 80
	MaxStepHeight 272
	MaxDropOffHeight 280
	PainChance 30

	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.5	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", 0.5
	Damagefactor "Fatality", 0.5	Damagefactor "HeadKick", 0.5	Damagefactor "HelperMarineFatallity", 0.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

	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

	Monster
	//MinMissileChance 200
	DeathHeight 0
	BurnHeight 0
	+BOSS
	+FLOORCLIP
    +DONTRIP
	+DONTMORPH
	+BOSSDEATH
    +NORADIUSDMG
    +NOBLOOD
	+MISSILEMORE
	+SOLID
	+MISSILEEVENMORE
	+SHOOTABLE
	DropItem "64UnmakerUpgradeSpawner", 16
	SeeSound "spider/sight"
	AttackSound "spider/attack"
	PainSound "SPIPAIN1"
	DeathSound "spider/death"
	ActiveSound "spider/active"
	States
	{

    Spawn:
		KPRM A 10 A_Look
		Loop

	See:
		KPRM A 20 A_Explode(9999, 370)
		KPRM BBBBB 2 A_Chase("", "")
		KPRM C 20 A_Explode(9999, 370)
		KPRM DDDDD 2 A_Chase("", "")
		Loop
	}
}