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

	<!-- Remove refuelable property -->
	<Operation Class="PatchOperationRemove">
		<xpath>Defs/ThingDef[
			defName="VFEP_Turret_FieldGun" or
			defName="VFEP_Turret_Cannon"
			]/comps/li[@Class="CompProperties_Refuelable"] </xpath>
	</Operation>

	<!-- Replace vanilla thingClass -->
	<Operation Class="PatchOperationAdd">
		<xpath>Defs/ThingDef[defName="VFEP_Turret_Cannon" or defName="VFEP_Turret_FieldGun"]</xpath>
		<value>
			<thingClass>CombatExtended.Building_TurretGunCE</thingClass>
		</value>
	</Operation>

	<!-- Field Gun -->

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

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="VFEP_Turret_FieldGun"]/building/turretBurstWarmupTime</xpath>
		<value>
			<turretBurstWarmupTime>4.0</turretBurstWarmupTime>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="VFEP_Turret_FieldGun"]/building/turretBurstCooldownTime</xpath>
		<value>
			<turretBurstCooldownTime>2.0</turretBurstCooldownTime>
		</value>
	</Operation>

	<Operation Class="PatchOperationAdd">
		<xpath>Defs/ThingDef[defName="VFEP_Turret_FieldGun"]</xpath>
		<value>
			<statBases>
				<Mass>500</Mass>
				<Bulk>250</Bulk>
			</statBases>
		</value>
	</Operation>

	<Operation Class="PatchOperationAdd">
		<xpath>Defs/ThingDef[defName="VFEP_Turret_FieldGun"]</xpath>
		<value>
			<placeWorkers Inherit="False">
				<li>PlaceWorker_TurretTop</li>
				<li>PlaceWorker_PreventInteractionSpotOverlap</li>
			</placeWorkers>
		</value>
	</Operation>

	<Operation Class="PatchOperationAdd">
		<xpath>Defs/ThingDef[defName="VFEP_Artillery_FieldGun"]/statBases</xpath>
		<value>
			<Mass>250</Mass>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="VFEP_Artillery_FieldGun"]/statBases/RangedWeapon_Cooldown</xpath>
		<value>
			<RangedWeapon_Cooldown>2</RangedWeapon_Cooldown>
		</value>
	</Operation>

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

	<Operation Class="PatchOperationAdd">
		<xpath>Defs/ThingDef[defName="VFEP_Artillery_FieldGun"]/comps</xpath>
		<value>
			<li Class="CombatExtended.CompProperties_AmmoUser">
				<magazineSize>1</magazineSize>
				<reloadTime>5</reloadTime>
				<ammoSet>AmmoSet_762x385mmRCannonShell</ammoSet>
			</li>
		</value>
	</Operation>

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

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="VFEP_Artillery_FieldGun"]/verbs</xpath>
		<value>
			<verbs>
				<li Class="CombatExtended.VerbPropertiesCE">
					<recoilAmount>4.36</recoilAmount>
					<verbClass>CombatExtended.Verb_ShootCE</verbClass>
					<forceNormalTimeSpeed>false</forceNormalTimeSpeed>
					<hasStandardCommand>true</hasStandardCommand>
					<defaultProjectile>Bullet_762x385mmRCannonShell_HEAT</defaultProjectile>
					<warmupTime>4</warmupTime>
					<minRange>16</minRange>
					<range>86</range>
					<burstShotCount>1</burstShotCount>
					<soundCast>VFEP_Shot_FieldCannon</soundCast>
					<muzzleFlashScale>16</muzzleFlashScale>
					<targetParams>
						<canTargetLocations>true</canTargetLocations>
					</targetParams>
					<recoilPattern>Mounted</recoilPattern>
				</li>
			</verbs>
		</value>
	</Operation>

	<!-- Cannon - Based on the M1897 12-pounder -->

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[@Name="VFEP_BaseCannonBuilding"]/fillPercent</xpath>
		<value>
			<fillPercent>0.85</fillPercent>
		</value>
	</Operation>

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

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

	<Operation Class="PatchOperationRemove">
		<xpath>Defs/ThingDef[@Name="VFEP_BaseCannonBuilding"]/placeWorkers/li[.="PlaceWorker_NotUnderRoof"]</xpath>
	</Operation>

	<Operation Class="CombatExtended.PatchOperationMakeGunCECompatible">
		<defName>VFEP_Artillery_Cannon</defName>
		<statBases>
			<RangedWeapon_Cooldown>2.7</RangedWeapon_Cooldown>
			<SightsEfficiency>0.80</SightsEfficiency>
			<ShotSpread>0.15</ShotSpread>
			<SwayFactor>0.81</SwayFactor>
			<Mass>125</Mass>
		</statBases>
		<AmmoUser>
			<magazineSize>1</magazineSize>
			<reloadTime>10</reloadTime>
			<ammoSet>AmmoSet_CannonBall</ammoSet>
		</AmmoUser>
		<FireModes>
			<aiUseBurstMode>FALSE</aiUseBurstMode>
			<aiAimMode>AimedShot</aiAimMode>
		</FireModes>
		<weaponTags>
			<li>TurretGun</li>
		</weaponTags>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="VFEP_Artillery_Cannon"]/verbs</xpath>
		<value>
			<verbs>
				<li Class="CombatExtended.VerbPropertiesCE">
					<recoilAmount>2.40</recoilAmount>
					<verbClass>CombatExtended.Verb_ShootCE</verbClass>
					<hasStandardCommand>true</hasStandardCommand>
					<defaultProjectile>Bullet_CannonBall_Round</defaultProjectile>
					<warmupTime>3.3</warmupTime>
					<range>64</range>
					<minRange>16</minRange>
					<soundCast>VFEP_Shot_Cannon</soundCast>
					<soundCastTail>GunTail_Heavy</soundCastTail>
					<muzzleFlashScale>18</muzzleFlashScale>
					<targetParams>
						<canTargetLocations>true</canTargetLocations>
					</targetParams>
					<recoilPattern>Mounted</recoilPattern>
				</li>
			</verbs>
		</value>
	</Operation>

	<Operation Class="PatchOperationAdd">
		<xpath>Defs/ThingDef[defName="VFEP_Turret_Cannon"]</xpath>
		<value>
			<statBases>
				<Bulk>150</Bulk>
				<Mass>250</Mass>
			</statBases>
		</value>
	</Operation>

</Patch>