<?xml version="1.0" encoding="utf-8"?>
<Patch>
	<!-- Remove refuelable property -->
	<Operation Class="PatchOperationRemove">
		<xpath>Defs/ThingDef[
			defName="RE_Turret_MassAccelerator" or
			defName="RE_Turret_HeavyMassAccelerator"]/comps/li[@Class="CompProperties_Refuelable"] </xpath>
	</Operation>

	<!-- Replace vanilla thingClass -->
	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[
			defName="RE_Turret_MassAccelerator"]/thingClass </xpath>
		<value>
			<thingClass>CombatExtended.Building_TurretGunCE</thingClass>
		</value>
	</Operation>

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

	<!-- Make turrets taller -->
	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="RE_Turret_MassAccelerator"]/fillPercent</xpath>
		<value>
			<fillPercent>0.85</fillPercent>
		</value>
	</Operation>

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

	<Operation Class="PatchOperationAdd">
		<xpath>Defs/ThingDef[
			defName="RE_Turret_MassAccelerator" or
			defName="RE_Turret_HeavyMassAccelerator"
			]/statBases </xpath>
		<value>
			<AimingAccuracy>0.25</AimingAccuracy>
		</value>
	</Operation>

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

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[
			defName="RE_Turret_MassAccelerator" or
			defName="RE_Turret_HeavyMassAccelerator"
			]/building/turretBurstCooldownTime </xpath>
		<value>
			<turretBurstCooldownTime>1.1</turretBurstCooldownTime>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="RE_Turret_MassAccelerator"]/comps/li[@Class="CompProperties_Power"]</xpath>
		<value>
			<li Class="CompProperties_Power">
				<compClass>CompPowerTrader</compClass>
				<basePowerConsumption>200</basePowerConsumption>
			</li>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="RE_Turret_HeavyMassAccelerator"]/comps/li[@Class="CompProperties_Power"]</xpath>
		<value>
			<li Class="CompProperties_Power">
				<compClass>CompPowerTrader</compClass>
				<basePowerConsumption>800</basePowerConsumption>
			</li>
		</value>
	</Operation>
	<!-- Make the Turret usable -->

	<Operation Class="CombatExtended.PatchOperationMakeGunCECompatible">
		<defName>RE_Gun_MassAccelerator</defName>
		<statBases>
			<Mass>10.00</Mass>
			<RangedWeapon_Cooldown>0.4</RangedWeapon_Cooldown>
			<SightsEfficiency>1</SightsEfficiency>
			<ShotSpread>0.08</ShotSpread>
			<SwayFactor>1.1</SwayFactor>
			<Bulk>1.00</Bulk>
		</statBases>
		<Properties>
			<recoilAmount>1.27</recoilAmount>
			<verbClass>CombatExtended.Verb_ShootCE</verbClass>
			<hasStandardCommand>true</hasStandardCommand>
			<defaultProjectile>Bullet_M8_Basic</defaultProjectile>
			<warmupTime>1.3</warmupTime>
			<range>50</range>
			<ticksBetweenBurstShots>5</ticksBetweenBurstShots>
			<burstShotCount>10</burstShotCount>
			<minRange>1.5</minRange>
			<soundCast>RE_Shot_Turret</soundCast>
			<soundCastTail>GunTail_Medium</soundCastTail>
			<muzzleFlashScale>9</muzzleFlashScale>
			<recoilPattern>Mounted</recoilPattern>
		</Properties>
		<AmmoUser>
			<magazineSize>50</magazineSize>
			<reloadTime>4</reloadTime>
			<ammoSet>AmmoSet_M8</ammoSet>
		</AmmoUser>
		<FireModes>
			<aiAimMode>AimedShot</aiAimMode>
			<aimedBurstShotCount>5</aimedBurstShotCount>
			<noSnapshot>true</noSnapshot>
			<noSingleShot>true</noSingleShot>
		</FireModes>
	</Operation>

	<!-- Make the Cannon usable -->

	<Operation Class="CombatExtended.PatchOperationMakeGunCECompatible">
		<defName>RE_Gun_HeavyMassAcceleratorTurret</defName>
		<statBases>
			<Mass>50.00</Mass>
			<RangedWeapon_Cooldown>1</RangedWeapon_Cooldown>
			<SightsEfficiency>1.1</SightsEfficiency>
			<ShotSpread>0.03</ShotSpread>
			<SwayFactor>1.36</SwayFactor>
			<Bulk>1.00</Bulk>
		</statBases>
		<Properties>
			<verbClass>CombatExtended.Verb_ShootCE</verbClass>
			<hasStandardCommand>true</hasStandardCommand>
			<defaultProjectile>ME_Bullet_Cannon</defaultProjectile>
			<recoilAmount>1.48</recoilAmount>
			<warmupTime>2</warmupTime>
			<range>78</range>
			<minRange>5.9</minRange>
			<ammoConsumedPerShotCount>10</ammoConsumedPerShotCount>
			<ticksBetweenBurstShots>30</ticksBetweenBurstShots>
			<burstShotCount>3</burstShotCount>
			<soundCast>RE_Shot_HeavyTurret</soundCast>
			<soundCastTail>GunTail_Heavy</soundCastTail>
			<muzzleFlashScale>12</muzzleFlashScale>
			<recoilPattern>Mounted</recoilPattern>
		</Properties>
		<AmmoUser>
			<magazineSize>400</magazineSize>
			<reloadTime>6.0</reloadTime>
			<ammoSet>AmmoSet_ME_Cannon</ammoSet>
		</AmmoUser>
		<FireModes>
			<aiAimMode>AimedShot</aiAimMode>
			<noSnapshot>true</noSnapshot>
		</FireModes>
	</Operation>

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

	<Operation Class="PatchOperationRemove">
		<xpath>Defs/ThingDef[@Name="RE_AmmoBelts"]/recipeMaker</xpath>
	</Operation>

	<Operation Class="PatchOperationRemove">
		<xpath>Defs/ThingDef[@Name="RE_AmmoBelts"]/tradeTags</xpath>
	</Operation>

	<!-- Implant Hediffs -->
	<Operation Class="PatchOperationAdd">
		<xpath>Defs/HediffDef[defName="RE_AdrenalineModule"]/stages/li[1]</xpath>
		<value>
			<statOffsets>
				<Suppressability>-0.15</Suppressability>
			</statOffsets>
		</value>
	</Operation>

	<Operation Class="PatchOperationRemove">
		<xpath>Defs/HediffDef[defName="RE_TargetingVI"]/hediffClass</xpath>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/HediffDef[defName="RE_TargetingVI"]/stages</xpath>
		<value>
			<stages>
				<li>
					<statOffsets>
						<AimingDelayFactor>-0.08</AimingDelayFactor>
					</statOffsets>
				</li>
			</stages>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="RE_TargetingVI"]/description</xpath>
		<value>
			<description>A small capsule with a VI system, increasing the combat abilities of the user. Decreases the aiming time of the user.</description>
		</value>
	</Operation>

</Patch>