
/*
	ChebMaster's note:
	I strongly encourage re-using my code in other mods
	-- but, PRETTY PLEASE, invent your own prefix and search-and-replace "FBD_"
	   with that prefix of yours everywhere in the borrowed code.
	Because when someone *else* goes a step further building something
		even more awesome by cros-breeeding the mods they'd have a *colossal pain*
		if identifiers in those mods are the same.
	I encountered this problem when trying to run Franken Brutal Doom Monsters-only	
		on top of Project Brutality. It went pear-shaped because PB copies *tons*
		of BD code verbatim, with class names staying *the same* - and GZDoom 
		fucks class inheritance up *hard* when it tries resolving two PK3s
		that declare identical class names.
*/


#include MARINES_syn.txt

//***Che this class implements methods common for all evil marines
// and the maradeur



// see below: ACTOR ChaosMarineWeak: ChaosMarineAbstract

ACTOR ChaosMarineAbstract: Marine_AbstractSynth 
{
	
	//***Che radius, height and maxdropoffheight (n/a for flying ones) MUST be kept consistent with FBD_TrySpawn in FBD_CORE.acs!
	
	// elite ones are bright shiny red
	Translation "112:124=168:187", "125:127=[91,0,0]:[21,0,0]", "152:159=16:47", "9:12=[61,12,12]:[13,0,0]", "128:143=168:186"

	//$category "FBD Chaos Marines"
	
	Health 120
	Height 42 //56 // unlike NPCs, chaos marines *do* have headboxes
	
	// so that he can be resurrected manually by simply setting the SOLID flag
	DeathHeight 42
	BurnHeight 42

	Speed 4
	FastSpeed 3
	
	PainChance 200	
	
	Species "EvilMarines" // must match headboxes', otherwise rocket marine's rockets explode against his headbox, LOL.
	
	damagefactor "SSG", 1.4 //  56 damage from that central hitscan
	
	
	// maradeur inherits this:
	damagefactor "Shotgun", 2.0 // because he then dodge-rolls from *one* pellet, others doing no damage
	PainChance "Shotgun", 96
	damagefactor "MonsterShotgunBullet", 2.0
	PainChance "MonsterShotgunBullet", 96
	damagefactor "Desintegrate", 3.0 // Bfg 9000 & Unmaker. The same problem as with shotguns.
	PainChance "Desintegrate", 128 // allows getting hit with more
	 
	
	damagefactor "Minigun", 0.7
	damagefactor "saw", 0.8
	damagefactor "cut", 0.8
	damagefactor "PussyGrab", 50.0
	damagefactor "explosiveimpact", 0.4
	//***Che
	damagefactor "FriendlyExplosion", 0.4
	damagefactor "Blood", 0.0 damagefactor "BlueBlood", 0.0 damagefactor "GreenBlood", 0.0
    
	//***Che: dafug, bro?
	// You can bury them in grenades, they only take damage because grenade is hard and heavy and hits like a thrown stone!
	//damagefactor "Shrapnel", 0.0
	damagefactor "Shrapnel", 0.4
	
	// they ignore captured marines
	damagefactor "KillMe", 0.0  damagefactor "TeleportRemover", 0.0
	SeeSound "zombiemarine/sight"
	AttackSound "grunt/attack"
	PainSound "zombiemarine/pain"
	DeathSound "zombiemarine/death"
	ActiveSound None // "zombiemarine/active" // do NOT use ActiveSound, replaced with a better custom mechanism - see the Nag state
	DamageFactor "ExtremePunches", 2.0

	// grayish green
	//Translation "48:79=[255,203,155]:[75,58,24]", "112:123=152:159", "124:127=9:12"
	

	//***Che: required for the headboxes to work
	+ISMONSTER

	Tag "$CHAOS_MARINE"
	Obituary "$CHAOS_MARINE_O"	
	
	+NOPAIN // temporary, cleared after init
	
	States
	{
		SetupDefaults:
			"----" A 0 A_GiveInventory("TargetIsAChaosMarine", 1)
			// relegated to the slaughtermap init script //"----" A 0 A_SetUserVar("user_jump_power", 50)
			"----" A 0 A_SetUserVar("user_ddgrll_chance", 192) // chance to dodge-roll on pain. 0 = always
			"----" A 0 A_SetUserVar("user_head_type", 6) // 6 - evil marine headbox
			"----" A 0 A_SetUserVar("user_nag_cooldown", 300)
			"----" A 0 A_SetUserVar("user_nag_period", 300)
			"----" A 0 A_SetUserVar("user_speed_limit", 8)
			"----" A 0 A_SetUserVar("user_voice_set", CHE_TRAITOR)
			
			"----" A 7
			"----" A 0 A_SetUserVar("user_jump_power", CallAcs("AdjustJumpPowerForEDAYMarsChapter", 50))
			"----" A 0 A_ChangeFlag("NOPAIN", 0)
			Goto WeaponSwitch // will proceed to Stand

		OnBeingUsed:
			// What did you expect, poking him?
			"----" A 0 A_FaceTarget
			"----" A 0 A_PlaySound("zombiemarine/sight", CHAN_VOICE)
			Goto See
			
		OnDeath:
			"----" A 0 A_GiveToTarget("SoulAmmo", 1) // now *all* deaths give the killer Unmaker ammo!
			"----" A 1
			"----" A -1
			
		Raise:
		FallbackRezSuccess:
			TNT1 A 0
			TNT1 A 0 A_ChangeFlag("NOPAIN", 1)
			TNT1 A 0 A_SetUserVar("user_head_tid", 0) // causes the headbox (which had auto-terminated on our death) to be created anew
			TNT1 A 0 A_SetScale(0.7, 0.7)
			TNT1 A 0 A_SpawnItemEx("StandaloneRezSfx",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			ID50 GFEDCB 3 // desintegrated human, gore flowing up into a human shape
			TNT1 A 0 A_SetScale(1.0, 1.0)
			TNT1 A 0 A_ChangeFlag("NOPAIN", 0)
			TNT1 A 0 ACS_NamedExecuteWithResult("FBD_CustomizeOnRez") // it runs OnRezMapScript
				// if the map prpvides one
			PLAY O 1 A_Jump(256, "See")
			
			Goto Stand	

		FallbackRaise: // we were put into this state by the superarchvile AOE raising, our height is hopelessly kaput and we have to spawn a substitute
			"----" A 0 A_GiveInventory("RezzingNow")
			"----" A 0 A_ChangeFlag("CORPSE", 0)
			
			//***Che this *only* works because he has DeathHeight and BurnHeight declared and equal to Height!
			"----" A 0 A_ChangeFlag("SOLID", 1)
			"----" A 0 A_ChangeFlag("SHOOTABLE", 1)
			Goto Raise
			
			
		IosChastises: // required by maradeur boss in Chebskies-EDAY map 313
			"----" A 0 A_ClearTarget
			Goto Pain.Argent
		Pain.Argent:
			"----" A 0
			//"----" A 0 A_ClearTarget
			"----" A 0 HealThing(60)
			"----" A 0 ACS_NamedExecuteWithResult("DisplayArgentDischarge", 10, 40, 0)
			"----" A 0 A_JumpIf(user_melee_weapon != 1, 2)
			"----" A 0 A_SetUserVar("user_melee_weapon", 2) // upgrade from fist to berserk fist!
			"----" A 1 A_Jump(256, "Pain")
			Wait
		
		
		Triumph: // after fatality
			"----" A 0 A_FaceTarget
			"----" A 0 A_ClearTarget
			"----" A 0 ACS_NamedExecuteWithResult("FBD_SynthMarineVoice", CHE_TRIUMPH)
/*			
			"----" A 0 A_JumpIf(user_maradeur == 1, "TriumphLaughMaradeur1")
			"----" A 0 A_JumpIf(user_maradeur == 2, "TriumphLaughMaradeur2")
			"----" A 0 A_JumpIf(user_maradeur == 3, "TriumphLaughMaradeur3")
			"----" A 0 A_PlaySound("chaosmarine/triumph", CHAN_VOICE)
			Goto TriumphContinue	
		TriumphLaughMaradeur1:
			"----" A 0 A_PlaySound("maradeur/1/triumph", CHAN_VOICE)
			Goto TriumphContinue
		TriumphLaughMaradeur2:
			"----" A 0 A_PlaySound("maradeur/2/triumph", CHAN_VOICE)
			Goto TriumphContinue
		TriumphLaughMaradeur3:
			"----" A 0 A_PlaySound("maradeur/3/triumph", CHAN_VOICE)
*/			
			Goto TriumphContinue
			
		TriumphContinue:	
			"----" A 0 A_JumpIf(user_weapon == 3, "Triumph_Chainsaw")
			"----" A 0 A_JumpIf(user_weapon == 4, "Triumph_Rifle")
			"----" A 0 A_JumpIf(user_weapon == 5, "Triumph_Shotgun")
			"----" A 0 A_JumpIf(user_weapon == 6, "Triumph_SSG")
			"----" A 0 A_JumpIf(user_weapon == 7, "Triumph_Minugun")
			"----" A 0 A_JumpIf(user_weapon == 8, "Triumph_RL")
			"----" A 0 A_JumpIf(user_weapon == 9, "Triumph_Plasma")
			"----" A 0 A_JumpIf(user_weapon == 10, "Triumph_Railgun")
			"----" A 0 A_JumpIf(user_weapon == 11, "Triumph_BFG") 
			"----" A 0 A_JumpIf(user_weapon == 12, "Triumph_10K")
			"----" A 0 A_JumpIf(user_weapon == 13, "Triumph_Unmaker")
			"----" A 0 A_JumpIf(user_weapon == 16, "Triumph_MG42")
		Triumph_Fists:
			"----" A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 2, 0, 46)
			PVPF E 30 // use fatality flex frame
			Goto TriumphFinish
		Triumph_Chainsaw: // this should NEVER happen: their meleee attack is chainsaw, never fatalizes!
			"----" A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -12, -8, 43)
			MAR1 E 30 // use pain frame - for this one and all others
			Goto TriumphFinish		
		Triumph_Rifle:
			"----" A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -10, -8, 44)
			PLAY G 30
			Goto TriumphFinish		
		Triumph_Shotgun:
			"----" A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -10, -5, 44)
			MAR3 E 30
			Goto TriumphFinish
		Triumph_SSG:
			"----" A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -11, -2, 44)
			MSSG E 30
			Goto TriumphFinish		
		Triumph_Minugun:
			"----" A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -10, -2, 43)
			MAR4 E 30
			Goto TriumphFinish		
		Triumph_RL:
			"----" A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -11, -6, 42)
			PL5S G 30
			Goto TriumphFinish
		Triumph_Plasma:
			"----" A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -10, -8, 44)
			MAR6 E 30
			Goto TriumphFinish		
		Triumph_Railgun:
			"----" A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -11, -8, 45)
			MRRG E 30
			Goto TriumphFinish
		Triumph_BFG:
			"----" A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -13, -7, 44)
			PLA7 G 30
			Goto TriumphFinish
		Triumph_10K:
			"----" A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -11, -10, 44)
			M10K E 30
			Goto TriumphFinish
		Triumph_Unmaker:
			"----" A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -8, -2, 45)
			P7UM G 30
			Goto TriumphFinish
		Triumph_MG42:	
			"----" A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -9, -2, 45)	
			P842 G 30
			Goto TriumphFinish

		TriumphFinish:
			// clear the target knowledge
			"----" A 0 A_SetUserVar("user_thr_chaaarge", 0)
			"----" A 0 A_SetUserVar("user_thr_mul", 0)
			"----" A 0 A_SetUserVar("user_thr_hrr", 0)
			"----" A 0 A_SetUserVar("user_wander", Random(5, 20))
			"----" A 0 A_JumpIf(user_maradeur, "Idle") // maradeur does not switch weapons!
			"----" A 0 A_SetUserVar("user_see_after_wp_sw", 2) // go to idle loop afterwards
			"----" A 0 A_SetUserVar("user_weapon", user_default_weapon < 4 ? user_melee_weapon : user_default_weapon)
			Goto WeaponSwitch

		StandLoop: // no such state in this class
		Stand:
			"----" A 0 A_JumpIf(user_serverside_sfchk >= 4, "StandSfest") // extreme slaughtermap optimization
			
			"----" A 0 A_JumpIf(user_weapon == 3, "Stand_Chainsaw")
			"----" A 0 A_JumpIf(user_weapon == 4, "Stand_Rifle")
			"----" A 0 A_JumpIf(user_weapon == 5, "Stand_Shotgun")
			"----" A 0 A_JumpIf(user_weapon == 6, "Stand_SSG")
			"----" A 0 A_JumpIf(user_weapon == 7, "Stand_Minugun")
			"----" A 0 A_JumpIf(user_weapon == 8, "Stand_RL")
			"----" A 0 A_JumpIf(user_weapon == 9, "Stand_Plasma")
			"----" A 0 A_JumpIf(user_weapon == 10, "Stand_Railgun")
			"----" A 0 A_JumpIf(user_weapon == 11, "Stand_BFG") 
			"----" A 0 A_JumpIf(user_weapon == 12, "Stand_10K") 
			"----" A 0 A_JumpIf(user_weapon == 13, "Stand_Unmaker") 
		Stand_Fists:
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 5, 0, 43)
			PLA1 AAAA 5 A_Look
			Loop
		Stand_Chainsaw:
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 6, 0, 43)
			MAR1 PPPP 5 A_Look
			Loop
		Stand_Rifle:
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 7, 3, 43)
			PLAY AAAA 5 A_Look
			Loop
		Stand_Shotgun:
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 4, 1, 43)
			PLA3 AAAA 5 A_Look
			Loop
		Stand_SSG:
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 4, 0, 43)
			PLA9 AAAA 5 A_Look
			Loop
		Stand_Minugun:
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 4, 0, 43)
			PL42 AAAA 5 A_Look
			Loop
		Stand_RL:
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -10, 1, 44)
			PL5S AAAA 5 A_Look
			Loop
		Stand_Plasma:
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 7, 3, 43)
			PLA6 AAAA 5 A_Look
			Loop
		Stand_Railgun:
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -11, 1, 44)
			MRRG AAAA 5 A_Look
			Loop
		Stand_BFG:
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 5, 0, 43)
			PLA7 AAAA 5 A_Look
			Loop
		Stand_10K:
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -4, -1, 44)
			M10K AAAA 5 A_Look
			Loop
		Stand_Unmaker:
			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 0, 0, 46)
			P7UM AAAA 5 A_Look
			Loop			


		StandSfest:
			"----" A 0 A_JumpIf(user_weapon == 3, "StandSfest_Chainsaw")
			"----" A 0 A_JumpIf(user_weapon == 4, "StandSfest_Rifle")
			"----" A 0 A_JumpIf(user_weapon == 5, "StandSfest_Shotgun")
			"----" A 0 A_JumpIf(user_weapon == 6, "StandSfest_SSG")
			"----" A 0 A_JumpIf(user_weapon == 7, "StandSfest_Minugun")
			"----" A 0 A_JumpIf(user_weapon == 8, "StandSfest_RL")
			"----" A 0 A_JumpIf(user_weapon == 9, "StandSfest_Plasma")
			"----" A 0 A_JumpIf(user_weapon == 10, "StandSfest_Railgun")
			"----" A 0 A_JumpIf(user_weapon == 11, "Stand_BFG") // no sfest for these monstrosities
			"----" A 0 A_JumpIf(user_weapon == 11, "Stand_10K") 
			"----" A 0 A_JumpIf(user_weapon == 11, "Stand_Unmaker") 
		StandSfest_Fists:
			PLA1 A 30 A_Look
			Loop
		StandSfest_Chainsaw:
			MAR1 P 30 A_Look
			Loop
		StandSfest_Rifle:
			PLAY A 30 A_Look
			Loop
		StandSfest_Shotgun:
			PLA3 A 30 A_Look
			Loop
		StandSfest_SSG:
			PLA9 A 30 A_Look
			Loop
		StandSfest_Minugun:
			PL42 A 30 A_Look
			Loop
		StandSfest_RL:
			PL5S A 30 A_Look
			Loop
		StandSfest_Plasma:
			PLA6 A 30 A_Look
			Loop
		StandSfest_Railgun:
			MRRG A 30 A_Look
			Loop
			
		
		// Unlike my first version, the synth machine itself takes care of dodge-rolling
		//  because all melee attacks have a small weapon cooldown and return to the synth loop afterwards.
		MeleeAttack: // weapon phase jumps here if tries firing a melee weapon
			"----" A 0 A_JumpIfTargetInLOS(1, 130, JLOSF_DEADNOJUMP, user_melee_range)
			Goto WeaponFinish
			"----" A 0 A_SetUserVar("user_wp_cooldown", user_weapon_cooldown_time)
			//"----" A 0 A_JumpIf(user_weapon == 14, "AttackDragonslayer") 
			"----" A 0 A_JumpIf(user_weapon == 3, "AttackChainsaw") 
			"----" A 0 A_JumpIfCloser(100, "AttackPunch")
			//"----" A 0 A_JumpIf(user_weapon == 4, "AttackKickRifle")
			Goto AttackKick
			// incongruously, berserk and normal inflict *identical* damage, only differing in attack cooldown and initiating range! 
		AttackKick:
			"----" A 0 A_JumpIf(user_in_air, "KickContinue")
			//"----" A 0 A_CustomMissile("FBD_CheckIfTargetIsAbove40")
			"----" A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 2, 0, 41)
			PKIK A 6 
			//***Che: do NOT adjust aim if target goes out of sight or is invisible
				"----" A 0 A_JumpIf(CallAcs("FBD_TargetIsInvisible"), 4)
				"----" A 0 A_JumpIfTargetInLOS(2)
				"----" A 0 A_Jump(256, 2)
				"----" A 0 A_FaceTarget
			PLA1 J 3 ThrustThingZ(0,10,0,1)
			"----" A 0 A_Recoil(-6)
			//"----" A 0 A_JumpIfInventory("TargetIsAbove", 1, 2)
			"----" A 0 A_JumpIf(CallAcs("GetZDeltaToTarget") > 40, 2)
			"----" A 0 A_JumpIf(true, 2)
			PLA1 J 3 ThrustThingZ(0,20,0,1) // stronger updraft
			"----" A 0 //A_TakeInventory("TargetIsAbove", 1)
			
		KickContinue:	
			"----" A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 5, 0, 44)
			//***Che: do NOT adjust aim if target goes out of sight or is invisible
				"----" A 0 A_JumpIf(CallAcs("FBD_TargetIsInvisible"), 4)
				"----" A 0 A_JumpIfTargetInLOS(2)
				"----" A 0 A_JumpIf(true, 2)
				"----" A 0 A_FaceTarget
			"----" A 0 A_TakeInventory("MeleeMiss", 10)	
			"----" A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -4, 1, 43)
			"----" A 0 A_SetUserVar("user_loiter_count", 0)
		KickFly:	
			"----" A 0 A_Recoil(-2)
			"----" A 0 A_JumpIfTargetInLOS("AttackPunch", 0, JLOSF_DEADNOJUMP, 110)
			PLA1 J 1 A_CheckFloor("DodgeRoll") // will jump to MissileAfterDodgeRoll after rolling because we came here from syn mode 1
			"----" A 0 A_SetUserVar("user_loiter_count", user_loiter_count + 1)
			"----" A 0 A_JumpIf(user_loiter_count > 35, "See")
			Loop
			
/*			
		AttackKickRifle:
			PLAY A 0
			"----" A 0 A_JumpIf(user_in_air, "KickRifleContinue")
			//"----" A 0 A_CustomMissile("FBD_CheckIfTargetIsAbove40")
			PLAY A 3 A_FaceTarget
			"----" A 0 ThrustThingZ(0,6,0,1)
		KickRifleContinue:
			"----" A 1
			//"----" A 0 A_JumpIfInventory("TargetIsAbove", 1, 3)
			"----" A 0 A_JumpIf(CallAcs("GetZDeltaToTarget") > 40, 2)
			"----" A 0 A_Stop // halt the upward movement -- otherwise flies over their heads
			//"----" A 0 A_TakeInventory("TargetIsAbove", 1)
			"----" A 0 A_Recoil(-6)
			"----" A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 0, 1, 43)
			MARJ A 6 A_FaceTarget
			"----" A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -5, 1, 44)
			AKIK A 1 A_CustomMissile("EvilMarineKick",40,0,0,0)
			"----" A 0 A_Stop
			AKIK A 6
			Goto CheckForFatality
*/			
		MeleeAttackPunch:
//			"----" A 0 A_JumpIf(user_weapon == 4, "AttackPunchRifle") 
		AttackPunch: 
			"----" A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -8, -1, 43) // is for reworked sprite!
			PLA1 H 4 A_FaceTarget
			"----" A 0 A_Recoil(-4)
			PLA1 H 4 A_FaceTarget
			"----" A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 3, 0, 44)
			PLA1 E 4 A_CustomMissile("EvilBerserkMarinePunch",40,0,0,0)
			PLA1 E 4		
			Goto CheckForFatality	
/*
		AttackPunchRifle:
			"----" A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 2, 6, 39)
			PLAM A 8 A_FaceTarget
			"----" A 0 A_Recoil(-4)
			PLAM A 1 A_FaceTarget
			"----" A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 2, -1, 38)
			PLAM B 3 A_CustomMissile("EvilMarinePunch",40,0,0,0)
			PLAM B 3
			Goto CheckForFatality
*/		
		AttackChainsaw: // uses a mighty leap attack, even up close!
			"----" A 0 ThrustThingZ(0,6,0,1)
			"----" A 0 A_PlaySound("weapons/chainsaw/start", CHAN_WEAPON, 1, 0)	
			"----" A 0 A_JumpIf(user_in_air, "ChainsawContinue")
			//***Che: adjust aim *early* if target is invisible
				"----" A 0 A_JumpIf(CallAcs("FBD_TargetIsInvisible"), 2)
				"----" A 0 A_JumpIfTargetInLOS(2)
				"----" A 0 A_FaceTarget
			// use attack frame (chainsaw forward)
			MAR1 A 6 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 3, 0, 46)
			//***Che: do NOT adjust aim if target goes out of sight or is invisible
				"----" A 0 A_JumpIf(CallAcs("FBD_TargetIsInvisible"), 4)
				"----" A 0 A_JumpIfTargetInLOS(2)
				"----" A 0 A_Jump(256, 2)
				"----" A 0 A_FaceTarget
		ChainsawContinue: 
			"----" A 0 A_Recoil(-8)
			"----" A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 0, 3, 50)
			//***Che: do NOT adjust aim if target goes out of sight or is invisible
				"----" A 0 A_JumpIf(CallAcs("FBD_TargetIsInvisible"), 4)
				"----" A 0 A_JumpIfTargetInLOS(2)
				"----" A 0 A_Jump(256, 2)
				"----" A 0 A_FaceTarget
			MAR1 X 3 
			"----" A 0 A_SetUserVar("user_prev_x", x)
			"----" A 0 A_SetUserVar("user_prev_y", y)
			MAR1 X 1
			"----" A 0 A_TakeInventory("MeleeMiss", 10)
			MAR1 XXXX 1 A_JumpIf(!CallAcs("SynthMarine_ChainsawContinueCheck"), "ChainsawCollided") //!momz || (momx > -2 && momx < 2 && momy > -2 && momy < 2), "ChainsawCollided")
			"----" A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -2, 0, 48)
			MAR1 YYYYYYYYYYYYYYYYYYYYY 1 A_JumpIf(!CallAcs("SynthMarine_ChainsawContinueCheck"), "ChainsawCollided") //!momz || (momx > -2 && momx < 2 && momy > -2 && momy < 2), "ChainsawCollided")			
		ChainsawCollided:
			// PATHETIC! He stops and this frame is so painfully long! 
			// Even an old lady could walk away from such an attack!
			//MAR1 YYY 2 A_CustomMissile("EvilSawDamageVertical",35,0,angle, CMF_ABSOLUTEANGLE | CMF_OFFSETPITCH | CMF_SAVEPITCH)
			
			"----" A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -2, 0, 48)
			MAR1 Y 0 A_CustomMissile("EvilSawDamageVertical",35,0,angle, CMF_ABSOLUTEANGLE | CMF_OFFSETPITCH | CMF_SAVEPITCH)
			MAR1 YY 1 A_Recoil(-2)
			MAR1 Y 0 A_CustomMissile("EvilSawDamageVertical",35,0,angle, CMF_ABSOLUTEANGLE | CMF_OFFSETPITCH | CMF_SAVEPITCH)
			MAR1 YY 1 A_Recoil(-2)
			MAR1 Y 0 A_CustomMissile("EvilSawDamageVertical",35,0,angle, CMF_ABSOLUTEANGLE | CMF_OFFSETPITCH | CMF_SAVEPITCH)
			MAR1 YY 1 A_Recoil(-2)
			
			"----" A 0 A_JumpIfInventory("MeleeHitSuccess", 1, "KeepSawing")
			Goto WeaponFinish
		KeepSawing:
			"----" A 0 A_TakeInventory("MeleeHitSuccess", 10)
			"----" A 0 A_Recoil(-2)
			"----" A 0 A_M_Saw("weapons/chainsaw/loop", "CSAWCUT", 1, "SSawPuff2") 
			MAR1 A 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 3, 0, 46)
			MAR1 AA 1 A_CustomMissile("EvilSawDamageVertical",35,0,angle, CMF_ABSOLUTEANGLE | CMF_OFFSETPITCH | CMF_SAVEPITCH)
			"----" A 0 A_JumpIfInventory("MeleeMiss", 5, "See")
			
				"----" A 0 A_JumpIfInventory("MeleeHitSuccess", 1, 4) // if we hit, your invisibility doesn't count. We SAW.
				//***Che: do NOT adjust aim if target goes out of sight or is invisible
				"----" A 0 A_JumpIf(CallAcs("FBD_TargetIsInvisible"), 4)
				"----" A 0 A_JumpIfTargetInLOS(2)
				"----" A 0 A_Jump(256, 2)
				"----" A 0 A_FaceTarget
				"----" A 0 A_TakeInventory("MeleeHitSuccess", 1) // while successful sawing gives +2
				
			"----" A 0 A_JumpIfInventory("MeleeHitSuccess", 1, 1)
			Goto WeaponFinish	
			
			"----" A 0 A_Recoil(-2)
			"----" A 0 A_M_Saw("weapons/chainsaw/loop", "CSAWCUT", 1, "SSawPuff2") 
			MAR1 B 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 3, 0, 45)
			MAR1 BB 1 A_CustomMissile("EvilSawDamageVertical",35,0,angle, CMF_ABSOLUTEANGLE | CMF_OFFSETPITCH | CMF_SAVEPITCH)
			"----" A 0 A_JumpIfInventory("MeleeMiss", 5, "See")
			
				"----" A 0 A_JumpIfInventory("MeleeHitSuccess", 1, 4) // if we hit, your invisibility doesn't count. We SAW.
				//***Che: do NOT adjust aim if target goes out of sight or is invisible
				"----" A 0 A_JumpIf(CallAcs("FBD_TargetIsInvisible"), 4)
				"----" A 0 A_JumpIfTargetInLOS(2)
				"----" A 0 A_Jump(256, 2)
				"----" A 0 A_FaceTarget
				"----" A 0 A_TakeInventory("MeleeHitSuccess", 1) // while successful sawing gives +2			
				
			"----" A 0 A_JumpIfInventory("MeleeHitSuccess", 1, 1)
			Goto WeaponFinish	
			
			"----" A 0 A_Recoil(-2)
			"----" A 0 A_M_Saw("weapons/chainsaw/loop", "CSAWCUT", 1, "SSawPuff2") 
			MAR1 C 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 3, 0, 44)
			MAR1 CC 1 A_CustomMissile("EvilSawDamageVertical",35,0,angle, CMF_ABSOLUTEANGLE | CMF_OFFSETPITCH | CMF_SAVEPITCH)
			"----" A 0 A_JumpIfInventory("MeleeMiss", 5, "See")
			
				"----" A 0 A_JumpIfInventory("MeleeHitSuccess", 1, 4) // if we hit, your invisibility doesn't count. We SAW.
				//***Che: do NOT adjust aim if target goes out of sight or is invisible
				"----" A 0 A_JumpIf(CallAcs("FBD_TargetIsInvisible"), 4)
				"----" A 0 A_JumpIfTargetInLOS(2)
				"----" A 0 A_Jump(256, 2)
				"----" A 0 A_FaceTarget
				"----" A 0 A_TakeInventory("MeleeHitSuccess", 1) // while successful sawing gives +2
				
			"----" A 0 A_JumpIfInventory("MeleeHitSuccess", 1, 1)
			Goto WeaponFinish	
			
			"----" A 0 A_Recoil(-2)
			"----" A 0 A_M_Saw("weapons/chainsaw/loop", "CSAWCUT", 1, "SSawPuff2") 
			MAR1 D 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 3, 0, 43)
			MAR1 DD 1 A_CustomMissile("EvilSawDamageVertical",35,0,angle, CMF_ABSOLUTEANGLE | CMF_OFFSETPITCH | CMF_SAVEPITCH)
			"----" A 0 A_JumpIfInventory("MeleeMiss", 5, "See")
			
				"----" A 0 A_JumpIfInventory("MeleeHitSuccess", 1, 4) // if we hit, your invisibility doesn't count. We SAW.
				//***Che: do NOT adjust aim if target goes out of sight or is invisible
				"----" A 0 A_JumpIf(CallAcs("FBD_TargetIsInvisible"), 4)
				"----" A 0 A_JumpIfTargetInLOS(2)
				"----" A 0 A_Jump(256, 2)
				"----" A 0 A_FaceTarget
				"----" A 0 A_TakeInventory("MeleeHitSuccess", 1) // while successful sawing gives +2			
			
			"----" A 0 A_JumpIfInventory("MeleeHitSuccess", 1, 1)
			Goto WeaponFinish
			
			"----" A 0 A_Jump(24, "WeaponFinish") // caannot saw indefinitely!
			
			// must check if target is dead! Otherwise gets stuck sawing indestructible corpses that bleed :(
			// also breaks cycle if target moves aways
			MAR1 D 0 A_JumpIfTargetInLOS("KeepSawing",0,JLOSF_DEADNOJUMP,96)
			Goto WeaponFinish
			
			
		SummonAttack: // weapon phase jumps here if tries firing a summon weapon	
			
			"----" A 0 A_JumpIfInventory("SummonsCount", user_maradeur == 3 ? 5 : 2, "SummonedEnough") // 1 => none, 2 => 2, 3 => 5
			
			// pkik abc - he summons the dogs by kicking them. They yelp
			
			PLA1 A 6 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 5, 0, 41)
			PKIK A 6 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 2, 0, 39)
			PKIK B 4 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 5, 0, 42)
			
			// spawn it inside himself but at a height of 20 with a hefty forward velocity.
			// this way, no chance to fail due to not enough space
			// the hellhound has EvilMarines species +THRUSPECIES
			"----" A 0 A_SpawnItemEx("HellHoundSummon",0,0,20, 10,0,0, 0,SXF_SETMASTER | SXF_NOCHECKPOSITION,0)
			// HellhoundSummon increases its masters' SummonsCount on spawn 
			//   and decreases it on death.
			// So, he is always aware how many summons he has out
			
			PKIK C 6 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 3, 0, 41)
			PLA1 A 6 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 5, 0, 41)
			
			Goto DodgeRoll // ignore dodge-roll cooldown. (jumps to Missile afterwards)
			
		SummonedEnough:
			"----" A 0 A_SetUserVar("user_summon_cooldown", 350) // 10 seconds
			Goto WeaponFinish
	

		AnimFrameJ:
			"----" A 0 A_JumpIf(user_weapon == 3, "AnimFrameJ_Chainsaw")
			"----" A 0 A_JumpIf(user_weapon == 4, "AnimFrameJ_Rifle")
			"----" A 0 A_JumpIf(user_weapon == 5, "AnimFrameJ_Shotgun")
			"----" A 0 A_JumpIf(user_weapon == 6, "AnimFrameJ_SSG")
			"----" A 0 A_JumpIf(user_weapon == 7, "AnimFrameJ_Minugun")
			"----" A 0 A_JumpIf(user_weapon == 8, "AnimFrameJ_RL")
			"----" A 0 A_JumpIf(user_weapon == 9, "AnimFrameJ_Plasma")
			"----" A 0 A_JumpIf(user_weapon == 10, "AnimFrameJ_Railgun")
			"----" A 0 A_JumpIf(user_weapon == 11, "AnimFrameJ_BFG") 
			"----" A 0 A_JumpIf(user_weapon == 12, "AnimFrameJ_10K") 
			"----" A 0 A_JumpIf(user_weapon == 13, "AnimFrameJ_Unmaker") 
			"----" A 0 A_JumpIf(user_weapon == 16, "AnimFrameJ_MG42")
		AnimFrameJ_Fists:
			PLA1 J 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -4, 1, 45)
			Goto WeaponPhase
		AnimFrameJ_Chainsaw:
			// not actually a jump frame, using one ofthhe attack frames (leap attack)
			MAR1 Y 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -12, 2, 43)
			Goto WeaponPhase
		AnimFrameJ_Rifle:
			//***Che: a *second* circumstance, beside SSG, where jumping animation exists 
			// and has radically different muzzle z
			// Sorry only noticed it when began porting the rifle marine from the original BD code
			TNT1 A 0 A_SetUserVar("user_muzzle_z", 31)
			MARJ A 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 0, 1, 43)
			Goto WeaponPhase
		AnimFrameJ_Shotgun:
			// no jumping frame
			MAR3 A 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -4, 2, 45)
			Goto WeaponPhase
		AnimFrameJ_SSG:
			//***Che: a reminder: this jumping stuff *only* appears here in the SSG marine (also in Maradeur)
			// because only the SSG marine has a jumping frame that doesn't look like a walking frame
			TNT1 A 0 A_SetUserVar("user_muzzle_z", 36) // unique circumstance of the animation phase affecting the weapon phase
			MSSG J 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -2, 2, 47)
			Goto WeaponPhase
		AnimFrameJ_Minugun:
			// no jumping frame, using the standing frame
			MAR4 A 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -10, 0, 43)
			Goto WeaponPhase
		AnimFrameJ_RL:
            // no jumping frame, using the standing frame
			PL5S A 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -10, 1, 44)
			Goto WeaponPhase
		AnimFrameJ_Plasma:
			MAR6 J 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -12, 2, 47)
			Goto WeaponPhase
		AnimFrameJ_Railgun:
			MRGA A 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -10, 1, 45)
			Goto WeaponPhase
		AnimFrameJ_BFG:
			// no jumping frame, using the standing frame
			PLA7 A 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 5, 0, 43)
			Goto WeaponPhase
		AnimFrameJ_10K:
			// no jumping frame, using the standing frame
			M10K A 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -8, 0, 44)
			Goto WeaponPhase
		AnimFrameJ_Unmaker:
			// no jumping frame, using the standing frame
			P7UM A 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 0, 0, 48)
			Goto WeaponPhase
		AnimFrameJ_MG42:
			// no jumping frame, using the standing frame
			P842 A 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 0, 0, 46)
			Goto WeaponPhase			
		

		AnimFrame1:
			"----" A 0 A_JumpIf(user_weapon == 3, "AnimFrame1_Chainsaw")
			"----" A 0 A_JumpIf(user_weapon == 4, "AnimFrame1_Rifle")
			"----" A 0 A_JumpIf(user_weapon == 5, "AnimFrame1_Shotgun")
			"----" A 0 A_JumpIf(user_weapon == 6, "AnimFrame1_SSG")
			"----" A 0 A_JumpIf(user_weapon == 7, "AnimFrame1_Minugun")
			"----" A 0 A_JumpIf(user_weapon == 8, "AnimFrame1_RL")
			"----" A 0 A_JumpIf(user_weapon == 9, "AnimFrame1_Plasma")
			"----" A 0 A_JumpIf(user_weapon == 10, "AnimFrame1_Railgun")
			"----" A 0 A_JumpIf(user_weapon == 11, "AnimFrame1_BFG") 
			"----" A 0 A_JumpIf(user_weapon == 12, "AnimFrame1_10K") 
			"----" A 0 A_JumpIf(user_weapon == 13, "AnimFrame1_Unmaker") 
			"----" A 0 A_JumpIf(user_weapon == 16, "AnimFrame1_MG42") 
		AnimFrame1_Fists:
			PLA1 A 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 5, 0, 42)
			Goto WeaponPhase
		AnimFrame1_Chainsaw:
			MAR1 P 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 6, 0, 43)
			Goto WeaponPhase
		AnimFrame1_Rifle:
			//***Che: a *second* circumstance, beside SSG, where jumping animation exists 
			// and has radically different muzzle z
			// Sorry only noticed it when began porting the rifle marine from the original BD code
			TNT1 A 0 A_SetUserVar("user_muzzle_z", 42)
			MAR2 A 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 2, 3, 45)
			Goto WeaponPhase
		AnimFrame1_Shotgun:
			MAR3 A 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -4, 2, 45)
			Goto WeaponPhase
		AnimFrame1_SSG:
			//***Che: a reminder: this jumping stuff *only* appears here in the SSG marine (also in Maradeur)
			// because only the SSG marine has a jumping frame that doesn't look like a walking frame
			TNT1 A 0 A_SetUserVar("user_muzzle_z", 31) // unique circumstance of the animation phase affecting the weapon phase
			MSSG A 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -4, 2, 45)
			Goto WeaponPhase
		AnimFrame1_Minugun:
			MAR4 A 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -10, 0, 43)
			Goto WeaponPhase
		AnimFrame1_RL:
			PL5S A 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -10, 1, 44)
			Goto WeaponPhase
		AnimFrame1_Plasma:
			MAR6 A 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -8, 2, 41)
			Goto WeaponPhase
		AnimFrame1_Railgun:
			MRGA A 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -10, 1, 45)
			Goto WeaponPhase
		AnimFrame1_BFG:
			PLA7 A 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -10, 0, 43)
			Goto WeaponPhase
		AnimFrame1_10K:
			M10K A 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -4, -1, 44)
			Goto WeaponPhase
		AnimFrame1_Unmaker:
			P7UM A 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 0, 0, 46)
			Goto WeaponPhase
		AnimFrame1_MG42:
			P842 A 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 0, 0, 46)
			Goto WeaponPhase			
			
		AnimFrame2:
			"----" A 0 A_JumpIf(user_weapon == 3, "AnimFrame2_Chainsaw")
			"----" A 0 A_JumpIf(user_weapon == 4, "AnimFrame2_Rifle")
			"----" A 0 A_JumpIf(user_weapon == 5, "AnimFrame2_Shotgun")
			"----" A 0 A_JumpIf(user_weapon == 6, "AnimFrame2_SSG")
			"----" A 0 A_JumpIf(user_weapon == 7, "AnimFrame2_Minugun")
			"----" A 0 A_JumpIf(user_weapon == 8, "AnimFrame2_RL")
			"----" A 0 A_JumpIf(user_weapon == 9, "AnimFrame2_Plasma")
			"----" A 0 A_JumpIf(user_weapon == 10, "AnimFrame2_Railgun")
			"----" A 0 A_JumpIf(user_weapon == 11, "AnimFrame2_BFG")
			"----" A 0 A_JumpIf(user_weapon == 12, "AnimFrame2_10K") 
			"----" A 0 A_JumpIf(user_weapon == 13, "AnimFrame2_Unmaker") 
			"----" A 0 A_JumpIf(user_weapon == 16, "AnimFrame2_MG42") 
		AnimFrame2_Fists:
			PLA1 B 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 5, 0, 45)
			Goto WeaponPhase
		AnimFrame2_Chainsaw:
			MAR1 Q 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 0, 0, 45)
			Goto WeaponPhase
		AnimFrame2_Rifle:
			TNT1 A 0 A_SetUserVar("user_muzzle_z", 39)
			MAR2 B 1
			Goto WeaponPhase
		AnimFrame2_Shotgun:
			MAR3 B 1
			Goto WeaponPhase
		AnimFrame2_SSG:
			TNT1 A 0 A_SetUserVar("user_muzzle_z", 31)
			MSSG B 1
			Goto WeaponPhase
		AnimFrame2_Minugun:
			MAR4 B 1
			Goto WeaponPhase
		AnimFrame2_RL:
			PL5S B 1
			Goto WeaponPhase
		AnimFrame2_Plasma:
			MAR6 B 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -11, 3, 43)
			Goto WeaponPhase
		AnimFrame2_Railgun:
			MRGA B 1
			Goto WeaponPhase
		AnimFrame2_BFG:
			PLA7 B 1
			Goto WeaponPhase
		AnimFrame2_10K:
			M10K B 1
			Goto WeaponPhase
		AnimFrame2_Unmaker:
			P7UM B 1
			Goto WeaponPhase
		AnimFrame2_MG42:
			P842 B 1
			Goto WeaponPhase

		AnimFrame3:
			"----" A 0 A_JumpIf(user_weapon == 3, "AnimFrame3_Chainsaw")
			"----" A 0 A_JumpIf(user_weapon == 4, "AnimFrame3_Rifle")
			"----" A 0 A_JumpIf(user_weapon == 5, "AnimFrame3_Shotgun")
			"----" A 0 A_JumpIf(user_weapon == 6, "AnimFrame3_SSG")
			"----" A 0 A_JumpIf(user_weapon == 7, "AnimFrame3_Minugun")
			"----" A 0 A_JumpIf(user_weapon == 8, "AnimFrame3_RL")
			"----" A 0 A_JumpIf(user_weapon == 9, "AnimFrame3_Plasma")
			"----" A 0 A_JumpIf(user_weapon == 10, "AnimFrame3_Railgun")
			"----" A 0 A_JumpIf(user_weapon == 11, "AnimFrame3_BFG") 
			"----" A 0 A_JumpIf(user_weapon == 12, "AnimFrame3_10K")
			"----" A 0 A_JumpIf(user_weapon == 13, "AnimFrame3_Unmaker")
			"----" A 0 A_JumpIf(user_weapon == 16, "AnimFrame3_MG42")
		AnimFrame3_Fists:
			PLA1 C 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 5, 0, 41)
			Goto WeaponPhase
		AnimFrame3_Chainsaw:
			MAR1 R 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 0, -1, 43)
			Goto WeaponPhase
		AnimFrame3_Rifle:
			TNT1 A 0 A_SetUserVar("user_muzzle_z", 39)
			MAR2 C 1
			Goto WeaponPhase
		AnimFrame3_Shotgun:
			MAR3 C 1
			Goto WeaponPhase
		AnimFrame3_SSG:
			TNT1 A 0 A_SetUserVar("user_muzzle_z", 31)
			MSSG C 1
			Goto WeaponPhase
		AnimFrame3_Minugun:
			MAR4 C 1
			Goto WeaponPhase
		AnimFrame3_RL:
			PL5S C 1
			Goto WeaponPhase
		AnimFrame3_Plasma:
			MAR6 C 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -9, 1, 41)
			Goto WeaponPhase
		AnimFrame3_Railgun:
			MRGA C 1
			Goto WeaponPhase
		AnimFrame3_BFG:
			PLA7 C 1
			Goto WeaponPhase
		AnimFrame3_10K:
			M10K C 1
			Goto WeaponPhase
		AnimFrame3_Unmaker:
			P7UM C 1
			Goto WeaponPhase
		AnimFrame3_MG42:
			P842 C 1
			Goto WeaponPhase			
			
		AnimFrame4:
			"----" A 0 A_JumpIf(user_weapon == 3, "AnimFrame4_Chainsaw")
			"----" A 0 A_JumpIf(user_weapon == 4, "AnimFrame4_Rifle")
			"----" A 0 A_JumpIf(user_weapon == 5, "AnimFrame4_Shotgun")
			"----" A 0 A_JumpIf(user_weapon == 6, "AnimFrame4_SSG")
			"----" A 0 A_JumpIf(user_weapon == 7, "AnimFrame4_Minugun")
			"----" A 0 A_JumpIf(user_weapon == 8, "AnimFrame4_RL")
			"----" A 0 A_JumpIf(user_weapon == 9, "AnimFrame4_Plasma")
			"----" A 0 A_JumpIf(user_weapon == 10, "AnimFrame4_Railgun")
			"----" A 0 A_JumpIf(user_weapon == 11, "AnimFrame4_BFG") 
			"----" A 0 A_JumpIf(user_weapon == 12, "AnimFrame4_10K") 
			"----" A 0 A_JumpIf(user_weapon == 13, "AnimFrame4_Unmaker")
			"----" A 0 A_JumpIf(user_weapon == 16, "AnimFrame4_MG42") 
		AnimFrame4_Fists:
			PLA1 D 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 5, 0, 43)
			Goto WeaponPhase
		AnimFrame4_Chainsaw:
			MAR1 S 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", 0, -2, 44)
			Goto WeaponPhase
		AnimFrame4_Rifle:
			TNT1 A 0 A_SetUserVar("user_muzzle_z", 39)
			MAR2 D 1
			Goto WeaponPhase
		AnimFrame4_Shotgun:
			MAR3 D 1
			Goto WeaponPhase
		AnimFrame4_SSG:
			TNT1 A 0 A_SetUserVar("user_muzzle_z", 31)
			MSSG D 1
			Goto WeaponPhase
		AnimFrame4_Minugun:
			MAR4 D 1
			Goto WeaponPhase
		AnimFrame4_RL:
			PL5S D 1
			Goto WeaponPhase
		AnimFrame4_Plasma:
			MAR6 D 1 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -8, 3, 41)
			Goto WeaponPhase
		AnimFrame4_Railgun:
			MRGA D 1
			Goto WeaponPhase
		AnimFrame4_BFG:
			PLA7 D 1
			Goto WeaponPhase	
		AnimFrame4_10K:
			M10K D 1
			Goto WeaponPhase
		AnimFrame4_Unmaker:
			P7UM D 1
			Goto WeaponPhase
		AnimFrame4_MG42:
			P842 D 1
			Goto WeaponPhase				
			
			
		Pain_Fists:
			"----" A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -11, -8, 44)
			PLA1 G 3 A_Pain
			PLA1 G 0 A_Jump(192, "DodgeRoll")
			PLA1 G 3
			Goto ShuffleFromPain
		Pain_Chainsaw:
			"----" A 0
			"----" A 0 A_ChangeFlag("NODROPOFF", 0)
			"----" A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -12, -8, 43)
			MAR1 E 3 A_Pain
			Goto PainContinue	
		Pain_Rifle:
			"----" A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -10, -8, 44)
			PLAY G 3 A_Pain
			Goto PainContinue
		Pain_Shotgun:
			"----" A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -10, -5, 44)
			"----" A 0 A_ChangeFlag("NODROPOFF", 0)
			"----" A 0 A_ChangeFlag("NOPAIN", 1)
			MAR3 E 3 A_Pain
			// pain interrupts his "charge" (merely a pre-firing pause) allowing him dodge-rolling
			//"----" A 0 A_JumpIf(user_charge && user_shots, "ShuffleFromPain") // don't interrupt charging, this jumps back into the synth loop
			"----" A 0 A_SetUserVar("user_charge", 0)
			"----" A 0 A_SetUserVar("user_shots", 0) // interrupt the firing burst
			Goto PainContinue
		Pain_SSG:
			"----" A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -11, -2, 45)
			"----" A 0 A_ChangeFlag("NOPAIN", 1)
			MSSG E 3 A_Pain
			"----" A 0 A_SetUserVar("user_shots", 0) // interrupt the firing burst
			"----" A 0 A_SetUserVar("user_notarget_cooldown", user_ambush_duration) // make the synth loop end as soon as weapon cooldown ends
			"----" A 0 A_JumpIf(user_charge && user_shots, "ShuffleFromPain") // don't interrupt charging, this jumps back into the synth loop
			"----" A 0 A_Jump(192, "DodgeRoll")
			Goto PainContinue
		Pain_Minugun:
			"----" A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -10, -2, 43)
			"----" A 0 A_ChangeFlag("NOPAIN", 1)
			MAR4 E 3 A_Pain
			"----" A 0 A_JumpIf(user_charge && user_shots > 3, "ShuffleFromPain") // don't interrupt charging, this jumps back into the synth loop
			"----" A 0 A_SetUserVar("user_shots", 0) // interrupt the firing burst
			Goto PainContinue
		Pain_RL:
			"----" A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -11, -6, 42)
			"----" A 0 A_ChangeFlag("NOPAIN", 1)
			PL5S G 3 A_Pain
			// pain interrupts his "charge" (merely a pre-firing pause) allowing him dodge-rolling
			"----" A 0 A_SetUserVar("user_charge", 0)
			"----" A 0 A_SetUserVar("user_shots", 0) // interrupt the firing burst
			Goto PainContinue
		Pain_Plasma:
			"----" A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -11, -7, 44) //-13, -7, 40)  capped @11
			PLA6 G 3 A_Pain
			Goto PainContinue
		Pain_Railgun:
			"----" A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -11, -8, 45)
			"----" A 0 A_ChangeFlag("NOPAIN", 1)
			MRRG E 3 A_Pain
			// pain interrupts his "charge" (merely a pre-firing pause) allowing him dodge-rolling
			//"----" A 0 A_JumpIf(user_charge && user_shots, "ShuffleFromPain") // don't interrupt charging, this jumps back into the synth loop
			"----" A 0 A_SetUserVar("user_charge", 0)
			"----" A 0 A_SetUserVar("user_shots", 0) // interrupt the firing burst
			Goto PainContinue
		Pain_BFG:
			"----" A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -13, -7, 44)
			"----" A 0 A_ChangeFlag("NOPAIN", 1)
			PLA7 G 3 A_Pain
			// do NOT interrupt charging
			"----" A 0 A_JumpIf(user_charge && user_charge < user_charge_time, "ShuffleFromPain") // don't interrupt charging, this jumps back into the synth loop
			Goto PainContinue
		Pain_10K:
			"----" A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -11, -10, 44)
			"----" A 0 A_ChangeFlag("NOPAIN", 1)
			M10K E 3 A_Pain
			// do NOT interrupt charging
			"----" A 0 A_JumpIf(user_charge && user_charge < user_charge_time, "ShuffleFromPain") // don't interrupt charging, this jumps back into the synth loop
			Goto PainContinue			
		Pain_Unmaker:
			"----" A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -8, -2, 45)
			"----" A 0 A_ChangeFlag("NOPAIN", 1)
			P7UM G 3 A_Pain
			// do NOT interrupt charging
			"----" A 0 A_JumpIf(user_charge && user_charge < user_charge_time, "ShuffleFromPain") // don't interrupt charging, this jumps back into the synth loop
			Goto PainContinue
		Pain_MG42:
			"----" A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -9, -2, 45)
			"----" A 0 A_ChangeFlag("NOPAIN", 1)
			M842 G 3 A_Pain
			// pain interrupts his "charge" (merely a pre-firing pause) allowing him dodge-rolling
			//"----" A 0 A_JumpIf(user_charge && user_shots, "ShuffleFromPain") // don't interrupt charging, this jumps back into the synth loop
			"----" A 0 A_SetUserVar("user_charge", 0)
			"----" A 0 A_SetUserVar("user_shots", 0) // interrupt the firing burst
			Goto PainContinue			
			
		
		WpnFire_Rifle:
			"----" A 0 A_PlaySound("weapons/rifle") // not on the weapon channel, allowing them to overlap
			"----" A 0 A_SpawnItem ("RifleCaseSpawn", 0, 30,0)
			"----" A 0 A_CustomMissile("EvilTracer",user_muzzle_z,0,angle + 0.01 * random(-50, 50), CMF_ABSOLUTEANGLE | (user_best_d ? CMF_AIMDIRECTION : CMF_OFFSETPITCH) | CMF_SAVEPITCH, (user_best_d ? user_best_p * 0.005493164 : 0) + 0.01 * random(-50, 50))
			// CMF_AIMDIRECTION's effect is auto-setting CMF_ABSOLUTEPITCH internally! -- meaning you have to provide the pitch yourself
			"----" A 0 A_SpawnItemEx("PlayerMuzzle1",27,6,user_muzzle_z, 0,0,0, 0,SXF_NOCHECKPOSITION)
			
			// while can seee target, randomly increase burst length -- just a little bit:
			"----" A 0 A_JumpIf(CallAcs("FBD_TargetIsInvisible"), "WeaponAfterFiring")
			"----" A 0 A_JumpIfTargetInLOS(1, 0, JLOSF_DEADNOJUMP) 
			Goto WeaponAfterFiring
			"----" A 0 A_Jump(24, "OneMoreShot")
			Goto WeaponAfterFiring
		WpnFire_Shotgun:
			"----" A 0 A_CustomMissile("DistantFireSoundShotgun", user_muzzle_z, 0, 0, CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH, 0)
			"----" A 0 A_PlaySound("weapons/sg", CHAN_WEAPON)
			"----" A 0 A_PlaySound("weapons/sgpump", 5)

			
			// visual effects:
			"----" AAAAAAAA 0 A_CustomMissile("ShotgunParticles", user_muzzle_z, 0, angle + random(-12, 12), CMF_ABSOLUTEANGLE | (user_best_d ? CMF_AIMDIRECTION : CMF_OFFSETPITCH) | CMF_SAVEPITCH, (user_best_d ? user_best_p * 0.005493164 : 0) + random(-9, 9))	
			"----" A 0 A_SpawnItemEx("PlayerMuzzle2",24,10,user_muzzle_z, 0,0,0, 0,SXF_NOCHECKPOSITION)
			
			// perfectly mimic the spread of player's weapon with only half the pellet number (5 vs 9):
			"----" AA 0 A_CustomMissile("ShotgunguyTracer", 36, 0, 0.05 * random(-50, 50) + angle, CMF_ABSOLUTEANGLE | (user_best_d ? CMF_AIMDIRECTION : CMF_OFFSETPITCH) | CMF_SAVEPITCH, (user_best_d ? user_best_p * 0.005493164 : 0) + 0.05 * random(-10, 10))
			"----" AAA 0 A_CustomMissile("ShotgunguyTracer", 36, 0, 0.05 * random(-25, 25) + angle, CMF_ABSOLUTEANGLE | (user_best_d ? CMF_AIMDIRECTION : CMF_OFFSETPITCH) | CMF_SAVEPITCH, (user_best_d ? user_best_p * 0.005493164 : 0) + 0.05 * random(-25, 25))
			
			// player's:
			// SHTN A 0 A_FireBullets (5, 1, 4, 13, "ShotgunPuff", FBF_NORANDOM)
			// SHTN A 0 A_FireBullets (2.5, 2.5, 5, 13, "ShotgunPuff2", FBF_NORANDOM)
			
			// CMF_ABSOLUTEANGLE is required for shotguns to avoid extra spread
			//    at invisible targets adding to shotgun's spread.
			// Otherwise, CMF_AIMDIRECTION would be preferrable

			Goto WeaponAfterFiring		
			
		WpnFire_SSG:
			"----" A 0 A_CustomMissile("DistantFireSoundSSG", user_muzzle_z, 0, 0, CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH, 0)
			"----" A 0 A_PlaySound("SSHFIRE", CHAN_WEAPON)
			// visual effects:
			"----" AAAAAAAA 0 A_CustomMissile("ShotgunParticles", user_muzzle_z, 0, angle + random(-12, 12), CMF_ABSOLUTEANGLE | (user_best_d ? CMF_AIMDIRECTION : CMF_OFFSETPITCH) | CMF_SAVEPITCH, (user_best_d ? user_best_p * 0.005493164 : 0) + random(-9, 9))	
			"----" A 0 A_SpawnItemEx("PlayerMuzzle3",30,8,user_muzzle_z, 0,0,0, 0,SXF_NOCHECKPOSITION)

			
			// just like regular shotgun guy, fires *half* the number of tracers compared to player's SSG
			// with each tracer doing nearly as much damage (12 vs 13)
			// Respecting the rule than monsters' weapons on UV do half the player weapons' damage.
			// If you want equality, FBD provides the "Equality" skills set, 
			// with monsters buffed to 200% making their weapons equal to yours.
			"----" A 0 A_CustomMissile("EvilShotpuff", user_muzzle_z, 0, angle, CMF_ABSOLUTEANGLE | (user_best_d ? CMF_AIMDIRECTION : CMF_OFFSETPITCH) | CMF_SAVEPITCH, user_best_d ? user_best_p * 0.005493164 : 0)
			
			// perfectly mimic the spread of player's weapon with only half the pellet number
			"----" AAAA 0 A_CustomMissile("ShotgunguyTracer", user_muzzle_z, 0, angle + 0.1 * random(-50, 50), CMF_ABSOLUTEANGLE | (user_best_d ? CMF_AIMDIRECTION : CMF_OFFSETPITCH) | CMF_SAVEPITCH, (user_best_d ? user_best_p * 0.005493164 : 0) + 0.1 * random(-5, 5))
			"----" AAAAA 0 A_CustomMissile("ShotgunguyTracer", user_muzzle_z, 0,angle +  0.1 * random(-30, 30), CMF_ABSOLUTEANGLE | (user_best_d ? CMF_AIMDIRECTION : CMF_OFFSETPITCH) | CMF_SAVEPITCH, (user_best_d ? user_best_p * 0.005493164 : 0) + 0.1 * random(-15, 15))
			
			// CMF_ABSOLUTEANGLE is required for sotguns to avoid extra spread at invisible adding to shotgun's spread.
			// Otherwise, CMF_AIMDIRECTION would be preferrable
			
			Goto WeaponAfterFiring

		WpnFire_Minugun:
			//***Che: poor thing doen't know what a division remainder is, got confused by '%' in (user_shots % 2)
			//***Che: it *does* -- the problem is you CANNOT use trinary operators to swap strings
			//  Obviously, unlike ACS, in DECORATE strings aren't integer indices.
			//"----" A 0 A_SpawnItemEx((user_shots - (user_shots / 2) * 2 > 0) ? "PlayerMuzzle2" : "PlayerMuzzle1", user_muzzle_z,9,27, 0,0,0, 0,SXF_NOCHECKPOSITION)
			//Execution could not continue.
			//Script error, "chebskies-EDAY-2.pk3:marines_evil.txt" line 818:
			//Expected ',', got 'user_shots'.

			"----" A 0 A_JumpIf(user_shots % 2, 3)
			"----" A 0 A_SpawnItemEx("PlayerMuzzle1", user_muzzle_z,9,27, 0,0,0, 0,SXF_NOCHECKPOSITION)
			"----" A 0 A_Jump(256, 2)
			"----" A 0 A_SpawnItemEx("PlayerMuzzle2", user_muzzle_z,9,27, 0,0,0, 0,SXF_NOCHECKPOSITION)
			
			"----" A 0 A_PlaySound ("CHGNSHOT", CHAN_WEAPON)
			"----" A 0 A_PlaySound("FARMGN", 5)
			"----" A 0 A_SpawnItem ("RifleCaseSpawn", 0, 30,0)

			"----" A 0 A_CustomMissile("MonsterMinigunTracer", user_muzzle_z, 0, angle + 0.1 * Random(-25, 25), CMF_ABSOLUTEANGLE | (user_best_d ? CMF_AIMDIRECTION : CMF_OFFSETPITCH) | CMF_SAVEPITCH, (user_best_d ? user_best_p * 0.005493164 : 0) + 0.1 * Random(-25, 25)) 

			"----" A 0 A_JumpIf(CallAcs("FBD_TargetIsInvisible"), "WeaponAfterFiring")
			"----" A 0 A_JumpIfTargetInLOS(1, 0, JLOSF_DEADNOJUMP) 
			Goto WeaponAfterFiring
			"----" A 0 A_Jump(96, "OneMoreShot")
			Goto WeaponAfterFiring
			
		WpnFire_MG42:
			//user_muzzle_z = 36
			"----" A 0 A_JumpIf(user_shots % 2, 3)
			"----" A 0 A_SpawnItemEx("PlayerMuzzle1", 45,6,user_muzzle_z, 0,0,0, 0,SXF_NOCHECKPOSITION)
			"----" A 0 A_Jump(256, 2)
			"----" A 0 A_SpawnItemEx("PlayerMuzzle2", 45,6,user_muzzle_z, 0,0,0, 0,SXF_NOCHECKPOSITION)
			
			"----" A 0 A_PlaySound("m14FIRE", user_shots % 2 ? CHAN_WEAPON : 5)
			"----" A 0 A_PlaySound("FARM14", user_shots % 2 ? 6 : 7)
			"----" A 0 A_SpawnItem ("RifleCaseSpawn", 0, 40,0)

			// 25 damage (50 on Equality skills)
			"----" A 0 A_CustomMissile("EnemyHeavyMachinegunProjectile", user_muzzle_z, 0, angle + 0.1 * Random(-15, 15), CMF_ABSOLUTEANGLE | (user_best_d ? CMF_AIMDIRECTION : CMF_OFFSETPITCH) | CMF_SAVEPITCH, (user_best_d ? user_best_p * 0.005493164 : 0) + 0.1 * Random(-15, 15)) 

			"----" A 0 A_JumpIf(CallAcs("FBD_TargetIsInvisible"), "WeaponAfterFiring")
			"----" A 0 A_JumpIfTargetInLOS(1, 0, JLOSF_DEADNOJUMP) 
			Goto WeaponAfterFiring
			"----" A 0 A_Jump(96, "OneMoreShot")
			Goto WeaponAfterFiring			

		WpnFire_RL:
			// no muzzle flash
			"----" A 0 A_PlaySound ("DSRFIRE", CHAN_WEAPON)
			
			// makes cacoes dodge the incoming rocket
			"----" A 0 A_CustomMissile("Alerter", user_muzzle_z, 0, angle, CMF_ABSOLUTEANGLE | (user_best_d ? CMF_AIMDIRECTION : CMF_OFFSETPITCH) | CMF_SAVEPITCH, user_best_d ? user_best_p * 0.005493164 : 0) 
			
			"----" A 0 A_CustomMissile("EvmRocket", user_muzzle_z, 0, angle, CMF_ABSOLUTEANGLE | (user_best_d ? CMF_AIMDIRECTION : CMF_OFFSETPITCH) | CMF_SAVEPITCH, user_best_d ? user_best_p * 0.005493164 : 0) 
			"----" A 0 A_CustomMissile("RocketGlassBreaker", user_muzzle_z, 0, angle, CMF_ABSOLUTEANGLE | (user_best_d ? CMF_AIMDIRECTION : CMF_OFFSETPITCH) | CMF_SAVEPITCH, user_best_d ? user_best_p * 0.005493164 : 0) 
			Goto WeaponAfterFiring
			
		WpnFire_Plasma:
			"----" A 0 A_CustomMissile("EnemyPlasmaBall",user_muzzle_z,0,angle, CMF_ABSOLUTEANGLE | (user_best_d ? CMF_AIMDIRECTION : CMF_OFFSETPITCH) | CMF_SAVEPITCH, user_best_d ? user_best_p * 0.005493164 : 0)
			
			// while can seee target, randomly increase burst length:
			"----" A 0 A_JumpIf(CallAcs("FBD_TargetIsInvisible"), "WeaponAfterFiring")
			"----" A 0 A_JumpIfTargetInLOS(1, 0, JLOSF_DEADNOJUMP) 
			Goto WeaponAfterFiring
			"----" A 0 A_Jump(96, "OneMoreShot")
			Goto WeaponAfterFiring
		WpnFire_Railgun:
			// no muzzle flash
			
			"----" A 0 A_PlaySound("RAILF1", CHAN_WEAPON)
			
			//"----" A 0 A_CustomMissile("RailgunTrailEffectMissile", user_muzzle_z, 0, angle, CMF_ABSOLUTEANGLE | CMF_OFFSETPITCH | CMF_SAVEPITCH, 0) 
			//"----" A 0 A_CustomMissile("EvnRailgunWallPenetrator", user_muzzle_z, 0, angle, CMF_ABSOLUTEANGLE | CMF_OFFSETPITCH | CMF_SAVEPITCH, 0) 
			
			// Insert here many colorful words about rail pitch autoaim 
			// implementation and it desyncing from the penetrator projectiles.
			
			// NOT possible to use the true rail:
			// railgun is only autoaimed vertically if its vertical plane 
			// would hit the target at the given angle (otherwise is fired horizontally)
			// OR the booleam "aim" parameter is set to TRUE.
			// BUT, if the "aim" is true, it forces horizontal auto-aim 
			//  disregarding actor's angle and making my blindfire algos useles
			
			//"----" A 0 A_CustomRailgun(200, 0, "95b2fc", "4b61ff", RGF_FULLBRIGHT, 0, 0, "RailgunPuff2", 0,0,0,0,1.0,1.0,None, user_muzzle_z - height /2 - 8)
			//player's RAIL A 0 A_RailAttack(400, 0, 0, None, None, RGF_FULLBRIGHT, 1, "RailgunPuff2")
			
			// In other words, excuse me, FUCK!!!!!
			
			// But I am the mighty Cheb, I code around that in 40 minutes 
			// even dead tired after a solid day of coding.
			
			// Soooo we use a fastprojectile that only hits *one* actor 
			// then spawns another projectile that refires the railgun beam
			// behind that actor 64 map units down the verctor after the impact point.

			
			"----" A 0 A_CustomMissile("EvmRailgunHACK", user_muzzle_z, 0, angle, CMF_ABSOLUTEANGLE | (user_best_d ? CMF_AIMDIRECTION : CMF_OFFSETPITCH) | CMF_SAVEPITCH, user_best_d ? user_best_p * 0.005493164 : 0) 

			Goto WeaponAfterFiring
			
		WpnFire_BFG:
			"----" A 0 A_PlaySound("misc/supermaster_bfg_fir", CHAN_WEAPON)  // much larger roloff dist
			"----" A 0 A_SpawnItemEx("BFGMuzzle3",30,7,30, momx,momy,momz, 0,SXF_NOCHECKPOSITION | SXF_ABSOLUTEVELOCITY)
			"----" A 0 A_CustomMissile("EnemyBFGBall", user_muzzle_z, 0, angle, CMF_ABSOLUTEANGLE | (user_best_d ? CMF_AIMDIRECTION : CMF_OFFSETPITCH) | CMF_SAVEPITCH, user_best_d ? user_best_p * 0.005493164 : 0)
			Goto WeaponAfterFiring
			
		WpnFire_10K:
			"----" A 0 A_PlaySound("maradeur/10k_fir", CHAN_WEAPON)  // much larger roloff dist
			// GreenFlareSmall is a fuzzy glage, duration 2 tics radius 24
			"----" A 0 A_SpawnItemEx("GreenFlareSmall",30,7,28, momx,momy,momz, 0,SXF_NOCHECKPOSITION | SXF_ABSOLUTEVELOCITY)
			"----" A 0 A_CustomMissile("Evil10kBall", user_muzzle_z, 0, angle, CMF_ABSOLUTEANGLE | (user_best_d ? CMF_AIMDIRECTION : CMF_OFFSETPITCH) | CMF_SAVEPITCH, user_best_d ? user_best_p * 0.005493164 : 0)
			Goto WeaponAfterFiring			
			
			
		WpnFire_Unmaker:
			"----" A 0 A_PlaySound("misc/supermaster_laz_pew", 0) // allow sounds to overlap!
			"----" A 0 A_CustomMissile("MaradeurLazer",user_muzzle_z,0,angle + Random(-100,100) * 0.05, CMF_ABSOLUTEANGLE | (user_best_d ? CMF_AIMDIRECTION : CMF_OFFSETPITCH) | CMF_SAVEPITCH, (user_best_d ? user_best_p * 0.005493164 : 0) + Random(-30,30) * 0.05)
			
			// while can seee target, randomly increase burst length:
			"----" A 0 A_JumpIf(CallAcs("FBD_TargetIsInvisible"), "WeaponAfterFiring")
			"----" A 0 A_JumpIfTargetInLOS(1, 0, JLOSF_DEADNOJUMP) 
			Goto WeaponAfterFiring
			"----" A 0 A_Jump(220, "OneMoreShot")
			Goto WeaponAfterFiring			
	}
}



ACTOR ChaosMarineWeak: ChaosMarineAbstract
{
	// the same health, the same everything -- EXCEPT dodge-rolling
	// dodge-rolling with its invulnerability frames turns a regular enemy into a boss-tier nightmare!
	
	// red with a red helmet
	Translation "112:124=26:47", "125:125=1:1", "126:126=2:2", "127:127=8:8", "156:159=236:239", "152:155=37:42", "9:12=5:8", "128:143=20:42"	
	
	damagefactor "Shotgun", 1.0 // reverting ancestor's resistances because we cannot dodge-roll so we take full damage
	damagefactor "MonsterShotgunBullet", 1.0
	damagefactor "Desintegrate", 1.0 
	
	
	States
	{
		SetupDefaults:
			"----" A 0 A_GiveInventory("TargetIsAChaosMarine", 1)
			"----" A 0 A_SetUserVar("user_ddgrll_chance", -1) // DISABLED
			"----" A 0 A_SetUserVar("user_head_type", 6) // 6 - evil marine headbox
			"----" A 0 A_SetUserVar("user_nag_cooldown", 300)
			"----" A 0 A_SetUserVar("user_nag_period", 300)
			"----" A 0 A_SetUserVar("user_speed_limit", 8)
			"----" A 0 A_SetUserVar("user_voice_set", CHE_TRAITOR)
			
			"----" A 7
			"----" A 0 A_SetUserVar("user_jump_power", CallAcs("AdjustJumpPowerForEDAYMarsChapter", 50))
			"----" A 0 A_ChangeFlag("NOPAIN", 0)
			Goto WeaponSwitch // will proceed to Stand
	}
}






















// ============================ EVIL WEAPON PROJECTILES ======================


// NOTE as per convention, monster weapons do half damage of players'.
//   Use ChebMaster's Equality skills family to make them equal (200% damage).

// super shotgun's central short-range hitscan

ACTOR EvilTracer: ZombiemanTracer
{
	// They are elite. They don't hit each other.
	Species "EvilMarines"
	+THRUSPECIES
	+MTHRUSPECIES
}

ACTOR EvilShotpuff: FastProjectile
{
	+THRUGHOST
	+DONTSPLASH
	+THRUSPECIES
	+MTHRUSPECIES
	Species "EvilMarines"
	Radius 4
	Height 2
	Speed 100
	DamageType SSG
	Damage (random(20,20)) // player's central hitscan does 40, we do 50% of that 
		// -- see above about monsters on UV doing half player's damage
	States
	{
		Spawn:
			TNT1 AAA 1 // travel 300 map units
			TNT1 A 0 A_Stop
			Stop
		Death:
			TNT1 A 1
			Stop
	}
}


// melee ------------------------------------------------------


ACTOR EvilMarinePunch: ZandronumBaronBall //BaronBall
{
	
	Damage (random(16,16)) // low damage because they *spam* these attacks!
	
	Radius 10
	Height 18
	DamageType Fatality // they fatalize the player!
	Projectile 
	+RANDOMIZE
	+FORCEXYBILLBOARD
    +THRUGHOST
    +BLOODSPLATTER 
	RenderStyle Add
	Alpha 0.6
	Obituary "$CHAOS_MARINE_MELEE_O" // "%o was brutally beaten to death." / "%o был зверски забит насметрть."

	+DONTHURTSPECIES
	
	//***Che
	+DONTHARMSPECIES
	Species "EvilMarines"
	+SEEKERMISSILE // to get out target's target as tracer and unlock JLOSF_PROJECTILE
	+HITMASTER // to receive someone we hit in our master pointer on hit		

	SeeSound "None"
	DeathSound "none"
	Decal "none"
    Speed 20
	
	States
	{
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_PlaySound("skeleton/swing")
			TNT1 A 4 BRIGHT
			TNT1 A 0 A_GiveInventory("MeleeMiss", 1, AAPTR_TARGET)
			Stop
		XDeath: // hit a bleeding actor
			TNT1 A 0 A_PlaySound("player/cyborg/fist")
			TNT1 A 0 A_JumpIf(IsPointerEqual(AAPTR_TRACER, AAPTR_MASTER), "HitGold")
			TNT1 A 0 A_GiveInventory("MeleeMiss", 1, AAPTR_TARGET)
			Stop
		Death: // hit a wall
			TNT1 A 0 A_PlaySound("player/cyborg/fist")
			TNT1 A 0 A_GiveInventory("MeleeMiss", 1, AAPTR_TARGET)
			TNT1 A 0 BRIGHT
			Stop
		HitGold: // hit the intended target
			TNT1 A 0 A_GiveInventory("MeleeHitSuccess", 1, AAPTR_TARGET)
			TNT1 A 10 A_TakeInventory("MeleeMiss", 10, 0, AAPTR_TARGET)
			Stop

			
	}
}



/* Deprecated, he will only use jumping to get close to target, then switch to punch)
ACTOR EvilMarineKick // a clone of AirKickAttack that excludes A_AlertMonsters
{
	Radius 5
	Height 5
	DamageType Fatality // they fatalize the player!
	Projectile 
	+FORCEXYBILLBOARD
	+NOEXTREMEDEATH
	+SEEKERMISSILE // to get out target's target as tracer and unlock JLOSF_PROJECTILE
	+HITMASTER // to receive someone we hit in our master pointer on hit	
	RenderStyle Add
	Alpha 0.6
    Damage (random(12,12)) 
    Speed 30
	Obituary "$CHAOS_MARINE_MELEE_O" // "%o was brutally beaten to death." / "%o был зверски забит насметрть."
	SeeSound "none"
	DeathSound "none"
	Decal "none"
	Species "EvilMarines"
	States
	{
		Spawn:
			TNT1 A 1 BRIGHT
			TNT1 A 1 //A_PlaySound("weapons/gswing")
			TNT1 A 0 A_GiveInventory("MeleeMiss", 1, AAPTR_TARGET)
			Stop
		Death:  // hit a wall
			TNT1 A 0 A_GiveInventory("MeleeMiss", 1, AAPTR_TARGET)
			TNT1 A 0 A_CheckFloor("DeathOnGround")
		    PUFF A 0 A_PlaySound("player/cyborg/fist", 3)
			TNT1 A 0 A_SpawnItemEx ("PLOFT2",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
			EXPL AAAAAA 0 A_CustomMissile ("MeleeSmoke", 0, 0, random (0, 360), 2, random (0, 360))
			TNT1 A 0 A_GiveToTarget("KickHasHit", 1)
			//***Che there seems to be a bug in Zandronum that focuses the effect on the *player* instead of the activator
			TNT1 A 0 A_JumpIf(CallACS("GetDistanceToClosestPlayer") > 1000, 1)			
			TNT1 A 0 Radius_Quake (2, 6, 0, 5, 0)//(intensity, duration, damrad, tremrad, tid)
			TNT1 A 10
			Stop		
		XDeath:  // hit a bleeding actor
		    PUFF A 0 A_PlaySound("player/cyborg/fist", 3)
			TNT1 A 0 A_SpawnItemEx ("PLOFT2",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
			EXPL AAAAAA 0 A_CustomMissile ("MeleeSmoke", 0, 0, random (0, 360), 2, random (0, 360))
			TNT1 A 0 A_JumpIf(IsPointerEqual(AAPTR_TRACER, AAPTR_MASTER), "HitGold")
			TNT1 A 0 A_GiveInventory("MeleeMiss", 1, AAPTR_TARGET)
			TNT1 A 10
			Stop
		DeathOnGround:
			TNT1 A 0
		    PUFF A 0 A_PlaySound("player/cyborg/fist", 3)
			TNT1 A 0 A_SpawnItemEx ("PLOFT2",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
			EXPL AAAAAA 0 A_CustomMissile ("MeleeSmoke", 0, 0, random (0, 360), 2, random (0, 360))
			TNT1 A 0 Radius_Quake (2, 6, 0, 5, 0)//(intensity, duration, damrad, tremrad, tid)
			TNT1 A 0 A_Explode(10, 40, 0)
			TNT1 A 10
			Stop
		HitGold: // hit intended target
			TNT1 A 0 A_TakeInventory("MeleeMiss", 10, 0, AAPTR_TARGET)
			TNT1 A 0 A_GiveInventory("MeleeHitSuccess", 1, AAPTR_TARGET)
			TNT1 A 0 A_GiveToTarget("KickHasHit", 1)
			TNT1 A 0 Radius_Quake (2, 6, 0, 5, 0)//(intensity, duration, damrad, tremrad, tid)
			TNT1 A 10
			Stop			
			
	}
}


ACTOR EvilBerserkMarineKick: EvilMarineKick
{
	-NOEXTREMEDEATH
	Damage (random(50,50))
}
*/

ACTOR EvilBerserkMarinePunch: EvilMarinePunch
{
	-NOEXTREMEDEATH
	Damage (random(32,32))
}

Actor NpcMarinePunch: EvilBerserkMarinePunch
{
	Species "Marines"
	DamageType "HelperMarineFatallity"
}


ACTOR EvilSawDamageVertical: FastProjectile
{
	Radius 22
	Height 2
	+SEEKERMISSILE // to get out target's target as tracer and unlock JLOSF_PROJECTILE
	+HITMASTER // to receive someone we hit in our master pointer on hit
	DamageType Saw
	Projectile 
	+FORCEXYBILLBOARD
	+EXTREMEDEATH
	+BLOODSPLATTER
	RenderStyle Add
	Decal "BulletDecalNew1"
	Alpha 0.6
    Damage (random(2,2))
    Speed 50
	SeeSound "none"
	DeathSound "none"
	Decal "none"
	decal "SawVertical"
	States
	{
		Spawn:
			TNT1 A 0 BRIGHT
			TNT1 A 1 //A_PlaySound("weapons/gswing")
			TNT1 A 0 A_GiveInventory("MeleeMiss", 1, AAPTR_TARGET)
			Stop
		Death: // hit a wall
			TNT1 A 0
			TNT1 A 0 A_SpawnItem("SSAwPuff")
			TNT1 A 0 A_PlaySound("DSSAWAL", 1)
			TNT1 A 0 A_GiveInventory("MeleeMiss", 1, AAPTR_TARGET)
			TNT1 A 10
			Stop
		XDeath: // hit a bleeding actor
			SAWG A 0
			
			// Make SURE we hit out spawner's enemy!
			// Without this check, he could get stuck sawing a fellow evil marine 
			//   (whom he cannot damage)
			//   because that still registers as "hit a bleeding actor".
			TNT1 A 0 A_JumpIf(IsPointerEqual(AAPTR_TRACER, AAPTR_MASTER), "HitGold")
			
			// Still counts as a miss, he won't go into saw continue state.
			TNT1 A 0 A_GiveInventory("MeleeMiss", 1, AAPTR_TARGET) 
			SAWG A 0 A_PlaySound("CSAWFLESH", 1)
			TNT1 A 10
			Stop
		HitGold: // hit the intended target, NOT someone else
			TNT1 A 0 A_GiveInventory("MeleeHitSuccess", 1, AAPTR_TARGET)
			TNT1 A 0 A_TakeInventory("MeleeMiss", 10, 0, AAPTR_TARGET)
			TNT1 A 1 Radius_Quake(2, 3, 0, 4, 0)
			SAWG A 0 A_PlaySound("CSAWFLESH", 1)
			TNT1 A 10
			Stop
	}
}

Actor NpcMarineSawDamageVertical: EvilSawDamageVertical
{
	Species "Marines"
}


// rocket -----------------------------------------------------

ACTOR EvmRocket: FBD_Rocket2
{
	+DONTHARMSPECIES
	+THRUSPECIES // otherwise it explodes immediately as it hits his headbox because firing point is high
	+MTHRUSPECIES
	Species "EvilMarines"
	Damage (random (150, 150)) // half the player's by default
	
	States
	{
		//***Che: supporting same-species infighting
		KinslayerAdjust:
			TNT1 A 0 A_ChangeFlag("MTHRUSPECIES", 0)
			TNT1 A 0 A_ChangeFlag("THRUSPECIES", 0)
			Goto Live		
		
		Spawn:
		
			MISL A 0
			TNT1 A 0 A_PlaySound("DSRLAUN")
			//***Che: so much fucking effort put into finding this one that works -- because wiki is crap!
			// the only one that works without a target is CMF_AIMDIRECTION, and it takes *relative* angle :(
			
			//***Che: For backblast to work properly, use the CMF_SAVEPITCH flag *every* time you fire a rocket 
			// (unless you are a player avatar calling A_FireCustomMissile)
			// Otherwise rocket's pitch is zero on spawn and any secondary projectiles, 
			// like the backblast here, fly straight horizontal!
			
			// This one is for hitting monsters extra hard with Shotgun damage type,
			//   does no self-harm by design
			TNT1 A 0 BRIGHT A_CustomMissile("RocketBackblast", 0, 0, 180, CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH | CMF_SAVEPITCH, 0-pitch)

			// this one I had to modify to avoid self-harm
			TNT1 A 0 BRIGHT A_CustomMissile("EvmRocketBackblast2", 0, 0, 180, CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH | CMF_SAVEPITCH, 0-pitch)
			
			// This one is again to splatter monsters, a *huge* Shrapnel damage
			//   with self-harm disabled	
			TNT1 A 0 BRIGHT A_CustomMissile("RocketBackblast3", 0, 0, 180, CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH | CMF_SAVEPITCH, 0-pitch)
			TNT1 A 0 BRIGHT A_CustomMissile("BackblastFlames1", 0, 0, 180, CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH | CMF_SAVEPITCH, 0-pitch)
			TNT1 A 0 BRIGHT A_CustomMissile("BackblastFlames2", 0, 0, 180, CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH | CMF_SAVEPITCH, 0-pitch)
			TNT1 A 0 BRIGHT A_CustomMissile("BackblastFlames3", 0, 0, 180, CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH | CMF_SAVEPITCH, 0-pitch)
			TNT1 A 0 BRIGHT A_CustomMissile("BackblastFlames4", 0, 0, 180, CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH | CMF_SAVEPITCH, 0-pitch)
			
			MISL AA 1 Bright // wait to leave the spawner 
			
			//***Che
			TNT1 A 0 A_JumpIfInventory("IsAKinSlayer", 1, "KinslayerAdjust", AAPTR_TARGET)
			
			Goto Live
		Death:
			EXPL A 0 Radius_Quake (3, 8, 0, 15, 0)//(intensity, duration, damrad, tremrad, tid)
			TNT1 A 0 A_CustomMissile("ExplosionSplashSpawner")
			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 ("UnderwaterExplosion",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 AAAAAA 0 A_CustomMissile ("BDExplosionparticles", 0, 0, random (0, 360), 2, random (0, 360))
			TNT1 AAAA 0 A_CustomMissile ("BDExplosionparticles2", 0, 0, random (0, 360), 2, random (0, 90))
			TNT1 AAAA 0 A_CustomMissile ("MediumExplosionFlames", 0, 0, random (0, 360), 2, random (0, 360))
			
			// half the player's damage -- and more cheating, self harm greatly reduced
			TNT1 A 0 A_SpawnItemEx ("EvmRocketExplosion",0,0,13,0,0,0,0,SXF_NOCHECKPOSITION,0)
			
			TNT1 A 0
			TNT1 A 2
			TNT1 A 0 A_SpawnItemEx ("LiquidExplosionEffectSpawner",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
			TNT1 A 0 A_PlaySound("FAREXPL", 3)
			TNT1 A 15
			TNT1 A 0 A_PlaySound("distantexp", 5)
			Stop	
	
	}
}

ACTOR EvmRocketExplosion: RocketExplosion
{
	States {
		Spawn:
			Goto Death
		Death:
			TNT1 A 0
			TNT1 A 0 A_SpawnItem("WhiteShockwave")
			TNT1 A 3
			// 50 instead of 100 (half the player's) plus self harm reduced to near cosmetic value of 20
			TNT1 A 0 A_Explode(20,150)
			TNT1 A 0 A_Explode(30,150, 0)
			Stop	
	}
}

ACTOR EvmRocketBackblast2: RocketBackblast2
{
	States
	{
		Death:
			TNT1 A 3
			TNT1 A 0 A_Explode(11, 2, 0) // NO self-damage!
			TNT1 A 0 A_SpawnItemEx ("LiquidExplosionEffectSpawner",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
			TNT1 A 0 A_CustomMissile("ExplosionSmokeHD", 2, 0, random(0, 360), 2, random(0, 90))
			Stop	
	}
}















// railgun CTHULHACKERY --------------------------------------------------------------------


/*
I RAN OUT OF CUSS WORDS at the game engine's implementation of rail attack (the inflexible autoaim options of it).
In the end, making them fire true railgun was impossible. Had to create a horrible hackaround.


The railgun beams work properly, going thjrough several monsters in a row then causing explosion and spalling at a wall that penetrates thin walls (hellooo, closing doors?)
Had to invent projectile that every time it hits someone it relaunches itself behind them to emulate a beam penetrating all. At arbitrary distance of 64 map units, so hopefully won't ever hit the same monster twice. Of two monsters close together, one could survive unscathed, though.
The spalling effects are identical to *your* railgun, simply doing 50% damage. 

To render as a rail attack, with the spiral particle effect, I had to invent an even more sanity-melting hack. When the rail attack (a very fast projectile, not a hitscan) finally hits map geometry it turns itself into a monster, which makes the one who fired it its enemy, and fires a sfx missile at the evil marine who fired it. The sfx missile immediately teleports to the evil marine's muzzle position, turns *itself* into a monster -- which makes the first former missile its enemy -- and fires a purely decorative, fully autoaimed railgun shot at it.

Works like a charm, makes the rail beam render between the points *I* dictate, not where the game engine's iffy and inflexible autoaiming wants it to go :) 

*/

Actor EvmRailgunHACK: FastProjectile 
{
	Radius 2
	Height 2
	Speed 900
	Damage (random(200, 200))
	
	DamageType Railgun
	Decal None //"Scorch"

	Speed 999
	+SKYEXPLODE
	+THRUGHOST
	DeathSound None //"weapons/plasmax"
    SeeSound None
	MissileType None //"EvmRailgunFlameTrailsBlue" //"RailgunTrailEffect" not visible in gzdoom ??? :( 
	Missileheight 12
	
	+HITMASTER // to receive someone we hit in our master pointer on hit
	
	States
	{
		Spawn:
			TNT1 A 1
			Loop
		Crash:
		XDeath: // hit an actor
			TNT1 A 0
			
			// some monsters cause the same effect as if we hit a wall
			TNT1 A 0 A_JumpIf(CheckClass("TheCyberdemon", AAPTR_MASTER, true), "Death")
			TNT1 A 0 A_JumpIf(CheckClass("CyberdemonChad", AAPTR_MASTER, true), "Death")
			TNT1 A 0 A_JumpIf(CheckClass("FBD_Mastermind", AAPTR_MASTER, true), "Death")
			TNT1 A 0 A_JumpIf(CheckClass("MightyMastermind", AAPTR_MASTER, true), "Death")
			TNT1 A 0 A_JumpIf(CheckClass("FBD_EnemyMBT", AAPTR_MASTER, true), "Death")
			TNT1 A 0 A_JumpIf(CheckClass("PlayerTank", AAPTR_MASTER, true), "Death")
			TNT1 A 0 A_JumpIf(CheckClass("Tank", AAPTR_MASTER, true), "Death")
		
			// fire a daughter missile that would re-launch us 1 tic and 64 map units later
			// (repeater because it can hit map geometry before it has a chance to relaunch
			//  - so repeater acts identical way to us in relation to wall hits:
			//  spawns spalling, spawns railgun spiral effect
			TNT1 A 0 A_CustomMissile ("EvmRailgunHACKRepeater", 0, 0, 0, CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH | CMF_SAVEPITCH | CMF_TRACKOWNER, pitch)
			TNT1 A 0 A_Stop
			
			// make some noise
			TNT1 A 0 A_PlaySound("weapons/plasmax")
			TNT1 A 0 A_SpawnItemEx("RailgunTrailEffect",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION,0)
			
			TNT1 A 1
			Stop
		Death: // hit map geometry
			
			// This one makes the explosion and generates spall -- UNLESS we hit sky
			// We delegate that task (including telling if it was a sky hit) to it.
			TNT1 A 0 A_CustomMissile ("EvmRgWallHit", 0, 0, 0, CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH | CMF_SAVEPITCH | CMF_TRACKOWNER, pitch)
			
			// ..while we employ a horrible, sanity-melting cthulhack
			// to make the game engine draw a rail spiral where WE need,
			// not where the game engine's moronic autoaim options want it to go!
			TNT1 A 0 A_RearrangePointers(AAPTR_DEFAULT, AAPTR_NULL, AAPTR_NULL, 0) // clear our master pointer
			TNT1 A 0 A_ChangeFlag("MISSILE", 0) // should be cleared by our death state anyway but let's make sure
			TNT1 A 0 A_ChangeFlag("ISMONSTER", 1) // by making ourselves a monster 
				// we change the meaning of our target pointer: the evil marine who fired us
				// is now our enemy
			
			
			// The direction doesn't affect anything because the projectile is intangible.
			// would fail to fire if we don't have a target
			// Since this is a seeker missile it receives the evil marine who fired us as its tracer
			TNT1 A 0 A_CustomMissile ("EvmRgBeamSfx")
			TNT1 A 30
			Stop
			
	}
}

ACTOR EvmRgBeamSfx
{
	PROJECTILE
	+SEEKERMISSILE
	+NOINTERACTION
	+CLIENTSIDEONLY
	Speed 0
	Height 1
	Radius 2
	States
	{
		Spawn:
			// warp to his muzzle position and hope he did not move far since the original projectile was fired
			TNT1 A 0 NODELAY A_Warp(AAPTR_TRACER,29,4,44,0,WARPF_STOP,"WarpedOk")
			TNT1 A 1
			Stop
		WarpedOk:
			// cheat again making us a monster and thus the actor who fired us our enamy
			TNT1 A 0 A_ChangeFlag("ISMONSTER", 1)
			
			// fire an autoaimed, purely decorative railgun beam at our enemy
			TNT1 A 0 A_CustomRailgun(0, 0, "95b2fc", "4b61ff", RGF_FULLBRIGHT | RGF_CENTERZ, 1, 0, "RailgunAlerterPuff")
			TNT1 A 30
			Stop
	}
}

ACTOR EvmRgWallHit
{
	Speed 1
	Radius 1 // vs radius 2 height 2 of the projectile who fired us -- 
		// so hopefuully we'd travel that one map unit before hitting map geometry.
	Height 1
	PROJECTILE
	-SKYEXPLODE
	+THRUACTORS
	+THRUGHOST
	Decal "Scorch"
	States
	{
		Spawn:
			TNT1 AAAAA 1
			Stop
		Death:
// act as the penetrator
			TNT1 A 0
			
			//half the number of player's, each one doing the same damage
			TNT1 AAAAAAAAAAAAAA 0 A_CustomMissile("EvmRailgunSpallTracker1", 0, 0, random(-30,30), CMF_AIMDIRECTION | CMF_TRACKOWNER | CMF_ABSOLUTEPITCH | CMF_SAVEPITCH, pitch + random(-30, 30))
			

			TNT1 A 0 A_SpawnItemEx ("Footstep91",0,0, 40,0,0,0,0,SXF_NOCHECKPOSITION,0)
			TNT1 A 0 
			RAIL A 0 A_SpawnItemEx ("ExplosionSplashSpawner", 0, 0, 0)
			RAIL A 0 A_SpawnItemEx ("DetectFloorCrater",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
			RAIL A 0 A_SpawnItemEx ("DetectCeilCrater",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
			TNT1 AA 0 A_CustomMissile ("SparkXNoModel", 2, 0, random (0, 360), 2, random (0, 360))
			RAIL A 0 A_SpawnItem("RailgunFlameTrails")
			
			EXPL A 0 Radius_Quake (3, 8, 0, 15, 0)
			RAIL A 0 A_SpawnItemEx ("UnderwaterExplosion",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
			RAIL A 0 A_SpawnItemEx ("ExplosionFlareSpawner",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
			TNT1 AAA 0 A_CustomMissile ("BDExplosionparticles", 0, 0, random (0, 360), 2, random (40, 90))
			TNT1 AA 0 A_CustomMissile ("BDExplosionparticles2", 0, 0, random (0, 360), 2, random (40, 90))
			TNT1 AA 0 A_CustomMissile ("BDExplosionparticles3", 10, 0, random (0, 360), 2, random (40, 90))
			TNT1 AAA 0 A_CustomMissile ("ExplosionFlames", 0, 0, random (0, 360), 2, random (0, 360))
			
			
			//inflict damage
			RAIL A 0 A_SpawnItemEx ("EvmRocketExplosion",0,0,13,0,0,0,0,SXF_NOCHECKPOSITION,0)
			
			
			TNT1 A 2
			RAIL A 0 A_SpawnItemEx ("LiquidExplosionEffectSpawner",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
			RAIL A 0 A_PlaySound("FAREXPL", 3)
			TNT1 A 15
			RAIL A 0 A_PlaySound("distantexp", 5)
			Stop		
		
	
	}

}

ACTOR EvmRailgunHACKRepeater: EvmRailgunHACK // shares its Death state to make BOOM on walls!
{
	Speed 64
	+THRUACTORS
	MissileType None
	States 
	{
		Spawn:
			TNT1 A 1 // travel for one tic, through everything, 64 map units
			
			// restart the railgun projectile (hopefully *behind* the actor the previous one hit).
			// woe to thicc d00ds like masterminds or tanks
			TNT1 A 0 A_CustomMissile ("EvmRailgunHACK", 0, 0, 0, CMF_AIMDIRECTION | CMF_ABSOLUTEPITCH | CMF_SAVEPITCH | CMF_TRACKOWNER, pitch)
			TNT1 A 1 A_Stop
			Stop
			
	}
}


//***Che Spalling, Step one: fire a bunch of missiles 
// with collision TOTALLY OFF that go through walls, *floors* and everything.

ACTOR EvmRailgunSpallTracker1 {
	//PROJECTILE
	+NOINTERACTION // ignore *ALL* collision
	-CLIENTSIDEONLY
	Decal None
	Radius 1
	Height 1
	Speed 50
	Scale 1
	States {
		Spawn:
			TNT1 A 1
			
			//***Che Step two: fire, straight backwards, 
			//  	projectiles tasked with finding the other side of the wall.
			//  Must pass through everything but walls.
			
			TNT1 A 0 A_Stop
			TNT1 A 10 A_CustomMissile("EvmRailgunSpallTracker2", 0, 0, 180, CMF_AIMDIRECTION | CMF_TRACKOWNER | CMF_ABSOLUTEPITCH | CMF_SAVEPITCH, -pitch)
			TNT1 A 0
			Stop
	
	}
}


ACTOR EvmRailgunSpallTracker2: FastProjectile
{
	damage (random(0, 0))
	Decal "Scorch"
	DamageType Railgun
	+NODAMAGETHRUST
	Radius 2
	Height 1
	Scale 0.2
	Speed 64
	-SKYEXPLODE
	+THRUGHOST
	+THRUACTORS
	States {
		Spawn:
			TNT1 A 1
			//KYDB G 30 A_Stop
			Stop
		Death:
			TNT1 A 0
			
			//***Che Step three: we found the wall surface! Fire damaging tracers forward.
			// (also causes shrapnel from the floor and ceiling when hit at a shallow angle)			
			
			
			TNT1 A 0 A_Stop
			TNT1 A 0 A_CustomMissile("ShotgunguyTracer", 0, 0, random(150,210), CMF_AIMDIRECTION | CMF_TRACKOWNER | CMF_ABSOLUTEPITCH | CMF_SAVEPITCH, - pitch + random(-30, 30))
			//SPRK AAAAAA 1 A_FadeOut(0.2)
			TNT1 A 0 A_Jump(140, 2)
			TNT1 A 0 A_CustomMissile ("Spark_BD13", 0, 0, random(150,210), CMF_AIMDIRECTION | CMF_TRACKOWNER | CMF_ABSOLUTEPITCH | CMF_SAVEPITCH, - pitch + random(-30, 30))
			TNT1 A 0 A_Jump(140, 2)
			TNT1 A 0 A_CustomMissile ("Spark_BD16", 0, 0, random(150,210), CMF_AIMDIRECTION | CMF_TRACKOWNER | CMF_ABSOLUTEPITCH | CMF_SAVEPITCH, - pitch + random(-30, 30))
			TNT1 A 10
			//KYDB J 30
		Crash:
		XDeath:
			// this should never happen
			TNT1 A 0
			Stop
	}
}






// ------- bfg 9000 ----------------------------------------------------


// re-uses the bfg ball defined for super masterminds

ACTOR BFGMuzzle
{
	Speed 0
	PROJECTILE
	+NOCLIP
	+NOGRAVITY
	+NOINTERACTION
	Renderstyle Add
	Scale 0.5
	States {
		Spawn:
			TNT1 A 1
			TNT1 A 0 A_Jump(256, "Flare1", "Flare2", "Flare3", "Flare4")
		Flare1:
			BFE2 DCBDCB 1
			Stop
		Flare2:
			BFE2 DCDCDC 1
			Stop
		Flare3:
			BFE2 CBCBCC 1
			Stop
		Flare4:
			BFE2 DCBCD 1
			Stop
	}
}


ACTOR BFGMuzzle2: BFGMuzzle
{
	States {
		Spawn:
			TNT1 A 1
			TNT1 A 0 A_Jump(256, "Flare1", "Flare2", "Flare3", "Flare4")
		Flare1:
			BFE2 CBACA 1
			Stop
		Flare2:
			BFE2 ABABC 1
			Stop
		Flare3:
			BFE2 CBCBCB 1
			Stop
		Flare4:
			BFE2 BACBC 1
			Stop
	}
}

ACTOR BFGMuzzle3: BFGMuzzle
{
	States {
		Spawn:
			TNT1 A 1
			TNT1 A 0 A_Jump(256, "Flare1", "Flare2", "Flare3", "Flare4")
		Flare1:
			BFE1 ADADA 1
			Stop
		Flare2:
			BFE1 ABABA 1
			Stop
		Flare3:
			BFE1 DEBED 1
			Stop
		Flare4:
			BFE1 ADBDA 1
			Stop
	}
}












// ------- bfg 10k -----------------------------------------------------

//Actor Evil10kBall: BFG10K_Ball // moved to BFG10k.txt
/*
{
	Damage (random(150, 150)) // half of player's
	Species "EvilMarines"
	States
	{
		Death:
			BFE1 A 0 Bright
			BFE1 A 3 Bright
			BG2G A 0 A_SpawnItem("EvmRocketExplosion")
			BG2G A 0 Radius_Quake(3, 2, 0, 12, 0)
			
			TNT1 A 0 A_CustomMissile("ExplosionSplashSpawner")
			TNT1 A 0 A_SpawnItemEx ("LiquidExplosionEffectSpawner",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
			
			TNT1 A 0 A_JumpIf(waterlevel >= 1, "SfxUnderwater")	
			Goto SfxAboveWater
	}
}
*/









// ------- unmaker -----------------------------------------------------

ACTOR MaradeurLazersFlames: FlamethrowerBurningStuffNoSelfHarm {
	Species "EvilMarines"
	+DONTHARMSPECIES
}

//Actor MaradeurLazer: SpiderLazer //moved to FBD_supermasterminds.txt


