

// ------------------------------ CHEBSKIES 2.x -------------------------------

//***Che: modified, removed BRIGHT from all frames replacing it all with dynamic light effects 
// also upgraded to my blindfire algorithms in case player takes cover while he is flinging fireballs

// no doomed nums because spawned by ACS scripts by class name - see eday21.wad
// the map 43 versions *do* have doomed nums
// 

Actor InfernoDemon

// return back to EDAY's original khorax sprites ditching my recolor

{
	
	damagefactor "Desintegrate", 0.6 // bfg 9000 & Unmaker
	damagefactor "Fire", 0.33 //***Che: flamethrower is another cheese
	Health 12000
	
	BloodType "FieryBlood", "FieryBlood", "FieryBlood"
	
	Tag "$INFERNAL"
	Obituary "$INFERNAL_O"
	
	Speed 42
	Radius 60
	Height 160 //140
	Mass 5000
	Damage 40
	Monster
	PainChance 10
	PainChance "Fire", 0
	PainChance "HeadStun", 255
	PainChance "HeadPlasma", 255
	Scale 2.0
	+MISSILEMORE
	+MISSILEEVENMORE
	+BOSS
	+FLOORCLIP
	+TELESTOMP
	+DONTMORPH
	+NOTARGET
	+NOICEDEATH
	MaxDropOffHeight 512
	damagefactor "Blood", 0.0 damagefactor "BlueBlood", 0.0 damagefactor "GreenBlood", 0.0
	damagefactor "Shrapnel", 0.0

	//damagefactor "Inferno", 0
	damagefactor "Flames", 0.0 //***Che his own damage type
	PainChance "Flames", 0
	
	SeeSound "Infdem/see"
	PainSound "Infdem/pain"
	DeathSound "Infdem/death"
	ActiveSound "Infdem/active"
	
	var int user_meteor_cooldown;
	
	var int user_head_tid;
	var int user_head_type;
		// note: the headbox, derived from the cyberdemon's, has damage factor 0.7 for direct rocket and bfg10k hits
		// effectively making him only receive 140% damage from a rocket to the face
	//Chebskies 2.0 switches to FBD's new headboxes
	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_sleeping;
	var int user_item_no;
	var int user_serverside_sfchk;

	var int user_attack_count;
	var int user_num_stomps;
	var int user_num_meteors;
	States
	{
		Spawn:
			DIAA A 0 NODELAY ACS_NamedExecuteWithResult("FBD_RunMonster", 14, 200) // infernal headbox, 200% scale
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 77, 0, 54, 1)
			// permanent ones, cycling like the lost soul's flames
			DIAA AAAAAA 0 A_SpawnItemEx("InfernoDemonLightSFX", 0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0) 
			TNT1 A 0 A_GiveInventory("TargetIsABoss")
			TNT1 A 0 A_GiveInventory("TargetIsAGreatTerribleBoss")
			
			DIAA A 1 A_Jump(256, "SetupValues")
			Wait
			
		SetupValues: // differs for different versions
			TNT1 A 0 A_SetUserVar("user_num_stomps", 2)
			TNT1 A 0 A_SetUserVar("user_num_meteors", 3)
			
			
			//***Che After spawn, he goes to wandering instead of standing still.
			// well, he just emerged from a portal
			Goto LookingForPlayer2
		Idle:
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 77, 0, 54)
			DIAA AAA 10 A_Look
		LookingForPlayer:
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 77, 0, 54)
			DIAA AAA 10 A_Look
			TNT1 A 0 A_Jump(96, "LookingForPlayer2")
			Loop
		LookingForPlayer2: // walking at half speed
			TNT1 A 0 A_SetAngle(angle + Random(-50,50))
			DIAA A 0 A_PlaySound("inferno/step", 5)
			DIAA A 0 Radius_Quake(10,5,0,10,0)
			DIAA A 0 A_SpawnItemEx("InfernoDemonFootstep", 44,14,16, 0,0,-10, 0,SXF_NOCHECKPOSITION,0)
			DIAA A 10 A_Wander
			TNT1 A 0 A_Look
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 84, -3, 61)
			DIAA B 10 A_Wander
			DIAA B 0 A_PlaySound("inferno/step", 5)
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 80, -2, 54)
			DIAA C 0 Radius_Quake(10,5,0,10,0)
			DIAA C 0 A_SpawnItemEx("InfernoDemonFootstep", 44,-24,16, 0,0,-10, 0,SXF_NOCHECKPOSITION,0)
			DIAA C 10 A_Wander
			TNT1 A 0 A_Look
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 83, -1, 61)
			DIAA D 10 A_Wander
			TNT1 A 0 A_Jump(32, "LookingForPlayer")
			Loop				
		See:
			TNT1 A 0
			DIAA A 2 A_SetUserVar("user_sleeping", 0) // headbox init always sets itself to sleeping, must clear
			//TNT1 A 0 ACS_ExecuteAlways(33, 0, 0, 0, 0) //***Che the original boss health display -- NOT localizable
			TNT1 A 0 ACS_NamedExecuteWithResult("FBD_DisplayBossHealth", 8)

		Chase:
			TNT1 A 0 A_ChangeFlag("NOPAIN", 0)
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 77, 0, 54)
			TNT1 A 0 A_SetUserVar("user_sleeping", 0)
			DIAA A 2
			DIAA A 0 A_PlaySound("inferno/step", 5)
			DIAA A 0 Radius_Quake(10,5,0,10,0)
			DIAA A 0 A_SpawnItemEx("InfernoDemonFootstep", 44,14,16, 0,0,-10, 0,SXF_NOCHECKPOSITION,0)
			DIAA A 6 A_Chase
			TNT1 A 0 A_JumpIfTargetInLOS("Stomp", 160, JLOSF_DEADNOJUMP, 300) // insta melee at close ranges
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 84, -3, 61)
			DIAA B 6 A_Chase
			DIAA B 0 A_PlaySound("inferno/step", 5)
			TNT1 A 0 A_JumpIfTargetInLOS("Stomp", 160, JLOSF_DEADNOJUMP, 300)
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 80, -2, 54)
			DIAA C 0 Radius_Quake(10,5,0,10,0)
			DIAA C 0 A_SpawnItemEx("InfernoDemonFootstep", 44,-24,16, 0,0,-10, 0,SXF_NOCHECKPOSITION,0)
			DIAA C 6 A_Chase
			TNT1 A 0 A_JumpIfTargetInLOS("Stomp", 160, JLOSF_DEADNOJUMP, 300)
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 83, -1, 61)
			DIAA D 6 A_Chase
			TNT1 A 0 A_JumpIfTargetInLOS("Stomp", 160, JLOSF_DEADNOJUMP, 300)
			TNT1 A 0 A_Jump(256, "SpecificBossMeteorLogic")
			Loop
			//TNT1 A 0 A_CheckSight("Meteor")
			//Goto Chase
		SpecificBossMeteorLogic:	
			TNT1 A 0 A_JumpIfTargetInLOS("ClearMeteorCooldown")
			Goto MeteorIfNotOnCooldown
		MeteorIfNotOnCooldown:	
			
			// map 43 boss starts in a cave with ceiling not suitable for meteors
			TNT1 A 0
			TNT1 A 0 A_JumpIf(ceilingz - z < 1000, "Chase")
			
			//***Che: don't use meteors up close. They suck up close.
			// Just walk around that cover and greet the player face to face
			//TNT1 A 0 A_JumpIfCloser(700, 1) 
			//Goto Chase
			
			//***Che: the problem with meteor is  he is designed to spam it if the player takes cover
			// But! him teleporting has the sme effect because he often teleports out of player's LOS
			// resulting in meteors coming out of the blue before you reacquire him.
			// Let us reserve that (unintended) player-raping feature for the ultra hard skills, shall we?
			
			// Somehow, the player is out of the arena. Either cheating, or just respawned in coop multiplayer.
			// Arena diameter is ~5200 map units
			// Go to idle if target is farther than 7000 map units
			TNT1 A 0 A_JumpIfCloser(7000, 1)
			Goto LookingForPlayer2 // won't stop immediately, just slow down to wander aimlessly
			// And won't meteor again until sees the target.
			
			
			TNT1 A 0 A_JumpIf(user_meteor_cooldown <= 0, "Meteor")
			TNT1 A 0 A_SetUserVar("user_meteor_cooldown", user_meteor_cooldown - 1)
			Goto Chase
		ClearMeteorCooldown:
			TNT1 A 0 A_SetUserVar("user_meteor_cooldown", 0)
			Goto Chase
		Missile:
			TNT1 A 0
			TNT1 A 0 A_SetUserVar("user_sleeping", 0)
			TNT1 A 0 A_JumpIfCloser(400, "Stomp")
			TNT1 A 0 A_Jump(128, "FireBall")
			TNT1 A 0 A_Jump(64, "sTOMP")
			TNT1 A 0 A_JumpIf(user_meteor_cooldown > 0, "FireballInstead")
			Goto Meteor
		FireballInstead:	
			TNT1 A 0 A_SetUserVar("user_meteor_cooldown", user_meteor_cooldown - 1)
		Fireball:
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 41, 0, 79)
			DIAA E 10 A_FaceTarget
			
			// MUST use auto-aiming at visible targets, otherwise misses at close range due to projectile's origin offset
			TNT1 A 0 A_JumpIfInTargetInventory("PowerInvisibility", 1, 2)
			TNT1 A 0 A_JumpIfTargetInLOS(3)
			// the version with auto-aim disabled:		
			TNT1 A 0 A_CustomMissile("InfernoDemonFireballMkII",random (90, 180),90,angle, CMF_ABSOLUTEANGLE | CMF_OFFSETPITCH | CMF_SAVEPITCH)
			TNT1 A 0 A_Jump(256, 2)
			// the auto-aimed version:
			TNT1 A 0 A_CustomMissile("InfernoDemonFireballMkII",random (90, 180),90,0,CMF_SAVEPITCH)
			
				TNT1 A 0 A_JumpIfInTargetInventory("PowerInvisibility", 1, 4)
				TNT1 A 0 A_JumpIfTargetInLOS(2)
				TNT1 A 0 A_Jump(256, 2)
				TNT1 A 0 A_FaceTarget
			
			DIAA F 10

				TNT1 A 0 A_JumpIfInTargetInventory("PowerInvisibility", 1, 4)
				TNT1 A 0 A_JumpIfTargetInLOS(2)
				TNT1 A 0 A_Jump(256, 2)
				TNT1 A 0 A_FaceTarget

			DIAA E 10
			
			TNT1 A 0 A_JumpIfInTargetInventory("PowerInvisibility", 1, 2)
			TNT1 A 0 A_JumpIfTargetInLOS(3)
			// the version with auto-aim disabled:		
			TNT1 A 0 A_CustomMissile("InfernoDemonFireballMkII",random (90, 180),-90,angle, CMF_ABSOLUTEANGLE | CMF_OFFSETPITCH | CMF_SAVEPITCH)
			TNT1 A 0 A_Jump(256, 2)
			// the auto-aimed version:
			TNT1 A 0 A_CustomMissile("InfernoDemonFireballMkII",random (90, 180),-90,0,CMF_SAVEPITCH)
			
				TNT1 A 0 A_JumpIfInTargetInventory("PowerInvisibility", 1, 4)
				TNT1 A 0 A_JumpIfTargetInLOS(2)
				TNT1 A 0 A_Jump(256, 2)
				TNT1 A 0 A_FaceTarget
			
			DIAA F 10 
			
				TNT1 A 0 A_JumpIfInTargetInventory("PowerInvisibility", 1, 4)
				TNT1 A 0 A_JumpIfTargetInLOS(2)
				TNT1 A 0 A_Jump(256, 2)
				TNT1 A 0 A_FaceTarget
			
			
			DIAA E 10
			
			TNT1 A 0 A_JumpIfInTargetInventory("PowerInvisibility", 1, 2)
			TNT1 A 0 A_JumpIfTargetInLOS(3)
			// the version with auto-aim disabled:		
			TNT1 A 0 A_CustomMissile("InfernoDemonFireballMkII",random (90, 180),90,angle, CMF_ABSOLUTEANGLE | CMF_OFFSETPITCH | CMF_SAVEPITCH)
			TNT1 A 0 A_Jump(256, 2)
			// the auto-aimed version:
			TNT1 A 0 A_CustomMissile("InfernoDemonFireballMkII",random (90, 180),90,0,CMF_SAVEPITCH)			
			
				TNT1 A 0 A_JumpIfInTargetInventory("PowerInvisibility", 1, 4)
				TNT1 A 0 A_JumpIfTargetInLOS(2)
				TNT1 A 0 A_Jump(256, 2)
				TNT1 A 0 A_FaceTarget
			
			DIAA F 10
			
				TNT1 A 0 A_JumpIfInTargetInventory("PowerInvisibility", 1, 4)
				TNT1 A 0 A_JumpIfTargetInLOS(2)
				TNT1 A 0 A_Jump(256, 2)
				TNT1 A 0 A_FaceTarget

			DIAA E 10
			
			TNT1 A 0 A_JumpIfInTargetInventory("PowerInvisibility", 1, 2)
			TNT1 A 0 A_JumpIfTargetInLOS(3)
			// the version with auto-aim disabled:		
			TNT1 A 0 A_CustomMissile("InfernoDemonFireballMkII",random (90, 180),-90,angle, CMF_ABSOLUTEANGLE | CMF_OFFSETPITCH | CMF_SAVEPITCH)
			TNT1 A 0 A_Jump(256, 2)
			// the auto-aimed version:
			TNT1 A 0 A_CustomMissile("InfernoDemonFireballMkII",random (90, 180),-90,0,CMF_SAVEPITCH)
			
				TNT1 A 0 A_JumpIfInTargetInventory("PowerInvisibility", 1, 4)
				TNT1 A 0 A_JumpIfTargetInLOS(2)
				TNT1 A 0 A_Jump(256, 2)
				TNT1 A 0 A_FaceTarget
			
			DIAA F 10
			Goto Chase
			
			
		Meteor:
			TNT1 A 0
			
			// map 43 boss starts in a cave with ceiling not suitable for meteors
			TNT1 A 0 A_JumpIf(ceilingz - z < 1000, "FireballInstead")
			
			TNT1 A 0 A_SetUserVar("user_attack_count", 0)
			TNT1 A 0 A_SetUserVar("user_sleeping", 0)
			TNT1 A 0 A_FaceTarget
			
		MeteorLoop:	
			
				TNT1 A 0 A_JumpIfInTargetInventory("PowerInvisibility", 1, 2)
				TNT1 A 0 A_FaceTarget
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 41, 0, 79)
			DIAA E 5 A_FaceTarget
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 27, -23, 79)
			DIAA G 5 A_CustomMissile("InfernoDemonMeteorMkII",200, user_attack_count % 2 ? -90 : 90)
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 64, 4, 48)
			DIAA H 5
			
			TNT1 A 0 A_SetUserVar("user_attack_count", user_attack_count + 1)	
			TNT1 A 0 A_JumpIf(user_attack_count >= user_num_meteors, "MeteorAfterpause")
			Loop
			
		MeteorAfterpause:
			DIAA H 20 A_FaceTarget
			Goto Chase
		  
		Melee:
		Stomp:
			// Unlike the original, the MkII version has a very limited range, barely one third of the arena's width.
			TNT1 A 0 A_JumpIfCloser(900, 1)
			Goto FireballInstead
			TNT1 A 0 A_FaceTarget
			TNT1 A 0 A_SetUserVar("user_meteor_cooldown", 0)
			TNT1 A 0 A_SetUserVar("user_attack_count", 0)
			TNT1 A 0 A_PlaySound("Infdem/active", CHAN_VOICE)
			
		StompLoop:		
				TNT1 A 0 A_JumpIfInTargetInventory("PowerInvisibility", 1, 4)
				TNT1 A 0 A_JumpIfTargetInLOS(2)
				TNT1 A 0 A_Jump(256, 2)
				TNT1 A 0 A_FaceTarget
			DIAA B 20 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 84, -3, 61)
			DIAA B 0 A_PlaySound("inferno/step", 5)
			DIAA B 0  A_CustomMissile("InfernoDemonFireBeamMkII",0,0,0,2,0)
			DIAA B 0  A_CustomMissile("InfernoDemonFireBeamMkII",0,0,20,2,0)
			DIAA B 0  A_CustomMissile("InfernoDemonFireBeamMkII",0,0,40,2,0)
			DIAA B 0  A_CustomMissile("InfernoDemonFireBeamMkII",0,0,60,2,0)
			DIAA B 0  A_CustomMissile("InfernoDemonFireBeamMkII",0,0,80,2,0)
			DIAA B 0  A_CustomMissile("InfernoDemonFireBeamMkII",0,0,-20,2,0)
			DIAA B 0  A_CustomMissile("InfernoDemonFireBeamMkII",0,0,-40,2,0)
			DIAA B 0  A_CustomMissile("InfernoDemonFireBeamMkII",0,0,-60,2,0)
			DIAA B 0  A_CustomMissile("InfernoDemonFireBeamMkII",0,0,-80,2,0)
			DIAA C 0 Radius_Quake(20,35,0,40,0)
			DIAA C 20 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 80, -2, 54)
			TNT1 A 0 A_SetUserVar("user_attack_count", user_attack_count + 1)	
			TNT1 A 0 A_JumpIfCloser(900, 1) // stop stomping if target moved away!
			//***Che must I remind you this distance *must* match the one in the Stomp state,
			//  otherwise it is fraught with infinite loops!
			Goto Missile
			TNT1 A 0 A_JumpIf(user_attack_count >= user_num_stomps, "Chase")
			Loop
		Pain:
			DIAA I 0 A_PlaySound("Infdem/shortpain", CHAN_VOICE) // the A_Pain in AfterTP overrides this if teleport succeeds (is not on cooldown)
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 46, -13, 74)
			DIAA I 7 ACS_NamedExecute("BossFlinches") // map script -- see eday21.wad
				// finds a suitable spot to teleport to (farthest from the current position)
				// and blinks away spawning a demon in his place
				// The spawns list is heavily dependent on game skill -- see the map script
				//  (barons on uv).
				//Must *only use ACS_NamedExecute to maintain the 5-second cooldown
				//  (the script is naturally limited to one instance running)
			
			DIAA H 7 A_SpawnItemEx("InfernoDemonFootstep", Random(-32,32),Random(-32,32),16, 0,0,-10, 0,SXF_NOCHECKPOSITION,0) 	
			Goto Chase			
		
		AfterTP: // is switched to this state by the ACS script "BossFlinches" 
			// if health is above 0 -- see eday21.wad
			
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 46, -13, 74)
			DIAA I 10 A_Pain
			// give him time to fall to ground (he teleports to height 130)
			TNT1 AAA 0 A_SpawnItemEx("InfernoDemonFootstep", Random(-48,48),Random(-48,48),16, 0,0,-10, 0,SXF_NOCHECKPOSITION,0) 
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 64, 4, 48)
			DIAA H 10
			DIAA H 1 A_Jump(256, "MaybeSandbag")
			Wait
		MaybeSandbag: // don't start spamming meteors right after teleporting
			TNT1 A 0 A_SetUserVar("user_meteor_cooldown", 5)
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 64, 4, 48)
			DIAA H 30
			Goto Chase
		Death:
			TNT1 A 0
			Goto Map21BossDeath
		
		RegularDeath:	
			TNT1 A 0 A_Scream
			TNT1 A 0 ACS_NamedExecuteAlways("DeleteHeadboxMkII")
			DIAA JJJJJKKKKKJJJJJKKKKKJJJJJKKKKKJJJJJ 1 BRIGHT A_CustomMissile("FieryBlood", Random(50,100), Random(-30,30), Random(0,360), CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH, Random(-45, 45))
			DIAA K 5 BRIGHT A_FaceTarget
			TNT1 A 0 A_Scream
			DIAA LMNOPQ 5 BRIGHT A_CustomMissile("InfernoIgniter", Random(20,50), Random(-50,50), Random(0,360), CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH, Random(30, 85))
			tnt1 a 0 Radius_Quake(5,200,0,5,0)
			DIAA PQRQPQRQPQR 4 BRIGHT A_CustomMissile("InfernoIgniter", Random(15,30), Random(-50,50), Random(0,360), CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH, Random(30, 85))
			DIAA R 5 BRIGHT A_NoBlocking
			
			// run, fool, for he is going to BLOW!
			TNT1 A 0 A_CustomMissile("InhumaneCyberLordMissile", 64, 0, 0, CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH, -90)
			
			DIAA RRRR 5 BRIGHT A_FadeOut(0.2)
			TNT1 A -1
			Stop
		
		Map21BossDeath:
			TNT1 A 0 A_Scream
			TNT1 A 0 ACS_NamedExecuteWithResult("DeleteHeadboxMkII")
			TNT1 A 0 ACS_NamedExecuteAlways("KillAllMonsters") // map script -- see eday21.wad
			
			DIAA JJJJJKKKKKJJJJJKKKKKJJJJJKKKKKJJJJJ 1 BRIGHT A_CustomMissile("FieryBlood", Random(50,100), Random(-30,30), Random(0,360), CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH, Random(-45, 45))
			DIAA K 5 BRIGHT A_FaceTarget
			TNT1 A 0 A_Scream
			DIAA LMNOPQ 5 BRIGHT A_CustomMissile("InfernoIgniter", Random(20,50), Random(-50,50), Random(0,360), CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH, Random(30, 85))
			tnt1 a 0 Radius_Quake(5,200,0,5,0)
			DIAA PQRQPQRQPQR 4 BRIGHT A_CustomMissile("InfernoIgniter", Random(15,30), Random(-50,50), Random(0,360), CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH, Random(30, 85))
			DIAA R 5 BRIGHT A_NoBlocking
			
			// run, fool, for he is going to BLOW!
			TNT1 A 0 A_CustomMissile("InhumaneCyberLordMissile", 64, 0, 0, CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH, -90)
			
			DIAA RRRR 5 BRIGHT A_FadeOut(0.2)
			TNT1 A 140
			TNT1 A 1 ACS_NamedExecute("EDAY21_EndTheMapIfAnyPlayerAlive",0,0,0,0)//A_BrainDie // ends the map
			TNT1 A -1
			Stop
			
		
	}
}

/*
	This ChebMaster's crime against humanity that is the new sectet map 43 has two of them.
	Each one's health is half the original but combined they have DOUBLE the firepower!
	You Died.
*/

Actor Map43Boss: InfernoDemon 17778
{
	Health 6000
	States
	{
		SetupValues: // differs for different versions
			TNT1 A 0 A_SetUserVar("user_num_stomps", 2)
			TNT1 A 0 A_SetUserVar("user_num_meteors", 3)		
			Goto Stand
		Stand:
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 77, 0, 54)
			DIAA AAA 10 A_Look
			Loop
		See:
			TNT1 A 0 // no boss health script
			DIAA A 2 A_SetUserVar("user_sleeping", 0)
			Goto Chase	
		Pain:
			DIAA I 0 A_Pain
			TNT1 A 0 A_ChangeFlag("NOPAIN", 1)
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 46, -13, 74)
			DIAA I 7
			DIAA H 7 A_SpawnItemEx("InfernoDemonFootstep", Random(-32,32),Random(-32,32),16, 0,0,-10, 0,SXF_NOCHECKPOSITION,0) 	
			Goto Missile					
		Death:
			TNT1 A 0
			Goto RegularDeath
			
		SpecificBossMeteorLogic:
			TNT1 A 0 A_JumpIf(ceilingz - z < 1000 || CallAcs("GetTargetCeilingClearance") < 900, "Chase")
			TNT1 A 0 A_SetUserVar("user_meteor_cooldown", user_meteor_cooldown > 0 ? user_meteor_cooldown - 1 : user_meteor_cooldown)
			TNT1 A 0 A_JumpIf(user_meteor_cooldown > 0, "Chase")
			TNT1 A 0 A_JumpIfTargetInLOS("MeteorIfNotOnCooldown")
			Goto Chase
			
		MeteorIfNotOnCooldown:	
			TNT1 A 0
			TNT1 A 0 A_JumpIfCloser(7000, 1)
			Goto LookingForPlayer2 // won't stop immediately, just slow down to wander aimlessly
			// And won't meteor again until sees the target.
			TNT1 A 0 A_JumpIf(user_meteor_cooldown <= 0, "Meteor")
			TNT1 A 0 A_SetUserVar("user_meteor_cooldown", user_meteor_cooldown - 1)
			Goto Chase			
	}
}

Actor InfernoDemonWimp: InfernoDemon
{
	Health 9000
	Tag "$INFERNAL_ITYTD"
	States
	{
		MaybeSandbag: 
			TNT1 A 0 A_SetUserVar("user_meteor_cooldown", 10) // in chase cycles or attack attempts
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 64, 4, 48)
			DIAA H 60
			Goto Chase	
		SetupValues: // differs for different versions
			TNT1 A 0 A_SetUserVar("user_num_stomps", 1)
			TNT1 A 0 A_SetUserVar("user_num_meteors", 2)
			Goto LookingForPlayer2			
	}
}

Actor Map43BossWimp: Map43Boss 17777
{
	Health 4500
	Tag "$INFERNAL_ITYTD"
	States
	{
		MaybeSandbag: 
			TNT1 A 0 A_SetUserVar("user_meteor_cooldown", 10) // in chase cycles or attack attempts
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 64, 4, 48)
			DIAA H 60
			Goto Chase			
		SetupValues: // differs for different versions
			TNT1 A 0 A_SetUserVar("user_num_stomps", 1)
			TNT1 A 0 A_SetUserVar("user_num_meteors", 2)
			Goto Stand
	}
}

Actor InfernoDemonUV: InfernoDemon 
{
	Health 16000
	States
	{
		MaybeSandbag: 
			TNT1 A 0 A_SetUserVar("user_meteor_cooldown", 3)
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 64, 4, 48)
			DIAA H 20
			Goto Chase	
		SetupValues: // differs for different versions
			TNT1 A 0 A_SetUserVar("user_num_stomps", 2)
			TNT1 A 0 A_SetUserVar("user_num_meteors", 4)
			Goto LookingForPlayer2			
	}	
}

Actor Map43BossUV: Map43Boss 17779
{
	Health 8000
	States
	{
		MaybeSandbag: 
			TNT1 A 0 A_SetUserVar("user_meteor_cooldown", 3)
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 64, 4, 48)
			DIAA H 20
			Goto Chase			
		SetupValues: // differs for different versions
			TNT1 A 0 A_SetUserVar("user_num_stomps", 2)
			TNT1 A 0 A_SetUserVar("user_num_meteors", 4)		
			Goto Stand
	}
}


Actor InfernoDemonMP: InfernoDemon // Coop *and* Hordes
{
	Health 20000
	PainChance 50 // the higher the pain chance, the more he teleports
	States
	{
		MaybeSandbag: 
			// NO. SANDBAGGING. Raep the player with surprise buttsecks meteors!
			DIAA H 0
			Goto Chase
		SetupValues: // differs for different versions
			TNT1 A 0 A_SetUserVar("user_num_stomps", 3)
			TNT1 A 0 A_SetUserVar("user_num_meteors", 5)
			Goto LookingForPlayer2			
	}	
}

Actor Map43BossMP: Map43Boss 17780
{
	Health 10000
	States
	{
		MaybeSandbag: 
			DIAA H 0
			Goto Chase		
		SetupValues: // differs for different versions
			TNT1 A 0 A_SetUserVar("user_num_stomps", 3)
			TNT1 A 0 A_SetUserVar("user_num_meteors", 5)		
			Goto Stand
	}
}

ACTOR InfernoDemonFootstep: DetectFloorCrater
{
    +THRUACTORS
	+GHOST
	+THRUGHOST
	-NOGRAVITY
	+NOBLOCKMAP
	DamageType "Flames"
	Damage (Random(0,0))
	States
    {
		Spawn:
			TNT1 A 0 NODELAY A_Stop
			TNT1 A 0 ThrustThingZ(0,10,1,1)
			TNT1 A 4 A_CheckFloor("Death")
			TNT1 A 0 A_CheckFloor("Death")
			TNT1 A 1 A_Stop
			Stop
		Death:
			TNT1 A 1
			TNT1 A 0 A_SpawnItemEx("SmallFireFocusInfernal",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
			//KYDB EEEEEEEEEE 20 A_FadeOut(0.1)
			XXX1 AAAAAAAAAA 20 A_FadeOut(0.1)
			Stop
    }
}


ACTOR SmallFireFocusInfernal: SmallFireFocus24 {
	//***Che cloning to change the dynamic light assigned in gldefs to a pure red one
}



ACTOR InfernoDemonLightSFX // see GLDEFS.skies
{
	+NOINTERACTION // exclude from physics completely
	Renderstyle Add
	Alpha 0.8 //0.3 //0.05
	var int user_z;
	Radius 1
	Height 1
	States
	{
		Spawn:
			TNT1 A 0 NODELAY A_PlaySound("props/redfire", CHAN_VOICE, 1, 1)
			Goto Live
		Live:
			DFFP A 0 A_SetUserVar("user_z", user_z + Random(15,64))
			DFFP A 0 A_JumpIf(user_z > 200, "Reset")
			DFFP A 0 A_Warp(AAPTR_TARGET, Random(-50,50) + 0.2 * user_z, Random(-50,50), user_z + Random(0,30), 0, WARPF_NOCHECKPOSITION) 
			DFFP A 0 A_Jump(128, "Flip")
			DFFP A 0 A_SetScale(0.1 * Random(5,13), 0.1 * Random(7,13))
			Goto Burn
		Flip:
			DFFP A 0 A_SetScale(-0.1 * Random(5,13), 0.1 * Random(7,13))
			Goto Burn
		Reset:
			TNT1 A 0 A_SetUserVar("user_z", 0)
			Goto Live
		Burn:
			DFFP A Random(1, 10) 
			//DFFP BCDPO 1
			FIR1 DEFGHI 1
			DFFP A 0 A_CheckFlag("SOLID", "Live", AAPTR_TARGET) // keep looping while the infernal lives
			DFFP A 90
			Stop
	}
}


ACTOR InfernoBurningStuff: FlamethrowerBurningStuff 
{
	Radius 4
	DamageType "Flames"
	-FORCERADIUSDMG // important, otherwise the boss harms self
	+MTHRUSPECIES
	States
	{
		TurnOff:
			TNT1 A 0 A_Jump(160, "TurnOff2", "TurnOff3")
			TNT1 A 0 A_SpawnItemEx("SmallFireFocusInfernal",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
			NF4R QRSTUV 1 BRIGHT
			Stop
		TurnOff2:
			TNT1 A 0 A_SpawnItemEx("TinyBurningPiece", random (-8, 8), random (-8, 8))
			TNT1 AA 0 A_SpawnItemEx("TinyBurningPiece2", random (-25, 25), random (-25, 25))
			NF4R QRSTUV 1 BRIGHT
			Stop
		TurnOff3:
			TNT1 AAA 0 A_SpawnItemEx("TinyBurningPiece3", random (-20, 20), random (-20, 20))
			NF4R QRSTUV 1 BRIGHT
			Stop	
	}
}


ACTOR InfernoDemonFireBeamMkII

//***Che: unlike the original one, mine explodes on colliding with anything, 
//  leaving an environmental hazard. Also, explodes if travels up a tall step
//  (so cannot get out of the pit). Also, the fire beam damage is different


{
	Height 10
	Radius 10
	DamageType "Flames"
	Damage (Random(0,0))
//	Obituary "%o was sent to burn in the fires of hell for an eternity."
	PROJECTILE
	+DropOff
	-NoGravity
	+FloorHugger
	-ExtremeDeath
	+DontSplash
//	+Ripper
	Speed 22
	RENDERSTYLE Add
	Alpha 0.75
	
	ReactionTime 50
	//***Che re-purposed it for a meteor dive-bombing sound!
	//ACTIVESOUND "monster/firebeamstart"
	ACTIVESOUND "Infdem/firebeam" // the super loud torch sound from Brutal Doom 19
	//ACTIVESOUND "Infdem/airburst"

	+THRUGHOST
	+MTHRUSPECIES
	XScale 0.5
	YScale 0.7
	var int user_prev_z;
	var int user_prev_x;
	var int user_prev_y;
	var int user_anim_phase;
	DeathSound "fatso/shotx"
	
	states
	{
		Spawn:
			HK04 A 0 NODELAY A_SetUserVar("user_prev_z", z)
			TNT1 A 0 A_SetUserVar("user_prev_x", x)
			TNT1 A 0 A_SetUserVar("user_prev_y", y)
		Travel:	
			TNT1 A 0 A_CountDown
			TNT1 A 0 A_LoopActiveSound
			TNT1 A 0 A_JumpIf(z - user_prev_z > 48, "TooHigh")
			
			TNT1 A 0 A_SetUserVar("user_prev_z", z)
			TNT1 A 0 A_SetUserVar("user_prev_x", x)
			TNT1 A 0 A_SetUserVar("user_prev_y", y)
			TNT1 A 0 A_CustomMissile("BeamFireMkII", 0, 0, 0, 4) // leave a damaging line on the floor
			TNT1 A 0 A_JumpIf(user_anim_phase >= 3, "AnimFrame3")
			TNT1 A 0 A_JumpIf(user_anim_phase == 2, "AnimFrame2")
		AnimFrame1:
			HK04 A 1 BRIGHT A_SetUserVar("user_anim_phase", 2)
			Goto Travel
		AnimFrame2:
			HK04 B 1 BRIGHT A_SetUserVar("user_anim_phase", 3)
			Goto Travel
		AnimFrame3:
			HK04 C 1 BRIGHT A_SetUserVar("user_anim_phase", 1)
			Goto Travel	
		TooHigh:
			// backtrack to our previous position before asplodink:
			TNT1 A 0 A_Warp(AAPTR_DEFAULT, user_prev_x - x, user_prev_y - y, 0, 0, WARPF_ABSOLUTEOFFSET | WARPF_TOFLOOR, "Death")
			TNT1 A 1
			Stop // warp failed: disappear silently
		Death:
			TNT1 A 0
			TNT1 A 0 A_Stop
			TNT1 A 0 A_Scream
			TNT1 A 0 A_CustomMissile("InfernoBurningStuff", 32, 0, 0, CMF_TRACKOWNER | CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH, -90) // fire it straight down from a height of 32
			TNT1 A 0 A_Explode(33, 50, 0)
			TNT1 AAAAAAAA 2 A_CustomMissile ("FireballExplosionFlames", 12, 0, random (0, 360), 2, random (0, 90))
			TNT1 A 30
			Stop
	}
}

ACTOR BeamFireMkII
{
	//Obituary "%o was sent to burn in the fires of hell for an eternity."
	Speed 0
	Scale 0.7
	DamageType "Flames"
	Damage (Random(0,0))
	RENDERSTYLE Add
	+DontSplash
	+ExtremeDeath
	+LowGravity
	+NonShootable
	+NoTeleport
	+Noclip
	+NoBlockMap
	SEESOUND "props/redfire"  //"world/largefire"
	states
	{
		Spawn:
			TNT1 A 5
			HK06 ABC 3 BRIGHT A_Explode(4,16)
			
			//***Che making them *all* play out of sync! 
			// Otherwise it's too synchronized to look like fire,
			// more like a flashing floor of Moire patterns.
			// (i don't want to even think what this does to network bandwidth
			// and multiplayer synchronicity)
			
			HK06 D Random(2,3) BRIGHT A_Explode(2, 16)
			HK06 E Random(2,3) BRIGHT A_Explode(2, 16)
			HK06 F Random(2,3) BRIGHT A_Explode(2, 16)
			HK06 G Random(2,3) BRIGHT A_Explode(2, 16)
			HK06 H Random(2,3) BRIGHT A_Explode(2, 16)
			HK06 I Random(2,3) BRIGHT A_Explode(2, 16)
			HK06 J Random(2,4) BRIGHT A_Explode(2, 16)
			HK06 K Random(2,4) BRIGHT A_Explode(2, 16)
			HK06 L Random(2,4) BRIGHT A_Explode(2, 16)
			HK06 M Random(2,4) BRIGHT A_Explode(2, 16)
			HK06 N Random(2,4) BRIGHT A_Explode(2, 16)
			HK06 O Random(2,4) BRIGHT A_Explode(2, 16)
			Stop
	}
}


ACTOR InfernoDemonFireballMkII //***Che very little changed in this one
{
	Game Doom
	Radius 6
	Height 8
	Speed 35
	FastSpeed 50
	Damage 15
	Projectile
	+RANDOMIZE
	Alpha 1
	Scale 1.2
	SeeSound "imp/attack"
	DeathSound "weapons/rocklx"
	DamageType "Flames"
	+BRIGHT
	RenderStyle Add
	States
	{
	
	Spawn:
		TNT1 A 1
		TNT1 A 0 A_PlaySoundEx("weapons/rocklf", 1, 0, 2)
		Goto Fly
	Fly:
		//***Che three trails per frame
		AF03 D 1 A_SpawnItemEx("InfernoDemonFireballTrail", - momx * 0.1, - momy * 0.1, - momz * 0.1, 0,0,0, 0,SXF_ABSOLUTEPOSITION)
			TNT1 A 0 A_SpawnItemEx("InfernoDemonFireballTrail", - momx * 0.43, - momy * 0.43, - momz * 0.43, 0,0,0, 0,SXF_ABSOLUTEPOSITION)
			TNT1 A 0 A_SpawnItemEx("InfernoDemonFireballTrail", - momx * 0.76, - momy * 0.76, - momz * 0.76, 0,0,0, 0,SXF_ABSOLUTEPOSITION)
		AF03 B 1 A_SpawnItemEx("InfernoDemonFireballTrail", - momx * 0.1, - momy * 0.1, - momz * 0.1, 0,0,0, 0,SXF_ABSOLUTEPOSITION)
			TNT1 A 0 A_SpawnItemEx("InfernoDemonFireballTrail", - momx * 0.43, - momy * 0.43, - momz * 0.43, 0,0,0, 0,SXF_ABSOLUTEPOSITION)
			TNT1 A 0 A_SpawnItemEx("InfernoDemonFireballTrail", - momx * 0.76, - momy * 0.76, - momz * 0.76, 0,0,0, 0,SXF_ABSOLUTEPOSITION)
		TNT1 A 0 A_SpawnItem("RedFlare")
		TNT1 A 0 A_CustomMissile ("SFXTinyExplosionBlackSmoke", 0, 0, random (0, 360), 2, random (10, 40))
		Loop
	Death:
		//***Che nerf explosion but splash napalm
		TNT1 A 0 A_explode(20, 300)
		
		TNT1 AAAAAAAA 0 A_CustomMissile("InfernoIgniter", 24.0, 0.0, Random(-180,180), CMF_AIMDIRECTION | CMF_TRACKOWNER | CMF_SAVEPITCH, Random(5, 70))
		TNT1 A 0 A_SpawnItem ("BigRicoChet", 0, -15)
		TNT1 A 0 A_SpawnItemEx ("DetectFloorCrater",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
	    TNT1 A 0 A_SpawnItemEx ("DetectCeilCrater",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
		TNT1 A 0 A_SpawnItemEx ("ExplosionFlareSpawner",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
        TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAA 0 A_CustomMissile ("ExplosionParticleHeavy", 0, 0, random (0, 360), 2, random (0, 180))
        TNT1 AAAAAA 0 A_CustomMissile ("ExplosionParticleHeavy", 0, 0, random (0, 360), 2, random (0, 180))
		TNT1 AAAAAAA 0 A_CustomMissile ("InfernoDemonFireballExplosion", 0, 0, random (0, 360), 2, random (10, 40))
	    EXPL A 0 Radius_Quake (3, 120, 0, 120, 0)
		BEXP B 0 BRIGHT A_Scream
        TNT1 A 0 A_ALertMonsters
		TNT1 A 0 A_CustomMissile ("SFXSmallExplosionBlackSmoke", 0, 0, random (0, 360), 2, random (10, 40))
		EXP1 ABCDEFGHIJKLMN 2 BRIGHT
		Stop
	}
}


ACTOR InfernoDemonMeteorMkII: InfernoDemonFireballMkII
{
	+SEEKERMISSILE
	Speed 13
	FastSpeed 15
	ACTIVESOUND "monster/firebeamstart"
	
	var int user_count;
	
	RenderStyle Normal
	
	States
	{
	
		Spawn:
			TNT1 A 1
			TNT1 A 0 A_PlaySoundEx("weapons/rocklf", 1, 0, 2)
			TNT1 A 0 ThrustThingZ(0,150,0,1)
			TNT1 A 1 A_SetUserVar("user_count", 42)// 14 * 3
		Ascend:
			// JLOSF_PROJECTILE means use AAPTR_TRACER instead of AAPTR_TARGET
			// 700 is distance to the tracer
			// A_JumpIfTargetInLOS is such a powerful function, 
			//  allows doing so much more than just checking line of sight!
			// This ChebMaster is in love with her!
			TNT1 A 0 A_JumpIf(user_count > 30, 2) // don't burst right away
			TNT1 A 0 A_JumpIfTargetInLOS("SeekAndStartFlying", 0, JLOSF_PROJECTILE | JLOSF_NOSIGHT, 700)
						
			//***Che: well, I love unnecessary fripperies. So what? 
			// There were *tons* of unused assets packed with the infernal
			TNT1 A 0 A_Jump(192, "AscendFlip2", "AscendFlip3", "AscendFlip4")
			TNT1 A 0 A_SetScale(1.0, 1.0)
			Goto AscendAnim
		AscendFlip2:
			TNT1 A 0 A_SetScale(1.0, -1.0)
			Goto AscendAnim
		AscendFlip3:
			TNT1 A 0 A_SetScale(-1.0, 1.0)
			Goto AscendAnim
		AscendFlip4:
			TNT1 A 0 A_SetScale(-1.0, -1.0)
			Goto AscendAnim
		AscendAnim:
			TNT1 A 0 A_Jump(171, "AscendAnim2", "AscendAnim3")
			AF02 A 1 
			Goto AscendTrail
		AscendAnim2:
			AF02 B 1 
			Goto AscendTrail
		AscendAnim3:
			AF02 C 1 
			Goto AscendTrail
		AscendTrail:
			//***Che One is too sparce :( We need three per frame!
			// (and then I will get haunted by the ghosts of players 
			//   who died to the frustration of fighting that rat at the FPS of
			//   one frame per several seconds in TES III Morrowind's portal rooms)
			TNT1 A 0 A_SpawnItemEx("InfernoDemonFireballTrail", - momx * 0.1, - momy * 0.1, - momz * 0.1, 0,0,0, 0,SXF_ABSOLUTEPOSITION)
			TNT1 A 0 A_SpawnItemEx("InfernoDemonFireballTrail", - momx * 0.43, - momy * 0.43, - momz * 0.43, 0,0,0, 0,SXF_ABSOLUTEPOSITION)
			TNT1 A 0 A_SpawnItemEx("InfernoDemonFireballTrail", - momx * 0.76, - momy * 0.76, - momz * 0.76, 0,0,0, 0,SXF_ABSOLUTEPOSITION)
			
			TNT1 A 0 A_JumpIf(user_count % 3, 3) // skip the next two frames 2 times out of 3
			TNT1 A 0 A_SpawnItem("RedFlare")
			TNT1 A 0 A_CustomMissile ("SFXTinyExplosionBlackSmoke", 0, 0, random (0, 360), 2, random (10, 40))
			
			TNT1 A 0 A_SetUserVar("user_count", user_count - 1)
			
			//***Che: keeping its original behavior unchanged, just de-spaghettifying the code
			TNT1 A 0 A_JumpIf(user_count == 39 || user_count == 36 || user_count == 33, "AscendBoost1")
			TNT1 A 0 A_JumpIf(user_count == 32 || user_count == 24 || user_count == 21 || user_count == 15, "AscendBoost2")
			
			TNT1 A 0 A_JumpIf(user_count > 0, "Ascend") 
			Goto SeekAndStartFlying
			
		AscendBoost1: 
			TNT1 A 0 A_Recoil(-4)
			Goto Ascend
		AscendBoost2:
			TNT1 A 0 ThrustThingZ(0,-50,0,1)
			Goto Ascend
			
		SeekAndStartFlying:
			//TNT1 A 0 A_PlaySound("Infdem/meteorseek", 5)
			
			AF02 A 1 A_SeekerMissile (80,90)
			Goto Fly
		
		Fly:
			
			TNT1 A 0 A_JumpIfTargetInLOS("AirburstByProximity", 0, JLOSF_PROJECTILE, 180)
			
			//AirburstByProximity: and then the devilish meteor will HOME on target before spraying!
			// DIRECTED! AT YOU!
			
			TNT1 A 0 A_JumpIf((z - floorz) < 150, "Airburst") // just blow
			
			TNT1 A 0 A_LoopActiveSound
			TNT1 A 0 A_Jump(192, "FlyFlip2", "FlyFlip3", "FlyFlip4")
			TNT1 A 0 A_SetScale(1.0, 1.0)
			Goto FlyAnim
		FlyFlip2:
			TNT1 A 0 A_SetScale(1.0, -1.0)
			Goto FlyAnim
		FlyFlip3:
			TNT1 A 0 A_SetScale(-1.0, 1.0)
			Goto FlyAnim
		FlyFlip4:
			TNT1 A 0 A_SetScale(-1.0, -1.0)
			Goto FlyAnim	
		flyAnim:
			TNT1 A 0 A_Jump(213, "flyAnim2", "flyAnim3", "flyAnim4", "flyAnim5", "flyAnim6")
			AF02 A 1 
			Goto flyTrail
		flyAnim2:
			AF02 B 1 
			Goto flyTrail
		flyAnim3:
			AF02 C 1 
			Goto flyTrail
		flyAnim4:
			AF02 D 1 
			Goto flyTrail			
		flyAnim5:
			AF02 E 1 
			Goto flyTrail			
		flyAnim6:
			AF02 F 1 
			Goto flyTrail
		FlyTrail:
		
			TNT1 A 0 A_SpawnItemEx("InfernoDemonFireballTrail", - momx * 0.1, - momy * 0.1, - momz * 0.1, 0,0,0, 0,SXF_ABSOLUTEPOSITION)
			TNT1 A 0 A_SpawnItemEx("InfernoDemonFireballTrail", - momx * 0.43, - momy * 0.43, - momz * 0.43, 0,0,0, 0,SXF_ABSOLUTEPOSITION)
			TNT1 A 0 A_SpawnItemEx("InfernoDemonFireballTrail", - momx * 0.76, - momy * 0.76, - momz * 0.76, 0,0,0, 0,SXF_ABSOLUTEPOSITION)
			
			TNT1 A 0 A_JumpIf(user_count % 2, 2) // skip the next frame every other frame
			TNT1 A 0 A_SpawnItem("RedFlare")
			TNT1 A 0 A_JumpIf(user_count % 4, 2) // skip the next frame 3 times out of 4
			TNT1 A 0 A_CustomMissile ("SFXTinyExplosionBlackSmoke", 0, 0, random (0, 360), 2, random (10, 40))
			TNT1 A 0 // an obligatory frame to jump to
			
			Goto Fly
		
		AirburstByProximity:
			AF02 A 1 A_SeekerMissile (80,90) // spray the napalm at target. MUHAHAHAHA!
		Airburst: // shower the arena in napalm. SHOWER IT!
			TNT1 A 0 A_Stop
			//TNT1 A 0 A_PlaySound("Infdem/airburst", CHAN_VOICE)
			TNT1 A 0 A_PlaySound("Infdem/meteorseek", CHAN_VOICE)
			TNT1 AAAAAAAAAA 0 A_CustomMissile("InfernoIgniter", 0, 0, Random(-66,66), CMF_AIMDIRECTION | CMF_TRACKOWNER | CMF_OFFSETPITCH, Random(-66, 30))
			BAL3 CDE 3 
			TNT1 A 30
			Stop
			
		Death: // Oh boy, it actually hit something!
			//TNT1 A 0 A_explode(50, 400)
			TNT1 A 0 A_Scream
			TNT1 A 0 A_explode(25, 400) 			
			TNT1 AAAAAAAA 0 A_CustomMissile("InfernoIgniter", 24.0, 0.0, Random(-180,180), CMF_AIMDIRECTION | CMF_TRACKOWNER | CMF_SAVEPITCH, Random(5, 70))
			TNT1 A 0 A_SpawnItem ("BigRicoChet", 0, -15)
			TNT1 A 0 A_SpawnItemEx ("DetectFloorCrater",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
			TNT1 A 0 A_SpawnItemEx ("DetectCeilCrater",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
			TNT1 A 0 A_SpawnItemEx ("ExplosionFlareSpawner",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
			//TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAA 0 A_CustomMissile ("ExplosionParticleHeavy", 0, 0, random (0, 360), 2, random (0, 180))
			//TNT1 AAAAAA 0 A_CustomMissile ("ExplosionParticleHeavy", 0, 0, random (0, 360), 2, random (0, 180))
			TNT1 AAAAAAA 0 A_CustomMissile ("InfernoDemonFireballExplosion", 0, 0, random (0, 360), 2, random (10, 40))
			EXPL A 0 Radius_Quake (3, 120, 0, 120, 0)
			BEXP B 0 BRIGHT A_Scream
			TNT1 A 0 A_ALertMonsters
			TNT1 A 0 A_CustomMissile ("SFXSmallExplosionBlackSmoke", 0, 0, random (0, 360), 2, random (10, 40))
			EXP1 ABCDEFGHIJKLMN 2 BRIGHT
			Stop
	}
}


ACTOR InfernoIgniter // see GoldenIgniter in DECORATE.supercyberdemon for comparison
{
    Radius 4
    Height 4
    Speed 12
	FastSpeed 12 // must NOT be faster, spread too much and become useles as area denial
    Renderstyle Add
	Mass 1
    +NOBLOCKMAP
	+MISSILE
    +NOTELEPORT
    +MOVEWITHSECTOR
    //+RIPPER no rip, explode
    +BLOODLESSIMPACT 
	+NODAMAGETHRUST
    //+DOOMBOUNCE
	+BOUNCEONWALLS // no bouncing on actors
	+BOUNCEONFLOORS
	+EXPLODEONWATER
	+CANBOUNCEWATER
	+SKYEXPLODE
    BounceFactor 0.5
	BounceCount 2
	damagetype "Flames"
	Damage (random (1, 1))
	States 
	{
		Spawn:
			FRPU KJ 1 BRIGHT A_SpawnItemEx("InfernoTinyFlameTrail", 0, 0, 0, 0, 0, 0, 0, 128)
			Loop
		Death:
			TNT1 A 0 A_CustomMissile("InfernoBurningStuff", 16, 0, 0, CMF_TRACKOWNER | CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH, -90)
			TNT1 A 30
			Stop
	}
}

ACTOR InfernoTinyFlameTrail: ExplosionFlames
{
	
	// green and golden versions are EXPG and EXPU correspondingly
	
	Scale 0.5
	States
	{
		Spawn:
			TNT1 A 2
			TNT1 A 0 A_Jump(192, "Spawn2", "Spawn3", "Spawn4")
		Spawn1:	
			TNT1 A 0 
			EXPL C 1 BRIGHT A_SetScale(0.15, 0.15)
			EXPL D 1 BRIGHT A_SetScale(0.2, 0.2)
			EXPL E 1 BRIGHT A_SetScale(0.3, 0.3)
			EXPL F 1 BRIGHT A_SetScale(0.4, 0.4)
			EXPL G 1 BRIGHT A_SetScale(0.5, 0.5)
			Stop
		Spawn2:	
			TNT1 A 0
			EXPL C 1 BRIGHT A_SetScale(-0.15, 0.15)
			EXPL D 1 BRIGHT A_SetScale(-0.2, 0.2)
			EXPL E 1 BRIGHT A_SetScale(-0.3, 0.3)
			EXPL F 1 BRIGHT A_SetScale(-0.4, 0.4)
			EXPL G 1 BRIGHT A_SetScale(-0.5, 0.5)
			Stop
		Spawn3:	
			TNT1 A 0
			EXPL C 1 BRIGHT A_SetScale(0.15, -0.15)
			EXPL D 1 BRIGHT A_SetScale(0.2, -0.2)
			EXPL E 1 BRIGHT A_SetScale(0.3, -0.3)
			EXPL F 1 BRIGHT A_SetScale(0.4, -0.4)
			EXPL G 1 BRIGHT A_SetScale(0.5, -0.5)
			Stop
		Spawn4:	
			TNT1 A 0
			EXPL C 1 BRIGHT A_SetScale(-0.15, -0.15)
			EXPL D 1 BRIGHT A_SetScale(-0.2, -0.2)
			EXPL E 1 BRIGHT A_SetScale(-0.3, -0.3)
			EXPL F 1 BRIGHT A_SetScale(-0.4, -0.4)
			EXPL G 1 BRIGHT A_SetScale(-0.5, -0.5)
			Stop
	}
}
	


	

// ---------------------- Unchanged copy-paste to inherit from  --------------------
// (for old Chebskies 1.x infernal and old Chebskies 1.x beastmaster)

ACTOR EDAY_Infernal //Infernal 12345
{
  Health 15000
  Speed 42
  Radius 60
  Height 140
  Mass 5000
  Damage 40
  Monster
  PainChance 10
  Scale 2.0
  +MISSILEMORE
  +MISSILEEVENMORE
  +BOSS
  +FLOORCLIP
  +TELESTOMP
  +DONTMORPH
  +NOTARGET
  +NOICEDEATH
  MaxDropOffHeight 512
  damagefactor "Blood", 0.0 damagefactor "BlueBlood", 0.0 damagefactor "GreenBlood", 0.0
    damagefactor "Shrapnel", 0.0

  damagefactor "Inferno", 0
  SeeSound "Infdem/see"
  PainSound "Infdem/pain"
  DeathSound "Infdem/death"
  ActiveSound "Infdem/active"
  Obituary "%o was sent to burn in the fires of hell by an Inferno Demon."

  States
  {
  Spawn:
    DIAA A 5 A_Look
    Loop
  See:
    DIAA A 2
	TNT1 A 0 ACS_ExecuteAlways(33, 0, 0, 0, 0)
  Chase:
	DIAA A 2
    DIAA A 0 A_PlaySound("inferno/step", 5)
    DIAA A 0 Radius_Quake(10,5,0,10,0)
	DIAA A 6 A_Chase
    DIAA B 6 A_Chase
    DIAA A 0 A_PlaySound("inferno/step", 5)
    DIAA C 0 Radius_Quake(10,5,0,10,0)
    DIAA C 6 A_Chase
    DIAA D 6 A_Chase
	TNT1 A 0 A_CheckSight("Meteor")
    Goto Chase
  Missile:
  TNT1 A 0
  TNT1 A 0 A_JumpIfCloser(400, "Stomp")
  TNT1 A 0 A_Jump(128, "FireBall")
  TNT1 A 0 A_Jump(64, "sTOMP")
  Goto Meteor
  
  Fireball:
	DIAA E 10 A_FaceTarget
	TNT1 A 0 A_CustomMissile("InfernoDemonFireball",random (90, 180), 90)
	DIAA F 10 A_FaceTarget
	
	DIAA E 10 A_FaceTarget
	TNT1 A 0 A_CustomMissile("InfernoDemonFireball",random (90, 180), -90)
	DIAA F 10 A_FaceTarget
	
	DIAA E 10 A_FaceTarget
	TNT1 A 0 A_CustomMissile("InfernoDemonFireball",random (90, 180), 90)
	DIAA F 10 A_FaceTarget
	
	DIAA E 10 A_FaceTarget
	TNT1 A 0 A_CustomMissile("InfernoDemonFireball",random (90, 180), -90)
	DIAA F 10 A_FaceTarget
	Goto Chase
	
	
	Meteor:
	DIAA E 5 A_FaceTarget
	DIAA G 5 BRIGHT A_CustomMissile("InfernoDemonMETEOR",200, 90)
	DIAA H 5 A_FaceTarget
	
	DIAA E 5 A_FaceTarget
	DIAA G 5 BRIGHT A_CustomMissile("InfernoDemonMETEOR",200, -90)
	DIAA H 5 A_FaceTarget
	
	DIAA E 5 A_FaceTarget
	DIAA G 5 BRIGHT A_CustomMissile("InfernoDemonMETEOR",200, 90)
	DIAA H 5 A_FaceTarget
	
	DIAA E 5 A_FaceTarget
	DIAA G 5 BRIGHT A_CustomMissile("InfernoDemonMETEOR",200, -90)
	DIAA H 5 A_FaceTarget
	
	DIAA E 5 A_FaceTarget
	DIAA G 5 BRIGHT A_CustomMissile("InfernoDemonMETEOR",200, 90)
	DIAA H 5 A_FaceTarget
	DIAA H 20 A_FaceTarget
	Goto Chase
  
  Stomp:
	DIAA B 20 Bright A_FaceTarget
	DIAA B 0 Bright A_CustomMissile("InfernoDemonFireBeam",0,0,0,2,0)
	DIAA B 0 Bright A_CustomMissile("InfernoDemonFireBeam",0,0,20,2,0)
	DIAA B 0 Bright A_CustomMissile("InfernoDemonFireBeam",0,0,40,2,0)
	DIAA B 0 Bright A_CustomMissile("InfernoDemonFireBeam",0,0,60,2,0)
	DIAA B 0 Bright A_CustomMissile("InfernoDemonFireBeam",0,0,80,2,0)
	DIAA B 0 Bright A_CustomMissile("InfernoDemonFireBeam",0,0,-20,2,0)
	DIAA B 0 Bright A_CustomMissile("InfernoDemonFireBeam",0,0,-40,2,0)
	DIAA B 0 Bright A_CustomMissile("InfernoDemonFireBeam",0,0,-60,2,0)
	DIAA B 0 Bright A_CustomMissile("InfernoDemonFireBeam",0,0,-80,2,0)
	DIAA C 0 Radius_Quake(20,35,0,40,0)
    DIAA C 20 Bright
	DIAA B 20 Bright A_FaceTarget
	DIAA B 0 Bright A_CustomMissile("InfernoDemonFireBeam",0,0,0,2,0)
	DIAA B 0 Bright A_CustomMissile("InfernoDemonFireBeam",0,0,20,2,0)
	DIAA B 0 Bright A_CustomMissile("InfernoDemonFireBeam",0,0,40,2,0)
	DIAA B 0 Bright A_CustomMissile("InfernoDemonFireBeam",0,0,60,2,0)
	DIAA B 0 Bright A_CustomMissile("InfernoDemonFireBeam",0,0,80,2,0)
	DIAA B 0 Bright A_CustomMissile("InfernoDemonFireBeam",0,0,-20,2,0)
	DIAA B 0 Bright A_CustomMissile("InfernoDemonFireBeam",0,0,-40,2,0)
	DIAA B 0 Bright A_CustomMissile("InfernoDemonFireBeam",0,0,-60,2,0)
	DIAA B 0 Bright A_CustomMissile("InfernoDemonFireBeam",0,0,-80,2,0)
	DIAA C 0 Radius_Quake(20,35,0,40,0)
    DIAA C 20 Bright
    Goto Chase
  Pain:
    DIAA A 0 A_Pain
	Goto Chase
  Death:
	tnt1 A 0 A_Scream
    DIAA IJKJKJKJ 5
    DIAA K 5 A_FaceTarget
    DIAA L 5 A_Scream
    DIAA MNOPQ 5
	tnt1 a 0 Radius_Quake(5,200,0,5,0)
    DIAA PQRQPQRQPQR 4
    DIAA R 5 A_NoBlocking
    DIAA R 5
    DIAA R 100
	DIAA R 0 A_BrainDie
	DIAA R -1
    Stop
  }
}


ACTOR InfernoDemonFireball
{
	Game Doom
	Radius 6
	Height 8
	Speed 35
	FastSpeed 50
	Damage 15
	Projectile
	+RANDOMIZE
	RenderStyle Translucent
	Alpha 1
	Scale 1.0
	SeeSound "imp/attack"
	DeathSound "weapons/rocklx"
	DamageType "ExplosiveImpact"
	States
	{
	
	Spawn:
		TNT1 A 1
		TNT1 A 0 A_PlaySoundEx("weapons/rocklf", 1, 0, 2)
		Goto Fly
	Fly:
		AF03 AB 1 BRIGHT A_SpawnItem("InfernoDemonFireballTrail")
		TNT1 A 0 A_SpawnItem("RedFlare")
		TNT1 A 0 A_CustomMissile ("SFXTinyExplosionBlackSmoke", 0, 0, random (0, 360), 2, random (10, 40))
		Loop
	Death:
		TNT1 A 0 A_explode(30, 300)
		TNT1 A 0 A_SpawnItem ("BigRicoChet", 0, -15)
		TNT1 A 0 A_SpawnItemEx ("DetectFloorCrater",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
	    TNT1 A 0 A_SpawnItemEx ("DetectCeilCrater",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
		TNT1 A 0 A_SpawnItemEx ("ExplosionFlareSpawner",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
        TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAA 0 A_CustomMissile ("ExplosionParticleHeavy", 0, 0, random (0, 360), 2, random (0, 180))
        TNT1 AAAAAA 0 A_CustomMissile ("ExplosionParticleHeavy", 0, 0, random (0, 360), 2, random (0, 180))
		TNT1 AAAAAAA 0 A_CustomMissile ("InfernoDemonFireballExplosion", 0, 0, random (0, 360), 2, random (10, 40))
	    EXPL A 0 Radius_Quake (3, 120, 0, 120, 0)
		BEXP B 0 BRIGHT A_Scream
        TNT1 A 0 A_ALertMonsters
		TNT1 A 0 A_CustomMissile ("SFXSmallExplosionBlackSmoke", 0, 0, random (0, 360), 2, random (10, 40))
		EXP1 ABCDEFGHIJKLMN 2 BRIGHT
		Stop
	}
}



ACTOR InfernoDemonMeteor: InfernoDemonFireball
{
	+SEEKERMISSILE
	Speed 13
	States
	{
	
		Spawn:
			TNT1 A 1
			TNT1 A 0 A_PlaySoundEx("weapons/rocklf", 1, 0, 2)
			TNT1 A 0 ThrustThingZ(0,150,0,1)
		
		AF03 ABC 1 BRIGHT A_SpawnItem("InfernoDemonFireballTrail")
			TNT1 A 0 A_SpawnItem("RedFlare")
			TNT1 A 0 A_CustomMissile ("SFXTinyExplosionBlackSmoke", 0, 0, random (0, 360), 2, random (10, 40))
			TNT1 A 0 A_SpawnItem("InfernoDemonFireballTrail")
			TNT1 A 0 A_Recoil(-4)
		AF03 ABC 1 BRIGHT A_SpawnItem("InfernoDemonFireballTrail")
			TNT1 A 0 A_SpawnItem("RedFlare")
			TNT1 A 0 A_CustomMissile ("SFXTinyExplosionBlackSmoke", 0, 0, random (0, 360), 2, random (10, 40))
			TNT1 A 0 A_SpawnItem("InfernoDemonFireballTrail")
			TNT1 A 0 A_Recoil(-4)
		AF03 ABC 1 BRIGHT A_SpawnItem("InfernoDemonFireballTrail")
			TNT1 A 0 A_SpawnItem("RedFlare")
			TNT1 A 0 A_CustomMissile ("SFXTinyExplosionBlackSmoke", 0, 0, random (0, 360), 2, random (10, 40))
			TNT1 A 0 A_SpawnItem("InfernoDemonFireballTrail")
			
			TNT1 A 0 ThrustThingZ(0,-50,0,1)
			TNT1 A 0 A_Recoil(-4)
			AF03 ABC 1 BRIGHT A_SpawnItem("InfernoDemonFireballTrail")
			TNT1 A 0 A_SpawnItem("RedFlare")
			TNT1 A 0 A_CustomMissile ("SFXTinyExplosionBlackSmoke", 0, 0, random (0, 360), 2, random (10, 40))
			TNT1 A 0 A_SpawnItem("InfernoDemonFireballTrail")
			
			AF03 ABC 1 BRIGHT A_SpawnItem("InfernoDemonFireballTrail")
			TNT1 A 0 A_SpawnItem("RedFlare")
			TNT1 A 0 A_CustomMissile ("SFXTinyExplosionBlackSmoke", 0, 0, random (0, 360), 2, random (10, 40))
			TNT1 A 0 A_SpawnItem("InfernoDemonFireballTrail")
			AF03 ABC 1 BRIGHT A_SpawnItem("InfernoDemonFireballTrail")
			TNT1 A 0 A_SpawnItem("RedFlare")
			TNT1 A 0 A_CustomMissile ("SFXTinyExplosionBlackSmoke", 0, 0, random (0, 360), 2, random (10, 40))
			TNT1 A 0 A_SpawnItem("InfernoDemonFireballTrail")
			AF03 ABC 1 BRIGHT A_SpawnItem("InfernoDemonFireballTrail")
			TNT1 A 0 A_SpawnItem("RedFlare")
			TNT1 A 0 A_CustomMissile ("SFXTinyExplosionBlackSmoke", 0, 0, random (0, 360), 2, random (10, 40))
			TNT1 A 0 A_SpawnItem("InfernoDemonFireballTrail")
			TNT1 A 0 ThrustThingZ(0,-50,0,1)
			AF03 ABC 1 BRIGHT A_SpawnItem("InfernoDemonFireballTrail")
			TNT1 A 0 A_SpawnItem("RedFlare")
			TNT1 A 0 A_CustomMissile ("SFXTinyExplosionBlackSmoke", 0, 0, random (0, 360), 2, random (10, 40))
			TNT1 A 0 A_SpawnItem("InfernoDemonFireballTrail")
			AF03 ABC 1 BRIGHT A_SpawnItem("InfernoDemonFireballTrail")
			TNT1 A 0 A_SpawnItem("RedFlare")
			TNT1 A 0 ThrustThingZ(0,-50,0,1)
			TNT1 A 0 A_CustomMissile ("SFXTinyExplosionBlackSmoke", 0, 0, random (0, 360), 2, random (10, 40))
			TNT1 A 0 A_SpawnItem("InfernoDemonFireballTrail")
			AF03 ABC 1 BRIGHT A_SpawnItem("InfernoDemonFireballTrail")
			TNT1 A 0 A_SpawnItem("RedFlare")
			TNT1 A 0 A_CustomMissile ("SFXTinyExplosionBlackSmoke", 0, 0, random (0, 360), 2, random (10, 40))
			TNT1 A 0 A_SpawnItem("InfernoDemonFireballTrail")
			TNT1 A 0 ThrustThingZ(0,-50,0,1)
			AF03 ABC 1 BRIGHT A_SpawnItem("InfernoDemonFireballTrail")
			TNT1 A 0 A_SpawnItem("RedFlare")
			TNT1 A 0 A_CustomMissile ("SFXTinyExplosionBlackSmoke", 0, 0, random (0, 360), 2, random (10, 40))
			TNT1 A 0 A_SpawnItem("InfernoDemonFireballTrail")
			
			
		   AF03 AB 1 BRIGHT A_SpawnItem("InfernoDemonFireballTrail")
			TNT1 A 0 A_SpawnItem("RedFlare")
			TNT1 A 0 A_CustomMissile ("SFXTinyExplosionBlackSmoke", 0, 0, random (0, 360), 2, random (10, 40))
			TNT1 A 0 A_SpawnItem("InfernoDemonFireballTrail")	
			TNT1 A 1 A_SeekerMissile (80,90)	
			
			AF03 AB 1 BRIGHT A_SpawnItem("InfernoDemonFireballTrail")
			TNT1 A 0 A_SpawnItem("RedFlare")
			TNT1 A 0 A_CustomMissile ("SFXTinyExplosionBlackSmoke", 0, 0, random (0, 360), 2, random (10, 40))
			TNT1 A 0 A_SpawnItem("InfernoDemonFireballTrail")	
			TNT1 A 1 A_SeekerMissile (80,90)	
			
			AF03 AB 1 BRIGHT A_SpawnItem("InfernoDemonFireballTrail")
			TNT1 A 0 A_SpawnItem("RedFlare")
			TNT1 A 0 A_CustomMissile ("SFXTinyExplosionBlackSmoke", 0, 0, random (0, 360), 2, random (10, 40))
			TNT1 A 0 A_SpawnItem("InfernoDemonFireballTrail")	
			TNT1 A 1 A_SeekerMissile (80,90)	
		Goto Fly
		Fly:
			AF03 AB 1 BRIGHT A_SpawnItem("InfernoDemonFireballTrail")
			TNT1 A 0 A_SpawnItem("RedFlare")
			AF03 CB 1 BRIGHT A_SpawnItem("InfernoDemonFireballTrail")
			TNT1 A 0 A_SpawnItem("RedFlare")
			TNT1 A 0 A_CustomMissile ("SFXTinyExplosionBlackSmoke", 0, 0, random (0, 360), 2, random (10, 40))
			Loop
		Death:
			TNT1 A 0 A_explode(50, 400)
			TNT1 A 0 A_SpawnItem ("BigRicoChet", 0, -15)
			TNT1 A 0 A_SpawnItemEx ("DetectFloorCrater",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
			TNT1 A 0 A_SpawnItemEx ("DetectCeilCrater",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
			TNT1 A 0 A_SpawnItemEx ("ExplosionFlareSpawner",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
			TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAA 0 A_CustomMissile ("ExplosionParticleHeavy", 0, 0, random (0, 360), 2, random (0, 180))
			TNT1 AAAAAA 0 A_CustomMissile ("ExplosionParticleHeavy", 0, 0, random (0, 360), 2, random (0, 180))
			TNT1 AAAAAAA 0 A_CustomMissile ("InfernoDemonFireballExplosion", 0, 0, random (0, 360), 2, random (10, 40))
			EXPL A 0 Radius_Quake (3, 120, 0, 120, 0)
			BEXP B 0 BRIGHT A_Scream
			TNT1 A 0 A_ALertMonsters
			TNT1 A 0 A_CustomMissile ("SFXSmallExplosionBlackSmoke", 0, 0, random (0, 360), 2, random (10, 40))
			EXP1 ABCDEFGHIJKLMN 2 BRIGHT
			Stop
	}
}




//***Che this is never used. I can guess to why.
// Some things man was simply not meantt to play.

ACTOR InfernoDemonMeteorSeeker: InfernoDemonMeteor
{
	+SEEKERMISSILE
	Speed 30
	States
	{
	
		Spawn:
			AF03 ABC 1 BRIGHT A_SpawnItem("InfernoDemonFireballTrail")
				TNT1 A 0 A_SpawnItem("RedFlare")
				TNT1 A 0 A_CustomMissile ("SFXTinyExplosionBlackSmoke", 0, 0, random (0, 360), 2, random (10, 40))
			AF03 ABC 1 BRIGHT A_SpawnItem("InfernoDemonFireballTrail")
				TNT1 A 0 A_SpawnItem("RedFlare")
				TNT1 A 0 A_CustomMissile ("SFXTinyExplosionBlackSmoke", 0, 0, random (0, 360), 2, random (10, 40))
			AF03 ABC 1 BRIGHT A_SpawnItem("InfernoDemonFireballTrail")
				TNT1 A 0 A_SpawnItem("RedFlare")
				TNT1 A 0 A_CustomMissile ("SFXTinyExplosionBlackSmoke", 0, 0, random (0, 360), 2, random (10, 40))
				TNT1 A 1 A_SeekerMissile (5,5)
				Loop
		
	
	}
}


ACTOR InfernoDemonFireballTrail
{
	+MISSILE
	+NOGRAVITY
	+THRUACTORS
	+CLIENTSIDEONLY
	RenderStyle Add
	Alpha 1
	Speed 1
	SCALE 1.0
	States
	{
	Spawn:
	    TNT1 A 1
		AF03 ABCDEFGHI 1 BRIGHT
		Stop
	}
}



ACTOR InfernoDemonFireballExplosion
{
	+MISSILE
	+NOGRAVITY
	+THRUACTORS
	+CLIENTSIDEONLY
	RenderStyle Add
	Alpha 1
	Speed 2
	SCALE 1.0
	Radius 1
	Height 1
	States
	{
		Spawn:
			TNT1 A 1
			Goto Death
		
		Death:
			FRME ABCDEFGHIJKLMNOPQRS 2 BRIGHT
			Stop
	}
}

ACTOR InfernoDemonFireBeam
{
	Height 10
	Radius 10
	DamageType "Inferno"
	Obituary "%o was sent to burn in the fires of hell for an eternity."
	PROJECTILE
	+DropOff
	-NoGravity
	+FloorHugger
	+ExtremeDeath
	+DontSplash
	+Ripper
	Speed 22
	Scale 0.5
	RENDERSTYLE Add
	Alpha 0.75
	Damage 10
	ReactionTime 50
	ACTIVESOUND "monster/firebeamstart"
	states
	{
		Spawn:
			HK04 A 0 
			HK04 A 0 A_CountDown
			HK04 A 0 A_LoopActiveSound
			HK04 ABC 1 BRIGHT A_CustomMissile("BeamFire", 0, 0, 0, 4)
			HK04 A 0 A_SeekerMissile (10, 25)
			Goto Spawn+1
			Death:
			HK04 ABC 4
			Stop
	}
}

ACTOR BeamFire
{
	Obituary "%o was sent to burn in the fires of hell for an eternity."
	Speed 0
	Scale 0.5
	DamageType "Inferno"
	RENDERSTYLE Add
	+DontSplash
	+ExtremeDeath
	+LowGravity
	+NonShootable
	+NoTeleport
	+Noclip
	+NoBlockMap
	SEESOUND "world/largefire"
	states
	{
		Spawn:
			TNT1 A 5
			HK06 ABC 3 BRIGHT A_Explode(1,8)
			HK06 DEFGHIJKLMNO 3 BRIGHT A_Explode(1, 8)
			Stop
	}
}




// ---------------------- End of unchanged copy-paste -------------------------


// ------------------------------ Chebskies 2.0 missiles ---------------------

ACTOR InfernoDemonFireBeam2: InfernoDemonFireBeam
{
	DamageType "Flames"
	States
	{
		Spawn:
			HK04 A 0 
			HK04 A 0 A_CountDown
			HK04 A 0 A_LoopActiveSound
			HK04 ABC 1 BRIGHT A_CustomMissile("BeamFire2", 0, 0, 0, 4)
			HK04 A 0 A_SeekerMissile (10, 25)
			Goto Spawn+1
			Death:
			HK04 ABC 4
			Stop	
	}
}

ACTOR BeamFire2: BeamFire
{
	DamageType "Flames"
}

ACTOR InfernoDemonFireball2: InfernoDemonFireball
{
	DamageType "Flames"
}

ACTOR InfernoDemonMeteor2: InfernoDemonMeteor
{
	DamageType "Flames"
}



// ------------------------------- OLD CHEBSKIES 1.x --------------------------

//***Che P.S. Obsoleted, will remove as soon as I reskin the map 311 beastmaster to a motherdemon

//P.P.S. Removed. Good riddance.


/*

Actor RecoloredInfernal: EDAY_Infernal 12345 //replaces Infernal 12345

// Iinfernal is a perfect boss, I do not want to even breathe in the direction of its code
// But did it have to be so DULL ? :(

// Unfortunately there is no way to edit sprites using Curves in The GIMP because it doesn't understand the concept of hotspot, loses sprite's origin.
// So I had to use SLADE, with its limited options. Meaning converting to greyscale -- losing differently colored eayes, alas.
// I then applied an equivalent of Levels making him bright grayscale, converted him to doom palette and set up a palette translation 
//
// The sprites themselves are kept as bright grayscale and override the ones from EDAY.



{
	
	//+BRIGHT
	//Translation "80:84=208:213", "4:4=226:226", "84:108=16:47", "109:111=239:239"
	
	// by some reason he had no name set. I cannot allow the scripts using his class name, obviously.
	Tag "$INFERNAL"
	Obituary "$INFERNAL_O"
	// health 15000
	
	damagefactor "Desintegrate", 0.6 // bfg 9000 & Unmaker
	
	States {
		See:
			DIAA A 2
			TNT1 A 0 ACS_NamedExecuteAlways("DisplayBossHealth", 0, 0, 0, 0)
			Goto Chase
		Death:
			// must override because we need to kill all monsters on his death
			tnt1 A 0 A_Scream
			DIAA IJKJKJKJ 5
			DIAA K 5 A_FaceTarget
			DIAA L 5 A_Scream
			DIAA MNOPQ 5
			tnt1 a 0 Radius_Quake(5,200,0,5,0)
			DIAA PQRQPQRQPQR 4
			DIAA R 5 ACS_NamedExecuteAlways("KillAllMonsters", 0, 0, 0, 0)
			DIAA R 5 A_NoBlocking
			DIAA R 5
			DIAA R 100 A_BrainDie
			DIAA R -1
			Stop
		Meteor:
			// overriding because I added a mirrored lef-handed frame
			DIAA E 5 A_FaceTarget
			DIAA G 5 BRIGHT A_CustomMissile("InfernoDemonMETEOR",200, 90)
			DIAA H 5 A_FaceTarget
			
			DIAA E 5 A_FaceTarget
			DIAA G 5 BRIGHT A_CustomMissile("InfernoDemonMETEOR",200, -90)
			DIAA H 5 A_FaceTarget
			
			DIAA E 5 A_FaceTarget
			DIAA G 5 BRIGHT A_CustomMissile("InfernoDemonMETEOR",200, 90)
			DIAA H 5 A_FaceTarget
			
			DIAA E 5 A_FaceTarget
			DIAA G 5 BRIGHT A_CustomMissile("InfernoDemonMETEOR",200, -90)
			DIAA H 5 A_FaceTarget
			
			DIAA E 5 A_FaceTarget
			DIAA G 5 BRIGHT A_CustomMissile("InfernoDemonMETEOR",200, 90)
			DIAA H 5 A_FaceTarget
			DIAA H 20 A_FaceTarget
			Goto Chase
	}
}

Actor RecoloredInfernalMP: RecoloredInfernal 12344 //replaces InfernalMultiplayer 12344 {
{
	Health 20000
}

Actor RecoloredInfernalITYTD: RecoloredInfernal 17541 {
	Health 9000
	Tag "$INFERNAL_ITYTD"
}

Actor MasterIsDeadGoFeral: Inventory
{
	inventory.maxamount 1
}

Actor PinkySummon: FBD_BullDemon {
	Tag "$ATTACK_PINKY" // Trained Attack Pinky
	Obituary "$INFERNAL2_O" // %o was harried by Inferrnal Pinkie Beastmaster.
	-COUNTKILL
	+NEVERRESPAWN
	States {
		Spawn:
			TNT1 A 0
			TNT1 A 0 ACS_NAMEDExecuteAlways("IAmLobbedOk", 0, 0, 0, 0) 
			// We cannot rely on the boss managing his own ammo count
			// because he can't know if spawning failed due to a wall in the way.
			// Accessing master's inventory is not supported by Zandronum, so we rely on map ACS
			// that addresses the boss by his tid
			
			// they spawn lobbed at high velocity through the air
			// first, the crouched posture from BDv21 monster fatalities (eating a corpse)
			PDEV B 1 
			PDEV B 7 A_PlaySound("demon/melee", 4) // boss has no firing sound for this
			// then, the leaping frame
			SAPC B 15
			Goto See
		GoFeral:
			// basically there is no way to clear the minion status (that I know of) so for them to stop being minions,
			// they spawn a feral variant in their place, then disappear
			TNT1 A 0
			TNT1 A 0 A_ChangeFlag("THRUACTORS", 1)
			TNT1 A 0 A_SpawnItemEx ("PinkySummonGoneFeral",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION, 0, 95) // 98) //SXF_NOPOINTERS,0, 99) 
			// TIDs 95..99 are reserved for minion infighting. When editing the map make sure not to use these 99 for anything.
			// without SXF_NOPOINTERS the spawned ferals STILL cannot harm each other, even with +DOHARMSPECIES
			TNT1 A 0
			Stop // be gone
			// So the master on his deathbed calls ACS_NamedExecute("MasterIsDeadGoFeral"), which is keeping in an infinite loop to give actors with TID = 99 inventory item "MasterIsDeadGoFeral" - which makes them switch to their going feral mechanics
		
		Forget:	
			TNT1 A 0
			TNT1 A 0 A_ClearTarget
			TNT1 A 0 A_TakeInventory("EnemyMemory", 15)
			TNT1 A 0 A_Jump(256, "SearchPlayer")
			Goto MultiplayerOopsnik //Stop // the same Zandronum quirk, skipping over A_Jump(256,) straight to Stop,
				// resulting in monster disappearing clientside but not serverside.
				// The end result is an invisible monster!
			
		MultiplayerOopsnik:
			TNT1 A 0
			TNT1 A 0 A_Jump(256, "SearchPlayer")
			Loop
		
		SearchPlayer:
		Idle:
			SARG YZ 10 A_Look
			TNT1 A 0 A_SetAngle(angle - 40)
			SARG YZ 10 A_Look
			TNT1 A 0 A_SetAngle(angle + 40)
			SARG YZ 10 A_Look
			
			
			SARG A 0 A_Wander
			SARG A 2 A_Look
			SARG A 0 A_Wander
			SARG A 2 A_Look
			SARG B 0 A_Wander
			SARG B 2 A_Look
			SARG B 0 A_Wander
			SARG B 2 A_Look
			SARG C 0 A_Wander
			SARG C 2 A_Look
			SARG C 0 A_Wander
			SARG C 2 A_Look
			SARG D 0 A_Wander
			SARG D 2 A_Look
			SARG D 0 A_Wander
			SARG D 2 A_Look
			
			TNT1 A 0 A_Jump(128, "SearchPlayer")
			
			SARG A 0 A_Wander
			SARG A 2 A_Look
			SARG A 0 A_Wander
			SARG A 2 A_Look
			SARG B 0 A_Wander
			SARG B 2 A_Look
			SARG B 0 A_Wander
			SARG B 2 A_Look
			SARG C 0 A_Wander
			SARG C 2 A_Look
			SARG C 0 A_Wander
			SARG C 2 A_Look
			SARG D 0 A_Wander
			SARG D 2 A_Look
			SARG D 0 A_Wander
			SARG D 2 A_Look
			
			TNT1 A 0 A_Jump(256, "SearchPlayer")
			Stop
		
		See:
			TNT1 A 0
			TNT1 A 0 A_CheckSight("SeeNeverSeen")
			TNT1 A 0 A_Jump(256, "SeeContinue")
			Goto MultiplayerOopsnik //Stop
		
		SeeContinue:
			TNT1 A 0
			TNT1 A 0 A_JumpIfInventory("MasterIsDeadGoFeral", 1, "GoFeral")
			
			// copy-paste of original SeeContinue
			TNT1 A 0 A_JumpIfInventory("ZombieManFatality", 1, "FatalityZombieman")
			TNT1 A 0 A_JumpIfInventory("SergeantFatality", 1, "FatalitySergeant")
			TNT1 A 0 A_JumpIfInventory("ImpFatality", 1, "FatalityImp")
			TNT1 A 0 A_JumpIfInventory("ComandoFatality", 1, "FatalityComando")
			TNT1 A 0 A_JumpIfInventory("ComeEatMeDemon", 1, "EnragedSee")
			TNT1 A 0 A_CheckSight("SeeNoSee")
			TNT1 A 0 A_JumpIfInventory("EatMe", 1, "Eat")
			//TNT1 A 0 A_SpawnItemEx("FootSep6", 0, 0, 30, 0, 0)
			TNT1 A 0 A_TakeInventory("EnemyMemory", 17)
			SARG AA 2 A_Chase
			SARG BB 2 A_Chase
			//TNT1 A 0 A_SpawnItemEx("FootSep6", 0, 0, 30, 0, 0)
			SARG CC 2 A_Chase
			SARG DD 2 A_Chase
			TNT1 A 0 A_JumpIfInTargetInventory("IsInvisible", 1, "Idle")
			Loop
			
		SeeNeverSeen:
			TNT1 A 0
			TNT1 A 0 A_JumpIfInventory("MasterIsDeadGoFeral", 1, "GoFeral")
		
			// copy-paste of the original SeeNeverSeen
			//TNT1 A 0 A_SpawnItemEx("FootSep6", 0, 0, 30, 0, 0)
			SARG AA 2 A_Chase("Melee", "")
			SARG BB 2 A_Chase
			SARG CC 2 A_Chase
			SARG DD 2 A_Chase
			Loop
			
		SeeNoSee:
			//TNT1 A 0 A_SpawnItemEx("FootSep6", 0, 0, 30, 0, 0)
			SARG AA 2 A_Chase
			SARG BB 2 A_Chase
			SARG CC 2 A_Chase
			SARG DD 2 A_Chase
			TNT1 A 0 A_GiveInventory("EnemyMemory", 1)
			TNT1 A 0 A_JumpIfInventory("EnemyMemory", 15, "Forget")
			TNT1 A 0 A_Jump(256, "See")
			Goto MultiplayerOopsnik //Stop

		Idle:
			TNT1 A 0
			TNT1 A 0 A_JumpIfInventory("MasterIsDeadGoFeral", 1, "GoFeral")
			
			// copy-paste of the original Idle
			SARG YZ 10 A_Look
			TNT1 A 0 A_JumpIfInventory("MasterIsDeadGoFeral", 1, "GoFeral")
			TNT1 A 0 A_SetAngle(angle - 40)
			SARG YZ 10 A_Look
			TNT1 A 0 A_JumpIfInventory("MasterIsDeadGoFeral", 1, "GoFeral")
			TNT1 A 0 A_SetAngle(angle + 40)
			SARG YZ 10 A_Look
			TNT1 A 0 A_JumpIfInventory("MasterIsDeadGoFeral", 1, "GoFeral")
			
			
			SARG A 0 A_Wander
			SARG A 2 A_Look
			SARG A 0 A_Wander
			SARG A 2 A_Look
			SARG B 0 A_Wander
			SARG B 2 A_Look
			SARG B 0 A_Wander
			SARG B 2 A_Look
			SARG C 0 A_Wander
			SARG C 2 A_Look
			SARG C 0 A_Wander
			SARG C 2 A_Look
			SARG D 0 A_Wander
			SARG D 2 A_Look
			SARG D 0 A_Wander
			SARG D 2 A_Look
			
			TNT1 A 0 A_JumpIfInventory("MasterIsDeadGoFeral", 1, "GoFeral")			
			TNT1 A 0 A_Jump(128, "SearchPlayer")
			
			SARG A 0 A_Wander
			SARG A 2 A_Look
			SARG A 0 A_Wander
			SARG A 2 A_Look
			SARG B 0 A_Wander
			SARG B 2 A_Look
			SARG B 0 A_Wander
			SARG B 2 A_Look
			SARG C 0 A_Wander
			SARG C 2 A_Look
			SARG C 0 A_Wander
			SARG C 2 A_Look
			SARG D 0 A_Wander
			SARG D 2 A_Look
			SARG D 0 A_Wander
			SARG D 2 A_Look
			TNT1 A 0 A_JumpIfInventory("MasterIsDeadGoFeral", 1, "GoFeral")
			
			Goto SearchPlayer
		
		EnragedSee:
			TNT1 A 0
			TNT1 A 0 A_JumpIfInventory("MasterIsDeadGoFeral", 1, "GoFeral")
			
			// copy-paste of the original EnragedSee
			TNT1 A 0 A_JumpIfInventory("EatMe", 1, "Eat")
			TNT1 A 0 A_TakeInventory("EnemyMemory", 17)
			SARG A 1 A_Chase("Melee", "")
			SARG A 2 A_Chase("Melee", "")
			SARG B 1 A_Chase("Melee", "")
			SARG B 2 A_Chase("Melee", "")
			SARG C 1 A_Chase("Melee", "")
			SARG C 2 A_Chase("Melee", "")
			SARG D 1 A_Chase("Melee", "")
			SARG D 2 A_Chase("Melee", "")
			TNT1 A 0 A_FaceTarget
			TNT1 A 0 A_JumpIfInTargetInventory("IsInvisible", 1, "Idle")
			Loop
	}		
}

Actor MultiplayerPinkySummon: PinkySummon { // the same as a regular stoneskin pinky but without checking if caster is dead and WITHOUT ELEMENTAL VULNERABILITIES
	Tag "Multiplayer MegaPinky"
	Obituary "%o was mauled by a Multiplayer MegaPinky."
	Translation "16:37=250:254" // bright purple
	Health 2000 // ten times as durable
	damagefactor "SSG", 2.0 // original has 50x
}	

Actor PinkySummonGoneFeral: FBD_BullDemon {
	Tag "$FERAL_PINKY" // Feral Pinky
	-COUNTKILL
	-DONTHARMCLASS
	-DONTHARMSPECIES
	+DOHARMSPECIES
	+NEVERRESPAWN
	// Lo and behold, normal pinkies cannot harm each other as well. 
	// Because in BD their bite attacks are projectiles.
	// They can, however, miss and bite a wrong target -- if that target is not a pinky
	Obituary "$FERAL_PINKY_O" // %o managed to get killed by pinkies gone feral
	Damagetype Saw
	States {
		Spawn:
			SARG Y 1
			SARG Y 1 ACS_NAmedExecuteAlways("ImmaFeralRawr", 0, 0, 0, 0) // sets TID to 96..98 and causes infighting
			TNT1 A 0 A_Jump (256, "Pain")
			
			Goto MultiplayerOopsnik //Stop
			
		MultiplayerOopsnik:
			TNT1 A 0
			TNT1 A 0 A_Jump(256, "Pain")
			Loop	
			
			// the following stages are copy-pasted to change the attack type (to AOE bite that can harm anyone
			// (INCLUDING the originator!)
		Melee:
			TNT1 A 0
			TNT1 A 0 A_JumpIfCloser(70, "Bite")
			TNT1 A 0
			TNT1 A 0 A_PlaySound("demon/melee", 4)
			TNT1 A 0 A_TakeInventory("EnemyMemory", 100)
			
			SAPC A 5 A_FaceTarget
			SARG E 3 A_FaceTarget
			TNT1 A 0 ThrustThingZ(0,25,0,1)
			TNT1 A 0 A_Recoil(-10)
			SAPC B 5 
			SARG GGG 4 A_CustomMissile("FeralPinkyAttack",40,0,0,2)
			//TNT1 A 0 A_CustomMissile("FeralPinkyAttack",5,0,0,2)
			SARG G 6
			TNT1 A 0 A_JumpIfCloser(70, "Bite")
			Goto SeeContinue
			
		Bite:	
			SARG G 0 A_FaceTarget
			TNT1 A 0 A_PlaySound("demon/melee", 4)
			TNT1 A 0 A_Recoil(-15)
			TNT1 A 0 A_TakeInventory("EnemyMemory", 100)
			TNT1 A 0 A_JumpIfInTargetInventory("ComeEatMeDemon", 1, "MeleeDown")
			SARG E 6 A_FaceTarget
			SARG F 6 A_FaceTarget
			TNT1 A 0 A_CustomMissile("FeralPinkyAttack",40,0,0,2)
			SARG G 12 A_CustomMissile("FeralPinkyAttack",5,0,0,2)
			Goto SeeContinue
			
			
		MeleeDown:
			PDEV A 6 A_FaceTarget
			PDEV B 6 A_FaceTarget
			PDEV C 12 A_CustomMissile("FeralPinkyAttack",5,0,0,0)			
	}		
}

ACTOR FeralPinkyAttack: DemonAttack
{
    +BLOODLESSIMPACT // prevent framerate dying because pinky bites are *ripper* projectiles
	Damagetype Saw
	Damage (random(1,1)) // useles. The only one they can harm with this is the player.
	States
	{
		Death:
			TNT1 A 0 BRIGHT
			TNT1 A 0 A_Explode(random(4,8), 64)
			TNT1 A 0 A_PlaySOund ("misc/xdeath1")
			TNT1 A 10
			Stop
	}
}


Actor InitialPinkySpam: Inventory
{
	inventory.maxamount 30
}

Actor PinkyReserve: Inventory
{
	inventory.maxamount 666
}

Actor PinkieInfernal: EDAY_Infernal 17540
{
	Health 9000 // he's a nightmare as he is
	//Translation "80:84=208:213", "4:4=226:226", "84:108=16:47", "109:111=239:239"
	// I wanted him pink but green looks so much cooler. Besides, there are so few green monsters in DooM.

	//Translation "4:4=112:112", "80:90=112:112", "91:107=112:125", "107:111=125:127"
	Tag "$INFERNAL2" // Infernal Pinkie Beastmaster
	Obituary "$INFERNAL_O" //%o was sent to burn in the fires of hell by an Inferno Demon.
	
	States {
		Spawn:
			TNT1 A 0 
			TNT1 A 0 A_JumpIfInventory("PinkyReserve", 1, 3) // why the heck is his Spawn stage gets called again if you die
			TNT1 A 0 A_GiveInventory("InitialPinkySpam", 30)
			TNT1 A 0 A_GiveInventory("PinkyReserve", 266)
			TNT1 A 0 A_GiveInventory("TargetIsAGreatTerribleBoss")
			TNT1 A 0
			Goto SitAndWait
		SitAndWait:
			DIAA A 5 A_Look
			Loop
		See:
			DIAA A 2
			TNT1 A 0 ACS_NamedExecuteAlways("DisplayBossHealth", 0, 0, 0, 0)
			TNT1 A 0
			
			// another example: the multiplayer variant was spawning his first minions as regular pinkies 
			// instead of multiplayer megapinkies, BECAUSE goto goes to this classes' Meteor,
			// not that derived classes'
			//Goto Meteor
			TNT1 A 0 A_Jump(256, "Meteor")
			Goto Chase //Zandronum multiplayer client oopsnik -- skips "A_Jump(256" galore!
			
		Death:
			// must override because we do NOT need A_BrainDie on this one
			tnt1 A 0 A_Scream
			
			DIAA IJKJKJKJ 5
			//tnt1 A 0 A_GiveToChildren("MasterIsDeadGoFeral", 1)
			//Script error, "chebskies.pk3:decorate.infernals_set" line 209:
			//Invalid state parameter a_givetochildren
			TNT1 A 0 ACS_NamedExecute("MasterIsDeadGoFeral") // see the map script thar gives actors with tid 99 that item
			
			DIAA K 5 A_FaceTarget
			DIAA L 5 A_Scream
			DIAA MNOPQ 5
			tnt1 a 0 Radius_Quake(5,200,0,5,0)
			DIAA PQRQPQRQPQR 4
			DIAA R 5 A_NoBlocking
			DIAA RRRRRRRRRR 10 ACS_NamedExecute("MasterIsDeadGoFeral") // gradually causes the minions to start infighting
			DIAA R 1800
			DIAA R -1
			Stop
		
		// cannot use meteor attack because ceiling in the temple not high enough.
		// fires pinkies instead of homing meteors
		Meteor:
			DIAA E 2 A_FaceTarget
			TNT1 A 0 A_JumpIfInventory("PinkyReserve", 1, 1) // jumps on zero items, in combination with the skippable goto below
			Goto Missile2 
			DIAA G 3 A_SpawnItemEx("PinkySummon", 100, 90, 42, 30, 0, 10, 0, SXF_SETMASTER | SXF_TRANSFERPOINTERS, 0, 99)
			TNT1 A 0 A_TakeInventory("InitialPinkySpam", 1)
			
			//fails too often //TNT1 A 0 A_TakeInventory("PinkyReserve", 1)
			// summons themselves decrease his inventory on successful spawn via ACS, addressing him by his TID=666
			
			//A_CustomMissile("InfernoDemonMETEOR",200, 90)
			DIAA H 3 A_FaceTarget

			DIAA E 2 A_FaceTarget
			TNT1 A 0 A_JumpIfInventory("PinkyReserve", 1, 1) // jumps on zero items, in combination with the skippable goto below
			Goto Missile2 
			DIAA G 3 A_SpawnItemEx("PinkySummon", 100, -90, 42, 30, 0, 10, 0, SXF_SETMASTER | SXF_TRANSFERPOINTERS, 0, 99)
			TNT1 A 0 A_TakeInventory("InitialPinkySpam", 1)
			//fails too often //TNT1 A 0 A_TakeInventory("PinkyReserve", 1)
			//A_CustomMissile("InfernoDemonMETEOR",200, 90)
			DIAA H 3 A_FaceTarget
			
			DIAA E 2 A_FaceTarget
			TNT1 A 0 A_JumpIfInventory("PinkyReserve", 1, 1) // jumps on zero items, in combination with the skippable goto below
			Goto Missile2 
			DIAA G 3 A_SpawnItemEx("PinkySummon", 100, 90, 42, 30, 0, 10, 0, SXF_SETMASTER | SXF_TRANSFERPOINTERS, 0, 99)
			TNT1 A 0 A_TakeInventory("InitialPinkySpam", 1)
			//fails too often //TNT1 A 0 A_TakeInventory("PinkyReserve", 1)
			//A_CustomMissile("InfernoDemonMETEOR",200, 90)
			DIAA H 3 A_FaceTarget

			DIAA E 2 A_FaceTarget
			TNT1 A 0 A_JumpIfInventory("PinkyReserve", 1, 1) // jumps on zero items, in combination with the skippable goto below
			Goto Missile2 
			DIAA G 3 A_SpawnItemEx("PinkySummon", 100, -90, 42, 30, 0, 10, 0, SXF_SETMASTER | SXF_TRANSFERPOINTERS, 0, 99)
			TNT1 A 0 A_TakeInventory("InitialPinkySpam", 1)
			//fails too often //TNT1 A 0 A_TakeInventory("PinkyReserve", 1)
			//A_CustomMissile("InfernoDemonMETEOR",200, 90)
			DIAA H 3 A_FaceTarget
			
			DIAA E 2 A_FaceTarget
			TNT1 A 0 A_JumpIfInventory("PinkyReserve", 1, 1) // jumps on zero items, in combination with the skippable goto below
			Goto Missile2 
			DIAA G 3 A_SpawnItemEx("PinkySummon", 100, 90, 42, 30, 0, 10, 0, SXF_SETMASTER | SXF_TRANSFERPOINTERS, 0, 99)
			TNT1 A 0 A_TakeInventory("InitialPinkySpam", 1)
			//fails too often //TNT1 A 0 A_TakeInventory("PinkyReserve", 1)
			//A_CustomMissile("InfernoDemonMETEOR",200, 90)
			DIAA H 3 A_FaceTarget			
			
			TNT1 A 0 A_JumpIfInventory("InitialPinkySpam", 1, "Meteor")
			Goto Chase
		Missile:
			TNT1 A 0
			TNT1 A 0 A_JumpIfInventory("InitialPinkySpam", 1, "Meteor")
			TNT1 A 0 A_JumpIfCloser(800, "Missile2")
			TNT1 A 0 A_JumpIfInventory("PinkyReserve", 1, 1) // jumps on zero items, in combination with the skippable goto below
			Goto Missile2
			TNT1 A 0 A_Jump(64, "Meteor")
			Goto Missile2
		Missile2:
			TNT1 A 0
			TNT1 A 0 A_JumpIfCloser(400, "Stomp")
			TNT1 A 0 A_Jump(128, "FireBall")
			//TNT1 A 0 A_Jump(64, "sTOMP")
			TNT1 A 0 A_JumpIfInventory("PinkyReserve", 1, 1) // jumps on zero items, in combination with the skippable goto below
			Goto FireBall
			TNT1 A 0
			TNT1 A 0 A_Jump(256, "Meteor")
			//Goto Meteor
			Goto Chase // multiplayer oopsnik: execution cannot reach here, buit it does, as a coop client
			
	}
}

Actor PinkieInfernalMP: PinkieInfernal 17628 // shoots megapinkies with 10x health instead
{
	Health 20000
	Tag "$INFERNAL2UV" // Brutal Infernal Beastmaster
	States {
		Spawn:
			TNT1 A 0 
			TNT1 A 0 A_JumpIfInventory("PinkyReserve", 1, 3) // why the heck is his Spawn stage gets called again if you die
			TNT1 A 0 A_GiveInventory("InitialPinkySpam", 9) // one tenth
			TNT1 A 0 A_GiveInventory("PinkyReserve", 66)
			TNT1 A 0 A_GiveInventory("TargetIsAGreatTerribleBoss")
			TNT1 A 0 
			Goto SitAndWait
		Missile:
			TNT1 A 0
			TNT1 A 0 A_JumpIfCloser(800, "Missile2")
			TNT1 A 0 A_JumpIfInventory("PinkyReserve", 1, 1) // jumps on zero items, in combination with the skippable goto below
			Goto Missile2 
			TNT1 A 0
			TNT1 A 0 A_Jump(192, "Meteor") // spam the pinkies! Flood the arena with them!
			Goto Missile2
		Meteor:
			DIAA E 2 A_FaceTarget
			TNT1 A 0 A_JumpIfInventory("PinkyReserve", 1, 1) // jumps on zero items, in combination with the skippable goto below
			Goto Missile2 
			DIAA G 3 A_SpawnItemEx("MultiplayerPinkySummon", 100, 90, 42, 30, 0, 10, 0, SXF_SETMASTER | SXF_TRANSFERPOINTERS, 0, 99)
			TNT1 A 0 A_TakeInventory("InitialPinkySpam", 1)
			
			//fails too often //TNT1 A 0 A_TakeInventory("PinkyReserve", 1)
			// summons themselves decrease his inventory on successful spawn via ACS, addressing him by his TID=666
			
			//A_CustomMissile("InfernoDemonMETEOR",200, 90)
			DIAA H 3 A_FaceTarget

			DIAA E 2 A_FaceTarget
			TNT1 A 0 A_JumpIfInventory("PinkyReserve", 1, 1) // jumps on zero items, in combination with the skippable goto below
			Goto Missile2 
			DIAA G 3 A_SpawnItemEx("MultiplayerPinkySummon", 100, -90, 42, 30, 0, 10, 0, SXF_SETMASTER | SXF_TRANSFERPOINTERS, 0, 99)
			TNT1 A 0 A_TakeInventory("InitialPinkySpam", 1)
			//fails too often //TNT1 A 0 A_TakeInventory("PinkyReserve", 1)
			//A_CustomMissile("InfernoDemonMETEOR",200, 90)
			DIAA H 3 A_FaceTarget
			
			DIAA E 2 A_FaceTarget
			TNT1 A 0 A_JumpIfInventory("PinkyReserve", 1, 1) // jumps on zero items, in combination with the skippable goto below
			Goto Missile2 
			DIAA G 3 A_SpawnItemEx("MultiplayerPinkySummon", 100, 90, 42, 30, 0, 10, 0, SXF_SETMASTER | SXF_TRANSFERPOINTERS, 0, 99)
			TNT1 A 0 A_TakeInventory("InitialPinkySpam", 1)
			//fails too often //TNT1 A 0 A_TakeInventory("PinkyReserve", 1)
			//A_CustomMissile("InfernoDemonMETEOR",200, 90)
			DIAA H 3 A_FaceTarget

			DIAA E 2 A_FaceTarget
			TNT1 A 0 A_JumpIfInventory("PinkyReserve", 1, 1) // jumps on zero items, in combination with the skippable goto below
			Goto Missile2 
			DIAA G 3 A_SpawnItemEx("MultiplayerPinkySummon", 100, -90, 42, 30, 0, 10, 0, SXF_SETMASTER | SXF_TRANSFERPOINTERS, 0, 99)
			TNT1 A 0 A_TakeInventory("InitialPinkySpam", 1)
			//fails too often //TNT1 A 0 A_TakeInventory("PinkyReserve", 1)
			//A_CustomMissile("InfernoDemonMETEOR",200, 90)
			DIAA H 3 A_FaceTarget
			
			DIAA E 2 A_FaceTarget
			TNT1 A 0 A_JumpIfInventory("PinkyReserve", 1, 1) // jumps on zero items, in combination with the skippable goto below
			Goto Missile2 
			DIAA G 3 A_SpawnItemEx("MultiplayerPinkySummon", 100, 90, 42, 30, 0, 10, 0, SXF_SETMASTER | SXF_TRANSFERPOINTERS, 0, 99)
			TNT1 A 0 A_TakeInventory("InitialPinkySpam", 1)
			//fails too often //TNT1 A 0 A_TakeInventory("PinkyReserve", 1)
			//A_CustomMissile("InfernoDemonMETEOR",200, 90)
			DIAA H 3 A_FaceTarget			
			
			TNT1 A 0 A_JumpIfInventory("InitialPinkySpam", 1, "Meteor")
			Goto Chase			
	}
}

Actor PinkieInfernalUV: PinkieInfernal 17542 
{
	Health 13666
	Tag "$INFERNAL2UV" // Brutal Infernal Beastmaster
	States {
		Spawn:
			TNT1 A 0 
			TNT1 A 0 A_JumpIfInventory("PinkyReserve", 1, 3) // why the heck is his Spawn stage gets called again if you die
			TNT1 A 0 A_GiveInventory("InitialPinkySpam", 90)
			TNT1 A 0 A_GiveInventory("PinkyReserve", 666)
			TNT1 A 0 A_GiveInventory("TargetIsAGreatTerribleBoss")
			TNT1 A 0 
			Goto SitAndWait
		Missile:
			TNT1 A 0
			TNT1 A 0 A_JumpIfCloser(800, "Missile2")
			TNT1 A 0 A_JumpIfInventory("PinkyReserve", 1, 1) // jumps on zero items, in combination with the skippable goto below
			Goto Missile2 
			TNT1 A 0
			TNT1 A 0 A_Jump(192, "Meteor") // spam the pinkies! Flood the arena with them!
			Goto Missile2	
			
		Meteor: // buffed to series of 8 on UV
			DIAA E 2 A_FaceTarget
			TNT1 A 0 A_JumpIfInventory("PinkyReserve", 1, 1) // jumps on zero items, in combination with the skippable goto below
			Goto Missile2 
			DIAA G 2 A_SpawnItemEx("PinkySummon", 100, 90, 42, 30, 0, 10, 0, SXF_SETMASTER | SXF_TRANSFERPOINTERS, 0, 99)
			TNT1 A 0 A_TakeInventory("InitialPinkySpam", 1)
			//fails too often //TNT1 A 0 A_TakeInventory("PinkyReserve", 1)
			DIAA H 2 A_FaceTarget
			
			DIAA E 2 A_FaceTarget
			TNT1 A 0 A_JumpIfInventory("PinkyReserve", 1, 1) // jumps on zero items, in combination with the skippable goto below
			Goto Missile2 
			DIAA G 2 A_SpawnItemEx("PinkySummon", 100, -90, 42, 30, 0, 10, 0, SXF_SETMASTER | SXF_TRANSFERPOINTERS, 0, 99)
			TNT1 A 0 A_TakeInventory("InitialPinkySpam", 1)
			//fails too often //TNT1 A 0 A_TakeInventory("PinkyReserve", 1)
			DIAA H 2 A_FaceTarget			

			DIAA E 2 A_FaceTarget
			TNT1 A 0 A_JumpIfInventory("PinkyReserve", 1, 1) // jumps on zero items, in combination with the skippable goto below
			Goto Missile2 
			DIAA G 2 A_SpawnItemEx("PinkySummon", 100, 90, 42, 30, 0, 10, 0, SXF_SETMASTER | SXF_TRANSFERPOINTERS, 0, 99)
			TNT1 A 0 A_TakeInventory("InitialPinkySpam", 1)
			//fails too often //TNT1 A 0 A_TakeInventory("PinkyReserve", 1)
			DIAA H 2 A_FaceTarget
			
			DIAA E 2 A_FaceTarget
			TNT1 A 0 A_JumpIfInventory("PinkyReserve", 1, 1) // jumps on zero items, in combination with the skippable goto below
			Goto Missile2 
			DIAA G 2 A_SpawnItemEx("PinkySummon", 100, -90, 42, 30, 0, 10, 0, SXF_SETMASTER | SXF_TRANSFERPOINTERS, 0, 99)
			TNT1 A 0 A_TakeInventory("InitialPinkySpam", 1)
			//fails too often //TNT1 A 0 A_TakeInventory("PinkyReserve", 1)
			DIAA H 2 A_FaceTarget			
			
			DIAA E 2 A_FaceTarget
			TNT1 A 0 A_JumpIfInventory("PinkyReserve", 1, 1) // jumps on zero items, in combination with the skippable goto below
			Goto Missile2 
			DIAA G 2 A_SpawnItemEx("PinkySummon", 100, 90, 42, 30, 0, 10, 0, SXF_SETMASTER | SXF_TRANSFERPOINTERS, 0, 99)
			TNT1 A 0 A_TakeInventory("InitialPinkySpam", 1)
			//fails too often //TNT1 A 0 A_TakeInventory("PinkyReserve", 1)
			DIAA H 2 A_FaceTarget
			
			DIAA E 2 A_FaceTarget
			TNT1 A 0 A_JumpIfInventory("PinkyReserve", 1, 1) // jumps on zero items, in combination with the skippable goto below
			Goto Missile2 
			DIAA G 2 A_SpawnItemEx("PinkySummon", 100, -90, 42, 30, 0, 10, 0, SXF_SETMASTER | SXF_TRANSFERPOINTERS, 0, 99)
			TNT1 A 0 A_TakeInventory("InitialPinkySpam", 1)
			//fails too often //TNT1 A 0 A_TakeInventory("PinkyReserve", 1)
			DIAA H 2 A_FaceTarget			

			DIAA E 2 A_FaceTarget
			TNT1 A 0 A_JumpIfInventory("PinkyReserve", 1, 1) // jumps on zero items, in combination with the skippable goto below
			Goto Missile2 
			DIAA G 2 A_SpawnItemEx("PinkySummon", 100, 90, 42, 30, 0, 10, 0, SXF_SETMASTER | SXF_TRANSFERPOINTERS, 0, 99)
			TNT1 A 0 A_TakeInventory("InitialPinkySpam", 1)
			//fails too often //TNT1 A 0 A_TakeInventory("PinkyReserve", 1)
			DIAA H 2 A_FaceTarget
			
			DIAA E 2 A_FaceTarget
			TNT1 A 0 A_JumpIfInventory("PinkyReserve", 1, 1) // jumps on zero items, in combination with the skippable goto below
			Goto Missile2 
			DIAA G 2 A_SpawnItemEx("PinkySummon", 100, -90, 42, 30, 0, 10, 0, SXF_SETMASTER | SXF_TRANSFERPOINTERS, 0, 99)
			TNT1 A 0 A_TakeInventory("InitialPinkySpam", 1)
			//fails too often //TNT1 A 0 A_TakeInventory("PinkyReserve", 1)
			DIAA H 2 A_FaceTarget			
			

			
			TNT1 A 0 A_JumpIfInventory("InitialPinkySpam", 1, "Meteor")
			Goto Chase	
	}
}


Actor PinkieInfernalHordes: PinkieInfernalUV 17683 
{
	Health 20000 // as coop
	Tag "$INFERNAL2UV" // Brutal Infernal Beastmaster
	States {
		Meteor: // fire rate is doubled *again* against UV
			DIAA E 1 A_FaceTarget
			TNT1 A 0 A_JumpIfInventory("PinkyReserve", 1, 1) // jumps on zero items, in combination with the skippable goto below
			Goto Missile2 
			DIAA G 1 A_SpawnItemEx("PinkySummon", 100, 90, 42, 30, 0, 10, 0, SXF_SETMASTER | SXF_TRANSFERPOINTERS, 0, 99)
			TNT1 A 0 A_TakeInventory("InitialPinkySpam", 1)
			DIAA H 1 
			
			DIAA E 1 A_FaceTarget
			TNT1 A 0 A_JumpIfInventory("PinkyReserve", 1, 1) // jumps on zero items, in combination with the skippable goto below
			Goto Missile2 
			DIAA G 1 A_SpawnItemEx("PinkySummon", 100, -90, 42, 30, 0, 10, 0, SXF_SETMASTER | SXF_TRANSFERPOINTERS, 0, 99)
			TNT1 A 0 A_TakeInventory("InitialPinkySpam", 1)
			DIAA H 1			

			DIAA E 1 A_FaceTarget
			TNT1 A 0 A_JumpIfInventory("PinkyReserve", 1, 1) // jumps on zero items, in combination with the skippable goto below
			Goto Missile2 
			DIAA G 1 A_SpawnItemEx("PinkySummon", 100, 90, 42, 30, 0, 10, 0, SXF_SETMASTER | SXF_TRANSFERPOINTERS, 0, 99)
			TNT1 A 0 A_TakeInventory("InitialPinkySpam", 1)
			DIAA H 1 A_FaceTarget
			
			DIAA E 1 A_FaceTarget
			TNT1 A 0 A_JumpIfInventory("PinkyReserve", 1, 1) // jumps on zero items, in combination with the skippable goto below
			Goto Missile2 
			DIAA G 1 A_SpawnItemEx("PinkySummon", 100, -90, 42, 30, 0, 10, 0, SXF_SETMASTER | SXF_TRANSFERPOINTERS, 0, 99)
			TNT1 A 0 A_TakeInventory("InitialPinkySpam", 1)
			DIAA H 1
			
			DIAA E 1 A_FaceTarget
			TNT1 A 0 A_JumpIfInventory("PinkyReserve", 1, 1) // jumps on zero items, in combination with the skippable goto below
			Goto Missile2 
			DIAA G 1 A_SpawnItemEx("PinkySummon", 100, 90, 42, 30, 0, 10, 0, SXF_SETMASTER | SXF_TRANSFERPOINTERS, 0, 99)
			TNT1 A 0 A_TakeInventory("InitialPinkySpam", 1)
			DIAA H 1 A_FaceTarget
			
			DIAA E 1 A_FaceTarget
			TNT1 A 0 A_JumpIfInventory("PinkyReserve", 1, 1) // jumps on zero items, in combination with the skippable goto below
			Goto Missile2 
			DIAA G 1 A_SpawnItemEx("PinkySummon", 100, -90, 42, 30, 0, 10, 0, SXF_SETMASTER | SXF_TRANSFERPOINTERS, 0, 99)
			TNT1 A 0 A_TakeInventory("InitialPinkySpam", 1)
			DIAA H 1

			TNT1 A 0 A_Jump(96, "Meteor")
			
			TNT1 A 0 A_JumpIfInventory("InitialPinkySpam", 1, "Meteor")
			Goto Chase	
	}
}
*/

Actor EDAY21_Quake1
{
	+NOINTERACTION
	States
	{
		Spawn:
			TNT1 A 0 NODELAY A_PlaySound("NUKEEXPL", CHAN_AUTO, 1.0, 0)
			TNT1 A 0 Radius_Quake (22, 140, 0, 32, 0)  // radius 2048 (32 * 64)
			TNT1 A 999
			Stop
	}
}


Actor EDAY21_Quake2
{
	+NOINTERACTION
	States
	{
		Spawn:
			TNT1 A 0 NODELAY Radius_Quake (22, 100, 0, 32, 0)  // radius 2048 (32 * 64)
			TNT1 A 999
			Stop
	}
}


Actor EDAY21_DirtSFX
{
	+THRUACTORS
	+GHOST
	+THRUGHOST
	States
	{
		Spawn:
			TNT1 A 0
			TNT1 AAA 0 A_CustomMissile ("MudDust", 6, 0, random (0, 360), 2, random (70, 85))
			TNT1 A 0 A_CustomMissile ("MudDust", 6, 0, random (0, 360), 2, random (85, 90))
			TNT1 AAAA 0 A_CustomMissile ("MudDust", 4, 0, random (0, 360), 2, random (50, 55))
			TNT1 AAAAAA 0 A_CustomMissile ("DirtChunk1", 0, 0, random (0, 360), 2, random (30, 150))
			TNT1 AAAAAA 0 A_CustomMissile ("DirtChunk2", 0, 0, random (0, 360), 2, random (30, 150))
			TNT1 AA 0 A_CustomMissile ("BrownCloud", 20, 0, random (0, 360), 2, random (10, 90))
			TNT1 AAA 0 A_CustomMissile ("BrownCloud", 60, 0, random (0, 360), 2, random (40, 90))
			TNT1 A 0 A_PlaySound("BHITDIR1", 1)
			TNT1 A 0 A_PlaySound("BHITDIR2", 2)
			TNT1 A 0 A_PlaySound("BHITDIR3", 3)
			TNT1 A 0 A_PlaySound("BHITDIR4", 4)
			TNT1 A 0 A_PlaySound("BHITDIR5", 5)
			Stop
	}		
}


Actor EDAY21_NoRubbleBuildingDust {
	+NOBLOCKMAP
	+NOGRAVITY
	-SHOOTABLE
	+GHOST
	+THRUGHOST
	states	{
		Spawn:
			TNT1 A 0
			Goto Death
		Death:
			TNT1 AAAAAA 0 A_CustomMissile ("DestroyedBuildingSmoke", 0, 0, random (0, 360), 2, random (10, 40))
			TNT1 AAAAAA 0 A_CustomMissile ("DestroyedBuildingSmokeSpawner", 0, 0, random (0, 360), 2, random (10, 40))
			TNT1 A 0 A_PlaySound("ROCKFAL")
			TNT1 A 500
			Stop
	}
}

Actor EDAY21_PitCollapseDust {
	+THRUACTORS
	+THRUGHOST
	+GHOST
	-NOGRAVITY
	-SHOOTABLE
	Gravity 1.5
	states	{
		Spawn:
			TNT1 A 0
			TNT1 AAAAA 0 A_SpawnItemEx("EDAY21_PitCollapseDust2", random(-255,255), random(-255,255),0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			TNT1 A 0 A_PlaySound("ROCKFAL")
			TNT1 AAAAAAAAAA Random(1, 4) A_CustomMissile ("DestroyedBuildingSmokeSpawner", 0, 0, random (0, 360), 2, random (10, 40))
			TNT1 A 50
			Stop
	}
}

Actor EDAY21_PitCollapseDust2 {
	+THRUACTORS
	+THRUGHOST
	+GHOST
	-NOGRAVITY
	-SHOOTABLE
	Gravity 3.0
	var int user_lifetime;
	states	{
		Spawn:
			TNT1 A 2
			TNT1 A 0 A_SetUserVar("user_lifetime", Random(10, 20))
			TNT1 AAAAAAAAAAAA Random(5, 7) A_CustomMissile ("BrownCloud", 20, 0, random (0, 360), 2, random (10, 90))
		Dust:	
			TNT1 A Random(7, 13) A_CustomMissile ("BrownCloud", 20, 0, random (0, 360), 2, random (10, 40))
			TNT1 A 0 A_SetUserVar("user_lifetime", user_lifetime - 1)
			TNT1 A 0 A_JumpIf(user_lifetime > 0, "Dust")
			TNT1 A 50
			Stop
	}
}

ACTOR EDAY21_AmbientSoundHurricane
{ 

	+NOBLOCKMAP
	+NOGRAVITY
	-SHOOTABLE
	States
	{
	Spawn:
		TNT1 A Random(0, 70)
		TNT1 A 0 A_PlaySound("eday/map21_hurricane", 1, 1.0, 1)
		TNT1 A 110
		Loop
	   
	}
}



