<?xml version="1.0" encoding="utf-8"?>
<Patch>

	<!-- ========== Structures ========== -->

	<Operation Class="PatchOperationAdd">
		<xpath>Defs/ThingDef[defName="Gloomlight"]/fillPercent</xpath>
		<value>
			<fillPercent>0.3</fillPercent>
		</value>
	</Operation>

	<!-- ========== Turrets ========== -->

	<!-- ========== Auto mini-turret ========== -->

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="Turret_AutoMiniTurret"]/label</xpath>
		<value>
			<label>mini-blaster turret</label>
		</value>
	</Operation>

	<Operation Class="PatchOperationRemove">
		<xpath>Defs/ThingDef[defName="Turret_AutoMiniTurret"]/comps/li[@Class="CompProperties_Stunnable"]/affectedDamageDefs/li[.="Stun"]</xpath>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="Turret_AutoMiniTurret"]/thingClass</xpath>
		<value>
			<thingClass>CombatExtended.Building_TurretGunCE</thingClass>
		</value>
	</Operation>

	<Operation Class="PatchOperationAdd">
		<xpath>Defs/ThingDef[defName="Turret_AutoMiniTurret"]/statBases</xpath>
		<value>
			<AimingAccuracy>0.75</AimingAccuracy>
			<NightVisionEfficiency>0.6</NightVisionEfficiency>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="Turret_AutoMiniTurret"]/statBases/ShootingAccuracyTurret</xpath>
		<value>
			<ShootingAccuracyTurret>1.25</ShootingAccuracyTurret>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="Turret_AutoMiniTurret"]/statBases/Mass</xpath>
		<value>
			<Mass>35</Mass>
		</value>
	</Operation>

	<Operation Class="PatchOperationRemove">
		<xpath>Defs/ThingDef[defName="Turret_AutoMiniTurret"]/comps/li[@Class="CompProperties_Explosive"]</xpath>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="Turret_AutoMiniTurret"]/fillPercent</xpath>
		<value>
			<fillPercent>0.85</fillPercent>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="Turret_AutoMiniTurret"]/building/turretBurstCooldownTime</xpath>
		<value>
			<turretBurstCooldownTime>2.0</turretBurstCooldownTime><!-- Intentionally increased from 1.0s of CE auto turrets-->
		</value>
	</Operation>

	<!-- ========== Auto Charge Blaster ========== -->

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="Turret_AutoChargeBlaster"]/thingClass</xpath>
		<value>
			<thingClass>CombatExtended.Building_CIWS_CE</thingClass>
		</value>
	</Operation>

	<Operation Class="PatchOperationRemove">
		<xpath>Defs/ThingDef[defName="Turret_AutoChargeBlaster"]/comps/li[@Class="CompProperties_Stunnable"]/affectedDamageDefs/li[.="Stun"]</xpath>
	</Operation>

	<Operation Class="PatchOperationRemove">
		<xpath>Defs/ThingDef[defName="Turret_AutoChargeBlaster"]/comps/li[@Class="CompProperties_Explosive"]</xpath>
	</Operation>

	<Operation Class="PatchOperationAdd">
		<xpath>Defs/ThingDef[defName="Turret_AutoChargeBlaster"]/statBases</xpath>
		<value>
			<AimingAccuracy>0.5</AimingAccuracy>
			<NightVisionEfficiency>0.6</NightVisionEfficiency>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="Turret_AutoChargeBlaster"]/statBases/ShootingAccuracyTurret</xpath>
		<value>
			<ShootingAccuracyTurret>1.0</ShootingAccuracyTurret>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="Turret_AutoChargeBlaster"]/statBases/Mass</xpath>
		<value>
			<Mass>100</Mass>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="Turret_AutoChargeBlaster"]/fillPercent</xpath>
		<value>
			<fillPercent>0.85</fillPercent>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="Turret_AutoChargeBlaster"]/building/turretBurstCooldownTime</xpath>
		<value>
			<turretBurstCooldownTime>2.0</turretBurstCooldownTime><!-- Intentionally increased from 1.0s of CE auto turrets-->
		</value>
	</Operation>


	<Operation Class="PatchOperationAdd">
		<xpath>Defs/ThingDef[defName="Turret_AutoChargeBlaster"]/comps</xpath>
		<value>
			<li>
				<compClass>CombatExtended.CompVerbDisabler</compClass>
			</li>
		</value>
	</Operation>

	<!-- ========== Auto Inferno Turret ========== -->

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="Turret_AutoInferno"]/thingClass</xpath>
		<value>
			<thingClass>CombatExtended.Building_TurretGunCE</thingClass>
		</value>
	</Operation>

	<Operation Class="PatchOperationRemove">
		<xpath>Defs/ThingDef[defName="Turret_AutoInferno"]/comps/li[@Class="CompProperties_Stunnable"]/affectedDamageDefs/li[.="Stun"]</xpath>
	</Operation>

	<Operation Class="PatchOperationAdd">
		<xpath>Defs/ThingDef[defName="Turret_AutoInferno"]/statBases</xpath>
		<value>
			<AimingAccuracy>0.5</AimingAccuracy>
			<NightVisionEfficiency>0.6</NightVisionEfficiency>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="Turret_AutoInferno"]/statBases/ShootingAccuracyTurret</xpath>
		<value>
			<ShootingAccuracyTurret>1.0</ShootingAccuracyTurret>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="Turret_AutoInferno"]/statBases/Mass</xpath>
		<value>
			<Mass>400</Mass>
		</value>
	</Operation>

	<Operation Class="PatchOperationRemove">
		<xpath>Defs/ThingDef[defName="Turret_AutoInferno"]/comps/li[@Class="CompProperties_Explosive"]</xpath>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="Turret_AutoInferno"]/fillPercent</xpath>
		<value>
			<fillPercent>0.85</fillPercent>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="Turret_AutoInferno"]/building/turretBurstCooldownTime</xpath>
		<value>
			<turretBurstCooldownTime>2.52</turretBurstCooldownTime><!-- Intentionally increased from 1.0s of CE auto turrets-->
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="Turret_AutoInferno"]/building/turretGunDef</xpath>
		<value>
			<turretGunDef>Gun_InfernoCannonTurret</turretGunDef>
		</value>
	</Operation>

	<!-- ========== Auto Mortar ========== -->

	<!-- Auto Mortar Base -->

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="Turret_AutoMortar"]/comps/li[@Class="CompProperties_Explosive"]/wickTicks</xpath>
		<value>
			<wickTicks>
				<min>280</min>
				<max>660</max>
			</wickTicks>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="Turret_AutoMortar"]/thingClass</xpath>
		<value>
			<thingClass>CombatExtended.Building_TurretGunCE</thingClass>
		</value>
	</Operation>

	<Operation Class="PatchOperationRemove">
		<xpath>Defs/ThingDef[defName="Turret_AutoMortar"]/comps/li[@Class="CompProperties_Stunnable"]/affectedDamageDefs/li[.="Stun"]</xpath>
	</Operation>
	
	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="Turret_AutoMortar"]/statBases/MaxHitPoints</xpath>
		<value>
			<MaxHitPoints>250</MaxHitPoints>
		</value>
	</Operation>

	<Operation Class="PatchOperationAdd">
		<xpath>Defs/ThingDef[defName="Turret_AutoMortar"]/statBases</xpath>
		<value>
			<AimingAccuracy>0.25</AimingAccuracy>
			<NightVisionEfficiency>0.6</NightVisionEfficiency>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="Turret_AutoMortar"]/statBases/ShootingAccuracyTurret</xpath>
		<value>
			<ShootingAccuracyTurret>0.5</ShootingAccuracyTurret>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="Turret_AutoMortar"]/fillPercent</xpath>
		<value>
			<fillPercent>0.85</fillPercent>
		</value>
	</Operation>

	<Operation Class="PatchOperationAdd">
		<xpath>Defs/ThingDef[defName="Turret_AutoMortar"]/comps</xpath>
		<value>
			<li Class="CombatExtended.CompProperties_Fragments">
				<fragments>
					<Fragment_Large>5</Fragment_Large>
					<Fragment_Small>20</Fragment_Small>
				</fragments>
			</li>
		</value>
	</Operation>

	<!-- Auto Mortar Top -->

	<!-- Glitter Tech Fix -->

	<Operation Class="PatchOperationConditional">
		<xpath>Defs/ThingDef[defName="Artillery_AutoMortar"]/statBases</xpath>
		<nomatch Class="PatchOperationAdd">
			<xpath>Defs/ThingDef[defName="Artillery_AutoMortar"]</xpath>
			<value>
				<statBases>
					<SightsEfficiency>0.5</SightsEfficiency>
				</statBases>
			</value>
		</nomatch>
		<match Class="PatchOperationAdd">
			<xpath>Defs/ThingDef[defName="Artillery_AutoMortar"]/statBases</xpath>
			<value>
				<SightsEfficiency>0.5</SightsEfficiency>
			</value>
		</match>
	</Operation>

	<Operation Class="PatchOperationAdd">
		<xpath>Defs/ThingDef[defName="Artillery_AutoMortar"]</xpath>
		<value>
			<comps>
				<li Class="CombatExtended.CompProperties_Charges">
					<chargeSpeeds>
						<li>30</li>
						<li>50</li>
						<li>70</li>
						<li>90</li>
					</chargeSpeeds>
				</li>
				<li Class="CombatExtended.CompProperties_AmmoUser">
					<magazineSize>10</magazineSize>
					<reloadTime>9.8</reloadTime>
					<ammoSet>AmmoSet_66mmThermalBolt</ammoSet>
				</li>
			</comps>
		</value>
	</Operation>

	<Operation Class="PatchOperationAdd">
		<xpath>Defs/ThingDef[defName="Artillery_AutoMortar"]/weaponTags</xpath>
		<value>
			<li>TurretGun</li>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="Artillery_AutoMortar"]/verbs</xpath>
		<value>
			<verbs>
				<li Class="CombatExtended.VerbPropertiesCE">
					<verbClass>CombatExtended.Verb_ShootMortarCE</verbClass>
					<forceNormalTimeSpeed>false</forceNormalTimeSpeed>
					<hasStandardCommand>true</hasStandardCommand>
					<defaultProjectile>Bullet_66mmThermalBolt_Incendiary</defaultProjectile>
					<warmupTime>11</warmupTime>
					<minRange>32</minRange>
					<range>700</range>
					<burstShotCount>1</burstShotCount>
					<soundCast>Mortar_LaunchA</soundCast>
					<muzzleFlashScale>16</muzzleFlashScale>
					<circularError>3</circularError>
					<indirectFirePenalty>0.4</indirectFirePenalty>
					<targetParams>
						<canTargetLocations>true</canTargetLocations>
					</targetParams>
				</li>
			</verbs>
		</value>
	</Operation>

</Patch>