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





ACTOR ZandronumCacodemon // ripped from zandronum.pk3
{
	Game Doom
	SpawnID 19
	Health 400
	Radius 31
	Height 56
	Mass 400
	Speed 8
	PainChance 128
	Monster
	+FLOAT +NOGRAVITY
	SeeSound "caco/sight"
	PainSound "caco/pain"
	DeathSound "caco/death"
	ActiveSound "caco/active"
	Obituary "$OB_CACO"
	HitObituary "$OB_CACOHIT"
	States
	{
	Spawn:
		HEAD A 10 A_Look
		Loop
	See:
		HEAD A 3 A_Chase
		Loop
	Missile:
		HEAD B 5 A_FaceTarget
		HEAD C 5 A_FaceTarget
		HEAD D 5 BRIGHT A_HeadAttack
		Goto See
	Pain:
		HEAD E 3
		HEAD E 3 A_Pain
		HEAD F 6
		Goto See
	Death:
		// [BB] In ST A_NoBlocking is called in the beginning of the death state.
		HEAD G 8 A_NoBlocking
		HEAD H 8 A_Scream
		HEAD I 8
		HEAD J 8
		HEAD K 8
		HEAD L -1 A_SetFloorClip
		Stop
	Raise:
		HEAD L 8 A_UnSetFloorClip
		HEAD KJIHG 8
		Goto See
	}
}



ACTOR FBD_Cacodemon : ZandronumCacodemon 17621
{
	//***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 Cacodemon_: FBD_Cacodemon Replaces Cacodemon {} in Doom_Replacements.txt
	
	//$category "FBD Monsters"
	
	Game Doom
	bloodtype "Blue_Blood", "BlueFBD_SawBlood", "BlueFBD_SawBlood"
	bloodcolor "Blue"
	SpawnID 19
    GibHealth 25
    damagefactor "Crush", 10.0
	
	//***Che: nerfing this so that he receives 500 damage from a perfectly aimed shot
	// (500 - 234 from super shotgun spread ) / 40 fron the super shotgun central blast = 6.65
	// -- so that one-shotting him requires good aiming, it's not
	// "me point in his general direkshon, he go splat" anymore
	damagefactor "SSG", 6.65 //100.0
	
	Radius 24
	Height 56
	Mass 400
	Speed 10
	Health 400
	PainChance 128
	PainChance "Kick", 255
	PainChance "Avoid", 90
	damagefactor "Avoid", 1.0
	PainChance "Saw", 255
	damagefactor "ExplosiveImpact", 3.0 damagefactor "Shrapnel", 3.0
	damagefactor "GibRemoving", 0.0 damagefactor "HangingHook", 0
	Monster
	Scale 0.9
	+FLOAT +NOGRAVITY +FORCEXYBILLBOARD
	SeeSound "caco/sight"
	PainSound "caco/pain"
	DeathSound "caco/death"
	ActiveSound "caco/active"
	damagefactor "TeleportRemover", 0.0
	DamageFactor "CauseSplash", 0.0 DamageFactor "CauseObjectsToSplashSlime", 0.0 DamageFactor "CauseObjectsToSplashNukage", 0.0
	DamageFactor "CauseObjectsToSplashBlood", 0.0 DamageFactor "CauseObjectsToSplashLava", 0.0
	Obituary "$OB_CACO"
	HitObituary "$OB_CACOHIT"
	DropItem "DemonStrengthRune" 5
	DeathHeight 4
	BurnHeight 0
	damagefactor "Blood", 0.0 damagefactor "BlueBlood", 0.0 damagefactor "GreenBlood", 0.0
	//Tag "Cacodemon"
	
	//***Che
	Tag "$CACODEMON"
	DamageFactor "FriendlyExplosion", 3.0
	
	var int user_sleeping;
	var int user_item_no;
	var int user_serverside_sfchk;
	
	PainChance "Argent", 255
	DamageFactor "Argent", 1.0
	
	PainChance "Bullet792", 160 // machineguns and snip[er rifles not aimed
	PainChance "SniperBullet", 255 // sniper rifle aimed
	
	damagefactor "Killme", 1.0 // AOE broadcasted by captured marines
	PainChance "Killme", 255	
	
	PainChance "Ice", 255
	
	Species "Cacodemons"
	
	States
	{
		Spawn:
			HEAD A 0 NODELAY A_JumpIf(CallAcs("GetPotPourri"), "PotPourriSwap")
		PotPourriCancel:	
			TNT1 A 0 ACS_NamedExecuteWithResult("FBD_RunMonster")
			HEAD A 1 //7 // slaughtermap init takes 5 tics
			TNT1 A 0 A_GiveInventory("CacoStamina", 30)
			Goto Stand
		Stand:	
			HEAD A 10 A_Look
			Loop


		//***Che
		Pain.Ice:
			"----" A 20 A_Pain
			Goto See
		
		
		WaitTargetsFatalityOut:
			HEAD E 1 A_PlaySound("caco/sight", CHAN_VOICE)
			HEAD E 1 A_FaceTarget
			HEAD E 6 A_Recoil(1)
			//HEAD E Random(6,24)
		WTF2:
			HEAD E 6
			HEAD E 6 ACS_NamedExecuteWithResult("CacoJumpWtf")
			Loop
//			HEAD E 1 A_Jump(256, "AvoidLeft", "AvoidRight", "See")
//			Wait
		
		
		Pain.Avoid: // inflicted by the tracer "Alerter" fired by: the vanilla bfg9000; the revenant launcher; the minigun when beginning to spin up; the rocket launcher. 
			TNT1 A 0
			TNT1 A 0 HealThing(1)
			TNT1 A 0 A_JumpIf(user_sleeping, "Flatfooted") // dont dodge if unaware
			
			TNT1 A 0 A_JumpIfInventory("CacoStamina", 15, 1) // max two such dodges, then cooldown
			Goto Flatfooted // no dodging if out of juice
			
			TNT1 A 0 A_TakeInventory("CacoStamina", 15)
			//TNT1 A 0 A_Jump(256, "AvoidLeft", "AvoidRight")
			TNT1 A 0 ACS_NamedExecuteWithResult("JumpAvoidLeftOrRight")
			HEAD E 1
			Wait
			//Goto AvoidLeft
		  
		AvoidLeft:
			HEAD E 1 A_FaceTarget
			TNT1 A 0 ThrustThing(angle*256/360+192, 10, 0, 0)
			HEAD FFEEE 1 
			Goto Missile
		AvoidRight:
			HEAD E 1 A_FaceTarget
			TNT1 A 0 ThrustThing(angle*256/360+64, 10, 0, 0)
			HEAD FFEEE 1 
			Goto Missile
		Flatfooted:
			TNT1 A 0 A_FaceTarget
			TNT1 A 0 A_SetUserVar("user_sleeping", 0)
			TNT1 A 0 A_PlaySound("caco/sight", CHAN_VOICE)
			HEAD BEFEA 4 
			Goto See
/*		
		ReplaceVanilla:
			TNT1 A 0 A_ChangeFlag("THRUACTORS", 1)
			TNT1 A 0 A_ChangeFlag("COUNTKILL", 0)
			TNT1 A 0 A_SpawnItemEx ("VanillaCacoDemon",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION | SXF_TRANSFERAMBUSHFLAG ,0)
			Stop
*/			
		PotPourriSwap:
			TNT1 A 0 A_ChangeFlag("COUNTKILL", 0)
			TNT1 A 0 A_ChangeFlag("SHOOTABLE", 0)
		PotPourriWait:			
			KYPP E 5 A_JumpIf(CallAcs("FBD_GetMapRandomizerReady"), 1) // a two-second delay to allow re-randomizing on loading an auto-save
			Loop			
			TNT1 A 0 A_Jumpif(!CallAcs("GetPotPourriChance", 33), "PotPourriNoSwap")
			TNT1 A 0 A_ChangeFlag("SOLID", 0)
			TNT1 A 0 A_ChangeFlag("THRUACTORS", 1)	
			TNT1 A 0 A_SpawnItemEx ("CacoPotpourriSwapper",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION | SXF_TRANSFERAMBUSHFLAG | SXF_TRANSFERPOINTERS | SXF_TRANSFERSPECIAL | SXF_CLEARCALLERSPECIAL | SXF_CLEARCALLERTID  ,0, tid)
			TNT1 A 30
			Stop
		PotPourriNoSwap:
			TNT1 A 0 A_ChangeFlag("SHOOTABLE", 1)
			TNT1 A 0 A_ChangeFlag("COUNTKILL", 1)
			Goto PotPourriCancel			
		
		Idle: // without this, the game engine puts him into his Spawn state when he loses target 
				//-- and that wrecks havok with the init scripts!
			HEAD A 1 A_ClearTarget
			TNT1 A 0 A_JumpIfInventory("Curbstomp_Marine", 1, "FatalityMarine")
			TNT1 A 0 A_SetUserVar("user_sleeping", 1)
			
		SearchPlayer:
			TNT1 A 0 A_JumpIfInventory("EnemyMemory", 1, 2) // this causes to clear target on the second loop
			TNT1 A 0 A_ClearTarget
			TNT1 A 0 A_TakeInventory("EnemyMemory", 40)
			HEAD A 10 A_Look
			TNT1 A 0 A_SetAngle(angle - 30)
			HEAD A 10 A_Look
			TNT1 A 0 A_SetAngle(angle + 30)
			HEAD A 10 A_Look
			TNT1 A 0 A_SetAngle(angle + 30)
			HEAD A 10 A_Look
			TNT1 A 0 A_SetAngle(angle - 30)
			
			
			HEAD A 0 A_Wander
			HEAD A 2 A_Look
			HEAD A 0 A_Wander
			HEAD A 2 A_Look
			HEAD A 0 A_Wander
			HEAD A 2 A_Look
			HEAD A 0 A_Wander
			HEAD A 2 A_Look
			HEAD A 0 A_Wander
			HEAD A 2 A_Look
			HEAD A 0 A_Wander
			HEAD A 2 A_Look
			HEAD A 0 A_Wander
			HEAD A 2 A_Look
			HEAD A 0 A_Wander
			HEAD A 2 A_Look
			HEAD A 0 A_Wander
			HEAD A 2 A_Look
			HEAD A 0 A_Wander
			HEAD A 2 A_Look
			HEAD A 0 A_Wander
			HEAD A 2 A_Look
			HEAD A 0 A_Wander
			HEAD A 2 A_Look
			HEAD A 0 A_Wander
			HEAD A 2 A_Look
			HEAD A 0 A_Wander
			HEAD A 2 A_Look
			HEAD A 0 A_Wander
			HEAD A 2 A_Look
			HEAD A 0 A_Wander
			HEAD A 2 A_Look
			HEAD A 0 A_Wander
			HEAD A 2 A_Look
			HEAD A 0 A_Wander
			HEAD A 2 A_Look
			HEAD A 0 A_Wander
			HEAD A 2 A_Look
			HEAD A 0 A_Wander
			HEAD A 2 A_Look
			TNT1 A 0 A_GiveInventory("CacoStamina", 10)
			
			TNT1 A 0 A_Jump(128, "SearchPlayer")
			HEAD A 0 A_Wander
			HEAD A 2 A_Look
			HEAD A 0 A_Wander
			HEAD A 2 A_Look
			HEAD A 0 A_Wander
			HEAD A 2 A_Look
			HEAD A 0 A_Wander
			HEAD A 2 A_Look
			HEAD A 0 A_Wander
			HEAD A 2 A_Look
			HEAD A 0 A_Wander
			HEAD A 2 A_Look
			HEAD A 0 A_Wander
			HEAD A 2 A_Look
			HEAD A 0 A_Wander
			HEAD A 2 A_Look
			HEAD A 0 A_Wander
			HEAD A 2 A_Look
			HEAD A 0 A_Wander
			HEAD A 2 A_Look
			TNT1 A 0 A_GiveInventory("CacoStamina", 10)
			Goto SearchPlayer
/*			
		VanillaSee:	
			HEAD A 3 A_Chase
			Loop
*/			
		See:
			TNT1 A 0
	
			// slaughtermap manage
			TNT1 A 0 A_JumpIf(!user_sleeping, 3) // forgo the expensive sight check if already awake
			TNT1 A 0 A_CheckSight(2) // do not consider ourselves awake if none of the players can see us
			TNT1 A 0 A_SetUserVar("user_sleeping", 0)
/*			
			TNT1 A 0 A_JumpIf(user_serverside_sfchk != -1, 3) // -1 means ACS commands us to do the radiusgive
			// A_RadiusGive is:
			//  1. serverside-only: the call is skipped on the client; only if a player is involved, a network command to update his item count is sent, otherwise the item count only increases on the server
			//  2. iterates over all actors in an infinitely tall square column checking their flags and coordinates
			//  3. performs expensive precision radius calculation (using a square root) unless RGF_CUBE is given (which results in cheaper delta per-coordinate comparison)
			//  4. performs expensive sight check, for each thing that passes flag and radius checks, unless RGF_NOSIGHT is given
			TNT1 A 0 A_RadiusGive("SfestCounterServerside", 500, RGF_MONSTERS | RGF_CUBE | RGF_NOSIGHT, 1)			
			TNT1 A 0 A_SetUserVar("user_serverside_sfchk", 1) // reply that we did the deed	
*/			
			
			
//			TNT1 A 0 A_JumpIfInventory("IAmClassicMonster", 1, "VanillaSee")
			TNT1 A 0 A_JumpIfInTargetInventory("IsPlayer", 1, "ChasePlayer")
			TNT1 A 0 A_JumpIfInTargetLOS("SeeContinue", 0, JLOSF_DEADNOJUMP)
			TNT1 A 0 A_CheckSight("See2")
			
		SeeContinue:	
			//***Che cloning this to decrease slaughterchecks frequency to ~1/second
			HEAD A 2 A_Chase
			HEAD AA 2 A_Chase ("","")
			//***Che: oops, tries biting through walls
			//TNT1 A 0 A_JumpIfCloser(99, "Melee")
			TNT1 A 0 A_JumpIfTargetInLOS("Melee", 190, JLOSF_DEADNOJUMP, 99, 0)
			TNT1 A 0 A_TakeInventory("EnemyMemory", 1)
			
			TNT1 A 0 A_CheckSight("See2")
			HEAD A 2 A_Chase
			HEAD AA 2 A_Chase ("","")
			//***Che: oops, tries biting through walls
			//TNT1 A 0 A_JumpIfCloser(99, "Melee")
			TNT1 A 0 A_JumpIfTargetInLOS("Melee", 190, JLOSF_DEADNOJUMP, 99, 0)
			TNT1 A 0 A_TakeInventory("EnemyMemory", 1)

			TNT1 A 0 A_CheckSight("See2")
			HEAD A 2 A_Chase
			HEAD AA 2 A_Chase ("","")
			//***Che: oops, tries biting through walls
			//TNT1 A 0 A_JumpIfCloser(99, "Melee")
			TNT1 A 0 A_JumpIfTargetInLOS("Melee", 190, JLOSF_DEADNOJUMP, 99, 0)
			TNT1 A 0 A_TakeInventory("EnemyMemory", 1)

			TNT1 A 0 A_CheckSight("See2")
			HEAD A 2 A_Chase
			HEAD AA 2 A_Chase ("","")
			//***Che: oops, tries biting through walls
			//TNT1 A 0 A_JumpIfCloser(99, "Melee")
			TNT1 A 0 A_JumpIfTargetInLOS("Melee", 190, JLOSF_DEADNOJUMP, 99, 0)
			TNT1 A 0 A_TakeInventory("EnemyMemory", 1)

			TNT1 A 0 A_CheckSight("See2")
			HEAD A 2 A_Chase
			HEAD AA 2 A_Chase ("","")
			//***Che: oops, tries biting through walls
			//TNT1 A 0 A_JumpIfCloser(99, "Melee")
			TNT1 A 0 A_JumpIfTargetInLOS("Melee", 190, JLOSF_DEADNOJUMP, 99, 0)
			TNT1 A 0 A_TakeInventory("EnemyMemory", 1)

			TNT1 A 0 A_CheckSight("See2")
			HEAD A 2 A_Chase
			HEAD AA 2 A_Chase ("","")
			//***Che: oops, tries biting through walls
			//TNT1 A 0 A_JumpIfCloser(99, "Melee")
			TNT1 A 0 A_JumpIfTargetInLOS("Melee", 190, JLOSF_DEADNOJUMP, 99, 0)
			TNT1 A 0 A_TakeInventory("EnemyMemory", 1)
			TNT1 A 0 A_GiveInventory("CacoStamina", 1)
			
			Loop
			
		See2:
			HEAD AAAAAA 2 A_Chase
			TNT1 A 0 A_GiveInventory("CacoStamina", 5)
			TNT1 A 0 A_JumpIfInventory("EnemyMemory", 25, "Idle")//"SearchPlayer")
			TNT1 A 0 A_GiveInventory("EnemyMemory", 1)
			Goto See
		ForgetQuicker:
			HEAD AAAAAA 2 A_Chase
			TNT1 A 0 A_GiveInventory("CacoStamina", 5)
			TNT1 A 0 A_JumpIfInventory("EnemyMemory", 25, "Idle")//"SearchPlayer")
			TNT1 A 0 A_GiveInventory("EnemyMemory", 4)
			HEAD AAAAAA 2 A_Wander
			TNT1 A 0 A_GiveInventory("CacoStamina", 5)
			TNT1 A 0 A_JumpIfInventory("EnemyMemory", 25, "Idle")//"SearchPlayer")
			TNT1 A 0 A_GiveInventory("EnemyMemory", 4)
			Goto See

		ChasePlayer:
			HEAD A 2 A_Chase("", "")
			TNT1 A 0 A_JumpIf(CallAcs("FBD_TargetIsInvisible"), "ForgetQuicker")
			// the Hexen boss dodging only works closer than 640 anyway(hardcoded in C++)
			TNT1 A 0 A_JumpIfInTargetLOS("Dance", 30, JLOSF_DEADNOJUMP | JLOSF_CLOSENOSIGHT, 400, 180)
			
			HEAD A 2 A_Chase
			HEAD AA 2 A_Chase ("","")
			//***Che: oops, tries biting through walls
			//TNT1 A 0 A_JumpIfCloser(99, "Melee")
			TNT1 A 0 A_JumpIfTargetInLOS("Melee", 190, JLOSF_DEADNOJUMP, 99, 0)
			TNT1 A 0 A_TakeInventory("EnemyMemory", 5)	
			TNT1 A 0 A_GiveInventory("CacoStamina", 1)
			TNT1 A 0 A_JumpIfTargetInLOS("ChasePlayer")
			Goto See2

		Dance:
			TNT1 A 0 A_JumpIfInventory("CacoStamina", 6, 1) // skip the goto
			Goto SeeContinue // out of juice
			TNT1 A 0 A_TakeInventory("CacoStamina", 6)
			HEAD A 2 A_Chase
			HEAD AA 2 A_Chase ("","", CHF_FASTCHASE) // hexen boss dodging
			TNT1 A 0 A_JumpIfTargetInLOS("Melee", 190, JLOSF_DEADNOJUMP, 99, 0)
			TNT1 A 0 A_TakeInventory("EnemyMemory", 10)
			TNT1 A 0 A_JumpIfTargetInLOS("ChasePlayer")
			Goto See2
			
		DanceThenMissile:
			HEAD A 2 A_FaceTarget
			HEAD AA 2 A_Chase ("","MissileAfterAvoid", CHF_FASTCHASE) // hexen boss dodging
			HEAD A 2 A_Recoil(2)
			HEAD AA 2 A_Chase ("","MissileAfterAvoid", CHF_FASTCHASE) // hexen boss dodging
			HEAD A 2 A_Recoil(3)
			HEAD AA 2 A_Chase ("","MissileAfterAvoid", CHF_FASTCHASE) // hexen boss dodging
			HEAD A 2 A_FaceTarget
			HEAD AA 2 A_Chase ("","MissileAfterAvoid", CHF_FASTCHASE) // hexen boss dodging
			HEAD A 2 A_Recoil(1)
			HEAD AA 2 A_Chase ("","MissileAfterAvoid", CHF_FASTCHASE) // hexen boss dodging
			HEAD A 2 A_Recoil(1)
			HEAD AA 2 A_Chase ("","MissileAfterAvoid", CHF_FASTCHASE) // hexen boss dodging
			TNT1 A 0 A_JumpIfTargetInLOS("Melee", 190, JLOSF_DEADNOJUMP, 99, 0)
			TNT1 A 0 A_TakeInventory("EnemyMemory", 10)
			TNT1 A 0 A_JumpIfTargetInLOS("MissileAfterAvoid")
			Goto ChasePlayer			
			
/*		
		VanillaMissile:	
			TNT1 A 0
			TNT1 A 0 A_JumpIfInventory("IAmSfestMonster", 1, "VanillaMissileSfest")
			HEAD B 5 A_FaceTarget
			HEAD C 5 A_FaceTarget
			// does NOT use A_HeadAttack, to be able to perform fatality on the player (damage type "DHFT" (duke of hell fatality))
			//  damage formula taken from https://zdoom.org/wiki/A_HeadAttack
			HEAD D 5 BRIGHT A_CustomComboAttack("CacodemonBall", 34, 10 * random(1, 6), "imp/melee", "DHFT")
			TNT1 A 0 A_JumpIfInventory("Curbstomp_Marine", 1, "FatalityMarine")
			Goto VanillaSee

		VanillaMissileSfest:
			HEAD B 5 A_FaceTarget
			HEAD C 5 A_FaceTarget
			HEAD D 5 BRIGHT A_CustomComboAttack("CacodemonBallSfest", 34, 10 * random(1, 6), "imp/melee", "DHFT")
			TNT1 A 0 A_JumpIfInventory("Curbstomp_Marine", 1, "FatalityMarine")
			Goto VanillaSee
*/			
		Missile:
			TNT1 A 0
			
			// Kinslayer check:	
			TNT1 A 0 A_JumpIf(!CheckClass("FBD_Cacodemon", AAPTR_TARGET, true), 2)
			TNT1 A 0 ACS_NamedExecuteWithResult("FBD_InfightFriendlyFireOn")	
			
//			TNT1 A 0 A_JumpIfInventory("IAmClassicMonster", 1, "VanillaMissile")
		
			TNT1 A 0 A_TakeInventory("EnemyMemory", 30)
			TNT1 A 0 A_JumpIfCloser(140, "Melee")
			
			TNT1 A 0 A_FaceTarget
			TNT1 A 0 A_JumpIf(CallAcs("FBD_TargetIsInvisible"), "MissileAfterAvoid")
			TNT1 A 0 A_Jump (198, "MissileAfterAvoid") // only 23% probability to side-dash before attacking. BUT in case of our target being a player, we already perform aggressive side-dashing in our Dance state, into which we get if in player's 30-degree frontal segment (those checks don't give a flying crap about *vertical* aim, purely 2d!)
			
			TNT1 A 0 A_JumpIfInventory("CacoStamina", 15, 1) // max two such dodges, then cooldown
			Goto MissileAfterAvoid // no dodging if out of juice
			
			// the Hexen boss dodging only works closer than 640 anyway (hardcoded in C++)
			TNT1 A 0 A_JumpIfCloser(700, "Avoid")
			
			Goto MissileAfterAvoid
		Avoid:
			
			TNT1 A 0 A_TakeInventory("CacoStamina", 15)
			
			TNT1 A 0 A_JumpIfInTargetInventory("IsPlayer", 1, "AvoidPlayer")
			
			HEAD A 6 A_Chase ("","", CHF_FASTCHASE) // hexen boss dodging //A_FastChase
			NULL A 0 A_FaceTarget
			HEAD A 6 A_Chase ("","", CHF_FASTCHASE) // hexen boss dodging //A_FastChase
			NULL A 0 A_FaceTarget
			HEAD A 6 A_Chase ("","", CHF_FASTCHASE) // hexen boss dodging //A_FastChase
			NULL A 0 A_FaceTarget
			HEAD A 6 A_Chase ("","", CHF_FASTCHASE) // hexen boss dodging //A_FastChase

			//HEAD B 5 A_FaceTarget
			//HEAD C 5 A_FaceTarget
			//HEAD D 5 BRIGHT A_HeadAttack
			//Goto See	
			Goto MissileAfterAvoid
			
		AvoidPlayer:
			
			TNT1 A 0 A_JumpIfInTargetLOS("DanceThenMissile", 30, JLOSF_DEADNOJUMP | JLOSF_CLOSENOSIGHT, 700, 180)
			Goto ChasePlayer
			
		MissileAfterAvoid:	
			
//			TNT1 A 0 A_JumpIfInventory("IAmSfestMonster", 1, "MissileContinueSfest")
			HEAD B 4 //A_FaceTarget
			HEAD C 4 //A_FaceTarget
			
			//***Che: do NOT adjust aim if target goes out of sight or is invisible
			TNT1 A 0 A_JumpIf(CallAcs("FBD_TargetIsInvisible"), 4)
			TNT1 A 0 A_JumpIfTargetInLOS(2)
			TNT1 A 0 A_Jump(256, 2)
			TNT1 A 0 A_FaceTarget
			
			// not autoaimed
			HEAD D 4 BRIGHT A_CustomMissile("FBD_CacoBall", 34, 0, angle, CMF_ABSOLUTEANGLE | CMF_OFFSETPITCH | CMF_SAVEPITCH)
			Goto See
/*			
		MissileContinueSfest:
			HEAD B 4 A_FaceTarget
			HEAD C 4 A_FaceTarget
			
			// autoaimed
			HEAD D 4 BRIGHT A_CustomMissile("CacodemonBallSfest", 34, 0, 0, 0)
			Goto See
*/			
		Melee:
			TNT1 A 0
			
			TNT1 A 0 A_JumpIfInTargetInventory("GoFatality", 1, "WaitTargetsFatalityOut")
			
			// Kinslayer check:	
			TNT1 A 0 A_JumpIf(!CheckClass("FBD_Cacodemon", AAPTR_TARGET, true), 2)
			TNT1 A 0 ACS_NamedExecuteWithResult("FBD_InfightFriendlyFireOn")	
			
			//TNT1 A 0 A_JumpIfInventory("IAmClassicMonster", 1, "VanillaMissile")
			

			TNT1 A 0 A_Facetarget
			HEAD B 4 A_Recoil(-5)
			TNT1 A 0 A_PlaySound("cheb/caco_omnom", CHAN_VOICE) // demon/melee from doom, sped up and filtered. 0.4s duration.
				// the voice channel so that it is interruptable by pain			
			HEAD C 4 
			HEAD D 7 //***Che: nerfing the biting speed			
			TNT1 A 0 A_CustomMissile("CacodemonBite", 34, 0, 0, 0) // the bite itself plays "imp/melee" if it connects
			//TNT1 A 0 A_JumpIfInventory("Fatality_Marine", 1, "FatalityMarine")
			//HEAD D 4
			HEAD F 4
			TNT1 A 0 A_JumpIfInventory("Curbstomp_Marine", 1, "FatalityMarine")
			HEAD F 2 //***Che: nerfing the biting speed
			HEAD E 4
			Goto See
		
		Pain:
			HEAD E 3
			HEAD E 3 A_Pain
			TNT1 A 0 A_JumpIfInventory("CacoStamina", 15, "MaybeAvoidAfterPain")
			HEAD F 6
			Goto See
			
		MaybeAvoidAfterPain:
			TNT1 A 0 A_Jump (128, "Avoid")
			HEAD F 6
			Goto See			
			
		Pain.Argent:
			
			//TNT1 A 0 A_ClearTarget
			TNT1 A 0 HealThing(50)
			TNT1 A 0 ACS_NamedExecuteWithResult("DisplayArgentDischarge", 20, 50, 0)	
			
			HEAD E 3 A_Pain
			HEAD EFE 3 
			HEAD FF 8 A_Pain
			TNT1 A 0 A_JumpIfTargetInLOS("Missile")
			Goto See			

		Pain.Kick:
		Pain.HeavyImpact:
			TNT1 A 0 A_FaceTarget
			HEAD E 6 A_Recoil(5)
			HEAD E 6 A_Pain
			HEAD F 10
			Goto See
			
		Pain.Cut:
		Pain.Saw:
			TNT1 A 0 A_Stop
			HEAD EF 6
			Goto See

		Death.Shotgun:
			TNT1 A 0
			TNT1 A 0 A_JumpIfCloser(500, "Death.Brutal")
			TNT1 A 0 
			Goto Death
		
		Death:
		Death.CCFT: // cacodemon bite from infighting
			HEAD G 3 A_Scream
			HEAD H 3 A_NoBlocking
			//TNT1 A 0 A_CustomMissile("CacodemonEyeBall", 50, 0, 0)
			TNT1 AAAA 0 A_CustomMissile ("Blue_FlyingBlood", 15, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			HEAD IJK 4
			TNT1 A 0 A_SpawnItem ("BlueGrowingBloodPool", 1)
			TNT1 A 0 A_SpawnItemEx ("FBD_DeadCacoDemon1", 0,0,0, momx,momy,momz, 0, SXF_NOCHECKPOSITION | SXF_ABSOLUTEVELOCITY)
			
			//***Che: here it is, the bug that caused the cacoes to pproliferate on being raised by viles! 
			//TNT1 A -1
			
			TNT1 A 30 A_ChangeFlag("CORPSE", 0) // give scripts and spawned objects time to access our inventory
			Stop
		
		Deathlulz:
			H3D2 A 6 A_Scream
			H3D2 B 6 A_NoBlocking
			H3D2 CD 6
			TNT1 AAAA 0 A_CustomMissile ("Blue_FlyingBlood", 15, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			H3D2 E 6
			TNT1 A 0 A_SpawnItem ("BlueGrowingBloodPool", 1)
			TNT1 A 0 A_SpawnItemEx ("FBD_DeadCacoDemon1", 0,0,0, momx,momy,momz, 0, SXF_NOCHECKPOSITION | SXF_ABSOLUTEVELOCITY)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop
			
		Death.Fatality:
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_Pain
			TNT1 A 0 A_JumpIfIntargetInventory("FistsSelected", 1, 1)
			Goto Death.SSG
			TNT1 A 0 A_FaceTarget
			//TNT1 AA 0 A_SpawnItemEx("HealthPlusFatalityBonus", 0,0,20, random (-1, 1),random (-1, 1),8, 0, SXF_ABSOLUTEVELOCITY | SXF_NOCHECKPOSITION)
			//TNT1 AA 0 A_SpawnItemEx("ArmorShardFatalityBonus", 0,0,20, random (-1, 1),random (-1, 1),8, 0, SXF_ABSOLUTEVELOCITY | SXF_NOCHECKPOSITION)
			TNT1 A 0 ACS_NamedExecuteAlways("DropFatalityBonuses", 0, 10, 10, 0) // 0, health, armor, 0 -- rounded down to nearest 2
			TNT1 A 0 A_GiveToTarget("GoFatality", 1)
			TNT1 A 0 A_Jump(128, "DeathFatality2")//5)
			TNT1 A 0 A_GiveToTarget("CacoDemonFatality", 1)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0) // without at least 8 tics delay, scripts runs ownerless
			Stop
			//TNT1 AAAAAAA 0
		DeathFatality2:
			TNT1 A 0 A_GiveToTarget("CacoDemonFatality2", 1)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0) // without at least 8 tics delay, scripts runs ownerless
			Stop
			
		Death.saw:
			TNT1 A 0 A_SetFloorClip
			TNT1 A 0 A_SetFloorClip
			TNT1 A 0 A_Scream
			TNT1 O 0 A_NoBlocking
			TNT1 A 0 A_SpawnItem("Muchblood2Blue", 0, 40)
			TNT1 AA 0 A_CustomMissile ("XDeath2Blue", 25, 0, random (0, 360), CMF_AIMDIRECTION, random (30, 150))
			TNT1 AA 0 A_CustomMissile ("XDeath3Blue", 25, 0, random (0, 360), CMF_AIMDIRECTION, random (30, 150))
			TNT1 AA 0 A_CustomMissile ("XDeath4Blue", 25, 0, random (0, 360), CMF_AIMDIRECTION, random (30, 150))
			TNT1 AAAAA 0 A_CustomMissile ("Blue_FlyingBlood", 47, 0, random (0, 360), CMF_AIMDIRECTION, random (30, 150))
			TNT1 A 0 A_CustomMissile ("CacoXDeath3", 50, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("CacoXDeath4", 50, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("CacoXDeath6", 50, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 AAA 0 A_CustomMissile ("CacoXDeath7", 50, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			HEDC AB 9
			TNT1 A 0 A_SpawnItem ("BlueGrowingBloodPool", 1)
			TNT1 A 0 A_SpawnItemEx ("SawedCacodemon", 0,0,0, momx,momy,momz, 0, SXF_NOCHECKPOSITION | SXF_ABSOLUTEVELOCITY)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop		
			
		Death.cut:
		Death.ExplosiveImpact:
		Death.FriendlyExplosion: //***Che
			TNT1 A 0 A_SetFloorClip
			TNT1 A 0 A_Scream
			TNT1 O 0 A_NoBlocking
			TNT1 A 0 A_SpawnItem("Muchblood2Blue", 0, 40)
			TNT1 AA 0 A_CustomMissile ("XDeath2Blue", 25, 0, random (0, 360), CMF_AIMDIRECTION, random (30, 150))
			TNT1 AA 0 A_CustomMissile ("XDeath3Blue", 25, 0, random (0, 360), CMF_AIMDIRECTION, random (30, 150))
			TNT1 AA 0 A_CustomMissile ("XDeath4Blue", 25, 0, random (0, 360), CMF_AIMDIRECTION, random (30, 150))
			TNT1 A 0 A_CustomMissile ("RipCaco", 0, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			CCD3 A 6
			TNT1 A 0 A_SpawnItem ("BlueGrowingBloodPool", 1)
			TNT1 A 0 A_SpawnItemEx ("DeadHalfCacoDemon", 0,0,0, momx,momy,momz, 0, SXF_NOCHECKPOSITION | SXF_ABSOLUTEVELOCITY)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop

		Death.SniperBullet:
		Death.Bullet792:			
		Death.Minigun:
			TNT1 O 0 A_Jump(64, 2)
			Goto Death.Brutal
			TNT1 A 0 A_SetFloorClip
			TNT1 A 0 A_SetFloorClip
			TNT1 A 0 A_Scream
			TNT1 O 0 A_NoBlocking
			TNT1 A 0 A_SpawnItem("Muchblood2Blue", 0, 40)
			TNT1 A 0 A_CustomMissile ("RipCaco", 0, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 AA 0 A_CustomMissile ("XDeath2Blue", 25, 0, random (0, 360), CMF_AIMDIRECTION, random (30, 150))
			TNT1 AA 0 A_CustomMissile ("XDeath3Blue", 25, 0, random (0, 360), CMF_AIMDIRECTION, random (30, 150))
			TNT1 AA 0 A_CustomMissile ("XDeath4Blue", 25, 0, random (0, 360), CMF_AIMDIRECTION, random (30, 150))
			CCD3 A 6
			TNT1 A 0 A_SpawnItem ("BlueGrowingBloodPool", 1)
			TNT1 A 0 A_SpawnItemEx ("DeadHalfCacoDemon", 0,0,0, momx,momy,momz, 0, SXF_NOCHECKPOSITION | SXF_ABSOLUTEVELOCITY)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop
		
		Death.Brutal:
		Death.Blast:
		Death.Railgun:
			TNT1 A 0 A_SetFloorClip
			TNT1 A 0 A_SetFloorClip
			TNT1 A 0 A_Scream
			TNT1 O 0 A_NoBlocking
			TNT1 A 0 A_FaceTarget
			TNT1 A 0 A_SpawnItem("Muchblood2Blue", 0, 40)
			TNT1 A 0 A_CustomMissile ("XDeath2bBlue", 25, 0, random (0, 360), CMF_AIMDIRECTION, random (30, 150))
			TNT1 A 0 A_CustomMissile ("XDeath3bBlue", 25, 0, random (0, 360), CMF_AIMDIRECTION, random (30, 150))
			TNT1 A 0 A_CustomMissile ("XDeath2Blue", 25, 0, random (160, 210), CMF_AIMDIRECTION, random (30, 60))
			TNT1 A 0 A_CustomMissile ("XDeath3Blue", 25, 0, random (160, 210), CMF_AIMDIRECTION, random (30, 60))
			TNT1 A 0 A_CustomMissile ("CacoXDeath3", 50, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("CacoXDeath4", 50, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("CacoXDeath6", 50, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 AAA 0 A_CustomMissile ("CacoXDeath7", 50, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			CCD1 A 0
			TNT1 A 0 A_SpawnItemEx("FBD_BrutalizedCacodemon1",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop
			
			
		Death.SuperPlasma:
		Death.Plasma: 
		Death.Plasma2:
		Death.Electric:
			TNT1 A 0
			TNT1 A 0 A_Scream
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_Stop
			CACB AA 0 A_CustomMissile ("XDeathBurnedBlueMeat1", 0, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			CACB AA 0 A_CustomMissile ("XDeathBurnedBlueMeat2", 0, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			CACB B 3 A_CustomMissile ("BurnParticles", 16, 0, random (0, 180), 2, random (0, 180))
			TNT1 A 0 A_JumpIf(momz == 0, "FallAndBurn")
			CACB B 3 A_CustomMissile ("BurnParticles", 16, 0, random (0, 180), 2, random (0, 180))
			TNT1 A 0 A_JumpIf(momz == 0, "FallAndBurn")
			CACB B 3 A_CustomMissile ("BurnParticles", 16, 0, random (0, 180), 2, random (0, 180))
			TNT1 A 0 A_JumpIf(momz == 0, "FallAndBurn")
			CACB B 3 A_CustomMissile ("BurnParticles", 16, 0, random (0, 180), 2, random (0, 180))
			TNT1 A 0 A_JumpIf(momz == 0, "FallAndBurn")
			CACB B 3 A_CustomMissile ("BurnParticles", 16, 0, random (0, 180), 2, random (0, 180))
			TNT1 A 0 A_JumpIf(momz == 0, "FallAndBurn")
			CACB B 3 A_CustomMissile ("BurnParticles", 16, 0, random (0, 180), 2, random (0, 180))
			TNT1 A 0 A_JumpIf(momz == 0, "FallAndBurn")
			CACB B 3 A_CustomMissile ("BurnParticles", 16, 0, random (0, 180), 2, random (0, 180))
			TNT1 A 0 A_JumpIf(momz == 0, "FallAndBurn")
			CACB B 3 A_CustomMissile ("BurnParticles", 16, 0, random (0, 180), 2, random (0, 180))
			TNT1 A 0 A_JumpIf(momz == 0, "FallAndBurn")
			
		FallAndBurn:	

			TNT1 A 0 A_SpawnItemEx ("DetectFloorCraterSmall",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
			TNT1 A 0 A_SpawnItem("BarrelExplosionSmokeColumn")
			TNT1 AA 0 A_SpawnItemEx("TinyBurningPiece", random (-15, 15), random (-15, 15))
			TNT1 AAA 0 A_SpawnItemEx("TinyBurningPiece2", random (-35, 35), random (-35, 35))
			TNT1 AAA 0 A_SpawnItemEx("TinyBurningPiece3", random (-45, 45), random (-45, 35))
			CACB B 8 A_CustomMissile ("BurnParticles", 16, 0, random (0, 180), 2, random (0, 180))
			
			CACB B -1 //***Che: Gibbed monsters -- ONLY the gibbed monsters -- may use this
				//   to auto-respawn on nightmare and be raised by viles.
				// Employing this on a destructible corpse results in that corpse
				//   respawning on nightmare as a corpse (or worse, as a burning hollering demon)
				// If a monster's death state spawns a destructible corpse,
				//   the respawning/raising is relegated to that corpse
				//   and the monster MUST use Stop instead	
			Stop
			
		Death.fire:
		Death.Flames:
			TNT1 A 0
			TNT1 A 0 A_Scream
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_Playsound("props/redfire")
			TNT1 A 0 A_CustomMissile ("PlasmaSmoke", 24, 0, random (0, 180), 2, random (0, 180))
			TNT1 A 0 A_SpawnItemEx("BurningCacoDemon", 0,0,0, momx,momy,momz, 0, SXF_NOCHECKPOSITION | SXF_ABSOLUTEVELOCITY)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop
			
		
		XDeath:
		Death.Desintegrate:
		Death.Bfg10k: //***Che changed damage type from extreme to custom
			TNT1 A 0 A_XScream
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_ChangeFlag("NOGRAVITY", 0) //***Che
			// CacoXDeath is a pure gore spawner. 
			// Angles given here do nothing, it spams its pieces all around 360
			TNT1 A 0 A_CustomMissile ("CacoXDeath", 0, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			
			TNT1 A -1 //***Che: Gibbed monsters -- ONLY the gibbed monsters -- may use this
				//   to auto-respawn on nightmare and be raised by viles.
				// Employing this on a destructible corpse results in that corpse
				//   respawning on nightmare as a corpse (or worse, as a burning hollering demon)
				// If a monster's death state spawns a destructible corpse,
				//   the respawning/raising is relegated to that corpse
				//   and the monster MUST use Stop instead
			Stop
			
			
		Death.SSG:
		Death.ExtremePunches:
			TNT1 A 0
			CCD3 A 1 A_Pain
			TNT1 A 0 A_FaceTarget
			TNT1 A 0 A_Scream
			TNT1 AAAAAA 0 A_CustomMissile ("BlueBloodMistBig", 50, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 50))
			TNT1 AAAAAA 0 A_CustomMissile ("BlueBloodMistBig", 50, 0, random (160, 200), 2, random (20, 40))
			TNT1 AA 0 A_CustomMissile ("XDeath2Blue", 25, 0, random (140, 230), 2, random (30, 60))
			TNT1 AA 0 A_CustomMissile ("XDeath3Blue", 25, 0, random (140, 230), 2, random (30, 60))
			TNT1 AA 0 A_CustomMissile ("XDeath4Blue", 25, 0, random (140, 230), 2, random (30, 60))
			
			TNT1 A 0 A_CustomMissile ("CacoXDeath2", 50, 0, random (160, 200), 2, random (20, 40))
			TNT1 A 0 A_CustomMissile ("CacoXDeath1", 50, 0, random (160, 200), 2, random (20, 40))
			TNT1 A 0 A_CustomMissile ("CacoXDeath3", 50, 0, random (160, 200), 2, random (20, 40))
			TNT1 A 0 A_CustomMissile ("CacoXDeath4", 50, 0, random (160, 200), 2, random (20, 40))
			TNT1 AA 0 A_CustomMissile ("CacoXDeath5", 50, 0, random (160, 200), 2, random (20, 40))
			TNT1 AAAA 0 A_CustomMissile ("CacoXDeath6", 50, 0, random (160, 200), 2, random (20, 40))
			TNT1 AAAAAA 0 A_CustomMissile ("CacoXDeath7", 50, 0, random (160, 200), 2, random (20, 40))
			CCD3 A 1 A_NoBlocking
			TNT1 A 0 A_SpawnItem ("BlueGrowingBloodPool", 1)
			TNT1 A 0 A_Stop
			TNT1 A 0 A_SpawnItemEx("DeadHalfCacoDemon",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop

		
		Raise:  // we were put into this state by the game engine that restored our height and made us solid	
			TNT1 A 0
			TNT1 A 0 A_SpawnItemEx("StandaloneBlueRezSfx",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 0 A_CheckFlag("SOLID", "NormalRaise")
			TNT1 A 0 A_ChangeFlag("NOGRAVITY", 1)
			HEAD L 8 A_UnSetFloorClip
			HEAD KJIHG 8
			TNT1 A 0 ACS_NamedExecuteWithResult("FBD_CustomizeOnRez") // it runs OnRezMapScript
				// if the map prpvides one
			Goto See
			
		FallbackRaise: // we were put into this state by the superarchvile AOE raising, our height is hopelessly kaput and we have to spawn a substitute
			"----" A 0 A_GiveInventory("RezzingNow")
			"----" A 0 A_ChangeFlag("CORPSE", 0)
			"----" A 0 A_ChangeFlag("COUNTKILL", 0)
			"----" A 0 A_ChangeFlag("SHOOTABLE", 0)
			"----" A -1 ACS_NamedExecuteWithResult("FallbackRezMkII", 2011) // see _mob_list.xlsx
			Stop
			
		FallbackRezSuccess:
			TNT1 A 0 A_SpawnItemEx("StandaloneBlueRezSfx",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30
			Stop				
		
		Crush:
			TNT1 A 0
			TNT1 A 0
			TNT1 AAAAAA 0 A_SpawnItem("BodyRemovalThing")
			TNT1 A 1 A_XScream
			
			TNT1 A -1 // be rezzable
			Stop

		Pain.KillMe:
		Pain.Taunt:
			TNT1 A 0 HealThing(1)
			Goto Missile
		Death.KillMe:
		Death.Taunt:
		Death.Avoid:
			//TNT1 A 0 A_ChangeFlag("SOLID", 0)
			//TNT1 A 0 A_SpawnItem("CacoDemon")
			//Stop
			
			// aggroes at you but dies from the strain while bleeding from his ass
			TNT1 A 0 A_PlaySound("cheb/caco_omnom", CHAN_VOICE)
			HEAD B 4 A_Facetarget
			HEAD C 4 A_Recoil(-5)
			HEAD D 16
			HEAD E 3 A_Pain
			HEAD EEEFFEEE 3 A_CustomMissile ("Blue_FlyingBlood", -15, 20, random (160, 200), CMF_AIMDIRECTION, random (-40, -20))
			HEAD F 16 A_Pain
			HEAD FFFEEFFFEEFFF 2 A_CustomMissile ("Blue_FlyingBlood", -15, 20, random (160, 200), CMF_AIMDIRECTION, random (-40, -20))
			Goto Death

		FatalityMarine:
			TNT1 A 0 A_SetInvulnerable
			CFPF A 1

			//TNT1 A 0 A_PlaySound("DSFDTHE") // which is BIGSCRE
			//***Che: moved the scream to the player, to allow for a gender-appropriate version
			// the scream is cut off after 60 tics!
			
			CFPF A 10
			TNT1 AAA 0 A_CustomMissile ("XDeath1", 1, 0, random (0, 360), 2, random (0, 160))
			TNT1 AA 0 A_CustomMissile ("BrainBlood", 25, 0, random (0, 360), 2, random (0, 160))

			CFPF B 9
			TNT1 AAA 0 A_CustomMissile ("XDeath1", 1, 0, random (0, 360), 2, random (0, 160))
			TNT1 AA 0 A_CustomMissile ("BrainBlood", 25, 0, random (0, 360), 2, random (0, 160))
			CFPF C 9


			CFPF B 9
			TNT1 AAA 0 A_CustomMissile ("XDeath1", 1, 0, random (0, 360), 2, random (0, 160))
			TNT1 AA 0 A_CustomMissile ("BrainBlood", 25, 0, random (0, 360), 2, random (0, 160))
			CFPF C 9

			CFPF B 9
			TNT1 AAA 0 A_CustomMissile ("XDeath1", 1, 0, random (0, 360), 2, random (0, 160))
			TNT1 AA 0 A_CustomMissile ("BrainBlood", 25, 0, random (0, 360), 2, random (0, 160))
			CFPF C 9

			CFPF B 9
			TNT1 AAA 0 A_CustomMissile ("XDeath1", 1, 0, random (0, 360), 2, random (0, 160))
			TNT1 AA 0 A_CustomMissile ("BrainBlood", 25, 0, random (0, 360), 2, random (0, 160))
			CFPF C 9
			TNT1 A 0 A_TakeInventory("Curbstomp_Marine",1)
			TNT1 A 0 A_SpawnItem("RipGuts", 0, 40)
			TNT1 A 0 A_SpawnItem ("PlayerJustGotCutInHalf", 1)
			TNT1 A 0 A_UnSetInvulnerable
			Goto See

		Death.Ice:
		Death.Freeze:
		Death.Frost:
			TNT1 A 0
			TNT1 A 0 A_StopSound(CHAN_VOICE) 
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_SpawnItemEx ("FrozenCacodemon", 0,0,0, momx,momy,momz, 0, SXF_NOCHECKPOSITION | SXF_ABSOLUTEVELOCITY)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop
			
		Death.IOS_Frost:
			TNT1 A 0
			TNT1 A 0 A_StopSound(CHAN_VOICE) 
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_SpawnItemEx ("PermaFrostCacodemon", 0,0,0, momx,momy,momz, 0, SXF_NOCHECKPOSITION | SXF_ABSOLUTEVELOCITY) 
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop
		
			
		Death.Massacre:
			Goto Death

		Death.DHFT: // duke of hell melee
			TNT1 A 0 A_Jump(256, "Death", "Death.Brutal", "Death.saw")
			Goto Death			
		
	}
}


ACTOR CacodemonRaisedByVile: FBD_Cacodemon {
	+NOPAIN
	-FLOORCLIP
	States {
		Spawn:
			TNT1 A 0 NODELAY ACS_NamedExecuteWithResult("FBD_RunMonster")
			
			TNT1 A 0 A_ChangeFlag("NOPAIN", 1)			
			//HEAD LKJIHG 8
			CCD3 BA 3
			CCD2 EA 3
			CCD1 EA 3
			TNT1 A 0 A_ChangeFlag("NOPAIN", 0)
			TNT1 A 0 ACS_NamedExecuteWithResult("FBD_CustomizeOnRez") // it runs OnRezMapScript
				// if the map prpvides one
			Goto See		

	}
}


//===========================================================================
//
// Cacodemon plasma ball
//
//===========================================================================
ACTOR FBD_CacoBall Replaces CacodemonBall
{
	Game Doom
	SpawnID 126
	Radius 6
	Height 6
	Speed 14
	FastSpeed 18
	Damage (random(30,30))
	Projectile 
	+RANDOMIZE
	+THRUGHOST
	+FORCEXYBILLBOARD
	RenderStyle Add
	Alpha 0.95
    damagetype Plasma
	SeeSound "caco/attack"
	DeathSound "caco/shotx"
	Decal "Scorch"
	Scale 0.3
	
	//***Che
	-NOBLOCKMAP // without this, A_RadiusGive does not see them 
	 // and so projectile-destroying effects do not work
	 // see Demon EleTech gun's ligtning element alt fire. 		
	
	States
	{
		Spawn:
			PBAL DE 2 BRIGHT
			Loop
		Death:
			TNT1 A 0 A_CustomMissile ("ShoqueAzul", 3, 0, random (0, 360), 2, random (0, 360))
			EXPL A 0 A_CustomMissile ("FireBallExplosionFlames", 1, 0, random (0, 360), 2, random (0, 360))
			EXPL A 0 A_CustomMissile ("BluePlasmaFire", 1, 0, random (0, 360), 2, random (0, 360))
			TNT1 A 0 A_CustomMissile ("BDExplosionparticlesSmall", 10, 0, random (0, 180), 2, random (40, 90))
			TNT1 AAA 1 A_SpawnItem("RedFlare")
			Stop
	}
}

ACTOR CacodemonBallSfest: FBD_CacoBall { // mostly to remove the light source linked from GLDEFS
	States {
		Death:
			// Nah, those are all short-lived anyway.
			TNT1 A 0 A_CustomMissile ("ShoqueAzul", 3, 0, random (0, 360), 2, random (0, 360))
			TNT1 A 0 A_CustomMissile ("FireBallExplosionFlames", 1, 0, random (0, 360), 2, random (0, 360))
			TNT1 A 0 A_CustomMissile ("BluePlasmaFire", 1, 0, random (0, 360), 2, random (0, 360))
			TNT1 A 0 A_CustomMissile ("BDExplosionparticlesSmall", 10, 0, random (0, 180), 2, random (40, 90))		
			Stop
	}
}

ACTOR Shoque
{
	Game Doom
	Radius 1
	Height 1
	Speed 2
	Damage 0 
    +NOBLOCKMAP
    +NOTELEPORT
    +DONTSPLASH
	+MISSILE
	+FORCEXYBILLBOARD
    +CLIENTSIDEONLY
	RenderStyle Add
    Scale 0.7
	Gravity 0
	Alpha 0.5
	States
	{
		//***Che: variability in flipping
		Spawn: 
			TNT1 A 0
//***Che this ChebMaster is much more knowledgeable now			
			TNT1 A 0 A_SetScale(random(0,1) ? 0.7 : -0.7, random(0,1) ? 0.7 : -0.7)
/*			TNT1 A 0 A_SetScale(0.7, -0.7)
			TNT1 A 0 A_Jump(256, "Spawn1", "Spawn2", "Spawn3", "Live")
		
		Spawn1:
			TNT1 A 0
			TNT1 A 0 A_SetScale(-0.7, 0.7)
			Goto live
		Spawn2:
			TNT1 A 0
			TNT1 A 0 A_SetScale(-0.7, -0.7)
			Goto live
		Spawn3:
			TNT1 A 0
			TNT1 A 0 A_SetScale(0.7, -0.7)
			Goto live
*/			
		Live:	
			TNT1 A 1
			SHOQ ABCDEFG 1 BRIGHT
			Stop
	}
}


ACTOR ShoqueAzul
{
	Game Doom
	Radius 1
	Height 1
	Speed 3
	Damage 0 
    +NOBLOCKMAP
    +NOTELEPORT
    +DONTSPLASH
	+MISSILE
	+FORCEXYBILLBOARD
    +CLIENTSIDEONLY
	RenderStyle Add
    Scale 1.0
	Gravity 0
	States
	{
		//***Che: variability in flipping
		Spawn: 
			TNT1 A 0
			TNT1 A 0 A_SetScale(random(0,1) ? 1 : -1, random(0,1) ? 1 : -1)
/*			
			TNT1 A 0 A_Jump(256, "Spawn1", "Spawn2", "Spawn3", "Live")
		Spawn1:
			TNT1 A 0
			TNT1 A 0 A_SetScale(-1, 1)
			Goto live
		Spawn2:
			TNT1 A 0
			TNT1 A 0 A_SetScale(-1, -1)
			Goto live
		Spawn3:
			TNT1 A 0
			TNT1 A 0 A_SetScale(1, -1)
			Goto live
*/			
		Live:	
			TNT1 A 1
			SH1K ABCDEFG 2 BRIGHT
			Stop
	}
}


// xdeath are meat pieces, all are missiles

ACTOR CacoXdeath1
{
	translation "168:191=192:207"
    Radius 8
    Height 8
    Speed 9
    Scale 1.1
	Mass 1
    +NOBLOCKMAP
	+MISSILE
    +NOTELEPORT
    +MOVEWITHSECTOR
    +CLIENTSIDEONLY
    +RIPPER
    +BLOODLESSIMPACT 
	Decal BlueBloodSplat
	damagetype Blood
    SeeSound "misc/xdeath4"
    DeathSound "misc/xdeath1"
	Decal BlueBloodSplat
    States
    {
		Spawn:
			TNT1 A 0 A_JumpIf(waterlevel > 1, "Splash")
			CCP1 A 8 A_CustomMissile("Blue_BloodTrails",0,0,180,CMF_AIMDIRECTION)
			Loop
		Death:
			TNT1 A 0
			TNT1 A 0 A_QueueCorpse
			TNT1 AAAAAAA 0 A_CustomMissile ("Blue_FlyingBloodTrail", 6, 0, random (0, 180), CMF_AIMDIRECTION, random (0, 180))
			TNT1 A 0 A_SpawnItem("Blue_BloodSpot",0,0,0,1)
			//***Che
			//CCP1 B 2002
			CCP1 B 30
			TNT1 A 0 ACS_NamedExecuteAlways("BDCheckFloorType", 0, 0, 0, 0)
			CCP1 B 30
			TNT1 A 0 A_JumpIfInventory("IsOverLava", 1, "LandOnLava")
			CCP1 B -1
			Stop
		LandOnLava:
			TNT1 A 0
			TNT1 AAA 0 A_SpawnItemEx("GoreLandingOnLava", random(-7, 7), random(-7, 7))
			TNT1 A 0 A_Jump(128, "LandOnLava2")
			CACB Q 1
			CACB Q -1
			Stop
		LandOnLava2:
			CARB B 1
			CARB B -1
			Stop
						
		Splash:
			TNT1 A 0
			Stop
    }
}

ACTOR CacoXdeath1b: CacoXdeath1 { Speed 6}

ACTOR CacoXdeath2: CacoXDeath1
{
    SeeSound "misc/xdeath3"
    DeathSound "misc/xdeath1"
    States
    {
		Spawn:
			TNT1 A 0 A_JumpIf(waterlevel > 1, "Splash")
			CCP1 A 8 A_CustomMissile("Blue_BloodTrails",0,0,180,CMF_AIMDIRECTION)
			Loop
		Death:
			TNT1 A 0
			TNT1 A 0 A_QueueCorpse
			TNT1 AAAAAAA 0 A_CustomMissile ("Blue_FlyingBloodTrail", 6, 0, random (0, 180), CMF_AIMDIRECTION, random (0, 180))
			TNT1 A 0 A_SpawnItem("Blue_BloodSpot",0,0,0,1)
			//***Che
			//CCP1 C 2002
			CCP1 C 30
			TNT1 A 0 ACS_NamedExecuteAlways("BDCheckFloorType", 0, 0, 0, 0)
			CCP1 C 30
			TNT1 A 0 A_JumpIfInventory("IsOverLava", 1, "LandOnLava")
			CCP1 C -1
			Stop
		Splash:
			TNT1 A 0
			Stop		
    }
}


ACTOR CacoXdeath2b: CacoXdeath2 { Speed 7}


ACTOR CacoXdeath3: CacoXDeath1
{
    SeeSound "misc/xdeath3"
    DeathSound "misc/xdeath1"
	Scale 0.9
    States
    {
		Spawn:
			TNT1 A 0 A_JumpIf(waterlevel > 1, "Splash")
			CCP2 A 8 A_CustomMissile("Blue_BloodTrails",0,0,180,CMF_AIMDIRECTION)
			Loop
		Death:
			TNT1 A 0
			TNT1 A 0 A_QueueCorpse
			TNT1 AAAAAAA 0 A_CustomMissile ("Blue_FlyingBloodTrail", 6, 0, random (0, 180), CMF_AIMDIRECTION, random (0, 180))
			TNT1 A 0 A_SpawnItem("Blue_BloodSpot",0,0,0,1)
			
			//***Che
			//CCP2 B 2002
			//Stop
			//TNT1 A 1
			CCP2 B 30
			TNT1 A 0 ACS_NamedExecuteAlways("BDCheckFloorType", 0, 0, 0, 0)
			CCP2 B 30
			TNT1 A 0 A_JumpIfInventory("IsOverLava", 1, "LandOnLava")
			CCP2 B -1
			Stop		
    }
}

ACTOR CacoXdeath3b: CacoXdeath3 { Speed 7}

ACTOR CacoXdeath4: CacoXDeath1
{
    SeeSound "misc/xdeath3"
    DeathSound "misc/xdeath1"
	Scale 0.9
    States
    {
		Spawn:
			TNT1 A 0 A_JumpIf(waterlevel > 1, "Splash")
			CCP2 A 8 A_CustomMissile("Blue_BloodTrails",0,0,180,CMF_AIMDIRECTION)
			Loop
		Death:
			TNT1 A 0
			TNT1 A 0 A_QueueCorpse
			TNT1 AAAAAAAAA 0 A_CustomMissile ("Blue_FlyingBloodTrail", 0, 0, random (0, 180), CMF_AIMDIRECTION, random (0, 180))
			TNT1 A 0 A_SpawnItem("Blue_BloodSpot",0,0,0,1)
			
			//***Che
			//CCP2 C 2002
			//Stop
			//TNT1 A 1
			CCP2 C 30
			TNT1 A 0 ACS_NamedExecuteAlways("BDCheckFloorType", 0, 0, 0, 0)
			CCP2 C 30
			TNT1 A 0 A_JumpIfInventory("IsOverLava", 1, "LandOnLava")
			CCP2 C -1
			Stop		
    }
}

ACTOR CacoXdeath4b: CacoXdeath4 { Speed 7}

ACTOR CacoXdeath5: CacoXDeath1
{
    SeeSound "misc/xdeath3"
    DeathSound "misc/xdeath1"
    States
    {
		Spawn:
			TNT1 A 0 A_JumpIf(waterlevel > 1, "Splash")
			CCP3 A 8 A_CustomMissile("Blue_BloodTrails",0,0,180,CMF_AIMDIRECTION)
			Loop
		Death:
			TNT1 A 0
			TNT1 A 0 A_QueueCorpse
			TNT1 AAAAAAAAAAA 0 A_CustomMissile ("Blue_FlyingBloodTrail", 0, 0, random (0, 180), CMF_AIMDIRECTION, random (0, 180))
			TNT1 A 0 A_SpawnItem("Blue_BloodSpot",0,0,0,1)
			//***Che
			//CCP3 B 2002
			//Stop
			//TNT1 A 1
			CCP3 B 30
			TNT1 A 0 ACS_NamedExecuteAlways("BDCheckFloorType", 0, 0, 0, 0)
			CCP3 B 30
			TNT1 A 0 A_JumpIfInventory("IsOverLava", 1, "LandOnLava")
			CCP3 B -1
			Stop		
    }
}

ACTOR CacoXdeath5b: CacoXdeath5 { Speed 7}

ACTOR CacoXdeath6: CacoXDeath1
{
Scale 1.3
Gravity 0.6
    States
    {
		Spawn:
			TNT1 A 0 A_JumpIf(waterlevel > 1, "Splash")
			CCP4 ABCDEFG 4 A_CustomMissile("Blue_BloodTrails",0,0,180,CMF_AIMDIRECTION)
			Loop
		Death:
			TNT1 A 0
			TNT1 A 0 A_QueueCorpse
			TNT1 AAAAAAA 0 A_CustomMissile ("Blue_FlyingBloodTrail", 6, 0, random (0, 180), CMF_AIMDIRECTION, random (0, 180))
			TNT1 A 0 A_SpawnItem("Blue_BloodSpot",0,0,0,1)
			//***Che
			//CCP4 H 2002
			//Stop
			CCP4 H 30
			TNT1 A 0 ACS_NamedExecuteAlways("BDCheckFloorType", 0, 0, 0, 0)
			CCP4 H 30
			TNT1 A 0 A_JumpIfInventory("IsOverLava", 1, "LandOnLava")
			CCP4 H -1
			Stop			
    }
}

ACTOR CacoXdeath6b: CacoXdeath6 { Speed 7}

ACTOR CacoXdeath7: CacoXDeath1
{
    SeeSound "misc/xdeath4"
    DeathSound "misc/xdeath1"
	Decal BlueBloodSplat
	Scale 0.9
	Speed 16
    States
    {
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_Jump(128, "Spawn2")
			TNT1 A 0 A_JumpIf(waterlevel > 1, "Splash")
			CCP5 C 8 A_CustomMissile("Blue_BloodTrails",0,0,180,CMF_AIMDIRECTION)
			Loop
		Spawn2:
			TNT1 A 0 A_JumpIf(waterlevel > 1, "Splash")
			CCP5 D 8 A_CustomMissile("Blue_BloodTrails",0,0,180,CMF_AIMDIRECTION)
			Loop	
		Death:
			TNT1 A 0
			TNT1 A 0 A_QueueCorpse
			TNT1 A 0 A_Jump(128, "Death2")
			TNT1 A 0 A_SpawnItem("Blue_BloodSpot",0,0,0,1)
			//***Che
			//CCP5 A 2002
			//Stop
			CCP5 A 30
			TNT1 A 0 ACS_NamedExecuteAlways("BDCheckFloorType", 0, 0, 0, 0)
			CCP5 A 30
			TNT1 A 0 A_JumpIfInventory("IsOverLava", 1, "LandOnLava")
			CCP5 A -1
			Stop			
		Death2:
			TNT1 A 0
			TNT1 A 0 A_SpawnItem("Blue_BloodSpot",0,0,0,1)
			//***Che
			//CCP5 B 2002
			//Stop	
			CCP5 B 30
			TNT1 A 0 ACS_NamedExecuteAlways("BDCheckFloorType", 0, 0, 0, 0)
			CCP5 B 30
			TNT1 A 0 A_JumpIfInventory("IsOverLava", 1, "LandOnLava")
			CCP5 B -1 
			Stop				
    }
}

ACTOR CacoXdeath7b: CacoXdeath7 { Speed 7}

//***Che
ACTOR GenericCacoSplosion: FBD_FlyingBlood {
	States {
		Spawn:
			TNT1 A 0
			//TNT1 AA 0 A_CustomMissile("Blue_FlyingBlood", 15, 0, random (0, 360), 2, random (0, 160))
			TNT1 A 0
			Goto Death
		Death:
			TNT1 A 0
			TNT1 AAA 0 A_CustomMissile ("CacoXDeath7b", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (20, 90))
			TNT1 AAA 0 A_CustomMissile ("CacoXDeath1b", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (20, 90))
			TNT1 A 0 A_CustomMissile ("CacoXDeath2b", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (20, 90))
			TNT1 A 0 A_CustomMissile ("CacoXDeath3b", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (20, 90))
			TNT1 A 0 A_CustomMissile ("CacoXDeath4b", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (20, 90))
			TNT1 AA 0 A_CustomMissile ("CacoXDeath6b", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (20, 90))
			TNT1 AAA 0 A_CustomMissile ("XDeath1Blue",30, 0, random (0, 360), CMF_AIMDIRECTION, random (20, 90))
			TNT1 AA 0 A_CustomMissile ("XDeath2bBlue", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (20, 90))
			TNT1 A 0 A_CustomMissile ("XDeath3bBlue", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (20, 90))
			TNT1 A 3
			Stop
	}
}

ACTOR HalfCacodemon
{
    Radius 8
    Height 8
	Speed 12
	Mass 1
    +NOBLOCKMAP
	+MISSILE
    +NOTELEPORT
    +DONTSPLASH
	+DOOMBOUNCE
    +MOVEWITHSECTOR
    +CLIENTSIDEONLY
	SeeSound "misc/xdeath4"
    DeathSound "misc/xdeath3"
	Decal BlueBloodSplat
	BounceFactor 0.5
	Scale 0.9
	
	-CORPSE // is NOT. FUCKING. RAISEABLE.
    States
    {
		//***Che
		Raise:
			Stop //***Che: NOT raiseable. I witnessed the horror of them cacoes multiplying like dividing cells. No more!
		Spawn:
			TNT1 A 0
		Fly:	  
			TNT1 A 0 A_JumpIf(waterlevel > 1, "Death")
			CACX ABCDEFGH 2 A_CustomMissile("Blue_FlyingBlood", 15, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			Loop
		Death:
			TNT1 A 0
			TNT1 A 0 A_QueueCorpse
			
			//***Che
			//CACX I -1
			//Stop
			CACX I 30
			TNT1 A 0 ACS_NamedExecuteAlways("BDCheckFloorType", 0, 0, 0, 0)
			CACX I 30
			TNT1 A 0 A_JumpIfInventory("IsOverLava", 1, "LandOnLava")
			
			//***Che: prevent the game engine from auto-respawning this corpse on nightmare as a corpse
			// while allowiing archviles raising it (they only check for the CORPSE flag)
			// and respawning via script on nightmare
			//TNT1 A 0 A_ChangeFlag("CORPSE", 1)
			//TNT1 A 0 A_ChangeFlag("ISMONSTER", 0)
			CACX I -1 //***Che: Stop. Don't uncomment. That way lies only madness! ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop
			
		LandOnLava:
			TNT1 A 0
			TNT1 A 0 A_SpawnItemEx ("CharredMeatsplosionBlue", 0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			
			//***Che: prevent the game engine from auto-respawning this corpse on nightmare as a corpse
			// while allowiing archviles raising it (they only check for the CORPSE flag)
			// and respawning via script on nightmare
			//TNT1 A 0 A_ChangeFlag("CORPSE", 1)
			//TNT1 A 0 A_ChangeFlag("ISMONSTER", 0)
			//TNT1 A -1 //ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop
    }
}


Actor FBD_DeadCacoDemon1: FBD_CurbstompedMarine Replaces DeadCacodemon
{
	Radius 24 //***Che otherwise raising failures //12
	Height 24
	Scale 0.9
	+SHOOTABLE
	-SOLID
	+NOTELEPORT
	+MOVEWITHSECTOR
	+CORPSE
	bloodtype "Blue_Blood", "BlueFBD_SawBlood", "BlueFBD_SawBlood"
	bloodcolor darkblue
	Mass 10000
	Health 300
	damagefactor "CrushedBodies", 500.0
	States
    {
		//***Che
		Raise:
			// note: the frame letter of the "----" (keep previous) sprite is ignored
			"----" A 0
			"----" A 0 A_ChangeFlag("CORPSE", 0)
			"----" A 0 A_GiveInventory("RezzingNow")
			"----" A 0 A_NoBlocking // the raising code deep in C++ makes it solid
			"----" A 0 A_JumpIf(!CallAcs("EnoughSpaceToRezNormally", 2011), "FallbackRaise")
			// The vile had already copied his friendliness and target to this corpse.
			// A_SpawnItem(Ex) automatically copy friendliness
			//   and target, but only if both the spawner and the spawnee are monsters.
			"----" A 0 A_ChangeFlag("COUNTKILL", 0)
			"----" A 0 A_ChangeFlag("ISMONSTER", 1)
			"----" A 0 A_SpawnItemEx ("CacodemonRaisedByVile",0,0,0, 0,0,0, 0,SXF_TRANSFERPOINTERS | SXF_NOCHECKPOSITION)
			"----" A 1 A_Jump(256, "OnRezSfx")
			Wait //Zandronum client repeats the last frame while it waits for a status update from the server
			
		FallbackRaise:
			"----" A 0 A_GiveInventory("RezzingNow")
			"----" A 0 A_ChangeFlag("CORPSE", 0)
			"----" A 0 A_ChangeFlag("SHOOTABLE", 0)
			//"----" A -1 ACS_NamedExecuteAlways("FallbackRez", 0, 10, 0, 0) //"CacodemonRaisedByVile"
			"----" A -1 ACS_NamedExecuteWithResult("FallbackRezMkII", 2011) // see _mob_list.xlsx
			Stop
		OnRezSfx:
			// knight, baron, duke, belphegor and cacodemon corpses must replace this method with one that has appropriate blood color
			TNT1 AAA 3 A_CustomMissile ("BlueBloodMistBig", 20, 0, random (0, 360), 2, random (30, 90))
			TNT1 AAAA 3 A_CustomMissile ("BlueBloodMist", 20, 0, random (0, 360), 2, random (30, 90))
			TNT1 AAAAA 3 A_CustomMissile ("BlueBloodMistSmall", 20, 0, random (0, 360), 2, random (30, 90))
			TNT1 A 30
			Stop			
		//***Che // this is a descendant of FBD_CurbstompedMarine, which is neither a missile nor a monster
		Spawn:
		Stay: // ancestor's Pain.Kick, Pain.ExplosiveImpact and Pain.Trample redirect here after z-thrusting the actor
			HEAD L 5 
			TNT1 A 0 A_CheckFloor("Slide")  // if this goes before the non-zero frame, we have an infinite loop!
			Loop
		Slide:
			TNT1 A 0
			TNT1 A 0 A_JumpIf(momx != 0 || momy != 0, "Stay") // not until the actor stops sliding		
		Land:	
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteAlways("FBD_CheckFloorIsLava_V", 0, 0, 0, 0) // also spawns smoke for 30 tics if succeeds
			HEAD L 30
			TNT1 A 0 A_JumpIf(user_floor_is_lava, "LandOnLava")	
			
			//***Che: prevent the game engine from auto-respawning this corpse on nightmare as a corpse
			// while allowiing archviles raising it (they only check for the CORPSE flag)
			// and respawning via script on nightmare
			TNT1 A 0 A_ChangeFlag("CORPSE", 1)
			TNT1 A 0 A_ChangeFlag("ISMONSTER", 0)	
			HEAD L -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop
		LandOnLava: // used by descendant classes
			TNT1 A 0
			TNT1 A 0 A_SpawnItem ("CharredMeatsplosionBlue")
			
			//***Che: prevent the game engine from auto-respawning this corpse on nightmare as a corpse
			// while allowiing archviles raising it (they only check for the CORPSE flag)
			// and respawning via script on nightmare
			TNT1 A 0 A_ChangeFlag("CORPSE", 1)
			TNT1 A 0 A_ChangeFlag("ISMONSTER", 0)				
			TNT1 A -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop			
			
		Death:
		Death.Electric:
			TNT1 AAA 0 A_CustomMissile ("CacoXDeath7b", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (20, 90))
			TNT1 AAA 0 A_CustomMissile ("CacoXDeath1b", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (20, 90))
			TNT1 A 0 A_CustomMissile ("CacoXDeath2b", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (20, 90))
			TNT1 A 0 A_CustomMissile ("CacoXDeath3b", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (20, 90))
			TNT1 A 0 A_CustomMissile ("CacoXDeath4b", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (20, 90))
			TNT1 AA 0 A_CustomMissile ("CacoXDeath6b", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (20, 90))
			TNT1 AAA 0 A_CustomMissile ("XDeath1Blue",30, 0, random (0, 360), CMF_AIMDIRECTION, random (20, 90))
			TNT1 AA 0 A_CustomMissile ("XDeath2bBlue", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (20, 90))
			TNT1 A 0 A_CustomMissile ("XDeath3bBlue", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (20, 90))
			TNT1 A 0 A_CustomMissile ("MuchBlood2Blue", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 50))
			TNT1 A 0 A_SpawnItemEx("DeadHalfCacoDemon",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop
		Death.cut:
		Death.ExplosiveImpact:
		Death.FriendlyExplosion:
			TNT1 A 0 A_SetFloorClip
			TNT1 A 0 A_Scream
			TNT1 O 0 A_NoBlocking
			TNT1 A 0 A_CustomMissile ("RipCaco", 0, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			CACL A 1
			TNT1 A 0 A_SpawnItemEx ("DeadHalfCacoDemon", 0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop
		Death.Plasma: 
		Death.Plasma2:
		XDeath.Electric:
			TNT1 A 0 A_Scream
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_SpawnItemEx ("DetectFloorCraterSmall",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
			TNT1 A 0 A_SpawnItem("BarrelExplosionSmokeColumn")
			TNT1 A 0 A_SpawnItemEx("TinyBurningPiece", random (-15, 15), random (-15, 15))
			TNT1 AA 0 A_SpawnItemEx("TinyBurningPiece2", random (-35, 35), random (-35, 35))
			TNT1 AA 0 A_SpawnItemEx("TinyBurningPiece3", random (-45, 45), random (-45, 35))
			CACB A 0 A_CustomMissile ("XDeathBurnedBlueMeat1", 0, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			CACB A 0 A_CustomMissile ("XDeathBurnedBlueMeat2", 0, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			
			//***Che: prevent the game engine from auto-respawning this corpse on nightmare as a corpse
			// while allowiing archviles raising it (they only check for the CORPSE flag)
			// and respawning via script on nightmare
			TNT1 A 0 A_ChangeFlag("CORPSE", 1)
			TNT1 A 0 A_ChangeFlag("ISMONSTER", 0)			
			CACB B -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop
			
		
		Death.Fire: 
		Death.Burn: 
		Death.Flames:
			TNT1 A 0 A_Scream
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_SpawnItemEx ("DetectFloorCraterSmall",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
			TNT1 A 0 A_SpawnItem("BarrelExplosionSmokeColumn")
			TNT1 A 0 A_SpawnItemEx("TinyBurningPiece", random (-15, 15), random (-15, 15))
			TNT1 AA 0 A_SpawnItemEx("TinyBurningPiece2", random (-35, 35), random (-35, 35))
			TNT1 AA 0 A_SpawnItemEx("TinyBurningPiece3", random (-45, 45), random (-45, 35))
			//CACB BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB 8 A_CustomMissile ("PlasmaSmoke", 16, 0, random (0, 180), 2, random (0, 180))
			//***Che: charred caco with no blood underneath:
			TNT1 A 0 ACS_NamedExecuteWithResult("BurnedCorpseSmoke") 
			//CARB UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU 8 A_CustomMissile ("PlasmaSmoke", 16, 0, random (0, 180), 2, random (0, 180))
			
			//***Che: prevent the game engine from auto-respawning this corpse on nightmare as a corpse
			// while allowiing archviles raising it (they only check for the CORPSE flag)
			// and respawning via script on nightmare
			TNT1 A 0 A_ChangeFlag("CORPSE", 1)
			TNT1 A 0 A_ChangeFlag("ISMONSTER", 0)
			CARB U -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			//CACB B -1
			Stop
		
		Death.Bfg10k: //***Che changed damage type from extreme to custom
		Death.CrushedBodies:
		Crush:
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_SetAngle(0)
			TNT1 A 0 A_CustomMissile ("XDeath1Blue", 5, random (-30, 30), random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("XDeath2bBlue", 5, random (-30, 30), random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("XDeath3bBlue", 5, random (-30, 30), random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 AAAAA 0 A_CustomMissile ("BlueBloodMistBig", 5, random (-40, 40), random (0, 360), CMF_AIMDIRECTION, random (30, 90))
			TNT1 A 0 A_SetAngle(90)
			TNT1 A 0 A_CustomMissile ("XDeath1Blue", 5, random (-30, 30), random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("XDeath2bBlue", 5, random (-30, 30), random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("XDeath3bBlue", 5, random (-30, 30), random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 AAAAAA 0 A_CustomMissile ("BlueBloodMistBig", 5, random (-40, 40), random (0, 360), CMF_AIMDIRECTION, random (30, 90))
			TNT1 A 1 A_XScream
			
			//***Che: prevent the game engine from auto-respawning this corpse on nightmare as a corpse
			// while allowiing archviles raising it (they only check for the CORPSE flag)
			// and respawning via script on nightmare
			TNT1 A 0 A_ChangeFlag("CORPSE", 1)
			TNT1 A 0 A_ChangeFlag("ISMONSTER", 0)
			CRS2 B -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop 
		
	}
}

Actor DeadHalfCacoDemon: FBD_DeadCacoDemon1
{
	Health 200 
	States{
		//***Che // this is a descendant of FBD_CurbstompedMarine, which is neither a missile nor a monster
		Spawn:
		Stay: // ancestor's Pain.Kick, Pain.ExplosiveImpact and Pain.Trample redirect here after CCD3 Bz-thrusting the actor
			CCD3 B 5 
			TNT1 A 0 A_CheckFloor("Slide")  // if this goes before the non-zero frame, we have an infinite loop!
			Loop
		Slide:
			TNT1 A 0
			TNT1 A 0 A_JumpIf(momx != 0 || momy != 0, "Stay") // not until the actor stops sliding		
		Land:	
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteAlways("FBD_CheckFloorIsLava_V", 0, 0, 0, 0) // also spawns smoke for 30 tics if succeeds
			CCD3 B 30
			TNT1 A 0 A_JumpIf(user_floor_is_lava, "LandOnLava")	
			
			//***Che: prevent the game engine from auto-respawning this corpse on nightmare as a corpse
			// while allowiing archviles raising it (they only check for the CORPSE flag)
			// and respawning via script on nightmare
			TNT1 A 0 A_ChangeFlag("CORPSE", 1)
			TNT1 A 0 A_ChangeFlag("ISMONSTER", 0)
			CCD3 B -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop
			
		Death:
		Death.Cut:
		Death.SniperBullet:
		Death.Bullet792:		
		Death.Minigun:
			TNT1 A 0 A_NoBlocking
			TNT1 AAA 0 A_CustomMissile ("CacoXDeath1b", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (20, 90))
			TNT1 AA 0 A_CustomMissile ("CacoXDeath2b", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (20, 90))
			TNT1 AA 0 A_CustomMissile ("CacoXDeath3b", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (20, 90))
			TNT1 AA 0 A_CustomMissile ("CacoXDeath4b", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (20, 90))
			TNT1 AA 0 A_CustomMissile ("CacoXDeath5b", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (20, 90))
			TNT1 AAA 0 A_CustomMissile ("XDeath1Blue",30, 0, random (0, 360), CMF_AIMDIRECTION, random (20, 90))
			TNT1 AA 0 A_CustomMissile ("XDeath2bBlue", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (20, 90))
			TNT1 A 0 A_CustomMissile ("XDeath3bBlue", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (20, 90))
			TNT1 A 0 A_CustomMissile ("MuchBlood2Blue", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 50))
			
			//***Che: prevent the game engine from auto-respawning this gibbed corpse on nightmare as a corpse
			// while allowiing archviles raising it (they only check for the CORPSE flag)
			// and respawning via script on nightmare
			TNT1 A 0 A_ChangeFlag("CORPSE", 1)
			TNT1 A 0 A_ChangeFlag("ISMONSTER", 0)
			TNT1 A -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop
	}
}
	   
Actor DeadCacoDemon2: FBD_DeadCacoDemon1
{
	Health 200 
	States{
		//***Che // this is a descendant of FBD_CurbstompedMarine, which is neither a missile nor a monster
		Spawn:
		Stay: // ancestor's Pain.Kick, Pain.ExplosiveImpact and Pain.Trample redirect here after z-thrusting the actor
			CCD2 B 5 
			TNT1 A 0 A_CheckFloor("Slide")  // if this goes before the non-zero frame, we have an infinite loop!
			Loop
		Slide:
			TNT1 A 0
			TNT1 A 0 A_JumpIf(momx != 0 || momy != 0, "Stay") // not until the actor stops sliding		
		Land:	
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteAlways("FBD_CheckFloorIsLava_V", 0, 0, 0, 0) // also spawns smoke for 30 tics if succeeds
			CCD2 B 30
			TNT1 A 0 A_JumpIf(user_floor_is_lava, "LandOnLava")	
			
			//***Che: prevent the game engine from auto-respawning this gibbed corpse on nightmare as a corpse
			// while allowiing archviles raising it (they only check for the CORPSE flag)
			// and respawning via script on nightmare
			TNT1 A 0 A_ChangeFlag("CORPSE", 1)
			TNT1 A 0 A_ChangeFlag("ISMONSTER", 0)
			CCD2 B -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop			
	}
}	
	   
Actor DeadCacoDemon3: FBD_DeadCacoDemon1
{
	Health 200 
	States{
		//***Che // this is a descendant of FBD_CurbstompedMarine, which is neither a missile nor a monster
		Spawn:
		Stay: // ancestor's Pain.Kick, Pain.ExplosiveImpact and Pain.Trample redirect here after z-thrusting the actor
			CCD1 C 5 
			TNT1 A 0 A_CheckFloor("Slide")  // if this goes before the non-zero frame, we have an infinite loop!
			Loop
		Slide:
			TNT1 A 0
			TNT1 A 0 A_JumpIf(momx != 0 || momy != 0, "Stay") // not until the actor stops sliding		
		Land:	
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteAlways("FBD_CheckFloorIsLava_V", 0, 0, 0, 0) // also spawns smoke for 30 tics if succeeds
			CCD1 C 30
			TNT1 A 0 A_JumpIf(user_floor_is_lava, "LandOnLava")	
			
			//***Che: prevent the game engine from auto-respawning this gibbed corpse on nightmare as a corpse
			// while allowiing archviles raising it (they only check for the CORPSE flag)
			// and respawning via script on nightmare
			TNT1 A 0 A_ChangeFlag("CORPSE", 1)
			TNT1 A 0 A_ChangeFlag("ISMONSTER", 0)
			CCD1 C -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop				
	}
}		   
		
		
Actor SawedCacoDemon: FBD_DeadCacoDemon1
{
	Health 400
	States{
		//***Che // this is a descendant of FBD_CurbstompedMarine, which is neither a missile nor a monster
		Spawn:
		Stay: // ancestor's Pain.Kick, Pain.ExplosiveImpact and Pain.Trample redirect here after z-thrusting the actor
			HEDC C 5 
			TNT1 A 0 A_CheckFloor("Slide")  // if this goes before the non-zero frame, we have an infinite loop!
			Loop
		Slide:
			TNT1 A 0
			TNT1 A 0 A_JumpIf(momx != 0 || momy != 0, "Stay") // not until the actor stops sliding		
		Land:	
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteAlways("FBD_CheckFloorIsLava_V", 0, 0, 0, 0) // also spawns smoke for 30 tics if succeeds
			HEDC C 30
			TNT1 A 0 A_JumpIf(user_floor_is_lava, "LandOnLava")	
			
			//***Che: prevent the game engine from auto-respawning this gibbed corpse on nightmare as a corpse
			// while allowiing archviles raising it (they only check for the CORPSE flag)
			// and respawning via script on nightmare
			TNT1 A 0 A_ChangeFlag("CORPSE", 1)
			TNT1 A 0 A_ChangeFlag("ISMONSTER", 0)
			HEDC C -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop			
		Death.Cut: 
		Death.SniperBullet:
		Death.Bullet792:		
		Death.Minigun:	        
		Death:
			TNT1 AAA 0 A_CustomMissile ("CacoXDeath7b", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (20, 90))
			TNT1 AAA 0 A_CustomMissile ("CacoXDeath1b", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (20, 90))
			TNT1 AA 0 A_CustomMissile ("CacoXDeath2b", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (20, 90))
			TNT1 AA 0 A_CustomMissile ("CacoXDeath3b", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (20, 90))
			TNT1 AA 0 A_CustomMissile ("CacoXDeath4b", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (20, 90))
			TNT1 AA 0 A_CustomMissile ("CacoXDeath6b", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (20, 90))
			TNT1 AAA 0 A_CustomMissile ("XDeath1Blue",30, 0, random (0, 360), CMF_AIMDIRECTION, random (20, 90))
			TNT1 AA 0 A_CustomMissile ("XDeath2bBlue", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (20, 90))
			TNT1 A 0 A_CustomMissile ("XDeath3bBlue", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (20, 90))
			TNT1 AAAAAA 0 A_CustomMissile ("BlueBloodMistBig", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 50))
			TNT1 A 0 A_CustomMissile ("MuchBlood2Blue", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 50))
			
			//***Che: prevent the game engine from auto-respawning this gibbed corpse on nightmare as a corpse
			// while allowiing archviles raising it (they only check for the CORPSE flag)
			// and respawning via script on nightmare
			TNT1 A 0 A_ChangeFlag("CORPSE", 1)
			TNT1 A 0 A_ChangeFlag("ISMONSTER", 0)
			TNT1 A -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop
	}
}	
		
		
		
		
		
		
ACTOR CacodemonBite: ImpAttack
{
    +THRUGHOST
	//DamageType HKFT // a regular scream
	DamageType CCFT //***Che a horrible scream cut off after 60 tics
    Damage 5
}





ACTOR FBD_BrutalizedCacodemon1: FBD_DeadCacoDemon1

	//This one is a short-lived transitional actor, so:
	//1. No checking for lava
	//2. No trying to slaughterdetect on our own

{
	Radius 24
	Height 48
	Health 50
	Scale 1.0
	States
	{
		//***Che // this is a descendant of FBD_CurbstompedMarine, which is neither a missile nor a monster
		Spawn:
			TNT1 A 0 NODELAY A_Jump(96, "NoSuffer")
			TNT1 A 0 A_Jump(64, "Fall")
			CCD1 AAEEAAEEAAAAEEAAEEAA 5 A_CustomMissile ("Blue_BloodTrails", 40, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
		Fall:
			TNT1 AAAAA 0 A_NoBlocking
			TNT1 A 0 A_Fall
			TNT1 A 0 A_ChangeFlag("SHOOTABLE", 0)
			TNT1 A 0 A_ChangeFlag("SOLID", 0)
			CCD1 ABC 6
			TNT1 A 0 A_SpawnItemEx("DeadCacodemon3",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop
		Stay: // ancestor's Pain.Kick, Pain.ExplosiveImpact and Pain.Trample redirect here after z-thrusting the actor
			TNT1 A 0
			Goto Fall

		Death:
			TNT1 AAAAA 0 A_CustomMissile ("Blue_FlyingBlood", 47, 0, random (0, 360), CMF_AIMDIRECTION, random (30, 150))
			TNT1 A 0 A_CustomMissile ("CacoXDeath3", 40, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("CacoXDeath4", 40, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("CacoXDeath6", 40, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 AAA 0 A_CustomMissile ("CacoXDeath7", 40, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 AAAA 0 A_CustomMissile ("BlueBloodMistBig", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 50))
			CCD2 A 10
			TNT1 A 0 A_SpawnItemEx("FBD_BrutalizedCacodemon2",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop
			
			
		
		NoSuffer:
			TNT1 AAAAA 0 A_CustomMissile ("Blue_FlyingBlood", 47, 0, random (0, 360), CMF_AIMDIRECTION, random (30, 150))
			TNT1 A 0 A_CustomMissile ("CacoXDeath3", 40, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("CacoXDeath4", 40, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("CacoXDeath6", 40, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 AAA 0 A_CustomMissile ("CacoXDeath7", 40, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			CCD2 B 6
			TNT1 A 0 A_ChangeFlag("SHOOTABLE", 0)
			TNT1 A 0 A_ChangeFlag("SOLID", 0)
			TNT1 A 0 A_SpawnItemEx("DeadCacoDemon2",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop	
	}
}

ACTOR FBD_BrutalizedCacodemon2: FBD_BrutalizedCacodemon1
{

	//This one is a short-lived transitional actor, so:
	//1. No checking for lava
	States
	{
		//***Che // this is a descendant of FBD_CurbstompedMarine, which is neither a missile nor a monster
		Spawn:
			CCD2 A 1
			CCD2 AEAEAEAEAEAEAEAE 5 A_CustomMissile ("Blue_BloodTrails", 40, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_Fall
			CCD2 B 6
			TNT1 A 0 A_ChangeFlag("SHOOTABLE", 0)
			TNT1 A 0 A_ChangeFlag("SOLID", 0)
			TNT1 A 0 A_SpawnItemEx("DeadCacodemon2",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop		
		Stay: // ancestor's Pain.Kick, Pain.ExplosiveImpact and Pain.Trample redirect here after z-thrusting the actor
			TNT1 A 0
			Goto Death		
		Death:
			TNT1 AAAAA 0 A_CustomMissile ("Blue_FlyingBlood", 47, 0, random (0, 360), CMF_AIMDIRECTION, random (30, 150))
			TNT1 AAAA 0 A_CustomMissile ("Blue_FlyingBloodTrail", 0, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 180))
			TNT1 AA 0 A_CustomMissile ("CacoXDeath6", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 AAAAA 0 A_CustomMissile ("CacoXDeath7", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 AAAAAA 0 A_CustomMissile ("BlueBloodMistBig", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 50))
			//TNT1 A 0 A_SpawnItemEx("ArmorShardFatalityBonus", 0,0,0, random (-1, 1),random (-1, 1),8, 0, SXF_ABSOLUTEVELOCITY | SXF_NOCHECKPOSITION)
			TNT1 A 0 ACS_NamedExecuteAlways("DropFatalityBonuses", 0, 0, 5, 0) // 0, health, armor, 0 -- rounded down to nearest 2
			CCD3 A 10
			TNT1 A 0 A_SpawnItemEx("DeadHalfCacoDemon",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop	
	}
}

	
	
ACTOR CacoStamina: fbd_Token
{
	Inventory.MaxAmount 30
}


#include Caclet.txt

#include Cacolord.txt






