ACTOR BloodDemonClone : DnD_BaseMeleeMonster { 
    Health 0x7FFFFFFF
	GibHealth -50
    Speed 12 
    Height 56
    Radius 30
    Mass 400
    PainChance 180
    REACTIONTIME 8 
    SeeSound "blooddemon/sight"
    PainSound "blooddemon/pain"
    DeathSound "blooddemon/death"
    ActiveSound "blooddemon/active"
    //MeleeSound "blooddemon/melee"
    HitObituary "%o Was chewed up and spat out by a Mech-demon." 
	Species "Demon"
	Tag "Blood Demon"
	+ISMONSTER
	+DONTHURTSPECIES
    States { 
		SetInfo:
			TNT1 A 0 A_SetArg(4, DND_BLOODDEMON)
		Goto SpawnSetup

		IdleState:
			SRG2 AB 10 A_GiveInventory("DnD_SightChecker", 1)
		Loop 
		SeeState:
			SRG2 A 0 A_PlaySound("blooddemon/walk")
			SRG2 AABB 2 Fast A_Chase
			SRG2 C 0 A_PlaySound("blooddemon/walk")
			SRG2 CCDD 2 Fast A_Chase
		Goto See
		MeleeState: 
			SRG2 E 0 A_PlaySound("blooddemon/melee")
			SRG2 EF 8 Fast A_FaceTarget
			SRG2 G 8 Fast A_CustomMeleeAttack(5 * random(1, 8))
		Goto See 
		PainState:
			SRG2 H 2 Fast
			SRG2 H 2 Fast A_Pain
		Goto See
		XDeathState:
			TNT1 A 0 A_SpawnDebris("MetalScrap_More")
			TNT1 A 0 A_SpawnItemEx("GenericGibber_Low", 0, 0, 0, 0, 0, 0, 0, SXF_USEBLOODCOLOR)
		DeathState: 
			SRG2 I 8 
			SRG2 I 0 A_FaceTarget
			SRG2 J 0 A_SpawnItemEx("BloodDemonArm", 10, 0, 32, 0, 8, 0, 0, 128)
			SRG2 J 8 A_Scream
			SRG2 K 4 
			SRG2 L 4 A_NoBlocking
			SRG2 M 4 
			SRG2 N -1
		Stop
		RaiseState: 
			SRG2 NMLKJI 5 
		Goto See
    } 
}

ACTOR BloodDemonArm {
	Radius 8
	Height 8
	Speed 8
	+DOOMBOUNCE
	+DROPOFF
	+Missile
	+CLIENTSIDEONLY
	States {
		Spawn:
			SG2A ABCDEFGH 2
		Loop
		Death:
			SG2A I -1
		Loop
	}
}

Actor Bloodfiend : DnD_BaseHybridMonster {
	Health 0x7FFFFFFF
	GibHealth -50
	PainChance 140
	Speed 12
	Radius 30
	Height 56
	Mass 450
	+DontHurtSpecies
	Obituary "%o died from the toxic blood of a bloodfiend."
	HitObituary "%o was eaten by a bloodfiend."
	SeeSound "Monster/sg2sit"
	AttackSound "Monster/sg2atk"
	PainSound "demon/Pain"
	DeathSound "demon/Death"
	ActiveSound "demon/sg2act"
	Tag "Blood Fiend"
	+ISMONSTER
	States {
		SetInfo:
			TNT1 A 0 A_SetArg(4, DND_BLOODFIEND)
			TNT1 A 0 ACS_NamedExecuteWithResult("DnD Init Monster Data", DND_MWEIGHT_UNCOMMON)
		Goto SpawnSetup

		IdleState:
			SAR2 AB 10 A_GiveInventory("DnD_SightChecker", 1)
		Loop
		SeeState:
			SAR2 AABBCCDD 2 Fast A_Chase
		Goto See
		MeleeState:
			SAR2 EF 8 Fast A_FaceTarget
			SAR2 G 8 Fast A_CustomMeleeAttack(random(1, 10) * 4)
		Goto See
		MissileState:
			SAR2 GF 8 Fast A_FaceTarget
			SAR2 E 0 A_PlaySound("Weapons/bloodf")
			SAR2 E 0 A_CustomMissile("Bloodshot",22,0,-1,0,0)
			SAR2 E 8 Fast A_CustomMissile("Bloodshot",22,0,1,0,0)
		Goto See
		PainState:
			SAR2 H 2 Fast
			SAR2 H 2 Fast A_Pain
		Goto See
		DeathState:
			SAR2 I 8
			SAR2 J 8 A_Scream
			SAR2 K 4
			SAR2 L 4 A_NoBlocking
			SAR2 M 4
			SAR2 N -1
		Stop
		XDeathState:
			TNT1 A 0 A_SpawnItemEx("GenericGibber_Low", 0, 0, 0, 0, 0, 0, 0, SXF_USEBLOODCOLOR)
			SAR2 O 5
			SAR2 P 5 A_XScream
			SAR2 Q 5 A_NoBlocking
			SAR2 RSTUV 5
			SAR2 W -1
		Stop
		RaiseState:
			SAR2 NMLKJI 5
		Goto See
	}
}

Actor Bloodshot {
	Radius 3
	Height 3
	Speed 20
	Damage (2 * random(1, 6))
	DamageType "Physical"
	Stamina 1
	Projectile
	RenderStyle Translucent
	Alpha 0.80
	+ThruGhost
	+DONTBLAST
	DeathSound "weapons/bloodx"
	States {
		Spawn:
			TNT1 A 0 NoDelay ACS_NamedExecuteAlways("DnD Pierce Check")
		SpawnLoop:
			FBLD A 2 Bright A_CStaffMissileSlither
			FBLD A 0 A_SpawnItemEx("Bloodtrail",0,0,0,0,0,0,128)
			FBLD B 2 Bright A_CStaffMissileSlither
			FBLD B 0 A_SpawnItemEx("Bloodtrail",0,0,0,0,0,0,128)
			Loop
		Death:
			TNT1 A 0 A_SpawnDebris("NashGore_FlyingBlood")
			FBLD CDE 3 Bright
		Stop
	}
}

Actor Bloodtrail {
	RenderStyle Translucent
	Alpha 0.67
	+NOINTERACTION
	+CLIENTSIDEONLY
	States {
		Spawn:
			TNT1 A 3
			FBLD FGH 3 BRIGHT
		Stop
	}
}

Actor Ravager : DnD_BaseHybridMonster {
	Health 0x7FFFFFFF
	GibHealth -50
	PainChance 96
	Speed 16
	Mass 1024
	Obituary "%o died from the toxic blood of a Ravager."
	HitObituary "%o was bitten by a Ravager."
	SeeSound "Monster/sg2sit"
	AttackSound "Monster/sg2atk"
	PainSound "demon/Pain2"
	DeathSound "demon/Death"
	ActiveSound "demon/sg2act"
	Tag "Ravager"
	MaxTargetRange 264
	Scale 1.15
	Radius 30
	Height 56
	+ISMONSTER
	States {
		SetInfo:
			TNT1 A 0 A_SetArg(4, DND_RAVAGER)
			TNT1 A 0 ACS_NamedExecuteWithResult("DnD Init Monster Data", DND_MWEIGHT_VERYRARE)
		Goto SpawnSetup
	
		IdleState:
			SAR3 AB 10 A_GiveInventory("DnD_SightChecker", 1)
		Loop
		SeeState:
			SAR3 AABBCCDD 2 Fast A_Chase
		Loop
		MeleeState:
			SAR3 EF 6 Fast A_FaceTarget
			SAR3 G 6 Fast A_CustomMeleeAttack(random(5, 10) * 4)
		Goto See
		MissileState:
			SAR3 GE 5 Fast A_FaceTarget
			SAR3 F 5 Fast A_CustomMissile("Bloodshot_Grav", 27, 0, frandom(-4, 4))
			TNT1 A 0 A_FaceTarget
			SAR3 F 5 Fast A_CustomMissile("Bloodshot_Grav", 27, 0, frandom(-4, 4))
			TNT1 A 0 A_FaceTarget
			SAR3 F 5 Fast A_CustomMissile("Bloodshot_Grav", 27, 0, frandom(-4, 4))
			TNT1 A 0 A_FaceTarget
			SAR3 F 5 Fast A_CustomMissile("Bloodshot_Grav", 27, 0, frandom(-4, 4))
			TNT1 A 0 A_FaceTarget
			SAR3 F 5 Fast A_CustomMissile("Bloodshot_Grav", 27, 0, frandom(-4, 4))
			TNT1 A 0 A_FaceTarget
			SAR3 F 5 Fast A_CustomMissile("Bloodshot_Grav", 27, 0, frandom(-4, 4))
			SAR3 F 0 A_FaceTarget
		Goto See
		Retaliate:
			SAR3 GE 6 Fast A_FaceTarget
			TNT1 A 0  A_CustomMissile("Bloodshot_Grav", 27, 0)
			SAR3 F 7 Fast A_CustomMissile("Bloodshot_Grav", 27, 0, -4)
			TNT1 A 0 A_FaceTarget
			TNT1 A 0  A_CustomMissile("Bloodshot_Grav", 27, 0)
			SAR3 F 7 Fast A_CustomMissile("Bloodshot_Grav", 27, 0, 4)
			SAR3 EG 6 Fast
		Goto See
		PainState:
			SAR3 H 2 Fast
			SAR3 H 2 Fast A_Pain
			SAR3 H 0 A_Jump(128, "Retaliate")
		Goto See
		XDeathState:
			TNT1 A 0 A_SpawnItemEx("GenericGibber_Low", 0, 0, 0, 0, 0, 0, 0, SXF_USEBLOODCOLOR)
		DeathState:
			SAR3 I 8
			SAR3 J 8 A_Scream
			SAR3 K 4
			SAR3 L 4 A_NoBlocking
			SAR3 M 4
			SAR3 N -1
		Stop
		RaiseState:
			SAR3 NMLKJI 5
		Goto See
	}
}

Actor Bloodshot_Grav : Bloodshot {
	Speed 22
	SeeSound "Weapons/bloodf"
	-NOGRAVITY
	States {
		Spawn:
			TNT1 A 0 NoDelay ThrustThingZ(0, 18, 0, 0)
		Goto Super::Spawn
	}
}

ACTOR CyberFiend : DnD_BaseHybridMonster { 
    Health 0x7FFFFFFF
	GibHealth -50
    Speed 10 
    Height 56
    Radius 30
    Mass 400
    PainChance 125
	MaxTargetRange 256
    +MISSILEMORE
	+MISSILEEVENMORE
    SeeSound "CyberFiend/sight"
    PainSound "CyberFiend/pain"
    DeathSound "CyberFiend/death"
    ActiveSound "CyberFiend/active"
    HitObituary "%o became the Cyber Fiend's dinner." 
    Obituary "The Cyber Fiend puked on %o"
	Species "Demon"
	+DONTHURTSPECIES
	Tag "Cyber Fiend"
	+ISMONSTER
    States { 
		SetInfo:
			TNT1 A 0 A_SetArg(4, DND_CYBERFIEND)
			TNT1 A 0 ACS_NamedExecuteWithResult("DnD Init Monster Data", DND_MWEIGHT_RARE2)
		Goto SpawnSetup

		IdleState:
			CYFN AB 10 A_GiveInventory("DnD_SightChecker", 1)
		Loop 
		SeeState:
			CYFN A 0 A_PlaySound("CyberFiend/walk")
			CYFN AABB 2 Fast A_Chase
			CYFN C 0 A_PlaySound("CyberFiend/walk")
			CYFN CCDD 2 Fast A_Chase
		Goto See
		MissileState:
			TNT1 A 0 A_Jump(256, "Puke1", "Puke2", "Puke3")
		Puke1:
			CYFN E 0 A_PlaySound("CyberFiend/Attack")
			CYFN EF 8 Fast A_FaceTarget
			CYFN G 8 Fast A_CustomMissile("Puke1")
		Goto See      
		Puke2:
			CYFN E 0 A_PlaySound("CyberFiend/Attack")
			CYFN EF 8 Fast A_FaceTarget
			CYFN G 8 Fast A_CustomMissile("Puke2")
		Goto See      
		Puke3:
			CYFN E 0 A_PlaySound("CyberFiend/Attack")
			CYFN EF 8 Fast A_FaceTarget
			CYFN G 8 Fast A_CustomMissile("Puke3")
		Goto See      
		MeleeState: 
			CYFN E 0 A_PlaySound("CyberFiend/Attack")
			CYFN EF 8 Fast A_FaceTarget
			CYFN G 8 Fast A_CustomMeleeAttack(8 * random(1, 8))
		Goto See 
		PainState:
			CYFN H 2 Fast
			CYFN H 2 Fast A_Pain
		Goto See
		XDeathState:
			TNT1 A 0 A_SpawnDebris("MetalScrap_More")
			TNT1 A 0 A_SpawnItemEx("GenericGibber_Low", 0, 0, 0, 0, 0, 0, 0, SXF_USEBLOODCOLOR)
		DeathState: 
			CYFN I 8 A_Scream
			CYFN I 0 A_FaceTarget
			CYFN J 0 A_SpawnItemEx("CyberFiendArm", 10, 0, 32, 0, 8, 0, 0, 128)
			CYFN J 8
			CYFN K 4 
			CYFN L 4 A_NoBlocking
			CYFN M 4 
			CYFN N -1 
		Stop    
		RaiseState: 
			CYFN NMLKJI 5 
		Goto See
    } 
}


//origional Blood demon Arm Decorate, it works so why not use it?
ACTOR CyberFiendArm {
	Radius 8
	Height 8
	Speed 8
	+DOOMBOUNCE
	+DROPOFF
	+Missile
	+CLIENTSIDEONLY
	States {
		Spawn:
			CYF1 ABCDEFGH 2
		Loop
		Death:
			CYF1 I -1
		Loop
	}
}

//FYI it actually pukes out body parts, a pinky's hand, a cacodemon eye and a player skull.
ACTOR Puke1 {
	Radius 8
	Height 8
	Speed 16
	Damage (3 * random(1, 8))
	DamageType "Physical"
	Stamina 1
	bouncefactor 0.8 
	bouncecount 8 
	+DOOMBOUNCE
	+DROPOFF
	+THRUGHOST
	+Missile
	States {
		Spawn:
			TNT1 A 0 NoDelay ACS_NamedExecuteAlways("DnD Pierce Check")
		SpawnLoop:
			PUK1 ABCDEFGH 2
		Loop
		Death:
			TNT1 A 0 A_PlaySound("misc/gibbed")
			TNT1 A 0 A_SpawnDebris("1Gib")
			TNT1 A 0 A_SpawnDebris("2Gib")
			TNT1 A 0 A_SpawnDebris("3Gib")
			TNT1 A 0 A_SpawnDebris("1Gib")
			TNT1 A 0 A_SpawnDebris("2Gib")
			TNT1 A 0 A_SpawnDebris("3Gib")
			TNT1 A 1 A_FadeOut(1)
		Stop
	}
}

ACTOR Puke2 : Puke1 {
	States {
		Spawn:
			PUK2 ABCDEFGH 2
		Loop
	}
}

ACTOR Puke3 : Puke1 {
	States {
		Spawn:
			PUK3 A 2
		Loop
	}
}

Actor 1GIB {
	health 1
	radius 6
	height 6
	mass 1
	+CORPSE
	+NOTELEPORT
	+CLIENTSIDEONLY
	States {
		Spawn:
			1GIB A 4
		loop
		Crash:
			1GIB A 1050
			TNT1 A 1 A_FadeOut(1)
		Stop
	}
}

Actor 2GIB : 1GIB {
	States {
		Spawn:
			2GIB A 4
		loop
		Crash:
			2GIB A 1050
			TNT1 A 1 A_FadeOut(1)
		Stop
	}
}

Actor 3GIB : 1GIB {
	States {
		Spawn:
			3GIB A 4
		loop
		Crash:
			3GIB A 1050
			TNT1 A 1 A_FadeOut(1)
		Stop
	}
}

Actor IGIB : 1GIB {
	States {
		Spawn:
			IGIB A 4
		loop
		Crash:
			IGIB A 1050
			TNT1 A 1 A_FadeOut(1)
		Stop
	}
}

Actor IGIB2 : 1GIB {
	States {
		Spawn:
			IGIB B 4
		loop
		Crash:
			IGIB B 1050
			TNT1 A 1 A_FadeOut(1)
		Stop
	}
}

ACTOR FlameDemon : DnD_BaseMeleeMonster {
	Health 0x7FFFFFFF
	GibHealth -50
	Speed 16
	Height 56
	Radius 30
	Mass 400
	PainChance 150
	REACTIONTIME 8
	+NORADIUSDMG
	SeeSound "demon/sight"
	PainSound "demon/pain2"
	DeathSound "demon/death2"
	ActiveSound "demon/active"
	MeleeSound "demon/melee"
	HitObituary "A charred demon hunted %o down."
	AttackSound "demon/melee"
	Translation "16:39=101:111", "40:47=5:8", "79:79=8:8", "190:191=7:8", "210:223=87:100", "224:224=161:161"
	Species "Demon"
	+DONTHURTSPECIES   
	Tag "Flame Demon"
	+ISMONSTER
	States {
		SetInfo:
			TNT1 A 0 A_SetArg(4, DND_FLAMEDEMON)
			TNT1 A 0 ACS_NamedExecuteWithResult("DnD Init Monster Data", DND_MWEIGHT_UNCOMMON)
		Goto SpawnSetup

		IdleState:
			SARG AB 8 A_GiveInventory("DnD_SightChecker", 1)
		Loop
		SeeState:
			SARG AABBCCDD 2 Fast A_Chase
		Goto See
		MeleeState:
			SARG EF 8 Fast A_FaceTarget
			SARG G 8 Fast A_CustomMeleeAttack(6 * random(1, 8))
		Goto See
		PainState:
			SARG H 2 Fast
			SARG H 2 Fast A_Pain
		Goto See
		XDeathState:
			TNT1 A 0 A_SpawnItemEx("GenericGibber_Low", 0, 0, 0, 0, 0, 0, 0, SXF_USEBLOODCOLOR)
		DeathState:
			SARG I 6
			SARG J 6 A_Scream
			SARG K 4
			SARG L 4 A_NoBlocking
			SARG M 4
			SARG N -1
		Stop  
		RaiseState:
			SARG NMLKJI 4
		Goto See
   }
}

ACTOR StoneImp : DnD_BaseMeleeMonster {
	Health 0x7FFFFFFF
	GibHealth -50
	Radius 20
	Height 56
	Speed 6
	Mass 400
	SeeSound "imp/sight"
	PainSound "imp/pain"
	DeathSound "imp/death"
	ActiveSound "imp/active"
	Obituary "%o was smashed by a stone imp."
	Species "Demon"
	+ISMONSTER
	+DONTHURTSPECIES  
	+NOBLOODDECALS
	+NOPAIN
	+DONTRIP
	+NOBLOOD
	Tag "Stone Imp"
	States {
		SetInfo:
			TNT1 A 0 A_SetArg(4, DND_STONEIMP)
		Goto SpawnSetup
	
		IdleState:
			GIMP AB 10 A_GiveInventory("DnD_SightChecker", 1)
		Loop
		SeeState:
			GIMP AABBCCDD 3 Fast A_Chase
		Goto See
		MeleeState:
			GIMP EF 8 Fast A_FaceTarget
			GIMP G 6 Fast A_CustomMeleeAttack(12 * random(1, 4), "stoneimp/hit", "", "Melee")
		Goto See
		PainState:
			GIMP H 2 Fast
			GIMP H 2 Fast A_Pain
		Goto See
		XDeathState:
			TNT1 AAAA 0 A_SpawnItemEx("StoneBitsSpawner", 0, 0, frandom(16.0, 32.0))
		DeathState:
			GIMP I 6
			GIMP J 6 A_Scream
			GIMP K 5
			GIMP L 5 A_Fall
			GIMP M 5
			GIMP N -1
		Stop
		RaiseState:
			GIMP ML 8
			GIMP KJI 6
		Goto See
	}
}

actor StoneDemon : DnD_BaseHybridMonster {
	Scale 1.1
	HitObituary "%o was smashed by a stone demon."
	Health 0x7FFFFFFF
	GibHealth -50
	PainChance 100
	Speed 8
	Radius 30
	Height 56
	Mass 9999999
	MissileType StoneDemonBoulder
	MissileHeight 24
	SeeSound "stone/sight"
	AttackSound "demon/melee"
	PainSound "demon/pain"
	DeathSound "stone/death"
	ActiveSound "demon/active"
	Species "Demon"
	+ISMONSTER
	+NOBLOOD
	+DONTHURTSPECIES
	Tag "Stone Demon"
	States {
		SetInfo:
			TNT1 A 0 A_SetArg(4, DND_STONEDEMON)
			TNT1 A 0 ACS_NamedExecuteWithResult("DnD Init Monster Data", DND_MWEIGHT_RARE2)
		Goto SpawnSetup

		IdleState:
			STON AB 10 A_GiveInventory("DnD_SightChecker", 1)
		Loop
		SeeState:
			STON AABBCCDD 2 Fast A_Chase
		Goto See
		MissileState:
			STON EF 6 Fast A_FaceTarget
			STON E 6 Fast A_MissileAttack
		Goto See
		MeleeState:
			STON EF 8 Fast A_FaceTarget
			STON G 0 A_CustomMeleeAttack(random(1, 10) * 4)
			STON G 6 Fast A_CustomMeleeAttack(random(1, 10) * 4)
			STON EF 8 Fast A_FaceTarget
			STON G 6 Fast A_CustomMeleeAttack(random(1, 10) * 4)
		Goto See
		PainState:
			STON H 3 Fast
			STON H 3 Fast A_Pain
		Goto See
		DeathState:
			TNT1 AAAAAAAAAAA 0 A_CustomMissile("StoneDemonMiniBoulder",16,0,random(0,359),2,random(0,40))
		DeathSkipExtra:
			STON I 5
			STON J 5 A_Scream
			STON K 5
			STON L 5 A_NoBlocking
			STON MN 5
			STON OP 4
			STON Q -1
		Stop
		XDeathState:
			TNT1 AAAA 0 A_SpawnItemEx("StoneBitsSpawner", 0, 0, frandom(16.0, 32.0))
		Goto DeathSkipExtra
		RaiseState:
			STON NMLKJI 5
		Goto See
	}
}

actor StoneDemonBoulder {
	PROJECTILE
	-NOGRAVITY
	+DOOMBOUNCE
	+BOUNCEONACTORS
	+DONTBLAST
	SeeSound "stone/bounce"
	Radius 6
	Height 6
	Scale 0.7
	Speed 20
	VSpeed 3
	Damage (random(4, 7))
	DamageType "Physical"
	Stamina 1
	States {
		Spawn:
			TNT1 A 0 NoDelay ACS_NamedExecuteAlways("DnD Pierce Check")
		SpawnLoop:
			STNB ABCDEFGH 3
		Loop
		Death:
			STNB H 200
		Stop
	}
}

actor StoneDemonMiniBoulder : StoneDemonBoulder {
	Damage (1)
	Scale 0.35
	SeeSound ""
}

Actor SoulEater : DnD_BaseHybridMonster {
	Health 0x7FFFFFFF
	GibHealth -50
	PainChance 128
	Speed 12
	Radius 30
	Height 56
	Mass 450
	+LongMeleeRange
	+DontHurtSpecies
	Obituary "%o had %p soul stolen by a Soul Eater."
	HitObituary "%o was eaten by a Soul Eater."
	SeeSound "SoulEater/See"
	AttackSound "Monster/sg2atk"
	PainSound "SoulEater/Pain"
	DeathSound "SoulEater/Die"
	ActiveSound "SoulEater/Act"
	Tag "Soul Eater"
	MaxTargetRange 512
	+ISMONSTER
	States {
		SetInfo:
			TNT1 A 0 A_SetArg(4, DND_SOULEATER)
			TNT1 A 0 ACS_NamedExecuteWithResult("DnD Init Monster Data", DND_MWEIGHT_RARE1)
		Goto SpawnSetup
	
		IdleState:
			SOEA AB 10 A_GiveInventory("DnD_SightChecker", 1)
		Loop
		SeeState:
			SOEA AABBCCDD 2 Fast A_Chase
		Goto See
		MeleeState:
			SOEA EF 8 Fast A_FaceTarget
			TNT1 A 0 A_CustomMissile("SoulEaterProj",28)
			SOEA G 8 Fast A_CustomMeleeAttack(random(1, 10) * 4)
		Goto See
		MissileState:
			SOEA EF 8 Fast A_FaceTarget
			SOEA G 8 Fast A_CustomMissile("SoulEaterProj",28)
		Goto See
		PainState:
			SOEA H 2 Fast
			SOEA H 2 Fast A_Pain
		Goto See
		XDeathState:
			TNT1 A 0 A_SpawnItemEx("GenericGibber_Low", 0, 0, 0, 0, 0, 0, 0, SXF_USEBLOODCOLOR)
		DeathState:
			SOEA I 8
			SOEA J 8 A_Scream
			SOEA K 4
			SOEA L 4 A_NoBlocking
			SOEA M 4
			SOEA N -1
		Stop
		RaiseState:
			SOEA NMLKJI 5
		Goto See
	}
}

Actor SoulEaterProj : MummyFX1 {
	Damage (random(8, 24))
	DamageType "MagicalYellow"
	Stamina 8
	Speed 12
	
	States {
		Spawn:
			TNT1 A 0 NoDelay ACS_NamedExecuteAlways("DnD Pierce Check")
		Goto Super::Spawn
		Death:
			TNT1 A 0 A_SpawnItemEx("OrangeParticleSpawner", 0, 0, 0, 0, 0, 0, 0, 128)
		Goto Super::Death
	}
}

// no resurrect
ACTOR BigBruty : DnD_BaseMeleeMonster_NoRes {
	Health 0x7FFFFFFF
	GibHealth -50
	Radius 30
	Height 56
	mass 999999
	Speed 12
	XScale 1.0
	YScale 1.1
	PainChance 48
	MeleeRange 96
	+ISMONSTER
	+NOFEAR
	PainSound "Bruty/Pain"
	DeathSound "Bruty/Die"
	ActiveSound "Bruty/Act"
	SeeSound "Bruty/See"
	MeleeRange 72
	Obituary "%o was nuked by a Big Bruty."
	Tag "Big Bruty"
	States {
		SetInfo:
			TNT1 A 0 A_SetArg(4, DND_BRUTY)
			TNT1 A 0 ACS_NamedExecuteWithResult("DnD Init Monster Data", DND_MWEIGHT_RARE1)
		Goto SpawnSetup

		IdleState:
			BBRT AB 10 A_GiveInventory("DnD_SightChecker", 1)
		Loop
		SeeState:
			BBRT AABB 3 Fast A_Chase
			TNT1 A 0 A_PlaySound("Bruty/walk")
			BBRT CCDD 3 Fast A_Chase
			BBRT D 0 A_PlaySound("Bruty/walk")
		Goto See
		PainState:
			TNT1 AA 0 A_Pain
			BBRT EEE 4 Fast A_Chase
		Goto See
		MeleeState:
			BBRT F 4 Fast A_Die("SelfExplosion")
			BBRT F 2 Fast
		Goto Death
		XDeathState:
			TNT1 A 0 A_SpawnItemEx("GenericGibber_Low", 0, 0, 0, 0, 0, 0, 0, SXF_USEBLOODCOLOR)
		DeathState:
			BBRT F 1
			TNT1 A 0 A_Scream
			BBRT F 15 A_Scream
			TNT1 A 0 A_NoBlocking
			BBRT G 8 A_Fall
			TNT1 A 0 A_SpawnItem("BruteExplosion1",0,32)
		Goto End
		Death.SelfExplosion:
			TNT1 A 0 A_SpawnItem("BruteExplosion2",0,32)
			TNT1 A 0 A_NoBlocking
			BBRT G 8 A_Fall
		End:
			TNT1 A 0 A_SpawnItemEx("GenericGibber_Medium", 0, 0, 0, 0, 0, 0, 0, SXF_USEBLOODCOLOR)
			BBRT H 4	
			BBRT IJKLM 4
			BBRT N -1
		Stop
	}
}

Actor BruteExplosion1 : BaseExplosionDamage {
	DamageType "Explosive"
	Stamina 4
	States {
		Spawn:
			TNT1 A 0 NoDelay ACS_NamedExecuteAlways("DnD Pierce Check")
			TNT1 A 0 A_Explode(36, 128, 0)
			TNT1 AAAAAA 0 A_SpawnDebris("NashGore_FlyingBlood")
			TNT1 AAAAAAAAAA 1 A_SpawnItemEx("ExplosionFX", 0, 0, 16, random(-3,3), random(-3,3), random(0,4))
		Stop
	}
}

Actor BruteExplosion2 : BaseExplosionDamage {
	DamageType "Explosive"
	Stamina 4
	States {
		Spawn:
			TNT1 A 0 NoDelay ACS_NamedExecuteAlways("DnD Pierce Check")
			TNT1 A 0 A_Explode(72, 128, 0)
			TNT1 AAAAAA 0 A_SpawnDebris("NashGore_FlyingBlood")
			TNT1 AAAAAAAAAA 1 A_SpawnItemEx("ExplosionFX", 0, 0, 16, random(-3,3), random(-3,3), random(0,4))
		Stop
	}
}

actor Scavenger : DnD_ArchVileHybridBase {
	obituary "%o was wrecked by a Scavenger."
	hitobituary "A Scavenger had %o for lunch."
	Health 0x7FFFFFFF
	Gibhealth -10
	radius 20
	height 56
	mass 120
	speed 7
	painchance 128
	+DONTHURTSPECIES
	seesound "monster/vulsit"
	painsound "monster/vulpai"
	deathsound "monster/vuldth"
	activesound "monster/vulact"
	meleesound "monster/vulhit"
	Translation "1:2=[2,2,1]:[1,1,1]", "7:8=0:0", "9:12=[18,14,12]:[3,2,2]", "15:15=[5,4,3]:[5,4,3]", "78:78=[12,9,8]:[12,9,8]", "127:131=[1,1,1]:[165,133,111]", "152:159=[124,94,73]:[24,20,17]"
	Species "Demon"
	Tag "Scavenger"
	+ISMONSTER
	states {
		SetInfo:
			TNT1 A 0 A_SetArg(4, DND_SCAVENGER)
			TNT1 A 0 ACS_NamedExecuteWithResult("DnD Init Monster Data", DND_MWEIGHT_RARE2)
		Goto SpawnSetup
	
		IdleState:
			VULG AB 10 A_GiveInventory("DnD_SightChecker", 1)
		loop
		SeeState:
			TNT1 A 0 A_JumpIfInventory("ScavengerCounter", 0, "NoRaise")
			VULG AABBCCDD 3 Fast A_VileChase
		Goto See
		NoRaise:
			VULG AABBCCDD 3 Fast A_Chase
		Goto See
		MeleeState:
			VULG E 8 Fast A_FaceTarget
			VULG F 1 Fast A_PlaySound("monster/vulswg")
			VULG F 7 Fast A_FaceTarget
			VULG G 6 Fast A_CustomMeleeAttack(4 * random(1, 8))
		goto See
		MissileState:
			VULG EF 8 Fast A_FaceTarget
			VULG G 6 Fast A_CustomMissile("ScavengerBall",37,0,0,0,0)
		goto See
		HealState:
			TNT1 A 0 A_GiveInventory("ScavengerCounter", 1)
			VULG EFG 3 Fast
		Goto See
		PainState:
			VULG H 2 Fast
			VULG H 2 Fast A_Pain
		goto See
		XDeathState:
			TNT1 A 0 A_SpawnItemEx("GenericGibber_Low", 0, 0, 0, 0, 0, 0, 0, SXF_USEBLOODCOLOR)
		DeathState:
			VULG I 8
			VULG J 8 A_Scream
			VULG KL 6
			VULG M 6 A_NoBlocking
			VULG N -1
		stop  
		RaiseState:
			VULG ML 8
			VULG KJI 6
		goto See
	}
}

Actor ScavengerBall {
	Radius 6
	Height 8
	Speed 16
	Damage (4 * random(1, 8))
	Projectile
	SeeSound "imp/attack"
	DeathSound "imp/shotx"
	Damagetype "FireBlue"
	Stamina 4
	Decal BaronScorch
	Translation "111:123=197:207", "124:127=242:245"
	+DONTBLAST
	States {
		Spawn:
			TNT1 A 0 NoDelay ACS_NamedExecuteAlways("DnD Pierce Check")
		SpawnLoop:
			BAL7 AAAABBBB 1 Bright A_FadeOut(0.075)
		Loop
		Death:
			TNT1 A 0 A_SpawnItemEx("BlueParticleSpawner", 0, 0, 0, 0, 0, 0, 0, 128)
			TNT1 AAA 0 A_SpawnItemEx("ExplosionFX5", 0, 0, 0, frandom(-1, 1), frandom(-1, 1), frandom(-1, 1))
			TNT1 AAA 0 A_CustomMissile("FireballSmoke", 0, 0, random(0,360), 2, random(0,360))
			BAL7 CDE 6 Bright
		Stop
	}
}

Actor ScavengerCounter : Inventory {
	inventory.maxamount 3
}

Actor Nhumcign : DnD_BaseMeleeMonster {
	Translation "0:255=%[0.00,0.00,0.00]:[1.17,0.10,1.29]", "0:47=0:47", "80:127=80:127", "152:235=152:235", "240:255=240:255"
	Health 0x7FFFFFFF
	GibHealth -50
	PainChance 96
	Speed 8
	Obituary "%o had %p ass bitten by a Nhumcign."
	Hitobituary "%o had %p ass bitten by a Nhumcign."
	SeeSound "PurpleDemon/See"
	AttackSound "Monster/sg2atk"
	PainSound "PurpleDemon/Pain"
	DeathSound "PurpleDemon/Die"
	ActiveSound "PurpleDemon/Act"
	Tag "Nhumcign"
	Species "Demon"
	Radius 30
	Height 56
	Mass 400
	+ISMONSTER
	+DONTHURTSPECIES
	States {
		SetInfo:
			TNT1 A 0 A_SetArg(4, DND_NHUMCIGN)
			TNT1 A 0 ACS_NamedExecuteWithResult("DnD Init Monster Data", DND_MWEIGHT_RARE2)
		Goto SpawnSetup
	
		IdleState:
			SOEA AB 10 A_GiveInventory("DnD_SightChecker", 1)
		Loop
		SeeState:
			TNT1 A 0 A_JumpIfInventory("NhumAngry", 1, "AngrySee")
			TNT1 A 0 A_GiveInventory("NhumHealthCheck", 1)
			SOEA AA 2 Fast A_Chase
			TNT1 A 0 A_GiveInventory("NhumHealthCheck", 1)
			SOEA B 2 Fast A_Chase
			TNT1 A 0 A_GiveInventory("DemonJumpCheck", 1)
			SOEA B 2 Fast A_Chase
			TNT1 A 0 A_JumpIfInventory("DemonGoJump", 1, "MissileGo")
			TNT1 A 0 A_GiveInventory("NhumHealthCheck", 1)
			SOEA C 2 Fast A_Chase
			TNT1 A 0 A_JumpIfInventory("NhumAngry", 1, "AngrySee")
			SOEA C 2 Fast A_Chase
			SOEA D 2 Fast A_Chase
			TNT1 A 0 A_GiveInventory("DemonJumpCheck", 1)
			SOEA D 2 Fast A_Chase
			SOEA D 0 A_JumpIfInventory("DemonGoJump", 1, "MissileGo")
		Goto See
		AngrySee:
			SOEA AA 1 Fast A_Chase("", "", CHF_NOPLAYACTIVE)
			TNT1 A 0 A_SpawnItem("NhumWalkFXA")
			SOEA AA 1 Fast A_Chase
			TNT1 A 0 A_SpawnItem("NhumWalkFXA")
			TNT1 A 0 A_GiveInventory("DemonJumpCheck", 1)
			SOEA BB 1 Fast A_Chase("", "", CHF_NOPLAYACTIVE)
			TNT1 A 0 A_SpawnItem("NhumWalkFXB")
			SOEA BB 1 Fast A_Chase
			TNT1 A 0 A_JumpIfInventory("DemonGoJump", 1, "MissileGo")
			TNT1 A 0 A_SpawnItem("NhumWalkFXB")
			TNT1 A 0 A_GiveInventory("DemonJumpCheck", 1)
			SOEA CC 1 Fast A_Chase("", "", CHF_NOPLAYACTIVE)
			TNT1 A 0 A_SpawnItem("NhumWalkFXC")
			TNT1 A 0 A_JumpIfInventory("DemonGoJump", 1, "MissileGo")
			SOEA CC 1 Fast A_Chase
			TNT1 A 0 A_SpawnItem("NhumWalkFXC")
			SOEA DD 1 Fast A_Chase("", "", CHF_NOPLAYACTIVE)
			TNT1 A 0 A_SpawnItem("NhumWalkFXD")
			SOEA DD 1 Fast A_Chase
			SOEA D 0 A_SpawnItem("NhumWalkFXD")
		Goto See
		MeleeState:
			SOEA E 5 Fast A_FaceTarget
			SOEA F 2 Fast A_FaceTarget
			SOEA F 3 Fast A_CustomMeleeAttack(random(1, 10) * 4)
			SOEA G 5 Fast
		Goto See
		MissileGo:
			SOEA EEEE 3 Fast A_FaceTarget
			TNT1 A 0 A_TakeInventory("DemonGoJump", 1)
			TNT1 A 0 A_PlaySound("PurpleDemon/Jump")
			TNT1 A 0 ACS_NamedExecuteAlways("DnD Monster Leap")
			SOEA F 3 Fast
			SOEA F 4 Fast ACS_NamedExecuteAlways("DnD Monster Leap Finish")
		Goto See
		PainState:
			TNT1 A 0 A_TakeInventory("DemonGoJump", 1)
			TNT1 A 0 A_GiveInventory("NhumHealthCheck", 1)
			SOEA H 2 Fast
			SOEA H 2 Fast A_Pain
		Goto See
		XdeathState:
			TNT1 A 0 A_SpawnItemEx("GenericGibber_Low", 0, 0, 0, 0, 0, 0, 0, SXF_USEBLOODCOLOR)
		DeathState:
			SOEA I 8 A_ChangeFlag("NOPAIN", 0)
			TNT1 A 0 A_TakeInventory("NhumAngry", 1)
			SOEA J 8 A_Scream
			SOEA K 4
			SOEA L 4 A_NoBlocking
			SOEA M 4
			SOEA N -1
		Stop
		RaiseState:
			SOEA NMLKJI 5
		Goto See
	}
}

Actor DemonLand : BaseExplosionDamage {
	DamageType "Physical"
	Stamina 1
	Obituary "%o was traumatized by a Nhumcign."
	States {
		Spawn:
			TNT1 A 0 NoDelay ACS_NamedExecuteAlways("DnD Pierce Check")
			TNT1 A 1 A_Explode(36, 84, 0)
		Stop
	}
}

Actor NhumWalkFXA {
	Height 2
	Radius 2
	Renderstyle Translucent
	Alpha 0.75
	Translation "0:255=%[0.00,0.00,0.00]:[1.17,0.10,1.29]", "0:63=0:63", "80:127=80:127", "152:255=152:255"
	+NOINTERACTION
	+CLIENTSIDEONLY
	States {
		Spawn:
			SOEA A 1 A_FadeOut(0.15)
		Loop
	}
}

Actor NhumWalkFXB : NhumWalkFXA {
	States {
		Spawn:
			SOEA B 1 A_FadeOut(0.15)
		Loop
	}
}

Actor NhumWalkFXC : NhumWalkFXA {
	States {
		Spawn:
			SOEA C 1 A_FadeOut(0.15)
		Loop
	}
}

Actor NhumWalkFXD : NhumWalkFXA {
	States {
		Spawn:
			SOEA D 1 A_FadeOut(0.15)
		Loop
	}
}

Actor NhumAngry : DnD_Boolean { }

Actor NhumHealthCheck : DnD_Activator {
	States {
		Pickup:
			TNT1 A 0 A_JumpIfInventory("NhumAngry", 1, "Nothing")
			TNT1 A 0 A_JumpIFHealthLower(3 * ACS_ExecuteWithResult(961, 7) / 5, "Anger")
		Stop
		Nothing:
			TNT1 A 0
		Stop
		Anger:
			TNT1 A 0 A_GiveInventory("NhumAngry", 1)
			TNT1 A 0 A_ChangeFlag("NOPAIN", 1)
		Stop
	}
}

Actor DemonLanded : DnD_Activator {
	States {
		Use:
			TNT1 A 0 A_SpawnItem("DemonLand")
			TNT1 A 0 A_PlaySound("PurpleDemon/Land", 6)
			TNT1 A 0 A_TakeInventory("DemonGoJump", 1)
		Stop
	}
}

Actor DemonGoJump : DnD_Boolean { }

Actor DemonJumpCooldown : PowerDamage {
	damagefactor "normal", 1.0
	powerup.duration -1
}

Actor DemonJumpCheck : DnD_Activator {
	States {
		Pickup:
			TNT1 A 0 A_JumpIfCloser(80, "Nothing")
			TNT1 A 0 A_JumpIfCloser(384, "CheckSight")
		Stop
		CheckSight:
			TNT1 A 0 A_JumpIfTargetInLOS("Jump")
		Stop
		Jump:
			TNT1 A 0 A_JumpIfInventory("DemonJumpCooldown", 1, "Nothing")
			TNT1 A 0 A_GiveInventory("DemonJumpCooldown", 1)
			TNT1 A 0 A_GiveInventory("DemonGoJump", 1)
		Stop
		Nothing:
			TNT1 A 0
		Stop
	}
}

Actor DemonFlightDamager : DnD_Activator {
	States {
		Pickup:
			TNT1 A 0 A_CustomMissile("DemonFlightAtk", 24, 0, 0, CMF_AIMDIRECTION)
		Stop
	}
}

Actor DemonFlightAtk {
	PROJECTILE
	Radius 6
	Height 12
	Damage (3 * random(2, 5))
	DamageType "Physical"
	Stamina 1
	+DONTBLAST
	+THRUSPECIES
	Species "Demon"
	Speed 56
	States {
		Spawn:
			TNT1 A 1 NoDelay ACS_NamedExecuteAlways("DnD Pierce Check")
		Stop
		Death:
			TNT1 A 1
		Stop
	}
}

actor Satyr : DnD_BaseMeleeMonster {
    Health 0x7FFFFFFF
	GibHealth -50
    Radius 24
    Height 56
    Scale 0.9
    Speed 8
    PainChance 84
    Mass 350
    SeeSound "Satyr/See"
    PainSound "Satyr/Hit"
    DeathSound "Satyr/Die"
    ActiveSound "Satyr/Act"
    MeleeSound "baron/melee"
    HitObituary "%o was mauled by a satyr."
	Tag "Satyr"
	Species "Demon"
	+ISMONSTER
	+DONTHURTSPECIES	
    States {
		SetInfo:
			TNT1 A 0 A_SetArg(4, DND_SATYR)
			TNT1 A 0 ACS_NamedExecuteWithResult("DnD Init Monster Data", DND_MWEIGHT_RARE1)
		Goto SpawnSetup
	
		IdleState:
			STYR AB 10 A_GiveInventory("DnD_SightChecker", 1)
		Loop
		SeeState:
			STYR AABBCCDD 3 Fast A_Chase
		Goto See
		MeleeState:
			STYR E 2 Fast A_FaceTarget
			TNT1 A 0 A_Recoil(-1.6)
			STYR E 3 Fast A_FaceTarget
			TNT1 A 0 A_Recoil(-2.0)
			STYR F 2 Fast A_FaceTarget
			TNT1 A 0 A_Recoil(-2.4)
			STYR F 3 Fast A_FaceTarget
			TNT1 A 0 A_Recoil(-2.8)
			TNT1 A 0 A_Stop
			STYR G 5 Fast A_CustomMeleeAttack(random(12, 24), "baron/melee", "")
			STYR P 2 Fast A_FaceTarget
			TNT1 A 0 A_Recoil(-1.6)
			STYR P 3 Fast A_FaceTarget
			TNT1 A 0 A_Recoil(-2.0)
			STYR Q 2 Fast A_FaceTarget
			TNT1 A 0 A_Recoil(-2.4)
			STYR Q 3 Fast A_FaceTarget
			TNT1 A 0 A_Recoil(-2.8)
			STYR R 5 Fast A_CustomMeleeAttack(random(12, 24), "baron/melee", "")
		Goto See
		PainState:
			STYR H 2 Fast
			STYR H 2 Fast A_Pain
		Goto See
		XDeathState:
			TNT1 A 0 A_SpawnItemEx("GenericGibber_Low", 0, 0, 0, 0, 0, 0, 0, SXF_USEBLOODCOLOR)
		DeathState:	
			STYR I 5
			STYR J 5 A_Scream
			STYR K 6
			STYR L 7 A_Fall
			STYR M 4
			STYR N 4
			STYR O -1
			Stop	
		RaiseState:
			STYR ONMLKJI 8
		Goto See
    }
}

Actor EarthGolem : DnD_BaseHybridMonster { 
    Health 0x7FFFFFFF
	GibHealth -50
    Speed 6
    Height 56
    Radius 22
    Mass 1024
    PainChance 128
    ReactionTime 8 
    SeeSound "EarthGolem/See"
    PainSound "EarthGolem/Pain"
    DeathSound "EarthGolem/Death"
    ActiveSound "EarthGolem/Act"
    HitObituary "%o became part of mother nature." 
	Species "Demon"
	Tag "Earth Golem"
	BloodColor "10 A5 10"
	MeleeRange 72
	MaxTargetRange 384
	+ISMONSTER
	+DONTHURTSPECIES
    States {
		SetInfo:
			TNT1 A 0 A_SetArg(4, DND_EARTHGOLEM)
			TNT1 A 0 ACS_NamedExecuteWithResult("DnD Init Monster Data", DND_MWEIGHT_VERYRARE)
		Goto SpawnSetup

		IdleState:
		   GOL1 AB 10 A_GiveInventory("DnD_SightChecker", 1)
	    Loop 
		SeeState:
			GOL1 AABBCCDD 2 Fast A_Chase
	    Goto See 
		MeleeState: 
			TNT1 A 0 A_PlaySound("Golem/Swing")
			GOL1 E 8 Fast A_FaceTarget
			GOL1 F 2 Fast A_FaceTarget
			TNT1 A 0 A_CustomMeleeAttack(5 * random(4, 6), "Golem/Hit")
			GOL1 FG 6 Fast 
		Goto See
		MissileState:
			GOl1 X 5 Fast A_FaceTarget
			TNT1 A 0 A_JumpIfCloser(76, "Melee")
			GOl1 X 5 Fast A_FaceTarget
			TNT1 A 0 A_JumpIfCloser(76, "Melee")
			GOl1 X 5 Fast A_FaceTarget
			TNT1 A 0 A_JumpIfCloser(76, "Melee")
			GOl1 X 5 Fast A_FaceTarget
			GOL1 Y 6 Fast Bright A_CustomMissile("EarthGolemShot", 32)
			TNT1 A 0 A_FaceTarget
			TNT1 A 0  A_CustomMissile("EarthGolemShot", 32, 0, 4)
			GOL1 Y 3 Fast Bright A_CustomMissile("EarthGolemShot", 32, 0, -4)
		Goto See
		PainState:
		   GOL1 H 4 Fast
		   GOL1 H 4 Fast A_Pain
	    Goto See
		XDeathState:
			TNT1 AAAAA 0 A_CustomMissile("EarthGolemPieces", random(16, 32), 0, random(0, 360), CMF_TRACKOWNER | CMF_AIMDIRECTION, 5 * random(-1, 18))
		DeathState:
		   GOL1 I 5
		   GOL1 J 4 A_Scream
		   GOL1 KKKK 1 A_CustomMissile("EarthGolemPieces", random(16, 32), 0, random(0, 360), CMF_TRACKOWNER | CMF_AIMDIRECTION, 5 * random(-1, 18))
		   TNT1 A 0 A_SpawnItemEx("GolemSoul", 0, 0, 10, 0, 0, 1)
		   TNT1 A 0 A_NoBlocking
		   GOL1 LLLLMMMM 1 A_CustomMissile("EarthGolemPieces", random(16, 32), 0, random(0, 360), CMF_TRACKOWNER | CMF_AIMDIRECTION, 5 * random(-1, 18))
		   GOL1 NO 4 
		   GOL1 P -1 
	    Stop
		RaiseState: 
		   GOL1 ONMLKJI 3
	    Goto See 
    } 
}

Actor EarthGolemShot : VulgarShot {
	Speed 18
	Damage (5 * random(2, 4))
	DamageType "Poison"
	Stamina 128
	States {
		Spawn:
			TNT1 A 0 NoDelay ACS_NamedExecuteAlways("DnD Pierce Check")
		SpawnLoop:
			FVUL AA 1 Bright A_SpawnItemEx("BarbTrail",0,0,0,0,0,0,0,128,0)
			TNT1 A 0 A_Weave(2.0, 0, 4.0, 0)
			FVUL AB 1 Bright A_SpawnItemEx("BarbTrail",0,0,0,0,0,0,0,128,0)
			TNT1 A 0 A_Weave(2.0, 0, 4.0, 0)
			FVUL BB 1 Bright A_SpawnItemEx("BarbTrail",0,0,0,0,0,0,0,128,0)
			TNT1 A 0 A_Weave(2.0, 0, 4.0, 0)
		loop
	}
}

Actor EarthGolemPieces {
	Damage (1)
	DamageType "Poison"
	Stamina 128
	PROJECTILE
	Speed 16
	Height 8
	Radius 5
	+FORCEPAIN
	-NOGRAVITY
	States {
		Spawn:
			TNT1 A 0 NoDelay ACS_NamedExecuteAlways("DnD Pierce Check")
		SpawnLoop:
			BPBL AB 2 Bright
		Loop
		Death:
			BPBL CDEFG 2 Bright
		Stop
	}
}

ACTOR PurebredDemon : DnD_BaseHybridMonster { 
    Health 0x7FFFFFFF
	GibHealth -50
    Speed 14
    Mass 2048
    PainChance 128
    REACTIONTIME 8 
	Radius 30
	Height 56
    SeeSound "demon/sight"
    PainSound "demon/pain2"
    DeathSound "demon/death"
    ActiveSound "demon/active"
	AttackSound ""
    HitObituary "%o fought a Purebred Demon and lost." 
	Species "Demon"
	Tag "Purebred Demon"
	MaxTargetRange 324
	+DONTHURTSPECIES
	+NOINFIGHTING
	+ISMONSTER
	Scale 1.1
	damage (3 * random(1, 6))
    States { 
		SetInfo:
			TNT1 A 0 A_SetArg(4, DND_PUREBREDDEMON)
			TNT1 A 0 ACS_NamedExecuteWithResult("DnD Init Monster Data", DND_MWEIGHT_EPIC)
		Goto SpawnSetup

		IdleState:
			BBRQ AB 10 A_GiveInventory("DnD_SightChecker", 1)
		Loop 
		SeeState:
			TNT1 A 0 ACS_NamedExecuteWithResult("DnD Monster Trait Take", 0, DND_ISBLOCKING)
			TNT1 A 0 A_ChangeFlag("NOBLOOD", 0)
		SeeLoop:
			BBRQ A 3 Fast A_Chase
			BBRQ A 2 Fast A_Chase
			BBRQ B 3 Fast A_Chase
			BBRQ B 2 Fast A_Chase
			BBRQ C 3 Fast A_Chase
			BBRQ C 2 Fast A_Chase
			BBRQ D 3 Fast A_Chase
			BBRQ D 2 Fast A_Chase
		Goto See 
		MeleeState: 
			TNT1 A 0 A_PlaySound("demon/melee")
			BBRQ EF 6 Fast A_FaceTarget
			BBRQ G 6 Fast A_CustomMeleeAttack(5 * random(1, 8))
		Goto See 
		MissileState:
			TNT1 A 0 A_PlaySound("demon/sight")
			TNT1 A 0 A_PlaySound("PurebredDemon/Thud", CHAN_BODY)
			BBRQ B 8 Fast A_FaceTarget
			BBRQ C 7 Fast A_FaceTarget
			TNT1 A 0 A_PlaySound("PurebredDemon/Thud", CHAN_BODY)
			BBRQ B 6 Fast A_FaceTarget
			BBRQ C 5 Fast A_FaceTarget
			TNT1 A 0 A_PlaySound("PurebredDemon/Thud", CHAN_BODY)
			BBRQ B 4 Fast A_FaceTarget
			BBRQ C 3 Fast A_FaceTarget
			TNT1 A 0 A_ChangeFlag("NOBLOOD", 1)
			BBRQ D 2 Fast ACS_NamedExecuteWithResult("DnD Monster Trait Give", DND_ISBLOCKING, -1, -1, -1)
			TNT1 A 0 A_SpawnItem("PurebredChargeExp", 0, 16)
			TNT1 A 0 A_SkullAttack
			BBRQ A 4 Fast A_ChangeVelocity(velx, vely, 0, CVF_REPLACE)
			TNT1 A 0 A_SpawnItemEx("PurebredGhost_A",0,0,0,0,0,0,0,128,0)
			TNT1 A 0 A_SpawnItem("PurebredChargeExp", 0, 16)
			BBRQ B 4 Fast
			TNT1 A 0 A_SpawnItemEx("PurebredGhost_B",0,0,0,0,0,0,0,128,0)
			TNT1 A 0 A_SpawnItem("PurebredChargeExp", 0, 16)
			TNT1 A 0 A_SkullAttack
			BBRQ C 4 Fast A_ChangeVelocity(velx, vely, 0, CVF_REPLACE)
			TNT1 A 0 A_SpawnItemEx("PurebredGhost_C",0,0,0,0,0,0,0,128,0)
			TNT1 A 0 A_SpawnItem("PurebredChargeExp", 0, 16)
			BBRQ D 4 Fast
			TNT1 A 0 A_SpawnItemEx("PurebredGhost_D",0,0,0,0,0,0,0,128,0)
			TNT1 A 0 A_SpawnItem("PurebredChargeExp", 0, 16)
			TNT1 A 0 A_SkullAttack
			BBRQ A 4 Fast A_ChangeVelocity(velx, vely, 0, CVF_REPLACE)
			TNT1 A 0 A_SpawnItemEx("PurebredGhost_A",0,0,0,0,0,0,0,128,0)
			TNT1 A 0 A_SpawnItem("PurebredChargeExp", 0, 16)
			BBRQ B 4 Fast
			TNT1 A 0 A_SpawnItemEx("PurebredGhost_B",0,0,0,0,0,0,0,128,0)
			TNT1 A 0 A_SpawnItem("PurebredChargeExp", 0, 16)
			TNT1 A 0 A_SkullAttack
			BBRQ C 4 Fast A_ChangeVelocity(velx, vely, 0, CVF_REPLACE)
			TNT1 A 0 A_SpawnItemEx("PurebredGhost_C",0,0,0,0,0,0,0,128,0)
			TNT1 A 0 A_SpawnItem("PurebredChargeExp", 0, 16)
			BBRQ D 4 Fast
			TNT1 A 0 A_SpawnItemEx("PurebredGhost_D",0,0,0,0,0,0,0,128,0)
			TNT1 A 0 A_Stop
			TNT1 A 0 ACS_NamedExecuteWithResult("DnD Monster Trait Take", 0, DND_ISBLOCKING)
			TNT1 A 0 A_ChangeFlag("NOBLOOD", 0)
			BBRQ A 8 Fast
		Goto See
		PainState:
			TNT1 A 0 ACS_NamedExecuteWithResult("DnD Monster Trait Take", 0, DND_ISBLOCKING)
			TNT1 A 0 A_ChangeFlag("NOBLOOD", 0)
			BBRQ H 2 Fast
			BBRQ H 3 Fast A_Pain
		Goto See
		XDeathState:
			TNT1 A 0 A_SpawnItemEx("GenericGibber_Medium", 0, 0, 0, 0, 0, 0, 0, SXF_USEBLOODCOLOR)
		DeathState: 
			BBRQ I 8 
			TNT1 A 0 A_FaceTarget
			TNT1 A 0 A_SpawnItemEx("PurebredDemonArm", 10, 0, 32, 0, 8, 0, 0, 128)
			BBRQ J 8 A_Scream
			BBRQ K 4 
			BBRQ L 4 A_NoBlocking
			BBRQ M 4 
			BBRQ N -1
		Stop
		RaiseState: 
			BBRQ NMLKJI 5 
		Goto See 
    } 
}

ACTOR PurebredDemonArm {
	Radius 8
	Height 8
	Speed 8
	+DOOMBOUNCE
	+DROPOFF
	+Missile
	+CLIENTSIDEONLY
	Scale 1.1
	States {
		Spawn:
			SG2B ABCDEFGH 2
		Loop
		Death:
			SG2B I -1
		Loop
	}
}

Actor PurebredChargeExp : BaseExplosionDamage {
	Obituary "%o was charged by a Purebred Demon."
	DamageType "Physical"
	Stamina 1
	States {
		Spawn:
			TNT1 A 0 NoDelay ACS_NamedExecuteAlways("DnD Pierce Check")
			TNT1 A 1 A_Explode(12, 96, 0, 0, 44)
		Stop
	}
}

Actor PurebredGhost_A {
	Scale 1.1
	+NOINTERACTION
	+CLIENTSIDEONLY
	Renderstyle Translucent
	Alpha 0.65
	PROJECTILE
	+CLIENTSIDEONLY
	+DONTSPLASH
	states {
		Spawn:
			BBRQ A 0
		SpawnLoop:
			BBRQ "#" 17
			BBRQ "#" 2 A_FadeOut(0.1)
		goto SpawnLoop + 1
	}
}

Actor PurebredGhost_B : PurebredGhost_A {
	States {
		Spawn:
			BBRQ B 0
		goto Super::SpawnLoop
	}
}

Actor PurebredGhost_C : PurebredGhost_A {
	States {
		Spawn:
			BBRQ B 0
		goto Super::SpawnLoop
	}
}

Actor PurebredGhost_D : PurebredGhost_A {
	States {
		Spawn:
			BBRQ B 0
		goto Super::SpawnLoop
	}
}

ACTOR Sabreclaw : DnD_BaseMeleeMonster { 
    Health 0x7FFFFFFF
	GibHealth -50
    Speed 16
    Height 56
    Radius 20
    Mass 640
    PainChance 96
	MeleeRange 56
    REACTIONTIME 8
    SeeSound "Saberclaw/sight"
    PainSound "Saberclaw/pain"
    DeathSound "Saberclaw/death"
    ActiveSound "Saberclaw/active"
    Attacksound "Saberclaw/melee"
    HitObituary "%o was cut to pieces by a Sabreclaw." 
	Species "Demon"
	Tag "Sabreclaw"
	var int user_dash;
	const int dash_lim = 3;
	const float v = 36;
	+NOBLOOD
	+ISMONSTER
	+DONTHURTSPECIES
	+NOINFIGHTING
    States { 
		SetInfo:
			TNT1 A 0 A_SetArg(4, DND_SABRECLAW)
			TNT1 A 0 ACS_NamedExecuteWithResult("DnD Init Monster Data", DND_MWEIGHT_RARE1)
		Goto SpawnSetup

		IdleState:
			CLNK AB 10 A_GiveInventory("DnD_SightChecker", 1)
		Loop 
		SeeState:
			CLNK AB 3 Fast A_Chase
			TNT1 A 0 A_GiveInventory("SabreclawDashDecider", 1)
			TNT1 A 0 A_JumpIfInventory("DnD_Boolean", 1, "Blink")
			CLNK CD 3 Fast A_Chase
		Goto See
		MeleeState: 
			CLNK E 4 Fast A_FaceTarget
			CLNK F 3 Fast A_FaceTarget
			CLNK G 5 Fast A_CustomMeleeAttack(random(14, 18), "Saberclaw/melee", "Saberclaw/melee")
		Goto See
		Blink:
			TNT1 A 0 A_TakeInventory("DnD_Boolean", 1)
			TNT1 A 0 A_CustomMissile("ClinkDashMarker", 44, 20)
			TNT1 A 0 A_PlaySound("Saberclaw/sight", CHAN_5)
			TNT1 A 0 A_SetUserVar("user_dash", 0)
			CLNK EEEEEEEE 4 Fast A_FaceTarget(0)
			TNT1 A 0 ACS_NamedExecuteWithResult("DnD Face Target (Pitch)")
			TNT1 A 0 A_PlaySound("Saberclaw/melee", CHAN_5)
		BlinkLoop:
			TNT1 A 0 A_SetUserVar("user_dash", user_dash + 1)
			TNT1 A 0 A_ChangeVelocity(v * cos(angle), v * sin(angle), v / 3 * sin(-pitch), CVF_REPLACE)
			TNT1 A 0 A_CustomMissile("ClinkDashDamager", 32)
			CLNK G 1 A_SpawnItemEx("ClinkAfterImage")
			TNT1 A 0 ACS_NamedExecuteWithResult("DnD Is Actor Stuck")
			CLNK G 1
			TNT1 A 0 A_CustomMissile("ClinkDashDamager", 32)
			TNT1 A 0 ACS_NamedExecuteWithResult("DnD Face Target (Pitch)")
			CLNK G 1 A_SpawnItemEx("ClinkAfterImage")
			TNT1 A 0 A_ChangeVelocity(v * cos(angle), v * sin(angle), v / 3 * sin(-pitch), CVF_REPLACE)
			CLNK G 1 A_SpawnItemEx("ClinkAfterImage")
			TNT1 A 0 A_CustomMissile("ClinkDashDamager", 32)
			CLNK GG 1 A_SpawnItemEx("ClinkAfterImage")
			TNT1 A 0 A_JumpIfInventory("DnD_Boolean", 1, "BlinkFinish")
			TNT1 A 0 A_JumpIf(user_dash == dash_lim, "BlinkFinish")
		Loop
		BlinkFinish:
			TNT1 A 0 A_Stop
			CLNK G 12 Fast A_TakeInventory("DnD_Boolean", 1)
		Goto See
		PainState:
			CLNK H 3 Fast A_GiveInventory("BlindCancelledSignal", 1)
			CLNK H 3 Fast A_Pain
		Goto See
		XDeathState:
		DeathState: 
			CLNK IJ 5
			CLNK K 4 A_Scream
			CLNK L 4 A_NoBlocking
			CLNK MN 4
			CLNK O -1
		Stop
		RaiseState: 
			CLNK NMLKJI 4 
		Goto See
    } 
}

Actor SabreclawDashDecider : DnD_Activator {
	States {
		Pickup:
			// check sight, distance and rng
			TNT1 A 0 A_Jump(192, "Nothing")
			TNT1 A 0 A_JumpIfCloser(320, "CheckSight")
		Stop
		CheckSight:
			TNT1 A 0 A_CheckSight("Nothing")
		CanDash:
			TNT1 A 0 A_GiveInventory("DnD_Boolean", 1)
		Stop
		Nothing:
			TNT1 A 0
		Stop
	}
}

// waits 32 tics
Actor ClinkDashMarker {
	Renderstyle Add
	Scale 0.75
	Translation "0:255=%[0.00,0.00,0.00]:[1.18,1.18,1.18]"
	const int t = 8;
	const float s = 0.75 / 16;
	var int user_count;
	+NOINTERACTION
	+FORCEXYBILLBOARD
	States {
		Spawn:
			TNT1 A 0 NoDelay A_SetUserVar("user_count", 0)
		SpawnLoop:
			TNT1 A 0 A_JumpIf(user_count >= t, "Finish")
			R075 P 2 Fast Bright A_Warp(AAPTR_TARGET, 16, 20, 44, 0, WARPF_INTERPOLATE)
			TNT1 A 0 A_JumpIfInTargetInventory("BlindCancelledSignal", 1, "Finish")
			TNT1 A 0 A_SetScale(scalex - s, scaley - s)
			R075 P 2 Fast Bright A_Warp(AAPTR_TARGET, 16, 20, 44, 0, WARPF_INTERPOLATE)
			TNT1 A 0 A_JumpIfInTargetInventory("BlindCancelledSignal", 1, "Finish")
			TNT1 A 0 A_SetScale(scalex - s, scaley - s)
			TNT1 A 0 A_JumpIfInTargetInventory("DnD_Boolean", 1, "Fade")
			TNT1 A 0 A_SetUserVar("user_count", user_count + 1)
		Loop
		Finish:
			TNT1 A 1
		Stop
		Fade:
			R075 P 1 Fast A_FadeOut(0.1)
		Wait
	}
}

Actor ClinkDashDamager {
	PROJECTILE
	Speed 36
	Height 28
	Radius 8
	Damage (15)
	DamageType "Physical"
	Stamina 1
	Scale 0.9
	+PIERCEARMOR
	+BLOODLESSIMPACT
	+NODAMAGETHRUST
	+MTHRUSPECIES
	States {
		Spawn:
			TNT1 A 3
		Stop
	}
}

Actor ClinkAfterImage {
	+CLIENTSIDEONLY
	+NOINTERACTION
	Renderstyle Translucent
	Alpha 0.9
	States {
		Spawn:
			CLNK G 1 A_FadeOut(0.0875)
		Loop
	}
}