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

	<!--=============== Base turrets ===============-->
	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[
			defName="Turret_Ballista" or
			defName="Turret_Triplecrossbow" or
			@Name="Turret_CatapultBase" or
			@Name="Turret_TrebuchetBase"
			]/thingClass </xpath>
		<value>
			<thingClass>CombatExtended.Building_TurretGunCE</thingClass>
		</value>
	</Operation>

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

	<!-- Remove duplicate mannable comp. -->
	<Operation Class="PatchOperationRemove">
		<xpath>Defs/ThingDef[
			@Name="Turret_CatapultBase" or
			@Name="Turret_TrebuchetBase"
			]/comps/li[@Class="CompProperties_Mannable"] </xpath>
	</Operation>

	<!--=============== Ballista ===============-->
	<Operation Class="CombatExtended.PatchOperationMakeGunCECompatible">
		<defName>Turret_BallistaGun</defName>
		<statBases>
			<Mass>25.0</Mass>
			<RangedWeapon_Cooldown>8.56</RangedWeapon_Cooldown>
			<SightsEfficiency>1.1</SightsEfficiency>
			<ShotSpread>0.002</ShotSpread>
			<SwayFactor>0.0</SwayFactor>
			<Bulk>18.87</Bulk>
		</statBases>
		<Properties>
			<recoilAmount>0.1</recoilAmount>
			<verbClass>CombatExtended.Verb_ShootCE</verbClass>
			<hasStandardCommand>true</hasStandardCommand>
			<defaultProjectile>Pilum_Fired</defaultProjectile>
			<warmupTime>0.5</warmupTime>
			<range>42</range>
			<soundCast>Ballista_Launch</soundCast>
			<muzzleFlashScale>0</muzzleFlashScale>
			<targetParams>
				<canTargetLocations>true</canTargetLocations>
			</targetParams>
		</Properties>
		<AmmoUser>
			<magazineSize>1</magazineSize>
			<reloadTime>3.5</reloadTime>
			<ammoSet>AmmoSet_Javelins</ammoSet>
		</AmmoUser>
		<FireModes>
			<aiAimMode>AimedShot</aiAimMode>
			<noSnapshot>true</noSnapshot>
			<noSingleShot>true</noSingleShot>
		</FireModes>
	</Operation>

	<!--=============== Triple Crossbow ===============-->
	<Operation Class="CombatExtended.PatchOperationMakeGunCECompatible">
		<defName>Turret_TriplecrossbowGun</defName>
		<statBases>
			<Mass>25.0</Mass>
			<RangedWeapon_Cooldown>8.56</RangedWeapon_Cooldown>
			<SightsEfficiency>1.1</SightsEfficiency>
			<ShotSpread>0.005</ShotSpread>
			<SwayFactor>0.0</SwayFactor>
			<Bulk>22.87</Bulk>
		</statBases>
		<Properties>
			<recoilAmount>0.1</recoilAmount>
			<verbClass>CombatExtended.Verb_ShootCE</verbClass>
			<hasStandardCommand>true</hasStandardCommand>
			<defaultProjectile>Pilum_Fired</defaultProjectile>
			<warmupTime>0.85</warmupTime>
			<range>40</range>
			<soundCast>Ballista_Launch</soundCast>
			<muzzleFlashScale>0</muzzleFlashScale>
			<ticksBetweenBurstShots>10</ticksBetweenBurstShots>
			<burstShotCount>3</burstShotCount>
			<targetParams>
				<canTargetLocations>true</canTargetLocations>
			</targetParams>
		</Properties>
		<AmmoUser>
			<magazineSize>3</magazineSize>
			<reloadTime>4.95</reloadTime>
			<ammoSet>AmmoSet_Javelins</ammoSet>
		</AmmoUser>
		<FireModes>
			<aiAimMode>AimedShot</aiAimMode>
			<aiUseBurstMode>true</aiUseBurstMode>
			<aimedBurstShotCount>3</aimedBurstShotCount>
			<noSnapshot>true</noSnapshot>
			<noSingleShot>true</noSingleShot>
		</FireModes>
	</Operation>

	<!--========== Catapult - Weapon ==========-->

	<Operation Class="PatchOperationAdd">
		<xpath>Defs/ThingDef[@Name="BaseCatapultWeapon"]</xpath>
		<value>
			<statBases>
				<SightsEfficiency>0.5</SightsEfficiency>
			</statBases>
		</value>
	</Operation>

	<Operation Class="PatchOperationAdd">
		<xpath>Defs/ThingDef[@Name="BaseCatapultWeapon"]/comps</xpath>
		<value>
			<li Class="CombatExtended.CompProperties_Charges">
				<chargeSpeeds>
					<li>10</li>
					<li>20</li>
					<li>30</li>
					<li>50</li>
					<li>70</li>
				</chargeSpeeds>
			</li>
			<li Class="CombatExtended.CompProperties_AmmoUser">
				<magazineSize>1</magazineSize>
				<reloadTime>12</reloadTime>
				<ammoSet>AmmoSet_Catapult</ammoSet>
			</li>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="Turret_CatapultGun"]/verbs</xpath>
		<value>
			<verbs>
				<li Class="CombatExtended.VerbPropertiesCE">
					<verbClass>CombatExtended.Verb_ShootMortarCE</verbClass>
					<forceNormalTimeSpeed>false</forceNormalTimeSpeed>
					<hasStandardCommand>true</hasStandardCommand>
					<defaultProjectile>Projectile_CatapultBullet_Boulder</defaultProjectile>
					<warmupTime>4</warmupTime>
					<minRange>20</minRange>
					<range>500</range>
					<burstShotCount>1</burstShotCount>
					<soundCast>Bow_Recurve</soundCast>
					<muzzleFlashScale>0</muzzleFlashScale>
					<indirectFirePenalty>0.2</indirectFirePenalty>
					<targetParams>
						<canTargetLocations>true</canTargetLocations>
					</targetParams>
				</li>
			</verbs>
		</value>
	</Operation>

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

	<!-- ========== Catapult - Base ========== -->

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[@Name="Turret_CatapultBase"]/building/turretBurstWarmupTime</xpath>
		<value>
			<turretBurstWarmupTime>1</turretBurstWarmupTime>
		</value>
	</Operation>

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

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

	<!--========== Trebuchet - Weapon ==========-->
	<Operation Class="PatchOperationAdd">
		<xpath>Defs/ThingDef[@Name="BaseTrebuchetWeapon"]</xpath>
		<value>
			<statBases>
				<SightsEfficiency>0.5</SightsEfficiency>
			</statBases>
		</value>
	</Operation>

	<Operation Class="PatchOperationAdd">
		<xpath>Defs/ThingDef[@Name="BaseTrebuchetWeapon"]/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>14</reloadTime>
				<ammoSet>AmmoSet_Catapult</ammoSet>
			</li>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="Turret_TrebuchetGun"]/verbs</xpath>
		<value>
			<verbs>
				<li Class="CombatExtended.VerbPropertiesCE">
					<verbClass>CombatExtended.Verb_ShootMortarCE</verbClass>
					<forceNormalTimeSpeed>false</forceNormalTimeSpeed>
					<hasStandardCommand>true</hasStandardCommand>
					<defaultProjectile>Projectile_CatapultBullet_Boulder</defaultProjectile>
					<warmupTime>4</warmupTime>
					<minRange>30</minRange>
					<range>500</range>
					<burstShotCount>1</burstShotCount>
					<soundCast>Bow_Recurve</soundCast>
					<muzzleFlashScale>0</muzzleFlashScale>
					<indirectFirePenalty>0.2</indirectFirePenalty>
					<targetParams>
						<canTargetLocations>true</canTargetLocations>
					</targetParams>
				</li>
			</verbs>
		</value>
	</Operation>

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

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

	<!-- === Remove Unneeded === -->

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

	<Operation Class="PatchOperationRemove">
		<xpath>Defs/RecipeDef[defName="Make_TrebuchetShells"]</xpath>
	</Operation>

	<Operation Class="PatchOperationRemove">
		<xpath>Defs/RecipeDef[defName="Make_TrebuchetShellsA"]</xpath>
	</Operation>

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

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

	<Operation Class="PatchOperationRemove">
		<xpath>Defs/RecipeDef[defName="MakeHumanRound"]</xpath>
	</Operation>

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

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

	<Operation Class="PatchOperationRemove">
		<xpath>Defs/RecipeDef[defName="Make_CatapultShells"]</xpath>
	</Operation>

	<Operation Class="PatchOperationRemove">
		<xpath>Defs/RecipeDef[defName="Make_CatapultShellsA"]</xpath>
	</Operation>
</Patch>