
// *** MODIFIED BY CHEBMASTER
// I mark most important places modified by me with //***Che -- unless I forget to.

ACTOR JuggernautPotpourriChecker: AbstractPotpourriChecker
{
	Height 88
	Radius 48
}

//***TODO: give him a headbox - or, more precisely, *three* headboxes, one head and two shoulders!

ACTOR FBD_Juggernaut : ZandronumFatso 17879
{
	//***Che radius, height and maxdropoffheight (n/a for flying ones) MUST be kept consistent with FBD_TrySpawn in FBD_CORE.acs!
	
	//***Che: cross-mod hardening: see ACTOR Juggernaut : FBD_Juggernaut 2545  {} in Doom_Replacements.txt
	
	//$category "FBD Bosses"
    Scale 1.5
	Game Doom
    GibHealth 25
	damagefactor "Avoid", 0.0
	PainChance "Kick", 255
	damagefactor "Head", 2.0
	damagefactor "Stomp", 0.0
	damagefactor "GibRemoving", 0.0
	damagefactor "MINORHead", 1.0
	damagefactor "TeleportRemover", 0.0
	DamageFactor "CauseSplash", 0.0 DamageFactor "CauseObjectsToSplashSlime", 0.0 DamageFactor "CauseObjectsToSplashNukage", 0.0
	DamageFactor "CauseObjectsToSplashBlood", 0.0 DamageFactor "CauseObjectsToSplashLava", 0.0
	Health 8000
	+NOICEDEATH
	+DONTRIP
	PainSound "juggernaut/pain"
	DeathSound "juggernaut/death"
	ActiveSound "juggernaut/roam"
	SeeSound "juggernaut/see"
	
    damagefactor "Blood", 0.0 damagefactor "BlueBlood", 0.0 damagefactor "GreenBlood", 0.0
    //BloodType "FBD_Blood"
	Bloodtype "JuggernautBlood", "JuggernautBlood", "JuggernautBlood"
    damagefactor "Shrapnel", 0.4
	damagefactor "Explosive", 1.3
	Tag "$FBD_JUGG" // "Juggernaut";
	Obituary "$FBD_JUGG_O" //"%o was destroyed by the Juggernaut";
	MaxStepHeight 24
	MaxDropOffHeight 32
	Speed 1
	Height 88
	Radius 48
	Mass 99999
	Painchance 10
	Painchance "Explosive", 50
	+MISSILEMORE
	+MISSILEEVENMORE
	MinMissileChance 150
	DeathHeight 4
	BurnHeight 0
	
	
	//***Che
	+NODROPOFF
	var int user_body_angle;
	var int user_aim_angle;
	
	+NOBLOODDECALS
	-BLOODSPLATTER	
	
	States
	{
		/////////////////////
		Spawn:
			BS1W A 1
			TNT1 A 0 A_GiveInventory("TargetIsABoss")
			//***Che this seems some sort of rudiment serving no purpose
			TNT1 A 0 //A_SpawnItemEx ("KillTreads",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
			Goto Standby
		Standby:
			BS1W A 1
			BS1W AC 10 A_Look
			Loop
		Idle:
			BS1W A 1
			BS1W AC 10 A_Look
			TNT1 A 0 A_Jump(16, "See")
			Loop
		//////////////////
		See:
			BS1W A 1
			//TNT1 A 0 A_SpawnItem("KillTreads")
			Goto Rolling
		Rolling:
			
			TNT1 A 0 A_PlaySound("juggernaut/engine")
			
			BS1W A 2 A_Recoil(-2)
			BS1W B 2 A_Recoil(-2)
			TNT1 A 0 A_SpawnItem("TreadsDamage",65)
			BS1W A 2 A_Recoil(-2)
			BS1W B 2 A_Recoil(-2)
			TNT1 A 0 A_SpawnItem("TreadsDamage",65)
			
			BS1W C 2 A_Recoil(-2)
			BS1W D 2 A_Recoil(-2)
			TNT1 A 0 A_SpawnItem("TreadsDamage",65)
			BS1W C 2 A_Recoil(-2)
			BS1W D 2 A_Recoil(-2)
			TNT1 A 0 A_SpawnItem("TreadsDamage",65)
			
			BS1W A 2 A_Wander //A_Chase("","")
			BS1W B 2 A_Recoil(-2)
			TNT1 A 0 A_SpawnItem("TreadsDamage",65)
			BS1W A 2 A_Recoil(-2)
			BS1W B 2 A_Recoil(-2)
			TNT1 A 0 A_SpawnItem("TreadsDamage",65)
			
			BS1W C 2 A_Recoil(-2)
			BS1W D 2 A_Recoil(-2)
			TNT1 A 0 A_SpawnItem("TreadsDamage",65)
			BS1W C 2 A_Recoil(-2)
			BS1W D 2 A_Wander //A_Chase("","")
			TNT1 A 0 A_Jump (128, "Rolling2")
			TNT1 A 0 A_SpawnItem("TreadsDamage",65)
			Loop
			
		Rolling2:
			
			TNT1 A 0 A_PlaySound("juggernaut/engine")
			
			TNT1 A 0 A_SetUserVar("user_body_angle", angle)
			TNT1 A 0 A_FaceTarget
			TNT1 A 0 A_SetUserVar("user_aim_angle", angle) // who cares if it gets discretized here, we're not firing
			TNT1 A 0 A_SetAngle(user_body_angle) // who cares if we discretize the body direction to integer degrees				
			
			//TNT1 A 0 A_CustomMissile ("FBD_JuggernautBody1", 0)
			TNT1 A 0 A_SpawnItemEx ("FBD_JuggernautBody1", 0,0,0, momx,momy,momz, user_aim_angle,SXF_NOCHECKPOSITION | SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE,0)
			BS1B A 2 A_Chase("","")
			TNT1 A 0 A_SpawnItemEx ("FBD_JuggernautBody1", 0,0,0, momx,momy,momz, user_aim_angle,SXF_NOCHECKPOSITION | SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE,0)
			BS1B A 2 A_Recoil(-2)
			TNT1 A 0 A_SpawnItemEx ("FBD_JuggernautBody1", 0,0,0, momx,momy,momz, user_aim_angle,SXF_NOCHECKPOSITION | SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE,0)
			BS1B A 2 A_Recoil(-2)
			TNT1 A 0 A_SpawnItemEx ("FBD_JuggernautBody1", 0,0,0, momx,momy,momz, user_aim_angle,SXF_NOCHECKPOSITION | SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE,0)
			BS1B A 2 A_Recoil(-2)
			TNT1 A 0 A_SpawnItemEx ("FBD_JuggernautBody1", 0,0,0, momx,momy,momz, user_aim_angle,SXF_NOCHECKPOSITION | SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE,0)
			BS1B A 2 A_Chase("","")
			TNT1 A 0 A_SpawnItemEx ("FBD_JuggernautBody1", 0,0,0, momx,momy,momz, user_aim_angle,SXF_NOCHECKPOSITION | SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE,0)
			BS1B A 2 A_Recoil(-2)
			TNT1 A 0 A_SpawnItemEx ("FBD_JuggernautBody1", 0,0,0, momx,momy,momz, user_aim_angle,SXF_NOCHECKPOSITION | SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE,0)
			BS1B A 2 A_Recoil(-2)
			TNT1 A 0 A_SpawnItemEx ("FBD_JuggernautBody1", 0,0,0, momx,momy,momz, user_aim_angle,SXF_NOCHECKPOSITION | SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE,0)
			BS1B A 2 A_Recoil(-2)

			//***Che: check for *current target*, not for *any player*
			//TNT1 A 0 A_CheckSight("See")
			//Goto Missile
			
			TNT1 A 0 A_JumpIfTargetInLOS("Missile")
			Goto See
			
		///////////////////	
		
		Missile:
			TNT1 A 0
			TNT1 A 0 A_JumpIfCloser(150, "Rolling")
			
			// Kinslayer check:	
			TNT1 A 0 A_JumpIf(!CheckClass("Juggernaut", AAPTR_TARGET, true), 2)
			TNT1 A 0 ACS_NamedExecuteWithResult("FBD_InfightFriendlyFireOn")			
			
			TNT1 A 0 A_SetUserVar("user_body_angle", angle)
			TNT1 A 0 A_FaceTarget
			TNT1 A 0 A_SetUserVar("user_aim_angle", angle) // converting double to integer, losing fractional part!
			TNT1 A 0 A_SetAngle(user_body_angle)		
			
			TNT1 A 0 A_Jump (128, "FireRockets")
			Goto FireMachinegun
		FireMachinegun:

			TNT1 A 0 A_PlaySound("juggernaut/engine")
			
			BS1B A 0 A_Chase("","")
			BS1B A 2 A_SpawnItemEx ("FBD_JuggernautBody1", 0,0,0, momx,momy,momz, user_aim_angle, SXF_NOCHECKPOSITION | SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE,0)
			//***Che the tracers were set up with a see sound "" that was nowhere to be found
			//  -- resulting in silent firing!
			//TNT1 A 0 A_PlaySound("juggernaut/minigun", CHAN_WEAPON)
			BS1B A 2 A_Recoil(-2)
			//TNT1 A 0 A_PlaySound("juggernaut/minigun", 5)
			TNT1 A 0 A_SpawnItemEx ("FBD_JuggernautBody2", 0,0,0, momx,momy,momz, user_aim_angle, SXF_NOCHECKPOSITION | SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE,0)
			
			
					//***Che: do NOT adjust aim if target goes out of sight or is invisible
					TNT1 A 0 A_JumpIf(CallAcs("FBD_TargetIsInvisible"), 8)
					TNT1 A 0 A_JumpIfTargetInLOS(2)
					TNT1 A 0 A_Jump(256, 5)
					
					//Juggernaut has *THIS* in place of A_FaceTarget
					TNT1 A 0 A_SetUserVar("user_body_angle", angle)
					TNT1 A 0 A_FaceTarget
					TNT1 A 0 A_SetUserVar("user_aim_angle", angle) // converting double to integer, losing fractional part!
					TNT1 A 0 A_SetAngle(user_body_angle) // who cares if we discretize the body direction to integer degrees					
					//TNT1 A 0 A_FaceTarget
				
				/*
					//P.S. changing him to autocannon projectiles, he's a joke otherwise
					
				// MUST use auto-aiming at visible targets, otherwise misses at close range due to projectile's origin offset
				TNT1 A 0 A_JumpIfTargetInLOS(4)
				// the version with auto-aim disabled:		
				TNT1 A 0 A_CustomMissile("MonsterMinigunTracer", 72, 42, user_aim_angle + random(-8, 8), CMF_ABSOLUTEANGLE | CMF_OFFSETPITCH | CMF_SAVEPITCH)
				TNT1 A 0 A_CustomMissile("MonsterMinigunTracer", 72, -42, user_aim_angle + random(-8, 8), CMF_ABSOLUTEANGLE | CMF_OFFSETPITCH | CMF_SAVEPITCH)
				TNT1 A 0 A_Jump(256, 3)
				// the auto-aimed version:
				TNT1 A 0 A_CustomMissile("MonsterMinigunTracer", 72, 42, random(-8, 8), 0)
				TNT1 A 0 A_CustomMissile("MonsterMinigunTracer", 72, -42, random(-8, 8), 0)
				*/
/*				
				//do NOT adjust aim if target goes out of sight or is invisible
				TNT1 A 0 A_JumpIf(CallAcs("FBD_TargetIsInvisible"), 8)
				TNT1 A 0 A_JumpIfTargetInLOS(2, 0, JLOSF_DEADNOJUMP)
				TNT1 A 0 A_Jump(256, 6)
					// the auto-aimed version
				//***Che cannot check on the projectile's side because target inventory checks do not work for fast projectiles
				TNT1 A 0 A_JumpIfInventory("IsAKinslayer", 1, 3) 
				TNT1 A 0 A_CustomMissile("AutoCannonProjectileEnemy", 72, 42, random(-8, 8), CMF_OFFSETPITCH | CMF_SAVEPITCH, random(-4, 4))
				TNT1 A 0 A_Jump(256, 5)
				TNT1 A 0 A_CustomMissile("AutoCannonProjectileEnemyKS", 72, 42, random(-8, 8), CMF_OFFSETPITCH | CMF_SAVEPITCH, random(-4, 4))
				TNT1 A 0 A_Jump(256, 2)
				// the not autoaimed version
				TNT1 A 0 A_CustomMissile("AutoCannonProjectileEnemy", 72, 42, angle + random(-8, 8), CMF_ABSOLUTEANGLE | CMF_OFFSETPITCH | CMF_SAVEPITCH, random(-4, 4))
*/				
				TNT1 A 0 A_JumpIf(CallAcs("FBD_TargetIsInvisible"), 9)
				TNT1 A 0 A_JumpIfTargetInLOS(2, 0, JLOSF_DEADNOJUMP)
				TNT1 A 0 A_Jump(256, 7)
				TNT1 A 0
				// the auto-aimed version
				//***Che cannot check on the projectile's side because target inventory checks do not work for fast projectiles
				TNT1 A 0 A_JumpIfInventory("IsAKinslayer", 1, 3) 
				TNT1 A 0 A_CustomMissile("AutoCannonProjectileEnemy", 72, -42, random(-8, 8), 0)
				TNT1 A 0 A_Jump(256, 2)
				TNT1 A 0 A_CustomMissile("AutoCannonProjectileEnemyKS", 72, -42, random(-8, 8), 0)
				TNT1 A 0 A_Jump(256, 3)
				// the not autoaimed version
				TNT1 A 0
				TNT1 A 0 A_CustomMissile("AutoCannonProjectileEnemy", 72, -42, angle + random(-8, 8), CMF_ABSOLUTEANGLE | CMF_OFFSETPITCH | CMF_SAVEPITCH, random(-4, 4))

				TNT1 A 0 A_PlaySound("ACANO1", 1)
				TNT1 A 0 A_PlaySound("FARCAN1", 4)				

			TNT1 A 0 A_CustomMissile("YellowFlareSmall", 72, 42, 0, 0)
			TNT1 A 0 A_CustomMissile("YellowFlareSmall", 72, -42, 0, 0)
			//TNT1 A 0 A_CustomMissile("RifleCaseSpawn", 72, 42, 0, 0)
			//TNT1 A 0 A_CustomMissile("RifleCaseSpawn", 72, -42, 180, 0)
			TNT1 A 0 A_SpawnItem("TreadsDamage",65)
			//TNT1 A 0 A_PlaySound("juggernaut/minigun", CHAN_WEAPON)
			BS1B A 2 A_Recoil(-2)
			//TNT1 A 0 A_PlaySound("juggernaut/minigun", 5)
			TNT1 A 0 A_SpawnItemEx ("FBD_JuggernautBody2", 0,0,0, momx,momy,momz, user_aim_angle, SXF_NOCHECKPOSITION | SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE,0)
			
			
					//***Che: do NOT adjust aim if target goes out of sight or is invisible
					TNT1 A 0 A_JumpIf(CallAcs("FBD_TargetIsInvisible"), 8)
					TNT1 A 0 A_JumpIfTargetInLOS(2)
					TNT1 A 0 A_Jump(256, 5)
					
					//Juggernaut has *THIS* in place of A_FaceTarget
					TNT1 A 0 A_SetUserVar("user_body_angle", angle)
					TNT1 A 0 A_FaceTarget
					TNT1 A 0 A_SetUserVar("user_aim_angle", angle) // converting double to integer, losing fractional part!
					TNT1 A 0 A_SetAngle(user_body_angle) // who cares if we discretize the body direction to integer degrees					
					//TNT1 A 0 A_FaceTarget
				

				//do NOT adjust aim if target goes out of sight or is invisible
				TNT1 A 0 A_JumpIf(CallAcs("FBD_TargetIsInvisible"), 8)
				TNT1 A 0 A_JumpIfTargetInLOS(2, 0, JLOSF_DEADNOJUMP)
				TNT1 A 0 A_Jump(256, 6)
					// the auto-aimed version
				//***Che cannot check on the projectile's side because target inventory checks do not work for fast projectiles
				TNT1 A 0 A_JumpIfInventory("IsAKinslayer", 1, 3) 
				TNT1 A 0 A_CustomMissile("AutoCannonProjectileEnemy", 72, 42, random(-8, 8), CMF_OFFSETPITCH | CMF_SAVEPITCH, random(-4, 4))
				TNT1 A 0 A_Jump(256, 5)
				TNT1 A 0 A_CustomMissile("AutoCannonProjectileEnemyKS", 72, 42, random(-8, 8), CMF_OFFSETPITCH | CMF_SAVEPITCH, random(-4, 4))
				TNT1 A 0 A_Jump(256, 2)
				// the not autoaimed version
				TNT1 A 0 A_CustomMissile("AutoCannonProjectileEnemy", 72, 42, angle + random(-8, 8), CMF_ABSOLUTEANGLE | CMF_OFFSETPITCH | CMF_SAVEPITCH, random(-4, 4))
/*
	Too too powerful :(				
				TNT1 A 0 A_JumpIf(CallAcs("FBD_TargetIsInvisible"), 9)
				TNT1 A 0 A_JumpIfTargetInLOS(2, 0, JLOSF_DEADNOJUMP)
				TNT1 A 0 A_Jump(256, 7)
				TNT1 A 0
				// the auto-aimed version
				//***Che cannot check on the projectile's side because target inventory checks do not work for fast projectiles
				TNT1 A 0 A_JumpIfInventory("IsAKinslayer", 1, 3) 
				TNT1 A 0 A_CustomMissile("AutoCannonProjectileEnemy", 72, -42, random(-8, 8), CMF_OFFSETPITCH | CMF_SAVEPITCH, random(-4, 4))
				TNT1 A 0 A_Jump(256, 2)
				TNT1 A 0 A_CustomMissile("AutoCannonProjectileEnemyKS", 72, -42, random(-8, 8), CMF_OFFSETPITCH | CMF_SAVEPITCH, random(-4, 4))
				TNT1 A 0 A_Jump(256, 3)
				// the not autoaimed version
				TNT1 A 0
				TNT1 A 0 A_CustomMissile("AutoCannonProjectileEnemy", 72, -42, angle + random(-8, 8), CMF_ABSOLUTEANGLE | CMF_OFFSETPITCH | CMF_SAVEPITCH, random(-4, 4))
*/	
				TNT1 A 0 A_PlaySound("ACANO1", 5)
				TNT1 A 0 A_PlaySound("FARCAN1", 6)	

			TNT1 A 0 A_CustomMissile("YellowFlareSmall", 72, 42, 0, 0)
			TNT1 A 0 A_CustomMissile("YellowFlareSmall", 72, -42, 0, 0)
			//TNT1 A 0 A_CustomMissile("RifleCaseSpawn", 72, 42, 0, 0)
			//TNT1 A 0 A_CustomMissile("RifleCaseSpawn", 72, -42, 180, 0)
			TNT1 A 0 A_SpawnItem("TreadsDamage",65)
			TNT1 A 0 A_GiveInventory("JuggernautMachinegunAmmo", 1)
			TNT1 A 0 A_JumpIfInventory("JuggernautMachinegunAmmo", 30, "stopfiring")
			
			//TNT1 A 0 A_CheckSight("StopFiring")
			//Loop
			TNT1 A 0 A_JumpIfTargetInLOS("FireMachinegun")
			Goto StopFiring
			
		FireRockets:
			TNT1 A 0
			TNT1 A 0 A_PlaySound("juggernaut/engine")
			
			TNT1 A 0 A_SpawnItemEx ("FBD_JuggernautBody1", 0,0,0, momx,momy,momz, user_aim_angle,SXF_NOCHECKPOSITION | SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE,0)
			BS1B A 2 A_Chase("","")
			
					//***Che: do NOT adjust aim if target goes out of sight or is invisible
					TNT1 A 0 A_JumpIf(CallAcs("FBD_TargetIsInvisible"), 8)
					TNT1 A 0 A_JumpIfTargetInLOS(2)
					TNT1 A 0 A_Jump(256, 5)
					
					//Juggernaut has *THIS* in place of A_FaceTarget
					TNT1 A 0 A_SetUserVar("user_body_angle", angle)
					TNT1 A 0 A_FaceTarget
					TNT1 A 0 A_SetUserVar("user_aim_angle", angle) // converting double to integer, losing fractional part!
					TNT1 A 0 A_SetAngle(user_body_angle)				
					//TNT1 A 0 A_FaceTarget
					
				// MUST use auto-aiming at visible targets, otherwise misses at close range due to projectile's origin offset
				TNT1 A 0 A_JumpIfTargetInLOS(3)
				// the version with auto-aim disabled:		
				TNT1 A 0 A_CustomMissile("JuggernautRocket", 110, -42, user_aim_angle + random(-3, 3), CMF_ABSOLUTEANGLE | CMF_OFFSETPITCH | CMF_SAVEPITCH)
				TNT1 A 0 A_Jump(256, 2)
				// the auto-aimed version:
				TNT1 A 0 A_CustomMissile("JuggernautRocket", 110, -42, random(-3, 3), 0)		
			
			TNT1 A 0 A_SpawnItemEx ("FBD_JuggernautBody1", 0,0,0, momx,momy,momz, user_aim_angle,SXF_NOCHECKPOSITION | SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE,0)
			BS1B A 2 A_Recoil(-2)
			
			TNT1 A 0 A_SpawnItemEx ("FBD_JuggernautBody1", 0,0,0, momx,momy,momz, user_aim_angle,SXF_NOCHECKPOSITION | SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE,0)
			TNT1 A 0 A_SpawnItem("TreadsDamage",65)
			BS1B A 2 A_Recoil(-2)
			
			TNT1 A 0 A_SpawnItemEx ("FBD_JuggernautBody1", 0,0,0, momx,momy,momz, user_aim_angle,SXF_NOCHECKPOSITION | SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE,0)
			BS1B A 2 A_Recoil(-2)
			
			TNT1 A 0 A_SpawnItemEx ("FBD_JuggernautBody1", 0,0,0, momx,momy,momz, user_aim_angle,SXF_NOCHECKPOSITION | SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE,0)
			BS1B A 2 A_Chase("","")
			
					//***Che: do NOT adjust aim if target goes out of sight or is invisible
					TNT1 A 0 A_JumpIf(CallAcs("FBD_TargetIsInvisible"), 8)
					TNT1 A 0 A_JumpIfTargetInLOS(2)
					TNT1 A 0 A_Jump(256, 5)
					
					//Juggernaut has *THIS* in place of A_FaceTarget
					TNT1 A 0 A_SetUserVar("user_body_angle", angle)
					TNT1 A 0 A_FaceTarget
					TNT1 A 0 A_SetUserVar("user_aim_angle", angle) // converting double to integer, losing fractional part!
					TNT1 A 0 A_SetAngle(user_body_angle) // who cares if we discretize the body direction to integer degrees					
					//TNT1 A 0 A_FaceTarget
					
				// MUST use auto-aiming at visible targets, otherwise misses at close range due to projectile's origin offset
				TNT1 A 0 A_JumpIfTargetInLOS(3)
				// the version with auto-aim disabled:		
				TNT1 A 0 A_CustomMissile("JuggernautRocket", 110, 42, user_aim_angle + random(-3, 3), CMF_ABSOLUTEANGLE | CMF_OFFSETPITCH | CMF_SAVEPITCH)
				TNT1 A 0 A_Jump(256, 2)
				// the auto-aimed version:
				TNT1 A 0 A_CustomMissile("JuggernautRocket", 110, 42, random(-3, 3), 0)
			
			TNT1 A 0 A_SpawnItemEx ("FBD_JuggernautBody1", 0,0,0, momx,momy,momz, user_aim_angle ,SXF_NOCHECKPOSITION | SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE,0)
			BS1B A 2 A_Recoil(-2)
			
			TNT1 A 0 A_SpawnItemEx ("FBD_JuggernautBody1", 0,0,0, momx,momy,momz, user_aim_angle, SXF_NOCHECKPOSITION | SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE,0)
			TNT1 A 0 A_SpawnItem("TreadsDamage",65)
			BS1B A 2 A_Recoil(-2)
			
			TNT1 A 0 A_SpawnItemEx ("FBD_JuggernautBody1", 0,0,0, momx,momy,momz, user_aim_angle, SXF_NOCHECKPOSITION | SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE,0)
			BS1B A 2 A_Recoil(-2)
			
			TNT1 A 0 A_SpawnItemEx ("FBD_JuggernautBody1", 0,0,0, momx,momy,momz, user_aim_angle, SXF_NOCHECKPOSITION | SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE,0)
			
			
			TNT1 A 0 A_SpawnItem("TreadsDamage",65)
			TNT1 A 0 A_GiveInventory("JuggernautRocketAmmo", 2)
			TNT1 A 0 A_JumpIfInventory("JuggernautRocketAmmo", 6, "stopfiring")
			
			//TNT1 A 0 A_CheckSight("StopFiring")
			//Loop	
			TNT1 A 0 A_JumpIfTargetInLOS("FireRockets")
			Goto StopFiring
		
		StopFiring:
			TNT1 A 0
			TNT1 A 0 A_TakeInventory("JuggernautMachinegunAmmo", 30)
			TNT1 A 0 A_TakeInventory("JuggernautRocketAmmo", 6)
			Goto See
			
		
		
		
		////////////////////
		Pain:	
			TNT1 A 0
			BS1W A 2
			BS1W A 2 A_Pain
			Goto Rolling
			
			
		///////////////////////
		Death:
			TNT1 A 0
			TNT1 A 0 A_Scream
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 //A_SpawnItem("KillTreads")
			EXPL A 0 Radius_Quake (6, 100, 0, 22, 0)
			TNT1 AAAA 0 A_CustomMissile ("ExplosionSpawner", 90, 0, random (0, 360), 2, random (0, 180))
			TNT1 AAAAAA 0 A_CustomMissile ("ExplosionSpawner", 90, 0, random (0, 180), 2, random (0, 180))
			TNT1 AAAA 0 A_CustomMissile ("UltraGoreSPawner", 90, 0, random (0, 360), 2, random (0, 180))
			TNT1 AAAAAA 0 A_CustomMissile ("UltraGoreSpawner", 90, 0, random (0, 180), 2, random (0, 180))
			TNT1 A 0 A_CustomMissile ("CyberXDeath", 0, 0, random (0, 360), 2, random (0, 160))
			TNT1 A 0
			BS1B B 5 A_CustomMissile ("ExplosionSmoke", 60, 0, random (0, 360), 2, random (70, 110))
			BS1B B 5 A_CustomMissile ("RealFlameTrailsMedium", 60, 0, random (0, 360), 2, random (0, 160))
					BS1B B 5 A_CustomMissile ("ExplosionSmoke", 60, 0, random (0, 360), 2, random (70, 110))
			BS1B B 5 A_CustomMissile ("RealFlameTrailsMedium", 60, 0, random (0, 360), 2, random (0, 160))
					BS1B B 5 A_CustomMissile ("ExplosionSmoke", 60, 0, random (0, 360), 2, random (70, 110))
			BS1B B 5 A_CustomMissile ("RealFlameTrailsMedium", 60, 0, random (0, 360), 2, random (0, 160))
					BS1B B 5 A_CustomMissile ("ExplosionSmoke", 60, 0, random (0, 360), 2, random (70, 110))
			BS1B B 5 A_CustomMissile ("RealFlameTrailsMedium", 60, 0, random (0, 360), 2, random (0, 160))
					BS1B B 5 A_CustomMissile ("ExplosionSmoke", 60, 0, random (0, 360), 2, random (70, 110))
			BS1B B 5 A_CustomMissile ("RealFlameTrailsMedium", 60, 0, random (0, 360), 2, random (0, 160))
					BS1B B 5 A_CustomMissile ("ExplosionSmoke", 60, 0, random (0, 360), 2, random (70, 110))
			BS1B B 5 A_CustomMissile ("RealFlameTrailsMedium", 60, 0, random (0, 360), 2, random (0, 160))
					BS1B B 5 A_CustomMissile ("ExplosionSmoke", 60, 0, random (0, 360), 2, random (70, 110))
			BS1B B 5 A_CustomMissile ("RealFlameTrailsMedium", 60, 0, random (0, 360), 2, random (0, 160))
					BS1B B 5 A_CustomMissile ("ExplosionSmoke", 60, 0, random (0, 360), 2, random (70, 110))
			BS1B B 5 A_CustomMissile ("RealFlameTrailsMedium", 60, 0, random (0, 360), 2, random (0, 160))
					BS1B B 5 A_CustomMissile ("ExplosionSmoke", 60, 0, random (0, 360), 2, random (70, 110))
			BS1B B 5 A_CustomMissile ("RealFlameTrailsMedium", 60, 0, random (0, 360), 2, random (0, 160))
					BS1B B 5 A_CustomMissile ("ExplosionSmoke", 60, 0, random (0, 360), 2, random (70, 110))
			BS1B B 5 A_CustomMissile ("RealFlameTrailsMedium", 60, 0, random (0, 360), 2, random (0, 160))
					BS1B B 5 A_CustomMissile ("ExplosionSmoke", 60, 0, random (0, 360), 2, random (70, 110))
			BS1B B 5 A_CustomMissile ("RealFlameTrailsMedium", 60, 0, random (0, 360), 2, random (0, 160))
			Goto Decay
			
		Decay:
			BS1B B 8 A_CustomMissile ("ExplosionSmoke", 60, 0, random (0, 360), 2, random (70, 110))
			Loop
			
		Pain.Killme:
		Pain.Taunt:
			TNT1 A 0
			TNT1 A 0 HealThing(1)
			Goto Missile	
			
	}
} 

/* //***Che wtf this is not used anywhere
actor JuggernautBase : FBD_CurbstompedMarine
{
	Health 10000
	damagefactor "Killme", 9999.0
	Radius 64
	Height 2
	Scale 1.5
	Monster
	+NOBLOOD
	+SOLID
	-NOBLOCKMAP
	-COUNTKILL
	Mass 99999
	States
	{
		Raise:
			Stop //***Che canceling this
		Spawn:
			BS1B A 5
			Loop
		
		Death:
			TNT1 A 0
			TNT1 A 0 A_NoBlocking
			Stop
	}
}
*/

/*
//***Che this seems a leftover serving no purpose
actor KillTreads
{
	+NOTARGET
	Radius 1
	Height 1
	DamageType Killme //***Che wtf d00d :(
	+NOGRAVITY
	+NOTELEPORT
	+NODAMAGETHRUST
	+THRUGHOST
	+NORADIUSDMG
	+NOEXTREMEDEATH
	+FORCERADIUSDMG
	PROJECTILE
	+DEHEXPLOSION
	+ACTIVATEMCROSS
	States
	{
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_Explode(20,80,0)
			Stop
		}
}
*/

actor TreadsDamage
{
	+NOTARGET
	Radius 1
	Height 1
	DamageType Stomp
	+NOGRAVITY
	+NOTELEPORT
	+NODAMAGETHRUST
	+THRUGHOST
	+NORADIUSDMG
	+NOEXTREMEDEATH
	+FORCERADIUSDMG
	PROJECTILE
	+DEHEXPLOSION
	+ACTIVATEMCROSS
	+EXPLODEONWATER
	States
	{
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_Explode(500,50,0)
			TNT1 A 1 A_Noblocking
			Stop
	}
}













Actor FBD_JuggernautBody1
{
	+NOINTERACTION // collision off
	+NOCLIP
	+NOGRAVITY
/*	
	+RANDOMIZE
	
	+FORCEXYBILLBOARD
	+DONTSPLASH
	+NOEXTREMEDEATH
	+THRUACTORS
	+NOGRAVITY
	+NOCLIP
	//Projectile

	damage 0
	speed 1
*/		
	radius 2
	height 0
	Scale 1.5
	states
	{
		Spawn:
			//***Che: there it was, the reason of its flickering:
			// this actor is not a monster,
			// therefore its target is the juggernaut itself!
			// he fires it in the correct direction (at the target)
			// but then A_FaceTarget turns it to face the juggernaut!
			
			// Reworking the fug out of this.
			
			BS1T AAAA 1 //A_Warp(AAPTR_TARGET,0,0,0,0,WARPF_NOCHECKPOSITION|WARPF_COPYINTERPOLATION|WARPF_USECALLERANGLE)
			// A_FaceTarget
			Stop
			Goto Death
		Death:
			TNT1 A 0
			Stop
		XDeath:
			TNT1 A 0
			Stop
	}
}

Actor FBD_JuggernautBody2: FBD_JuggernautBody1
{
	states
	{
		Spawn:
			BS1T BBBB 1 BRIGHT //A_Warp(AAPTR_TARGET,0,0,0,0,WARPF_NOCHECKPOSITION|WARPF_COPYINTERPOLATION|WARPF_USECALLERANGLE)
			// A_FaceTarget
			Stop
			Goto Death
	}
}

//***Che: copy-pasting after mastermind's
actor JuggernautBlood: FBD_SawBlood
{
	+PUFFGETSOWNER
	states
	{
		HitMetal:
		   TNT1 A 1
		   TNT1 A 0 A_SpawnItem("HitPuff")
		   Stop
		Spawn:
			tnt1 a 1
			TNT1 A 0 A_ChangeFlag("FRIENDLY", 0)
			TNT1 A 0 A_JumpIf(waterlevel > 1, "Splash")
			TNT1 A 0 A_JumpIf((z - floorz) > 64, 1)
		Goto HitMetal
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("BD_CheckBloodIntensity")
			Goto Spawn2
	}
}