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

	<Operation Class="PatchOperationRemove">
		<xpath>Defs/ThingDef[
			defName="RNTurret_SentryGun" or
			defName="RNTurret_SentrySMG" or
			defName="RNTurret_SentrySniper" or
			defName="RNTurret_SentryNLAR"
			]/comps/li[@Class="CompProperties_Refuelable"] </xpath>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[
			defName="RNTurret_SentryGun" or
			defName="RNTurret_SentrySMG" or
			defName="RNTurret_SentrySniper" or
			defName="RNTurret_SSMTurret" or
			defName="RNTurret_SentryNLAR"
			]/thingClass </xpath>
		<value>
			<thingClass>CombatExtended.Building_TurretGunCE</thingClass>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[
			defName="RNTurret_SentryGun" or
			defName="RNTurret_SentrySniper" or
			defName="RNTurret_SentryNLAR"
			]/fillPercent </xpath>
		<value>
			<fillPercent>0.85</fillPercent>
		</value>
	</Operation>

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

	<Operation Class="PatchOperationRemove">
		<xpath>Defs/ThingDef[
			defName="RNTurret_SentryGun" or
			defName="RNTurret_SentrySMG" or
			defName="RNTurret_SentrySniper" or
			defName="RNTurret_SSMTurret" or
			defName="RNTurret_SentryNLAR"
			]/comps/li[@Class="CompProperties_Explosive"] </xpath>
	</Operation>

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

	<!-- ========== Sentry Gun ========== -->

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

	<Operation Class="CombatExtended.PatchOperationMakeGunCECompatible">
		<defName>RNGun_SentryGun</defName>
		<statBases>
			<RangedWeapon_Cooldown>0.35</RangedWeapon_Cooldown>
			<SightsEfficiency>1.00</SightsEfficiency>
			<ShotSpread>0.06</ShotSpread>
			<SwayFactor>1.31</SwayFactor>
			<Bulk>8.02</Bulk>
		</statBases>
		<Properties>
			<recoilAmount>0.59</recoilAmount>
			<verbClass>CombatExtended.Verb_ShootCE</verbClass>
			<hasStandardCommand>true</hasStandardCommand>
			<defaultProjectile>Bullet_762x51mmNATO_FMJ</defaultProjectile>
			<warmupTime>2.3</warmupTime>
			<range>62</range>
			<ticksBetweenBurstShots>1</ticksBetweenBurstShots>
			<burstShotCount>100</burstShotCount>
			<soundCast>Shot_Minigun</soundCast>
			<soundCastTail>GunTail_Heavy</soundCastTail>
			<muzzleFlashScale>10</muzzleFlashScale>
			<recoilPattern>Mounted</recoilPattern>
		</Properties>
		<AmmoUser>
			<magazineSize>500</magazineSize>
			<reloadTime>9.2</reloadTime>
			<ammoSet>AmmoSet_762x51mmNATO</ammoSet>
		</AmmoUser>
		<FireModes>
			<aiAimMode>AimedShot</aiAimMode>
			<noSnapshot>true</noSnapshot>
			<noSingleShot>true</noSingleShot>
		</FireModes>
		<weaponTags>
			<li>TurretGun</li>
		</weaponTags>
	</Operation>

	<!-- ========== SMG Sentry Gun ========== -->

	<Operation Class="CombatExtended.PatchOperationMakeGunCECompatible">
		<defName>RNGun_SentrySMG</defName>
		<statBases>
			<Mass>2.60</Mass>
			<RangedWeapon_Cooldown>0.36</RangedWeapon_Cooldown>
			<SightsEfficiency>1.00</SightsEfficiency>
			<ShotSpread>0.12</ShotSpread>
			<SwayFactor>0.77</SwayFactor>
			<Bulk>10</Bulk>
		</statBases>
		<Properties>
			<recoilAmount>1.05</recoilAmount>
			<verbClass>CombatExtended.Verb_ShootCE</verbClass>
			<hasStandardCommand>true</hasStandardCommand>
			<defaultProjectile>Bullet_FN57x28mm_FMJ</defaultProjectile>
			<warmupTime>0.5</warmupTime>
			<range>31</range>
			<burstShotCount>5</burstShotCount>
			<ticksBetweenBurstShots>4</ticksBetweenBurstShots>
			<soundCast>RNP90Shot</soundCast>
			<soundCastTail>GunTail_Light</soundCastTail>
			<muzzleFlashScale>9</muzzleFlashScale>
		</Properties>
		<AmmoUser>
			<magazineSize>50</magazineSize>
			<reloadTime>4.5</reloadTime>
			<ammoSet>AmmoSet_FN57x28mm</ammoSet>
		</AmmoUser>
		<FireModes>
			<aiAimMode>AimedShot</aiAimMode>
			<noSnapshot>true</noSnapshot>
			<noSingleShot>true</noSingleShot>
		</FireModes>
	</Operation>

	<!-- ========== Sniper Turret ========== -->

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

	<Operation Class="CombatExtended.PatchOperationMakeGunCECompatible">
		<defName>RNGun_SentrySniper</defName>
		<statBases>
			<RangedWeapon_Cooldown>5</RangedWeapon_Cooldown>
			<SightsEfficiency>2</SightsEfficiency>
			<ShotSpread>0.01</ShotSpread>
			<SwayFactor>1.23</SwayFactor>
			<Bulk>11.90</Bulk>
		</statBases>
		<Properties>
			<verbClass>CombatExtended.Verb_ShootCE</verbClass>
			<hasStandardCommand>true</hasStandardCommand>
			<defaultProjectile>Bullet_50BMG_FMJ</defaultProjectile>
			<warmupTime>4.1</warmupTime>
			<range>86</range>
			<ticksBetweenBurstShots>9</ticksBetweenBurstShots>
			<soundCast>RNShot50Cal</soundCast>
			<soundCastTail>GunTail_Light</soundCastTail>
			<muzzleFlashScale>18</muzzleFlashScale>
			<recoilPattern>Mounted</recoilPattern>
		</Properties>
		<AmmoUser>
			<magazineSize>20</magazineSize>
			<reloadTime>4.5</reloadTime>
			<ammoSet>AmmoSet_50BMG</ammoSet>
		</AmmoUser>
		<FireModes>
			<aiUseBurstMode>FALSE</aiUseBurstMode>
			<aiAimMode>AimedShot</aiAimMode>
			<noSnapshot>true</noSnapshot>
		</FireModes>
		<weaponTags>
			<li>TurretGun</li>
		</weaponTags>
	</Operation>

	<!-- ========== NL Turret ========== -->

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

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="RNTurret_SentryNLAR"]/label</xpath>
		<value>
			<label>sentry shotgun turret</label>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="RNTurret_SentryNLAR"]/description</xpath>
		<value>
			<description>A versatile turret capable of firing a variety of different munitions, including buckshot, EMP slugs, and non-lethal beanbag projectiles, though the bulky shells mean the ammo capacity is somewhat limited. Its dumb AI brain can't be directly controlled, so beware of friendly fire.</description>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="RNGun_SentryNLAR"]/label</xpath>
		<value>
			<label>sentry shotgun</label>
		</value>
	</Operation>

	<Operation Class="CombatExtended.PatchOperationMakeGunCECompatible">
		<defName>RNGun_SentryNLAR</defName>
		<statBases>
			<RangedWeapon_Cooldown>0.35</RangedWeapon_Cooldown>
			<SightsEfficiency>1</SightsEfficiency>
			<ShotSpread>0.12</ShotSpread>
			<SwayFactor>0.82</SwayFactor>
			<Bulk>20.00</Bulk>
		</statBases>
		<Properties>
			<recoilAmount>0.76</recoilAmount>
			<verbClass>CombatExtended.Verb_ShootCE</verbClass>
			<hasStandardCommand>true</hasStandardCommand>
			<defaultProjectile>Bullet_12Gauge_Beanbag</defaultProjectile>
			<warmupTime>1.3</warmupTime>
			<range>22</range>
			<ticksBetweenBurstShots>12</ticksBetweenBurstShots>
			<burstShotCount>5</burstShotCount>
			<soundCast>GunShotA</soundCast>
			<soundCastTail>GunTail_Light</soundCastTail>
			<muzzleFlashScale>9</muzzleFlashScale>
			<recoilPattern>Mounted</recoilPattern>
		</Properties>
		<AmmoUser>
			<magazineSize>30</magazineSize>
			<reloadTime>6</reloadTime>
			<ammoSet>AmmoSet_12Gauge</ammoSet>
		</AmmoUser>
		<FireModes>
			<aiAimMode>AimedShot</aiAimMode>
			<noSnapshot>true</noSnapshot>
			<noSingleShot>true</noSingleShot>
		</FireModes>
	</Operation>

	<!-- ========== SSM ========== -->

	<!-- SSM Base -->

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

	<Operation Class="PatchOperationAdd">
		<xpath>Defs/ThingDef[defName="RNTurret_SSM"]/statBases</xpath>
		<value>
			<ShootingAccuracyTurret>0.75</ShootingAccuracyTurret>
		</value>
	</Operation>

	<!-- SSM Top -->

	<!-- Glitter Tech Fix -->

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

	<Operation Class="PatchOperationAdd">
		<xpath>Defs/ThingDef[defName="RNArtillery_SSMTurret"]</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>3</magazineSize>
					<reloadTime>8</reloadTime>
					<ammoSet>AmmoSet_130mmType63_SSM</ammoSet>
				</li>
			</comps>
		</value>
	</Operation>

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

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="RNArtillery_SSMTurret"]/verbs</xpath>
		<value>
			<verbs>
				<li Class="CombatExtended.VerbPropertiesCE">
					<verbClass>CombatExtended.Verb_ShootMortarCE</verbClass>
					<forceNormalTimeSpeed>false</forceNormalTimeSpeed>
					<hasStandardCommand>true</hasStandardCommand>
					<defaultProjectile>Bullet_130mmType63_SSM</defaultProjectile>
					<warmupTime>11</warmupTime>
					<minRange>32</minRange>
					<range>700</range>
					<burstShotCount>1</burstShotCount>
					<soundCast>InfernoCannon_Fire</soundCast>
					<soundCastTail>GunTail_Heavy</soundCastTail>
					<muzzleFlashScale>16</muzzleFlashScale>
					<circularError>0.1</circularError>
					<indirectFirePenalty>0.1</indirectFirePenalty>
					<targetParams>
						<canTargetLocations>true</canTargetLocations>
					</targetParams>
				</li>
			</verbs>
		</value>
	</Operation>
</Patch>