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





//***Che: cross-mod hardening: see ACTOR ShotgunGuy1: FBD_ShotgunGuy Replaces ShotgunGuy {} in Doom_Replacements.txt

ACTOR FBD_ShotgunGuy : ZandronumShotgunGuy 17844
{
	//***Che radius, height and maxdropoffheight (n/a for flying ones) MUST be kept consistent with FBD_TrySpawn in FBD_CORE.acs!
	
	//$category "FBD Monsters"
	
	Game Doom
	
	Health 40
	SpawnID 1
	Radius 16
	Height 44
	//Height 44
	Mass 300
	Speed 4
	FastSpeed 8
    Scale 0.98
	PainChance 255
	PainChance "Avoid", 50
	PainChance "Head", 255
	PainChance "Kick", 256 PainChance "Slide", 256
	PainChance "Melee", 255 PainChance "HangingHook", 0 PainChance "Stealth", 255
	PainChance "HelperMarineFatallity", 255
	PainChance "MonsterKnocked", 255
	PainChance "ExplosiveImpact", 255
	damagefactor "Crush", 5.0 DamageFactor "Fatality", 5.0 damagefactor "FallInLava", 500.0
	PainChance "Taunt", 255
	damagefactor "Avoid", 0.0 // effectively disables the rolls
	damagefactor "DontCallTheBaron", 0.0 damagefactor "PussyGrab", 50.0
	damagefactor "TeleportRemover", 0.0
	damagefactor "GibRemoving", 0.0
	damagefactor "SSG", 500.0
	PainChance "LowKick", 255
	DropItem "GrenadeAmmo" 15
	DropItem "ShotgunSpawnerDroped"
	damagetype "Melee"
	DamageFactor "Head", 1.3
	damagefactor "Melee", 1.35
	damagefactor "Shotgun", 2.0
	Monster
	+FLOORCLIP
	+SLIDESONWALLS
	+RANDOMIZE
	+MISSILEMORE
	+DOHARMSPECIES
	DeathHeight 4
	BurnHeight 0
	Species "Zombies"
    //BloodType "FBD_Blood", "FBD_SawBlood", "FBD_SawBlood"
	// legshot blood replaces the legboxes, gives the monster "HitLeg" tokens if hit below 25 from origin
	// but monster must check for it in all death states
	BloodType "FBD_LegshotBlood", "FBD_LegshotBloodSaw", "FBD_LegshotBloodSaw"
	SeeSound "grunt/sight"
	PainSound "grunt/pain"
	DeathSound "grunt/death"
	ActiveSound "grunt/active"
    damagefactor "Blood", 0.0 damagefactor "BlueBlood", 0.0 damagefactor "GreenBlood", 0.0
	damagefactor "taunt", 0.0
	Obituary "%o got his face splattered on the wall by a Zombie Shotgunner."
	MaxStepHeight 24
	MaxDropOffHeight 32
	Tag "$SHOTGUY" // "Shotgun Zombie";
	DamageFactor "CauseSplash", 0.0 DamageFactor "CauseObjectsToSplashSlime", 0.0 DamageFactor "CauseObjectsToSplashNukage", 0.0
	DamageFactor "CauseObjectsToSplashBlood", 0.0 DamageFactor "CauseObjectsToSplashLava", 0.0
	
	//***Che
	PainChance "FriendlyExplosion", 255
	
	var int user_head_tid;
	var int user_head_rel;
	var int user_head_scale;
	var int user_head_xyzf; /* 
		a packed value: 
		bits 0..7 =x+128, clamped to -128..127
		bits 8..15 =y+128, clamped to -128..127
		bits 16..23 =z, clamped to 1..255
		bit 29 is a command to assume an unique TID, used in monster-on-monster headshotting
		A zero value is a command to terminate
	*/
	var int user_head_type; 
	var int user_sleeping;
	var int user_item_no;
	var int user_serverside_sfchk;	

	
	PainChance "Argent", 255 // a healing/enraging buff inflicted by ghost souls summoned by super archviles
	DamageFactor "Argent", 1.0
	
	DamageFactor "FireInTheHole", 1.0 // AOE inflicted by grenades that fall to the ground
	PainChance "FireInTheHole", 170
	DamageFactor "HurrDurrMeHazGrenaed", 1.0 // AOE inflicted by imps who chatch a grenade
	PainChance "HurrDurrMeHazGrenaed", 255
	PainChance "PlummetAaah", 255 // bottomless pits in Chebskies-EDAY
	DamageFactor "PlummetAaah", 1.0		
	damagefactor "Killme", 1.0 // AOE inflicted by captured marines
	PainChance "Killme", 255
	
	damagefactor "Leg", 1.0 // subscribe to lift the default immunity
	
	PainChance "Ice", 255
	
	//***Che this damage type is now for subscribers only
	damagefactor "Stealth", 1.0
	PainChance "Stealth", 255	
	
	
	States
	{
		Pain.Ice:
			"----" A 20 A_Pain
			Goto See
		
		Pain.PlummetAaah:
			"----" A 0 A_PlaySound("zombieman/panic", CHAN_VOICE)
			"----" A 0 A_ChangeFlag("NOPAIN", 1) // prevent repeated activation by the trigger filling the bottomless pit
			Goto FallingAfterImpact	
		Death.PlummetAaah:
			TNT1 A 0 A_StopSound(CHAN_VOICE)
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_CustomMissile ("FBD_ThrowedShotgunguy", 0, 0, 0, CMF_AIMDIRECTION, -90)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0) // give the scripts and actors time to run and access us
			Stop				
		WaitTargetsFatalityOut:
			SPOS A 1 A_Jump(256, "FallBackContinue", "Panic", "Pain.Avoid")
			Wait
		Pain.HurrDurrMeHazGrenaed:
			TNT1 A 0
			TNT1 A 0 HealThing(1)
			TNT1 A 0 A_FaceTarget
			TNT1 A 0 A_JumpIfInventory("Enraged", 1, "Missile") // no retreat!
			Goto FallBack
	
		Pain.FireInTheHole:
			TNT1 A 0
			TNT1 A 0 HealThing(1)
			TNT1 A 0 A_JumpIfInventory("Enraged", 1, "Missile") // no retreat!
			TNT1 A 0 A_Jump(128, "FallBack", "Panic")
			
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			TNT1 A 0 A_Jump(256, "AvoidLeft", "AvoidRight")
			Goto AvoidLeft		
		
		Pain.Avoid: 
			TNT1 A 0
			TNT1 A 0 HealThing(1)
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			TNT1 A 0 A_Jump(256, "AvoidLeft", "AvoidRight")
			Goto AvoidLeft
		  
		AvoidLeft:
			// We can afford headbox switching at will
			// because he only does this in reaction to player aiming at him
			// so, realiztically, no more than one per player would be
			// performing this move at any given time!
			SPOS A 1 A_FaceTarget
			TNT1 A 0 ThrustThing(angle*256/360+192, 15, 0, 0)
			ZRO4 ABCDEFGH 2 A_FaceTarget
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 2, 0, 42, 1)
			Goto Missile
		AvoidRight:
			SPOS A 1 A_FaceTarget
			TNT1 A 0 ThrustThing(angle*256/360+64, 15, 0, 0)
			ZRO3 ABCDEFGH 2 A_FaceTarget
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 2, 0, 42, 1)
			Goto Missile
//		Duck:
			//ZRO3 A , the squatting sprite -- sadly, front only
			
		ReplaceSMG:
			TNT1 A 0 A_ChangeFlag("THRUACTORS", 1)
			TNT1 A 0 A_ChangeFlag("COUNTKILL", 0)
			TNT1 A 0 A_SpawnItemEx ("FBD_SMGGuy",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION | SXF_TRANSFERAMBUSHFLAG | SXF_TRANSFERTRANSLATION | SXF_TRANSFERPOINTERS | SXF_TRANSFERSPECIAL | SXF_CLEARCALLERSPECIAL | SXF_CLEARCALLERTID  ,0, tid)
			Stop
/* no vanilla in this fbd version		
		ReplaceVanilla:
			TNT1 A 0 A_ChangeFlag("THRUACTORS", 1)
			TNT1 A 0 A_ChangeFlag("COUNTKILL", 0)
			TNT1 A 0 A_SpawnItemEx ("VanillaShotgunguy",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 A 5 A_JumpIf(CallAcs("FBD_GetMapRandomizerReady"), 1) // a two-second delay to allow re-randomizing on loading an auto-save
			Loop
			
			"----" 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 ("SergeantPotpourriSwapper",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
			
		Spawn:
			SPOS B 0 NODELAY A_JumpIf(CallAcs("GetPotPourri"), "PotPourriSwap")
		PotPourriCancel:	
			"----" A 0 A_Jump(32, "ReplaceSMG")
		ReplaceCancel:	
			"----" A 0 ACS_NamedExecuteWithResult("FBD_RunMonster", 5) // 5 = default headbox
			"----" A 0 A_GiveInventory("TargetIsAFormerHuman", 1) //used by AOE DOT inflictors to reward players with soul ammo -- otherwise untraceable
			"----" A 0 A_GiveInventory("SKShotgunGuy", 1)
			"----" A 0 A_GiveInventory("TypeSergeant", 1)
			"----" A 0 A_TakeInventory("SergeantAmmo", 6)
			"----" A 0 A_GiveInventory("SergeantAmmo", random(0,5))
			//"----" A 0 A_JumpIfInventory("nonewenemies", 1, "Stand")
			SPOS B 7
			Goto Stand
		Raise:
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII") // should not have a headbox by now -- but what if?
			TNT1 A 0 A_SpawnItemEx("StandaloneRezSfx",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			SPOS L 5
			SPOS KJIH 5
			TNT1 A 0 ACS_NamedExecuteWithResult("FBD_CustomizeOnRez") // it runs OnRezMapScript
				// if the map prpvides one
			Goto SeeContinue

		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)
			// unlike other monsters, shotgun guys and zombies re-randomize on raising
			"----" A -1 ACS_NamedExecuteWithResult("FallbackRezMkII", 2001) // see _mob_list.xlsx
			Stop
			
		FallbackRezSuccess:
			TNT1 A 0 A_SpawnItemEx("StandaloneRezSfx",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30
			Stop
			
		Stand:
			TNT1 A 0
			TNT1 A 0 A_JumpIf(user_serverside_sfchk >= 4, "StandSfestExtreme") // extreme slaughtermap optimization
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 2, 0, 42)
			
			SHID ABABABAB 11 A_Look
			Loop
			
		StandSfestExtreme:
			SHID AB 11 A_Look
			Loop
	  
		FallBack:
			//***Che: taraget, not "any player" //TNT1 A 0 A_CheckSight("Advance")
			TNT1 A 0 A_JumpIfTargetinLOS(1)
			Goto Advance
			
			TNT1 A 0 A_JumpIfInventory("Enraged", 1, 4)
			TNT1 A 0 A_JumpIfInTargetInventory("TargetIsACyberdemon", 1, "Panic")
			TNT1 A 0 A_JumpIfInTargetInventory("TargetIsAGreatTerribleBoss", 1, "Panic")
			TNT1 A 0 A_JumpIfInTargetInventory("GoFatality", 1, "WaitTargetsFatalityOut")
			
		FallBackContinue:	
			TNT1 A 0 A_ChangeFLag("NODROPOFF", 1)
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 3, 0, 40)
			SPOS D 2 A_FaceTarget
			SPOS D 2 A_Recoil(2)
			TNT1 A 0 A_jump(64, "Missile")
			
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 5, 2, 38)
			SPOS C 2 A_FaceTarget
			SPOS C 2 A_Recoil(2)
			
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 4, 4, 40)
			SPOS B 2 A_FaceTarget
			SPOS B 2 A_Recoil(2)
			
			SPOS A 2 A_FaceTarget
			SPOS A 2 A_Recoil(2)
			
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 3, 0, 40)
			SPOS D 2 A_FaceTarget
			TNT1 A 0 A_ChangeFLag("NODROPOFF", 0)
			GOto Missile
		
		Idle:		
			TNT1 A 0
			TNT1 A 0 A_SetUserVar("user_sleeping", 1)
		SearchForPlayer:
			TNT1 A 0 A_ClearTarget
			TNT1 A 0 A_TakeInventory("EnemyMemory", 30)
			TNT1 A 0 A_GiveInventory("SKShotgunGUy", 1)

			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 2, 0, 42)
			SHID A 10 A_Look

			SHID C 10 A_Look

			SHID A 10 A_Look

			SHID D 10 A_Look

			SHID A 10 A_Look
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 7, 0, 38)
			SPOS A 4 A_Look
			
			TNT1 A 0 A_Wander
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 4, 4, 40)
			SPOS B 4 A_Look
			
			TNT1 A 0 A_Wander
			
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 5, 2, 38)
			SPOS C 4 A_Look
			
			TNT1 A 0 A_Wander
			
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 3, 0, 40)
			SPOS D 4 A_Look
			
			TNT1 A 0 A_Wander
			
			
			TNT1 A 0 A_Jump(128, "SearchForPlayer")
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 7, 0, 38)
			SPOS A 4 A_Look
			
			TNT1 A 0 A_Wander
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 4, 4, 40)
			SPOS B 4 A_Look
			
			TNT1 A 0 A_Wander
			
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 5, 2, 38)
			SPOS C 4 A_Look
			
			TNT1 A 0 A_Wander
			
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 3, 0, 40)
			SPOS D 4 A_Look
			
			TNT1 A 0 A_Wander
			
			Loop
			
		
		See:
			TNT1 A 0 A_ChangeFLag("NODROPOFF", 0)
			TNT1 A 0 A_TakeInventory("SKZombieman", 1)
			TNT1 A 0 A_TakeInventory("EnemyMemory", 15)
			TNT1 A 0 A_CheckSight("SeeNeverSeen")
			Goto SeeContinue
		
		SeeContinue:
			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
			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_ChangeFLag("NODROPOFF", 0)
			TNT1 A 0 A_JumpIfCloser(200, "FallBack")
			//Advance:
			TNT1 A 0 A_ChangeFLag("NODROPOFF", 0)
			TNT1 A 0 A_JumpIfInventory("EnemyMemory", 15, "Idle")
			TNT1 A 0 A_GiveInventory("EnemyMemory", 1)
			//TNT1 A 0 A_SpawnItemEx("FootSep", 0, 0, 20, 0, 0)
			TNT1 A 0 A_TakeInventory("SKShotgunGuy", 1)

			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 7, 0, 38)
			SPOS AAA 2 A_Chase

			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 4, 4, 40)
			SPOS BBB 2 A_Chase

			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 5, 2, 38)
			SPOS CCC 2 A_Chase

			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 3, 0, 40)
			SPOS DDD 2 A_Chase
			
			
			TNT1 A 0 A_JumpIf(CallAcs("FBD_TargetIsInvisible"), "Idle")
			Loop
		Panic:
			TNT1 A 0
			TNT1 A 0 A_GiveInventory("AbjectTerror", 3)
			TNT1 A 0 A_CheckFlag("FRIGHTENED", "PanicContinue")
			TNT1 A 0 A_ChangeFlag("FRIGHTENED", 1)
			TNT1 A 0 A_PlaySound("zombieman/panic", CHAN_VOICE)
			TNT1 A 0 A_FaceTarget
			TNT1 A 0 A_SetAngle(angle + 180)
		PanicContinue:
			
			TNT1 A 0 A_TakeInventory("AbjectTerror", 1) // in the beginning, 
			  //in case it is interrupted by pain -- or falling into the Idle state because of having no target
			
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 7, 0, 38)
			TNT1 AA 0 A_Chase
			SPOS AAA 1 A_Wander
			
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 4, 4, 40)
			TNT1 AA 0 A_Chase
			SPOS BBB 1 A_Wander
		
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 5, 2, 38)
			TNT1 AA 0 A_Chase
			SPOS CCC 1 A_Wander
			
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 3, 0, 40)
			TNT1 AA 0 A_Chase
			SPOS DDD 1 A_Wander
						
			TNT1 A 0 A_JumpIfInventory("AbjectTerror", 1, "PanicContinue")
		PanicEnd:
			TNT1 A 0 A_PlaySound("grunt/active", CHAN_VOICE)
			TNT1 A 0 A_ChangeFlag("FRIGHTENED", 0)
			Goto See
			
		SeeNeverSeen:
			TNT1 A 0 A_JumpIfCloser(200, "FallBack")
			Advance:
			TNT1 A 0 A_ChangeFLag("NODROPOFF", 0)
			//TNT1 A 0 A_SpawnItemEx("FootSep", 0, 0, 10, 0, 0)
			
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 7, 0, 38)
			SPOS AAA 2 A_Chase
			
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 4, 4, 40)
			SPOS BBB 2 A_Chase
			
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 5, 2, 38)
			SPOS CCC 2 A_Chase
			
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 3, 0, 40)
			SPOS DDD 2 A_Chase
			Loop		
			
		Missile:
			TNT1 A 0 A_Stop
			TNT1 A 0 A_TakeInventory("EnemyMemory", 10)
			
			TNT1 A 0 A_ChangeFLag("NODROPOFF", 0)
			TNT1 A 0 A_TakeInventory("SKShotgunGuy", 1)
			
			//TNT1 A 0 A_TakeInventory("CantFire", 1)
			//TNT1 A 0 A_CustomMissile("MonsterTargetCheck", 34, 0, 0, 0) 
			//TNT1 A 0 A_CustomMissile("MonsterTargetCheckFaster", 34, 0, 0, 0) 
			
			TNT1 A 0 A_JumpIfInTargetInventory("IsLTGPlayer", 1, "LTGCheck")
		MissileContinueAfterLTGCheck:			
			
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 3, 0, 40)
			SPOS D 3 A_FaceTarget
			//TNT1 A 0 A_JumpIfInventory("CantFire",1, "Advance")
			
			TNT1 A 0 A_GiveInventory("SergeantAmmo", 1)
			
			
			//***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
			
			SPOS D 3 //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
			
			SPOS E 10 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 0, 0, 38)
			
			
			//***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
			
			SPOS E 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
			
			SPOS E 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			
			
			SPOS E 4 //A_FaceTarget
			
			TNT1 A 0 A_JumpIfCloser(300, 2)
			TNT1 A 0 A_Jump(200, 2)
			TNT1 A 0 A_JumpIfInTargetInventory("GoFatality", 1, "WaitTargetsFatalityOut")
			
			//TNT1 A 0 A_SetPitch(random (-8, 8) + pitch)
			TNT1 AAAAA 0 A_CustomMissile("ShotgunguyTracer", 36, 0, random(-7, 7) + angle, CMF_ABSOLUTEANGLE | CMF_OFFSETPITCH | CMF_SAVEPITCH, random(-4, 4))
			TNT1 A 0 A_CustomMissile("DistantFireSoundShotgun", 32, 0, 0, 1, 0)
			TNT1 AAAAAAAA 0 A_CustomMissile("ShotgunParticles", 36, 0, random(-9, 9) + angle, CMF_ABSOLUTEANGLE | CMF_OFFSETPITCH | CMF_SAVEPITCH, random(-9, 9))
			TNT1 A 0 A_PlaySound("weapons/sg")
			SPOS F 5 BRIGHT //A_CustomBulletAttack(8, 8, 10, 3, "HitPuff")
			TNT1 A 0 A_Recoil(1)
			
			
			SPSR C 6 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 0, 1, 36)

			
			//***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
			
			SPOS E 7 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 0, 0, 38)

			SPSR A 7 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 2, 4, 44)
			TNT1 A 0 A_PlaySound("weapons/sgpump")

			SPSR B 7 A_SpawnItem ("ShotCaseSpawn", 0, 30,0)

			SPSR A 7
			TNT1 A 0 A_JumpIfInventory("SergeantAmmo", 6, "Reload")
			TNT1 A 0 A_JumpIf(CallAcs("FBD_TargetIsInvisible"), "SearchForPlayer")
			Goto SeeContinue
		
		Reload:
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 2, 4, 44)
			

			SPSR A 15

			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 0, 0, 40)
			ID12 EFG 5
			TNT1 A 0 A_PlaySound("insertshell")
			TNT1 A 0 A_TakeInventory("SergeantAmmo", 1)
			
			ID12 EFG 5
			TNT1 A 0 A_PlaySound("insertshell")
			TNT1 A 0 A_TakeInventory("SergeantAmmo", 1)
			
			// because "wait target's fatality out" for such weak monsters is panicking. Must panic even if reloading.
			TNT1 A 0 A_JumpIfInTargetInventory("GoFatality", 1, "WaitTargetsFatalityOut")

			ID12 EFG 5
			TNT1 A 0 A_PlaySound("insertshell")
			TNT1 A 0 A_TakeInventory("SergeantAmmo", 1)
			

			ID12 EFG 5
			TNT1 A 0 A_PlaySound("insertshell")
			TNT1 A 0 A_TakeInventory("SergeantAmmo", 1)
			
			TNT1 A 0 A_JumpIfInTargetInventory("GoFatality", 1, "WaitTargetsFatalityOut")

			ID12 EFG 5
			TNT1 A 0 A_PlaySound("insertshell")
			TNT1 A 0 A_TakeInventory("SergeantAmmo", 1)

			ID12 EFG 5
			TNT1 A 0 A_PlaySound("insertshell")
			TNT1 A 0 A_TakeInventory("SergeantAmmo", 1)

			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 2, 4, 44)
			SPSR A 10
			TNT1 A 0 A_PlaySound("weapons/sgpump")
			
			SPSR B 10
			
			SPSR A 10
			
			Goto SeeContinue
			

		Pain.Cut:
		Pain.Saw:
			TNT1 A 0
			TNT1 A 0 A_Stop
		Pain:
			TNT1 A 0 A_JumpIfInventory ("IsDown", 1, "PainDownB") //9)
			TNT1 A 0 A_TakeInventory("SKShotgunGuy", 1)
			
			SPOS G 3 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -12, -3, 41)
			
			SPOS G 3 A_Pain
			TNT1 A 0 A_Jump(196, "Missile")
			Goto SeeContinue
		PainDownB:	
			TNT1 A 0
			TNT1 A 0 A_Pain
			ID11 H 6 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -15, 0, 3)
			Goto GetUp
			
		Pain.Argent:
			TNT1 A 0
			
			//TNT1 A 0 A_ClearTarget
			TNT1 A 0 A_GiveInventory("Enraged", 1)
			TNT1 A 0 A_Pain
			TNT1 A 0 HealThing(15,60)
			TNT1 A 0 A_JumpIfInventory ("IsDown", 1, "PainArgentDownB") //9)
			TNT1 A 0 ACS_NamedExecuteWithResult("DisplayArgentDischarge", 10, 40, 0)	
			TNT1 A 0 A_TakeInventory("SKShotgunGuy", 1)
			
			SPOS G 3 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -12, -3, 41)
			TNT1 A 0 ACS_NamedExecuteWithResult("DisplayArgentDischarge", 10, 15, 0)	
			SPOS GGGG 8 A_Pain
			TNT1 A 0 A_Jump(64, "Missile")
			Goto SeeContinue
		PainArgentDownB:	
			TNT1 A 0
			TNT1 A 0 A_Pain
			ID11 H 6 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -15, 0, 3)
			ID11 HHH 8 A_Pain
			Goto GetUp			
			
			
		Pain.Head:
		Pain.Shrapnel:	
		Pain.HeadPlasma:
		Pain.HeadStun:
		Pain.Decaptate:
			TNT1 A 0 A_TakeInventory("SKShotgunguy", 1)
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 0, 1, 41)
			POSH K 5 A_Pain
			TNT1 A 0 A_FaceTarget
			POSH L 20 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 0, -5, 32)
			POSH L 20
			Goto SeeContinue	
			
		Pain.Melee:
			TNT1 A 0
			TNT1 A 0 A_JumpIfInventory ("SKShotgunGuy", 1, "GotoStealthKill")
			TNT1 A 0 A_JumpIfInventory ("IsDown", 1, "PainDown") //6)
			
			SPOS G 4 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -12, -3, 41)
			
			SPOS G 4 A_Pain
			Goto SeeContinue
		PainDown:	
			TNT1 A 0
			TNT1 A 0 A_Pain
			ID11 H 8 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -15, 0, 3)
			ID11 S 35 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -15, 0, 1)
			TNT1 A 0 A_TakeInventory("IsDown", 1)
			ID11 T 10 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 0, -3, 16)
			Goto SeeContinue

		Pain.Stealth:
			TNT1 A 0
			TNT1 A 0 A_Pain
			TNT1 A 0 A_JumpIfInventory ("SKShotgunguy", 1, "GotoStealthKill")
			TNT1 A 0 A_JumpIfInventory ("IsDown", 1, "GroundExecution")
			Goto See
			
		GroundExecution:
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("ExecuteDownedShotgunguy", 1)
			TNT1 A 0 A_GiveToTarget("GoSpecial", 1)
			TNT1 A 0 A_Die("Vanish")
			Stop
			
		Death.Vanish:
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			TNT1 A 3 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("SoulAmmo", 1)
			Stop

		Pain.ExplosiveImpact:
		Pain.ExtremePunches:
		Pain.Explosive:
		Pain.Bfg10k: //***Che changed damage type from extreme to custom
		
		//***Che
		Pain.FriendlyExplosion:
			TNT1 A 0 A_ChangeFLag("NODROPOFF", 0)
			TNT1 A 0 A_ChangeFlag("NOBLOCKMONST", 1)
			TNT1 A 0
			TNT1 A 0 A_Pain
			TNT1 A 0 A_JumpIfInventory ("IsDown", 1, "Pain")
			TNT1 A 0 A_TakeInventory("SKShotgunGuy", 1)
			TNT1 A 0 A_GiveInventory("IsDown", 1)
			TNT1 A 0 ThrustThingZ(0,40,0,1)
			//falling backwards (front only)
			//SPO4 UUVWXY 4
			SPO4 U 8 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 0, -5, 40)
			SPO4 V 4 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -12, -8, 27)
			SPO4 W 4 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -15, -8, 18)
			SPO4 X 4 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -15, 0, 4)
			SPO4 Y 4 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -15, 0, 1)
			Goto FallingAfterImpact


		


		Pain.LowKick:
			TNT1 A 0
			TNT1 A 0 A_JumpIfInventory("IsDown", 1, "Death.LowKick")
			Goto Pain
			
		Death.LowKick:
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")		
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("GoFatality", 1)
			TNT1 A 3 A_GiveToTarget("IsCurbstompingSergeant", 1)
			TNT1 A 0 A_GiveToTarget("SoulAmmo", 1)
			Stop
			
			
			 
		Pain.Slide:
			TNT1 A 0
			TNT1 A 0 A_ChangeFlag("NOBLOCKMONST", 1)
			TNT1 A 0 A_ChangeFLag("NODROPOFF", 0)
			TNT1 A 0 A_ChangeFlag("GHOST", 1)
			TNT1 A 0 A_ChangeFlag("THRUGHOST", 1)	
			TNT1 A 0 A_JumpIfInventory ("IsDown", 1, "Pain")
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 0, -5, 40) 
			ID11 G 1 A_Pain
			TNT1 A 0 A_GiveInventory("IsDown", 1)
			TNT1 A 0 A_TakeInventory("SKShotgunGuy", 1)
			TNT1 A 0 ThrustThingZ(0,30,0,1)
			TNT1 A 0 A_ChangeFlag("NOPAIN", 1)
			//ID11 E 1 A_Chase ("","")
			SPO4 U 1 A_facetarget
			SPO4 U 3
			TNT1 A 0 A_Recoil(-5)
			//SPO4 UVWXY 3
			SPO4 U 3
			SPO4 V 3 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -12, -8, 27)
			SPO4 W 3 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -15, -8, 18)
			SPO4 X 3 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -15, 0, 4)
			SPO4 Y 3 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -15, 0, 1)
			TNT1 A 0 A_ChangeFlag("NOPAIN", 0)
			TNT1 A 0 A_ChangeFlag("GHOST", 0)
			TNT1 A 0 A_ChangeFlag("THRUGHOST", 0)	
			Goto FallingAfterImpact

		FallingAfterImpact:
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -15, 0, 3)
			ID11 H 1 A_GiveInventory ("FallingHeight", 1)
			ID11 H 1 A_CheckFloor ("GetUp")
			NULL A 0 A_JumpIf (momz == 0, "GetUp")
			Loop	 
			
		Pain.Taunt:
			TNT1 A 0
			TNT1 A 0 HealThing(1)
			TNT1 A 0 A_JumpIfInventory("Enraged", 1, "Missile")
			POSR B 0 A_Pain
			TNT1 A 0 A_ChangeFlag("FASTER", 1)
			TNT1 A 0 A_ChangeFlag("MISSILEMORE", 1)
			TNT1 A 0 A_ChangeFlag("MISSILEEVENMORE", 1)
			TNT1 A 0 A_PlaySound("grunt/sight", CHAN_VOICE)
			
			//***Che: dafug? SPO4 B is a bloody pain sprite, he is tilted 40 degrees right
			//SPO4 B 1 A_FaceTarget
			//SPO4 B 10
			// replaced it with one of the reloading frames
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 0, 1, 36)
			SPSR C 1 A_FaceTarget
			SPSR C 10
			TNT1 A 0 A_GiveInventory("Enraged", 1)
			TNT1 A 0 A_PlaySound("grunt/sight", CHAN_WEAPON)
			Goto Missile
			
		Pain.Kick:
		Pain.Stomp:
		Pain.HeavyImpact:
		Pain.BlackHole: // ancient arachnotron
			TNT1 A 0
			TNT1 A 0 A_ChangeFlag("NOBLOCKMONST", 1)
			TNT1 A 0 A_ChangeFLag("NODROPOFF", 0)
			TNT1 A 0 A_JumpIfInventory ("IsDown", 1, "Pain")
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 0, -5, 40) 
			ID11 G 1 A_Pain
			TNT1 A 0 A_GiveInventory("IsDown", 1)
			TNT1 A 0 A_TakeInventory("SKShotgunGuy", 1)
			TNT1 A 0 ThrustThingZ(0,30,0,1)
			TNT1 A 0 A_ChangeFlag("NOPAIN", 1)
			//ID11 E 1 A_Chase ("","")
			SPO4 U 1 A_facetarget
			SPO4 U 3 ThrustThing(angle*256/360+128, 10, 0, 0)
			//SPO4 UVWXY 3
			SPO4 U 3
			SPO4 V 3 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -12, -8, 27)
			SPO4 W 3 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -15, -8, 18)
			SPO4 X 3 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -15, 0, 4)
			SPO4 Y 3 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -15, 0, 1)
			TNT1 A 0 A_ChangeFlag("NOPAIN", 0)
			Goto FallingAfterImpact
/* repeated  SEVERAL times!			
		FallingAfterImpact:
			ID11 H 1 A_GiveInventory ("FallingHeight", 1)
			ID11 H 1 A_CheckFloor ("GetUp")
			NULL A 0 A_JumpIf (momz == 0, "GetUp")
			Loop
*/			
		GetUp:
			TNT1 A 0
			TNT1 A 0 A_GiveInventory("IsDown", 1)
			MARN A 0 A_SpawnItem("bdbodythud")
			TNT1 A 0 A_ChangeFlag("FORCEXYBILLBOARD", 1)
			TNT1 A 0 A_ChangeFlag("NOPAIN", 0)
			TNT1 A 0 A_ChangeFLag("GHOST", 1)
			TNT1 A 0 A_JumpIfInventory ("FallingHeight", 5, "FallingDie")
			ID11 S 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -15, 0, 1)
			ID11 SSSSSSSSS 5 A_JumpIf(momz < 0, "FallingAfterImpact")
			TNT1 A 0 A_TakeInventory("FallingHeight", 100)
			
			ID11 T 10 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 0, -3, 16)
			TNT1 A 0 A_ChangeFlag("FORCEXYBILLBOARD", 0)
			TNT1 A 0 A_TakeInventory("IsDown", 1)
			TNT1 A 0 A_ChangeFlag("GHOST", 0)
			Goto SeeContinue
			 
		FallingDie:
			TNT1 A 0
			TNT1 A 0 A_Stop
			TNT1 A 0 A_CustomMissile("BodyCrash1", 10)
			Goto Getup+9
			
		Death.Fall:
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			TNT1 A 0 A_Scream
			TNT1 A 0 A_NoBLocking
			TNT1 A 0 A_GiveToTarget("SoulAmmo", 1)
			TNT1 A 0 A_Stop
			TNT1 AAAA 0 A_CustomMissile ("XDeath1", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (50, 130))
			//***Che: are ZOMBIEMAN falling sprites!
			//ID11 EF 2
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -15, 0, 3)
			ID11 GH 2
			TNT1 A 0 A_SpawnItem ("GrowingBloodPool")
			TNT1 A 0 A_SpawnItemEx("DeadShotgunguy",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			//ID11 F 2 // zombieman green pants!
			MARN AAA 0 A_SpawnItem("bdbodythud")
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop
		
		
		
		Pain.KillMe:
			TNT1 A 0
			TNT1 A 0 HealThing(1)
			Goto Missile
			
		Death.RailAvoid:
		Death.Avoid:
		Death.KillMe:
		Death.Taunt:
		Death.HurrDurrMeHazGrenaed: // AOE inflicted by imps who chatch a grenade
		Death.FireInTheHole:

			// the same as pain.taunt but fall dead afterwards
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			SPSR C 1 A_FaceTarget
			SPSR C 1 A_PlaySound("grunt/sight", CHAN_VOICE)
			SPSR C 10
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("SoulAmmo", 1)
			POSH LLLL 5 A_Pain // clutching at his face
			SPO4 UUWWXY 4 // bloodless falling back (after kick fall sprites)
			TNT1 A 0 A_SpawnItemEx("DeadShotgunguy",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop
			
			//TNT1 A 0 A_ChangeFlag("SOLID", 0)
			//TNT1 A 0 A_SpawnItem("ShotgunGuy")
			//Stop
			
		Death.MonsterShotgunBullet:
		Death.Shotgun:
			TNT1 A 0
			TNT1 A 0 A_JumpIfInventory("HitLeg", 3, "Death.LegMassacre") 
			TNT1 A 0 A_JumpIfInventory("HitLeg", 1, "Death.Leg")
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")		
			SPOS J 1 A_FaceTarget
			
			TNT1 A 0 A_SpawnItem("MuchBlood", 0, 40)
			TNT1 A 0 A_CustomMissile ("SuperWallRedBlood", 42, 0, random (170, 190), CMF_AIMDIRECTION, random (0, 20))
			TNT1 A 0 A_Jump(42, "Death.Shotgunontheface")
			TNT1 A 0 A_JumpIfCloser(100, "Death.bLAST")
			TNT1 A 0 A_JumpIfCloser(320, "Death.Shotgunontheface")
			Goto Death
			
		Death.Shotgunontheface:	
		Death.HeavyImpact:
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			TNT1 A 0 A_ChangeFlag("SLIDESONWALLS", 0)
			TNT1 A 0 A_Jump(24, "Death.ARm")
			TNT1 A 0 A_Jump(128, "DeathShotgunFly")
			TNT1 A 0 A_ChangeFlag("NOBLOCKMONST", 1)
			TNT1 A 0 A_Jump(96, "Death.Blast")
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("SoulAmmo", 1)
			TNT1 A 0 A_Jump(128, "DeathShotgunontheface2")
			TNT1 A 0 A_Stop
			TNT1 A 0 A_Pain
			SPOS H 1 A_FaceTarget
			TNT1 A 0 A_Recoil(13)
			TNT1 A 0 ThrustThingZ(0,20,0,1)
			TNT1 A 0 A_Scream
			TNT1 AA 0 A_CustomMissile ("XDeath1", 35, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			SPO4 ABCD 4
			SPO4 EFGHIJ 4 A_JumpIf((MomY == 0), "DSFStop")
			Goto DSFStop+1
			
		DSFStop:
			TNT1 A 0 A_SpawnItem("Ploft3")
			TNT1 A 0 A_Stop
			TNT1 A 0 A_SpawnItem ("GrowingBloodPool")
			TNT1 A 0 A_CustomMissile ("SuperWallRedBlood", 2, 0, random (170, 190), CMF_AIMDIRECTION, random (0, 0))
			TNT1 A 0 A_SpawnItemEx("DeadShotgunguySPO4J",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop
		
		DeathShotgunontheface2:	
			TNT1 A 0 A_ChangeFlag("NOBLOCKMONST", 1)
			TNT1 A 0 A_Stop
			TNT1 A 0 A_Pain
			SPOS H 1 A_FaceTarget
			TNT1 A 0 A_Scream
			TNT1 A 0 A_Recoil(13)
			TNT1 A 0 ThrustThingZ(0,20,0,1)
			TNT1 AA 0 A_CustomMissile ("XDeath1", 35, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			SPO4 KLMN 4
			SPO4 OPQRST 4 A_JumpIf((MomY == 0), "DSFStop2")
			Goto DSFStop2+1
			
		DSFStop2:
			TNT1 A 0 A_SpawnItem("Ploft3")
			TNT1 A 0 A_Stop
			TNT1 A 0 A_SpawnItem ("GrowingBloodPool")
			TNT1 A 0 A_CustomMissile ("SuperWallRedBlood", 2, 0, random (170, 190), CMF_AIMDIRECTION, random (0, 0))
			TNT1 A 0 A_SpawnItemEx("DeadShotgunguySPO4T",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop
			
		DeathShotgunFly:
			TNT1 A 0 A_ChangeFLag("NODROPOFF", 0)
			TNT1 A 0 A_ChangeFLag("SLIDESONWALLS", 0)
			TNT1 A 0 ThrustThingZ(0,30,0,1)
			TNT1 A 0 A_Scream
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_FaceTarget
			TNT1 A 0 A_Recoil (6)
			SPO4 Z 5 A_CustomMissile ("Brutal_LiquidBlood3", 15, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 40))
			TNT1 A 0 A_JumpIf((MomY == 0), "TakeASit")
			SPO4 Z 5 A_CustomMissile ("Brutal_LiquidBlood3", 15, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 40))
			TNT1 A 0 A_JumpIf((MomY == 0), "TakeASit")
			SPO4 [ 5 A_CustomMissile ("Brutal_LiquidBlood3", 15, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 40))
			TNT1 A 0 A_JumpIf((MomY == 0), "TakeASit")
			SPO4 W 5 A_CustomMissile ("Brutal_LiquidBlood3", 15, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 40))
			SPO4 X 5 A_CustomMissile ("Brutal_LiquidBlood3", 15, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 40))
			SPO4 Y 5 A_CustomMissile ("Brutal_LiquidBlood3", 15, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 40))
			TNT1 A 0 A_SpawnItem("GrowingBloodPool")
			TNT1 A 0 A_SpawnItemEx("FBD_DeadShotgunGuy1",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop
		TakeASit:
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")		
			TNT1 AA 0 A_CustomMissile ("SuperWallRedBlood", 6, 0, random (170, 190), CMF_AIMDIRECTION, random (0, 40))
			SPO4 U 5
			TNT1 A 0 A_SpawnItem("GrowingBloodPool")
			TNT1 A 0 A_SpawnItemEx("DeadShotgunguy_Slumped", 10,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop	

		Death.Eat:
			TNT1 A 0
			TNT1 A 0 A_JumpIfInventory("HitLeg", 1, "Death.LegMassacre") 
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")	
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("SoulAmmo", 1)
			TNT1 A 0 A_Scream
			TNT1 A 0 A_GiveToTarget("SergeantFatality",1)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop
			
		Death.ShotgunonthefaceArm:	
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")	
			TNT1 A 0 A_Jump(128, "Death.Arm")
			TNT1 A 0 ThrustThingZ(0,40,0,1)
			TNT1 A 0 A_CustomMissile ("XDeathArm1", 35, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("MuchBlood", 35, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_Scream
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("SoulAmmo", 1)
			ID11 OP 15
			TNT1 A 0 A_SpawnItemEx ("DeadShotgunGuy_NoArm",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop

		GotoStealthKill:
			TNT1 A 1
			//TNT1 A 0 A_JumpIfInTargetInventory("PowerStrength", 1, "BecomeMeatShield")
			TNT1 A 0 A_Explode(100, 1, 1)
			TNT1 A 1
			Goto SeeContinue
			
		BecomeMeatShield:
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")	
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("HasZManShield", 1)
			TNT1 A 0 A_GiveToTarget("GotMeatShield", 1)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop
			
		Death.Melee:
		
			TNT1 A 0 A_JumpIfInventory ("IsDown", 1, "Death.Down")
			TNT1 A 0 A_JumpIfInventory ("SKShotgunGuy", 1, "StealthKill")
		Death.Kick:
		Death.BlackHole:
			TNT1 A 0
			TNT1 A 0 A_JumpIfHealthLower(-200, "Asplode") //***Che: instead of the now defunct XDeath
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")	
			TNT1 A 0 A_ChangeFLag("NODROPOFF", 0)
			TNT1 A 0 A_Scream
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("SoulAmmo", 1)
			TNT1 A 0 ThrustThingZ(0,30,0,1)
			TNT1 A 0 A_FaceTarget
			TNT1 A 0 A_Recoil (8)
			SPO4 UUVWXY 4
			TNT1 A 0 A_SpawnItemEx("DeadShotgunguy",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop

		

		Death:
			TNT1 A 0
			TNT1 A 0 A_JumpIfHealthLower(-200, "Asplode") //***Che: instead of the now defunct XDeath
			TNT1 A 0 A_JumpIfInventory ("IsDown", 1, "Death.Down")
			TNT1 A 0 A_JumpIfInventory("HitLeg", 1, "Death.Leg")
			TNT1 A 0 A_Jump(96, "Death.Arm")
		Death.MinorLeg:	
			TNT1 A 0 A_Jump(48, "Death.Leg")
		Death.Minor:
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")	
			SPOS H 5 A_Scream
			SPOS I 5 
			SPOS J 5 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("SoulAmmo", 1)
			SPOS K 5
			TNT1 A 0 A_SpawnItem ("GrowingBloodPool")
			TNT1 A 0 A_SpawnItemEx("DeadShotgunguy",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			//TNT1 A -1
			Stop
			
		Death.Electric:				
			TNT1 A 0
			TNT1 A 0 A_SpawnItem("BarrelExplosionSmokeColumn")
			Goto Death.Minor				
			
		Death.Down:
		Death.Trample:
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			TNT1 A 0 A_Scream
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("SoulAmmo", 1)
			TNT1 AAA 0 A_CustomMissile ("XDeath1", 2, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 40))
			ID11 H 12
			TNT1 A 0 A_SpawnItemEx("DeadShotgunguy",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			//TNT1 A -1
			Stop	

		Death.Leg:
		LegRemove:
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")		
			TNT1 A 0 A_CustomMissile ("XDeathSargeLeg1", 35, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			SPO3 A 9 A_CustomMissile ("MuchBlood", 10, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_Playsound ("grunt/death", CHAN_VOICE)
			SPO3 B 3 
			SPO3 C 3 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("SoulAmmo", 1)
			
			//***Che: adding this back, seems this kind of dying got removed at some point
			TNT1 A 0 A_Jump(45, "LeaveCrawling")
			
			TNT1 A 0 A_SpawnItemEx ("SergeantGotHisLegBlowed",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop
			
		LeaveCrawling: //***Che: this doesn't seem to be invoked from anywhere
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			TNT1 A 0 A_SpawnItemEx ("DyingSergeantNoLeg",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop

		Death.Arm:
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")		
			TNT1 A 0 A_Scream
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("SoulAmmo", 1)
			TNT1 A 0 A_CustomMissile ("XDeathArm2", 35, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			SPO5 A 9 A_CustomMissile ("XDeath1", 40, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_SpawnItem ("GrowingBloodPool")
			TNT1 A 0 A_SpawnItemEx ("DyingSergeant",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop

		HeadExploder:
			TNT1 A 0
			TNT1 A 0 A_Jump(72, "Death.HeadExplode")
			Goto Death.HeadMinor

		Death.Head:
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			//TNT1 A 0 A_JumpIfInTargetInventory("HasPlasmaWeapon", 1, "Death.Plasma")
			//TNT1 A 0 A_JumpIfInTargetInventory("HasCutingWeapon", 1, "Death.Decaptate")
			TNT1 A 0 A_JumpIfHealthLower(-300, "HeavyHead")
			TNT1 A 0 A_JumpIfHealthLower(-50, "Death.HeadExplode")
			TNT1 A 0 A_JumpIfInTargetInventory("RandomHeadExploder", 1, "HeadExploder")
			TNT1 A 0 A_JumpIfInTargetInventory("HeavyAutomaticWeapon", 1, "Death.MinorHeadLong")
		Death.HeadMinor:
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")		
			TNT1 A 0 A_FaceTarget
			TNT1 A 0 A_PlaySound("misc/xdeath4", CHAN_VOICE)
			TNT1 A 0 A_Jump(96, "Death.MinorHeadLong")
			TNT1 A 0 A_CustomMissile ("FBD_Bloodmist", 50, 0, random (0, 360), CMF_AIMDIRECTION, random (30, 90))
			TNT1 AA 0 A_CustomMissile ("SmallBrainPiece", 50, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("XDeath1", 40, 0, random (100, 130), 2, random (0, 160))
			TNT1 A 0 A_CustomMissile ("Brains3", 50, 0, random (90, 110), 2, random (0, 160))
			TNT1 A 0 A_CustomMissile ("Brains5", 50, 0, random (100, 130), 2, random (0, 160))
			TNT1 A 0 A_Scream
			SPOS TTTTUU 2 A_CustomMissile ("Brutal_LiquidBlood", 40, 0, 120, 2, random (0, 60))
			SPOS VVV 2 A_CustomMissile ("Brutal_LiquidBlood2", 30, 0, 120, 2, random (60, 120))
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("SoulAmmo", 1)			
			SPOS XXXYYY 2 A_CustomMissile ("Brutal_LiquidBlood2", 20, 0, random (0, 360), CMF_AIMDIRECTION, random (60, 120))
			TNT1 A 0 A_CustomMissile ("ArterialBloodSPray", 10, 10, -45, 2, random (0, 60))
			TNT1 A 0 A_SpawnItem ("GrowingBloodPool")
			TNT1 A 0 A_SpawnItemEx("DeadShotgunguySPOSZ",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			//TNT1 A -1
			Stop
			
		Death.MinorHeadLong:
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("SoulAmmo", 1)
			TNT1 A 0 A_Scream
			TNT1 A 0 A_SpawnItemEx("DyingShotgunguyHitInEye",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop
			
		DeathMinorHead4:
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			TNT1 A 0 A_Pain
			TNT1 A 0 A_FaceTarget
			TNT1 A 0 A_CustomMissile ("Brains4", random (45, 55), random (5, -5), random (170, 190), CMF_AIMDIRECTION, random (-10, 10))
			TNT1 AA 0 A_CustomMissile ("SmallBrainPieceFast", random (45, 55), random (5, -5), random (170, 190), CMF_AIMDIRECTION, random (-10, 10))
			TNT1 A 0 A_CustomMissile ("SmallBrainPiece", 50, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("SuperWallRedBlood", 46, 0, random (170, 190), CMF_AIMDIRECTION, random (0, 40))
			TNT1 A 0 A_CustomMissile ("FBD_Bloodmist", 50, 0, random (0, 360), CMF_AIMDIRECTION, random (30, 90))
			13DG J 6
			13DG KL 8
			
			TNT1 A 0 A_Scream
			13DG M 6 A_NoBlocking
			TNT1 A 0 A_CustomMissile ("ArterialBloodSPray", 10, -10, 45, 2, random (0, 60))
			TNT1 A 0 A_SpawnItem ("GrowingBloodPool")
			TNT1 A 0 A_SpawnItemEx("FBD_DeadShotgunGuy13DGN",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop
		
		//***Che:
		Death.HeadPlasma: // inflicted by headbox hit by plasma
			TNT1 A 0 
			TNT1 A 0 A_JumpIfHealthLower(-200, "Death.Plasma") //***Che: instead of the now defunct XDeath
		
		//***Che:
		Death.Psionic: // inflicted by aracnorbs
		
		Death.headExplode:
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			TNT1 A 0 A_XScream
			TNT1 A 0 A_JumpIfInTargetInventory("HeavyStrikeUpward", 1, "HeavyHead")
			TNT1 A 0 A_SpawnItem("ShotgunguyHeadExplode", 0, 50)
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("SoulAmmo", 1)
			SPDH AAAAA 2 A_CustomMissile ("Brutal_LiquidBlood2", 40, 0, random (0, 360), CMF_AIMDIRECTION, random (60, 120))
			TNT1 A 0 A_FaceTarget
			TNT1 A 0 A_SpawnItemEx("DeadShotgunguyNoHeadContinue",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop
			
		//***Che
		Death.HeadStun:
		HeavyHead: //***Che: this awesome backflip death was never seen because who, ever, receives 400 damage from a headshot? Had to remove xdeath to allow this
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")		
			TNT1 A 0 A_ChangeFlag("NOBLOCKMONST", 1)
			TNT1 A 0 A_PlaySound("misc/xdeath4", CHAN_VOICE)
			TNT1 A 0 A_FaceTarget
			TNT1 A 0 A_Recoil(10)
			TNT1 A 0 ThrustThingZ(0,35,0,1)
			TNT1 A 0 A_CustomMissile ("MuchBlood2", 40, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("Brains2", 40, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("Brains3", 40, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("Brains5", 40, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("BrainsSergeantHeadPiece", 50, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 AAA 0 A_CustomMissile ("SmallBrainPieceFast", random (45, 55), random (5, -5), random (170, 190), CMF_AIMDIRECTION, random (-10, 10))
			TNT1 AAAAA 0 A_CustomMissile ("SmallBrainPiece", 40, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 AA 0 A_CustomMissile ("SuperWallRedBlood", 46, 0, random (170, 190), CMF_AIMDIRECTION, random (0, 40))
			ZMAD B 0 A_XScream
			
			ZMAD C 0 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("SoulAmmo", 1)
			SOSL GHIJK 6
			TNT1 A 0 A_CustomMissile ("ArterialBloodSPray", 10, 10, -45, 2, random (0, 60))
			SOSL L -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.decaptate:
		Death.CCFT:
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")		
			TNT1 AAAAAAA 0 A_CustomMissile ("Blood", 50, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_PlaySound("misc/xdeath4", CHAN_VOICE)
			TNT1 A 0 A_CustomMissile ("XDeathSergeantHeadBeheaded", 50, 0, random (0, 360), CMF_AIMDIRECTION, random (40, 90))
			TNT1 A 0 A_CustomMissile ("MuchBlood2", 40, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_XScream
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("SoulAmmo", 1)
			SPDH AAAAABBBBBBBBBBCCCCC 2 A_CustomMissile ("Brutal_LiquidBlood2", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (60, 120))
			SPDH DDDDDDEEEEE 2 A_CustomMissile ("Brutal_LiquidBlood2", 10, 0, random (0, 360), CMF_AIMDIRECTION, random (60, 120))
			SPDH EEEEEEEEEEEE 2 A_CustomMissile ("Brutal_LiquidBlood2", 5, 0, random (0, 360), CMF_AIMDIRECTION, random (10, 40))
			TNT1 A 0 A_SpawnItem ("GrowingBloodPool")
			TNT1 A 0 A_SpawnItemEx("DeadShotgunguySPDHE",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			//TNT1 A -1
			Stop

			
			
		Death.HKFT:
			TNT1 A 0
			TNT1 A 0 A_JumpIfInventory("HitLeg", 1, "Death.LegMassacre") 
			TNT1 A 0 A_Jump(64, "Death.Arm")
			Goto Death.Tear

		Death.SniperBullet:
		Death.Bullet792:		
		Death.Minigun:
			TNT1 A 0 A_JumpIfInventory("HitLeg", 3, "Death.LegMassacre") 
			TNT1 A 0 A_JumpIfInventory("HitLeg", 1, "Death.Leg")
			TNT1 A 0
			TNT1 A 0 A_JumpIfInventory ("IsDown", 1, "Death.Down")
			TNT1 A 0 A_Jump(16, "Death")
			TNT1 A 0 A_Jump(32, "Death.Cut")
			//TNT1 A 0 A_Jump(9, "Death.LegMassacre")
			TNT1 A 0 A_Jump(64, "Death")
			Goto Death_Minigun
			
		Death.Saw:
		Death.Tear:
			TNT1 A 0
			TNT1 A 0 A_JumpIfInventory("HitLeg", 2, "Death.LegMassacre") 
			TNT1 A 0 A_JumpIfInventory("HitLeg", 1, "Death.Leg")

			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			TNT1 A 0 A_Jump(32, "Death.ARm")
			TNT1 A 0 A_CustomMissile ("MuchBlood", 1, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_Scream
			TNT1 O 0 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("SoulAmmo", 1)
			SP2X AA 8
			TNT1 A 0 A_CustomMissile ("XDeath4", 40, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("RipSergeant", 0, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			SP2X BBCD 8
			TNT1 A 0 A_SpawnItem ("GrowingBloodPool")
			TNT1 A 0 A_SpawnItemEx("DeadShotgunguySP2XE",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			//TNT1 A -1
			Stop
			
		Death_Minigun:
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			TNT1 A 0 A_FaceTarget
			TNT1 A 0 A_Scream
			TNT1 O 0 A_NoBlocking
			TNT1 A 0 A_SpawnItemEx ("BrutalizedSergeant1",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop

		Death.LegMassacre:
			TNT1 A 0
			TNT1 A 0 A_FaceTarget
			TNT1 A 0 A_Scream
			TNT1 O 0 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("SoulAmmo", 1)
			TNT1 A 0 A_SpawnItemEx ("BrutalizedSergeantLeg",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop
			
		Death.Blast:
		Death.Railgun:
			TNT1 A 0
			TNT1 A 0 A_JumpIfInventory("HitLeg", 1, "Death.Leg") 
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			TNT1 A 0 A_FaceTarget
			TNT1 A 0 A_Jump(12, "Death.Arm")
			TNT1 A 0 A_Jump(128, "Death.Blast2")
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("SoulAmmo", 1)
			TNT1 A 0 A_Scream
			TNT1 AAA 0 A_CustomMissile ("Guts", 32, 0, random (150, 210), CMF_AIMDIRECTION, random (0, 40))
			TNT1 AAA 0 A_CustomMissile ("XDeath1", 32, 0, random (150, 210), CMF_AIMDIRECTION, random (0, 40))
			TNT1 AAA 0 A_CustomMissile ("Xdeath3", 16, 0, random (170, 190), CMF_AIMDIRECTION, random (0, 40))
			TNT1 AAAA 0 A_CustomMissile ("FBD_FlyingBlood", 32, 0, random (170, 190), CMF_AIMDIRECTION, random (0, 40))
			TNT1 AAAA 0 A_CustomMissile ("Brutal_FlyingBloodFaster", 32, 0, random (170, 190), CMF_AIMDIRECTION, random (0, 40))
			TNT1 AAAA 0 A_CustomMissile ("Brutal_FlyingBloodMuchFaster", 32, 0, random (170, 190), CMF_AIMDIRECTION, random (0, 40))
			TNT1 AA 0 A_CustomMissile ("SuperWallRedBlood", 32, 0, random (170, 190), CMF_AIMDIRECTION, random (0, 40))
			TNT1 AA 0 A_CustomMissile ("BloodMistBig", 40, 0, random (0, 360), CMF_AIMDIRECTION, random (30, 90))
			TNT1 AAA 0 A_CustomMissile ("BloodMistBig", 40, 0, random (0, 360), CMF_AIMDIRECTION, random (30, 90))
			ZXZ7 A 6 A_Stop
			TNT1 A 0 A_SpawnItemEx ("SergeantFallingHoleOnStomach",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop
			
		Death.Blast2:
			TNT1 A 0 A_XScream
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("SoulAmmo", 1)
			TNT1 A 0 A_CustomMissile ("XDeathArm1", 42, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 40))
			TNT1 AAA 0 A_CustomMissile ("Guts", 32, 0, random (150, 210), CMF_AIMDIRECTION, random (0, 40))
			TNT1 AAA 0 A_CustomMissile ("XDeath1", 32, 0, random (150, 210), CMF_AIMDIRECTION, random (0, 40))
			TNT1 AAA 0 A_CustomMissile ("Xdeath3", 16, 0, random (170, 190), CMF_AIMDIRECTION, random (0, 40))
			TNT1 AA 0 A_CustomMissile ("Xdeath2", 16, 0, random (130, 210), CMF_AIMDIRECTION, random (0, 40))
			TNT1 AAAA 0 A_CustomMissile ("FBD_FlyingBlood", 32, 0, random (170, 190), CMF_AIMDIRECTION, random (0, 40))
			TNT1 AAAA 0 A_CustomMissile ("Brutal_FlyingBloodFaster", 32, 0, random (170, 190), CMF_AIMDIRECTION, random (0, 40))
			TNT1 AAAA 0 A_CustomMissile ("Brutal_FlyingBloodMuchFaster", 32, 0, random (170, 190), CMF_AIMDIRECTION, random (0, 40))
			TNT1 AA 0 A_CustomMissile ("SuperWallRedBlood", 32, 0, random (170, 190), CMF_AIMDIRECTION, random (0, 40))
			TNT1 AAA 0 A_CustomMissile ("BloodMistBig", 40, 0, random (0, 360), CMF_AIMDIRECTION, random (30, 90))
			TNT1 AAA 0 A_CustomMissile ("FBD_Bloodmist", 40, 0, random (0, 360), CMF_AIMDIRECTION, random (40, 90))
			ZXZ6 A 6 A_Stop
			TNT1 A 0 A_SpawnItemEx("SergeantFallingSplattered",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop
			
		Death.SSG:
		//Death.Railgun:
			TNT1 A 0
			TNT1 A 0 A_JumpIfInventory("HitLeg", 3, "Death.LegMassacre") 
			TNT1 A 0 A_JumpIfInventory("HitLeg", 1, "Death.Leg") 
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			TNT1 A 0 A_Stop
			SZD1 E 1 A_Pain
			TNT1 A 0 A_SpawnItem("Muchblood2", 0, 40)
			SZD1 E 1 A_FaceTarget
			
			TNT1 AAA 0 bright A_CustomMissile ("SuperGoreSpawner", 35, 0, random (170, 190), CMF_AIMDIRECTION, random (0, 40))
			TNT1 A 0 A_CustomMissile ("XDeath2", 32, 0, random (170, 190), CMF_AIMDIRECTION, random (0, 40))
			TNT1 A 0 A_CustomMissile ("XDeath3", 32, 0, random (170, 190), CMF_AIMDIRECTION, random (0, 40))
			TNT1 AAA 0 A_CustomMissile ("Guts", 32, 0, random (150, 210), CMF_AIMDIRECTION, random (0, 40))
			TNT1 AA 0 A_CustomMissile ("XDeathArm1", 32, 0, random (170, 190), CMF_AIMDIRECTION, random (0, 40))
			TNT1 A 0 A_CustomMissile ("XDeathSergeantHead", 32, 0, random (170, 190), CMF_AIMDIRECTION, random (0, 40))
			TNT1 A 0 A_XScream
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("SoulAmmo", 1)
			SZD1 EEFFGH 6
			TNT1 A 0 A_SpawnItem ("GrowingBloodPool")
			TNT1 A 0 A_SpawnItemEx("DeadShotgunguySZD1H",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			//TNT1 A -1
			Stop
			
			
		Death.Cut:
			TNT1 A 0
			TNT1 A 0 A_JumpIfInventory("HitLeg", 2, "Death.LegMassacre") 
			TNT1 A 0 A_JumpIfInventory("HitLeg", 1, "Death.Leg")
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			TNT1 A 0 A_Stop
			SZD1 E 1 A_Pain
			TNT1 A 0 A_SpawnItem("Muchblood2", 0, 40)
			SZD1 E 1 A_FaceTarget
			TNT1 A 0 A_CustomMissile ("RipGuts", 32, 0, random (170, 190), CMF_AIMDIRECTION, random (0, 40))
			TNT1 A 0 A_CustomMissile ("XDeathHalfSergeant2", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (60, 70))
			TNT1 A 0 A_XScream
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("SoulAmmo", 1)
			SZD1 EEFFGH 6
			TNT1 A 0 A_SpawnItem ("GrowingBloodPool")
			TNT1 A 0 A_SpawnItemEx("DeadShotgunguySZD1H",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			//TNT1 A -1
			Stop	
			
			
		

		Death.GreenFire:
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			TNT1 A 0 A_XScream
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("SoulAmmo", 1)
			TNT1 AAAA 0 A_CustomMissile ("FBD_Blood", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			
			TNT1 A 0 A_CustomMissile ("XDeathBurnedArm", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("XDeathBurnedLeg", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("XDeathBurnedSkull", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("XDeathBurnedMeat", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("XDeathBurnedMeat2", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("XDeathBurnedMeat3", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			
			EXPL AAAAAAAAAAAAAAAAAAAAAAAA 0 A_CustomMissile ("GreenFlameTrails", 50, 0, random (0, 360), 2, random (0, 360))
			XBRN AAAA 2 BRIGHT A_SpawnItem("GreenFlare",0,43)
			
			//***Che: ChebMaster's blunder of a lifetime: produces an invulnerable ghost!
			//TNT1 A 2400 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			
			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.Plasma: 
		XDeath.Electric:
		Death.Plasma2:
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			TNT1 A 0 A_Stop
			PBR1 A 6 A_XScream
			TNT1 AAAA 0 A_CustomMissile ("BluePlasmaFireNonStatic", 42, 0, random (0, 360), 2, random (0, 180))
			TNT1 AAA 0 A_CustomMissile ("Blood", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 180))
			TNT1 AAA 0 A_CustomMissile ("BloodMistSmall", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 180))
			TNT1 AAA 0 A_CustomMissile ("FBD_FlyingBlood", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 180))
			PBR1 B 6 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("SoulAmmo", 1)
			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))
			PBR1 CCDD 3 A_CustomMissile ("BluePlasmaFireNonStatic", 32, 0, random (0, 360), 2, random (0, 180))
			PBR1 EEFF 3 A_CustomMissile ("BluePlasmaFireNonStatic", 24, 0, random (0, 360), 2, random (0, 180))
			PBR1 GG 3 A_CustomMissile ("BluePlasmaFireNonStatic", 22, 0, random (0, 360), 2, random (0, 180))
			
			PBR1 H -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.ExtremePunches:
		Death.DHFT:
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			//TNT1 A 0 A_JumpIfInTargetInventory("HeavyStrikeRight", 1, "HeavyPunchRight")
			//TNT1 A 0 A_JumpIfInTargetInventory("HeavyStrikeLeft", 1, "HeavyPunchLeft") 
			//TNT1 A 0 A_JumpIfInTargetInventory("HeavyStrikeUpper", 1, "HeavyPunchUpper")
			TNT1 A 0 A_XScream
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("SoulAmmo", 1)
			TNT1 A 0 A_FaceTarget
			TNT1 A 0 A_CustomMissile ("ExtremePunchedShotgunguy", 8, 0, random (175, 185), 2, random (10, 20))
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop
			 
		HeavyPunchRight:
			TNT1 A 0
			TNT1 A 0 A_FaceTarget
			TNT1 A 0 ThrustTHing(angle*256/360+64, 10, 0)
			Goto BlownAwayRight
			
		HeavyPunchLeft:
			TNT1 A 0
			TNT1 A 0 A_FaceTarget
			TNT1 A 0 ThrustTHing(angle*256/360+192, 10, 0)
			Goto BlownAwayLeft
		
		

		Death.SuperPlasma:
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			TNT1 A 0 A_XScream
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("SoulAmmo", 1)
			XBRN AA 2 BRIGHT A_SpawnItem("BlueFlare",0,43)
			TNT1 AAAA 0 A_CustomMissile ("FBD_Blood", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			
			TNT1 A 0 A_CustomMissile ("XDeathBurnedArm", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("XDeathBurnedLeg", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("XDeathBurnedSkull", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("XDeathBurnedMeat", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("XDeathBurnedMeat2", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("XDeathBurnedMeat3", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))

			XBRN BB 2 BRIGHT A_SpawnItem("BlueFlare",0,43)
			TNT1 A 0 A_CustomMissile ("FBD_Blood", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			XBRN CC 2 BRIGHT A_SpawnItem("BlueFlare",0,43)
			TNT1 AAAAA 0 A_CustomMissile ("PlasmaParticleX", 48, 0, random (0, 360), 2, random (0, 360))
			TNT1 AAA 0 A_CustomMissile ("BigPlasmaParticleX", 42, 0, random (0, 360), 2, random (0, 360))
			
			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.Fatality:
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			TNT1 A 0 A_FaceTarget
			TNT1 A 0 A_SpawnItemEx("Shell", 0, 0, 40, 0, 0, 0, 0, 0, 128)
			//TNT1 A 0 A_SpawnItemEx("HealthPlusFatalityBonus", 0,0,20, random (-1, 1),random (-1, 1),8, 0, SXF_ABSOLUTEVELOCITY | SXF_NOCHECKPOSITION)
			//TNT1 A 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, 5, 5, 0) // 0, health, armor, 0 -- rounded down to nearest 2
			TNT1 A 0 A_Pain
			TNT1 A 0 A_JumpIfIntargetInventory("IsPlayer", 1, 2)
			Goto Death.ExplosiveImpact
			TNT1 A 0
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("SoulAmmo", 1)
			TNT1 A 0 A_GiveToTarget("GoFatality", 1)
			TNT1 A 0 A_Jump(256, "Death.Fatality1", "Death.Fatality4", "Death.Fatality2", "Death.Fatality3")
			
		Death.Fatality1:	
			TNT1 A 0 A_GiveToTarget("SergeantFatality", 1)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0) // without at least 8 tics delay, scripts runs ownerless
			Stop
		Death.Fatality2:    
			TNT1 A 0 A_GiveToTarget("SergeantFatality2", 1)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0) // without at least 8 tics delay, scripts runs ownerless
			Stop
		Death.Fatality3:    
			TNT1 A 0 A_GiveToTarget("SergeantFatality3", 1)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0) // without at least 8 tics delay, scripts runs ownerless
			Stop
			
		Death.Fatality4:    
			TNT1 A 0 A_GiveToTarget("SergeantFatality4", 1)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0) // without at least 8 tics delay, scripts runs ownerless
			Stop	
		Death.Fatality5:    
			TNT1 A 0 A_GiveToTarget("SergeantFatality5", 1)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0) // without at least 8 tics delay, scripts runs ownerless
			Stop		
			
		Death.PussyGrab:
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			TNT1 A 0 A_Pain
			TNT1 A 0 A_Chase("","")
			TNT1 A 0 A_Pain
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("SoulAmmo", 1)
			TNT1 A 0 A_GiveToTarget("GrabbedAShotgunguy", 1)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop		
			
		Death.HelperMarineFatallity:	
		Death.BHFT:
		Death.RVFT:
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			TNT1 A 1 A_Pain
			TNT1 A 0 A_Chase("","")
			TNT1 A 0 A_Scream
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("SoulAmmo", 1)			
			TNT1 A 0 A_GiveToTarget("SergeantFatality", 1)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop	
			
		Death.fire:
		Death.burn:
		Death.FallInLava:
		Death.flames:
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")		
			TNT1 A 0 A_Scream
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("SoulAmmo", 1)
			TNT1 A 0 A_SpawnItemEx("BurningShotgunguy",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			//TNT1 A 0 A_SpawnItem("BurningShotgunguy", 0, 10)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop
		
		//***Che: having this state at all prevents many other states from working!
		XDeath:
			Stop // we can't just comment it out: inherited state goes into effect... all messed up because BD sprites mismatch DooM sprites
		
		Death.Explosives: // direct rocket hit	
		Death.Bfg10k: //***Che changed damage type from extreme to custom
		Asplode:
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")		
			TNT1 A 0 A_XScream
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("SoulAmmo", 1)
			TNT1 A 0 A_FaceTarget
			TNT1 AAA 0 A_CustomMissile ("XDeath1", 42, 0, random (0, 190), CMF_AIMDIRECTION, random (10, 60))
			TNT1 AAA 0 A_CustomMissile ("XDeath3", 42, 0, random (0, 190), CMF_AIMDIRECTION, random (10, 60))
			TNT1 A 0 A_CustomMissile ("XDeath2", 42, 0, random (0, 190), CMF_AIMDIRECTION, random (10, 60))
			TNT1 A 0 A_CustomMissile ("XDeath4", 42, 0, random (0, 190), CMF_AIMDIRECTION, random (10, 60))
			TNT1 A 0 A_CustomMissile ("SargeXDeath", 0, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop
			
		Death.Desintegrate:
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")		
			TNT1 A 0 A_XScream
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("SoulAmmo", 1)
			TNT1 A 0 A_SpawnItemEx("DesintegratingShotgunGuy", 0,0,0, momx,momy,momz, 0,SXF_NOCHECKPOSITION | SXF_ABSOLUTEVELOCITY)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop
		Death.Slime:
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")		
			TNT1 A 0 A_XScream
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("SoulAmmo", 1)
			TNT1 A 0 A_SpawnItemEx("MeltingShotgunGuy", 0,0,0, momx,momy,momz, 0,SXF_NOCHECKPOSITION | SXF_ABSOLUTEVELOCITY)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop			
			
/*			
			TNT1 A 0 A_SpawnItem("DesintegratedHuman")
			TNT1 A 0 A_Stop
			
			TGIB ABCDEFGHIJKLMNOPQ 3
			TGIB Q -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.Stomp:
			TNT1 A 0
			// if 15% random chance or the cyberdemon is below us, be catapulted violently
			TNT1 A 0 A_JumpIf(Random(0,100) < 15 || CallAcs("GetZDeltaToTarget") < - 32, "Death.ExtremePunches") 
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")		
			TNT1 A 0 A_Scream
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("SoulAmmo", 1)
			SPOS IJK 2
			TNT1 AA 0 A_SpawnItem("MeatDeathSmall")
			TNT1 AAA 0 bright A_CustomMissile ("SuperGoreSpawner", 5, 0, random (0, 360), CMF_AIMDIRECTION, random (30, 180))
			TNT1 AAAA 0 bright A_CustomMissile ("XDeath1", 5, 0, random (0, 360), CMF_AIMDIRECTION, random (30, 180))
			TNT1 AA 0 bright A_CustomMissile ("XDeath2b", 55, 0, random (0, 360), CMF_AIMDIRECTION, random (30, 180))
			TNT1 AA 0 bright A_CustomMissile ("XDeath3b", 55, 0, random (0, 360), CMF_AIMDIRECTION, random (30, 180))
			TNT1 A 0 A_SpawnItem ("GrowingBloodPool")
			TNT1 A 0 A_SpawnItem ("CrushedRemains")
			TNT1 A 1
			TNT1 A 1 A_XScream
			
			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
			
		Crush:
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			TNT1 AAAA 0 A_SpawnItemEx ("BodyRemovalThing",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
			TNT1 AAAAA 0 A_CustomMissile ("Brutal_FlyingBloodTrail8", 0, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 360))
			TNT1 A 1 A_XScream
			
			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

		//***Che
		Death.FriendlyExplosion:
		
		Death.ExplosiveImpact:
			TNT1 A 0
			
			TNT1 A 0 A_JumpIfHealthLower(-70, "Asplode") //***Che: instead of the now defunct XDeath
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			TNT1 A 0 A_ChangeFLag("NODROPOFF", 0)
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("SoulAmmo", 1)
			TNT1 A 0 A_SpawnItemEx("MuchBlood2", 0, 0, 40)
			TNT1 A 0 ThrustThingZ(0,30,0,1)
			TNT1 A 0 A_FaceTarget
			TNT1 A 1
			TNT1 A 0 A_JumpIf(angle < 180, "IsFacingNorth")
			TNT1 A 0 A_JumpIf(velx < 0, "BlownAwayRight")
			TNT1 A 0 A_JumpIf(velx > 0, "BlownAwayLeft")
			Goto Asplode //XDeath
		IsFacingNorth:
			TNT1 A 0 A_JumpIf(velx > 0, "BlownAwayRight")
			TNT1 A 0 A_JumpIf(velx < 0, "BlownAwayLeft")
			Goto Asplode //XDeath
			
		BlownAwayLeft:	
			TNT1 A 0
			TNT1 A 0 ThrustThingZ(0,15,0,1)
			TNT1 A 0 A_JumpIfHealthLower(-15, 1)
			Goto LegRemove
			TNT1 A 0 A_Jump(96, "Death.LandMine")
			TNT1 A 0
			TNT1 A 0 A_CustomMissile ("XDeath2", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_ChangeFlag("NOBLOCKMONST", 1)
			TNT1 A 0 A_CustomMissile ("Brains2", 50, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("Brains3", 50, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("Brains4", 50, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("Brains5", 50, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 AAAA 0 A_CustomMissile ("SmallBrainPieceFast", random (45, 55), random (5, -5), random (170, 190), CMF_AIMDIRECTION, random (-10, 10))
			TNT1 AAAA 0 A_CustomMissile ("SmallBrainPiece", 50, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("XDeathArm1", 35, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("XDeath3", 40, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("XDeathZombieLeg", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 ThrustThingZ(0,10,0,1)
			TNT1 A 0 A_Xscream
			SXSX GHIJKLM 3
			TNT1 A 0 A_CheckFloor("Land8473")
			SXSX GHIJKLMGHIJKLM 5 A_CheckFloor("Land8473")
		Land8473:
			SXSX N 0
			TNT1 A 0 A_Stop
			TNT1 A 0 A_SpawnItem("GrowingBloodPool")
			TNT1 A 0 A_SpawnItemEx("DeadSergeantSXSXO",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop
			
		BlownAwayRight:
			TNT1 A 0
			TNT1 A 0 ThrustThingZ(0,15,0,1)
			TNT1 A 0 A_JumpIfHealthLower(-15, 1)
			Goto Death.Arm
			TNT1 A 0 A_Jump(96, "Death.Hammered")
			TNT1 A 0 A_CustomMissile ("XDeath2", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_ChangeFlag("NOBLOCKMONST", 1)
			TNT1 A 0 A_CustomMissile ("Brains2", 50, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("Brains3", 50, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("Brains4", 50, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("Brains5", 50, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 AAAA 0 A_CustomMissile ("SmallBrainPieceFast", random (45, 55), random (5, -5), random (170, 190), CMF_AIMDIRECTION, random (-10, 10))
			TNT1 AAAA 0 A_CustomMissile ("SmallBrainPiece", 50, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("XDeathArm1", 35, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("XDeath3", 40, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("XDeathZombieLeg", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 ThrustThingZ(0,15,0,1)
			TNT1 A 0 A_XScream
			SXS2 GHIJKLM 3
			TNT1 A 0 A_CheckFloor("Land8472")
			SXS2 GHIJKLMGHIJKLM 5 A_CheckFloor("Land8472")
		Land8472:
			SXS2 N 0
			TNT1 A 0 A_Stop
			TNT1 A 0 A_SpawnItem("GrowingBloodPool")
			TNT1 A 0 A_SpawnItemEx("DeadSergeantSXS2O",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop	
			
		Death.Hammered:
			TNT1 A 0 A_ChangeFLag("NODROPOFF", 0)
			TNT1 A 0
			TNT1 A 0 A_CustomMissile ("XDeath1", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("XDeath2", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_ChangeFlag("NOBLOCKMONST", 1)
			TNT1 A 0
			TNT1 A 0 A_Jump(96,"Death.LandMine")
			TNT1 AAAA 0 A_CustomMissile ("Brains1", 50, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("Brains2", 50, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("Brains3", 50, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("Brains4", 50, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("Brains5", 50, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 AAAA 0 A_CustomMissile ("SmallBrainPieceFast", random (45, 55), random (5, -5), random (170, 190), CMF_AIMDIRECTION, random (-10, 10))
			TNT1 AAAA 0 A_CustomMissile ("SmallBrainPiece", 50, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 AA 0 A_CustomMissile ("SuperWallRedBlood", 46, 0, random (170, 190), CMF_AIMDIRECTION, random (0, 40))
			TNT1 AAAAAAAAAAA 0 A_CustomMissile ("BrainBlood", 50, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("XDeathArm1", 35, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("XDeath3", 40, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("XDeathSargeLeg2", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 ThrustThingZ(0,30,0,1)
			ID14 AB 5
			ID14 CDEF 5 A_CheckFloor ("Dead.ExplosiveImpact")
			ID14 FFFFFF 5 A_CheckFloor ("Dead.ExplosiveImpact")
			TNT1 A 0 A_SpawnItemEx ("VeryFuckedUpBrutalizedSergeantLeg",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop
			
		Dead.ExplosiveImpact:
			TNT1 A 0 A_SpawnItem ("GrowingBloodPool")
			TNT1 A 0 A_SpawnItemEx ("VeryFuckedUpBrutalizedSergeantLeg",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 0 A_SpawnItem ("Ploft")
			TNT1 A 0 A_SpawnItem ("MuchBlood")
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop

			
		Death.LandMine:
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")		
			TNT1 A 0 A_CustomMissile ("XDeathSargeLeg1", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 ThrustThingZ(0,25,0,1)
			ID16 A 1 A_Scream
			ID16 A 9
			ID16 BCD 9 A_CheckFloor ("Dead.Landmine")
			ID16 DDDD 9 A_CheckFloor ("Dead.Landmine")
			TNT1 A 0 A_SpawnItemEx ("DeadShotgunguy_NoLeg",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop		
		
		Dead.Landmine:
			TNT1 A 0 A_SpawnItem ("GrowingBloodPool")
			TNT1 A 0 A_SpawnItemEx ("DeadShotgunguy_NoLeg",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 0 A_SpawnItem ("Ploft")
			TNT1 A 0 A_SpawnItem ("MuchBlood")
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop
		

		 
			
		StealthKill:
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			TNT1 A 0 A_JumpIfInTargetInventory("IsPlayer", 1, 1)
			Goto Death
			TNT1 A 0 A_GiveToTarget("GoFatality", 1)
			TNT1 A 0 A_GiveToTarget("GoSpecial", 1)
			TNT1 A 0 A_GiveToTarget("SKShotgunGuy", 1)
			TNT1 A 0 A_Fall
			//TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_Die("Stealthy")
			TNT1 A 1
			
			TNT1 A 1
			Stop
		Death.Stealthy:
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("SoulAmmo", 1)
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop
			
		Death.Ice:
		Death.Freeze:
		Death.Frost:
			//TNT1 A 0 A_ChangeFlag("SHOOTABLE", 0)
			//TNT1 A 0 A_ChangeFlag("SOLID", 0)
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("SoulAmmo", 1)
			TNT1 A 0 A_SpawnItemEx("FrozenShotgunguy",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop
			
		Death.IOS_Frost:
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_SpawnItemEx("PermafrostShotgunguy",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop	
		
		Death.Massacre:
			Goto Death
			
		LTGCheckExtreme: // extreme outfits, 25% chance to treat the player as naked on each attack.
			TNT1 A 0 A_JumpIfCloser(400, 1)
			Goto MissileContinueAfterLTGCheck
			TNT1 A 0 A_JumpIfInTargetInventory("LTGExtreme", 1, 1)
			Goto MissileContinueAfterLTGCheck
			TNT1 A 0 A_Jump(64, "LTGCheckB")
			Goto MissileContinueAfterLTGCheck
		LTGCheck:
			TNT1 A 0 A_JumpIfInTargetInventory("IsDressed", 1, "LTGCheckExtreme")
		LTGCheckB:
			TNT1 A 0 A_JumpIfInventory("AlreadyPerformedLTGCatCall", 1, "LTGCheck2")
			
			TNT1 A 0 A_JumpIfCloser(600, 1)
			Goto MissileContinueAfterLTGCheck
			
			TNT1 A 0 A_GiveInventory("AlreadyPerformedLTGCatCall", 1)
			TNT1 A 0 A_PlaySound("grunt/catcall", CHAN_VOICE)
			
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 0, 1, 36)
			SPSR CCCCCCC 15 A_FaceTarget
			Goto See

		LTGCheck2:
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 2, 0, 42)
			TNT1 A 0 A_PlaySound("grunt/catcall", CHAN_VOICE)
			SHID ABABAB 15 A_FaceTarget
			TNT1 A 0 A_JumpIfTargetInLOS("MissileContinueAfterLTGCheck")
			Goto See
	}
}

Actor ShotgunGuyRaisedByVile: FBD_ShotgunGuy {
	States {
		Spawn:
			TNT1 A 0 NODELAY A_ChangeFlag("NOPAIN", 1)
			
			//SPOS LKJIH 5
			SPOS TSRQPONMHG 3
			TNT1 A 0 A_Jump(32, "ReplaceSMG")
			TNT1 A 0 ACS_NamedExecuteWithResult("FBD_RunMonster", 5) // 5 = default headbox
			SPOS G 7
			TNT1 A 0 A_ChangeFlag("NOPAIN", 0)
			TNT1 A 0 ACS_NamedExecuteWithResult("FBD_CustomizeOnRez") // it runs OnRezMapScript
				// if the map prpvides one
			Goto See	

	}
}

Actor ShotgunGuy1_PP: FBD_ShotgunGuy
{
	States
	{
		PotPourriSwap:
			TNT1 A 0
			Goto PotPourriCancel		
	}
}	

Actor FBD_DeadShotgunGuy1: FBD_CurbstompedMarine Replaces DeadShotgunguy
{
    Radius 16 //***Che otherwise raising failures //12
    Height 12
    +SHOOTABLE
    +NOTELEPORT
    +MOVEWITHSECTOR
    +CORPSE
	+FLOORCLIP
	-SOLID
	+THRUACTORS
	damagefactor "Crush", 50.0
    Mass 6000
    Health 300
    damagefactor "Blood", 0.0
    PainChance "Melee", 255
    damagefactor "Trample", 0.0
	damagefactor "ExplosiveImpact", 10.0
	States
		{
		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", 2001), "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 ("ShotgunGuyRaisedByVile",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, 9, 0, 0) //"ShotgunGuyRaisedByVile"
			"----" A -1 ACS_NamedExecuteWithResult("FallbackRezMkII", 2001) // see _mob_list.xlsx
			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
			SPOS 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
			SPOS L 30
			TNT1 A 0 A_JumpIf(user_floor_is_lava, "LandOnLava")	
			SPOS L -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop			
		LandOnLava: 
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			TNT1 A 0 A_SpawnItem("CharredMeatsplosionIntoGoryAshes")
			TNT1 A -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop				
			
		Death:
			TNT1 A 0 A_CustomMissile ("XDeathSargeLeg1", 5, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			SPOS A 0 A_CustomMissile ("MeatDeathSmall", 5, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_SpawnItemEx ("DeadShotgunGuy_NoLeg",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop

		Death.Plasma: 
		Death.Electric:
		Death.Plasma2:
		Death.Bfg10k: //***Che changed damage type from extreme to custom
			TNT1 A 0
			TNT1 A 0 A_XScream
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			TNT1 AAA 0 A_CustomMissile ("FBD_FlyingBlood", 50, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("XDeathBurnedMeat", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("XDeathBurnedMeat2", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("XDeathBurnedMeat3", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			EXPL AAA 0 A_CustomMissile ("ExplosionSmoke", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 360))
			
			TNT1 A -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop

	}
}

Actor DesintegratingShotgunGuy: FBD_DeadShotgunGuy1
{
	damagefactor "Desintegrate", 0.0
	
	Health 300
	States
	{
		Spawn:
			ID50 HIJKL 5 
		Stay: // ancestor's Pain.Kick, Pain.ExplosiveImpact and Pain.Trample redirect here after z-thrusting the actor
			ID50 M 5 
			"----" A 0 A_CheckFloor("Slide")  // if this goes before the non-zero frame, we have an infinite loop!
			Loop
		Slide:
			"----" A 0
			"----" A 0 A_JumpIf(momx != 0 || momy != 0, "Stay") // not until the actor stops sliding		
		Land:	
			"----" A 0
			"----" A 0 ACS_NamedExecuteAlways("FBD_CheckFloorIsLava_V", 0, 0, 0, 0) // also spawns smoke for 30 tics if succeeds
			ID50 N 30
			TNT1 A 0 A_JumpIf(user_floor_is_lava, "LandOnLava")	
			ID50 N -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop
		Death:
		XDeath:
		Death.Stomp:
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_SpawnItemEx("SmalllMeatDeath", 0,0,10, 0,0,0, 0, SXF_NOCHECKPOSITION)
			TNT1 A -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
	}
}


Actor MeltingShotgunGuy: FBD_DeadShotgunGuy1
{
	damagefactor "Desintegrate", 0.3
	damagefactor "Slime", 0.0
	States
	{
		Spawn:
			ID50 H 0 NODELAY ACS_NamedExecuteWithResult("MeltingImpSmoke")
			ID50 HIJKL 7 A_PlaySound("burn") 
			Goto Stay
	}
}

Actor DeadShotgunGuy_NoArm: FBD_DeadShotgunGuy1
{
	Health 300 
	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
			SPO5 E 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
			SPO5 E 30
			TNT1 A 0 A_JumpIf(user_floor_is_lava, "LandOnLava")	
			SPO5 E -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop				
	}
}


Actor DeadShotgunGuy_NoLeg: FBD_DeadShotgunGuy1 
{
	Health 300 
	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
			SPO3 F 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
			SPO3 F 30
			TNT1 A 0 A_JumpIf(user_floor_is_lava, "LandOnLava")	
			SPO3 F -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop		
		Death:
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_CustomMissile ("XDeathSargeLeg1", 5, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			SPOS A 0 A_CustomMissile ("MeatDeathSmall", 5, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_SpawnItemEx ("DeadShotgunGuy_NoLegBoth",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop
	}
}
		
Actor DeadShotgunGuy_NoLegBoth: FBD_DeadShotgunGuy1 
{
	Health 300 
	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
			SPO3 K 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
			SPO3 K 30
			TNT1 A 0 A_JumpIf(user_floor_is_lava, "LandOnLava")	
			SPO3 K -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop				
		Death:
			TNT1 A 0 A_NoBlocking
			SPOS A 0 A_CustomMissile ("MeatDeathSmall", 5, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("XDeathArm1", 5, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			
			// RipSergeant is a pure gore spawner
			TNT1 A 0 A_SpawnItemEx("RipSergeant",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			
			TNT1 A -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop	
	}
}		

Actor DeadShotgunGuy_NoBrain: FBD_DeadShotgunGuy1
{
	Health 300 
	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
			SPOS Z 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
			SPOS Z 30
			TNT1 A 0 A_JumpIf(user_floor_is_lava, "LandOnLava")	
			SPOS Z -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop			
		Death:
			TNT1 A 0 A_PlaySound("misc/xdeath4")
			TNT1 A 0 A_SpawnItem("ShotgunguyHeadExplode")
			TNT1 A 0 A_SpawnItemEx ("DeadShotgunguy_NoHead",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop
    }
}


Actor DeadShotgunGuy_NoHead: FBD_DeadShotgunGuy1
{
	Health 300 
	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
			SPDH E 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
			SPDH E 30
			TNT1 A 0 A_JumpIf(user_floor_is_lava, "LandOnLava")	
			SPDH E -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop		
		Death:
			TNT1 A 0 A_NoBlocking
			SPOS A 0 A_CustomMissile ("MeatDeathSmall", 5, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("XDeathArm1", 5, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_SpawnItemEx("DeadShotgunGuy_NoHeadNoArm",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop
	}
}

Actor DeadShotgunGuy_NoHeadNoArm: FBD_DeadShotgunGuy1
{
	Health 300 
	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
			SZD4 D 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
			SZD4 D 30
			TNT1 A 0 A_JumpIf(user_floor_is_lava, "LandOnLava")	
			SZD4 D -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop			
		Death:
			TNT1 A 0 A_NoBlocking
			SPOS A 0 A_CustomMissile ("MeatDeathSmall", 5, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("XDeathArm1", 5, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_SpawnItemEx("DeadShotgunguySZD3C",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop
	}
}

Actor DeadShotgunGuy_Half: FBD_DeadShotgunGuy1
{
	Health 300 
	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
			SP2X E 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
			SP2X E 30
			TNT1 A 0 A_JumpIf(user_floor_is_lava, "LandOnLava")	
			SP2X E -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop
			
		Death:
			TNT1 A 0 A_NoBlocking
			SPOS A 0 A_CustomMissile ("MeatDeathSmall", 5, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("XDeathArm1", 5, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_SpawnItemEx("DeadShotgunguySZD1H",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop
	}
}



ACTOR BeheadedSergeantZombie: DeadShotgunGuy_NoHead
{
	Mass 6
}




Actor DeadShotgunguy_Slumped: AbstractSlumpedBodyWithHeadbox //FBD_ZombiemanTorso

// slumped bodies are NOT raiseable

{
	+NOPAIN
	+NOBLOCKMONST
	Health 200
	DamageFactor "Head", 15.0 DamageFactor "HeadStun", 15.0 DamageFactor "HeadPlasma", 15.0
	Height 22
	Radius 6
	States
	{
		Spawn:
			TNT1 A 0 NODELAY ACS_NamedExecuteWithResult("FBD_RunMonster", 12) // dying guy headbox
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 6, 0, 22, 1)
		SitSlumped:
			TNT1 A 0
			TNT1 A 0 A_Recoil(6)
			BR93 A 6
			TNT1 A 0 A_JumpIf(momx < 0, "LayDown")
			TNT1 A 0 A_JumpIf(momy < 0, "LayDown")
			TNT1 A 0 A_JumpIf(momx > 0, "LayDown")
			TNT1 A 0 A_JumpIf(momy > 0, "LayDown")
			//TNT1 A 0 A_SpawnItemEx("HeadshotTarget20", 0, 0, 22)
			
			//***Che
			TNT1 A 0 ACS_NamedExecuteAlways("FBD_CheckFloorIsLava", 0, 0, 0, 0)
			BR93 A 16
			TNT1 A 0 A_JumpIfInventory("IsOverLava", 1, "LandOnLava")
			Loop 
		
		LayDown:
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			TNT1 A 0 A_SpawnItemEx("FBD_DeadShotgunGuy1",radius + 16,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0) // give the scripts and actors time to run and access us
			Stop
		XDeath:
		Death.Explosives:
		Death.ExplosiveImpact:
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			TNT1 A 0 A_SpawnItemEx("SargeXDeath",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			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.Head:
		Death.HeadStun:
		Death.HeadPlasma:
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			TNT1 A 0 A_SpawnItemEx("ShotgunguyHeadExplode", 0, 0, 22)
			TNT1 A 0 A_SpawnItemEx("DeadShotgunguy_Slumped_NoHead",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0) // give the scripts and actors time to run and access us
			Stop
			
		Death:
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			TNT1 AAA 0 A_CustomMissile ("Guts", 32, 0, random (150, 210), CMF_AIMDIRECTION, random (0, 40))
			TNT1 AAA 0 A_CustomMissile ("XDeath1", 32, 0, random (150, 210), CMF_AIMDIRECTION, random (0, 40))
			TNT1 AAA 0 A_CustomMissile ("Xdeath3", 16, 0, random (170, 190), CMF_AIMDIRECTION, random (0, 40))
			TNT1 AAAA 0 A_CustomMissile ("FBD_FlyingBlood", 32, 0, random (170, 190), CMF_AIMDIRECTION, random (0, 40))
			TNT1 AAAA 0 A_CustomMissile ("Brutal_FlyingBloodFaster", 32, 0, random (170, 190), CMF_AIMDIRECTION, random (0, 40))
			TNT1 AAAA 0 A_CustomMissile ("Brutal_FlyingBloodMuchFaster", 32, 0, random (170, 190), CMF_AIMDIRECTION, random (0, 40))
			TNT1 AA 0 A_CustomMissile ("SuperWallRedBlood", 32, 0, random (170, 190), CMF_AIMDIRECTION, random (0, 40))
			TNT1 AAA 0 A_CustomMissile ("BloodMistBig", 40, 0, random (0, 360), CMF_AIMDIRECTION, random (30, 90))
			TNT1 AA 0 A_CustomMissile ("XDeathArm1", 40, 0, random (0, 360), CMF_AIMDIRECTION, random (30, 90))
			TNT1 A 0 A_SpawnItemEx("ShotgunguyHeadExplode", 0, 0, 22)
			//TNT1 A 0 A_SpawnItem("DeadShotgunguyJustLegsAreLeft")
			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
		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", 2001), "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 ("ShotgunGuyRaisedByVile",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, 9, 0, 0) //"ShotgunGuyRaisedByVile"
			"----" A -1 ACS_NamedExecuteWithResult("FallbackRezMkII", 2001) // see _mob_list.xlsx
			Stop			
	}
}
		
		
Actor DeadShotgunguy_Slumped_NoHead: FBD_ZombiemanTorso
{
	+NOPAIN
	+NOBLOCKMONST
	Height 22
	States{
		//***Che // this is a descendant of FBD_CurbstompedMarine, which is neither a missile nor a monster
		Spawn:
		Sit:	
			BR93 B 70
			TNT1 A 0 ACS_NamedExecuteAlways("FBD_CheckFloorIsLava_V", 0, 0, 0, 0) // also spawns smoke for 30 tics if succeeds
			BR93 B 30
			TNT1 A 0 A_JumpIf(user_floor_is_lava, "LandOnLava")
			Loop 
		LandOnLava:
			TNT1 A 0
			TNT1 A 0 A_SpawnItem("CharredMeatsplosionIntoGoryAshes", 1)
			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  
		XDeath:
		Death.Explosives:
		Death.ExplosiveImpact:
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_SpawnItemEx("SargeXDeath",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0) // not a corpse, a gore spammer
			TNT1 A 0 A_ChangeFlag("CORPSE", 1)
			TNT1 A 0 A_ChangeFlag("ISMONSTER", 0)
			TNT1 A -1
			Stop	
		Death:
			TNT1 A 0 A_NoBlocking
			TNT1 AAA 0 A_CustomMissile ("Guts", 32, 0, random (150, 210), CMF_AIMDIRECTION, random (0, 40))
			TNT1 AAA 0 A_CustomMissile ("XDeath1", 32, 0, random (150, 210), CMF_AIMDIRECTION, random (0, 40))
			TNT1 AAA 0 A_CustomMissile ("Xdeath3", 16, 0, random (170, 190), CMF_AIMDIRECTION, random (0, 40))
			TNT1 AAAA 0 A_CustomMissile ("FBD_FlyingBlood", 32, 0, random (170, 190), CMF_AIMDIRECTION, random (0, 40))
			TNT1 AAAA 0 A_CustomMissile ("Brutal_FlyingBloodFaster", 32, 0, random (170, 190), CMF_AIMDIRECTION, random (0, 40))
			TNT1 AAAA 0 A_CustomMissile ("Brutal_FlyingBloodMuchFaster", 32, 0, random (170, 190), CMF_AIMDIRECTION, random (0, 40))
			TNT1 AA 0 A_CustomMissile ("SuperWallRedBlood", 32, 0, random (170, 190), CMF_AIMDIRECTION, random (0, 40))
			TNT1 AAA 0 A_CustomMissile ("BloodMistBig", 40, 0, random (0, 360), CMF_AIMDIRECTION, random (30, 90))
			TNT1 AA 0 A_CustomMissile ("XDeathArm1", 40, 0, random (0, 360), CMF_AIMDIRECTION, random (30, 90))
			//TNT1 A 0 A_SpawnItem("DeadShotgunguyJustLegsAreLeft")
			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
		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", 2001), "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 ("ShotgunGuyRaisedByVile",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, 9, 0, 0) //"ShotgunGuyRaisedByVile"
			"----" A -1 ACS_NamedExecuteWithResult("FallbackRezMkII", 2001) // see _mob_list.xlsx
			Stop			
	}
}
		
		
		
Actor DeadSergeantSXSXO: FBD_DeadShotgunGuy1
{
	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
			SXSX O 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
			SXSX O 30
			TNT1 A 0 A_JumpIf(user_floor_is_lava, "LandOnLava")	
			SXSX O -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop			
		
		Death:
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_SpawnItem("MeatDeathSmall")
			TNT1 A 0 A_SpawnItem("RipGuts")
			TNT1 A 0 A_CustomMissile ("XDeathSargeLeg2", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("XDeathaRM1", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			
			TNT1 A -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop
	}
}		


	
Actor DeadSergeantSXS2O: FBD_DeadShotgunGuy1
{
	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
			SXS2 O 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
			SXS2 O 30
			TNT1 A 0 A_JumpIf(user_floor_is_lava, "LandOnLava")	
			SXS2 O -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop	
			
		Death:
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_SpawnItem("MeatDeathSmall")
			TNT1 A 0 A_SpawnItem("RipGuts")
			TNT1 A 0 A_CustomMissile ("XDeathSargeLeg2", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("XDeathaRM1", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("ShotgunguyHeadExplode", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			
			TNT1 A -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop
	}
}	




Actor DeadShotgunguySPO4J: FBD_DeadShotgunGuy1
{
	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
			SPO4 J 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
			SPO4 J 30
			TNT1 A 0 A_JumpIf(user_floor_is_lava, "LandOnLava")	
			SPO4 J -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop			
			
		Death:
			TNT1 A 0
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_SpawnItem("MeatDeathSmall")
			TNT1 A 0 A_SpawnItem("RipSergeant")
			TNT1 A 0 A_SpawnItemEx("DeadShotgunguy_Half",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop
	}
}	



Actor DeadShotgunguySPO4T: DeadShotgunguySPO4J
{
	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
			SPO4 T 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
			SPO4 T 30
			TNT1 A 0 A_JumpIf(user_floor_is_lava, "LandOnLava")	
			SPO4 T -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop			
	}
}	


Actor DeadShotgunguySPOSZ: DeadShotgunGuy_NoBrain
{
	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
			SPOS Z 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
			SPOS Z 30
			TNT1 A 0 A_JumpIf(user_floor_is_lava, "LandOnLava")	
			SPOS Z -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop			
			
	}
}	


Actor FBD_DeadShotgunGuy13DGN: DeadShotgunGuy_NoBrain
{
	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
			13DG N 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
			13DG N 30
			TNT1 A 0 A_JumpIf(user_floor_is_lava, "LandOnLava")	
			13DG N -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop				
	}
}	



Actor DeadShotgunguySPDHE: DeadShotgunGuy_NoHead
{
	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
			SPDH E 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
			SPDH E 30
			TNT1 A 0 A_JumpIf(user_floor_is_lava, "LandOnLava")	
			SPDH E -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop			
	}
}	




Actor DeadShotgunguySP2XE: DeadShotgunGuy_Half
{
	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
			SP2X E 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
			SP2X E 30
			TNT1 A 0 A_JumpIf(user_floor_is_lava, "LandOnLava")	
			SP2X E -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop			
	}
}	


Actor DeadShotgunguyZXZ7E: FBD_DeadShotgunGuy1
{
	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
			ZXZ7 E 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
			ZXZ7 E 30
			TNT1 A 0 A_JumpIf(user_floor_is_lava, "LandOnLava")	
			ZXZ7 E -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop			
		Death:
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_SpawnItem("MeatDeathSmall")
			TNT1 A 0 A_SpawnItem("DeadShotgunguySZD3C")
			TNT1 AA 0 A_CustomMissile ("XDeathArm1", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_SpawnItem("ShotgunguyHeadExplode")
			
			TNT1 A -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop
	}
}	


Actor DeadShotgunguyZXZ6E: FBD_DeadShotgunGuy1
{
	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
			ZXZ6 E 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
			ZXZ6 E 30
			TNT1 A 0 A_JumpIf(user_floor_is_lava, "LandOnLava")	
			ZXZ6 E -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop			
		Death:
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_SpawnItem("MeatDeathSmall")
			TNT1 A 0 A_SpawnItem("DeadShotgunguySZD3F")
			TNT1 A 0 A_CustomMissile ("XDeathArm1", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_SpawnItem("ShotgunguyHeadExplode")
			TNT1 A -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop
	}
}



Actor DeadShotgunguySZD3C: FBD_DeadShotgunGuy1
{
	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
			SZD3 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
			SZD3 C 30
			TNT1 A 0 A_JumpIf(user_floor_is_lava, "LandOnLava")	
			SZD3 C -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop		
		Death:
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_SpawnItem("MeatDeathSmall")
			TNT1 A 0 A_SpawnItem("RipGuts")
			TNT1 AA 0 A_CustomMissile ("XDeathSargeLeg2", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0) 
			Stop
	}
}	


Actor DeadShotgunguySZD3F: DeadShotgunguySZD3C
{
	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
			SZD3 F 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
			SZD3 F 30
			TNT1 A 0 A_JumpIf(user_floor_is_lava, "LandOnLava")	
			SZD3 F -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop			
	}
}	




Actor DeadShotgunguySZD1H: FBD_DeadShotgunGuy1
{
	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
			SZD1 H 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
			SZD1 H 30
			TNT1 A 0 A_JumpIf(user_floor_is_lava, "LandOnLava")	
			SZD1 H -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop			
		Death:
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_SpawnItem("MeatDeathSmall")
			TNT1 A 0 A_CustomMissile ("XDeathSargeLeg2", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("GibSargeBoot", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop
	}
}

Actor DeadShotgunguySZD1HNonRaiseable: DeadShotgunguySZD1H {
	// used by nazi as a nazi corpse -- the invisible nazi himself is raiseable instead
	-CORPSE
	States {
		Raise:
			Stop
		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
			SZD1 H 30
			TNT1 A 0 A_JumpIf(user_floor_is_lava, "LandOnLava")	
			SZD1 H -1
			Stop			
		Death:
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_SpawnItem("MeatDeathSmall")
			TNT1 A 0 A_CustomMissile ("XDeathSargeLeg2", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("GibSargeBoot", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 30 // for the blood actors
			Stop			
	}
}		



Actor DeadShotgunguySZD4D: FBD_DeadShotgunGuy1
{
	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
			SZD4 D 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
			SZD4 D 30
			TNT1 A 0 A_JumpIf(user_floor_is_lava, "LandOnLava")	
			SZD4 D -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop			
		Death:
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_SpawnItem("MeatDeathSmall")
			TNT1 A 0 A_SpawnItem("RipGuts")
			TNT1 AA 0 A_CustomMissile ("XDeathSargeLeg2", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 AA 0 A_CustomMissile ("XDeathSargeLeg2", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A 0 A_CustomMissile ("XDeathaRM1", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (0, 160))
			TNT1 A -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop
	}
}		




Actor FatalizedSGGuy4: deadshotgunguy_nobrain
{
	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
			SGF8 N 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
			SGF8 N 30
			TNT1 A 0 A_JumpIf(user_floor_is_lava, "LandOnLava")	
			SGF8 N -1 ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop			
	}
}











ACTOR FBD_SMGGuy: FBD_ShotgunGuy 17845
{
	DropItem "SMGSpawner"
	Tag "$SMGGUY" // "SMG Zombie";
	Obituary "%o got punctured by a SMG Zombie."
	States
	{
		Pain.Ice:
			"----" A 20 A_Pain
			Goto See		
		WaitTargetsFatalityOut:
			PSS3 A 1 A_Jump(256, "FallBackContinue", "Panic", "Pain.Avoid")
			Wait
		Pain.HurrDurrMeHazGrenaed:
			TNT1 A 0
			TNT1 A 0 HealThing(1)
			TNT1 A 0 A_FaceTarget
			Goto FallBack
		Pain.FireInTheHole:
		Pain.Avoid: 
			TNT1 A 0
			TNT1 A 0 HealThing(1)
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			TNT1 A 0 A_Jump(256, "AvoidLeft", "AvoidRight")
			Goto AvoidLeft
		AvoidLeft:
			PSS3 A 1 A_FaceTarget
			TNT1 A 0 ThrustThing(angle*256/360+192, 15, 0, 0)
			ZRO4 ABCDEFGH 2 A_FaceTarget
			// we can afford this because realistically only one zombie at a time would be rolling
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 6, 0, 38, 1)
			
			Goto Missile
		AvoidRight:
			PSS3 A 1 A_FaceTarget
			TNT1 A 0 ThrustThing(angle*256/360+64, 15, 0, 0)
			ZRO3 ABCDEFGH 2 A_FaceTarget
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 6, 0, 38, 1)
			Goto Missile
/*		
		ReplaceVanilla:
			TNT1 A 0 A_ChangeFlag("THRUACTORS", 1)
			TNT1 A 0 A_ChangeFlag("COUNTKILL", 0)
			TNT1 A 0 A_SpawnItemEx ("VanillaShotgunguy",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION | SXF_TRANSFERAMBUSHFLAG ,0)
			Stop
*/			
		Spawn:
			PSS3 A 1 NODELAY ACS_NamedExecuteWithResult("FBD_RunMonster", 5) // 5 = default headbox
			"----" A 0 A_GiveInventory("TargetIsAFormerHuman", 1) //used by AOE DOT inflictors to reward players with soul ammo -- otherwise untraceable
			//TNT1 A 0 ACS_NamedExecuteAlways("BDCHeckClassicMonsters", 0, 0, 0, 0)//Check if Vanilla Mode is activated
			TNT1 A 0
			TNT1 A 0 A_GiveInventory("SKShotgunGuy", 1)
			TNT1 A 0 A_GiveInventory("TypeSergeant", 1)
			TNT1 A 0 A_GiveInventory("SergeantAmmo", random(0,5))
			PSS3 B 7 // slaughtermap init takes 5 tics
			Goto Stand
		Stand:
			TNT1 A 0
			TNT1 A 0 A_JumpIf(user_serverside_sfchk >= 4, "StandSfestExtreme") // extreme slaughtermap optimization
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 8, 2, 38)
			PSS3 A 11 A_Look
			TNT1 A 0 A_CheckSight("Stand2")
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 5, 2, 39)
			PSS3 B 11 A_Look
			Loop
			
		Stand2:
			PSS3 AA 11 A_Look
			Goto Stand
		StandSfestExtreme: // no headbox created until sees the player!
			PSS3 AB 15 A_Look
			Loop
	  
		FallBack:
			//***Che: taraget, not "any player" //TNT1 A 0 A_CheckSight("Advance")
			TNT1 A 0 A_JumpIfTargetinLOS(1)
			Goto Advance
			
			TNT1 A 0 A_JumpIfInventory("Enraged", 1, 4)
			TNT1 A 0 A_JumpIfInTargetInventory("TargetIsACyberdemon", 1, "Panic")
			TNT1 A 0 A_JumpIfInTargetInventory("TargetIsAGreatTerribleBoss", 1, "Panic")
			TNT1 A 0 A_JumpIfInTargetInventory("GoFatality", 1, "WaitTargetsFatalityOut")

		FallBackContinue:
			TNT1 A 0 A_ChangeFLag("NODROPOFF", 1)

			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 6, 0, 38)
			PSS3 D 2 A_FaceTarget
			PSS3 D 2 A_Recoil(2)
			TNT1 A 0 A_jump(64, "Missile")

			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 6, 0, 39)
			PSS3 C 2 A_FaceTarget
			PSS3 C 2 A_Recoil(2)

			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 5, 2, 39)
			PSS3 B 2 A_FaceTarget
			PSS3 B 2 A_Recoil(2)

			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 8, 2, 38)
			PSS3 A 2 A_FaceTarget
			PSS3 A 2 A_Recoil(2)

			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 6, 0, 38)
			PSS3 D 2 A_FaceTarget
			TNT1 A 0 A_ChangeFLag("NODROPOFF", 0)
			GOto Missile
			
		
		Idle:		
			TNT1 A 0
			TNT1 A 0 A_ClearTarget
			TNT1 A 0 A_SetUserVar("user_sleeping", 1)
			TNT1 A 0 A_TakeInventory("SergeantAmmo", 6)
			TNT1 A 0 A_GiveInventory("SergeantAmmo", random(0,5))			
		SearchForPlayer:
			TNT1 A 0 A_TakeInventory("EnemyMemory", 30)
			
			TNT1 A 0 A_JumpIfInventory("AbjectTerror", 1, "PanicContinue")
			
			TNT1 A 0 A_GiveInventory("SKShotgunGUy", 1)
			
			//***Che: seems a bit unfinished, uses shotgunner frames for this looking around animation!
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 2, 0, 42)
			SHID A 10 A_Look
			
			SHID C 10 A_Look
			
			SHID A 10 A_Look
			
			SHID D 10 A_Look
			
			SHID A 10 A_Look
			
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 8, 2, 38)
			PSS3 A 4 A_Look
			
			TNT1 A 0 A_Wander
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 5, 2, 39)
			PSS3 B 4 A_Look
			
			TNT1 A 0 A_Wander
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 6, 0, 39)
			PSS3 C 4 A_Look
			
			TNT1 A 0 A_Wander
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 6, 0, 38)
			PSS3 D 4 A_Look
			
			TNT1 A 0 A_Wander
			
			
			TNT1 A 0 A_Jump(128, "SearchForPlayer")
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 8, 2, 38)
			PSS3 A 4 A_Look
			
			TNT1 A 0 A_Wander
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 5, 2, 39)
			PSS3 B 4 A_Look
			
			TNT1 A 0 A_Wander
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 6, 0, 39)
			PSS3 C 4 A_Look
			
			TNT1 A 0 A_Wander
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 6, 0, 38)
			PSS3 D 4 A_Look
			
			TNT1 A 0 A_Wander
			
			Loop
			
		
		See:
			TNT1 A 0 A_ChangeFLag("NODROPOFF", 0)
			TNT1 A 0 A_TakeInventory("SKZombieman", 1)
			TNT1 A 0 A_TakeInventory("EnemyMemory", 15)
			TNT1 A 0 A_CheckSight("SeeNeverSeen")
			Goto SeeContinue
		
		SeeContinue:
		
		
			// 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
			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_ChangeFLag("NODROPOFF", 0)
			TNT1 A 0 A_JumpIfInventory("Enraged", 1, 2) // no retreat!
			TNT1 A 0 A_JumpIfCloser(200, "FallBack")
			//Advance:
			TNT1 A 0 A_ChangeFLag("NODROPOFF", 0)
			TNT1 A 0 A_JumpIfInventory("EnemyMemory", 15, "Idle")
			TNT1 A 0 A_GiveInventory("EnemyMemory", 1)
			//TNT1 A 0 A_SpawnItemEx("FootSep", 0, 0, 20, 0, 0)
			TNT1 A 0 A_TakeInventory("SKShotgunGuy", 1)
			
			TNT1 A 0 A_JumpIfInventory("AbjectTerror", 1, "PanicContinue")

			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 8, 2, 38)
			PSS3 AAA 2 A_Chase

			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 5, 2, 39)
			PSS3 BBB 2 A_Chase

			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 6, 0, 39)
			PSS3 CCC 2 A_Chase

			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 6, 0, 38)
			PSS3 DDD 2 A_Chase

			TNT1 A 0 A_JumpIf(CallAcs("FBD_TargetIsInvisible"), "Idle")
			Loop
			
			
		Panic:
			TNT1 A 0
			TNT1 A 0 A_GiveInventory("AbjectTerror", 3)
			TNT1 A 0 A_CheckFlag("FRIGHTENED", "PanicContinue")
			TNT1 A 0 A_ChangeFlag("FRIGHTENED", 1)
			TNT1 A 0 A_PlaySound("zombieman/panic", CHAN_VOICE)
			TNT1 A 0 A_FaceTarget
			TNT1 A 0 A_SetAngle(angle + 180)
		PanicContinue:
			
			TNT1 A 0 A_TakeInventory("AbjectTerror", 1) // in the beginning, 
			  //in case it is interrupted by pain -- or falling into the Idle state because of having no target

			
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 8, 2, 38)
			TNT1 AA 0 A_Chase
			PSS3 AAA 1 A_Wander
			
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 5, 2, 39)
			TNT1 AA 0 A_Chase
			PSS3 BBB 1 A_Wander
		
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 6, 0, 39)
			TNT1 AA 0 A_Chase
			PSS3 CCC 1 A_Wander
			
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 6, 0, 38)
			TNT1 AA 0 A_Chase
			PSS3 DDD 1 A_Wander
						
			TNT1 A 0 A_JumpIfInventory("AbjectTerror", 1, "PanicContinue")
		PanicEnd:
			TNT1 A 0 A_PlaySound("grunt/active", CHAN_VOICE)
			TNT1 A 0 A_ChangeFlag("FRIGHTENED", 0)
			Goto See
			
			
		SeeNeverSeen:
			TNT1 A 0 A_JumpIfInventory("Enraged", 1, 2) // no retreat!
			TNT1 A 0 A_JumpIfCloser(200, "FallBack")
		Advance:
			TNT1 A 0 A_ChangeFLag("NODROPOFF", 0)
			//TNT1 A 0 A_SpawnItemEx("FootSep", 0, 0, 10, 0, 0)

			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 8, 2, 38)
			PSS3 AAA 2 A_Chase

			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 5, 2, 39)
			PSS3 BBB 2 A_Chase

			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 6, 0, 39)
			PSS3 CCC 2 A_Chase

			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 6, 0, 38)
			PSS3 DDD 2 A_Chase
			Loop		
			
		Missile:
			TNT1 A 0
			
			// slaughtermap manage - warming the headbox up
			TNT1 A 0 A_JumpIf(!user_sleeping, 4) // forgo the expensive sight check if already awake
			TNT1 A 0 A_JumpIfInTargetInventory("IsPlayer", 1, 2) // bypass the sight check 
			TNT1 A 0 A_CheckSight(2) // out of sight of any player, AND attacking another monster, keep slumbering
			TNT1 A 0 A_SetUserVar("user_sleeping", 0)
		
			TNT1 A 0 A_Stop
			TNT1 A 0 A_JumpIfHealthLower(1, "Death")
			
			
			TNT1 A 0 A_TakeInventory("EnemyMemory", 10)
			
			TNT1 A 0 A_ChangeFLag("NODROPOFF", 0)
			TNT1 A 0 A_TakeInventory("SKShotgunGuy", 1)
			
			//TNT1 A 0 A_TakeInventory("CantFire", 1)
			//TNT1 A 0 A_CustomMissile("MonsterTargetCheck", 34, 0, 0, 0) 
			//TNT1 A 0 A_CustomMissile("MonsterTargetCheckFaster", 34, 0, 0, 0) 
			
			
			TNT1 A 0 A_JumpIfInTargetInventory("IsLTGPlayer", 1, "LTGCheck")
		MissileContinueAfterLTGCheck:			
			
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 6, 0, 38)
			PSS3 D 3 A_FaceTarget
			//TNT1 A 0 A_JumpIfInventory("CantFire",1, "Advance")

			
			TNT1 A 0 A_GiveInventory("SergeantAmmo", 1)
			
			
			//***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
			
			PSS3 D 3 //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
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -2, 2, 39)
			PSS3 E 10 //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
			
			PSS3 E 4 //A_FaceTarget
			
			
			TNT1 A 0 A_CustomMissile("ZombieManTracer", 36, 0, random(-7, 7) + angle, CMF_ABSOLUTEANGLE | CMF_OFFSETPITCH | CMF_SAVEPITCH, random(-4, 4))
			TNT1 A 0 A_SpawnItem ("PistolCaseSpawn", 0, 30,0)
			TNT1 A 0 A_PlaySound("FARSHT", CHAN_6)
			TNT1 A 0 A_PlaySound("SMGFIRE", CHAN_WEAPON)
			PSS3 F 1 BRIGHT
			
			//***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
			
			PSS3 E 2 //A_FaceTarget
			
			TNT1 A 0 A_CustomMissile("ZombieManTracer", 36, 0, random(-7, 7) + angle, CMF_ABSOLUTEANGLE | CMF_OFFSETPITCH | CMF_SAVEPITCH, random(-4, 4))
			TNT1 A 0 A_SpawnItem ("PistolCaseSpawn", 0, 30,0)
			TNT1 A 0 A_PlaySound("FARSHT", CHAN_6)
			TNT1 A 0 A_PlaySound("SMGFIRE", CHAN_WEAPON)
			PSS3 F 1 BRIGHT
			
			//***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
			
			PSS3 E 2 //A_FaceTarget
			
			TNT1 A 0 A_CustomMissile("ZombieManTracer", 36, 0, random(-7, 7) + angle, CMF_ABSOLUTEANGLE | CMF_OFFSETPITCH | CMF_SAVEPITCH, random(-4, 4))
			TNT1 A 0 A_SpawnItem ("PistolCaseSpawn", 0, 30,0)
			TNT1 A 0 A_PlaySound("FARSHT", CHAN_6)
			TNT1 A 0 A_PlaySound("SMGFIRE", CHAN_WEAPON)
			PSS3 F 1 BRIGHT
			
			//***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
			
			PSS3 E 2 //A_FaceTarget
			
			TNT1 A 0 A_CustomMissile("ZombieManTracer", 36, 0, random(-7, 7) + angle, CMF_ABSOLUTEANGLE | CMF_OFFSETPITCH | CMF_SAVEPITCH, random(-4, 4))
			TNT1 A 0 A_SpawnItem ("PistolCaseSpawn", 0, 30,0)
			TNT1 A 0 A_PlaySound("FARSHT", CHAN_6)
			TNT1 A 0 A_PlaySound("SMGFIRE", CHAN_WEAPON)
			PSS3 F 1 BRIGHT
			
			//***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
			
			PSS3 E 2 //A_FaceTarget
			
			TNT1 A 0 A_CustomMissile("ZombieManTracer", 36, 0, random(-7, 7) + angle, CMF_ABSOLUTEANGLE | CMF_OFFSETPITCH | CMF_SAVEPITCH, random(-4, 4))
			TNT1 A 0 A_SpawnItem ("PistolCaseSpawn", 0, 30,0)
			TNT1 A 0 A_PlaySound("FARSHT", CHAN_6)
			TNT1 A 0 A_PlaySound("SMGFIRE", CHAN_WEAPON)
			PSS3 F 1 BRIGHT
			
			//***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
			
			PSS3 E 2 //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
			
			PSS3 E 10 //A_FaceTarget
			TNT1 A 0 A_JumpIf(CallAcs("FBD_TargetIsInvisible"), "SearchForPlayer")
			Goto SeeContinue

		//***Che: this animation is a copy of shotgunner's shotgun reloading animation 
		//  it is NOT used!
/*		
		Reload:
			TNT1 A 0

			
			SPSR A 15 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 2, 4, 44)

			ID12 EFG 5
			TNT1 A 0 A_PlaySound("insertshell")
			TNT1 A 0 A_TakeInventory("SergeantAmmo", 1)
			
			ID12 EFG 5
			TNT1 A 0 A_PlaySound("insertshell")
			TNT1 A 0 A_TakeInventory("SergeantAmmo", 1)

			ID12 EFG 5
			TNT1 A 0 A_PlaySound("insertshell")
			TNT1 A 0 A_TakeInventory("SergeantAmmo", 1)

			ID12 EFG 5
			TNT1 A 0 A_PlaySound("insertshell")
			TNT1 A 0 A_TakeInventory("SergeantAmmo", 1)

			ID12 EFG 5
			TNT1 A 0 A_PlaySound("insertshell")
			TNT1 A 0 A_TakeInventory("SergeantAmmo", 1)

			ID12 EFG 5
			TNT1 A 0 A_PlaySound("insertshell")
			TNT1 A 0 A_TakeInventory("SergeantAmmo", 1)

			SPSR A 10
			TNT1 A 0 A_PlaySound("weapons/sgpump")

			SPSR B 10
			
			SPSR A 10
			
			Goto SeeContinue
*/			

		Pain.Cut:
		Pain.Saw:
			TNT1 A 0
			TNT1 A 0 A_Stop
		Pain:
			TNT1 A 0 A_JumpIfInventory ("IsDown", 1, "PainWhileDown")//9)
			TNT1 A 0 A_TakeInventory("SKShotgunGuy", 1)
			
			PSS3 G 2
			
			PSS3 G 2 A_Pain
			TNT1 A 0 A_Jump(196, "Missile")
			Goto SeeContinue
			
		Pain.Argent:
			TNT1 A 0
			
			//TNT1 A 0 A_ClearTarget
			TNT1 A 0 A_GiveInventory("Enraged", 1)
			TNT1 A 0 A_Pain
			TNT1 A 0 HealThing(15,60)
			TNT1 A 0 ACS_NamedExecuteWithResult("DisplayArgentDischarge", 10, 40, 0)	
			TNT1 A 0 A_JumpIfInventory ("IsDown", 1, "PainWhileDown")
			
			TNT1 A 0 A_TakeInventory("SKShotgunGuy", 1)
			
			PSS3 GGGG 8 A_Pain
			TNT1 A 0 A_Jump(64, "Missile")
			Goto SeeContinue			
			
		PainWhileDown:	
			TNT1 A 0
			TNT1 A 0 A_Pain
			ID11 H 6
			Goto GetUp
			
		Pain.Melee:
			TNT1 A 0
			TNT1 A 0 A_JumpIfInventory ("SKShotgunGuy", 1, "GotoStealthKill")
			TNT1 A 0 A_JumpIfInventory ("IsDown", 1, "PainMeleeWhileDown") //6)
			
			PSS3 G 4 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -12, -4, 40)
			
			PSS3 G 4 A_Pain
			Goto SeeContinue
		PainMeleeWhileDown:	
			TNT1 A 0
			TNT1 A 0 A_Pain
			ID11 H 8 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -15, 0, 3)
			ID11 S 35 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -15, 0, 1)
			TNT1 A 0 A_TakeInventory("IsDown", 1)
			ID11 T 10 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 0, -3, 16)
			Goto SeeContinue


		Pain.ExplosiveImpact:
		Pain.ExtremePunches:
		Pain.Explosive:
		Pain.Bfg10k: //***Che changed damage type from extreme to custom
			TNT1 A 0 A_ChangeFLag("NODROPOFF", 0)
			TNT1 A 0 A_ChangeFlag("NOBLOCKMONST", 1)
			TNT1 A 0
			TNT1 A 0 A_Pain
			TNT1 A 0 A_JumpIfInventory ("IsDown", 1, "Pain")
			TNT1 A 0 A_TakeInventory("SKShotgunGuy", 1)
			TNT1 A 0 A_GiveInventory("IsDown", 1)
			TNT1 A 0 ThrustThingZ(0,40,0,1)
			//SPO4 UUVWXY 4
			SPO4 U 4 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 0, -5, 40)
			SPO4 V 4 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -12, -8, 27)
			SPO4 W 4 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -15, -8, 18)
			SPO4 X 4 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -15, 0, 4)
			SPO4 Y 4 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -15, 0, 1)			
			Goto FallingAfterImpact


		


		Pain.LowKick:
			TNT1 A 0
			TNT1 A 0 A_JumpIfInventory("IsDown", 1, "Death.LowKick")
			Goto Pain
			
		Death.LowKick:
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")		
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("GoFatality", 1)
			TNT1 A 0 A_GiveToTarget("IsCurbstompingSergeant", 1)
			Stop
			
			
			 
		Pain.Slide:
			TNT1 A 0
			TNT1 A 0 A_ChangeFlag("NOBLOCKMONST", 1)
			TNT1 A 0 A_ChangeFLag("NODROPOFF", 0)
			TNT1 A 0 A_ChangeFlag("GHOST", 1)
			TNT1 A 0 A_ChangeFlag("THRUGHOST", 1)	
			TNT1 A 0 A_JumpIfInventory ("IsDown", 1, "Pain")
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 0, -5, 40)
			ID11 G 1 A_Pain
			TNT1 A 0 A_GiveInventory("IsDown", 1)
			TNT1 A 0 A_TakeInventory("SKShotgunGuy", 1)
			TNT1 A 0 ThrustThingZ(0,30,0,1)
			TNT1 A 0 A_ChangeFlag("NOPAIN", 1)
			//ID11 E 1 A_Chase ("","")
			SPO4 U 1 A_facetarget
			SPO4 U 3 
			TNT1 A 0 A_Recoil(-5)
			//SPO4 UVWXY 3
			SPO4 U 3
			SPO4 V 3 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -12, -8, 27)
			SPO4 W 3 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -15, -8, 18)
			SPO4 X 3 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -15, 0, 4)
			SPO4 Y 3 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -15, 0, 1)			
			TNT1 A 0 A_ChangeFlag("NOPAIN", 0)
			TNT1 A 0 A_ChangeFlag("GHOST", 0)
			TNT1 A 0 A_ChangeFlag("THRUGHOST", 0)	
			Goto FallingAfterImpact
		FallingAfterImpact:
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -15, 0, 3)
			ID11 H 1 A_GiveInventory ("FallingHeight", 1)
			ID11 H 1 A_CheckFloor ("GetUp")
			NULL A 0 A_JumpIf (momz == 0, "GetUp")
			Loop			
		Pain.Kick:
		Pain.HeavyImpact:
		
			TNT1 A 0
			TNT1 A 0 A_ChangeFlag("NOBLOCKMONST", 1)
			TNT1 A 0 A_ChangeFLag("NODROPOFF", 0)
			TNT1 A 0 A_JumpIfInventory ("IsDown", 1, "Pain")
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 0, -5, 40)
			ID11 G 1 A_Pain
			TNT1 A 0 A_GiveInventory("IsDown", 1)
			TNT1 A 0 A_TakeInventory("SKShotgunGuy", 1)
			TNT1 A 0 ThrustThingZ(0,30,0,1)
			TNT1 A 0 A_ChangeFlag("NOPAIN", 1)
			//ID11 E 1 A_Chase ("","")
			SPO4 U 1 A_facetarget
			SPO4 U 3 ThrustThing(angle*256/360+128, 10, 0, 0)
			//SPO4 UVWXY 3
			SPO4 V 3 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -12, -8, 27)
			SPO4 W 3 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -15, -8, 18)
			SPO4 X 3 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -15, 0, 4)
			SPO4 Y 3 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -15, 0, 1)
			TNT1 A 0 A_ChangeFlag("NOPAIN", 0)
			Goto FallingAfterImpact
/* wtf repeated twice			
		FallingAfterImpact:
			ID11 H 1 A_GiveInventory ("FallingHeight", 1)
			ID11 H 1 A_CheckFloor ("GetUp")
			NULL A 0 A_JumpIf (momz == 0, "GetUp")
			Loop
*/			
			
		GetUp:
			TNT1 A 0
			TNT1 A 0 A_GiveInventory("IsDown", 1)
			MARN A 0 A_SpawnItem("bdbodythud")
			TNT1 A 0 A_ChangeFlag("FORCEXYBILLBOARD", 1)
			TNT1 A 0 A_ChangeFlag("NOPAIN", 0)
			TNT1 A 0 A_ChangeFLag("GHOST", 1)
			TNT1 A 0 A_JumpIfInventory ("FallingHeight", 5, "FallingDie")
			ID11 S 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -15, 0, 1)
			ID11 SSSSSSSSS 5 A_JumpIf(momz < 0, "FallingAfterImpact")
			TNT1 A 0 A_TakeInventory("FallingHeight", 100)
			
			ID11 T 10 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 0, -3, 16)
			TNT1 A 0 A_ChangeFlag("FORCEXYBILLBOARD", 0)
			TNT1 A 0 A_TakeInventory("IsDown", 1)
			TNT1 A 0 A_ChangeFlag("GHOST", 0)
			Goto SeeContinue
			 
		FallingDie:
			TNT1 A 0
			TNT1 A 0 A_Stop
			TNT1 A 0 A_CustomMissile("BodyCrash1", 10)
			Goto Getup+8
			
		Death.Fall:
			TNT1 A 0
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			TNT1 A 0 A_Scream
			TNT1 A 0 A_NoBLocking
			TNT1 A 0 A_Stop
			TNT1 AAAA 0 A_CustomMissile ("XDeath1", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (50, 130))
			ID11 EF 2
			TNT1 A 0 A_SpawnItem ("GrowingBloodPool")
			TNT1 A 0 A_SpawnItemEx("DeadShotgunguy",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			//ID11 F 2
			MARN AAA 0 A_SpawnItem("bdbodythud")
			TNT1 A 3
			Stop
		
		
		Pain.KillMe:
			TNT1 A 0
			TNT1 A 0 HealThing(1)
			Goto Missile
			
		LTGCheckExtreme: // extreme outfits, 25% chance to treat the player as naked on each attack.
			TNT1 A 0 A_JumpIfCloser(400, 1)
			Goto MissileContinueAfterLTGCheck
			TNT1 A 0 A_JumpIfInTargetInventory("LTGExtreme", 1, 1)
			Goto MissileContinueAfterLTGCheck
			TNT1 A 0 A_Jump(64, "LTGCheckB")
			Goto MissileContinueAfterLTGCheck
		LTGCheck:
			TNT1 A 0 A_JumpIfInTargetInventory("IsDressed", 1, "LTGCheckExtreme")
		LTGCheckB:
			TNT1 A 0 A_JumpIfInventory("AlreadyPerformedLTGCatCall", 1, "LTGCheck2")
			
			TNT1 A 0 A_JumpIfCloser(600, 1)
			Goto MissileContinueAfterLTGCheck
			
			TNT1 A 0 A_GiveInventory("AlreadyPerformedLTGCatCall", 1)
			TNT1 A 0 A_PlaySound("grunt/catcall", CHAN_VOICE)
			
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 8, 2, 38)
			PSS3 ABABABAB  15 A_FaceTarget
			Goto See

		LTGCheck2:
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 8, 2, 38)
			TNT1 A 0 A_PlaySound("grunt/catcall", CHAN_VOICE)
			PSS3 ABABABAB  15 A_FaceTarget
			TNT1 A 0 A_JumpIfTargetInLOS("MissileContinueAfterLTGCheck")
			Goto See			
	}
}