//=============================================================================================
//
// Sorcerer (Some code from Bitter Heretic and Some from Baron/etc. from Schism)
// modified by LordADHD
//=============================================================================================

ACTOR BrutalDSparil replaces Sorcerer1
{
    Scale 1.1
	damagefactor "Crush", 10.0
	damagefactor "GibRemoving", 0.0
	Game Heretic
	SpawnID 142
	Monster
	Health 2400
	PainChance "Saw", 75
	PainChance "Cut", 80
	PainChance "Minor", 75
	PainChance "Kick", 75
	PainChance "LowKick", 80 PainChance "HangingHook", 0
	PainChance "Stun", 125
	PainChance "Freeze", 75
	damagefactor "TeleportRemover", 0.0
	damagefactor "Avoid", 0.0
	damagefactor "SSG", 0.2
	+QUICKTORETALIATE
	PainChance "Explosive", 75
	DamageFactor "CauseSplash", 0.0 DamageFactor "CauseObjectsToSplashSlime", 0.0 DamageFactor "CauseObjectsToSplashNukage", 0.0
	DamageFactor "CauseObjectsToSplashBlood", 0.0 DamageFactor "CauseObjectsToSplashLava", 0.0
	PainSound "PSXDPN"
	damagefactor "Blood", 0.0 damagefactor "BlueBlood", 0.0 damagefactor "GreenBlood", 0.0
    BloodType "Brutal_Blood", "SawBlood", "SawBlood"
	Obituary "%o was destroyed by the D'Sparil!" //placeholder shit
	MaxStepHeight 24
	MaxDropOffHeight 32
	+MISSILEMORE
	+DONTHURTSPECIES
	+BOSS
	+DONTMORPH
	+NORADIUSDMG
	+NOTARGET
	+NOICEDEATH
	+FLOORCLIP
	+DONTGIB
	DeathHeight 0
	Radius 28
	Height 100
	BurnHeight 0
	Speed 16
	//PainChance "Head", 120
	PainChance 56
	Species "DSparils"
	Tag "D'Sparil"
	States
	{		
    Spawn:
		SRCR B 0
		Goto Stand
		Stand:
		TNT1 A 0
		SRCR AB 10 A_Look
		Loop
	
	See:
		SRCR A 5 A_Chase
		SRCR B 5 A_Chase
		SRCR C 5 A_Chase
		SRCR D 5 A_Chase
		Loop
	
	QuickSee:
		SRCR A 2 A_Chase
		SRCR B 2 A_Chase
		SRCR C 2 A_Chase
		SRCR D 2 A_Chase
		Goto See
	
	Melee:
	    TNT1 A 0
		TNT1 A 0 A_FaceTarget
		SRCR Q 1
        SRCR Q 6
        TNT1 A 0 A_PlaySound("weapons/gswing")
		SRCR R 6 A_FaceTarget
		SRCR S 6 A_CustomMissile("DSparilRiderAttack",10,0,0,0)
		Goto See
	
    Missile:
		TNT1 A 0 A_JumpIfHealthLower(1800, "Missile2")
		SRCR Q 1
        
		SRCR Q 3 A_FaceTarget
		
		SRCR R 2 A_FaceTarget
		TNT1 A 0 bright A_SpawnItemEx ("SmallFlameTrails", 12, 0, 72)
		TNT1 A 0 A_SpawnItemEx ("ImBallGettingReady", 12, 0, 72)
		SRCR R 2 A_FaceTarget
		TNT1 A 0 bright A_SpawnItemEx ("SmallFlameTrails", 12, 0, 72)
		TNT1 A 0 A_SpawnItemEx ("ImBallGettingReady", 12, 0, 72)
		SRCR R 2 A_FaceTarget
		TNT1 A 0 bright A_SpawnItemEx ("SmallFlameTrails", 12, 0, 72)
		TNT1 A 0 A_SpawnItemEx ("ImBallGettingReady", 12, 0, 72)
		SRCR R 2 A_FaceTarget
		TNT1 A 0 bright A_SpawnItemEx ("SmallFlameTrails", 12, 0, 72)
		TNT1 A 0 A_SpawnItemEx ("ImBallGettingReady", 12, 0, 72)
		SRCR R 2 A_FaceTarget
		
		SRCR S 3 A_FaceTarget
		SRCR S 8 A_CustomMissile("DSparilRiderBall", 72, 0, 0, 1)
		Goto See
		
	Missile2:
		SRCR Q 1
        
		SRCR Q 3 A_FaceTarget
		
		SRCR R 2 A_FaceTarget
		TNT1 A 0 bright A_SpawnItemEx ("SmallFlameTrails", 12, 0, 72)
		TNT1 A 0 A_SpawnItemEx ("ImBallGettingReady", 12, 0, 72)
		SRCR R 2 A_FaceTarget
		TNT1 A 0 bright A_SpawnItemEx ("SmallFlameTrails", 12, 0, 72)
		TNT1 A 0 A_SpawnItemEx ("ImBallGettingReady", 12, 0, 72)
		SRCR R 2 A_FaceTarget
		TNT1 A 0 bright A_SpawnItemEx ("SmallFlameTrails", 12, 0, 72)
		TNT1 A 0 A_SpawnItemEx ("ImBallGettingReady", 12, 0, 72)
		SRCR R 2 A_FaceTarget
		TNT1 A 0 bright A_SpawnItemEx ("SmallFlameTrails", 12, 0, 72)
		TNT1 A 0 A_SpawnItemEx ("ImBallGettingReady", 12, 0, 72)
		SRCR R 2 A_FaceTarget
		
		SRCR S 3 A_FaceTarget
		TNT1 A 0 A_CustomMissile("DSparilRiderBall", 72, 0, -3, 1)
		TNT1 A 0 A_CustomMissile("DSparilRiderBall", 72, 0, 3, 1)
		SRCR S 8 A_CustomMissile("DSparilRiderBall", 72, 0, 0, 1)
		Goto See
	
	Pain:
		SRCR Q  3
		SRCR Q  3 A_Pain
		Goto QuickSee
	
	Pain.Freeze:
		TNT1 A 0
		TNT1 A 0 A_JumpIfInventory("IsSlowed", 1, "Pain")
		TNT1 A 0 ACS_NamedExecute("SlowingFreeze",0)
		TNT1 A 0 A_GiveInventory("IsSlowed", 1)
		Goto Pain
	
	Death:
		TNT1 A 0
		TNT1 A 0 A_Scream
		SRCR EFG 6
		TNT1 A 0 A_CustomMissile("SerpHorn1", 90, 0, random (0, 360), 2, random (0, 180))
		TNT1 A 0 A_CustomMissile("SerpHorn2", 90, 0, random (0, 360), 2, random (0, 180))
		TNT1 A 0 A_CustomMissile("SerpHorn3", 90, 0, random (0, 360), 2, random (0, 180))
		TNT1 AA 0 A_CustomMissile("SerpArm", 90, 0, random (0, 360), 2, random (0, 180))
		TNT1 AA 0 A_CustomMissile("SerpLeg", 90, 0, random (0, 360), 2, random (0, 180))
		TNT1 A 0 A_CustomMissile("SerpTail", 90, 0, random (0, 360), 2, random (0, 180))
		TNT1 AAAAAAAAAAAA 0 A_CustomMissile ("XDeath1", random(40,120), random(-30,30), random (0, 190), 2, random (10, 60))
		TNT1 AAAAAAAAAAAA 0 A_CustomMissile ("XDeath3", random(40,120), random(-30,30), random (0, 190), 2, random (10, 60))
		TNT1 AAAA 0 A_CustomMissile ("XDeath2", random(40,120), random(-30,30), random (0, 190), 2, random (10, 60))
		TNT1 AAAA 0 A_CustomMissile ("XDeath4", random(40,120), random(-30,30), random (0, 190), 2, random (10, 6))
		SRCR L 15
		TNT1 AAAAAAA 0 A_SpawnItemEx("DLightningFX",0,0,0,frandom(3,-3),frandom(3,-3),frandom(3,-3),0,0)
		TNT1 AAAAA 0 A_CustomMissile ("BluePlasmaParticle", 0, 0, random (0, 360), 2, random (0, 360))
		TNT1 A 0 A_SpawnItemEx("LightningTrailLarge",0,0,0,0,0,0,0,32)
		SRCR L 25 A_PlaySound("PZAPBOMB", CHAN_BODY, 1, FALSE, ATTN_NONE) //placeholder shit (sound itself)
		SRCR MN 5
		SRCR O 4
		TNT1 A 0 A_CustomMissile ("DeathLightningMissile", 40)
		TNT1 AAAAAAA 0 A_SpawnItemEx("DLightningFX",0,0,0,frandom(3,-3),frandom(3,-3),frandom(3,-3),0,0)
		TNT1 AAAAA 0 A_CustomMissile ("BluePlasmaParticle", 0, 0, random (0, 360), 2, random (0, 360))
		TNT1 A 0 A_SpawnItemEx("LightningTrailLarge",0,0,0,0,0,0,0,32)
		TNT1 A 0 A_SpawnItemEx("BrutalDSparil2", 0, 0, 0, 0, 0, 0, 0)
		SRCR L 25 A_PlaySound("PZAPBOMB", CHAN_BODY, 1, FALSE, ATTN_NONE) //placeholder shit (sound itself)
		SRCR MN 5
		SRCR O 4 
		SRCR P 1 
		SRCR P -1 A_SpawnItem("BrutalDSparilRise")
		Stop
	
	Pain.Lightning:
		TNT1 A 0
		TNT1 A 0 A_SpawnItemEx ("StunElectrocute", random (-4, 4), random (-4, 4),  random (16, 32), 0, 0)
		SRCR Q 1 A_Pain
		SRCR QQQQQQQQQQ 3 A_SpawnItemEx ("StunElectrocute", random (-12, 12), random (-12, 12),  random (16, 52), 0, 0)
		SRCR Q 1 A_Pain
		Goto QuickSee

	Pain.Stun:
		TNT1 A 0
		TNT1 A 0 A_SpawnItemEx ("StunElectrocute", random (-4, 4), random (-4, 4),  random (16, 32), 0, 0)
		SRCR Q 1 A_Pain
		SRCR QQQQQQQQQQ 3 A_SpawnItemEx ("StunElectrocute", random (-12, 12), random (-12, 12),  random (16, 52), 0, 0)
		SRCR Q 1 A_Pain
		SRCR QQQQQQQQQQ 3 A_SpawnItemEx ("StunElectrocute", random (-12, 12), random (-12, 12),  random (16, 52), 0, 0)
		SRCR Q 1 A_Pain
		Goto QuickSee

    Pain.KillMe:
    Pain.Taunt:
        TNT1 A 0
		TNT1 A 0 HealThing(1)
        Goto Missile
    Death.KillMe:
    Death.Taunt:
	    TNT1 A 0 A_ChangeFlag("SOLID", 0)
        TNT1 A 0 A_SpawnItem("BrutalDSparil")
        Stop

	}
}

////////////////////
//D'Sparil Attacks//
////////////////////

ACTOR DSparilRiderAttack : BaronBall
{
	Radius 24
	Height 16
	DamageType BHFT
	Projectile 
	+RANDOMIZE
	+FORCEXYBILLBOARD
    +THRUGHOST
	RenderStyle Add
	Alpha 0.6
    Damage 25
    Speed 28
	//HitObituary "$OB_IMPHIT"
	SeeSound "none"
	DeathSound "none"
	Decal "none"
	States
	{
	Spawn:
		TNT1 A 2 BRIGHT
        TNT1 A 2 //A_PlaySound("weapons/gswing")
		Goto Death
	Death:
		TNT1 A 0 BRIGHT
		Stop
	}
}

ACTOR DSparilRiderBall
{
	Game Doom
	DamageType Burn
	Radius 8
	Height 18
	Speed 24
	FastSpeed 32
	Damage (random(30,30))
	PROJECTILE
    +THRUGHOST
	+FORCEXYBILLBOARD
	RenderStyle Add
	Alpha 1
	SeeSound "imp/attack"
	DeathSound "imp/shotx"
	Decal "Scorch"
	Species "DSparils"
	+DONTHURTSPECIES
	Scale 0.6
	States
	{
	StopInAir:
		TNT1 A 0
		EXPL A 0 A_CustomMissile ("FireBallExplosionFlames", 1, 0, random (0, 360), 2, random (0, 360))
		Stop
		
	Spawn:
	    TNT1 A 0 A_JumpIf(waterlevel > 1, "SpawnUnderwater")
		TNT1 A 0 ACS_NamedExecuteAlways("BDCheckJanitor", 0, 0, 0, 0)//Check Effects
		BLHD AB 1 BRIGHT
		TNT1 A 0 A_JumpIfInventory("lowgraphicsmode", 1, "SpawnCheap")
	
	Spawn1:
		TNT1 A 0 
		BLHD A 1 BRIGHT A_SpawnItem ("CoolAndNewFlameTrails", 0, random( -2, 2))
		TNT1 A 0 A_CustomMissile ("OldschoolRocketSmokeTrailDarker", 2, 0, random (160, 210), 2, random (-30, 30))
		Loop
		
	SpawnCheap:
		BLHD AB 1 BRIGHT// A_SpawnItem ("CoolAndNewFlameTrails")
		Loop
		
	SpawnUnderwater:
		FR7X A 1 BRIGHT A_SpawnItem("FireballFlare",0,0)
		TNT1 A 0 A_CustomMissile ("BUBULZ", 0, 0, random (0, 360), 2, random (0, 180))
		FR7X B 1 BRIGHT A_SpawnItem("FireballFlare",0,0)
		TNT1 A 0 A_CustomMissile ("BUBULZ", 0, 0, random (0, 360), 2, random (0, 180))
		Goto Spawn1	
		
	Death:
		//TNT1 A 0 A_ChangeFlag("SHOOTABLE", 0)
		//TNT1 A 0 A_JumpIfInventory("lowgraphicsmode", 1, "DeathCheap")
		TNT1 A 0
		TNT1 A 0 A_SpawnItemEx ("SmallUnderwaterExplosion",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
	    EXPL A 0 A_CustomMissile ("FireBallExplosionFlames", 1, 0, random (0, 360), 2, random (0, 360))
		//FRFX CDEFGHIJKLMNOP 1 BRIGHT A_SpawnItem("RedFlare",0,0)
		TNT1 A 0 A_SpawnItemEx("TinyBurningPiece3", random (-5, 5), random (-5, 5))
		TNT1 A 0 A_SpawnItemEx ("DetectFloorCraterSmall",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
	    TNT1 A 0 A_SpawnItemEx ("DetectCeilCraterSmall",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
		TNT1 A 0 A_CustomMissile ("BDExplosionparticlesSmall", 10, 0, random (0, 180), 2, random (40, 90))
		TNT1 A 0 A_CustomMissile ("PlasmaSmoke", 1, 0, random (0, 360), 2, random (0, 160))
		Stop
	XDeath:
	    TNT1 A 0
		//TNT1 A 0 A_JumpIfInventory("lowgraphicsmode", 1, "DeathCheap")
		TNT1 A 0 A_SpawnItemEx ("SmallUnderwaterExplosion",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
		TNT1 A 0 A_CustomMissile ("BDExplosionparticlesSmall", 10, 0, random (0, 180), 2, random (40, 90))
	    EXPL A 0 A_CustomMissile ("FireBallExplosionFlames", 1, 0, random (0, 360), 2, random (0, 360))
		TNT1 A 0 A_SpawnItemEx("TinyBurningPiece3", random (-15, 15), random (-15, 15))
		TNT1 A 0 A_CustomMissile ("PlasmaSmoke", 1, 0, random (0, 360), 2, random (0, 160))
		//FRFX CDEFGHIJKLMNOP 1 BRIGHT A_SpawnItem("RedFlare",0,0)
		Stop
	}
}

////////////////
//Serpent Gibs//
////////////////

ACTOR SerpHorn1: XDeath1
{
    Speed 12
	Gravity 0.4
	SeeSound "misc/xdeath5"
    DeathSound "misc/xdeath5"
    Scale 1.1
    States
    {
    Spawn:
        SRCG ABCD 2
        Loop
    Death:
		TNT1 A 0
		TNT1 A 0 A_QueueCorpse
	    TNT1 A 0 A_CheckFloor("SpawnFloor")
        SRCG A 9009
		TNT1 A 2
        Stop
	SpawnFloor:
	    SRCG A 9009
		TNT1 A 2
		Stop
    }
}

ACTOR SerpHorn2: XDeath1
{
    Speed 12
	Gravity 0.4
	SeeSound "misc/xdeath5"
    DeathSound "misc/xdeath5"
    Scale 1.1
    States
    {
    Spawn:
        SRCG EFGH 2
        Loop
    Death:
		TNT1 A 0
		TNT1 A 0 A_QueueCorpse
	    TNT1 A 0 A_CheckFloor("SpawnFloor")
        SRCG G 9009
		TNT1 A 2
        Stop
	SpawnFloor:
	    SRCG G 9009
		TNT1 A 2
		Stop
    }
}

ACTOR SerpHorn3: XDeath1
{
    Speed 12
	Gravity 0.4
	SeeSound "misc/xdeath5"
    DeathSound "misc/xdeath5"
    Scale 1.1
    States
    {
    Spawn:
        SRCG IJKL 2
        Loop
    Death:
		TNT1 A 0
		TNT1 A 0 A_QueueCorpse
	    TNT1 A 0 A_CheckFloor("SpawnFloor")
        SRCG J 9009
		TNT1 A 2
        Stop
	SpawnFloor:
	    SRCG J 9009
		TNT1 A 2
		Stop
    }
}

ACTOR SerpArm: XDeath1
{
    Speed 12
	Gravity 0.4
	SeeSound "misc/xdeath5"
    DeathSound "misc/xdeath5"
    Scale 1.1
    States
    {
    Spawn:
        SRCG MNOP 2
        Loop
    Death:
		TNT1 A 0
		TNT1 A 0 A_QueueCorpse
	    TNT1 A 0 A_CheckFloor("SpawnFloor")
        SRCG N 9009
		TNT1 A 2
        Stop
	SpawnFloor:
	    SRCG N 9009
		TNT1 A 2
		Stop
    }
}

ACTOR SerpLeg: XDeath1
{
    Speed 12
	Gravity 0.4
	SeeSound "misc/xdeath5"
    DeathSound "misc/xdeath5"
    Scale 1.1
    States
    {
    Spawn:
        SRCG QRST 2
        Loop
    Death:
		TNT1 A 0
		TNT1 A 0 A_QueueCorpse
	    TNT1 A 0 A_CheckFloor("SpawnFloor")
        SRCG T 9009
		TNT1 A 2
        Stop
	SpawnFloor:
	    SRCG T 9009
		TNT1 A 2
		Stop
    }
}

ACTOR SerpTail: XDeath1
{
    Speed 12
	Gravity 0.4
	SeeSound "misc/xdeath5"
    DeathSound "misc/xdeath5"
    Scale 1.1
    States
    {
    Spawn:
        SRCG UVWX 2
        Loop
    Death:
		TNT1 A 0
		TNT1 A 0 A_QueueCorpse
	    TNT1 A 0 A_CheckFloor("SpawnFloor")
        SRCG Y 9009
		TNT1 A 2
        Stop
	SpawnFloor:
	    SRCG Y 9009
		TNT1 A 2
		Stop
    }
}