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






// NOTE: pain elemental has no raiseable corpses. 
// The frozen corpse spawns PEExplodingHarmlessly, which is juat a regular PE rigged to explode on spawn.
// Any respawning on nightmare is done by the game engine on the PE actor itself,
//   all his deaths end with -1 states -- exceptthe fatality. Fatalized monsters do not respawn. 

// P.S. his respawning doesnt work and I don't give a flying pigeon dropping to care find why.


ACTOR PEPotpourriChecker: AbstractPotpourriChecker
{
	// The pain elemental himself is *never* swapped to anything, 
	// only serves a low-probability swap for the cacodemon.
	Radius 31
	Height 56
}

ACTOR FBD_PainElemental 17622
{
	//$category "FBD Monsters"
	
	//***Che radius, height and maxdropoffheight (n/a for flying ones) MUST be kept consistent with FBD_TrySpawn in FBD_CORE.acs!
	
	//***Che: cross-mod hardening: see ACTOR PainElemental1: FBD_PainElemental  Replaces PainElemental {} in Doom_Replacements.txt
	
	//***Che: I tried making him raiseable if superarchviles are around on map start.
	// But it never worked... Let it be that way.
	// I have better things to do than debug this.
	
	Health 400
	Radius 31
	Height 56
	Mass 400
    Scale 1.0
	Speed 9
	PainChance 128
	Monster
	+FLOAT 
	+NOGRAVITY
	+FORCEXYBILLBOARD
	SeeSound "pain/sight"
	//damagefactor "Avoid", 0.0
	damagefactor "GibRemoving", 0.0 damagefactor "HumanBBQ", 0.0
	PainSound "pain/pain"
	DeathSound "pain/death"
	ActiveSound "pain/active"
    BloodType "FBD_Blood", "FBD_SawBlood", "FBD_SawBlood" damagefactor "HangingHook", 0
	DropItem "DemonStrengthRune" 5
	damagefactor "TeleportRemover", 0.0
	DamageFactor "CauseSplash", 0.0 DamageFactor "CauseObjectsToSplashSlime", 0.0 DamageFactor "CauseObjectsToSplashNukage", 0.0
	DamageFactor "CauseObjectsToSplashBlood", 0.0 DamageFactor "CauseObjectsToSplashLava", 0.0
	PainChance "Kick", 255
	damagefactor "Avoid", 0.0
	damagefactor "Blood", 0.0 damagefactor "BlueBlood", 0.0 damagefactor "GreenBlood", 0.0
    
	//***Che: the game engine *fucking ignores* damagetype for monsters!
	// The only way to inflict the damage type you want is using custom projectiles.
	//damagetype Flames
	
	DeathHeight 4
	damagefactor "Shrapnel", 3.0
	damagefactor "ExplosiveImpact", 3.0

	//***Che
	DamageFactor "FriendlyExplosion", 3.0

	DamageFactor "YouMustDuck", 1.0 // the *only* monster who reacts to this damage directly and not via his headbox
		// the *only* monster who reacts to this damage directly and not via his headbox
	PainChance "YouMustDuck", 255 // short-ranged alerter tracer fired by the player's ssg every 10 tics
	

	DamageFactor "Avoid", 1.0 
	PainChance "Avoid", 255 // alerter tracer fired by player's rocket launcher, faster than the rocket
	
	BurnHeight 0
	//***Che
	//Tag "Pain Elemental"
	Tag "$PAIN_ELEMENTAL"
	Obituary "$O_PAIN_ELEMENTAL" // "%o was too close when the pain elemental exploded"
	
	var int user_sleeping;
	var int user_item_no;
	var int user_serverside_sfchk;	
	
	DamageFactor "Argent", 0.0 //immune to ghost souls' enraging buff
	
	PainChance "Bullet792", 160 // machineguns and snip[er rifles not aimed
	PainChance "SniperBullet", 255 // sniper rifle aimed
	
	damagefactor "Killme", 1.0 // AOE inflicted by captured marines
	PainChance "Killme", 255

	PainChance "Ice", 255

	States
	{
		//***Che
		Pain.Ice:
			"----" A 20 A_Pain
			Goto See
		
		
		Spawn:
			PAIN A 1 NODELAY ACS_NamedExecuteWithResult("FBD_RunMonster")
			TNT1 A 0 A_SetUserVar("user_sleeping", 1)
		Stand:
			PAIN A 10 A_Look
			Loop
			
		Idle: // without this, the game engine puts him into his Spawn state when he loses target 
				//-- and that wrecks havok with the init scripts!
			TNT1 A 0
			TNT1 A 0 A_SetUserVar("user_sleeping", 1)

		SearchPlayer:
			TNT1 A 0 A_ClearTarget
			TNT1 A 0 A_TakeInventory("EnemyMemory", 30)
			PAIN A 10 A_Look
			TNT1 A 0 A_SetAngle(angle - 30)
			PAIN A 10 A_Look
			TNT1 A 0 A_SetAngle(angle + 30)
			PAIN A 10 A_Look
			TNT1 A 0 A_SetAngle(angle + 30)
			PAIN A 10 A_Look
			TNT1 A 0 A_SetAngle(angle - 30)
			
			PAIN AA 3 A_Wander
			PAIN A 2 A_look
			PAIN BB 3 A_Wander
			PAIN B 2 A_look
			PAIN CC 3 A_Wander
			PAIN C 2 A_look
			PAIN BB 3 A_Wander
			PAIN B 2 A_look
			PAIN AA 3 A_Wander
			PAIN A 2 A_look
			Loop
			
			
		See:
			TNT1 A 0
			TNT1 A 0 A_CheckSight("See2")
			TNT1 A 0 A_SetUserVar("user_sleeping", 0)
/*	
OBSOLETED		
			//***Che
			// slaughtermap manage
			TNT1 A 0 A_JumpIf(!user_sleeping, 3) // forgo the expensive sight check if already awake
			TNT1 A 0 A_CheckSight(2) // do not consider ourselves awake if none of the players can see us
			TNT1 A 0 A_SetUserVar("user_sleeping", 0)
			TNT1 A 0 A_JumpIf(user_serverside_sfchk != -1, 3) // -1 means ACS commands us to do the radiusgive
			// A_RadiusGive is:
			//  1. serverside-only: the call is skipped on the client; only if a player is involved, a network command to update his item count is sent, otherwise the item count only increases on the server
			//  2. iterates over all actors in an infinitely tall square column checking their flags and coordinates
			//  3. performs expensive precision radius calculation (using a square root) unless RGF_CUBE is given (which results in cheaper delta per-coordinate comparison)
			//  4. performs expensive sight check, for each thing that passes flag and radius checks, unless RGF_NOSIGHT is given
			TNT1 A 0 A_RadiusGive("SfestCounterServerside", 500, RGF_MONSTERS | RGF_CUBE | RGF_NOSIGHT, 1)			
			TNT1 A 0 A_SetUserVar("user_serverside_sfchk", 1) // reply that we did the deed	
*/
			TNT1 A 0 A_JumpIf(CallAcs("FBD_TargetIsInvisible"), "ForgetQuicker")
			
			TNT1 A 0 A_TakeInventory("EnemyMemory", 10)
			PAIN AABBCC 3 A_Chase
			
			TNT1 A 0 A_TakeInventory("EnemyMemory", 10)
			PAIN AABBCC 3 A_Chase
			
			Loop
		
		See2:
			TNT1 A 0 A_JumpIfInventory("EnemyMemory", 18, "Idle") //"SearchPlayer")
			TNT1 A 0 A_GiveInventory("EnemyMemory", 1)
			PAIN AABBCC 3 A_Chase
			Goto See
		//***Che	
		ForgetQuicker:
			TNT1 A 0 A_JumpIfInventory("EnemyMemory", 18, "Idle") //"SearchPlayer")
			TNT1 A 0 A_GiveInventory("EnemyMemory", 4)
			PAIN AABBCC 3 A_Chase
			Goto See			
			
		Missile:
			TNT1 A 0 A_TakeInventory("EnemyMemory", 30)
			PAIN D 7 A_FaceTarget
			PAIN E 7 A_FaceTarget
			PAIN F 5 BRIGHT A_FaceTarget
			PAIN F 2 BRIGHT A_PainAttack("FBD_LostSoul")
			PAIN ED 7
			Goto See
		
		Death.Fatality:
			TNT1 A 0 A_Pain
			TNT1 A 0 A_JumpIfIntargetInventory("FistsSelected", 1, 1)
			Goto Death
			TNT1 A 0 A_FaceTarget
			//TNT1 AA 0 A_SpawnItemEx("HealthPlusFatalityBonus", 0,0,20, random (-1, 1),random (-1, 1),8, 0, SXF_ABSOLUTEVELOCITY | SXF_NOCHECKPOSITION)
			//TNT1 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, 10, 5, 0) // 0, health, armor, 0 -- rounded down to nearest 2
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_GiveToTarget("GoFatality", 1)
			TNT1 A 0 A_GiveToTarget("PEFatality", 1)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0) // without at least 8 tics delay, scripts runs ownerless
			// fatalized monsters do not respawn
			Stop
			
		Pain:
			PAIN G 6
			PAIN G 6 A_Pain
			Goto See
			
		//***Che
		Pain.Avoid:
		Pain.YouMustDuck: // the *only* monster who reacts to this damage directly and not via his headbox
			// fire a lost soul to serve as a meatshield, then backpedal
			TNT1 A 0 HealThing(1)
			TNT1 A 0 A_JumpIf(user_sleeping, "Flatfooted") // dont dodge if unaware
			PAIN G 3 A_ChangeFlag("NOPAIN", 1)
			PAIN D 4 A_FaceTarget
			PAIN E 4 A_Recoil(4)
			PAIN F 2 BRIGHT A_Recoil(4)
			PAIN F 2 BRIGHT A_PainAttack("FBD_LostSoul")			
			PAIN G 0 A_ChangeFlag("NOPAIN", 0)
			PAIN GG 10 A_Recoil(4) // this *is* interrupted by pain resulting in him firing
			// lost souls like a machinegun while backpedaling
			// Then again, the alerter tracer has a chance to hit the lost soul instead.
			Goto See
		Flatfooted:
			PAIN G 3 A_ChangeFlag("NOPAIN", 1) 
			
			TNT1 A 0 A_SetUserVar("user_sleeping", 0) // otherwise, he is caught in an infinite loop
			// while your ssg is aimed at him
			// this 15-tic nopain frame nicely skips the *next* alerter fired by your super shotgun (after 11 tics)
			PAIN A 8 A_PlaySound("pain/sight", CHAN_VOICE) 
			PAIN B 7 A_FaceTarget
			TNT1 A 0 HealThing(1) // assuming he is still being aimed at, takes 1 damage again
			PAIN B 0 A_ChangeFlag("NOPAIN", 0)
			PAIN A 10 A_Recoil(2)
			Goto See
			
		Pain.Kick:
			TNT1 A 0 A_FaceTarget
			PAIN G 12
			PAIN G 12 A_Pain
			Goto See
		Death.Telefrag:
		Death.ExplodeHarmlessly:
			TNT1 A 0
			TNT1 A 0 A_NoBlocking
			Goto DeathPlus5 //Death+5
		
		Death:
			PAIN H 8 BRIGHT
			PAIN I 8 BRIGHT A_Scream
			
			//***Che inflict Fire damage instead of Normal (as I mentioned above, DamageType is ignored for monsters)
			//TNT1 A 0 A_Explode (50,220)
			TNT1 A 0 A_SpawnItemEx("PEDeathExplosionEffect",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			
			TNT1 AA 0 A_CustomMissile ("FireworkSFXType1", 0, 0, random (0, 360), 2, random (10, 80))
		DeathPlus5:	
			TNT1 AAAA 0 A_CustomMissile ("FireworkSFXType1", 0, 0, random (0, 360), 2, random (10, 80))
			TNT1 AAAAAA 0 bright A_CustomMissile ("SuperGoreSpawner", 5, 0, random (0, 360), CMF_AIMDIRECTION, random (30, 180))
			TNT1 AAAAAAAAA 0 A_CustomMissile ("CeilBloodLauncherLong", 0, 0, random (0, 360), CMF_AIMDIRECTION, random (50, 130))
			
			TNT1 AAA 0 A_CustomMissile ("XDeathPainElementalNew1", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (30, 90))
			TNT1 AAA 0 A_CustomMissile ("XDeathPainElementalNew2", 32, 0, random (0, 360), CMF_AIMDIRECTION, random (30, 90))
			
			TNT1 AAAAAAAAAAAA 0 A_CustomMissile ("BloodMistExtraBig", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (30, 90))
			TNT1 AA 0 A_CustomMissile ("XDeath2", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (40, 90))
			TNT1 AA 0 A_CustomMissile ("XDeath3", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (40, 90))
			TNT1 AA 0 A_CustomMissile ("XDeath1", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (40, 90))
			TNT1 AAA 0 A_CustomMissile ("BDExplosionparticles", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (40, 90))
			TNT1 AA 0 A_CustomMissile ("BDExplosionparticles2", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (40, 90))
			TNT1 AA 0 A_CustomMissile ("BDExplosionparticles3", 10, 0, random (0, 360), CMF_AIMDIRECTION, random (40, 90))
			TNT1 AA 0 A_SpawnItemEx("TinyBurningPiece3", random (-5, 5), random (-5, 5))
			TNT1 AA 0 A_SpawnItemEx("TinyBurningPiece", random (-5, 5), random (-5, 5))
			TNT1 AA 0 A_SpawnItemEx("TinyBurningPiece2", random (-5, 5), random (-5, 5))
			TNT1 A 0 A_SpawnItemEx ("DetectFloorCrater",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
			EXPL A 0 A_SpawnItemEx("ExplosionParticleSpawner", 0, 0, 0, 0, 0, 0, 0, 128)
			TNT1 A 0 A_SpawnItem("BigBloodSpot")
			EXPL AAAAAAAAAAAAAAAAA 0 A_CustomMissile ("FireBallExplosion", 6, 0, random (0, 360), 2, random (0, 360))
			TNT1 A 0 BRIGHT A_PainDie("FBD_LostSoul")
			TNT1 A 0 A_JumpIfInTargetInventory("IAmRaiseable", 1, "RestRaiseable")
		RestInPeace:
			TNT1 A 0
			TNT1 A 0 A_ChangeFlag("CORPSE", 0)
			TNT1 A 0 A_ChangeFlag("ISMONSTER", 0)
			PAIN N -1
			Stop
		RestRaiseable:
			TNT1 A 0
			TNT1 A 0 A_ChangeFlag("CORPSE", 1)
			TNT1 A 0 A_ChangeFlag("ISMONSTER", 1)
			PAIN N -1 //***Che: ChebMaster's blunder of a lifetime: produces an invulnerable ghost! ACS_NamedExecuteAlways("RespawnCorpseAfter60sIfNightmare", 0, 0, 0, 0)
			Stop

		Pain.KillMe:
		Pain.Taunt:
			TNT1 A 0
			TNT1 A 0 HealThing(1)
			Goto Missile
		Death.KillMe:
		Death.Taunt:
		Death.Avoid:
		Death.YouMustDuck:
			//TNT1 A 0 A_ChangeFlag("SOLID", 0)
			//TNT1 A 0 A_SpawnItem("PainElemental")
			//Stop
			
			// fire one last lost soul
			PAIN D 4 A_FaceTarget
			PAIN E 4 A_FaceTarget
			PAIN F 6 BRIGHT A_PainAttack("FBD_LostSoul")
			PAIN EG 4
			Goto Death
		Death.Ice:
		Death.Freeze:
		Death.Frost:
			//TNT1 A 0 A_ChangeFlag("SHOOTABLE", 0)
			//TNT1 A 0 A_ChangeFlag("SOLID", 0)
			TNT1 A 0 // freeze deaths are permanent!
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_SpawnItemEx("FrozenPainElemental", 0,0,0, momx,momy,momz, 0, SXF_NOCHECKPOSITION | SXF_ABSOLUTEVELOCITY)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop
		Death.IOS_Frost:
			TNT1 A 0 A_NoBlocking
			TNT1 A 0 A_SpawnItemEx("PermafrostPainElemental", 0,0,0, momx,momy,momz, 0, SXF_NOCHECKPOSITION | SXF_ABSOLUTEVELOCITY)
			TNT1 A 30 A_ChangeFlag("CORPSE", 0)
			Stop	
	}
}

//***Che:
ACTOR PEExplodingHarmlessly: FBD_PainElemental {
	-COUNTKILL
	+NOPAIN
	States {
		Spawn:
			TNT1 A 1 NODELAY A_Die("ExplodeHarmlessly") 
			Stop
		See:
		Pain:
		Idle:
		Missile:
			TNT1 A 1 A_Die("ExplodeHarmlessly") 
			Stop
	}
}

ACTOR PEDeathExplosionEffect 
{
	+MISSILE
	+NOINTERACTION
	Speed 0
	DamageType Fire
	States
	{
		Spawn:
		Death:
			TNT1 A 0 NODELAY A_Explode (50,220)
			TNT1 A 30
			Stop
	}
}



ACTOR PEPart1
{
    Radius 8
    Height 8
    Speed 12
    Scale 1.5
	Mass 1
    +NOBLOCKMAP
	+MISSILE
    +NOTELEPORT
    +MOVEWITHSECTOR
    +CLIENTSIDEONLY
    +RIPPER
    +BLOODLESSIMPACT 
    +DOOMBOUNCE
	+SKYEXPLODE
    BounceFactor 0.5
	damagetype Blood
    SeeSound "misc/xdeath4"
    DeathSound "misc/xdeath1"
	Decal BloodSuper
    States
    {
		Spawn:
			TNT1 A 0 A_JumpIf(waterlevel > 1, "Splash")
			ID22 A 2 A_CustomMissile("BloodTrails",0,0,180,2)
			TNT1 A 0 A_CustomMissile ("SmallFlameTrails", 2, 0, random (0, 360), 2, random (70, 110))
			ID22 B 2 A_CustomMissile("BloodTrails",0,0,180,2)
			TNT1 A 0 A_CustomMissile ("SmallFlameTrails", 2, 0, random (0, 360), 2, random (70, 110))
			ID22 C 2 A_CustomMissile("BloodTrails",0,0,180,2)
			TNT1 A 0 A_CustomMissile ("SmallFlameTrails", 2, 0, random (0, 360), 2, random (70, 110))
			ID22 D 2 A_CustomMissile("BloodTrails",0,0,180,2)
			TNT1 A 0 A_CustomMissile ("SmallFlameTrails", 2, 0, random (0, 360), 2, random (70, 110))
			Loop
		Death:
			ID22 F 1 
			TNT1 A 0 A_QueueCorpse
			ID22 F -1
			Stop
			TNT1 A 1
		Splash:
			TNT1 A 0
			Stop
    }
}


ACTOR PEPart2
{
    Radius 8
    Height 8
    Speed 16
    Scale 1.5
	Mass 1
    +NOBLOCKMAP
	+MISSILE
    +NOTELEPORT
    +MOVEWITHSECTOR
    +CLIENTSIDEONLY
    +RIPPER
    +BLOODLESSIMPACT 
    +DOOMBOUNCE
	+SKYEXPLODE
    BounceFactor 0.5
	damagetype Blood
    SeeSound "misc/xdeath4"
    DeathSound "misc/xdeath1"
	Decal BloodSuper
    States
    {
		Spawn:
			TNT1 A 0 A_JumpIf(waterlevel > 1, "Splash")
			ID22 A 2 A_CustomMissile("BloodTrails",0,0,180,2)
			TNT1 A 0 bright A_SpawnItem("YellowFlare",0,2)
			TNT1 A 0 A_SPawnItem("PlasmaSmoke")
			TNT1 A 0 A_CustomMissile ("SmallFlameTrails", 2, 0, random (0, 360), 2, random (70, 110))
		
			ID22 B 2 A_CustomMissile("BloodTrails",0,0,180,2)
			TNT1 A 0 bright A_SpawnItem("YellowFlare",0,2)
			TNT1 A 0 A_CustomMissile ("SmallFlameTrails", 2, 0, random (0, 360), 2, random (70, 110))
			
			ID22 C 2 A_CustomMissile("BloodTrails",0,0,180,2)
			TNT1 A 0 bright A_SpawnItem("YellowFlare",0,2)
			TNT1 A 0 A_SPawnItem("PlasmaSmoke")
			TNT1 A 0 A_CustomMissile ("SmallFlameTrails", 2, 0, random (0, 360), 2, random (70, 110))
			
			ID22 D 2 A_CustomMissile("BloodTrails",0,0,180,2)
			TNT1 A 0 bright A_SpawnItem("YellowFlare",0,2)
			TNT1 A 0 A_CustomMissile ("SmallFlameTrails", 2, 0, random (0, 360), 2, random (70, 110))
			Loop
		Death:
			ID22 F 1 A_SpawnItem("FBD_FlyingBlood",0,5,0,1)
			TNT1 A 0 A_QueueCorpse
			TNT1 A 0 A_SpawnItem("100SmallFireFocusSpawnerz")
			ID22 F -1
			Stop
			TNT1 A 1
		Splash:
			TNT1 A 0
			Stop
    }
}

Actor PEPart2SuperFast: PEPart2
{
Speed 22
States
    {
    Spawn:
	    TNT1 A 0 A_JumpIf(waterlevel > 1, "Splash")
        ID22 A 1 A_CustomMissile("BloodTrails",0,0,180,2)
		TNT1 A 0 bright A_SpawnItem("YellowFlare",0,2)
		
        TNT1 A 0 A_CustomMissile ("SmallFlameTrails", 2, 0, random (0, 360), 2, random (70, 110))
	
        ID22 B 1 A_CustomMissile("BloodTrails",0,0,180,2)
		TNT1 A 0 bright A_SpawnItem("YellowFlare",0,2)
        TNT1 A 0 A_CustomMissile ("SmallFlameTrails", 2, 0, random (0, 360), 2, random (70, 110))
        
		ID22 C 1 A_CustomMissile("BloodTrails",0,0,180,2)
		TNT1 A 0 bright A_SpawnItem("YellowFlare",0,2)
        
		TNT1 A 0 A_CustomMissile ("SmallFlameTrails", 2, 0, random (0, 360), 2, random (70, 110))
        
		ID22 D 1 A_CustomMissile("BloodTrails",0,0,180,2)
		TNT1 A 0 bright A_SpawnItem("YellowFlare",0,2)
        TNT1 A 0 A_CustomMissile ("SmallFlameTrails", 2, 0, random (0, 360), 2, random (70, 110))
		Loop
	}	
}


//***Che
// TRIVIA: the player is specifically excluded from any mechanisms
// that prevent AOE friendly fire, so these mechanisms only work between monsters
// (which the marine NPCs are) but would *never* work between monsters and player.
// Sad, but true (I studied source code of Zandronum and GZDoom).
// All the checks in the code are wrapped in "if (this is not a player) { ... }"
// :(


// ========= Explosive pain elemental corpse bug: =====================
// the pain elemental corpse is a bomb very dangerous for the player.
// Any monster hitting it, or even the player himself stepping on it
// makes it ASPLODE for massive damage!


ACTOR ChePainExplosion: ZandronumBaronBall //BaronBall
{
	Radius 8
	Height 8
	DamageType "FriendlyExplosion"
	Projectile 
    Speed 1
	FastSpeed 1
    Damage 1
	+THRUGHOST
	SeeSound "none"
	DeathSound "none"
	States
	{
		Spawn:
			TNT1 A 0
			TNT1 A 1
			Stop
		
		Death:
			TNT1 A 0 
			TNT1 A 0 A_Explode(100, 200)
			TNT1 A 1
			Stop
	}
}


Actor FatalizedPE
{
    Radius 12
    Height 32
    Scale 1.0
    //+SHOOTABLE
    +NOTELEPORT
    +MOVEWITHSECTOR
    +CORPSE
	-SOLID
	//+PUSHABLE
	-PUSHABLE // very annoying, dragging after player as if glued to your feet and then sliding off into a wall
	+THRUSPECIES
	//SPecies "Marines"
    Mass 10000
    Health 100
    damagefactor "Blood", 0.0
    damagefactor "Trample", 0.0
	
	
	//***Che
	//+DONTHURTSPECIES
	//Nope:
	//  DONTHARMCLASS
	//  Prevents monsters with this flag from dealing explosion damage to other monsters 
	//    of the same class. By default, projectiles fired by monsters of the same class
	//    don't deal impact damage but can deal damage and trigger infighting via A_Explode.
	//  This flag overrides that behavior, blocking explosion damage between the same
	//    class as well. (This also means that monsters with this flag can't blow 
	//    themselves up with their own explosive projectiles.)
	//      Note, if DONTHARMSPECIES is used on the monster, adding this flag is pointless 
	//        because it's implied.
    //		This flag was previously named DONTHURTSPECIES, which was a misleading name that
	//        could lead to believe its effect was that of DONTHARMSPECIES.
	
	Species "Marines"
	+DONTHARMSPECIES // this is not useles, it protects friendly marines
	+SHOOTABLE // instead of pushable

	
	// un-fucking-fortunately, players are NOT monsters so DONTHARMSPECIES does NOT apply to them,
	// so I had to get creative and add whole new damage type 
	//   AND add specifications for that damage type to ALL the monsters
	// what a PAIN
	
	//damagetype "FriendlyExplosion" // this is silently ignored by the engine, because corpse is not a missile!
	
	
	
	States
    {
		Spawn:
			PA1F U -1
			Stop
		
		Death:
			TNT1 AAAAAAAAAAAA 0 A_CustomMissile ("BloodMistExtraBig", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (30, 90))
			TNT1 AA 0 A_CustomMissile ("XDeath2", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (40, 90))
			TNT1 AA 0 A_CustomMissile ("XDeath3", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (40, 90))
			TNT1 AA 0 A_CustomMissile ("XDeath1", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (40, 90))
			TNT1 AAA 0 A_CustomMissile ("BDExplosionparticles", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (40, 90))
			TNT1 AA 0 A_CustomMissile ("BDExplosionparticles2", 30, 0, random (0, 360), CMF_AIMDIRECTION, random (40, 90))
			TNT1 AA 0 A_CustomMissile ("BDExplosionparticles3", 10, 0, random (0, 360), CMF_AIMDIRECTION, random (40, 90))
			TNT1 AA 0 A_SpawnItemEx("TinyBurningPiece3", random (-5, 5), random (-5, 5))
			TNT1 AA 0 A_SpawnItemEx("TinyBurningPiece", random (-5, 5), random (-5, 5))
			TNT1 AA 0 A_SpawnItemEx("TinyBurningPiece2", random (-5, 5), random (-5, 5))
			TNT1 A 0 A_SpawnItemEx ("DetectFloorCrater",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
			EXPL A 0 A_SpawnItemEx("ExplosionParticleSpawner", 0, 0, 0, 0, 0, 0, 0, 128)
			TNT1 A 0 A_SpawnItem("BigBloodSpot")
			
			
			//TNT1 A 0 A_Explode(100, 200)
			// Do NOT call A_Explode from corpses as damage type is ignored and your explosion will inflict "Normal"!
			// Use a custom missile class to do the explosion of required type instead.
			TNT1 A 0 A_CustomMissile ("ChePainExplosion", 30, 0, 0, 2, 0)
			
			EXPL AAAAAAAAAAAAAAAAA 0 A_CustomMissile ("FireBallExplosion", 6, 0, random (0, 360), 2, random (0, 360))
			PAIN N 1
			PAIN N -1
			Stop
	}
}

#include Agony.txt		
		