<?xml version="1.0" encoding="utf-8"?>
<Patch>
	<Operation Class="PatchOperationFindMod">
		<mods>
			<li>Royalty</li>
		</mods>
		<match Class="PatchOperationSequence">
			<operations>

				<!-- === Bug fix === -->
				<li Class="PatchOperationAdd">
					<xpath>Defs/ThingDef[@Name="EW_BasePersonaEltexGun"]/comps</xpath>
					<value>
						<li Class="CompProperties_Forbiddable" />
					</value>
				</li>
				<!-- === Mod Extensions === -->
				<li Class="PatchOperationConditional">
					<xpath>Defs/ThingDef[defName="EW_Gun_PersonaEltexPistol"]/modExtensions/li[@Class="AthenaFramework.DamageModifierExtension"]</xpath>
					<nomatch Class="PatchOperationRemove">
						<xpath>Defs/ThingDef[
							defName="EW_Gun_PersonaEltexPistol" or
							defName="EW_Gun_PersonaEltexSMG" or
							defName="EW_Gun_PersonaEltexRifle" or
							defName="EW_Gun_PersonaEltexLance"
							]/modExtensions/li[@Class="EltexWeaponry.ModExtension_PsychicDamage"]</xpath>
					</nomatch>
					<match Class="PatchOperationRemove">
						<xpath>Defs/ThingDef[
							defName="EW_Gun_PersonaEltexPistol" or
							defName="EW_Gun_PersonaEltexSMG" or
							defName="EW_Gun_PersonaEltexRifle" or
							defName="EW_Gun_PersonaEltexLance"
							]/modExtensions/li[@Class="AthenaFramework.DamageModifierExtension"]</xpath>
					</match>
				</li>
				<!-- === Tools === -->
				<li Class="PatchOperationReplace">
					<xpath>Defs/ThingDef[defName ="EW_Gun_PersonaEltexPistol" or defName="EW_Gun_PersonaEltexSMG"]/tools</xpath>
					<value>
						<tools>
							<li Class="CombatExtended.ToolCE">
								<label>grip</label>
								<capacities>
									<li>Blunt</li>
								</capacities>
								<power>2</power>
								<cooldownTime>1.54</cooldownTime>
								<chanceFactor>1.5</chanceFactor>
								<armorPenetrationBlunt>0.555</armorPenetrationBlunt>
								<linkedBodyPartsGroup>Grip</linkedBodyPartsGroup>
							</li>
							<li Class="CombatExtended.ToolCE">
								<label>muzzle</label>
								<capacities>
									<li>Poke</li>
								</capacities>
								<power>2</power>
								<cooldownTime>1.54</cooldownTime>
								<armorPenetrationBlunt>0.555</armorPenetrationBlunt>
								<linkedBodyPartsGroup>Muzzle</linkedBodyPartsGroup>
							</li>
						</tools>
					</value>
				</li>

				<li Class="PatchOperationReplace">
					<xpath>/Defs/ThingDef[defName="EW_Gun_PersonaEltexRifle" or defName="EW_Gun_PersonaEltexLance"]/tools</xpath>
					<value>
						<tools>
							<li Class="CombatExtended.ToolCE">
								<label>stock</label>
								<capacities>
									<li>Blunt</li>
								</capacities>
								<power>8</power>
								<cooldownTime>1.55</cooldownTime>
								<chanceFactor>1.5</chanceFactor>
								<armorPenetrationBlunt>2.755</armorPenetrationBlunt>
								<linkedBodyPartsGroup>Stock</linkedBodyPartsGroup>
							</li>
							<li Class="CombatExtended.ToolCE">
								<label>barrel</label>
								<capacities>
									<li>Blunt</li>
								</capacities>
								<power>5</power>
								<cooldownTime>2.02</cooldownTime>
								<armorPenetrationBlunt>1.630</armorPenetrationBlunt>
								<linkedBodyPartsGroup>Barrel</linkedBodyPartsGroup>
							</li>
							<li Class="CombatExtended.ToolCE">
								<label>muzzle</label>
								<capacities>
									<li>Poke</li>
								</capacities>
								<power>8</power>
								<cooldownTime>1.55</cooldownTime>
								<armorPenetrationBlunt>2.755</armorPenetrationBlunt>
								<linkedBodyPartsGroup>Muzzle</linkedBodyPartsGroup>
							</li>
						</tools>
					</value>
				</li>

				<!-- Eltex Pistol -->
				<li Class="CombatExtended.PatchOperationMakeGunCECompatible">
					<defName>EW_Gun_PersonaEltexPistol</defName>
					<statBases>
						<Mass>1.30</Mass>
						<Bulk>2.20</Bulk>
						<SwayFactor>1.07</SwayFactor>
						<ShotSpread>0.15</ShotSpread>
						<SightsEfficiency>0.8</SightsEfficiency>
						<RangedWeapon_Cooldown>0.36</RangedWeapon_Cooldown>
						<WorkToMake>21250</WorkToMake>
					</statBases>
					<costList>
						<Steel>20</Steel>
						<Plasteel>30</Plasteel>
						<Chemfuel>5</Chemfuel>
						<ComponentIndustrial>2</ComponentIndustrial>
						<ComponentSpacer>1</ComponentSpacer>
						<VPE_Eltex MayRequire="VanillaExpanded.VPsycastsE">1</VPE_Eltex>
					</costList>
					<Properties>
						<verbClass>CombatExtended.Verb_ShootCE</verbClass>
						<hasStandardCommand>True</hasStandardCommand>
						<defaultProjectile>Bullet_EltexLight</defaultProjectile>
						<burstShotCount>3</burstShotCount>
						<ticksBetweenBurstShots>5</ticksBetweenBurstShots>
						<warmupTime>0.5</warmupTime>
						<range>12</range>
						<soundCast>EW_Shot_Light</soundCast>
						<soundCastTail>GunTail_Light</soundCastTail>
						<muzzleFlashScale>9</muzzleFlashScale>
					</Properties>
					<AmmoUser>
						<magazineSize>12</magazineSize>
						<reloadTime>3</reloadTime>
						<ammoSet>AmmoSet_EltexLight</ammoSet>
					</AmmoUser>
					<FireModes>
						<aiAimMode>AimedShot</aiAimMode>
					</FireModes>
					<weaponTags>
						<li>SpacerGun</li>
						<li>CE_Sidearm</li>
						<li>CE_OneHandedWeapon</li>
					</weaponTags>
				</li>

				<!-- Eltex SMG -->
				<li Class="CombatExtended.PatchOperationMakeGunCECompatible">
					<defName>EW_Gun_PersonaEltexSMG</defName>
					<statBases>
						<WorkToMake>35000</WorkToMake>
						<Mass>2.80</Mass>
						<Bulk>5.00</Bulk>
						<SwayFactor>0.70</SwayFactor>
						<ShotSpread>0.15</ShotSpread>
						<SightsEfficiency>1</SightsEfficiency>
						<RangedWeapon_Cooldown>0.36</RangedWeapon_Cooldown>
					</statBases>
					<costList>
						<Steel>30</Steel>
						<Plasteel>45</Plasteel>
						<ComponentIndustrial>8</ComponentIndustrial>
						<ComponentSpacer>2</ComponentSpacer>
						<VPE_Eltex MayRequire="VanillaExpanded.VPsycastsE">1</VPE_Eltex>
					</costList>
					<Properties>
						<verbClass>CombatExtended.Verb_ShootCE</verbClass>
						<hasStandardCommand>True</hasStandardCommand>
						<defaultProjectile>Bullet_EltexLight</defaultProjectile>
						<burstShotCount>6</burstShotCount>
						<ticksBetweenBurstShots>4</ticksBetweenBurstShots>
						<warmupTime>0.5</warmupTime>
						<range>31</range>
						<soundCast>EW_Shot_Light</soundCast>
						<soundCastTail>GunTail_Medium</soundCastTail>
						<muzzleFlashScale>9</muzzleFlashScale>
						<recoilAmount>1.20</recoilAmount>
					</Properties>
					<AmmoUser>
						<magazineSize>36</magazineSize>
						<reloadTime>4</reloadTime>
						<ammoSet>AmmoSet_EltexLight</ammoSet>
					</AmmoUser>
					<FireModes>
						<aiAimMode>Snapshot</aiAimMode>
						<aiUseBurstMode>True</aiUseBurstMode>
						<aimedBurstShotCount>3</aimedBurstShotCount>
					</FireModes>
					<weaponTags>
						<li>SpacerGun</li>
						<li>CE_Sidearm</li>
						<li>CE_OneHandedWeapon</li>
					</weaponTags>
				</li>

				<!-- Eltex Rifle -->
				<li Class="CombatExtended.PatchOperationMakeGunCECompatible">
					<defName>EW_Gun_PersonaEltexRifle</defName>
					<statBases>
						<WorkToMake>57500</WorkToMake>
						<Mass>3.0</Mass>
						<Bulk>7.00</Bulk>
						<SwayFactor>1.10</SwayFactor>
						<ShotSpread>0.07</ShotSpread>
						<SightsEfficiency>1.10</SightsEfficiency>
						<RangedWeapon_Cooldown>0.42</RangedWeapon_Cooldown>
					</statBases>
					<costList>
						<Steel>40</Steel>
						<Plasteel>60</Plasteel>
						<ComponentIndustrial>10</ComponentIndustrial>
						<ComponentSpacer>3</ComponentSpacer>
						<VPE_Eltex MayRequire="VanillaExpanded.VPsycastsE">2</VPE_Eltex>
					</costList>
					<Properties>
						<verbClass>CombatExtended.Verb_ShootCE</verbClass>
						<hasStandardCommand>True</hasStandardCommand>
						<defaultProjectile>Bullet_EltexMedium</defaultProjectile>
						<burstShotCount>6</burstShotCount>
						<ticksBetweenBurstShots>5</ticksBetweenBurstShots>
						<ammoConsumedPerShotCount>2</ammoConsumedPerShotCount>
						<warmupTime>1.0</warmupTime>
						<range>55</range>
						<soundCast>EW_Shot_Medium</soundCast>
						<soundCastTail>GunTail_Medium</soundCastTail>
						<muzzleFlashScale>11</muzzleFlashScale>
					</Properties>
					<AmmoUser>
						<magazineSize>60</magazineSize>
						<reloadTime>4</reloadTime>
						<ammoSet>AmmoSet_EltexMedium</ammoSet>
					</AmmoUser>
					<FireModes>
						<aiAimMode>AimedShot</aiAimMode>
						<aiUseBurstMode>True</aiUseBurstMode>
						<aimedBurstShotCount>3</aimedBurstShotCount>
					</FireModes>
					<weaponTags>
						<li>SpacerGun</li>
						<li>CE_AI_AR</li>
					</weaponTags>
				</li>

				<!-- Eltex Lance -->
				<li Class="CombatExtended.PatchOperationMakeGunCECompatible">
					<defName>EW_Gun_PersonaEltexLance</defName>
					<statBases>
						<WorkToMake>57500</WorkToMake>
						<Mass>8</Mass>
						<Bulk>14.5</Bulk>
						<SwayFactor>2.15</SwayFactor>
						<ShotSpread>0.05</ShotSpread>
						<SightsEfficiency>2.8</SightsEfficiency>
						<RangedWeapon_Cooldown>0.42</RangedWeapon_Cooldown>
						<NightVisionEfficiency_Weapon>0.6</NightVisionEfficiency_Weapon>
					</statBases>
					<costList>
						<Steel>55</Steel>
						<Plasteel>70</Plasteel>
						<ComponentIndustrial>12</ComponentIndustrial>
						<ComponentSpacer>3</ComponentSpacer>
						<VPE_Eltex MayRequire="VanillaExpanded.VPsycastsE">2</VPE_Eltex>
					</costList>
					<Properties>
						<verbClass>CombatExtended.Verb_ShootCE</verbClass>
						<hasStandardCommand>True</hasStandardCommand>
						<defaultProjectile>Bullet_EltexHeavy</defaultProjectile>
						<warmupTime>1.6</warmupTime>
						<range>70</range>
						<ammoConsumedPerShotCount>3</ammoConsumedPerShotCount>
						<soundCast>EW_Shot_Heavy</soundCast>
						<soundCastTail>GunTail_Medium</soundCastTail>
						<muzzleFlashScale>11</muzzleFlashScale>
					</Properties>
					<AmmoUser>
						<magazineSize>15</magazineSize>
						<reloadTime>4</reloadTime>
						<ammoSet>AmmoSet_EltexHeavy</ammoSet>
					</AmmoUser>
					<FireModes>
						<aiAimMode>AimedShot</aiAimMode>
					</FireModes>
					<weaponTags>
						<li>SniperRifle</li>
						<li>SpacerGun</li>
						<li>CE_AI_SR</li>
						<li>Bipod_DMR</li>
					</weaponTags>
					<AllowWithRunAndGun>false</AllowWithRunAndGun>
				</li>
				<!-- Eltex Warmace -->
				<li Class="PatchOperationReplace">
					<xpath>Defs/ThingDef[defName="EW_Melee_PersonaEltexWarmace"]/tools</xpath>
					<value>
						<tools>
							<li Class="CombatExtended.ToolCE">
								<label>handle</label>
								<capacities>
									<li>Blunt</li>
								</capacities>
								<power>3</power>
								<chanceFactor>0.33</chanceFactor>
								<cooldownTime>1.6</cooldownTime>
								<armorPenetrationBlunt>0.65</armorPenetrationBlunt>
								<linkedBodyPartsGroup>Handle</linkedBodyPartsGroup>
							</li>
							<li Class="CombatExtended.ToolCE">
								<label>head</label>
								<capacities>
									<li>Blunt</li>
								</capacities>
								<power>17</power>
								<cooldownTime>1.78</cooldownTime>
								<armorPenetrationBlunt>49</armorPenetrationBlunt>
								<linkedBodyPartsGroup>Head</linkedBodyPartsGroup>
							</li>
						</tools>
					</value>
				</li>

				<li Class="PatchOperationAdd">
					<xpath>Defs/ThingDef[defName="EW_Melee_PersonaEltexWarmace"]/equippedStatOffsets</xpath>
					<value>
						<MeleeCritChance>0.43</MeleeCritChance>
						<MeleeParryChance>0.23</MeleeParryChance>
						<MeleeDodgeChance>0.2</MeleeDodgeChance>
					</value>
				</li>

				<li Class="PatchOperationAdd">
					<xpath>Defs/ThingDef[defName="EW_Melee_PersonaEltexWarmace"]/statBases</xpath>
					<value>
						<Bulk>3.5</Bulk>
						<MeleeCounterParryBonus>0.23</MeleeCounterParryBonus>
						<ToughnessRating>15</ToughnessRating>
					</value>
				</li>

				<li Class="PatchOperationConditional">
					<xpath>Defs/ThingDef[defName="EW_Melee_PersonaEltexWarmace"]/weaponTags</xpath>
					<nomatch Class="PatchOperationAdd">
						<xpath>Defs/ThingDef[defName="EW_Melee_PersonaEltexWarmace"]</xpath>
						<value>
							<weaponTags />
						</value>
					</nomatch>
				</li>

				<li Class="PatchOperationAdd">
					<xpath>Defs/ThingDef[defName="EW_Melee_PersonaEltexWarmace"]/weaponTags</xpath>
					<value>
						<li>CE_OneHandedWeapon</li>
					</value>
				</li>
			</operations>
		</match>
	</Operation>

</Patch>