<?xml version="1.0" encoding="utf-8"?>
<Patch>
	<!-- ========== Common to all Turrets ========== -->

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[
			@Name="Base_FK_96_KA" or
			@Name="Base_leFH_16_KA" or
			defName="Turret_MG_08_KA"
			]/thingClass </xpath>
		<value>
			<thingClass>CombatExtended.Building_TurretGunCE</thingClass>
		</value>
	</Operation>

	<!-- ========== Remove Vanilla Ammo Shells ========== -->

	<Operation Class="PatchOperationRemove">
		<xpath>Defs/ThingDef[defName="Shell_77cm_AP_KA"]</xpath>
	</Operation>

	<Operation Class="PatchOperationRemove">
		<xpath>Defs/ThingDef[defName="Shell_77cm_HE_KA"]</xpath>
	</Operation>

	<Operation Class="PatchOperationRemove">
		<xpath>Defs/ThingDef[defName="Shell_105cm_HE_KA"]</xpath>
	</Operation>
	<!-- ========== MG 08 ========== -->

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

	<Operation Class="CombatExtended.PatchOperationMakeGunCECompatible">
		<defName>Gun_MG_08_KA</defName>
		<statBases>
			<RangedWeapon_Cooldown>0.35</RangedWeapon_Cooldown>
			<SightsEfficiency>1</SightsEfficiency>
			<ShotSpread>0.17</ShotSpread>
			<SwayFactor>1.66</SwayFactor>
			<Bulk>13.75</Bulk>
		</statBases>
		<Properties>
			<recoilAmount>0.40</recoilAmount>
			<verbClass>CombatExtended.Verb_ShootCE</verbClass>
			<hasStandardCommand>true</hasStandardCommand>
			<defaultProjectile>Bullet_792x57mmMauser_FMJ</defaultProjectile>
			<warmupTime>1.3</warmupTime>
			<range>62</range>
			<ticksBetweenBurstShots>8</ticksBetweenBurstShots>
			<burstShotCount>10</burstShotCount>
			<soundCast>Shot_MG_08</soundCast>
			<soundCastTail>GunTail_Heavy</soundCastTail>
			<muzzleFlashScale>12</muzzleFlashScale>
			<recoilPattern>Mounted</recoilPattern>
		</Properties>
		<AmmoUser>
			<magazineSize>250</magazineSize>
			<reloadTime>7.8</reloadTime>
			<ammoSet>AmmoSet_792x57mmMauser</ammoSet>
		</AmmoUser>
		<FireModes>
			<aiUseBurstMode>FALSE</aiUseBurstMode>
			<aiAimMode>SuppressFire</aiAimMode>
			<aimedBurstShotCount>5</aimedBurstShotCount>
		</FireModes>
		<weaponTags>
			<li>TurretGun</li>
		</weaponTags>
	</Operation>

	<!-- ========== FK 96 ========== -->

	<Operation Class="CombatExtended.PatchOperationMakeGunCECompatible">
		<defName>Artillery_FK_96_KA</defName>
		<statBases>
			<RangedWeapon_Cooldown>2.75</RangedWeapon_Cooldown>
			<SightsEfficiency>2</SightsEfficiency>
			<ShotSpread>0.01</ShotSpread>
			<SwayFactor>1.14</SwayFactor>
		</statBases>
		<Properties>
			<verbClass>CombatExtended.Verb_ShootCE</verbClass>
			<hasStandardCommand>true</hasStandardCommand>
			<defaultProjectile>Bullet_77x230mmRCannonShell_HE</defaultProjectile>
			<warmupTime>4.55</warmupTime>
			<range>78</range>
			<ticksBetweenBurstShots>8</ticksBetweenBurstShots>
			<burstShotCount>10</burstShotCount>
			<soundCast>Shot_FK_96</soundCast>
			<soundCastTail>GunTail_Heavy</soundCastTail>
			<muzzleFlashScale>20</muzzleFlashScale>
			<recoilPattern>Mounted</recoilPattern>
		</Properties>
		<AmmoUser>
			<magazineSize>1</magazineSize>
			<reloadTime>9.8</reloadTime>
			<ammoSet>AmmoSet_77x230mmRCannonShell</ammoSet>
		</AmmoUser>
		<FireModes>
			<aiAimMode>AimedShot</aiAimMode>
		</FireModes>
		<weaponTags>
			<li>TurretGun</li>
		</weaponTags>
	</Operation>

	<!-- ========== leFH 16 ========== -->

	<Operation Class="PatchOperationAdd">
		<xpath>Defs/ThingDef[defName="Artillery_leFH_16_KA"]</xpath>
		<value>
			<statBases>
				<SightsEfficiency>0.8</SightsEfficiency>
			</statBases>
		</value>
	</Operation>

	<Operation Class="PatchOperationConditional">
		<xpath>Defs/ThingDef[defName="Artillery_leFH_16_KA"]/comps</xpath>
		<nomatch Class="PatchOperationAdd">
			<xpath>Defs/ThingDef[defName="Artillery_leFH_16_KA"]</xpath>
			<value>
				<comps/>
			</value>
		</nomatch>
	</Operation>

	<Operation Class="PatchOperationAdd">
		<xpath>Defs/ThingDef[defName="Artillery_leFH_16_KA"]/comps</xpath>
		<value>
			<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>1</magazineSize>
				<reloadTime>5</reloadTime>
				<ammoSet>AmmoSet_105x155mmRCannonShell</ammoSet>
			</li>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="Artillery_leFH_16_KA"]/verbs</xpath>
		<value>
			<verbs>
				<li Class="CombatExtended.VerbPropertiesCE">
					<verbClass>CombatExtended.Verb_ShootMortarCE</verbClass>
					<forceNormalTimeSpeed>false</forceNormalTimeSpeed>
					<hasStandardCommand>true</hasStandardCommand>
					<requireLineOfSight>false</requireLineOfSight>
					<defaultProjectile>Bullet_105x155mmRCannonShell_HE</defaultProjectile>
					<warmupTime>10</warmupTime>
					<minRange>32</minRange>
					<range>1000</range>
					<burstShotCount>1</burstShotCount>
					<soundCast>Shot_leFH_16</soundCast>
					<muzzleFlashScale>39</muzzleFlashScale>
					<circularError>1</circularError>
					<indirectFirePenalty>0.15</indirectFirePenalty>
					<targetParams>
						<canTargetLocations>true</canTargetLocations>
					</targetParams>
				</li>
			</verbs>
		</value>
	</Operation>

	<!-- Patch base -->

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[@Name="Base_leFH_16_KA"]/thingClass</xpath>
		<value>
			<thingClass>CombatExtended.Building_TurretGunCE</thingClass>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[@Name="Base_leFH_16_KA"]/building/turretBurstCooldownTime</xpath>
		<value>
			<turretBurstCooldownTime>5</turretBurstCooldownTime>
		</value>
	</Operation>

	<Operation Class="PatchOperationAdd">
		<xpath>Defs/ThingDef[@Name="Base_leFH_16_KA"]/building</xpath>
		<value>
			<spawnedConceptLearnOpportunity>CE_MortarDirectFire</spawnedConceptLearnOpportunity>
		</value>
	</Operation>

	<Operation Class="PatchOperationRemove">
		<xpath>Defs/ThingDef[@Name="Base_leFH_16_KA"]/inspectorTabs</xpath>
	</Operation>
</Patch>