

//==============================================================================
//============================ SPOOKY GHOST BUDDIES ============================
//==============================================================================


ACTOR SidheGhost
{
	Health 350
	PainChance 10
	Speed 6
	Radius 16
	Height 56
	Monster
	Renderstyle Translucent
	+FLOORCLIP
	+THRUACTORS
	+GHOST
	+DONTMORPH
	+VISIBILITYPULSE
	+NOBLOODDECALS
	+NOBLOOD
	+DONTTHRUST
	+BRIGHT
	SeeSound "GHOSTSEE"
	ActiveSound "GHOSTSEE"
	PainSound "SPIRT5"
	DeathSound "SPIRTS1"
	Obituary "$OB_GHOSTWARRIOR1"
	Tag "Ghost Warrior"

	States
	{
		Spawn:
			PLAY NMLKJIH 1 A_ChangeFlag ("FRIENDLY",TRUE)
			goto Search
		Search:
			TNT1 A 0 A_JumpIfInventory("SummonTimer", 35,"Death")
			TNT1 A 0 A_GiveInventory("SummonTimer",1)
			PLAY AB 5 A_Look
			//TNT1 A 0 A_DamageSelf(3)
			Loop
		See:
			TNT1 A 0 A_JumpIfInventory("SummonTimer", 35,"Death")
			TNT1 A 0 A_GiveInventory("SummonTimer",1)
			PLAY AAA 1 A_GiveInventory("GhostAction1",1)
			PLAY BBB 1 A_GiveInventory("GhostAction2",1)
			PLAY CCC 1 A_GiveInventory("GhostAction3",1)
			PLAY DDD 1 A_GiveInventory("GhostAction4",1)
			//TNT1 A 0 A_DamageSelf(3)
			Loop
		Pain:
			PLAY G 1
			PLAY G 6 A_Pain
			Goto See
		Melee:
			PLAY E 4 A_FaceTarget
			PLAY F 5 A_CustomMeleeAttack(random(45,70),TRUE,0,"BrutalStaffPuff",104)
			Goto See
		Death:
			PLAY G 0 A_Scream
			PLAY GGGGGGGGGGGGGGGG 1 A_SpawnItemEx("GhostTrail5",0,0,0,frandom(-1,1),frandom(-1,1),frandom(-1,1),0,SXF_NOCHECKPOSITION)
			Stop
	}
}

ACTOR SidheGhost2
{
	Health 350
	PainChance 10
	Speed 6
	Radius 16
	Height 56
	Monster
	Renderstyle Translucent
	+FLOORCLIP
	+TELESTOMP
	+GHOST
	+DONTMORPH
	+VISIBILITYPULSE
	+NOBLOODDECALS
	+NOBLOOD
	+THRUACTORS
	+DONTTHRUST
	+BRIGHT
	SeeSound "GHOSTSEE"
	ActiveSound "GHOSTSEE"
	PainSound "SPIRT5"
	DeathSound "SPIRTS1"
	Obituary "$OB_GHOSTWARRIOR1"
	Tag "Ghost Warrior"
	
	States
	{
		Spawn:
			PLAY AB 1 A_ChangeFlag ("FRIENDLY",TRUE)
			goto Search
		Search:
			TNT1 A 0 A_JumpIfInventory("SummonTimer", 35,"Death")
			TNT1 A 0 A_GiveInventory("SummonTimer",1)
			PLAY AB 5 A_Look
			Loop
		See:
			TNT1 A 0 A_JumpIfInventory("SummonTimer", 35,"Death")
			TNT1 A 0 A_GiveInventory("SummonTimer",1)
			PLAY AAA 1 A_GiveInventory("GhostAction1",1)
			PLAY BBB 1 A_GiveInventory("GhostAction2",1)
			PLAY CCC 1 A_GiveInventory("GhostAction3",1)
			PLAY DDD 1 A_GiveInventory("GhostAction4",1)
			Loop
		Pain:
			PLAY G 1
			PLAY G 6 A_Pain
			Goto See
		Melee:
		Missile:
			PLAY E 4 A_FaceTarget
			PLAY F 5 A_CustomComboAttack("BHSpell_FX1", 32, 10 * random(1, 8), "Melee")
			Goto See
		Death:
			PLAY G 0 A_Scream
			PLAY GGGGGGGGGGGGGGGG 1 A_SpawnItemEx("GhostTrail5",0,0,0,frandom(-1,1),frandom(-1,1),frandom(-1,1),0,SXF_NOCHECKPOSITION)
			Stop
	}
}

ACTOR SidheGhost3
{
	Health 350
	PainChance 10
	Speed 6
	Radius 16
	Height 56
	Monster
	Renderstyle Translucent
	+FLOORCLIP
	+TELESTOMP
	+GHOST
	+DONTMORPH
	+VISIBILITYPULSE
	+NOBLOODDECALS
	+NOBLOOD
	+THRUACTORS
	+DONTTHRUST
	+BRIGHT
	SeeSound "GHOSTSEE"
	ActiveSound "GHOSTSEE"
	PainSound "SPIRT5"
	DeathSound "SPIRTS1"
	Obituary "$OB_GHOSTWARRIOR1"
	Tag "Ghost Warrior"

	States
	{
		Spawn:
			PLAY AB 1 A_ChangeFlag ("FRIENDLY",TRUE)
			goto Search
		Search:
			TNT1 A 0 A_JumpIfInventory("SummonTimer", 35,"Death")
			TNT1 A 0 A_GiveInventory("SummonTimer",1)
			PLAY AB 5 A_Look
			//TNT1 A 0 A_DamageSelf(3)
			Loop
		See:
			TNT1 A 0 A_JumpIfInventory("SummonTimer", 35,"Death")
			TNT1 A 0 A_GiveInventory("SummonTimer",1)
			PLAY AAA 1 A_GiveInventory("GhostAction1",1)
			PLAY BBB 1 A_GiveInventory("GhostAction2",1)
			PLAY CCC 1 A_GiveInventory("GhostAction3",1)
			PLAY DDD 1 A_GiveInventory("GhostAction4",1)
			//TNT1 A 0 A_DamageSelf(3)
			Loop
		Pain:
			PLAY G 1
			PLAY G 6 A_Pain
			Goto See
		Melee:
		Missile:
			PLAY E 4 A_FaceTarget
			PLAY F 5 A_CustomComboAttack("SidheSpooker", 32, 10 * random(1, 8), "Melee")
			Goto See
		Death:
			PLAY G 0 A_Scream
			PLAY GGGGGGGGGGGGGGGG 1 A_SpawnItemEx("GhostTrail5",0,0,0,frandom(-1,1),frandom(-1,1),frandom(-1,1),0,SXF_NOCHECKPOSITION)
			Stop
	}
}


//==============================================================================
//============================ MISC GHOST FX AND AI ============================
//==============================================================================


ACTOR Ghostspawner : Randomspawner
{
	DropItem"SidheGhost"
	DropItem"SidheGhost2"
	DropItem"SidheGhost3"
}

ACTOR SummonTimer : Inventory
{
	Inventory.MaxAmount 350
}

Actor GhostAction1 : CustomInventory
{
	Inventory.PickupMessage ""
	Inventory.PickupSound ""
	-COUNTITEM
	
	states
	{
		Spawn:
			TNT1 A 1
			Fail
		Pickup:
			TNT1 A 0 A_Chase
			TNT1 A 0 A_CheckSight("Stopped")
			TNT1 A 0 A_SpawnItemEx("GhostTrail1",0,0,0,frandom(-1,1),frandom(-1,1),frandom(-1,1),0,SXF_NOCHECKPOSITION)
		Stopped:
			TNT1 A 0
			Stop
	}
}

Actor GhostAction2 : CustomInventory
{
	Inventory.PickupMessage ""
	Inventory.PickupSound ""
	-COUNTITEM
	
	states
	{
		Spawn:
			TNT1 A 1
			Fail
		Pickup:
			TNT1 A 0 A_Chase
			TNT1 A 0 A_CheckSight("Stopped")
			TNT1 A 0 A_SpawnItemEx("GhostTrail2",0,0,0,frandom(-1,1),frandom(-1,1),frandom(-1,1),0,SXF_NOCHECKPOSITION)
		Stopped:
			TNT1 A 0
			Stop
	}
}

Actor GhostAction3 : CustomInventory
{
	Inventory.PickupMessage ""
	Inventory.PickupSound ""
	-COUNTITEM
	
	states
	{
		Spawn:
			TNT1 A 1
			Fail
		Pickup:
			TNT1 A 0 A_Chase
			TNT1 A 0 A_CheckSight("Stopped")
			TNT1 A 0 A_SpawnItemEx("GhostTrail3",0,0,0,frandom(-1,1),frandom(-1,1),frandom(-1,1),0,SXF_NOCHECKPOSITION)
		Stopped:
			TNT1 A 0
			Stop
	}
}

Actor GhostAction4 : CustomInventory
{
	Inventory.PickupMessage ""
	Inventory.PickupSound ""
	-COUNTITEM
	
	states
	{
		Spawn:
			TNT1 A 1
			Fail
		Pickup:
			TNT1 A 0 A_Chase
			TNT1 A 0 A_CheckSight("Stopped")
			TNT1 A 0 A_SpawnItemEx("GhostTrail4",0,0,0,frandom(-1,1),frandom(-1,1),frandom(-1,1),0,SXF_NOCHECKPOSITION)
			Stopped:
			TNT1 A 0
		Stop
	}
}

Actor GhostTrail1
{
	Radius 0
	Height 0
	Renderstyle Translucent
	Alpha 0.2
	+NOINTERACTION
	+CLIENTSIDEONLY
	
	States
	{
	 	Spawn:
			PLAY A 1 Bright A_FadeOut(0.02)
			Loop
	}
}

Actor GhostTrail2 : GhostTrail1
{
	States
	{
	 	Spawn:
			PLAY B 1 Bright A_FadeOut(0.02)
			Loop
	}
}

Actor GhostTrail3 : GhostTrail1
{
	States
	{
	 	Spawn:
			PLAY C 1 Bright A_FadeOut(0.02)
			Loop
	}
}

Actor GhostTrail4 : GhostTrail1
{
	States
	{
	 	Spawn:
		PLAY D 1 Bright A_FadeOut(0.02)
		Loop
	}
}

Actor GhostTrail5 : GhostTrail1
{
	States
	{
	 	Spawn:
		PLAY G 1 Bright A_FadeOut(0.01)
		Loop
	}
}