

ACTOR FBD_Hater: FBD_LostSoul 17857
{
	//$category "FBD Monsters"
	
	// headbox type 99
	
	// bright shiny red with white glowing eyes
	Translation "168:191=250:254", "224:231=4:4", "160:167=4:4", "48:63=16:24", "64:79=23:47", "128:143=168:183", "144:151=173:184", "80:111=16:47", "152:159=182:188", "13:15=47:47"
	
	DamageFactor "Argent", 0
	DamageFactor "Ice", 2.0 DamageFactor "Freeze", 2.0 DamageFactor "Frost", 2.0
	
	
	AttackSound "hater/attack"
	DeathSound "hater/death"
	PainSound "hater/pain"
	ActiveSound "hater/pain"
	
	Tag "$FBD_HATER" // "Hater"
	Obituary "$OB_FBD_HATER" // "%o was overwhelmed with hate";
	
	States
	{
		Spawn:
			LSOL A 0 NODELAY ACS_NamedExecuteWithResult("FBD_RunMonster", 99) // hater's virtual headbox
			"----" A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 0, 0, 24)
			Goto Stand
			
		GotoCharging:
			Goto Charging
			
		StartupThenMissile:
			LSOL A 0 ACS_NamedExecuteWithResult("FBD_RunMonster", 99) // hater's virtual headbox
			"----" A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 0, 0, 24)
			"----" A 0 A_PlaySound("hater/attack", CHAN_VOICE)
			Goto MissileAfterParticles

/*
	Whoops, Zandronum doesn't support this, lost soul goes to its See state if it does have one!	
		Slam: // collided with another actor
			"----" A 1 A_Die // does nothing on the client
			Goto Death // happens on client only
*/			
	
		See:
			TNT1 A 0
			TNT1 A 0 A_TakeInventory("MaxLostSoulRange", 30)
			TNT1 A 0 A_ChangeFlag("NOPAIN", 0)			

		SeeContinue:	
		
			TNT1 A 0 A_StopSound(CHAN_VOICE) // shared code with Hater, stop screeching
			
			"----" A 0 A_JumpIfTargetInsideMeleeRange("Badaboom")
			LSOL A 2 BRIGHT A_Chase("", "")
			//***Che: no dodging in melee!
			LSOL A 2 BRIGHT A_Chase
			
			LSOL A 2 BRIGHT A_Chase("", "")
			//***Che: no dodging in melee!
			LSOL A 2 BRIGHT A_Chase

			LSOL A 2 BRIGHT A_Chase("", "")
			//***Che: no dodging in melee!
			LSOL A 2 BRIGHT A_Chase

			LSOL A 2 BRIGHT A_Chase("", "")
			//***Che: no dodging in melee!
			LSOL A 2 BRIGHT A_Chase
			
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 0, 0, 24)
			
			Loop		
		
		Badaboom:
			"----" A 0 A_Die
		Death:
			LSOL F 1 BRIGHT A_NoBlocking
			"----" A 0 A_Scream
			"----" AAA 0 BRIGHT A_CustomMissile ("HaterExplosionSfx", 24, 0, random (0, 360), 2, random (-90, 90)) 
			
			// inflict horrible damage:
			"----" A 0 A_CustomMissile ("HaterGonnaHate", 32, 0, random (0, 360), 2, random (-90, 90))
			
			LSOL FFF 1 BRIGHT A_CustomMissile ("HaterExplosionSfx", 24, 0, random (0, 360), 2, random (-90, 90)) 

			"----" AAAAA 1 BRIGHT A_FadeOut(0.19)
			Stop
			
		
		// Hater does not need the complex dance the lost soul performs up close because there won't be another attack if this one hits
		
		Missile:
			TNT1 A 0
			// lost souls are peculiar, the game engine oft spawns them right into the missile state
			// thus bypassing the spawn state
			TNT1 A 0 A_JumpIf(!user_item_no, "StartupThenMissile") // does nothing on the client
		MissileAfterParticles:
			
			TNT1 A 0 A_JumpIfInTargetInventory("GoFatality", 1, "WaitTargetsFatalityOut")

			TNT1 A 0 A_ChangeFlag("NOPAIN", 1)
			LSOL B 3 BRIGHT A_FaceTarget
			LSOL D 0 BRIGHT A_SkullAttack
			goto Charging	

		Charging:
			TNT1 A 0 A_takeInventory("LostSoulImPatience", 100)
			LSOL BBBB 2 BRIGHT 
			TNT1 A 0 A_JumpIfInventory("MaxLostSoulRange", 10, "See")
			TNT1 A 0 A_giveInventory("MaxLostSoulRange", 1)
			TNT1 A 0 A_PlaySound("hater/screech", CHAN_VOICE, 1, 1) // looping
			Loop
		
	}
}

ACTOR HaterGonnaHate: ZandronumBaronBall //BaronBall
{
	DamageType "Argent"
	Damage (Random(0, 0))
	SeeSound None
	DeathSound None
	Speed 0
	States {
		Spawn:
			TNT1 A 0 NODELAY A_Die
		Death:	
			TNT1 A 0
			// deviously delayed explosion so that it does not kill weak monsters but heals them instead!
			// 3 tics must be enough to go into the specialized pain state and heal
			TNT1 A 3 A_Explode(128, 32)
			TNT1 AA 0 A_CustomMissile ("HaterExplosionSfx", 24, 0, random (0, 360), 2, random (-90, 90)) 
			TNT1 A 3 A_Explode(128, 32)
			TNT1 AA 0 A_CustomMissile ("HaterExplosionSfx", 24, 0, random (0, 360), 2, random (-90, 90)) 
			TNT1 A 3 A_Explode(128, 32)
			TNT1 AA 0 A_CustomMissile ("HaterExplosionSfx", 24, 0, random (0, 360), 2, random (-90, 90)) 
			TNT1 A 3 A_Explode(128, 32)
			TNT1 AA 0 A_CustomMissile ("HaterExplosionSfx", 24, 0, random (0, 360), 2, random (-90, 90)) 
			Stop
	}
}

ACTOR HaterExplosionSfx: FlameTrails
{
	+BRIGHT
	Speed 8
	var int user_blife;
	States
	{
		Spawn:	
			TNT1 A 0 NODELAY A_SetScale(0.1 * (Random(0,1) ? Random(10,30) : Random(-30,-10)), 0.1 * (Random(0,1) ? Random(10,30) : Random(-30,-10)))
			HEFX C Random(1,2)
			HEFX D Random(1,2)
			HEFX E Random(1,2)
			HEFX F Random(1,2)
			TNT1 A 0 A_PlaySound("hater/death/particle")
			HEFX G Random(1,2) A_JumpIf(waterlevel >= 1, "ProceedBubbling")
			HEFX H Random(1,2) A_JumpIf(waterlevel >= 1, "ProceedBubbling")
			HEFX I Random(1,2) A_JumpIf(waterlevel >= 1, "ProceedBubbling")
			
			Stop
		ProceedBubblingA:	
			TNT1 A 0 A_PlaySound("hater/death/particle", CHAN_BODY)
		ProceedBubbling:	
			TNT1 A 0 A_SetScale(0.5, 0.5)
			TNT1 A 0 A_SetUserVar("user_blife", Random(30,50))
			TNT1 A 0 A_Jump(255, "Bubble1", "Bubble2")
		Bubble1:
			BUBL A 1 A_JumpIf(waterlevel < 1, "Pop")
			"----" A 0 A_SetUserVar("user_blife", user_blife - 1)
			"----" A 0 A_JumpIf(user_blife <= 0, "Recycle")
			"----" A 0 A_ChangeVelocity(momx * 0.95, momy * 0.95, momz * 0.85 + 0.3, CVF_REPLACE)
			Loop
		Bubble2:
			BUBL B 1 A_JumpIf(waterlevel < 1, "Pop")
			"----" A 0 A_SetUserVar("user_blife", user_blife - 1)
			"----" A 0 A_JumpIf(user_blife <= 0, "Recycle")
			"----" A 0 A_ChangeVelocity(momx * 0.95, momy * 0.95, momz * 0.85 + 0.3, CVF_REPLACE)
			Loop
		Pop:		
			"----" A 0 A_Stop
			"----" A 1 A_PlaySound("BUBULZ_S", CHAN_BODY)
			"----" A 1 A_SetScale(0.7, 0.7)
			LIQU ABDCD 1
			TNT1 A 10			
	}
}

ACTOR HaterExplosionSfxFast: HaterExplosionSfx
{
	Speed 24
	States
	{
		Spawn:
			TNT1 A 0 NODELAY A_SetScale(0.05 * (Random(0,1) ? Random(10,40) : Random(-40,-10)), 0.05 * (Random(0,1) ? Random(10,40) : Random(-40,-10)))
			TNT1 A 0 A_PlaySound("hater/death/particle")
			HEFX C 1
			HEFX D 1
			HEFX E 1 A_JumpIf(waterlevel >= 1, "ProceedBubbling")
			HEFX F 1 A_JumpIf(waterlevel >= 1, "ProceedBubbling")
			HEFX G 1 A_JumpIf(waterlevel >= 1, "ProceedBubbling")
			HEFX H 1 A_JumpIf(waterlevel >= 1, "ProceedBubbling")
			HEFX I 1 A_JumpIf(waterlevel >= 1, "ProceedBubbling")
			Stop	
	}
}

ACTOR PerpetualAgonyParticle: PerpeualLSFlameParticle
{
	States
	{
		Spawn:
			TNT1 A Random(1,8)
		Warpback:
			TNT1 A 0 A_SetUserVar("user_x", Random(-12, 0))
			TNT1 A 0 A_SetUserVar("user_y", Random(-8,8))
			TNT1 A 0 A_SetUserVar("user_z", Random(15,24) + user_x)
			TNT1 A 0 A_Stop
			Goto DoBurn
		DoBurn:
			TNT1 A 0 A_JumpIf(waterlevel >= 1, "Bubble")
			TNT1 A 0 A_SetScale(0.01 * (Random(0, 1) ? Random(40,100) : Random(-100,-40)), 0.01 * (Random(0, 1) ? Random(40,100) : Random(-100,-40)))
			Goto Burn
		Burn:
			
			
			SHOQ A 1 BRIGHT A_Warp(AAPTR_TARGET,user_x,user_y,user_z,0,WARPF_NOCHECKPOSITION|WARPF_INTERPOLATE)
			
			// without these, flames continue buring underwater for half a second
			// when the lost soul dives in at full ramming speed
			TNT1 A 0 A_JumpIf(waterlevel >= 1, "ProceedBubbling")
			
			SHOQ B 1 BRIGHT A_Warp(AAPTR_TARGET,user_x,user_y,user_z+1,0,WARPF_NOCHECKPOSITION|WARPF_INTERPOLATE)
			TNT1 A 0 A_JumpIf(waterlevel >= 1, "ProceedBubbling")
			SHOQ C 1 BRIGHT A_Warp(AAPTR_TARGET,user_x,user_y,user_z+2,0,WARPF_NOCHECKPOSITION|WARPF_INTERPOLATE)
			TNT1 A 0 A_JumpIf(waterlevel >= 1, "ProceedBubbling")
			SHOQ D 1 BRIGHT A_Warp(AAPTR_TARGET,user_x,user_y,user_z+3,0,WARPF_NOCHECKPOSITION|WARPF_INTERPOLATE)
			TNT1 A 0 A_JumpIf(waterlevel >= 1, "ProceedBubbling")
			SHOQ E 1 BRIGHT A_Warp(AAPTR_TARGET,user_x-1,user_y,user_z+4,0,WARPF_NOCHECKPOSITION|WARPF_INTERPOLATE)
			TNT1 A 0 A_JumpIf(waterlevel >= 1, "ProceedBubbling")
			SHOQ F 1 BRIGHT A_Warp(AAPTR_TARGET,user_x-2,user_y,user_z+5,0,WARPF_NOCHECKPOSITION|WARPF_INTERPOLATE)
			TNT1 A 0 A_JumpIf(waterlevel >= 1, "ProceedBubbling")
			SHOQ G 1 BRIGHT A_Warp(AAPTR_TARGET,user_x-3,user_y,user_z+6,0,WARPF_NOCHECKPOSITION|WARPF_INTERPOLATE)
			Goto Recycle
	}
}


ACTOR PerpetualAgonyParticleKickstart: PerpetualAgonyParticle
{
	States
	{
		Spawn:
			TNT1 A Random(0,2) // instead of regular particle's 1..8
			Goto Warpback
	}
}

