<?xml version="1.0" encoding="utf-8"?>
<Patch>
	<!-- ============== Changing Projectile's thingClass to CE ones ================ -->

	<Operation Class="PatchOperationRemove">
		<xpath>Defs/ThingDef[
			defName="AA_FrostWeb" or
			defName="AA_FireWeb" or
			defName="AA_AcidicWeb" or
			defName="AA_ElectricBolt" or
			defName="AA_FrostBolt"
			]/thingClass
		</xpath>
	</Operation>

	<Operation Class="PatchOperationAdd">
		<xpath>Defs/ThingDef[
			defName="AA_AcidicWeb" or
			defName="AA_Bullet_Barb" or
			defName="AA_Bullet_VenomBarb" or
			defName="AA_FireWeb" or
			defName="AA_FrostWeb" or
			defName="AA_Plasma" or
			defName="AA_PoisonBolt" or
			defName="AA_BlackHiveBolt" or
			defName="AA_Quill" or
			defName="AA_RedPoisonBolt" or
			defName="AA_Web" or
			defName="AA_FireSpit" or
			defName="AA_DarkBolt" or
			defName="AA_AcidBolt" or
			defName="AA_ElectricBolt" or
			defName="AA_WindBolt" or
			defName="AA_FrostBolt"]
		</xpath>
		<value>
			<thingClass>CombatExtended.BulletCE</thingClass>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[
			defName="AA_Bullet_Rock" or
			defName="AA_IncendiaryMote" or
			defName="AA_FrostBolt"
			]/thingClass 
		</xpath>
		<value>
			<thingClass>CombatExtended.ProjectileCE_Explosive</thingClass>
		</value>
	</Operation>

	<!-- ============== Adding 'Standard' AimingAccuracy node to creatures' that use ranged attack statBases. =============== -->
	<Operation Class="PatchOperationAdd">
		<xpath>Defs/ThingDef[
			defName="AA_Barbslinger" or
			defName="AA_Blizzarisk" or
			defName="AA_BlizzariskClutchMother" or
			defName="AA_Cinderlisk" or
			defName="AA_CrystallineCaracal" or
			defName="AA_Dunealisk" or
			defName="AA_DunealiskClutchMother" or
			defName="AA_Darkbeast" or
			defName="AA_Feralisk" or
			defName="AA_FeraliskClutchMother" or
			defName="AA_GreenGoo" or
			defName="AA_InfectedAerofleet" or
			defName="AA_Junglelisk" or
			defName="AA_Mantrap" or
			defName="AA_NightAve" or
			defName="AA_Nightling" or
			defName="AA_OcularJelly" or
			defName="AA_Plasmorph" or
			defName="AA_RedGoo" or
			defName="AA_RedSpore" or
			defName="AA_TetraSlug" or
			defName="AA_Thermadon" or
			defName="AA_Erin" or
			defName="AA_Thunderbeast" or
			defName="AA_WindBeast" or
			defName="AA_FrostLynx"
			]/statBases
		</xpath>
		<value>
			<AimingAccuracy>0.7</AimingAccuracy>
		</value>
	</Operation>

	<!-- Different accuracy for spammy stuff -->
	<Operation Class="PatchOperationAdd">
		<xpath>Defs/ThingDef[defName="AA_Needlepost" or defName="AA_Needleroll"]/statBases</xpath>
		<value>
			<AimingAccuracy>0.3</AimingAccuracy>
		</value>
	</Operation>

	<!-- Different accuracy for Gallatross since his Projectile isn't directly under his control (it's just a random boulder he picks off the ground with his psionic abilities) -->
	<Operation Class="PatchOperationAdd">
		<xpath>Defs/ThingDef[defName="AA_Gallatross"]/statBases</xpath>
		<value>
			<AimingAccuracy>0.6</AimingAccuracy>
		</value>
	</Operation>

	<!-- =============== Now defining Projectiles in CE Procedure ============= -->
	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="AA_Bullet_Barb"]/projectile</xpath>
		<value>
			<projectile Class="CombatExtended.ProjectilePropertiesCE">
				<flyOverhead>false</flyOverhead>
				<damageDef>AA_ToxicBolt</damageDef>
				<damageAmountBase>7</damageAmountBase>
				<speed>31</speed>
				<armorPenetrationSharp>1.5</armorPenetrationSharp>
				<armorPenetrationBlunt>1.440</armorPenetrationBlunt>
			</projectile>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="AA_PoisonBolt"]/projectile</xpath>
		<value>
			<projectile Class="CombatExtended.ProjectilePropertiesCE">
				<flyOverhead>false</flyOverhead>
				<damageDef>AA_ToxicBolt</damageDef>
				<damageAmountBase>9</damageAmountBase>
				<speed>25</speed>
				<armorPenetrationSharp>2.3</armorPenetrationSharp>
				<armorPenetrationBlunt>1.5</armorPenetrationBlunt>
			</projectile>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="AA_BlackHiveBolt"]/projectile</xpath>
		<value>
			<projectile Class="CombatExtended.ProjectilePropertiesCE">
				<flyOverhead>false</flyOverhead>
				<damageDef>AA_BlackHiveBolt</damageDef>
				<damageAmountBase>10</damageAmountBase>
				<speed>27</speed>
				<armorPenetrationSharp>2.5</armorPenetrationSharp>
				<armorPenetrationBlunt>1.6</armorPenetrationBlunt>
			</projectile>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="AA_RedPoisonBolt"]/projectile</xpath>
		<value>
			<projectile Class="CombatExtended.ProjectilePropertiesCE">
				<flyOverhead>false</flyOverhead>
				<damageDef>AA_ToxicBolt</damageDef>
				<damageAmountBase>6</damageAmountBase>
				<speed>27</speed>
				<armorPenetrationSharp>1.5</armorPenetrationSharp>
				<armorPenetrationBlunt>1.660</armorPenetrationBlunt>
			</projectile>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="AA_Plasma"]/projectile</xpath>
		<value>
			<projectile Class="CombatExtended.ProjectilePropertiesCE">
				<flyOverhead>false</flyOverhead>
				<damageDef>Flame</damageDef>
				<damageAmountBase>25</damageAmountBase>
				<speed>30</speed>
				<armorPenetrationSharp>16</armorPenetrationSharp>
				<armorPenetrationBlunt>14.4</armorPenetrationBlunt>
			</projectile>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="AA_Quill"]/projectile</xpath>
		<value>
			<projectile Class="CombatExtended.ProjectilePropertiesCE">
				<flyOverhead>false</flyOverhead>
				<damageDef>AA_ToxicBolt</damageDef>
				<damageAmountBase>15</damageAmountBase>
				<speed>19</speed>
				<armorPenetrationSharp>1.5</armorPenetrationSharp>
				<armorPenetrationBlunt>3</armorPenetrationBlunt>
			</projectile>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="AA_Bullet_VenomBarb"]/projectile</xpath>
		<value>
			<projectile Class="CombatExtended.ProjectilePropertiesCE">
				<flyOverhead>false</flyOverhead>
				<damageDef>AA_ToxicBolt</damageDef>
				<damageAmountBase>7</damageAmountBase>
				<speed>27</speed>
				<armorPenetrationSharp>1.5</armorPenetrationSharp>
				<armorPenetrationBlunt>1.440</armorPenetrationBlunt>
			</projectile>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="AA_Bullet_Rock"]/projectile</xpath>
		<value>
			<projectile Class="CombatExtended.ProjectilePropertiesCE">
				<explosionRadius>1.5</explosionRadius>
				<suppressionFactor>3.0</suppressionFactor>
				<dangerFactor>2.0</dangerFactor>
				<damageDef>Bomb</damageDef>
				<damageAmountBase>40</damageAmountBase>
				<soundExplode>MortarBomb_Explode</soundExplode>
				<speed>14</speed>
				<armorPenetrationSharp>5</armorPenetrationSharp>
				<armorPenetrationBlunt>25</armorPenetrationBlunt>
				<applyDamageToExplosionCellsNeighbors>true</applyDamageToExplosionCellsNeighbors>
			</projectile>
		</value>
	</Operation>

	<Operation Class="PatchOperationAdd">
		<xpath>Defs/ThingDef[defName="AA_Bullet_Rock"]</xpath>
		<value>
			<comps>
				<li Class="CombatExtended.CompProperties_Fragments">
					<fragments>
						<Fragment_Small>16</Fragment_Small>
						<Fragment_Large>3</Fragment_Large>
					</fragments>
				</li>
			</comps>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="AA_FrostWeb"]/projectile</xpath>
		<value>
			<projectile Class="CombatExtended.ProjectilePropertiesCE">
				<flyOverhead>false</flyOverhead>
				<damageDef>Frostbite</damageDef>
				<damageAmountBase>5</damageAmountBase>
				<speed>15</speed>
				<armorPenetrationBlunt>3</armorPenetrationBlunt>
				<!-- Adding secondary damage with CE's Procedure instead of AA's AnimalProjectile -->
				<secondaryDamage>
					<li>
						<def>Stun</def>
						<amount>8</amount>
						<chance>0.5</chance>
					</li>
				</secondaryDamage>
			</projectile>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="AA_FireWeb"]/projectile</xpath>
		<value>
			<projectile Class="CombatExtended.ProjectilePropertiesCE">
				<flyOverhead>false</flyOverhead>
				<damageDef>Flame</damageDef>
				<damageAmountBase>3</damageAmountBase>
				<speed>15</speed>
				<armorPenetrationBlunt>3</armorPenetrationBlunt>
				<!-- Adding secondary damage with CE's Procedure instead of AA's AnimalProjectile -->
				<secondaryDamage>
					<li>
						<def>Stun</def>
						<amount>8</amount>
						<chance>0.5</chance>
					</li>
				</secondaryDamage>
			</projectile>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="AA_AcidicWeb"]/projectile</xpath>
		<value>
			<projectile Class="CombatExtended.ProjectilePropertiesCE">
				<flyOverhead>false</flyOverhead>
				<damageDef>AA_AcidSpit</damageDef>
				<damageAmountBase>5</damageAmountBase>
				<speed>15</speed>
				<armorPenetrationBlunt>3</armorPenetrationBlunt>
				<!-- Adding secondary damage with CE's Procedure instead of AA's AnimalProjectile -->
				<secondaryDamage>
					<li>
						<def>Stun</def>
						<amount>8</amount>
						<chance>0.5</chance>
					</li>
				</secondaryDamage>
			</projectile>
		</value>
	</Operation>

	<!-- ======== Note: AA_ExplodingWeb wasn't used in any Race, so it wasn't included. If it gets added, just add a secondaryDamage to the corresponding projectile, with the Bomb damageDef ======== -->
	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="AA_Web"]/projectile</xpath>
		<value>
			<projectile Class="CombatExtended.ProjectilePropertiesCE">
				<flyOverhead>false</flyOverhead>
				<damageDef>Stun</damageDef>
				<damageAmountBase>15</damageAmountBase>
				<speed>15</speed>
				<armorPenetrationBlunt>0.25</armorPenetrationBlunt>
			</projectile>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="AA_IncendiaryMote"]/projectile</xpath>
		<value>
			<projectile Class="CombatExtended.ProjectilePropertiesCE">
				<speed>20</speed>
				<damageDef>Flame</damageDef>
				<damageAmountBase>8</damageAmountBase>
				<explosionRadius>1.1</explosionRadius>
				<suppressionFactor>3.0</suppressionFactor>
				<dangerFactor>2.0</dangerFactor>
				<preExplosionSpawnThingDef>Filth_Fuel</preExplosionSpawnThingDef>
				<preExplosionSpawnChance>0.6</preExplosionSpawnChance>
				<ai_IsIncendiary>true</ai_IsIncendiary>
				<soundExplode>Interact_Ignite</soundExplode>
			</projectile>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="AA_FireSpit"]/projectile</xpath>
		<value>
			<projectile Class="CombatExtended.ProjectilePropertiesCE">
				<flyOverhead>false</flyOverhead>
				<damageDef>Flame</damageDef>
				<damageAmountBase>4</damageAmountBase>
				<speed>15</speed>
				<ai_IsIncendiary>true</ai_IsIncendiary>
			</projectile>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="AA_AcidBolt"]/projectile</xpath>
		<value>
			<projectile Class="CombatExtended.ProjectilePropertiesCE">
				<flyOverhead>false</flyOverhead>
				<damageDef>AA_AcidSpit</damageDef>
				<damageAmountBase>5</damageAmountBase>
				<speed>36</speed>
				<armorPenetrationSharp>7</armorPenetrationSharp>
			</projectile>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="AA_DarkBolt"]/projectile</xpath>
		<value>
			<projectile Class="CombatExtended.ProjectilePropertiesCE">
				<flyOverhead>false</flyOverhead>
				<damageDef>Flame</damageDef>
				<damageAmountBase>10</damageAmountBase>
				<speed>36</speed>
			</projectile>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="AA_ElectricBolt"]/projectile</xpath>
		<value>
			<projectile Class="CombatExtended.ProjectilePropertiesCE">
				<flyOverhead>false</flyOverhead>
				<damageDef>AA_Electric</damageDef>
				<damageAmountBase>12</damageAmountBase>
				<speed>50</speed>
			</projectile>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="AA_WindBolt"]/projectile</xpath>
		<value>
			<projectile Class="CombatExtended.ProjectilePropertiesCE">
				<flyOverhead>false</flyOverhead>
				<damageDef>Blunt</damageDef>
				<damageAmountBase>18</damageAmountBase>
				<speed>35</speed>
			</projectile>
		</value>
	</Operation>

	<!-- Windbolt uses an unsupported graphics class. -->
	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="AA_WindBolt"]/graphicData</xpath>
		<value>
			<graphicData>
				<texPath>Things/Pawn/Animal/AA_ArcticLion/AA_ArcticLion_Invisible</texPath>
				<graphicClass>Graphic_Single</graphicClass>
			</graphicData>
		</value>
	</Operation>

	<Operation Class="PatchOperationReplace">
		<xpath>Defs/ThingDef[defName="AA_FrostBolt"]/projectile</xpath>
		<value>
			<projectile Class="CombatExtended.ProjectilePropertiesCE">
				<explosionDelay>1</explosionDelay>
				<airborneSuppressionFactor>0.25</airborneSuppressionFactor>
				<explosionRadius>2.9</explosionRadius>
				<suppressionFactor>3.0</suppressionFactor>
				<dangerFactor>2.0</dangerFactor>
				<damageDef>AA_FrostBomb</damageDef>
				<damageAmountBase>14</damageAmountBase>
				<postExplosionSpawnThingDef>AA_FrostPuff</postExplosionSpawnThingDef>
				<postExplosionSpawnThingCount>1</postExplosionSpawnThingCount>
				<postExplosionSpawnChance>1</postExplosionSpawnChance>
				<speed>28</speed>
			</projectile>
		</value>
	</Operation>

</Patch>