
//***Che this is #include'd from Cyberdemon.txt


//***Che: note, tyrant has *no* spread (just like the vanilla cyberdemon) 
// and fires in bursts of 3 (like the vanilla cyberdemon again) 
//  instead of BD cyberdemon's 4
// and he does *not* leap when stomping (regular cyberdemons now DO!)


Actor FBD_Tyrant: AbstractCyberdemon 17539 {
	//***Che radius, height and maxdropoffheight (n/a for flying ones) MUST be kept consistent with FBD_TrySpawn in FBD_CORE.acs!
	
	//$category "FBD Monsters"
	//$Sprite CYBRG8
	Health 2500
	// greenish gray with brown pipes
	Translation "48:66=86:100", "67:74=152:159", "75:79=123:127", "1:2=127:127", "144:151=159:159", "96:106=152:159", "172:191=63:79", "41:47=236:239", "160:167=87:111"
	Tag "$CYBRRUNT" // "Cyber-tyrant" / "Кибер-тиран"

	// note that headbox offsets in the abstract ancestor have been pre-baked with the 1.2 multiplier
	// so the tyrant (back to standard cyberdemon size) uses 83% headbox scale and "Scale 1.0"
	Scale 1.0
	Radius 35
	Height 78
	
	-BOSS // do not scream at full volume regardless of distance 
	
	States
	{
		Spawn:
			CYBR G 0 NODELAY
			TNT1 A 0 A_JumpIf(CallAcs("GetPotPourri"), "PotPourriSwap")
		PotPourriCancel:
			TNT1 A 0 ACS_NamedExecuteWithResult("FBD_RunMonster", 17, 83) // tyrant headbox, scale 83%
			TNT1 A 0 A_SetUserVar("user_dont_adjust_aim", 0)
			TNT1 A 0 A_SetUserVar("user_headshot_stun_limit", 8) // prevents permanent stunlock
			TNT1 A 0 A_GiveInventory("TargetIsACyberdemon")
			TNT1 A 0 A_ChangeFlag("NOPAIN", 0)	
			Goto Stand
		PotPourriNoSwap:
			TNT1 A 0 A_ChangeFlag("SHOOTABLE", 1)
			TNT1 A 0 A_ChangeFlag("COUNTKILL", 1)
			Goto PotPourriCancel
		
		Missile:
		SpecialAttack: // tyrant does not get a special attack
		
	
			TNT1 A 0
			
			//TNT1 A 0 A_JumpIf(CallACS("GetDistanceToTarget", 999) <= 180 && CallACS("GetIsZDeltaToTargetInRange", -40, 40) && !CallACS("GetIsTargetUnStompeable"), "Stomp")
			TNT1 A 0 A_JumpIf(CallACS("GetCyberdemonCanStompTarget", 120), "Stomp")
/*			
			// slaughtermap manage - warming the headbox up
			TNT1 A 0 A_JumpIf(!user_sleeping, 4) // forgo the expensive sight check if already awake
			TNT1 A 0 A_JumpIfInTargetInventory("IsPlayer", 1, 2) // bypass the sight check 
			TNT1 A 0 A_CheckSight(2) // out of sight of any player, AND attacking another monster, keep slumbering
			TNT1 A 0 A_SetUserVar("user_sleeping", 0)
*/			

			TNT1 A 0 A_JumpIfInTargetInventory("IsInATank", 1, "SpecialAttack")

			// Kinslayer check:	
			TNT1 A 0 A_JumpIfInTargetInventory("TargetIsACyberdemon", 1, 2)
			TNT1 A 0 A_JumpIf(true, 2)
			TNT1 A 0 ACS_NamedExecuteWithResult("FBD_InfightFriendlyFireOn")	

			TNT1 A 0 ACS_NamedExecuteWithResult("AdjustHeadboxMkII", -12, -6, 96)
			
			TNT1 A 0 A_JumpIfTargetInLOS(2)
			TNT1 A 0 A_JumpIf(user_dont_adjust_aim, 2)
			TNT1 A 0 A_FaceTarget
			CYBR E 8
			TNT1 A 0 A_SetUserVar("user_dont_adjust_aim", 0)

			// MUST use auto-aiming at visible targets, otherwise misses at close range due to projectile's origin offset
			TNT1 A 0 A_JumpIf(CallAcs("FBD_TargetIsInvisible"), 2)
			TNT1 A 0 A_JumpIfTargetInLOS(3)
			// the version with auto-aim disabled:		
			CYBR F 3 BRIGHT A_CustomMissile("CyberBalls",0.0000152587890625 * user_head_scale * 60.0,0.0000152587890625 * user_head_scale * -25.0,angle, CMF_ABSOLUTEANGLE | CMF_OFFSETPITCH | CMF_SAVEPITCH)
			TNT1 A 0 A_Jump(256, 2)
			// the auto-aimed version:
			CYBR F 3 BRIGHT A_CustomMissile("CyberBalls",0.0000152587890625 * user_head_scale * 60.0,0.0000152587890625 * user_head_scale * -25.0,0,0)
			
			//TNT1 A 0 A_JumpIf(CallACS("GetDistanceToTarget", 999) <= 180 && CallACS("GetIsZDeltaToTargetInRange", -40, 40) && !CallACS("GetIsTargetUnStompeable"), "Stomp")
			TNT1 A 0 A_JumpIf(CallACS("GetCyberdemonCanStompTarget", 180), "Stomp")
			
			
				//***Che: do NOT adjust aim if target goes out of sight or is invisible
				TNT1 A 0 A_JumpIf(CallAcs("FBD_TargetIsInvisible"), 4)
				TNT1 A 0 A_JumpIfTargetInLOS(2)
				TNT1 A 0 A_Jump(256, 2)
				TNT1 A 0 A_FaceTarget
			
			CYBR E 6 //A_FaceTarget

				//***Che: do NOT adjust aim if target goes out of sight or is invisible
				TNT1 A 0 A_JumpIf(CallAcs("FBD_TargetIsInvisible"), 4)
				TNT1 A 0 A_JumpIfTargetInLOS(2)
				TNT1 A 0 A_Jump(256, 2)
				TNT1 A 0 A_FaceTarget
			
			CYBR E 6 //A_FaceTarget
			
			TNT1 A 0 A_JumpIf(CallACS("GetCyberdemonCanStompTarget", 120), "Stomp")

			// MUST use auto-aiming at visible targets, otherwise misses at close range due to projectile's origin offset
			TNT1 A 0 A_JumpIf(CallAcs("FBD_TargetIsInvisible"), 2)
			TNT1 A 0 A_JumpIfTargetInLOS(3)
			// the version with auto-aim disabled:		
			CYBR F 3 BRIGHT A_CustomMissile("CyberBalls",0.0000152587890625 * user_head_scale * 60.0,0.0000152587890625 * user_head_scale * -25.0,angle, CMF_ABSOLUTEANGLE | CMF_OFFSETPITCH | CMF_SAVEPITCH)
			TNT1 A 0 A_Jump(256, 2)
			// the auto-aimed version:
			CYBR F 3 BRIGHT A_CustomMissile("CyberBalls",0.0000152587890625 * user_head_scale * 60.0,0.0000152587890625 * user_head_scale * -25.0,0,0)

			
			
				//***Che: do NOT adjust aim if target goes out of sight or is invisible
				TNT1 A 0 A_JumpIf(CallAcs("FBD_TargetIsInvisible"), 4)
				TNT1 A 0 A_JumpIfTargetInLOS(2)
				TNT1 A 0 A_Jump(256, 2)
				TNT1 A 0 A_FaceTarget
			
			CYBR E 6 //A_FaceTarget

				//***Che: do NOT adjust aim if target goes out of sight or is invisible
				TNT1 A 0 A_JumpIf(CallAcs("FBD_TargetIsInvisible"), 4)
				TNT1 A 0 A_JumpIfTargetInLOS(2)
				TNT1 A 0 A_Jump(256, 2)
				TNT1 A 0 A_FaceTarget
			
			CYBR E 6 //A_FaceTarget

			
			// MUST use auto-aiming at visible targets, otherwise misses at close range due to projectile's origin offset
			TNT1 A 0 A_JumpIf(CallAcs("FBD_TargetIsInvisible"), 2)
			TNT1 A 0 A_JumpIfTargetInLOS(3)
			// the version with auto-aim disabled:		
			CYBR F 3 BRIGHT A_CustomMissile("CyberBalls",0.0000152587890625 * user_head_scale * 60.0,0.0000152587890625 * user_head_scale * -25.0,angle, CMF_ABSOLUTEANGLE | CMF_OFFSETPITCH | CMF_SAVEPITCH)
			TNT1 A 0 A_Jump(256, 2)
			// the auto-aimed version:
			CYBR F 3 BRIGHT A_CustomMissile("CyberBalls",0.0000152587890625 * user_head_scale * 60.0,0.0000152587890625 * user_head_scale * -25.0,0,0)		

				//***Che: do NOT adjust aim if target goes out of sight or is invisible
				TNT1 A 0 A_JumpIf(CallAcs("FBD_TargetIsInvisible"), 4)
				TNT1 A 0 A_JumpIfTargetInLOS(2)
				TNT1 A 0 A_Jump(256, 2)
				TNT1 A 0 A_FaceTarget
			
			CYBR E 6 //A_FaceTarget

				//***Che: do NOT adjust aim if target goes out of sight or is invisible
				TNT1 A 0 A_JumpIf(CallAcs("FBD_TargetIsInvisible"), 4)
				TNT1 A 0 A_JumpIfTargetInLOS(2)
				TNT1 A 0 A_Jump(256, 2)
				TNT1 A 0 A_FaceTarget
			
			CYBR E 6 //A_FaceTarget
			
			CYBR E 12
			Goto See
			
	}	
	
	
}