Actor Noise : GhoulBaseFloor
{ //Scripted (Samara and Halloween mode will not spawn this ghoul if replaced)
//Creator: Fluffy
//Origin: Ghoul Insanity
//Sprite: GOST
//Title: "Noise" 
health 2000
PainChance 1
scale 0.12
radius 24
height 62
Speed 7
RENDERSTYLE TRANSLUCENT
Activesound ""
DeathSound "UBOADETH"
BloodColor Gray
Painchance 255
MeleeRange 70
Obituary "%o was taken by the noise."
Tag "\c[f4]!#¤%?!£@\c-"
+DROPOFF
+DONTSPLASH
+NOCLIP
+FLOORHUGGER
+GHOST
var int user_pain;
var int user_speed;
var int user_hide;
States
{
  Spawn:
    TNT1 A 0
	TNT1 A 0 A_PlaySound("noise/ambient",5,1.0,TRUE)
  SpawnLoop:
	TNT1 A 0 A_Look
    GOST A 1 A_Wander
	Loop
  Idle:
    GOST A 0 A_SetTranslucent(1)
	TNT1 A 0 A_Look
    GOST A 1 A_Wander
	Goto Idle+1
  UnHide:
    TNT1 A 0 A_ChangeFlag(SHOOTABLE,1)
    GOST BBBBCCCCDDDDEEEEFFFFGGGGHHHH 1 A_FadeIn(0.04)
	GOST A 0 A_SetTranslucent(1)
	TNT1 A 0 A_ChangeFlag(NOPAIN,0)
  See:
    TNT1 A 0 A_ChangeFlag(NOPAIN,0)
    TNT1 A 0 A_PlaySound("CONSTANT",5,1.0,TRUE)
  SeeLoop:
    GOST A 1 A_Chase
	TNT1 A 0 A_JumpIfCloser(40,"Scare")
    Loop
  Scare:
    TNT1 A 0 A_ChangeFlag(NOPAIN,1)
    GOST A 0 A_RadiusGive("VesselFuckery",120,RGF_PLAYERS|RGF_CORPSES)
    GOST A 1 A_GiveToTarget("NoiseActivate",1)
	GOST A 1 A_Stop
  Hide:
    TNT1 A 0 A_SetUserVar("user_hide",0)
    TNT1 A 0 A_PlaySound("noise/ambient",5,1.0,TRUE)
	GOST BBBBCCCCDDDDEEEEFFFFGGGGHHHH 1 A_Fadeout(0.04,0)
	TNT1 A 0 A_ChangeFlag(SHOOTABLE,0)
  Hiding:
    TNT1 A 0 A_JumpIf(user_pain >= 700,"UnHide")
	TNT1 A 0 A_JumpIfCloser(200,"UnHide")
    TNT1 A 0 A_SetUserVar("user_pain",user_pain+Random(1,3))
    TNT1 A 5 A_Wander
	Loop
  Pain:
    TNT1 A 0 A_ChangeFlag(NOPAIN,1)
    TNT1 A 0 A_PlaySound("SCRE",2)
    TNT1 A 0 A_SetUserVar("user_pain",0)
	TNT1 A 0 A_SetUserVar("user_speed",-10)
  PainLoop:
    TNT1 A 0 A_JumpIf(user_pain >= 10,"See")
    TNT1 A 0 A_SetUserVar("user_pain",user_pain+1)
	TNT1 A 0 A_Stop
	TNT1 A 0 A_FaceTarget
	TNT1 A 0 A_JumpIfCloser(60,"Scare")
    GOST A 1 A_Recoil(user_speed)
	TNT1 A 0 A_SetUserVar("user_speed",user_speed-10)
    Loop
  Death:
    GOST A 0 A_SetTranslucent(1)
	GOST A 0 A_StopSound(5)
	GOST A 0 A_Fall
    GOST A 0 A_Scream
	TNT1 A 0 Radius_Quake(7,7,7,100,0)
	TNT1 A 0 A_SpawnItemEx("GhoulFireX2",0,0,random(5,50),frandom(0,4),0,frandom(-2,2),random(0,360))
	GOST B 2 A_Fadeout(0.02)
	TNT1 A 0 A_SpawnItemEx("GhoulFireX2",0,0,random(5,50),frandom(0,4),0,frandom(-2,2),random(0,360))
	GOST B 2 A_Fadeout(0.02)
	TNT1 A 0 A_SpawnItemEx("GhoulFireX2",0,0,random(5,50),frandom(0,4),0,frandom(-2,2),random(0,360))
	GOST B 2 A_Fadeout(0.02)
	TNT1 A 0 A_SpawnItemEx("GhoulFireX2",0,0,random(5,50),frandom(0,4),0,frandom(-2,2),random(0,360))
	GOST B 2 A_Fadeout(0.02)
	TNT1 A 0 A_SpawnItemEx("GhoulFireX2",0,0,random(5,50),frandom(0,4),0,frandom(-2,2),random(0,360))
	GOST C 2 A_Fadeout(0.02)
	TNT1 A 0 A_SpawnItemEx("GhoulFireX2",0,0,random(5,50),frandom(0,4),0,frandom(-2,2),random(0,360))
	GOST C 2 A_Fadeout(0.02)
	TNT1 A 0 A_SpawnItemEx("GhoulFireX2",0,0,random(5,50),frandom(0,4),0,frandom(-2,2),random(0,360))
	GOST C 2 A_Fadeout(0.02)
	TNT1 A 0 A_SpawnItemEx("GhoulFireX2",0,0,random(5,50),frandom(0,4),0,frandom(-2,2),random(0,360))
	GOST C 2 A_Fadeout(0.02)
	TNT1 A 0 A_SpawnItemEx("GhoulFireX2",0,0,random(5,50),frandom(0,4),0,frandom(-2,2),random(0,360))
	GOST D 2 A_Fadeout(0.02)
	TNT1 A 0 A_SpawnItemEx("GhoulFireX2",0,0,random(5,50),frandom(0,4),0,frandom(-2,2),random(0,360))
	GOST D 2 A_Fadeout(0.02)
	TNT1 A 0 A_SpawnItemEx("GhoulFireX2",0,0,random(5,50),frandom(0,4),0,frandom(-2,2),random(0,360))
	GOST D 2 A_Fadeout(0.02)
	TNT1 A 0 A_SpawnItemEx("GhoulFireX2",0,0,random(5,50),frandom(0,4),0,frandom(-2,2),random(0,360))
	GOST D 2 A_Fadeout(0.02)
	TNT1 A 0 A_SpawnItemEx("GhoulFireX2",0,0,random(5,50),frandom(0,4),0,frandom(-2,2),random(0,360))
	GOST E 2 A_Fadeout(0.02)
	TNT1 A 0 A_SpawnItemEx("GhoulFireX2",0,0,random(5,50),frandom(0,4),0,frandom(-2,2),random(0,360))
	GOST E 2 A_Fadeout(0.02)
	TNT1 A 0 A_SpawnItemEx("GhoulFireX2",0,0,random(5,50),frandom(0,4),0,frandom(-2,2),random(0,360))
	GOST E 2 A_Fadeout(0.02)
	TNT1 A 0 A_SpawnItemEx("GhoulFireX2",0,0,random(5,50),frandom(0,4),0,frandom(-2,2),random(0,360))
	GOST E 2 A_Fadeout(0.02)
	TNT1 A 0 A_SpawnItemEx("GhoulFireX2",0,0,random(5,50),frandom(0,4),0,frandom(-2,2),random(0,360))
	GOST F 2 A_Fadeout(0.02)
	TNT1 A 0 A_SpawnItemEx("GhoulFireX2",0,0,random(5,50),frandom(0,4),0,frandom(-2,2),random(0,360))
	GOST F 2 A_Fadeout(0.02)
	TNT1 A 0 A_SpawnItemEx("GhoulFireX2",0,0,random(5,50),frandom(0,4),0,frandom(-2,2),random(0,360))
	GOST F 2 A_Fadeout(0.02)
	TNT1 A 0 A_SpawnItemEx("GhoulFireX2",0,0,random(5,50),frandom(0,4),0,frandom(-2,2),random(0,360))
	GOST F 2 A_Fadeout(0.02)
	TNT1 A 0 A_SpawnItemEx("GhoulFireX2",0,0,random(5,50),frandom(0,4),0,frandom(-2,2),random(0,360))
	GOST G 2 A_Fadeout(0.02)
	TNT1 A 0 A_SpawnItemEx("GhoulFireX2",0,0,random(5,50),frandom(0,4),0,frandom(-2,2),random(0,360))
	GOST G 2 A_Fadeout(0.02)
	TNT1 A 0 A_SpawnItemEx("GhoulFireX2",0,0,random(5,50),frandom(0,4),0,frandom(-2,2),random(0,360))
	GOST G 2 A_Fadeout(0.02)
	TNT1 A 0 A_SpawnItemEx("GhoulFireX2",0,0,random(5,50),frandom(0,4),0,frandom(-2,2),random(0,360))
	GOST G 2 A_Fadeout(0.02)
	TNT1 A 0 A_SpawnItemEx("GhoulFireX2",0,0,random(5,50),frandom(0,4),0,frandom(-2,2),random(0,360))
	GOST H 2 A_Fadeout(0.02)
	TNT1 A 0 A_SpawnItemEx("GhoulFireX2",0,0,random(5,50),frandom(0,4),0,frandom(-2,2),random(0,360))
	GOST H 2 A_Fadeout(0.02)
	TNT1 A 0 A_SpawnItemEx("GhoulFireX2",0,0,random(5,50),frandom(0,4),0,frandom(-2,2),random(0,360))
	GOST H 2 A_Fadeout(0.02)
	TNT1 A 0 A_SpawnItemEx("GhoulFireX2",0,0,random(5,50),frandom(0,4),0,frandom(-2,2),random(0,360))
	GOST H 2 A_Fadeout(0.02)
	TNT1 A 0 A_SpawnItemEx("GhoulFireX2",0,0,random(5,50),frandom(0,4),0,frandom(-2,2),random(0,360))
	Stop
    }
}

ACTOR NoiseActivateTest
{
    +NOGRAVITY
	States 
	{
		Spawn:  
			TNT1 A 0 NoDelay A_RadiusGive("NoiseActivate",16383,RGF_PLAYERS|RGF_NOSIGHT)
			stop
	}
}

ACTOR NoiseActivate : Crusaderbuff
{
	States 
	{
		Pickup:
		    TNT1 A 1
			TNT1 A 0 ACS_NamedExecuteAlways("NoiseScript",0)
			stop
	}
}