// Mech turret
actor Utility_MechTurretRed : Utility_TurretBase {
	obituary "%o was owned by a \cgRed \c-anti-Mech turret."
	health 500
	painchance 50
	damagefactor "Explosion", 0.75
	damagefactor "MassDriver", 0.75
	//seesound "turret/sight"
	attacksound "rifle/fire"
	activesound "turret/sight"
	states {
	Spawn:
		CIGN AA 0 A_CheckSight("Death.Deconstruction")
		CIGN A 0 Thing_SetSpecial (0, 84, 345, 0, TEAM_RED)
	Idle:
		CIGN A 0 A_GiveInventory("MechReloading",12)
		CIGN A 6 A_Look
		wait
	See:
		CIGN A 0 A_GiveInventory("IsRed",1)
		CIGN A 2 A_ChangeFlag("FRIENDLY",0)
		CIGN D 12 A_StopSoundEx("SoundSlot6")
		CIGN A 2 A_JumpIfTargetInLOS("Missile")
		CIGN A 0 A_TakeInventory("MechReloading",12)
		CIGN A 2 A_ClearTarget
		goto Idle+1
	Clear:
		CIGN A 2 A_ClearTarget
		goto See
	MissileCheck:
		CIGN A 0 A_JumpIfInTargetInventory ("IsBlue", 1, 1)
		goto Clear
		CIGN A 0 A_Chase("","",CHF_DONTMOVE)
		CIGN A 0 
		goto MissileGo+2
	Missile:
		CIGN A 0 
		CIGN A 1 A_JumpIfInTargetInventory ("IsBlue", 1, 1)
		goto Clear
		CIGN A 1 A_JumpIfCloser(4000,"MissileGo")
		CIGN A 0 
		goto Clear
	MissileGo:
		CIGN B 0 A_JumpIfInTargetInventory("IsMech",1,1)
		goto Clear
		CIGN B 10 A_FaceTarget
		CIGN F 0 A_CPosRefire
		CIGN B 0 A_JumpIfInventory("MechReloading",6,"Pain")
		CIGN B 0 A_PlayWeaponSound("rifle/fire")
		CIGN B 0 A_CustomMissile("MechTurretProjectile",48,0)
		CIGN B 0 //A_CustomBulletAttack(2,2,1,15,"RiflePuff",4000)
		CIGN B 0 A_SpawnItemEx("Flash",0,0,0,0,0,0,0,128,0)
		CIGN B 0 A_FaceTarget
		CIGN C 4 BRIGHT A_SpawnItemEx("ShellCasing",8,8,48,random(1,3),random(0,1),random(1,3),random(45,60),128)
		CIGN BA 6 BRIGHT A_ChangeFlag("FRIENDLY",0)
		CIGN F 0 A_CPosRefire
		CIGN F 0 A_GiveInventory("MechReloading",1)
		goto MissileCheck
	Pain:
		CIGN A 0 A_StopSoundEx("SoundSlot6")
		CIGN A 0 A_ClearTarget
		CIGN A 3 A_TakeInventory("MechReloading",6)
		goto See
	Death:	
		TC4T A 0		 
		CIGN A 0 A_StopSoundEx("SoundSlot6")
		TC4T A 0 A_NoBlocking
		TNT1 A 0 A_SpawnItemEx("ExplosionMain", 0, 0, 32, 0, 0, 0, 0, 128, 0)
		TC4T A 0 A_PlaySound("weapons/rocklx")
		TNT1 A 0 A_SpawnItemEx("FlameWallDecay", 0, 0, 0, 0, 0, 0, 0, 0, 0)
		TNT1 A 4 bright // ACS_ExecuteAlways(345,0,4,0,0)
		stop
	}
}

actor Utility_MechTurretBlue : Utility_TurretBase
{
	obituary "%o was owned by a \chBlue \c-anti-Mech turret."
	health 500
	painchance 50
	damagefactor "Explosion", 0.75
	damagefactor "MassDriver", 0.75
	//seesound "turret/sight"
	attacksound "rifle/fire"
	activesound "turret/sight"
	states
	{
	Spawn:
		CIGN AA 0 A_CheckSight("Death.Deconstruction")
		CIGN A 0 Thing_SetSpecial (0, 84, 345, 0, TEAM_BLUE)
	Idle:
		CIGN A 0 A_GiveInventory("MechReloading",12)
		CIGN A 6 A_Look
		wait
	See:
		CIGN A 0 A_GiveInventory("IsBlue",1)
		CIGN A 2 A_ChangeFlag("FRIENDLY",0)
		CIGN D 12 A_StopSoundEx("SoundSlot6")
		CIGN A 2 A_JumpIfTargetInLOS("Missile")
		CIGN A 0 A_TakeInventory("MechReloading",12)
		CIGN A 2 A_ClearTarget
		goto Idle+1
	Clear:
		CIGN A 2 A_ClearTarget
		goto See
	MissileCheck:
		CIGN A 0 A_JumpIfInTargetInventory ("IsRed", 1, 1)
		goto Clear
		CIGN A 0 A_Chase("","",CHF_DONTMOVE)
		CIGN A 0 
		goto MissileGo+2
	Missile:
		CIGN A 0 
		CIGN A 1 A_JumpIfInTargetInventory ("IsRed", 1, 1)
		goto Clear
		CIGN A 1 A_JumpIfCloser(4000,"MissileGo")
		CIGN A 0 
		goto Clear
	MissileGo:
		CIGN B 0 A_JumpIfInTargetInventory("IsMech",1,1)
		goto Clear
		CIGN B 10 A_FaceTarget
		CIGN F 0 A_CPosRefire
		CIGN B 0 A_JumpIfInventory("MechReloading",6,"Pain")
		CIGN B 0 A_PlayWeaponSound("rifle/fire")
		CIGN B 0 A_CustomMissile("MechTurretProjectileBlue",48,0)
		CIGN B 0 //A_CustomBulletAttack(2,2,1,15,"RiflePuff",4000)
		CIGN B 0 A_SpawnItemEx("Flash",0,0,0,0,0,0,0,128,0)
		CIGN B 0 A_FaceTarget
		CIGN C 4 BRIGHT A_SpawnItemEx("ShellCasing",8,8,48,random(1,3),random(0,1),random(1,3),random(45,60),128)
		CIGN BA 6 BRIGHT A_ChangeFlag("FRIENDLY",0)
		CIGN F 0 A_CPosRefire
		CIGN F 0 A_GiveInventory("MechReloading",1)
		goto MissileCheck
	Pain:
		CIGN A 0 A_StopSoundEx("SoundSlot6")
		CIGN A 0 A_ClearTarget
		CIGN A 3 A_TakeInventory("MechReloading",6)
		goto See
	Death:	
		TC4T A 0		 
		CIGN A 0 A_StopSoundEx("SoundSlot6")
		TC4T A 0 A_NoBlocking
		TNT1 A 0 A_SpawnItemEx("ExplosionMain", 0, 0, 32, 0, 0, 0, 0, 128, 0)
		TC4T A 0 A_PlaySound("weapons/rocklx")
		TNT1 A 0 A_SpawnItemEx("FlameWallDecay", 0, 0, 0, 0, 0, 0, 0, 0, 0)
		TNT1 A 4
		stop
	}
}

actor MechTurretProjectile : FastProjectile {
	Radius 5
	Height 5
	Speed 250
	Damage (12)
	Projectile
	-RANDOMIZE
	obituary "%o was owned by a \cgRed \c-anti-Mech turret."
	DamageType "AntiArmor"
	states {
	Spawn:
		TNT1 A -1
		stop
	Death:
		TNT1 A 5 A_SpawnItemEx ("ExplosionPuffSmall")
		stop
	}
}

actor MechTurretProjectileBlue : MechTurretProjectile {
	obituary "%o was owned by a \chBlue \c-anti-Mech turret."
	DamageType "AntiArmor"
}