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

	<!-- ========== Add DefModExtension ========== -->

	<Operation Class="PatchOperationAddModExtension">
		<xpath>Defs/DamageDef[defName="Flame"]</xpath>
		<value>
			<li Class="CombatExtended.DamageDefExtensionCE">
				<harmOnlyOutsideLayers>true</harmOnlyOutsideLayers>
				<isAmbientDamage>true</isAmbientDamage>
				<canCauseWallFragmentation>false</canCauseWallFragmentation>
			</li>
		</value>
	</Operation>

	<Operation Class="PatchOperationAddModExtension">
		<xpath>Defs/DamageDef[defName="Frostbite"]</xpath>
		<value>
			<li Class="CombatExtended.DamageDefExtensionCE">
				<harmOnlyOutsideLayers>true</harmOnlyOutsideLayers>
				<isAmbientDamage>true</isAmbientDamage>
			</li>
		</value>
	</Operation>

	<Operation Class="PatchOperationAddModExtension">
		<xpath>Defs/DamageDef[defName="EMP"]</xpath>
		<value>
			<li Class="CombatExtended.DamageDefExtensionCE">
				<isAmbientDamage>true</isAmbientDamage>
				<secondaryDamageShieldOverride>true</secondaryDamageShieldOverride>
				<shieldDamageMultiplier>2.5</shieldDamageMultiplier>
			</li>
		</value>
	</Operation>

	<!-- ========== Add Names for secondary damage inheritance ========== -->

	<Operation Class="PatchOperationAttributeSet">
		<xpath>Defs/DamageDef[defName="Bullet"]</xpath>
		<attribute>Name</attribute>
		<value>Bullet</value>
	</Operation>

	<Operation Class="PatchOperationAttributeSet">
		<xpath>Defs/DamageDef[defName="Frostbite"]</xpath>
		<attribute>Name</attribute>
		<value>Frostbite</value>
	</Operation>

	<!-- ========== Change Bomb hediff ========== -->

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/DamageDef[defName="Bomb"]/hediff</xpath>
		<value>
			<hediff>Blast</hediff>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/DamageDef[defName="Bomb"]/armorCategory</xpath>
		<value>
			<armorCategory>Blunt</armorCategory>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/DamageDef[defName="Bomb"]/minDamageToFragment</xpath>
		<value>
			<minDamageToFragment>4</minDamageToFragment>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/DamageDef[defName="Bomb"]/defaultDamage</xpath>
		<value>
			<defaultDamage>156</defaultDamage>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/DamageDef[defName="Bomb"]/defaultArmorPenetration</xpath>
		<value>
			<defaultArmorPenetration>62</defaultArmorPenetration>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/DamageDef[defName="BombSuper"]/defaultDamage</xpath>
		<value>
			<defaultDamage>800</defaultDamage>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/DamageDef[defName="BombSuper"]/defaultArmorPenetration</xpath>
		<value>
			<defaultArmorPenetration>320</defaultArmorPenetration>
		</value>
	</Operation>

	<!-- ========== Change Thump hediff ========== -->

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/DamageDef[defName="Thump"]/hediff</xpath>
		<value>
			<hediff>Blast</hediff>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/DamageDef[defName="Thump"]/armorCategory</xpath>
		<value>
			<armorCategory>Blunt</armorCategory>
		</value>
	</Operation>

	<!-- ========== Patch-out vanilla melee stun mechanic from blunt damage ========== -->

	<Operation Class="PatchOperationRemove">
		<xpath>Defs/DamageDef[@Name="BluntBase"]/*[self::bluntStunDuration or self::bluntStunChancePerDamagePctOfCorePartToHeadCurve or self::bluntStunChancePerDamagePctOfCorePartToBodyCurve]</xpath>
	</Operation>

	<!-- ========== Add electric armor to EMP damage ========== -->

	<Operation Class="PatchOperationAdd">
		<xpath>Defs/DamageDef[defName="EMP"]</xpath>
		<value>
			<armorCategory>Electric</armorCategory>
		</value>
	</Operation>

	<!-- ========== Add heat armor to Frostbite damage ========== -->

	<Operation Class="PatchOperationAdd">
		<xpath>Defs/DamageDef[defName="Frostbite"]</xpath>
		<value>
			<armorCategory>Heat</armorCategory>
		</value>
	</Operation>

	<!-- ========== Venom Bite & Scratch ========== -->

	<Operation Class="PatchOperationAdd">
		<xpath>Defs/DamageDef[defName="ToxicBite"]</xpath>
		<value>
			<hediff>VenomousBite</hediff>
		</value>
	</Operation>

	<Operation Class="PatchOperationRemove">
		<xpath>Defs/DamageDef[defName="ToxicBite"]/additionalHediffs/li[hediff="ToxicBuildup"]</xpath>
	</Operation>

	<Operation Class="PatchOperationAdd">
		<xpath>Defs/DamageDef[defName="ScratchToxic"]</xpath>
		<value>
			<hediff>VenomousScratch</hediff>
		</value>
	</Operation>

	<Operation Class="PatchOperationRemove">
		<xpath>Defs/DamageDef[defName="ScratchToxic"]/additionalHediffs/li[hediff="ToxicBuildup"]</xpath>
	</Operation>

	<!-- ========== Fix harm layers for stab attacks ========== -->

	<Operation Class="PatchOperationAdd">
		<xpath>Defs/DamageDef[defName="Stab"]</xpath>
		<value>
			<harmAllLayersUntilOutside>true</harmAllLayersUntilOutside>
		</value>
	</Operation>

	<Operation Class="PatchOperationAdd">
		<xpath>Defs/DamageDef[defName="RangedStab"]</xpath>
		<value>
			<harmAllLayersUntilOutside>true</harmAllLayersUntilOutside>
		</value>
	</Operation>

	<!-- ========== Acid Burn armor category ========== -->

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/DamageDef[defName="AcidBurn"]/armorCategory</xpath>
		<value>
			<armorCategory>Heat</armorCategory>
		</value>
	</Operation>

  <!-- ========== Disable wall fragmentation ========== -->

	<Operation Class="PatchOperationAddModExtension">
		<xpath>Defs/DamageDef[defName="Crush"]</xpath>
		<value>
		<li Class="CombatExtended.DamageDefExtensionCE">
			<canCauseWallFragmentation>false</canCauseWallFragmentation>
		</li>
		</value>
	</Operation>

	<Operation Class="PatchOperationAddModExtension">
		<xpath>Defs/DamageDef[defName="Mining"]</xpath>
		<value>
			<li Class="CombatExtended.DamageDefExtensionCE">
				<canCauseWallFragmentation>false</canCauseWallFragmentation>
			</li>
		</value>
	</Operation>

	<Operation Class="PatchOperationAddModExtension">
		<xpath>Defs/DamageDef[defName="Beam" or defName="BeamBypassShields"]</xpath>
		<value>
			<li Class="CombatExtended.DamageDefExtensionCE">
				<canCauseWallFragmentation>false</canCauseWallFragmentation>
			</li>
		</value>
	</Operation>

	<Operation Class="PatchOperationAddModExtension">
		<xpath>Defs/DamageDef[defName="Demolish"]</xpath>
		<value>
			<li Class="CombatExtended.DamageDefExtensionCE">
				<canCauseWallFragmentation>false</canCauseWallFragmentation>
			</li>
		</value>
	</Operation>

	<Operation Class="PatchOperationAddModExtension">
		<xpath>Defs/DamageDef[defName="Thump"]</xpath>
		<value>
			<li Class="CombatExtended.DamageDefExtensionCE">
				<canCauseWallFragmentation>false</canCauseWallFragmentation>
			</li>
		</value>
	</Operation>

	<!-- ========== Add soundExplosion to Bullet for cookoff ========== -->

	<Operation Class="PatchOperationAdd">
		<xpath>Defs/DamageDef[defName="Bullet"]</xpath>
		<value>
			<soundExplosion>Explosion_Bomb</soundExplosion>
		</value>
	</Operation>

</Patch>