ACTOR Anachrony_PhaseImp 13502
{
	//$Category Monsters
	//$Title Phase Imp
	Health 150
	Radius 20
	Height 56
	Mass 120
	Speed 8
	PainChance 192
	MeleeDamage 4
	Alpha 0
	RenderStyle Translucent
	MONSTER
	+FLOORCLIP
	SeeSound "neodarkimp/sight"
	PainSound "neodarkimp/pain"
	DeathSound "neodarkimp/death"
	ActiveSound "neodarkimp/active"
	MeleeSound "neodarkimp/melee"
	Obituary "%o was incinerated by a Dark Imp."
	HitObituary "%o was scratched by a Dark Imp."
	MissileType DarkImpBall
	States
	{
	Spawn:
		DIMP AB 10 A_LookEx(LOF_NOSEESOUND)
		Loop
	See:
		// Stay invisible until the player can't see us
		// TODO should return to Spawn if there's no target?
		DIMP A 5 A_JumpIf(alpha >= 1.0, "Chase")
		DIMP A 0 A_JumpIfInTargetLOS("See", 210.0)
		DIMP A 0 A_PlaySound("neodarkimp/sight")
		DIMP A 0 ACS_NamedExecuteAlways("anachrony_phase_in", 0, 1)
	Chase:
		DIMP AABBCCDD 3 A_Chase
		loop
	PhasedChase:
		DIMP AABBCCDDAABBCCDDAABBCCDDAABBCCDD 1 A_Chase("", "")
	PhasedChase2:
		DIMP AABBCCDDAABBCCDD 1 A_Chase
		loop
	Melee:
		DIMP E 0 ACS_NamedExecuteAlways("anachrony_phase_in", 0, 1)
		DIMP EF 8 A_FaceTarget
		DIMP G 6 A_ComboAttack
		Goto Chase
	Missile:
		DIMP E 0 A_Jump(64, "Vanish")
		DIMP E 0 ACS_NamedExecuteAlways("anachrony_phase_in", 0, 1)
		DIMP EF 8 A_FaceTarget
		DIMP G 6 A_ComboAttack
		Goto Chase
	Vanish:
		DIMP F 0 A_PlaySound("neodarkimp/teleport")
		DIMP F 0 ACS_NamedExecuteAlways("anachrony_phase_out", 0, 1)
		DIMP FE 4 Bright A_FaceTarget
		Goto PhasedChase
	Pain:
		DIMP H 2 ACS_NamedExecuteAlways("anachrony_phase_in", 0, 1)
		DIMP H 2 A_Pain
		Goto Chase
	Death:
		DIMP I 8 ACS_NamedExecuteAlways("anachrony_phase_in", 0, 1)
		DIMP J 8 A_Scream
		DIMP K 6
		DIMP L 6 A_Fall
		DIMP M random(70, 350)
		DIMP M 10 A_FadeOut(0.0625)
		wait
	XDeath:
		DIMP N 5 ACS_NamedExecuteAlways("anachrony_phase_in", 0, 1)
		DIMP O 5 A_XScream
		DIMP P 5 A_Fall
		DIMP RST 5
		DIMP U random(70, 350)
		DIMP U 10 A_FadeOut(0.0625)
		wait
	Raise:
		DIMP LK 8
		DIMP JI 6
		goto Chase
	}
}

actor Anachrony__SetInvisible : CustomInventory
{
	states
	{
	Pickup:
		TNT1 A 0 A_ChangeFlag("INVISIBLE", true)
	}
}
actor Anachrony__ClearInvisible : CustomInventory
{
	states
	{
	Pickup:
		TNT1 A 0 A_ChangeFlag("INVISIBLE", false)
	}
}

ACTOR DarkImpBall
{
	Radius 6
	Height 8
	Speed 10
	Damage 4
	PROJECTILE
	+SEEKERMISSILE
	+MTHRUSPECIES
	SeeSound "neodarkimp/attack"
	DeathSound "imp/shotx"
	RenderStyle Add
	Alpha 0
	Decal DoomImpScorch
	
	States
	{
	Spawn:
		// Reveal us if we're fairly close to the player -- don't be unfair
		DIMB A 0 Bright A_JumpIfTracerCloser(512.0, "Reveal", true)
		DIMB A 2 Bright A_SeekerMissile(20, 0)
		// Reveal us once we've moved some distance from whoever fired us
		DIMB A 2 Bright A_JumpIfCloser(1024.0, "Spawn")
	Reveal:
		// Fade up to 0.75, not 1.0!
		DIMB B 2 Bright A_SetTranslucent(0.25, 1)
		DIMB B 2 Bright A_SeekerMissile(20, 0)
		DIMB A 2 Bright A_SetTranslucent(0.5, 1)
		DIMB A 2 Bright A_SeekerMissile(20, 0)
		DIMB B 2 Bright A_SetTranslucent(0.75, 1)
		DIMB B 2 Bright A_SeekerMissile(20, 0)
	Continue:
		DIMB AB 4 Bright A_SeekerMissile(20, 0)
		loop
	Death:
		DIMB CDE 6 Bright
		stop
	}
}
