Actor Ghouls : Inventory {}
Actor Ghoul
{
MONSTER
Health 150
Height 56
Radius 16
Speed 7
Damage (10)
MeleeRange 70
MaxStepHeight 64
Painchance "Mine", 256
Painchance "AdvancedImp", 0
Painchance "Shadow", 0
Painchance "Goreling", 256
Painchance 10
+Float
+FloorClip
+DropOFF
+NoTarget
+SlidesOnWalls
+MissileMore
+LookAllAround
+QuickToRetaliate
+DONTHARMSPECIES
Species "Ghoul"
Damagefactor "Acid", 2.35
Damagefactor "Fire", 0.7
//No Infighting
Damagefactor "AdvancedImp", 0.0
Damagefactor "Nightshade", 0.0
Damagefactor "HellionFire", 0.0
Damagefactor "Catharsi15k", 0.0
Damagefactor "Catharsi10K", 0.0
Damagefactor "GlaucomaGas", 0.0
Damagefactor "Glaucoma", 0.0
DropItem "LifeEssence", 200, 4
DropItem "HEMArmorBonusMax4", 200
DropItem "PartialKakuhou", 100, 1
seesound "monster/vulsit"
activesound "monster/vulact"
meleesound "monster/vulhit"
painsound "monster/vulpai"
deathsound "monster/vuldth"
HitObituary "%o was made into a feast for a Ghoul."
Obituary "%o was deep impaled by a Ghoul."
Tag "\c[m9]Ghoul\c-"
States
	{
	Spawn:
		TNT1 A 0 A_GiveInventory("GHOULS",1)
	Spawn.Real:
	Idle:
		GHUL A 10 A_Look
		Loop
	Wander:
		TNT1 A 0 A_Gravity
		GHUL AAAA 1 A_Look
		TNT1 A 0 A_Wander
		GHUL BBBB 1 A_Look
		TNT1 A 0 A_Wander
		TNT1 A 0 A_SpawnItemEx("HumanishStep2",0,0,2,0,0,-20)
		GHUL CCCC 1 A_Look
		TNT1 A 0 A_Wander
		GHUL DDDD 1 A_Look
		TNT1 A 0 A_Wander
		TNT1 A 0 A_SpawnItemEx("HumanishStep2",0,0,2,0,0,-20)
		Loop
	See:
		TNT1 A 0 A_Gravity
		GHUL AA 1 A_Chase("","")
		TNT1 A 0 A_Gravity
		GHUL A 1 A_Chase
		TNT1 A 0 A_Gravity
		GHUL BB 1 A_Chase("","")
		TNT1 A 0 A_Gravity
		GHUL B 1 A_Chase
		TNT1 A 0 A_SpawnItemEx("HumanishStep2",0,0,2,0,0,-20)
		GHUL CC 1 A_Chase("","")
		GHUL C 1 A_Chase
		GHUL DD 1 A_Chase("","")
		GHUL D 1 A_Chase
		TNT1 A 0 A_Gravity
		TNT1 A 0 A_SpawnItemEx("HumanishStep2",0,0,2,0,0,-20)
		GHUL A 0 A_Jump(60,"Dodge")
		Loop
	Dodge:
		TNT1 A 0
		TNT1 A 0 A_Jump(255,"Strafe","FastChase")
		GoTo See
	Strafe:
		GHUL A 0 A_Jump(255,"Right","Left","Back","BackLeftRange","BackRightRange")
		GoTo See
	Right:
		TNT1 A 0
		TNT1 A 0 ThrustThing(angle*256/360+64,30,0,0)
		GHUL A 5
		GoTo See
	Left:
		TNT1 A 0
		TNT1 A 0 ThrustThing(angle*256/360+192,30,0,0)
		GHUL A 5
		GoTo See
	Back:
		TNT1 A 0
		TNT1 A 0 ThrustThing(angle*256/360+128,30,0,0)
		GHUL A 5
		GoTo See
	BackLeftRange:
		TNT1 A 0
		TNT1 A 0 ThrustThing(angle*256/360+random(133,187),30,0,0)
		GHUL A 5
		GoTo See
	BackRightRange:
		TNT1 A 0
		TNT1 A 0 ThrustThing(angle*256/360+random(69,123),30,0,0)
		GHUL A 5
		GoTo See
	FastChase:
		GHUL A 1 A_FastChase
		TNT1 A 0 A_FastChase
		GHUL A 1 A_FastChase
		TNT1 A 0 A_FastChase
		GHUL B 1 A_FastChase
		TNT1 A 0 A_FastChase
		GHUL B 1 A_FastChase
		TNT1 A 0 A_FastChase
		TNT1 A 0 A_SpawnItemEx("HumanishStep2",0,0,2,0,0,-20)
		GHUL C 1 A_FastChase
		TNT1 A 0 A_FastChase
		GHUL C 1 A_FastChase
		TNT1 A 0 A_FastChase
		GHUL D 1 A_FastChase
		TNT1 A 0 A_FastChase
		GHUL D 1 A_FastChase
		TNT1 A 0 A_SpawnItemEx("HumanishStep2",0,0,2,0,0,-20)
		TNT1 A 0 A_FastChase
		GHUL A 1 A_FastChase
		TNT1 A 0 A_FastChase
		GHUL A 1 A_FastChase
		TNT1 A 0 A_FastChase
		GHUL B 1 A_FastChase
		TNT1 A 0 A_FastChase
		GHUL B 1 A_FastChase
		TNT1 A 0 A_FastChase
		TNT1 A 0 A_SpawnItemEx("HumanishStep2",0,0,2,0,0,-20)
		GHUL C 1 A_FastChase
		TNT1 A 0 A_FastChase
		GHUL C 1 A_FastChase
		TNT1 A 0 A_FastChase
		GHUL D 1 A_FastChase
		TNT1 A 0 A_FastChase
		GHUL D 1 A_FastChase
		TNT1 A 0 A_FastChase
		TNT1 A 0 A_SpawnItemEx("HumanishStep2",0,0,2,0,0,-20)
		TNT1 A 0 A_Jump(30,"See")
		Loop
	Melee:
		GHUL EF 3 A_FaceTarget
		GHUL G 3 A_CustomMissile("GhoulAttack",30,0,0)
		GHUL GG 2 A_JumpIfInventory("SuccessfulBite",1,"Detect")
		GoTo See
	Detect:
		TNT1 A 0
		TNT1 A 0 A_ChangeFlag(Invulnerable,1)
		GHUL E 15 A_ChangeFlag(Invulnerable,0)
		GHUL E 1
		TNT1 A 0 A_TakeInventory("SuccessfulBite",1)
	End:
		TNT1 A 0
		TNT1 A 0 HealThing(30)
		TNT1 A 0 A_JumpIfInventory("BiteCountShot",5,"KakuHou")
		TNT1 A 0 A_JumpIfTargetInLos("See",360)
		TNT1 A 0 A_ClearTarget
		Goto Wander
	KakuHou:
		TNT1 A 0
		GHUL FG 5 A_FaceTarget
		TNT1 A 0 A_TakeInventory("BiteCountShot",5)
		TNT1 A 0 A_CustomMissile("GhoulShot",38,0,0)
		GHUL H 5
		GoTo See
	Missile:
		TNT1 A 0
		TNT1 A 0 A_Jump(16,"KakuHou")
		GHUL A 1 A_Jump(100,"RightCharge","LeftCharge")
	Charge:
		TNT1 A 0
		TNT1 A 0 A_ClearTarget
		TNT1 A 0 A_LookEx(0,0,0,0,0,"Charging")
		GHUL E 2
		GoTo Wander
	Charging:
		GHUL EEEE 1 A_FaceTarget
		GHUL E 1 A_JumpIfCloser(70,"Melee")
		TNT1 A 0 ThrustThingZ(0,18,0,0)
		TNT1 A 0 A_SkullAttack(20)
		GHUL E 1 A_Recoil(-17)
		GHUL EEEEE 1 A_JumpIfCloser(70,"Melee")
		GHUL E 2 A_Stop
		TNT1 A 0 A_Gravity
		GHUL H 5
		GoTo See
	RightCharge:
		TNT1 A 0
		TNT1 A 0 ThrustThing(angle*256/360+random(69,5),30,0,0)
		GHUL A 5
		GHUL A 1 A_Stop
		GoTo Charge
	LeftCharge:
		TNT1 A 0
		TNT1 A 0 ThrustThing(angle*256/360+random(133,251),30,0,0)
		GHUL A 5
		GHUL A 1 A_Stop
		GoTo Charge
	Pain:
		TNT1 A 0
		GHUL H 4 A_Pain
		TNT1 A 0 A_Jump(90,"Dodge")
		GoTO See
	Death: 
		TNT1 A 0 A_TakeInventory("Ghouls",1)
		GHUL I 3
		GHUL J 3 A_ScreamAndUnblock
		GHUL KLM 4
		TNT1 A 0 A_SpawnItem("BodyCrash",0,0,0,0)
		GHUL N 63000 CanRaise
		Stop
	XDeath:
		TNT1 A 0 A_TakeInventory("Ghouls",1)
		GHUL O 5
		TNT1 A 0 A_XSCream
		TNT1 A 0 A_GiveInventory("XDeathCheck",1)
		TNT1 A 0 A_SpawnItemEx("GibbedGenerator",0,0,30)
		GHUL PQ 4
		TNT1 A 0 A_NoBlocking
		GHUL RSTU 3
		GHUL V 63000 CanRaise
		Stop
	Raise:
		TNT1 A 0
		TNT1 A 0 A_SpawnItemEx("VileHealEffect",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION)
		TNT1 A 0 A_JumpIfInventory("XDeathCheck",1,"XRaise")
		GHUL NMLKJIH 3
		TNT1 A 0 A_GiveInventory("Ghouls",1)
		GoTo See
	XRaise:
		TNT1 A 0 A_TakeInventory("XDeathCheck",1)
		GHUL UTSRQPO 4
		TNT1 A 0 A_GiveInventory("Ghouls",1)
		GoTo See
	Pain.Goreling:
		TNT1 A 0 A_JumpIfInventory("Ghouls",1,"See")
		TNT1 A 0 A_SpawnItemEx("BloodConsumeFX",0,0,32,0,0,0,0,SXF_NOCHECKPOSITION)
		TNT1 A 0
		TNT1 A 1
		Stop
	}
}
 
Actor GhoulAttack
{
Projectile
Speed 36
Height 6
Radius 6
Damage (random(35,40))
+DontHurtSpecies
+DontHarmSpecies
Species "AdvancedImp"
Damagetype "AdvancedImp"
Obituary "%o was eaten alive by a Ghoul."

States
	{
	Spawn:
		TNT1 A 2
	Crash:
	Death:
		TNT1 A 1
		Stop
	XDeath:
		TNT1 A 0
		TNT1 A 0 A_GiveToTarget("BiteCountShot",1)
		TNT1 A 0 A_GiveToTarget("BiteCount",1)
		TNT1 A 1 A_GiveToTarget("SuccessfulBite",1)
		Stop
	}
}

Actor GhoulShot
{
Projectile
Height 5
Radius 8
Speed 30
Damage (random(6,8))
+Ripper
+DontHurtSpecies
+DontHarmSpecies
Species "AdvancedImp"
Damagetype "AdvancedImp"
SeeSound "Kagune/Spawn"
DeathSound "Kagune/Crash"
Obituary "%o was impaled by a Ghoul's Kagune."

States
	{
	Spawn:
		TNT1 A 1
		TNT1 A 0 A_PlaySound("Kagune/Spawn",0,1.0,0)
	Fly:
		KAGU PPPPPPPPPP 2 A_SpawnItemEx("KaguneGas",random(5,-5),random(3,-3),random(3,-3),0,0,0,random(0,360))
		Goto Death
	Death:
		TNT1 A 0
		TNT1 A 1
		TNT1 AAAA 0 A_SpawnItemEx("KaguneGas",random(5,-5),random(3,-3),random(3,-3),random(-8,8),random(-8,8),random(-8,8),random(0,360))
		TNT1 AAAAAAAAAAAAAAAAAAAA 0 A_SpawnItemEx("KaguneShard",0,0,0,25,random(-16,16),momz+random(-13,13),0,0,0)
		Stop
	}
}

Actor KaguneShard
{
Projectile
Speed 18
Radius 3
Height 3
DeathSound "Shard/Hit"
Damage (random(4,6))
+DontHurtSpecies
+DontHarmSpecies
Species "AdvancedImp"
Damagetype "AdvancedImp"
States
	{
	Spawn:
		KAGU A 1 Bright A_SpawnItemEx("KaguneGas2",random(1,-1),random(1,-1),random(1,-1),0,0,0,random(0,360))
		Loop
	Death:
		TNT1 A 0
		TNT1 A 1
		TNT1 AAAA 0 A_SpawnItemEx("KaguneGas2",random(1,-1),random(1,-1),random(1,-1),random(5,-5),random(5,-5),random(5,-5),random(0,360))
		Stop
	}
}

Actor KaguneGas : RedBloodCloud { Scale 0.2 }
Actor KaguneGas2 : RedBloodCloud { Scale 0.03 }
Actor SuccessfulBite : Inventory { Inventory.MaxAmount 1 }
Actor BiteCount : Inventory { Inventory.MaxAmount 11 }
Actor BiteCountShot : Inventory { Inventory.MaxAmount 5 }