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




// NOTE #3: BD_CheckBloodIntensity now also checks for the slaughtercount 
//   and forces LowBlood if it is over 1200.
//  -- in case I forgot a slaughtercheck or a CMF_TRACKOWNER somewhere

// NOTE: Blood can run ACS scripts and use jump functions clientside
//  only thanks to being marked as +CLIENTSIDE
//  When non-clientside actors try doing that, nothing happens.



//All the liquid gore stuff goes here.


/* Zandronum source code for reference

void P_SpawnBlood (fixed_t x, fixed_t y, fixed_t z, angle_t dir, int damage, AActor *originator)
{
	// [BB] Initialize with NULL.
	AActor *th = NULL;
	PalEntry bloodcolor = originator->GetBloodColor();
	const PClass *bloodcls = originator->GetBloodType();
	
	int bloodtype = cl_bloodtype;
	
	if (bloodcls != NULL && !(GetDefaultByType(bloodcls)->flags4 & MF4_ALLOWPARTICLES))
		bloodtype = 0;

	if (bloodcls != NULL)
	{
		z += pr_spawnblood.Random2 () << 10;
		th = Spawn (bloodcls, x, y, z, NO_REPLACE); // GetBloodType already performed the replacement
		th->velz = FRACUNIT*2;
		th->angle = dir;
		// [NG] Applying PUFFGETSOWNER to the blood will make it target the owner
		if (th->flags5 & MF5_PUFFGETSOWNER) th->target = originator; //<------------------------------
																//***Che: FUCKING **THIS**!



*/


//Hit puff actor

actor FBD_Blood Replaces Blood
{
	Decal BrutalBloodSplat
	Renderstyle Translucent
	+FORCEXYBILLBOARD
	+THRUACTORS
	+CLIENTSIDEONLY
	
	//***Che for slaughterchecks! 
	// Blood's Target is set to the monster bleeding - 
	// allowing for TNT1 A 0 A_JumpIfInTargetInventory("IAmSfestMonster", 1, "LowBlood")
	+PUFFGETSOWNER
	
	Speed 0
	Scale 0.8
	Alpha 1.0
	Mass 999999
	
	//***Che
	+NOBLOCKMAP // for optimization: actors *without* this flag are costlier to create, delete
		// and they add to the cost of anything, from AOE damage to A_RadiusGive 
		// to hitscan checks, by simply existing!		
	
	states
	{
		Spawn:
			BSPR A 0
			TNT1 A 0 A_CustomMissile ("SuperGoreMistTiny", 0, 0, random (0, 360), 2, random (0, 90))
			TNT1 A 0 A_JumpIf(waterlevel > 1, "Splash")
			
			// THIS!!! instead of complicated slaughterswapsthat rek map's scripting
			//TNT1 A 0 A_JumpIfInTargetInventory("IAmSfestMonster", 1, "LowBlood")
			//P.S. No, *this*:
			TNT1 A 0 A_JumpIf(!CallAcs("FBD_RequestExpensiveSfx", 90), "LowBlood") 
			
			TNT1 A 0 A_PlaySound("misc/xdeath5")
			TNT1 A 0 ACS_NamedExecuteWithResult("BD_CheckBloodIntensity")
			TNT1 A 0 A_CustomMissile ("WaterBloodCHecker", 7, 0, random (0, 360), 2, random (30, 60))
			
		Spawn2:
			TNT1 A 0 A_CustomMissile ("FBD_FlyingBlood", 7, 0, random (0, 360), 2, random (30, 60))
			TNT1 A 0 A_CustomMissile ("Brutal_FlyingBloodTrail", 0, 0, random (0, 360), 2, random (20, 90))
			Goto LowBlood  
		Splash:
			BLOD A 0
			TNT1 AAA 0 A_CustomMissile ("Underblood1", 7, 0, random (0, 360), 2, random (30, 150))
			stop
		LotsOfBlood:
		   TNT1 A 0
		   TNT1 AAAA 0 A_CustomMissile ("BloodMistSmall", 0, 0, random (0, 360), 2, random (0, 90))
		   TNT1 AAAAA 0 A_CustomMissile ("FBD_FlyingBlood", 7, 0, random (0, 360), 2, random (30, 70))
		   TNT1 A 0 A_CustomMissile ("SuperWallRedBlood", 0, 0, random (0, 360), 2, random (-15, 15))
		   TNT1 AAAA 0 A_CustomMissile ("Brutal_FlyingBloodTrail", 0, 0, random (0, 360), 2, random (0, 90))
		   Goto LowBlood  
		AbsurdBlood:
		   TNT1 A 2
		   TNT1 AAAA 0 A_CustomMissile ("SuperWallRedBlood", 0, 0, random (0, 360), 2, random (-15, 15))
		   TNT1 A 0 A_JumpIfInventory("AnimuGore", 1, "AnimuGore")
		   TNT1 AA 0 A_CustomMissile ("FBD_Bloodmist", 0, 0, random (0, 360), 2, random (0, 90))
		   TNT1 AAA 0 A_CustomMissile ("Brutal_FlyingBloodMuchFaster", 7, 0, random (0, 360), 2, random (10, 50))
		   TNT1 A 0 A_CustomMissile ("Brutal_FlyingBloodMuchFaster", 7, 0, random (0, 360), 2, random (40, 60))
		   TNT1 A 0 A_CustomMissile ("BloodmistSmall", 7, 0, random (0, 360), 2, random (30, 90))
		   TNT1 A 0 A_CustomMissile ("SuperGoreMist", 0, 0, random (0, 360), 2, random (10, 90))
		   TNT1 AAAAA 0 A_CustomMissile ("FBD_FlyingBlood", 7, 0, random (0, 360), 2, random (30, 70))
		   TNT1 AAA 0 A_CustomMissile ("BloodmistSpray", 0, 0, random (0, 360), 2, random (20, 90))
		   Goto LowBlood  
		AnimuGore:
		   TNT1 AAA 0 A_CustomMissile ("Brutal_FlyingBloodMuchFaster", 7, 0, random (0, 360), 2, random (10, 50))
		   TNT1 A 0 A_CustomMissile ("SuperWallRedBlood", 0, 0, random (0, 360), 2, random (-15, 15))
		   TNT1 A 0 A_CustomMissile ("Brutal_FlyingBloodMuchFaster", 7, 0, random (0, 360), 2, random (40, 60))
		   TNT1 AAAAAAA 0 A_CustomMissile ("FBD_FlyingBlood", 7, 0, random (0, 360), 2, random (30, 70))
		   TNT1 AAAAAAAAA 0 A_CustomMissile ("XDeath1", 0, 0, random (0, 360), 2, random (40, 80))
		   TNT1 A 0 A_CustomMissile ("SuperGoreSpawner", 0, 0, random (0, 360), 2, random (10, 90))
		   TNT1 AAAAA 0 A_CustomMissile ("BloodmistSpray", 0, 0, random (0, 360), 2, random (20, 90))
		   Goto LowBlood  
		LowBlood:
			TNT1 A 0
			TNT1 A 0 A_Jump(128, 2)
			TNT1 A 0 A_SetScale(-0.7, 0.8)
			BSPR BCDEFGHIJJ 1
			Stop
			
		SpawnPlayer:
			TNT1 A 0
			TNT1 A 0 A_CustomMissile ("SuperGoreMistTiny", 0, 0, random (0, 360), 2, 0)
			TNT1 A 0 A_CustomMissile ("FBD_FlyingBlood", 7, 0, random (0, 360), 2, random (30, 60))
			TNT1 A 0 A_CustomMissile ("Brutal_FlyingBloodTrail", 0, 0, random (0, 360), 2, random (20, 90))
			TNT1 A 0 A_Jump(128, 2)
			TNT1 A 0 A_SetScale(-0.7, 0.8)
			BSPR BCDEFGHIJJ 1 BRIGHT
			Stop
		Vanish:
			TNT1 A 1
			Stop
	}
}


Actor FBD_LegshotBlood: FBD_Blood
// aping after BDv22's Blood_Imp : Brutal_Blood
{
	Decal None
	-ALLOWPARTICLES 
	-CLIENTSIDEONLY
	+MISSILE
	+SERVERSIDEONLY
	+PUFFGETSOWNER
	Damagetype "Leg"
	+NODAMAGETHRUST
	+NOINTERACTION
	States
	{
		Spawn:
			TNT1 A 0 NoDelay A_FaceTarget
			TNT1 A 0 A_SpawnItemEx("FBD_Blood",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			
			TNT1 A 0 A_JumpIf(CallAcs("GetZDeltaToTarget") >= -25, "HitLeg")
			TNT1 A 0 A_TakeFromTarget("HitLeg", 0x7FFFFFFF)
			Stop

		HitLeg:
			TNT1 A 0 A_GiveToTarget("HitLeg", 1)
			Stop
			
	}
}


Actor FBD_LegshotBloodSaw: FBD_LegshotBlood
{
	States
	{
		Spawn:
			TNT1 A 0 NoDelay A_FaceTarget
			TNT1 A 0 A_SpawnItemEx("FBD_SawBlood",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			
			TNT1 A 0 A_JumpIf(CallAcs("GetZDeltaToTarget") <= -25, "HitLeg")
			TNT1 A 0 A_TakeFromTarget("HitLeg", 0x7FFFFFFF)
			Stop

		HitLeg:
			TNT1 A 0 A_GiveToTarget("HitLeg", 1)
			Stop
			
	}
}




//Dummy actor just to replace the bloodpuff made by Hexen axe
actor FBD_SawBlood : FBD_Blood Replaces AxeBlood
{
	-ALLOWPARTICLES 
	Speed 1
	 states
	{
		Spawn:			
			TNT1 A 1
			TNT1 A 0 A_JumpIfInTargetInventory("HasCutingWeapon", 1, "HitSaw", AAPTR_TARGET)
			TNT1 A 0 A_JumpIfInTargetInventory("IAmSfestMonster", 1, "LowBlood")
			BSPR A 0
			TNT1 A 0 A_CustomMissile ("SuperGoreMistTiny", 0, 0, random (0, 360), 2, random (0, 90))
			TNT1 A 0 A_JumpIf(waterlevel > 1, "Splash")
			TNT1 A 0 A_PlaySound("misc/xdeath5")
			TNT1 A 0 ACS_NamedExecuteWithResult("BD_CheckBloodIntensity")
			TNT1 A 0 A_CustomMissile ("WaterBloodCHecker", 7, 0, random (0, 360), 2, random (30, 60))
		Spawn2:
			TNT1 A 0 A_CustomMissile ("FBD_FlyingBlood", 7, 0, random (0, 360), 2, random (30, 60))
			TNT1 A 0 A_CustomMissile ("Brutal_FlyingBloodTrail", 0, 0, random (0, 360), 2, random (20, 90))
			Goto LowBlood  
		
		HitSaw:
			TNT1 A 1
			TNT1 A 0 A_RadiusGive("ChainsawHitRed", 200, RGF_PLAYERS | RGF_MONSTERS , 1) //***Che this signals player's weapon to keep looping the sawinganimation instead of completing the swing
			TNT1 A 0 A_RadiusGive("PowerBloodOnVisor", 200, RGF_PLAYERS | RGF_MONSTERS , 1)
			TNT1 A 0 A_CustomMissile ("BloodmistChainsaw", -10, 0, random (0, 360), 2, random (60, 90))
			TNT1 A 0 A_CustomMissile ("XDeath1", 0, 0, random (0, 360), 2, random (40, 80))
			TNT1 A 0 A_CustomMissile ("ChainsawWallRedBlood", 0, 0, random (0, 360), 2, random (-10, 80))
			TNT1 A 0 A_PlaySound("CSAWFLESH")
			//***Che there seems to be a bug in Zandronum that focuses the effect on the *player* instead of the activator
			TNT1 A 0 A_JumpIf(CallACS("GetDistanceToClosestPlayer") > 200, 2)
			TNT1 A 0 Radius_Quake (2, 2, 0, 2, 0)
			TNT1 A 0
			Stop
	}
}


//Dummy actor just to replace the bloodpuff made by projectiles
actor BloodSPlatterReplacer : FBD_Blood Replaces BloodSplatter{ speed 4}
actor BrainBlood : FBD_Blood{ speed 4}


//Base flying blood actor. Leaves bloodspots on the floor
ACTOR FBD_FlyingBlood 
{
	scale 0.5
	speed 4
	radius 8
	height 1
	Gravity 0.8
	Renderstyle Translucent
	Alpha 0.9
	Decal BrutalBlood
	Mass 1
	+MISSILE   
	+CLIENTSIDEONLY
	+NOTELEPORT   
	+NOBLOCKMAP
	+THRUACTORS   
	+FORCEXYBILLBOARD
	+MOVEWITHSECTOR   
	+DONTSPLASH
   
	+PUFFGETSOWNER
    States
    {
		Spawn:
			TNT1 A 0
			//TNT1 A 0 A_JumpIfInTargetInventory("IAmSfestMonster", 1, "NoSpawn")
			TNT1 A 0 A_JumpIf(waterlevel > 1, "Splash")
			TNT1 A 0 A_Jump(256, "Spawn1", "Spawn2", "Spawn3", "Live")
		Spawn1:
			TNT1 A 0
			TNT1 A 0 A_SetScale(-0.6, 0.6)
			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.6, -0.6)
			Goto live		
				
		Live:
			BSPR ABCDEFGH 2
			BSPR I 100 A_JumpIf(waterlevel > 1, "Splash")
			Stop	
		
		Splash:
			BLOD A 0
			TNT1 A 0 A_JumpIfInTargetInventory("IAmSfestMonster", 1, "Vanish")
			TNT1 A 0 A_SpawnItem ("Underblood2")
			stop
			
		Death:
			TNT1 A 0
			TNT1 A 0 A_JumpIfInTargetInventory("IAmSfestMonster", 1, "Vanish")
			TNT1 A 0 A_PlaySound("blooddrop2")
			TNT1 A 0 A_CheckFloor("DeathFloor")
			TNT1 A 1
			Stop
  
		DeathFloor:
			//***Che:
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteAlways("FBD_CheckFloorIsLava", 0, 0, 0, 0)
			XDT1 E 2
			TNT1 A 0 A_JumpIfInventory("IsOverLava", 1, "LandOnLava")
			
			//original code:
			//TNT1 A 0
			TNT1 A 0 A_SpawnItemEx ("Brutal_BloodSpot",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION |  SXF_TRANSFERTRANSLATION,0)
			TNT1 A 0 A_PlaySound("blooddrop2")
		    XDT1 FGHIJKL 2 //EFGHIJKL 2
			Stop
			
		NoSpawn:
		Vanish:
			TNT1 A 0
			Stop
					
		LandOnLava:	//***Che
			TNT1 A 0
			TNT1 A 0 A_SpawnItemEx("BloodDropLandingOnLava", 0, 0)
			TNT1 A 0 
			TNT1 A 0
			Stop	
			
    }
}


//Faster version used in some specific cases
ACTOR Brutal_FlyingBloodMuchFaster: FBD_FlyingBlood
{
	 Scale 1.0
	 Speed 8
}


actor Brutal_FlyingBloodTrail 
{
	scale 0.5
	mass 1
	renderstyle Normal
	Decal BrutalBloodSplat
	+NOTELEPORT
	+NOBLOCKMAP
	+FORCEXYBILLBOARD
	+CLIENTSIDEONLY
	+MISSILE
	+THRUACTORS
	+DONTSPLASH
	+PUFFGETSOWNER
	Gravity 0.4
	Speed 2
	states
	{
		Spawn:
			TNT1 A 0
			//TNT1 A 0 A_JumpIfInTargetInventory("IAmSfestMonster", 1, "Death")
			TNT1 A 0 A_JumpIf(waterlevel > 1, "Splash")
			TNT1 A 0
			TNT1 A 0 A_Jump(128, 2)
			TNT1 A 0 A_SetScale (-0.5, 0.6)
			BL8A ABCDE 1
			BL8A F 60
			stop
	  
		Death:
			TNT1 A 0
			Stop

		Splash:
			BLOD A 0
			TNT1 A 0 A_JumpIfInTargetInventory("IAmSfestMonster", 1, "Death")
			TNT1 A 0 A_SpawnItem ("Underblood2")
			stop

	}
}

///***Che
actor Brutal_FlyingBloodTrailNoDecal: Brutal_FlyingBloodTrail {
	+NODECAL
}


actor Brutal_FlyingBloodFaster: Brutal_FlyingBloodTrail
{
	Speed 3
	Scale 0.7
	+BOUNCEONWALLS
	states
	{
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_JumpIfInTargetInventory("IAmSfestMonster", 1, "Death")
			TNT1 A 0 A_JumpIf(waterlevel > 1, "Splash")
			TNT1 A 0
			TNT1 A 0 A_Jump(128, 2)
			TNT1 A 0 A_SetScale (-0.7, 0.9)
			BL8A ABCDEF 2
			BL8A F 35
			stop
	}
}


ACTOR Brutal_FlyingBloodFake: Brutal_FlyingBloodTrail 
{
	scale 0.5
	speed 3
	Gravity 0.3
	Renderstyle Translucent
	Alpha 0.95
	+NOCLIP
    Mass 1
    States
    {
     Spawn:
	    TNT1 A 0 A_JumpIf(waterlevel > 1, "Splash")
		BLOD KKKKKKKKKKKK 1 A_FadeOut(0.05)
        Stop
	Splash:
        BLOD A 0
		TNT1 A 0 A_SpawnItem ("Underblood2")
        stop
	Death:
	    TNT1 A 10
		Stop
    }
}

ACTOR Brutal_FlyingBloodFakeNoDecal: Brutal_FlyingBloodFake { decal "none"}

ACTOR Brutal_FlyingBloodTrail5: Brutal_FlyingBloodTrail { decal "none"}
ACTOR Brutal_FlyingBloodTrail8: Brutal_FlyingBloodTrail { decal "none"}
ACTOR BloodTrails: Brutal_FlyingBloodTrail { decal "none"}
ACTOR BloodTr255: Brutal_FlyingBloodTrail { decal "none"}


actor FBD_Bloodmist : FBD_FlyingBlood
{
	+BOUNCEONWALLS
	+BOUNCEONCEILINGS
	+PUFFGETSOWNER
	scale 0.8
	radius 2
	height 2
	speed  8
	Gravity 0.6
	alpha 0.9
	 states
	 {
		Spawn:
			BLHT A 0
			//TNT1 A 0 A_JumpIfInTargetInventory("IAmSfestMonster", 1, "Vanish")
			//TNT1 A 0 ACS_NamedExecuteAlways("BDCHeckJanitor4", 0 , 0, 0, 0)
			BLHT A 1
			TNT1 A 0 A_Jump(256, "Spawn1", "Spawn2", "Spawn3", "Live")
		Spawn1:
			TNT1 A 0
			TNT1 A 0 A_SetScale(-0.8, 0.8)
			Goto live

		Spawn2:
			TNT1 A 0
			TNT1 A 0 A_SetScale(-0.9, -0.9)
			Goto live
			
		Spawn3:
			TNT1 A 0
			TNT1 A 0 A_SetScale(0.7, -0.7)
			Goto live		
			
		Live:
			BLHT ABCDEFGHI 3
			TNT1 A 0 
			BLHT JJJJ 6 A_JumpIf(waterlevel > 1, "Splash")
			Stop
		Vanish:
			TNT1 A 0
			Stop
		Death:
			XDT1 FGHIJKL 2
			Stop
		 
	}
}




actor BloodmistSmall : FBD_Bloodmist
{
	scale    0.5
	speed    8
	GRAVITY 1.0
	
	states
	{
		Spawn:
				TNT1 A 0
				//TNT1 A 0 A_JumpIfInTargetInventory("IAmSfestMonster", 1, "Vanish")
				//TNT1 A 0 ACS_NamedExecuteAlways("BDCHeckJanitor4", 0 , 0, 0, 0)
				TNT1 A 0 A_Jump(256, "Spawn1", "Spawn2", "Spawn3", "Live")
		Spawn1:
				TNT1 A 0
				TNT1 A 0 A_SetScale(-0.5, 0.5)
				Goto live
		
		Spawn2:
				TNT1 A 0
				TNT1 A 0 A_SetScale(-0.4, -0.4)
				Goto live
				
		Spawn3:
				TNT1 A 0
				TNT1 A 0 A_SetScale(0.5, -0.6)
				Goto live	
	}	
}

actor BloodmistBig : FBD_Bloodmist
{
	scale    1
	speed    5
	GRAVITY 0.4
	
	states
	{
		Spawn:
			TNT1 A 0
			//TNT1 A 0 A_JumpIfInTargetInventory("IAmSfestMonster", 1, "Vanish")
			//TNT1 A 0 ACS_NamedExecuteAlways("BDCHeckJanitor4", 0 , 0, 0, 0)
			TNT1 A 0 A_Jump(256, "Spawn1", "Spawn2", "Spawn3", "Live")
		Spawn1:
			TNT1 A 0
			TNT1 A 0 A_SetScale(-1.1, 1.1)
			Goto live
	
		Spawn2:
			TNT1 A 0
			TNT1 A 0 A_SetScale(-0.9, -0.9)
			Goto live
			
		Spawn3:
			TNT1 A 0
			TNT1 A 0 A_SetScale(1.0, -1.0)
			Goto live	
	}	
}


actor BloodmistExtraBig : FBD_Bloodmist
{
	scale    1.5
	speed    5
	GRAVITY 0.4
	
	states
	{
		Spawn:
			TNT1 A 0
			//TNT1 A 0 A_JumpIfInTargetInventory("IAmSfestMonster", 1, "Vanish")
			//TNT1 A 0 ACS_NamedExecuteAlways("BDCHeckJanitor4", 0 , 0, 0, 0)
			TNT1 A 0 A_Jump(256, "Spawn1", "Spawn2", "Spawn3", "Live")
		Spawn1:
			TNT1 A 0
			TNT1 A 0 A_SetScale(-1.6, 1.6)
			Goto live
	
		Spawn2:
			TNT1 A 0
			TNT1 A 0 A_SetScale(-1.5, -1.6)
			Goto live
			
		Spawn3:
			TNT1 A 0
			TNT1 A 0 A_SetScale(1.4, -1.5)
			Goto live	
	}	
}

Actor BloodMistLarge: BloodMistBig
{
	speed    6
}


actor BloodmistXXXBig : FBD_Bloodmist
{
	scale   3.0
	speed    10
	GRAVITY 0.2
	
	states
	 {
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_Jump(256, "Spawn1", "Spawn2", "Spawn3", "Live")
		Spawn1:
			TNT1 A 0
			TNT1 A 0 A_SetScale(-3.6, 3.6)
			Goto live
	
		Spawn2:
			TNT1 A 0
			TNT1 A 0 A_SetScale(-3.5, -3.6)
			Goto live
			
		Spawn3:
			TNT1 A 0
			TNT1 A 0 A_SetScale(3.2, -3.2)
			Goto live	
	}	
}



actor BloodmistXXBig : BloodmistXXXBig
{
	scale   3.0
	speed    12
}

//More wattery version
actor BloodmistSpray : FBD_Bloodmist
{
	scale    1.0
	Gravity 0.4
	states
	{
		Spawn:
			BSPR ABCDEFGHIJJJJ 2
			Stop
	}
}

actor BloodmistChainsaw : FBD_Bloodmist
{
	Scale 0.4
	Alpha 0.9
	Gravity 0.5
	Decal BrutalBloodSuper
	Speed 9
	states
	{
		Spawn:
			MSBL ABCDEFGH 1
			MSBL H 200
			Stop
	}
}





actor BloodmistSpraySmall : BloodmistSpray
{
	Speed 8
	Gravity 0.7
}



/////////////////////// BLOOD SPOTS //////////////////////////

//base bloodspot actor
ACTOR Brutal_BloodSpot
{
	radius 2
	height 2
	mass 1
	+NOTELEPORT
	+CLIENTSIDEONLY
	+FORCEXYBILLBOARD
	+MOVEWITHSECTOR
	+FLOORCLIP
	+DONTSPLASH
	-SOLID
	+THRUACTORS
	Alpha 0.99
	Scale 0.5
	Decal BrutalBloodSplat
	//***Che
	+PUFFGETSOWNER
	+NOBLOCKMAP // for optimization: actors *without* this flag are costlier to create, delete and add to the cost of anything, from AOE damage to A_RadiusGive to hitscan checks.		
	states
	{
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_JumpIfInTargetInventory("IAmSfestMonster", 1, "Vanish") 
			TNT1 A 0 A_JumpIf(waterlevel > 1, "Splash")
			TNT1 A 1

			TNT1 A 0 A_CheckFloor("SpawnNormally")
			Goto Splash
		Vanish:
			TNT1 A 0
			Stop
	  
		SpawnNormally:
		//***Che
			TNT1 A 0
			//TNT1 A 0 ACS_NamedExecuteAlways("FBD_CheckFloorIsLava", 0, 0, 0, 0)
			//TNT1 A 3 // obligatory delay because scripts run asynchronously
			//TNT1 A 0 A_JumpIfInventory("IsOverLava", 1, "LandOnLava")
			TNT1 A 0 A_JumpIf(CallAcs("FBD_CheckFloorIsLava_I"), "LandOnLava")
		//original
			//TNT1 A 0
			TNT1 A 0 A_QueueCorpse
			TNT1 A 0 A_Jump(256, "SpawnBFrameOnly", "SpawnCFrameOnly", "SpawnDFrameOnly")
		SpawnAFrameOnly:
			BPDL A -1
			Loop
		  
		SpawnBFrameOnly:
			BPDL B -1
			Loop
		  
		FadeA:
			BPDL AAAA 1 A_FadeOut(0.05)
			Stop
		  
		FadeB:
			BPDL BBBB 1 A_FadeOut(0.05)
			Stop
		  
		SpawnCFrameOnly:
			BPDL C -1
			Loop
		  
		SpawnDFrameOnly:
			BPDL D -1
			Loop
		  
		FadeC:
			BPDL CCCC 1 A_FadeOut(0.05)
			Stop
		  
		FadeD:
			BPDL DDDD 1 A_FadeOut(0.05)
			Stop
	  
		Splash:
			BLOD A 0
			stop
				
		Death:
			TNT1 A 0
			TNT1 A 0 A_NoBlocking
			Stop
			
		IsOverLiquid:
			BPDL E 1 A_FadeOut(0.9)
			BPDL EEEEEEEEEEEEEEEEEEEE 4 A_FadeIn(0.05)
			BPDL E 400
			BPDL EEEEEEEEEEEEEEEEEEEE 4 A_FadeOut(0.05)
			Stop
		LandOnLava:	//***Che
			TNT1 A 0
			TNT1 A 0 A_SpawnItemEx("BloodDropLandingOnLava", 0, 0)
			TNT1 A 0 
			Stop			
	}
}


//a special flying blood actor that spawns muddy water pools over liquids
ACTOR WaterBloodCHecker
{
    Speed 4
    Scale 1.2
	Radius 1
	+MISSILE
	+EXPLODEONWATER
	+CLIENTSIDEONLY
	+DOOMBOUNCE
	+NOBLOCKMAP //***Che
	BounceFactor 0.01
	Height 1
    SeeSound "none"
    DeathSound "none"
	Decal none
	+PUFFGETSOWNER
	States
    {
		Spawn:
			TNT1 A 5
			Loop
		Vanish:
			TNT1 A 0
			Stop
		Death:
			TNT1 A 0
	//***Che		
			TNT1 A 0 A_JumpIfInTargetInventory("IAmSfestMonster", 1, "Vanish") 
			TNT1 A 0 ACS_NamedExecuteAlways("BD_CheckIfOverLiquid") //"BD_CheckIfOverLiquid")
			TNT1 A 5
			TNT1 A 0 A_JumpIfInventory("IsOverWater", 1, "IsOverLiquid")
			TNT1 A 0 A_JumpIfInventory("IsOverSlime", 1, "IsOverLiquid")
			TNT1 A 0 A_JumpIfInventory("IsOverNukage", 1, "IsOverLiquid")
	//***Che		
			TNT1 A 0 A_JumpIfInventory("IsOverLava", 1, "IsOverLava")		
			TNT1 A 10
			Stop
			
		IsOverLiquid:
			TNT1 A 1
			TNT1 A 0 A_CheckFloor("SpawnOnWater")
			TNT1 A 2
			Stop
			
		SpawnOnWater:
			TNT1 A 1
			TNT1 A 0 A_SpawnItem ("WaterBloodSpot", 5)
			Stop
	//***Che
		IsOverLava:
			TNT1 A 1
			TNT1 A 0 A_CheckFloor("LandOnLava")
			TNT1 A 2
			Stop
		LandOnLava:	
			TNT1 A 0
			TNT1 A 0 A_SpawnItemEx("BloodDropLandingOnLava", 0, 0)
			TNT1 A 2 
			Stop	
    }
}

//muddy water bloodspot actor
ACTOR WaterBloodSpot
{
	+CLIENTSIDEONLY
	+THRUACTORS
	+NOBLOCKMAP //***Che
	Radius 0
	Height 0
	Renderstyle Shaded
	StencilColor "55 00 00"
	Alpha 0.2
	states
	{
		Spawn:
			BPDL E 1 A_FadeOut(0.9)
			BPDL EEEEEEEEEEEEEEEEEEEE 4 A_FadeIn(0.02)
			BPDL E 100
			BPDL EEEEEEEEEEEEEEEEEEEE 4 A_FadeOut(0.02)
			Stop
	}
}

//bigger bloodsplat 
actor GiantBloodSpot: Brutal_BloodSpot
{
	Scale 1.1
	States
	{
		Spawn:
			TNT1 A 0
	//***Che		
			TNT1 A 0 A_JumpIfInTargetInventory("IAmSfestMonster", 1, "Disappear") 
			TNT1 A 0 ACS_NamedExecuteAlways("BD_CheckIfOverLiquid") //"BD_CheckIfOverLiquid")//Check Floortype
			TNT1 A 3
			TNT1 A 0 A_JumpIfInventory("IsOverSlimy", 1, "Disappear")
			TNT1 A 0 A_JumpIfInventory("IsOverWater", 1, "Disappear")
			TNT1 A 0 A_JumpIfInventory("IsOverNukage", 1, "Disappear")
			TNT1 A 0 A_JumpIfInventory("IsOverLava", 1, "Disappear")
			//***Che
			TNT1 A 0 A_JumpIf(!CallAcs("FBD_RequestExpensiveSfx", 90, -50), 2)
			TNT1 A 0 A_SpawnItemEx ("BootSmearerRed",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
			TNT1 A 0 A_QueueCorpse
			Goto SpawnAFrameOnly
		
		Disappear:
			TNT1 A 0
			Stop
	}
}


actor MinuscleBloodSpot: Brutal_BloodSpot {Scale 0.25}
actor BigBloodSpot: GiantBloodSpot { Scale 0.7}
actor MediumBloodSpot: GiantBloodSpot { Scale 0.4}
actor MediumBloodSpot2: GiantBloodSpot{ Scale 0.4}


//Big version spawned by XDeath animations
ACTOR SplatteredSmall: Brutal_BloodSpot
{
	states
	{
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_JumpIfInTargetInventory("IAmSfestMonster", 1, "Vanish") 
			TNT1 A 0 A_JumpIf(waterlevel > 1, "Splash")
			TNT1 A 0 A_FaceTarget
		//***Che		
			TNT1 A 0 A_JumpIfInTargetInventory("IAmSfestMonster", 1, "Vanish") 
			TNT1 A 0 ACS_NamedExecuteAlways("BD_CheckIfOverLiquid")
			TNT1 A 3
			//TNT1 A 2
			TNT1 A 0 A_JumpIfInventory("IsOverWater", 1, "Splash")
			TNT1 A 0 A_JumpIfInventory("IsOverSlime", 1, "Splash")
			TNT1 A 0 A_JumpIfInventory("IsOverlava", 1, "Splash")
			TNT1 A 0 A_JumpIf(!CallAcs("FBD_RequestExpensiveSfx", 90, -50), 2)
			TNT1 A 0 A_SpawnItemEx ("BootSmearerRed",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
			BPDL A -1
			Stop
	}
}

//Big version spawned by XDeath animations of bigger enemies
ACTOR SplatteredLarge: Brutal_BloodSpot
{
	states
	{
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_JumpIfInTargetInventory("IAmSfestMonster", 1, "Vanish") 
			TNT1 A 0 A_JumpIf(waterlevel > 1, "Splash")
			TNT1 A 0 A_CheckFloor("Live")
			Goto Splash

		Live: 
			//***Che
			TNT1 A 0
			TNT1 A 0 A_JumpIfInTargetInventory("IAmSfestMonster", 1, "Vanish") 
			TNT1 A 0 ACS_NamedExecuteAlways("BD_CheckIfOverLiquid") //"BD_CheckIfOverLiquid")//Check if is under a liquid
			TNT1 A 4
			TNT1 A 0 A_JumpIfInventory("IsOverWater", 1, "WaterBloodSpot")
			TNT1 A 0 A_JumpIfInventory("IsOverSlime", 1, "WaterBloodSpot")
			TNT1 A 0 A_JumpIfInventory("IsOverlava", 1, "LandOnLava") //"WaterBloodSpot")
			TNT1 A 0 A_JumpIf(!CallAcs("FBD_RequestExpensiveSfx", 90, -50), 2)
			TNT1 A 0 A_SpawnItemEx ("BootSmearerRed",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
			TNT1 A 0 A_QueueCorpse
			BPDL A -1
			Stop

		WaterBloodSpot:
			TNT1 A 0
			TNT1 A 0 A_SpawnItem("WaterBloodSpot")
			Stop
	}
}



//A blood pool spawned by regular enemy deaths.
actor GrowingBloodPool: Brutal_BloodSpot
{
	var int user_bloodpoolsize;
	radius 1
	height 1
	mass 1
	Health 600
	RenderStyle Normal
	Alpha 0.99
	+NOTELEPORT
	+FORCEXYBILLBOARD
	+MOVEWITHSECTOR
	+FLOORCLIP
	+MISSILE
	+DONTSPLASH
	-CLIENTSIDEONLY
	Scale 0.3
	Decal BrutalBloodSplat
	states {
		Spawn:
		//***Che
			TNT1 A 0 A_JumpIfInTargetInventory("IAmSfestMonster", 1, "Vanish") 
			TNT1 A 0 A_JumpIf(waterlevel > 1, "Splash")
			TNT1 A 0 ACS_NamedExecuteAlways("FBD_CheckFloorIsLava")
			TNT5 A 4
			TNT1 A 0 A_JumpIfInventory("IsOverLava", 1, "LandOnLava")
			
			//original
			//TNT5 A 1
			TNT1 A 0 A_JumpIf(!CallAcs("FBD_RequestExpensiveSfx", 90, -50), 2)
			TNT1 A 0 A_SpawnItemEx ("BootSmearerRed",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
			TNT1 A 0 A_QueueCorpse //TNT5 A 2 A_QueueCorpse
			TNT5 A 1 A_SetScale(0.33, 0.33)
			TNT5 A 1 A_SetScale(0.36, 0.36)
			TNT5 A 1 A_SetScale(0.39, 0.39)
			TNT5 A 1 A_SetScale(0.42, 0.42)
			TNT5 A 1 A_SetScale(0.45, 0.45)
			TNT5 A 1 A_SetScale(0.48, 0.48)
			TNT5 A 1 A_SetScale(0.50, 0.50)

			TNT5 A 2 A_SetScale(0.53, 0.53)
			TNT5 A 2 A_SetScale(0.56, 0.56)
			TNT5 A 2 A_SetScale(0.59, 0.59)
			TNT5 A 2 A_SetScale(0.62, 0.62)
			TNT5 A 2 A_SetScale(0.65, 0.65)
			TNT5 A 2 A_SetScale(0.68, 0.68)
			TNT5 A 2 A_SetScale(0.70, 0.70)


			TNT5 A 3 A_SetScale(0.73, 0.73)
			TNT5 A 3 A_SetScale(0.76, 0.76)
			TNT5 A 3 A_SetScale(0.79, 0.79)
			TNT5 A 3 A_SetScale(0.82, 0.82)
			TNT5 A 3 A_SetScale(0.85, 0.85)
			TNT5 A 3 A_SetScale(0.88, 0.88)
			TNT5 A 3 A_SetScale(0.90, 0.90)

			TNT5 A 3 A_SetScale(0.93, 0.93)
			TNT5 A 3 A_SetScale(0.96, 0.96)
			TNT5 A 3 A_SetScale(0.99, 0.99)
			TNT5 A 3 A_SetScale(1.02, 1.02)
			TNT5 A 3 A_SetScale(1.05, 1.05)
			TNT5 A 3 A_SetScale(1.08, 1.08)
			TNT5 A 3 A_SetScale(1.11, 1.11)
		  
		Live:
			TNT5 A 900//duration
			TNT1 A 0 A_JumpIfInventory("lowgraphicsmode", 1, "Splash")
			TNT5 A -1
			Stop
		Splash:
			BLOD A 0
			stop
	}
}




//A decorative kind of flying blood spawned by arterial blood
ACTOR Brutal_LiquidBlood: FBD_FlyingBlood 
{
	speed 3
	scale 0.2
	gravity 0.6
	decal "BrutalBloodSmearSmall"
    States
    {
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_JumpIfInTargetInventory("IAmSfestMonster", 1, "SlaughterErsatz") 
			TNT1 A 0 A_CustomMissile ("Brutal_FlyingBloodTrail", 1, 0, random (0, 360), 2, random (40, 90))
			BLOD AAAAAAAAAAAAAAAAAAAAAAAAAAA 1 A_SpawnItem("Brutal_LiquidBloodTrail")
			Stop
		SlaughterErsatz:
			BL8A ABCDEFABCDEFABCDEFABCDEF 1
			Stop
		Death:
			//***Che
			TNT1 A 0
			TNT1 A 0 A_JumpIfInTargetInventory("IAmSfestMonster", 1, "Vanish")
			TNT1 A 0 ACS_NamedExecuteAlways("FBD_CheckFloorIsLava", 0, 0, 0, 0)
			XDT1 FG 2
			TNT1 A 0 A_JumpIfInventory("IsOverLava", 1, "LandOnLava")  	   
	   
			//original
			TNT1 A 0 A_PlaySound("blooddrop2")
			XDT1 HIJKL 2 //FGHIJKL 2
			TNT1 A 0
			Stop
    }
}

//Faster version, leaves no decals. Used to prevent decal overflow
ACTOR Brutal_LiquidBlood2: Brutal_LiquidBlood 
{
	speed 4
	scale 0.4
	gravity 0.6
	decal "None"
	+NODECAL
	States {
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_JumpIfInTargetInventory("IAmSfestMonster", 1, "SlaughterErsatz") 
			TNT1 A 0 A_CustomMissile ("Brutal_FlyingBloodTrailNoDecal", 1, 0, random (0, 360), 2, random (40, 90))
			BLOD AAAAAAAAAAAAAAAAAAAAAAAAAAA 1 A_SpawnItem("Brutal_LiquidBloodTrailNoDecal")
			Stop
	}
}

//Very fast version
ACTOR Brutal_LiquidBloodFast: Brutal_LiquidBlood2
{
	speed 8
}

//This version leaves a bloodspot
ACTOR Brutal_LiquidBlood3: FBD_FlyingBlood 
{
	Speed 3
    States
    {
		Death:
		   TNT1 A 0 A_PlaySound("blooddrop2")
		   TNT1 A 0 A_CheckFloor("SpawnFloor")
		   TNT1 A 4
		   Stop
		  
		SpawnFloor:
		   tnt1 a 0 A_SPawnItem("Brutal_BloodSpot")
		   XDT1 FGHIJKL 2
		   TNT1 A 0
		   Stop
    }
}


//Decorative trails
ACTOR Brutal_LiquidBloodTrail: FBD_FlyingBlood 
{
	scale 0.4
	gravity 0.4
	States
	{
		Spawn:
			TNT1 A 0
			BRTL ABC 2
			Stop
		Death:
			TNT1 A 0
			Stop
	}
}

ACTOR Brutal_LiquidBloodTrailNoDecal: Brutal_LiquidBloodTrail {
	+NODECAL
}

//An actor that will spawn multiple arterial blood actors
ACTOR ArterialBloodSpray
{
	Speed 0
	+CLIENTSIDEONLY
	+NOINTERACTION
    States
    {
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_stop
			TNT1 AAAA 2 A_CustomMissile ("Brutal_LiquidBlood2", 0, 0, 0, 2, random (0, 60))
			TNT1 A 6
			TNT1 A 2 A_CustomMissile ("Brutal_LiquidBlood2", 0, 0, 0, 2, random (0, 60))
			TNT1 A 6
			TNT1 A 2 A_CustomMissile ("Brutal_LiquidBlood2", 0, 0, 0, 2, random (0, 60))
			TNT1 A 6
			TNT1 A 2 A_CustomMissile ("Brutal_LiquidBlood2", 0, 0, 0, 2, random (0, 60))
			TNT1 A 6
			TNT1 A 2 A_CustomMissile ("Brutal_LiquidBlood2", 0, 0, 0, 2, random (0, 60))
			TNT1 A 9
			TNT1 A 2 A_CustomMissile ("Brutal_LiquidBlood2", 0, 0, 0, 2, random (0, 60))
			TNT1 A 9
			TNT1 A 2 A_CustomMissile ("Brutal_LiquidBlood2", 0, 0, 0, 2, random (0, 60))
			TNT1 A 9
			TNT1 A 2 A_CustomMissile ("Brutal_LiquidBlood2", 0, 0, 0, 2, random (0, 60))
			TNT1 A 9
			TNT1 A 2 A_CustomMissile ("Brutal_LiquidBlood2", 0, 0, 0, 2, random (0, 60))
			TNT1 A 12
			TNT1 A 2 A_CustomMissile ("Brutal_LiquidBlood2", 0, 0, 0, 2, random (0, 60))
			TNT1 A 12
			TNT1 A 2 A_CustomMissile ("Brutal_LiquidBlood2", 0, 0, 0, 2, random (0, 60))
			TNT1 A 16
			TNT1 A 2 A_CustomMissile ("Brutal_LiquidBlood2", 0, 0, 0, 2, random (0, 60))
			TNT1 A 19
			TNT1 A 2 A_CustomMissile ("Brutal_LiquidBlood2", 0, 0, 0, 2, random (0, 60))
			Stop
    }
}


ACTOR BloodDying
{
	Speed 0
	+CLIENTSIDEONLY
	+NOINTERACTION // causes +NOBLOCKMAP as well
    States
    {
		Spawn:
			TNT1 AAAA 2 A_CustomMissile ("Brutal_LiquidBlood2", 0, 0, random (0, 360), 2, random (20, 90))
			TNT1 AAAA 0 A_CustomMissile ("Brutal_FlyingBloodTrail", 0, 0, random (0, 360), 2, random (20, 90))
			Stop
    }
}

/////////////////// CEILING BLOOD //////////////////////////

//Launches bloodspots on the ceiling
ACTOR CeilBloodLauncher: FBD_FlyingBlood
{
    +THRUACTORS
	-DOOMBOUNCE
	-SKYEXPLODE
	+BOUNCEONWALLS
    Speed 15
    Gravity 0.0
	Radius 1
	Height 1
	Decal BrutalBloodSplat
	+PUFFGETSOWNER
    States
	{
		Spawn:
		    TNT1 A 0 NODELAY A_JumpIfInTargetInventory("IAmSfestMonster", 1, "XDeath")
			TNT1 A 0 A_JumpIf(waterlevel > 1, "Splash")
			TNT1 A 3
			Stop
		Splash:
			BLOD A 0
			stop
		 Death:
			TNT1 A 0
			TNT1 A 0 A_CheckCeiling("IsOnCeil")
			TNT1 A 0
			stop
			
		 IsOnCeil:
			TNT1 A 0
			TNT1 A 1 A_SpawnItem("CeilBloodSpot",0,0,0,1)
			Stop
		 Melee:
		 Xdeath:
			TNT1 A 1
			Stop
		}
}

//Longer version (for extreme deaths)
ACTOR CeilBloodLauncherLong: CeilBloodLauncher
{
    States
    {
		 Spawn:
			TNT1 A 0 NODELAY A_JumpIfInTargetInventory("IAmSfestMonster", 1, "XDeath")
			TNT1 A 0 A_JumpIf(waterlevel > 1, "Splash")
			TNT1 A 12
			Stop
    }
}



// The Ceil Blood Spot
actor CeilBloodSpot
{
	+MISSILE
	+CEILINGHUGGER
	-SKYEXPLODE
	+THRUACTORS
	Height 1
	Radius 2
	+DontSplash
	Mass 0
	Scale 0.5
	Gravity 0.0
	Decal BrutalBloodSplat
	Renderstyle Normal
	Alpha 0.9
	+NOBLOCKMAP //***Che
	states
	{
		Spawn:
			BPDL A 1
			TNT1 A 0 A_QueueCorpse
			TNT1 A 0 A_SpawnItem ("DripingBloodLeavesSmallPool")
			TNT1 A 0 A_SpawnItem ("CeilBloodTinyBloodSpawner")
		Live:	
			BPDL A 5 ThrustThingZ(0, 20, 0, 1)
			Loop
	}
}

//Bigger version of a ceil blood spot, usually left by sticky gibs.
actor CeilBloodSpotLarge: CeilBloodSpot
{
	states
	{
		Spawn:
			BPDL A 1
			TNT1 A 0 A_QueueCorpse
			TNT1 A 0 A_SpawnItem ("DripingBloodLeavesSmallPool")
			TNT1 A 0 A_SpawnItem ("CeilBloodLargeBloodSpawner")
		Live:	
			BPDL A 5 ThrustThingZ(0, 20, 0, 1)
			Loop
		Splash:
			BLOD A 0
			stop
	}
}

//These are the actors that spawns blood drips. They are separate from the bloodspots so the sticky gibs can spawn them separately.

//Small blood drips spawner, usually caused by regular blood touching the ceiling.
ACTOR CeilBloodTinyBloodSpawner: FBD_FlyingBlood
{
	+NOGRAVITY
	+THRUACTORS
	+NOCLIP
	States
	{
		 Spawn:
			  TNT1 A 0
			  TNT1 A 1 A_SpawnItemEx ("DripingBloodLeavesSmallPool", random (-5, 5), random (-5, 5), 0, 0, 0, -5)
			  TNT1 AAAAAAAAAAAAAA 5 A_SpawnItemEx ("BloodDripingFromCeiling", random (-5, 5), random (-5, 5), 0, 0, 0, -5)
			  TNT1 AAAAAAAAAAAAAA 10 A_SpawnItemEx ("BloodDripingFromCeiling", random (-5, 5), random (-5, 5), 0, 0, 0, -5)
			  TNT1 AAAAAAAAAAAAAA 16 A_SpawnItemEx ("BloodDripingFromCeiling", random (-5, 5), random (-5, 5), 0, 0, 0, -5)
			  TNT1 AAAAAAAAAAAAAA 24 A_SpawnItem ("BloodDripingFromCeiling")
			  stop
	}
}

//Large blood drips spawner, usually caused by huge chunks of meat getting stuck on the ceiling.
ACTOR CeilBloodLargeBloodSpawner: FBD_FlyingBlood
{
	+NOGRAVITY
	+THRUACTORS
	+NOCLIP
	Scale 0.5
	States
	{
		 Spawn:
			  TNT1 A 0
			  TNT1 A 1 A_SpawnItemEx ("DripingBloodLeavesSmallPool", random (-5, 5), random (-5, 5), 0, 0, 0, -5)
			  TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 3 A_SpawnItemEx ("BloodDripingFromCeilingBig", random (-5, 5), random (-5, 5), 0, 0, 0, -5)
			  TNT1 AAAAAAAAAAAAAA 10 A_SpawnItemEx ("BloodDripingFromCeilingBig", random (-5, 5), random (-5, 5), 0, 0, 0, -5)
			  TNT1 AAAAAAAAAAAAAA 15 A_SpawnItemEx ("BloodDripingFromCeiling", random (-5, 5), random (-5, 5), 0, 0, 0, -5)
			  TNT1 AAAAAAAAAAAAAA 20 A_SpawnItemEx ("BloodDripingFromCeiling", random (-5, 5), random (-5, 5), 0, 0, 0, -5)
			  stop 
	}
}

//This is the actual blood driping from the ceiling actor
ACTOR BloodDripingFromCeiling: FBD_FlyingBlood
{
	+THRUACTORS
	+CLIENTSIDEONLY
	-FORCEXYBILLBOARD
	+FORCEYBILLBOARD
	+TOUCHY
	Alpha 0.9
	Gravity 1.0
	Radius 2
	Height 1
    States {
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_Jump(230, "NoSpawn")
			TNT1 A 0 A_JumpIfInTargetInventory("IAmSfestMonster", 1, "NoSpawn")
			TNT1 A 0 A_JumpIf(waterlevel > 1, "Splash")
			BLUD Z 500
			loop
		Death:
			//***Che
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteAlways("FBD_CheckFloorIsLava", 0, 0, 0, 0)
			XDT1 E 3
			TNT1 A 0 A_JumpIfInventory("IsOverLava", 1, "LandOnLava")			
			
			//original
			//TNT1 A 0
			TNT1 A 0 A_PlaySound("blooddrop2")
			XDT1 FGHIJKL 2 //EFGHIJKL 2
			stop 
	}
}


Actor DripingBlood: BloodDripingFromCeiling {
	Alpha 0.9 
	Scale 1.0
}


//This is a bigger and denser version of the blood drip, droped by sticky gibs
ACTOR BloodDripingFromCeilingBig: BloodDripingFromCeiling
{
	XScale 0.4
	YScale 1.0
	Gravity 0.8
    States
    {
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_Jump(160, "NoSpawn")
			TNT1 A 0 A_JumpIf(waterlevel > 1, "Splash")
			BLUD Z 500
			loop
		//***Che
		// Commenting it out: use inherited ancestor's method instead
		//Death:
		//	TNT1 A 0
		//	TNT1 A 0 A_PlaySound("blooddrop2")
		//	XDT1 EFGHIJKL 2
		//	stop 
    }
}

//This is the first drip spawned by the drip spawners, which leaves a small blood pool
ACTOR DripingBloodLeavesPool: BloodDripingFromCeiling
{
	-FORCEXYBILLBOARD
	+FORCEYBILLBOARD

	 scale 0.3
    States
    {
		Spawn:
		   TNT1 A 0 A_JumpIf(waterlevel > 1, "Splash")
			BLUD Z 4
			loop
		Splash:
			BLOD A 0
			stop
		Death:
			//***Che
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteAlways("FBD_CheckFloorIsLava", 0, 0, 0, 0)
			XDT1 E 3
			TNT1 A 0 A_JumpIfInventory("IsOverLava", 1, "LandOnLava")
			
			//original
			//TNT1 A 0
			TNT1 A 0 A_SpawnItem("MediumBloodSpot")
			TNT1 A 0 A_PlaySound("blooddrop2")
			XDT1 FGHIJKL 2 //EFGHIJKL 2
			stop
    }
}

//Just like above, but leaves a smaller pool
ACTOR DripingBloodLeavesSmallPool: DripingBloodLeavesPool
{
	-FORCEXYBILLBOARD
	+FORCEYBILLBOARD
	+DONTSPLASH
	States
	{
		Death:
			//***Che
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteAlways("FBD_CheckFloorIsLava", 0, 0, 0, 0)
			XDT1 E 3
			TNT1 A 0 A_JumpIfInventory("IsOverLava", 1, "LandOnLava")
			
			//original
			//TNT1 A 0
			TNT1 A 0 A_SpawnItem("MinuscleBloodSpot")
			TNT1 A 0 A_PlaySound("blooddrop2")
			XDT1 FGHIJKL 2 //EFGHIJKL 2
			stop
    }
}

//An invisible projectile only used to spawn bloodsplats on the walls, usually spawned by extreme deaths.
ACTOR WallRedBlood
{
	scale 0.6
	speed 7
	health 1
	radius 8
	height 1
	Gravity 0.7
	damage 0
	DamageType Blood
	Decal BrutalBloodSmearer
	+MISSILE
	+CLIENTSIDEONLY
	+NOTELEPORT
	+NOBLOCKMAP
	+THRUACTORS
	+PUFFGETSOWNER
    States
    {
		Spawn:
			TNT1 A 0 NODELAY A_JumpIfInTargetInventory("IAmSfestMonster", 1, "Vanish")
			TNT1 A 0 A_JumpIf(waterlevel > 1, "Splash")
			TNT1 ABCD 4
			loop
		Splash:
			BLOD A 0
			stop
		Death:
			TNT1 A 3
			stop
		Vanish:
			TNT1 A 0
			Stop
    }
}

//This one spawns an even bigger decal
ACTOR SuperWallRedBlood: WallRedBlood
{
	speed 32
	Gravity 0.1
	Decal BrutalBloodSuper
    States	{
		Spawn:
			TNT1 A 0 NODELAY A_JumpIfInTargetInventory("IAmSfestMonster", 1, "Vanish")
			TNT1 A 0 A_JumpIf(waterlevel > 1, "Splash")
			TNT1 ABCD 1
			Stop
	}
}


//This one spawns a ridiculously bigger decal, used by BFG extreme deaths
ACTOR GiantWallRedBlood: WallRedBlood
{
	speed 32
	Gravity 0.1
	Decal BrutalBloodGiant
    States	{
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_JumpIfInTargetInventory("IAmSfestMonster", 1, "Vanish")
			TNT1 A 0 A_JumpIf(waterlevel > 1, "Splash")
			TNT1 ABCD 1
			Stop
	}
}


ACTOR ChainsawWallRedBlood: GiantWallRedBlood
{
	Decal BloodSplat
	speed 64
}

//Spawns giant blood decals all around the area. Used in Brutal Doom's BFG deaths.
Actor BloodSplinter
{
	+THRUACTORS
	+CLIENTSIDEONLY
	+NOBLOCKMAP //***Che
	States
	{
		Spawn:
		   TNT1 A 0 NODELAY A_JumpIf(waterlevel > 1, "Splash")
		   TNT1 A 0 A_JumpIfInTargetInventory("IAmSfestMonster", 1, "Splash")
		   TNT1 A 0 A_CustomMissile ("GiantWallRedBlood", 40, 0, 0, 2, random (0, 35))
		   TNT1 A 0 A_CustomMissile ("GiantWallRedBlood", 40, 0, 45, 2, random (0, 35))
		   TNT1 A 0 A_CustomMissile ("GiantWallRedBlood", 40, 0, 90, 2, random (0, 35))
		   TNT1 A 0 A_CustomMissile ("GiantWallRedBlood", 40, 0, 135, 2, random (0, 35))
		   TNT1 A 0 A_CustomMissile ("GiantWallRedBlood", 40, 0, 180, 2, random (0, 35))
		   TNT1 A 0 A_CustomMissile ("GiantWallRedBlood", 40, 0, 225, 2, random (0, 35))
		   TNT1 A 0 A_CustomMissile ("GiantWallRedBlood", 40, 0, 270, 2, random (0, 35))
		   TNT1 A 0 A_CustomMissile ("GiantWallRedBlood", 40, 0, 315, 2, random (0, 35))
		   Stop
			
		Splash:
			BLOD A 0
			stop
	}
}


//Spawned by BD's kicked heads  to spawn blood decals and make the head bounce sound.
ACTOR ShortWallRedBlood: WallRedBlood
{
	speed 2
	Gravity 1
	Radius 24
	Height 12
    States
    {
		Spawn:
			
			TNT1 A 0 A_JumpIf(waterlevel > 1, "Splash")
			TNT1 A 3
			Stop
		Death:
			TNT1 AAAAAAAAAAAAAAAAAA 0 A_CustomMissile ("Brutal_FlyingBloodFakeNoDecal", 0, 0, random (0, 360), 2, random (0, 90))
			TNT1 A 0 A_SpawnItem("Brutal_BloodSpot",0,0,0,1)
			TNT1 A 0 A_PlaySound("HEDBON")
			TNT1 A 20
			Stop
	}
}





//Blood actors spawned underwater
ACTOR Underblood1
{
	scale 1.4
	speed 1
	health 1
	radius 8
	height 1
	Gravity 0.9
	Renderstyle Translucent
	Alpha 0.2
	Decal BrutalBloodSplat
	+MISSILE
	+CLIENTSIDEONLY
	+NOTELEPORT
	+NOBLOCKMAP
	+FORCEXYBILLBOARD
	-DONTSPLASH
	+THRUACTORS
	Mass 1
	States
	{
		Spawn:
			BSP4 ABCDEFGHIJKLMNOPQRSTUVWXYZ 2 A_JumpIf(waterlevel < 1, "Splash")
			Stop
		 
		Splash:
			BLOD A 0
			stop
		Death:
			TNT1 A 0
			Stop
	}
}

//Shorter version
ACTOR Underblood2: Underblood1
{
	scale 0.7
	speed 0
    States
    {
		Spawn:
			BSP4 ABCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_JumpIf(waterlevel < 1, "Splash")
			Stop

		Splash:
			BLOD A 0
			stop
		Death:
			TNT1 A 0
			Stop
    }
}
//Bigger version that moves, used for gibbing.
ACTOR Underblood3: Underblood1
{
	scale 2.2
	speed 2
	Alpha 0.3
}


//Big blood mists


actor SuperGore
{
	Decal BloodSplat
	Alpha 0.6
	Renderstyle Translucent
	+FORCEXYBILLBOARD
	+GHOST
	+NOBLOCKMAP
	Gravity 0.01
	+DontSplash
	-EXPLODEONWATER
	-ALLOWPARTICLES 
	+CLIENTSIDEONLY
	-NOGRAVITY
	+THRUACTORS
	+NOCLIP
	Gravity 0.2
	Scale 1.0
	Speed 1
	+PUFFGETSOWNER
	states
	{
		Spawn:
			TNT1 A 0
			//BLOR HHHHHHHHHHHHHHHHHHHHHHHHIJKKKK 1 A_FadeOut(0.01)
			TNT1 A 0 A_JumpIfInTargetInventory("IAmSfestMonster", 1, "LowRes")
			BLOR L 15
			BLOR LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL 1 A_FadeOut(0.015)
			Stop
		LowRes:
			BLOR L 5 A_ChangeFlag("NODECAL", 1)
			BLOR LLLL 5 A_FadeOut(0.2)
			Stop
		Vanish:
			TNT1 A 0
			Stop
	}
}


Actor SuperGoreMist: SuperGore
{
	Scale 1.5
	Speed 1
	+NOGRAVITY
}


actor SuperGoreMistSmall: SuperGore
{
	Scale 1.0
}

actor SmallSuperGore: SuperGore
{
	Scale 1.0
}

//Used on bullet hit impacts
Actor SuperGoreMistTiny: SuperGore
{
	Scale 0.4
	Alpha 0.3
	Speed 0
	+NOGRAVITY
	states
	{
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_JumpIfInTargetInventory("IAmSfestMonster", 1, "Vanish")
			BLOR AAABBBCCCDDDEEEFFFGGGHHHIIJJKK 1 A_FadeOut(0.01)
			Stop
	}
}

actor BigSuperGore: SuperGore
{
	Scale 2.0
	Speed 4
}


actor GiantSuperGore: SuperGore
{
	Scale 4.0
	Speed 4
}


//Spawners for the supergore thing
Actor SuperGoreSpawner
{
	Projectile //***Che already includes noblockmap
	+MISSILE 
	+FORCEXYBILLBOARD
	+THRUACTORS
	Decal BloodSuper
	radius 2
	height 2
	speed 15
	states
	{
		Spawn:
			TNT1 A 2
			TNT1 AAA 2 A_CustomMissile("SuperGore", 0, 0, random (0, 360), 2 , random (30, 60))
			Stop
		Death:
		XDeath:
			TNT1 A 0
			Stop
	}
}


Actor SuperGoreSpawner2: SuperGoreSpawner
{
	states
	{
		Spawn:
			TNT1 A 3
			TNT1 AAAAAA 2 A_CustomMissile("SuperGore", 0, 0, random (0, 360), 2, random (30, 60))
			Stop
	}
}


Actor SuperGoreSpawner3: SuperGoreSpawner
{
	states
	{
	Spawn:
		TNT1 A 2
		TNT1 AAAAAAAAAAAAAAAAA 2 A_CustomMissile("SuperGore", 7, 0, random (0, 360), 2, random (30, 60))
		Stop
	}
}


actor UltraGore: SuperGore
{
	Scale 4.0
	Speed 1
	states
	{
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_JumpIfInTargetInventory("IAmSfestMonster", 1, "LowRes")
			BLOR LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL 2 A_FadeOut(0.01) // 180 tics / 5 seconds
			Stop
		LowRes:
			TNT1 A 0
			BLOR LLLLLLLLLL 4 A_FadeOut(0.1) // 40 tics, 1.1 second
			Stop
	}
}


Actor UltraGoreSpawner: SuperGoreSpawner
{
	states
	{
		Spawn:
			TNT1 A 0 NODELAY A_QueueCorpse
			Goto Bleed
		SpawnSfest:
			// most spawners will be *gone* after 3 tics, but we need 30
			TNT1 A 0
			TNT1 A 0 A_GiveInventory("IAmSfestMonster", 1)
			TNT1 A 0 A_RearrangePointers(AAPTR_NULL, AAPTR_DEFAULT, AAPTR_DEFAULT, 0) // cut the ties with our spawner, thus becoming the originator
		Bleed:	
			TNT1 AAAAAAAAAA 3 A_CustomMissile("UltraGore", 7, 0, random (0, 360), 2, random (30, 60))
		Death:
		XDeath:
			TNT1 A 0
			Stop
	}
}



//Bloody footprints still requires the player to be edited to work.
//Gives the player an inventory item to indicate the feet are smeared.
ACTOR BootSmearerRed
{
	MONSTER
	
	//***Che the fucking NPCs acquire it as a *VALID* target (Monster? Check. Hostile? Check. Shootable? Check. Health above zero? Check.) and keep shooting it ad nauseum!
	-NOTARGET
	-NEVERTARGET
	-SHOOTABLE
	
	
	-SOLID
	+THRUACTORS
	-COUNTKILL
	+LOOKALLAROUND
	-FRIENDLY
	Radius 0
	Height 0
	+PUFFGETSOWNER
	

		
	 states
	 {
		Spawn:
			//***Che
			TNT1 A 0 NODELAY A_QueueCorpse
			//TNT1 A 0 A_JumpIfInTargetInventory("IAmSfestMonster", 1, "Vanish")
			TNT1 A 0 ACS_NamedExecuteAlways("FBD_CheckFloorIsLava", 0, 0, 0, 0)
			TNT1 A 2
			TNT1 A 0 A_JumpIfInventory("IsOverLava", 1, "LandOnLava")	 
			
			//TNT1 A 0
			TNT1 A 1 A_Look
			Goto See
		LandOnLava:	
			TNT1 A 1 
			Stop
	  
		See:
			TNT1 AA 1 A_Chase("","")
			TNT1 A 0 A_Die("LookForPlayer")
			//  
		Death:	
		Death.LookForPlayer:
			TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 8 A_JumpIfCloser(60, "SmearBootsWithRedBlood")
			Stop
		SmearBootsWithRedBlood:
			TNT1 A 0 A_GiveToTarget("BootsSmearedWithRedBlood", 8)
			BPDL A 0
			Stop
		Vanish:
			TNT1 A 0
			Stop
	}
}

ACTOR RedBloodFootPrintLeft: GrowingBloodPool
{
	Scale 0.09
	+CLIENTSIDEONLY
	Alpha 1.0
	states
	{
		Spawn:
		Death:
		Crash:
			TNT1 A 0 A_JumpIf(waterlevel > 1, "Splash")
			//***Che
			TNT1 A 0 ACS_NamedExecuteAlways("BD_CheckIfOverLiquid")//"BD_CheckIfOverLiquid")//Check if is under a liquid
			TNT1 A 4
			
			TNT1 A 0 A_JumpIfInventory("IsOverWater", 1, "Splash")
			TNT1 A 0 A_JumpIfInventory("IsOverSlime", 1, "Splash")
			TNT1 A 0 A_JumpIfInventory("IsOverlava", 1, "Splash")
			TNT1 A 0 A_CheckFloor("ShowUp")
			//Goto Splash
		ShowUp:
			TNT1 A 0
			TNT1 A 0 A_QueueCorpse
			BPDL A 200
			TNT1 A 0 A_JumpIfInventory("LowGraphicsMode", 1, "Splash")
			BPDL A -1
			Stop
		Splash:
			TNT1 A 0
			Stop	
	}
}


ACTOR RedBloodFootPrintRight: GrowingBloodPool
{
	Scale 0.09
	+CLIENTSIDEONLY
	states
	{
		Spawn:
		Death:
		Crash:
			TNT1 A 0 A_JumpIf(waterlevel > 1, "Splash")
			//***Che
			TNT1 A 0 ACS_NamedExecuteAlways("BD_CheckIfOverLiquid") //"BD_CheckIfOverLiquid")//Check if is under a liquid
			TNT1 A 4
			
			TNT1 A 0 A_JumpIfInventory("IsOverWater", 1, "Splash")
			TNT1 A 0 A_JumpIfInventory("IsOverSlime", 1, "Splash")
			TNT1 A 0 A_JumpIfInventory("IsOverlava", 1, "Splash")
			TNT1 A 0 A_CheckFloor("ShowUp")
			Goto Splash
			ShowUp:
			TNT1 A 0
			TNT1 A 0 A_QueueCorpse
			BPDL A 200
			TNT1 A 0 A_JumpIfInventory("LowGraphicsMode", 1, "Splash")
			BPDL A -1
			Stop
		Splash:
			TNT1 A 0
			Stop
	}
}




actor DeadBlood
{
	Decal BrutalBloodSplat
	Renderstyle Translucent
	+FORCEXYBILLBOARD
	+THRUACTORS
	+CLIENTSIDEONLY
	+NOGRAVITY
	Scale 0.6
	Alpha 0.9
	Mass 999999
	Speed 1
	+PUFFGETSOWNER
	
	//***Che
	+NOBLOCKMAP // for optimization: actors *without* this flag are costlier to create, delete and add to the cost of anything, from AOE damage to A_RadiusGive to hitscan checks.		
	states
	{
		Spawn:
			BSPR A 0
			TNT1 A 0 A_JumpIfInTargetInventory("IAmSfestMonster", 1, "LowBlood")
			TNT1 A 0 A_CustomMissile ("SuperGoreMistTiny", 0, 0, random (0, 360), 2, random (40, 90))
			TNT1 A 0 A_JumpIf(waterlevel > 1, "Splash")
			TNT1 A 0 A_PlaySound("misc/xdeath5")
			TNT1 A 0 ACS_NamedExecuteWithResult("BD_CheckBloodIntensity")
			TNT1 A 0 A_CustomMissile ("WaterBloodCHecker", 7, 0, random (0, 360), 2, random (30, 60))
		Spawn2:
			//TNT1 A 0 A_CustomMissile ("Brutal_FlyingBloodTrail", 10, 0, random (0, 360), 2, random (40, 90))
			Goto LowBlood
		Splash:
			BLOD A 0
			TNT1 AAA 0 A_CustomMissile ("Underblood1", 7, 0, random (0, 360), 2, random (30, 150))
			stop
		LotsOfBlood:
			TNT1 A 0
			TNT1 AAAA 0 A_CustomMissile ("BloodMistSmall", 10, 0, random (0, 360), 2, random (0, 90))
			TNT1 AA 0 A_CustomMissile ("FBD_FlyingBlood", 7, 0, random (0, 360), 2, random (40, 90))
			TNT1 A 0 A_CustomMissile ("SuperWallRedBlood", 0, 0, random (0, 360), 2, random (5, 15))
			TNT1 AAAA 0 A_CustomMissile ("Brutal_FlyingBloodTrail", 10, 0, random (0, 360), 2, random (40, 90))
			Goto LowBlood
		AbsurdBlood:
			TNT1 A 2
			TNT1 AAAA 0 A_CustomMissile ("SuperWallRedBlood", 0, 0, random (0, 360), 2, random (-15, 15))
			TNT1 A 0 A_JumpIfInventory("AnimuGore", 1, "AnimuGore")
			TNT1 AA 0 A_CustomMissile ("FBD_Bloodmist", 0, 0, random (0, 360), 2, random (0, 90))
			TNT1 AAA 0 A_CustomMissile ("Brutal_FlyingBloodMuchFaster", 7, 0, random (0, 360), 2, random (10, 50))
			TNT1 A 0 A_CustomMissile ("Brutal_FlyingBloodMuchFaster", 7, 0, random (0, 360), 2, random (40, 60))
			TNT1 A 0 A_CustomMissile ("BloodmistSmall", 7, 0, random (0, 360), 2, random (30, 90))
			TNT1 A 0 A_CustomMissile ("SuperGoreMist", 0, 0, random (0, 360), 2, random (10, 90))
			TNT1 AAAAA 0 A_CustomMissile ("FBD_FlyingBlood", 7, 0, random (0, 360), 2, random (30, 70))
			TNT1 AAA 0 A_CustomMissile ("BloodmistSpray", 0, 0, random (0, 360), 2, random (20, 90))
			Goto LowBlood
		AnimuGore:
			TNT1 AAA 0 A_CustomMissile ("Brutal_FlyingBloodMuchFaster", 7, 0, random (0, 360), 2, random (10, 50))
			TNT1 A 0 A_CustomMissile ("SuperWallRedBlood", 0, 0, random (0, 360), 2, random (-15, 15))
			TNT1 A 0 A_CustomMissile ("Brutal_FlyingBloodMuchFaster", 7, 0, random (0, 360), 2, random (40, 60))
			TNT1 AAAAAAA 0 A_CustomMissile ("FBD_FlyingBlood", 7, 0, random (0, 360), 2, random (30, 70))
			TNT1 AAAAAAAAA 0 A_CustomMissile ("XDeath1", 0, 0, random (0, 360), 2, random (40, 80))
			TNT1 A 0 A_CustomMissile ("SuperGoreSpawner", 0, 0, random (0, 360), 2, random (10, 90))
			TNT1 AAAAA 0 A_CustomMissile ("BloodmistSpray", 0, 0, random (0, 360), 2, random (20, 90))
			Goto LowBlood 
		LowBlood:
			TNT1 A 0
			TNT1 A 0 A_Jump(128, 2)
			TNT1 A 0 A_SetScale(-0.7, 0.8)
			BSPR ABCDEFGHIJ 1
			Stop
			
		SpawnPlayer:
			TNT1 A 0
			TNT1 A 0 A_CustomMissile ("SuperGoreMistTiny", 0, 0, random (0, 360), 2, 0)
			TNT1 A 0 A_CustomMissile ("FBD_FlyingBlood", 7, 0, random (0, 360), 2, random (30, 60))
			TNT1 A 0 A_CustomMissile ("Brutal_FlyingBloodTrail", 0, 0, random (0, 360), 2, random (20, 90))
			BSPR ABCDEFGHIJ 1 BRIGHT
			Stop	
	}
}
