// Klaxon turret AKA Advanced Gun Turret
actor Utility_KlaxonRed : Utility_TurretBase {
	obituary "%o was pwned by a \cgRed\c- klaxon turret."
	health 250
	speed 0
	painchance 50
	attacksound "minigun/fire2"
	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 0 A_StopSound (6)
		CIGN AAAAA 6 A_Look
		goto Idle+2
	See:
		CIGN A 0 A_GiveInventory("IsRed",1)
		CIGN A 2 A_ChangeFlag("FRIENDLY",0)
		CIGN A 8 A_StopSound (6)
		CIGN A 2 A_JumpIfTargetInLOS("Missile")
		CIGN A 0 A_TakeInventory("MechReloading",12)
		CIGN A 2 A_ClearTarget
		goto Spawn+3
	Clear:
		CIGN A 2 A_ClearTarget
		goto See
	See3:
		CIGN A 1 A_JumpIfInTargetInventory ("IsBlue", 1, 1)
		goto Clear
		CIGN A 0 A_Jump(16,"MissileGo")
		CIGN A 0 A_JumpIfCloser(128,"MissileGo")
		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+3
	Missile:
		CIGN A 0 
		CIGN A 1 A_JumpIfInTargetInventory ("IsBlue", 1, 1)
		goto Clear
		CIGN A 0 A_JumpIfInTargetInventory ("StealthMode", 2, "Clear")
		CIGN A 1 A_JumpIfCloser (1024, "MissileGo")
		CIGN A 0
		goto Clear
	MissileGo:
		CIGN B 0 A_SpawnItemEx ("KlaxonMarker", 0,0,0,0,0,0,0, 32)
		CIGN B 8 A_PlaySound ("misc/alarm")
		CIGN B 8 A_FaceTarget
		CIGN F 0 A_CPosRefire
		CIGN B 2 A_PlaySoundEx("minigun/loop","SoundSlot6",1)
		CIGN B 0 A_JumpIfInventory("GunTurretClip", 23, "Klaxon")
		CIGN B 0 A_CustomBulletAttack (8.0, 2, 1, 4, "RiflePuff")
		CIGN B 0 A_SpawnItemEx("Flash",0,0,0,0,0,0,0,128,0)
		CIGN B 0 A_FaceTarget
		CIGN C 2 BRIGHT A_SpawnItemEx("ShellCasing",8,8,48,random(1,3),random(0,1),random(1,3),random(45,60),128)
		CIGN B 1 BRIGHT 
		CIGN B 0 A_CustomBulletAttack (8.0, 2, 1, 4, "RiflePuff")
		CIGN B 0 A_SpawnItemEx("Flash",0,0,0,0,0,0,0,128,0)
		CIGN B 0 A_PlaySoundEx("minigun/fire2","Weapon")
		CIGN B 0 A_FaceTarget
		CIGN C 2 BRIGHT A_SpawnItemEx("ShellCasing",8,8,48,random(1,3),random(0,1),random(1,3),random(45,60),128)
		CIGN B 1 BRIGHT A_ChangeFlag("FRIENDLY",0)
		CIGN F 0 A_CPosRefire
		CIGN F 0 A_GiveInventory("GunTurretClip",1)
		goto MissileCheck
	Pain.LaserBlue:
	Pain:
		CIGN A 0 A_StopSound (6)
		CIGN A 0 A_ClearTarget
		CIGN A 9 A_TakeInventory("GunTurretClip", 23)
		goto See
	Klaxon:
		CIGN A 0 A_StopSound (6)
		CIGN A 0 A_ClearTarget
		CIGN A 0 A_SpawnItemEx ("KlaxonMarker", 0,0,0,0,0,0,0, 32)
		CIGN A 0 A_PlaySound  ("misc/alarm")
		CIGN D 35 bright A_TakeInventory ("GunTurretClip",23)
		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)
		TC4T A 0 A_PlaySound("weapons/rocklx")
		TNT1 A 0 A_SpawnItemEx("FlameWallDecay")
		TNT1 A 4
		stop
	}
}

actor Utility_KlaxonBlue : Utility_TurretBase {
	obituary "%o was pwned by a \chBlue\c- klaxon turret."
	health 250
	speed 0
	painchance 50
	//seesound "turret/sight"
	attacksound "minigun/fire2"
	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 0 A_StopSound (6)
		CIGN AAAAA 6 A_Look
		goto Idle+2
	See:
		CIGN A 0 A_GiveInventory("IsBlue",1)
		CIGN A 2 A_ChangeFlag("FRIENDLY",0)
		CIGN A 8 A_StopSound (6)
		CIGN A 2 A_JumpIfTargetInLOS("Missile")
		CIGN A 0 A_TakeInventory("MechReloading",12)
		CIGN A 2 A_ClearTarget
		goto Spawn+3
	See3:
		CIGN A 0 A_JumpIfInTargetInventory("IsRed",1,1)
		goto Clear
		CIGN A 0 A_Jump(16,"MissileGo")
		CIGN A 0 A_JumpIfCloser(128,"MissileGo")
		goto See
	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+3
	Missile:
		CIGN A 0 
		CIGN A 1 A_JumpIfInTargetInventory("IsRed",1,1)
		goto Clear
		CIGN A 0 A_JumpIfInTargetInventory("StealthMode",2,"Clear")
		CIGN A 1 A_JumpIfCloser(7072,"MissileGo")
		CIGN A 0 
		goto Clear
	MissileGo:
		CIGN B 0 A_SpawnItemEx ("KlaxonMarker", 0,0,0,0,0,0,0, 32)
		CIGN B 8 A_PlaySound ("misc/alarm")
		CIGN B 8 A_FaceTarget
		CIGN F 0 A_CPosRefire
		CIGN B 2 A_PlaySoundEx ("minigun/loop","SoundSlot6",1)
		CIGN B 0 A_JumpIfInventory("GunTurretClip", 23, "Klaxon")
		CIGN B 0 A_CustomBulletAttack (8.0, 2, 1, 4, "RiflePuff")
		CIGN B 0 A_SpawnItemEx("Flash")
		CIGN B 0 A_FaceTarget
		CIGN C 2 BRIGHT A_SpawnItemEx("ShellCasing",8,8,48,random(1,3),random(0,1),random(1,3),random(45,60),128)
		CIGN B 1 BRIGHT 
		CIGN B 0 A_CustomBulletAttack (8.0, 2, 1, 4, "RiflePuff")
		CIGN B 0 A_SpawnItemEx("Flash")
		CIGN B 0 A_PlaySoundEx("minigun/fire2","Weapon")
		CIGN B 0 A_FaceTarget
		CIGN C 2 BRIGHT A_SpawnItemEx("ShellCasing",8,8,48,random(1,3),random(0,1),random(1,3),random(45,60),128)
		CIGN B 1 BRIGHT A_ChangeFlag("FRIENDLY",0)
		CIGN F 0 A_CPosRefire
		CIGN F 0 A_GiveInventory("GunTurretClip", 1)
		goto MissileCheck
	Pain.LaserRed:
	Pain:
		CIGN A 0 A_StopSound (6)
		CIGN A 0 A_ClearTarget
		CIGN A 9 A_TakeInventory ("GunTurretClip", 23)
		goto See
	Klaxon:
		CIGN A 0 A_StopSound (6)
		CIGN A 0 A_ClearTarget
		CIGN A 0 A_SpawnItemEx ("KlaxonMarker", 0,0,0,0,0,0,0, 32)
		CIGN A 0 A_PlaySound("misc/alarm")
		CIGN D 35 bright A_TakeInventory ("GunTurretClip", 23)
		goto See
	Death:  
		TC4T A 0     
		CIGN A 0 A_StopSound (6)
		TC4T A 0 A_NoBlocking
		TNT1 A 0 A_SpawnItemEx ("ExplosionMain", 0, 0, 32)
		TC4T A 0 A_PlaySound ("weapons/rocklx")
		TNT1 A 0 A_SpawnItemEx ("FlameWallDecay")
		TNT1 A 4
		stop
	}
}

actor KlaxonMarker : MapMarker {
	scale .1
	states {
	Spawn:
		KLAX A 70
		KLAX A 1 A_FadeOut (0.1)
		wait
	}
}