class BabelNazi : SyncEnabledMonster Replaces WolfensteinSS
{
	int user_loopCounter;
	int baseHealth;
	default
	{
		Health 50;
		Radius 20;
		Height 56;
		Speed 8;
		PainChance 170;
		Monster;
		+FLOORCLIP;
		SeeSound "wolfss/sight";
		PainSound "wolfss/pain";
		DeathSound "wolfss/death";
		ActiveSound "wolfss/active";
		AttackSound "wolfss/attack";
		Obituary "$OB_WOLFSS";
		Dropitem "Clip";
		Species "Zombie"; //because why the hell not?
		+MISSILEMORE;
		+MISSILEEVENMORE;
		DamageType "Monster";
		PainChance "PlayerPistol", 240;
		Tag "Wolfenstein SS (Babel)";
		
		BabelMonster.FearEnabled		true;
		BabelMonster.FearThreshold		300.0;
		BabelMonster.FearMaxValue		400.0;
		BabelMonster.FearFallOff		1.0;
		BabelMonster.FearRecovery		2.0;
		BabelMonster.FearResistChance	25.0;
		BabelMonster.SyncChainCheckLOS	true;
		BabelMonster.SyncChainCheckLOF	true;
	}
	
	override void BeginPlay()
	{
		super.BeginPlay();
		
		baseHealth = health;
	}
	
	//This is just a copy of A_BabelZMShot because I don't feel like making a horrible inheritance tree
	action void A_BabelNaziShot(double xspread, double yspread, string attackSound = "grunt/attack")
	{
		string missileType = "ZManShot";
		if(CVar.FindCVar("egr_enemy_tracer_type").GetInt() == 3)
		{
			missileType = "ClassicZManShot";
		}
		invoker.A_PlaySound(attackSound);
		if(invoker.isHardest)
		{
			A_SpawnProjectile(missileType,32.0,0, (Random2[GunShot]() * (xspread / 256)) + invoker.PredictPlayerMovementRough(80), CMF_OFFSETPITCH, frandom(-yspread, yspread));
			A_SetAngle(angle+invoker.PredictPlayerMovementRough(80));
		}
		else
		{
			A_SpawnProjectile(missileType,32.0,0,(Random2[GunShot]() * (xspread / 256)), CMF_OFFSETPITCH, frandom(-yspread, yspread));
		}
	}
	
	States
	{
	Spawn:
		TNT1 A 0 Nodelay 
		{
			return ResolveState("Look");
		}
	Wander:
		SSWV AABBCCDD 3 Fast 
		{
			A_Wander();
			A_Look();
		}
		Loop;
	Look:
		SSWV AB 10 A_Look();
		Loop;
	See:
		TNT1 A 0 
		{
			ReleaseState();
			return JumpIfAfraid("Fear");
		}
		SSWV AABBCCDD 3 A_Chase();
		Loop;
	Fear:
		//We are afraid
		SSWV AABBCCDD 3
		{
			isAfraid = true;
			bFRIGHTENED = true;
			A_SetSpeed(10);
			A_Chase("Melee", null);
		}
		TNT1 A 0 JumpIfHasFear("Fear");
		
		//Now we've recovered from fear
		
		TNT1 A 0 
		{
			currentFear = 0;
			isAfraid = false;
			bFRIGHTENED = false;
			ResetGroupFear();
			A_SetSpeed(8);
		}
		Goto See;
	Melee:
		TNT1 A 0 A_Jump(256, "MissileNoSignal");
	Missile:
		TNT1 A 0 
		{
			TriggerSync("BabelZombieMan", 25.0);
			TriggerSync("BabelChaingunGuy", 35.0);
			TriggerSync("BabelShotgunGuy", 30.0);
			TriggerSync("BabelNazi", 75.0);
		}
	MissileNoSignal:
		TNT1 A 0 JumpIfCannotTarget("See");
		TNT1 A 0 HoldState();
	MissileRepeat:
		SSWV E 10 A_FaceTarget();
		SSWV F 10 A_FaceTarget();
		SSWV G 4 Bright A_BabelNaziShot(9.3, 5.9, "wolfss/attack");
		SSWV F 6 A_FaceTarget();
		SSWV G 4 Bright A_BabelNaziShot(9.3, 5.9, "wolfss/attack");
		SSWV F 1 A_CPosRefire;
		Goto MissileRepeat+1;
	Pain:
		SSWV H 3;
		SSWV H 3 A_BabelPain();
		Goto See;
	Death:
		TNT1 A 0 A_Jump(48, "Death.Monster");
		TNT1 A 0 
		{
			TriggerSync("BabelZombieMan", 25.0);
			TriggerSync("BabelChaingunGuy", 35.0);
			TriggerSync("BabelShotgunGuy", 30.0);
			TriggerSync("BabelNazi", 75.0);
		}
	Death.Monster:
	XDeath.Massacre:
		SSWV I 5;
		SSWV J 5 A_Scream();
		SSWV K 5 A_NoBlocking;
		SSWV L 5;
		SSWV M -1;
		Stop;
	XDeath:
		TNT1 A 0 A_Jump(64, "XDeath.Monster");
		TNT1 A 0 
		{
			TriggerSync("BabelZombieMan", 25.0);
			TriggerSync("BabelChaingunGuy", 35.0);
			TriggerSync("BabelShotgunGuy", 30.0);
			TriggerSync("BabelNazi", 75.0);
		}
	XDeath.Monster:
		TNT1 A 0
		{
			if(CVar.FindCVar("egr_gore").GetInt())
			{
				for(user_loopCounter = 0; user_loopCounter < 4*CVar.FindCVar("egr_gore_level").GetInt(); user_loopCounter++)
				{
					
					A_SpawnProjectile("Bits", random(24, 48), random(-10, 10), random (0, 360), CMF_OFFSETPITCH, -random (0, 160));
					A_SpawnItemEx("BloodSpew", random(-10, 10), random(-10, 10), random(24, 56));
				}
				for(user_loopCounter = 0; user_loopCounter < CVar.FindCVar("egr_gore_level").GetInt()/2; user_loopCounter++)
				{
					A_SpawnProjectile("Chunks", random(24, 48), random(-10, 10), random (0, 360), CMF_OFFSETPITCH, -random (0, 160));
				}
			}
		}
		SSWV N 5 ;
		SSWV O 5 A_XScream();
		SSWV P 5 A_NoBlocking;
		SSWV QRSTU 5;
		SSWV V -1;
		Stop;
	Raise:
		SSWV M 5
		{
			A_SetSpeed(8);
		}
		SSWV LKJI 5;
		Goto See ;
	}
}