//For now it just fires tracers and a lot faster
class BabelChaingunGuy : SyncEnabledMonster Replaces ChaingunGuy
{
	int user_loopCounter;
	int baseHealth;
	default
	{
		Health 70;
		Radius 20;
		Height 56;
		Mass 100;
		Speed 8;
		Monster;
		+FLOORCLIP;
		SeeSound "chainguy/sight";
		PainSound "chainguy/pain";
		DeathSound "chainguy/death";
		ActiveSound "chainguy/active";
		AttackSound "chainguy/attack";
		Obituary "$OB_CHAINGUY";
		Dropitem "Chaingun";
		PainChance 56;
		Species "Zombie";
		+DOHARMSPECIES;
		PainChance "PlayerPistol", 200;
		DamageType "Monster";
		Tag "Heavy Weapon Dude (Babel)";
		
		BabelMonster.SyncChainCheckLOS	true;
		BabelMonster.SyncChainCheckLOF	true;
	}
	
	action void A_BabelCGShot()
	{
		string missileType = "CGuyShot";
		if(CVar.FindCVar("egr_enemy_tracer_type").GetInt() == 3)
		{
			missileType = "ClassicCGuyShot";
		}
		A_PlaySound("weapons/chngun", CHAN_WEAPON);
		A_SpawnProjectile(missileType,32.0,0, (Random2[GunShot]() * (11.2 / 256)), CMF_OFFSETPITCH, frandom(-5.6, 5.6));
	}
	
	override void BeginPlay()
	{
		super.BeginPlay();
		
		baseHealth = health;
	}
	
	States
	{
	Spawn:
		TNT1 A 0 Nodelay 
		{
			return ResolveState("Look");
		}
	Wander:
		CPOS AABBCCDD 3 Fast 
		{
			A_Wander();
			A_Look();
		}
		Loop;
	Look:
		CPOS AB 10 A_Look();
		Loop;
	See:
		TNT1 A 0 ReleaseState();
		CPOS AABBCCDD 3 Fast A_Chase();
		Goto See;
	Missile:
		TNT1 A 0 
		{
			TriggerSync("BabelZombieMan", 50.0);
			TriggerSync("BabelChaingunGuy", 40.0);
			TriggerSync("BabelShotgunGuy", 45.0);
			TriggerSync("BabelNazi", 75.0);
		}
	MissileNoSignal:
		TNT1 A 0 JumpIfCannotTarget("See");
		TNT1 A 0 HoldState();
		//----------------------------
		CPOS E 11 A_FaceTarget(); //Same windup as player
	Refire:
		CPOS E 2 bright A_FaceTarget();
		CPOS F 2 bright A_BabelCGShot();
		CPOS E 1 A_CPosRefire;
		Goto Refire+1;
	Pain:
		CPOS G 3 Fast;
		CPOS G 3 Fast A_BabelPain();
		Goto See;
	Death:
		TNT1 A 0 A_Jump(48, "Death.Monster");
		TNT1 A 0 
		{
			TriggerSync("BabelZombieMan", 50.0);
			TriggerSync("BabelChaingunGuy", 40.0);
			TriggerSync("BabelShotgunGuy", 45.0);
			TriggerSync("BabelNazi", 75.0);
		}
	Death.Monster:
	XDeath.Massacre:
		CPOS H 5; 
		CPOS I 5 A_Scream();
		CPOS J 5 A_NoBlocking;
		CPOS KLM 5;
		CPOS N -1;
		Stop;
	XDeath:
		TNT1 A 0 
		{
			if(random(0, 255) < 244)
			{
				TriggerSync("BabelZombieMan", 50.0);
				TriggerSync("BabelChaingunGuy", 40.0);
				TriggerSync("BabelShotgunGuy", 45.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));
				}
			}
		}
		CPOS O 5; 
		CPOS P 5 A_XScream();
		CPOS Q 5 A_NoBlocking;
		CPOS RS 5;
		CPOS T -1;
		Stop;
	Raise:
		CPOS N 5;
		CPOS MLKJIH 5;
		Goto See;
	}
}
