############################################################
##               ESC : Crystalline Weapons                ##
############################################################

# - Crystal Shard Thrower 				S/M/L
# - Improved Crystal Shard Thrower		S/M/L
# - Crystal Spike Thrower				S/M/L
# - Improved Crystal Spike Thrower		S/M/L
# - Crystal Spear Cannon				S/M/L
# - Crystal Javelin Cannon				X
# - Crystal Lance Cannon				X
# - Crystalline Impaler					Titanic

@ESC_WEAPON_crystalline_hull_damage = 1.0
@ESC_WEAPON_crystalline_lance_hull_damage = 1.25
@ESC_WEAPON_crystalline_armor_damage = 1.0
@ESC_WEAPON_crystalline_armor_penetration = 0.0
@ESC_WEAPON_crystalline_shields_damage = 1.0
@ESC_WEAPON_crystalline_shields_penetration = 0.0

############################################################
##                 Crystal Shard Thrower                  ##
############################################################

# small
weapon_component_template = {
	key = SMALL_ESC_CRYSTAL_CANNON_1
	size = small
	icon = GFX_esc_crystal_cannon_1
	icon_frame = 1
	type = instant

	damage = { min = 8 max = 20 }
	windup = { min = 4 max = 14 }
	total_fire_time = 20
	range = @ESC_WEAPON_RANGE_S_3
	accuracy = 0.85
	power = -7

	inline_script = {
		script = component_costs/shorthands/esc_inlines_crystalline_cost
		COMPONENT_TYPE = WEAPON
		SIZE = s
		TIER = 3
	}

	hull_damage = @ESC_WEAPON_crystalline_hull_damage
	armor_penetration = @ESC_WEAPON_crystalline_armor_penetration
	armor_damage = @ESC_WEAPON_crystalline_armor_damage
	shield_penetration = @ESC_WEAPON_crystalline_shields_penetration
	shield_damage = @ESC_WEAPON_crystalline_shields_damage
	tracking = 0.5

	prerequisites = { "esc_tech_crystal_cannon_1" }
	component_set = ESC_CRYSTAL_CANNON_1
	projectile_gfx = red_crystal_ship_projectile
	tags = { weapon_type_kinetic s_slot }
	ai_tags = { weapon_role_anti_shield brawler gunship }
	upgrades_to = SMALL_ESC_CRYSTAL_CANNON_2

	inline_script = {
		script = weapon_effects/esc_critical_hit
		CRITICAL_HIT_CHANCE = 20
		NORMAL_HIT_CHANCE = 80
		CRITICAL_DAMAGE_AMOUNT = 14 # (min damage + max damage) / 2
	}

	# only regular empires and xenophile FE should use this component
	valid_for_country = {
		ESC_TRIGGER_is_normal_empire_or_xenophile_fe = yes
	}

	ai_weight = {
		weight = 1
		### AI shouldn't use this component if it can't afford at least some upgrades right away
		modifier = {
			factor = 0.0
			no_resource_for_component = { RESOURCE = rare_crystals }
		}
	}
}

# medium
weapon_component_template = {
	key = MEDIUM_ESC_CRYSTAL_CANNON_1
	size = medium
	icon = GFX_esc_crystal_cannon_1
	icon_frame = 1
	type = instant

	damage = { min = 20 max = 50 }
	windup = { min = 5 max = 17 }
	total_fire_time = 25
	range = @ESC_WEAPON_RANGE_M_3
	accuracy = 0.85
	power = -13

	inline_script = {
		script = component_costs/shorthands/esc_inlines_crystalline_cost
		COMPONENT_TYPE = WEAPON
		SIZE = m
		TIER = 3
	}

	hull_damage = @ESC_WEAPON_crystalline_hull_damage
	armor_penetration = @ESC_WEAPON_crystalline_armor_penetration
	armor_damage = @ESC_WEAPON_crystalline_armor_damage
	shield_penetration = @ESC_WEAPON_crystalline_shields_penetration
	shield_damage = @ESC_WEAPON_crystalline_shields_damage
	tracking = 0.25

	prerequisites = { "esc_tech_crystal_cannon_1" }
	component_set = ESC_CRYSTAL_CANNON_1
	projectile_gfx = "red_crystal_ship_projectile"
	tags = { weapon_type_kinetic m_slot }
	ai_tags = { weapon_role_anti_shield brawler gunship }
	upgrades_to = MEDIUM_ESC_CRYSTAL_CANNON_2

	inline_script = {
		script = weapon_effects/esc_critical_hit
		CRITICAL_HIT_CHANCE = 20
		NORMAL_HIT_CHANCE = 80
		CRITICAL_DAMAGE_AMOUNT = 35 # (min damage + max damage) / 2
	}

	# only regular empires and xenophile FE should use this component
	valid_for_country = {
		ESC_TRIGGER_is_normal_empire_or_xenophile_fe = yes
	}

	ai_weight = {
		weight = 1
		### AI shouldn't use this component if it can't afford at least some upgrades right away
		modifier = {
			factor = 0.0
			no_resource_for_component = { RESOURCE = rare_crystals }
		}
	}
}

# large
weapon_component_template = {
	key = LARGE_ESC_CRYSTAL_CANNON_1
	size = large
	icon = GFX_esc_crystal_cannon_1
	icon_frame = 1
	type = instant

	damage = { min = 50 max = 120 }
	windup = { min = 5 max = 20 }
	total_fire_time = 30
	range = @ESC_WEAPON_RANGE_L_3
	min_range = @ESC_WEAPON_MIN_RANGE_4
	accuracy = 0.85
	power = -25

	inline_script = {
		script = component_costs/shorthands/esc_inlines_crystalline_cost
		COMPONENT_TYPE = WEAPON
		SIZE = l
		TIER = 3
	}

	hull_damage = @ESC_WEAPON_crystalline_hull_damage
	armor_penetration = @ESC_WEAPON_crystalline_armor_penetration
	armor_damage = @ESC_WEAPON_crystalline_armor_damage
	shield_penetration = @ESC_WEAPON_crystalline_shields_penetration
	shield_damage = @ESC_WEAPON_crystalline_shields_damage
	tracking = 0.1

	prerequisites = { "esc_tech_crystal_cannon_1" }
	component_set = ESC_CRYSTAL_CANNON_1
	projectile_gfx = "red_crystal_ship_projectile"
	tags = { weapon_type_kinetic l_slot }
	ai_tags = { weapon_role_anti_shield artillery }
	upgrades_to = LARGE_ESC_CRYSTAL_CANNON_2

	inline_script = {
		script = weapon_effects/esc_critical_hit
		CRITICAL_HIT_CHANCE = 20
		NORMAL_HIT_CHANCE = 80
		CRITICAL_DAMAGE_AMOUNT = 85 # (min damage + max damage) / 2
	}

	# only regular empires and xenophile FE should use this component
	valid_for_country = {
		ESC_TRIGGER_is_normal_empire_or_xenophile_fe = yes
	}

	ai_weight = {
		weight = 1
		### AI shouldn't use this component if it can't afford at least some upgrades right away
		modifier = {
			factor = 0.0
			no_resource_for_component = { RESOURCE = rare_crystals }
		}
	}
}

############################################################
##             Improved Crystal Shard Thrower             ##
############################################################

# small
weapon_component_template = {
	key = SMALL_ESC_CRYSTAL_CANNON_2
	size = small
	icon = GFX_esc_crystal_cannon_2
	icon_frame = 1
	type = instant

	damage = { min = 10 max = 32 }
	windup = { min = 4 max = 14 }
	total_fire_time = 20
	range = @ESC_WEAPON_RANGE_S_3
	accuracy = 0.85
	power = -11

	inline_script = {
		script = component_costs/shorthands/esc_inlines_crystalline_cost
		COMPONENT_TYPE = WEAPON
		SIZE = s
		TIER = 4
	}

	hull_damage = @ESC_WEAPON_crystalline_hull_damage
	armor_penetration = @ESC_WEAPON_crystalline_armor_penetration
	armor_damage = @ESC_WEAPON_crystalline_armor_damage
	shield_penetration = @ESC_WEAPON_crystalline_shields_penetration
	shield_damage = @ESC_WEAPON_crystalline_shields_damage
	tracking = 0.5

	prerequisites = { "esc_tech_crystal_cannon_2" }
	component_set = ESC_CRYSTAL_CANNON_2
	projectile_gfx = "red_crystal_ship_projectile"
	tags = { weapon_type_kinetic s_slot }
	ai_tags = { weapon_role_anti_shield brawler gunship }
	upgrades_to = SMALL_ESC_CRYSTAL_CANNON_3

	inline_script = {
		script = weapon_effects/esc_critical_hit
		CRITICAL_HIT_CHANCE = 20
		NORMAL_HIT_CHANCE = 80
		CRITICAL_DAMAGE_AMOUNT = 21 # (min damage + max damage) / 2
	}

	# only regular empires and xenophile FE should use this component
	valid_for_country = {
		ESC_TRIGGER_is_normal_empire_or_xenophile_fe = yes
	}

	ai_weight = {
		weight = 1
		### AI shouldn't use this component if it can't afford at least some upgrades right away
		modifier = {
			factor = 0.0
			no_resource_for_component = { RESOURCE = rare_crystals }
		}
	}
}

# medium
weapon_component_template = {
	key = MEDIUM_ESC_CRYSTAL_CANNON_2
	size = medium
	icon = GFX_esc_crystal_cannon_2
	icon_frame = 1
	type = instant

	damage = { min = 27 max = 78 }
	windup = { min = 5 max = 17 }
	total_fire_time = 25
	range = @ESC_WEAPON_RANGE_M_3
	accuracy = 0.85
	power = -20

	inline_script = {
		script = component_costs/shorthands/esc_inlines_crystalline_cost
		COMPONENT_TYPE = WEAPON
		SIZE = m
		TIER = 4
	}

	hull_damage = @ESC_WEAPON_crystalline_hull_damage
	armor_penetration = @ESC_WEAPON_crystalline_armor_penetration
	armor_damage = @ESC_WEAPON_crystalline_armor_damage
	shield_penetration = @ESC_WEAPON_crystalline_shields_penetration
	shield_damage = @ESC_WEAPON_crystalline_shields_damage
	tracking = 0.25

	prerequisites = { "esc_tech_crystal_cannon_2" }
	component_set = ESC_CRYSTAL_CANNON_2
	projectile_gfx = "red_crystal_ship_projectile"
	tags = { weapon_type_kinetic m_slot }
	ai_tags = { weapon_role_anti_shield brawler gunship }
	upgrades_to = MEDIUM_ESC_CRYSTAL_CANNON_3

	inline_script = {
		script = weapon_effects/esc_critical_hit
		CRITICAL_HIT_CHANCE = 20
		NORMAL_HIT_CHANCE = 80
		CRITICAL_DAMAGE_AMOUNT = 52 # (min damage + max damage) / 2
	}

	# only regular empires and xenophile FE should use this component
	valid_for_country = {
		ESC_TRIGGER_is_normal_empire_or_xenophile_fe = yes
	}

	ai_weight = {
		weight = 1
		### AI shouldn't use this component if it can't afford at least some upgrades right away
		modifier = {
			factor = 0.0
			no_resource_for_component = { RESOURCE = rare_crystals }
		}
	}
}

# large
weapon_component_template = {
	key = LARGE_ESC_CRYSTAL_CANNON_2
	size = large
	icon = GFX_esc_crystal_cannon_2
	icon_frame = 1
	type = instant

	damage = { min = 58 max = 190 }
	windup = { min = 5 max = 20 }
	total_fire_time = 30
	range = @ESC_WEAPON_RANGE_L_3
	min_range = @ESC_WEAPON_MIN_RANGE_4
	accuracy = 0.85
	power = -40

	inline_script = {
		script = component_costs/shorthands/esc_inlines_crystalline_cost
		COMPONENT_TYPE = WEAPON
		SIZE = l
		TIER = 4
	}

	hull_damage = @ESC_WEAPON_crystalline_hull_damage
	armor_penetration = @ESC_WEAPON_crystalline_armor_penetration
	armor_damage = @ESC_WEAPON_crystalline_armor_damage
	shield_penetration = @ESC_WEAPON_crystalline_shields_penetration
	shield_damage = @ESC_WEAPON_crystalline_shields_damage
	tracking = 0.1

	prerequisites = { "esc_tech_crystal_cannon_2" }
	component_set = ESC_CRYSTAL_CANNON_2
	projectile_gfx = "red_crystal_ship_projectile"
	tags = { weapon_type_kinetic l_slot }
	ai_tags = { weapon_role_anti_shield artillery }
	upgrades_to = LARGE_ESC_CRYSTAL_CANNON_3

	inline_script = {
		script = weapon_effects/esc_critical_hit
		CRITICAL_HIT_CHANCE = 20
		NORMAL_HIT_CHANCE = 80
		CRITICAL_DAMAGE_AMOUNT = 124 # (min damage + max damage) / 2
	}

	# only regular empires and xenophile FE should use this component
	valid_for_country = {
		ESC_TRIGGER_is_normal_empire_or_xenophile_fe = yes
	}

	ai_weight = {
		weight = 1
		### AI shouldn't use this component if it can't afford at least some upgrades right away
		modifier = {
			factor = 0.0
			no_resource_for_component = { RESOURCE = rare_crystals }
		}
	}
}

############################################################
##                  Crystal Spike Thrower                 ##
############################################################

# small
weapon_component_template = {
	key = SMALL_ESC_CRYSTAL_CANNON_3
	size = small
	icon = GFX_esc_crystal_cannon_3
	icon_frame = 1
	type = instant

	damage = { min = 14 max = 44 }
	windup = { min = 4 max = 14 }
	total_fire_time = 20
	range = @ESC_WEAPON_RANGE_S_3
	accuracy = 0.85
	power = -17

	inline_script = {
		script = component_costs/shorthands/esc_inlines_crystalline_cost
		COMPONENT_TYPE = WEAPON
		SIZE = s
		TIER = 5
	}

	hull_damage = @ESC_WEAPON_crystalline_hull_damage
	armor_penetration = @ESC_WEAPON_crystalline_armor_penetration
	armor_damage = @ESC_WEAPON_crystalline_armor_damage
	shield_penetration = @ESC_WEAPON_crystalline_shields_penetration
	shield_damage = @ESC_WEAPON_crystalline_shields_damage
	tracking = 0.5

	prerequisites = { "esc_tech_crystal_cannon_3" }
	component_set = ESC_CRYSTAL_CANNON_3
	projectile_gfx = "crystal_ship_projectile"
	tags = { weapon_type_kinetic s_slot }
	ai_tags = { weapon_role_anti_shield brawler gunship }
	upgrades_to = SMALL_ESC_CRYSTAL_CANNON_4

	inline_script = {
		script = weapon_effects/esc_critical_hit
		CRITICAL_HIT_CHANCE = 20
		NORMAL_HIT_CHANCE = 80
		CRITICAL_DAMAGE_AMOUNT = 29 # (min damage + max damage) / 2
	}

	# only regular empires and xenophile FE should use this component
	valid_for_country = {
		ESC_TRIGGER_is_normal_empire_or_xenophile_fe = yes
	}

	ai_weight = {
		weight = 1
		### AI shouldn't use this component if it can't afford at least some upgrades right away
		modifier = {
			factor = 0.0
			no_resource_for_component = { RESOURCE = rare_crystals }
		}
	}
}

# medium
weapon_component_template = {
	key = MEDIUM_ESC_CRYSTAL_CANNON_3
	size = medium
	icon = GFX_esc_crystal_cannon_3
	icon_frame = 1
	type = instant

	damage = { min = 42 max = 86 }
	windup = { min = 5 max = 17 }
	total_fire_time = 25
	range = @ESC_WEAPON_RANGE_M_3
	accuracy = 0.85
	power = -30

	inline_script = {
		script = component_costs/shorthands/esc_inlines_crystalline_cost
		COMPONENT_TYPE = WEAPON
		SIZE = m
		TIER = 5
	}

	hull_damage = @ESC_WEAPON_crystalline_hull_damage
	armor_penetration = @ESC_WEAPON_crystalline_armor_penetration
	armor_damage = @ESC_WEAPON_crystalline_armor_damage
	shield_penetration = @ESC_WEAPON_crystalline_shields_penetration
	shield_damage = @ESC_WEAPON_crystalline_shields_damage
	tracking = 0.25

	prerequisites = { "esc_tech_crystal_cannon_3" }
	component_set = ESC_CRYSTAL_CANNON_3
	projectile_gfx = "crystal_ship_projectile"
	tags = { weapon_type_kinetic m_slot }
	ai_tags = { weapon_role_anti_shield brawler gunship }
	upgrades_to = MEDIUM_ESC_CRYSTAL_CANNON_4

	inline_script = {
		script = weapon_effects/esc_critical_hit
		CRITICAL_HIT_CHANCE = 20
		NORMAL_HIT_CHANCE = 80
		CRITICAL_DAMAGE_AMOUNT = 64 # (min damage + max damage) / 2
	}

	# only regular empires and xenophile FE should use this component
	valid_for_country = {
		ESC_TRIGGER_is_normal_empire_or_xenophile_fe = yes
	}

	ai_weight = {
		weight = 1
		### AI shouldn't use this component if it can't afford at least some upgrades right away
		modifier = {
			factor = 0.0
			no_resource_for_component = { RESOURCE = rare_crystals }
		}
	}
}

# large
weapon_component_template = {
	key = LARGE_ESC_CRYSTAL_CANNON_3
	size = large
	icon = GFX_esc_crystal_cannon_3
	icon_frame = 1
	type = instant

	damage = { min = 88 max = 220 }
	windup = { min = 5 max = 20 }
	total_fire_time = 30
	range = @ESC_WEAPON_RANGE_L_3
	min_range = @ESC_WEAPON_MIN_RANGE_4
	accuracy = 0.85
	power = -58

	inline_script = {
		script = component_costs/shorthands/esc_inlines_crystalline_cost
		COMPONENT_TYPE = WEAPON
		SIZE = l
		TIER = 5
	}

	hull_damage = @ESC_WEAPON_crystalline_hull_damage
	armor_penetration = @ESC_WEAPON_crystalline_armor_penetration
	armor_damage = @ESC_WEAPON_crystalline_armor_damage
	shield_penetration = @ESC_WEAPON_crystalline_shields_penetration
	shield_damage = @ESC_WEAPON_crystalline_shields_damage
	tracking = 0.1

	prerequisites = { "esc_tech_crystal_cannon_3" }
	component_set = ESC_CRYSTAL_CANNON_3
	projectile_gfx = "crystal_ship_projectile"
	tags = { weapon_type_kinetic l_slot }
	ai_tags = { weapon_role_anti_shield artillery }
	upgrades_to = LARGE_ESC_CRYSTAL_CANNON_4

	inline_script = {
		script = weapon_effects/esc_critical_hit
		CRITICAL_HIT_CHANCE = 20
		NORMAL_HIT_CHANCE = 80
		CRITICAL_DAMAGE_AMOUNT = 154 # (min damage + max damage) / 2
	}

	# only regular empires and xenophile FE should use this component
	valid_for_country = {
		ESC_TRIGGER_is_normal_empire_or_xenophile_fe = yes
	}

	ai_weight = {
		weight = 1
		### AI shouldn't use this component if it can't afford at least some upgrades right away
		modifier = {
			factor = 0.0
			no_resource_for_component = { RESOURCE = rare_crystals }
		}
	}
}

############################################################
##             Improved Crystal Spike Thrower             ##
############################################################

# small
weapon_component_template = {
	key = SMALL_ESC_CRYSTAL_CANNON_4
	size = small
	icon = GFX_esc_crystal_cannon_4
	icon_frame = 1
	type = instant

	damage = { min = 18 max = 47 }
	windup = { min = 4 max = 14 }
	total_fire_time = 20
	range = @ESC_WEAPON_RANGE_S_3
	accuracy = 0.85
	power = -20

	inline_script = {
		script = component_costs/shorthands/esc_inlines_crystalline_cost
		COMPONENT_TYPE = WEAPON
		SIZE = s
		TIER = 6
	}

	hull_damage = @ESC_WEAPON_crystalline_hull_damage
	armor_penetration = @ESC_WEAPON_crystalline_armor_penetration
	armor_damage = @ESC_WEAPON_crystalline_armor_damage
	shield_penetration = @ESC_WEAPON_crystalline_shields_penetration
	shield_damage = @ESC_WEAPON_crystalline_shields_damage
	tracking = 0.5

	prerequisites = { "esc_tech_crystal_cannon_4" }
	component_set = ESC_CRYSTAL_CANNON_4
	projectile_gfx = "crystal_ship_projectile"
	tags = { weapon_type_kinetic s_slot }
	ai_tags = { weapon_role_anti_shield brawler gunship }
	upgrades_to = SMALL_ESC_CRYSTAL_CANNON_5

	inline_script = {
		script = weapon_effects/esc_critical_hit
		CRITICAL_HIT_CHANCE = 20
		NORMAL_HIT_CHANCE = 80
		CRITICAL_DAMAGE_AMOUNT = 32 # (min damage + max damage) / 2
	}

	# only regular empires and xenophile FE should use this component
	valid_for_country = {
		ESC_TRIGGER_is_normal_empire_or_xenophile_fe = yes
	}

	ai_weight = {
		weight = 1
		### AI shouldn't use this component if it can't afford at least some upgrades right away
		modifier = {
			factor = 0.0
			no_resource_for_component = { RESOURCE = rare_crystals }
		}
	}
}

# medium
weapon_component_template = {
	key = MEDIUM_ESC_CRYSTAL_CANNON_4
	size = medium
	icon = GFX_esc_crystal_cannon_4
	icon_frame = 1
	type = instant

	damage = { min = 52 max = 108 }
	windup = { min = 5 max = 17 }
	total_fire_time = 25
	range = @ESC_WEAPON_RANGE_M_3
	accuracy = 0.85
	power = -34

	inline_script = {
		script = component_costs/shorthands/esc_inlines_crystalline_cost
		COMPONENT_TYPE = WEAPON
		SIZE = m
		TIER = 6
	}

	hull_damage = @ESC_WEAPON_crystalline_hull_damage
	armor_penetration = @ESC_WEAPON_crystalline_armor_penetration
	armor_damage = @ESC_WEAPON_crystalline_armor_damage
	shield_penetration = @ESC_WEAPON_crystalline_shields_penetration
	shield_damage = @ESC_WEAPON_crystalline_shields_damage
	tracking = 0.25

	prerequisites = { "esc_tech_crystal_cannon_4" }
	component_set = ESC_CRYSTAL_CANNON_4
	projectile_gfx = "crystal_ship_projectile"
	tags = { weapon_type_kinetic m_slot }
	ai_tags = { weapon_role_anti_shield brawler gunship }
	upgrades_to = MEDIUM_ESC_CRYSTAL_CANNON_5

	inline_script = {
		script = weapon_effects/esc_critical_hit
		CRITICAL_HIT_CHANCE = 20
		NORMAL_HIT_CHANCE = 80
		CRITICAL_DAMAGE_AMOUNT = 80 # (min damage + max damage) / 2
	}

	# only regular empires and xenophile FE should use this component
	valid_for_country = {
		ESC_TRIGGER_is_normal_empire_or_xenophile_fe = yes
	}

	ai_weight = {
		weight = 1
		### AI shouldn't use this component if it can't afford at least some upgrades right away
		modifier = {
			factor = 0.0
			no_resource_for_component = { RESOURCE = rare_crystals }
		}
	}
}

# large
weapon_component_template = {
	key = LARGE_ESC_CRYSTAL_CANNON_4
	size = large
	icon = GFX_esc_crystal_cannon_4
	icon_frame = 1
	type = instant

	damage = { min = 118 max = 238 }
	windup = { min = 5 max = 20 }
	total_fire_time = 30
	range = @ESC_WEAPON_RANGE_L_3
	min_range = @ESC_WEAPON_MIN_RANGE_4
	accuracy = 0.85
	power = -64

	inline_script = {
		script = component_costs/shorthands/esc_inlines_crystalline_cost
		COMPONENT_TYPE = WEAPON
		SIZE = l
		TIER = 6
	}

	hull_damage = @ESC_WEAPON_crystalline_hull_damage
	armor_penetration = @ESC_WEAPON_crystalline_armor_penetration
	armor_damage = @ESC_WEAPON_crystalline_armor_damage
	shield_penetration = @ESC_WEAPON_crystalline_shields_penetration
	shield_damage = @ESC_WEAPON_crystalline_shields_damage
	tracking = 0.1

	prerequisites = { "esc_tech_crystal_cannon_4" }
	component_set = ESC_CRYSTAL_CANNON_4
	projectile_gfx = "crystal_ship_projectile"
	tags = { weapon_type_kinetic l_slot }
	ai_tags = { weapon_role_anti_shield artillery }
	upgrades_to = LARGE_ESC_CRYSTAL_CANNON_5

	inline_script = {
		script = weapon_effects/esc_critical_hit
		CRITICAL_HIT_CHANCE = 20
		NORMAL_HIT_CHANCE = 80
		CRITICAL_DAMAGE_AMOUNT = 178 # (min damage + max damage) / 2
	}

	# only regular empires and xenophile FE should use this component
	valid_for_country = {
		ESC_TRIGGER_is_normal_empire_or_xenophile_fe = yes
	}

	ai_weight = {
		weight = 1
		### AI shouldn't use this component if it can't afford at least some upgrades right away
		modifier = {
			factor = 0.0
			no_resource_for_component = { RESOURCE = rare_crystals }
		}
	}
}

############################################################
##                  Crystal Spear Cannon                  ##
############################################################

# small
weapon_component_template = {
	key = SMALL_ESC_CRYSTAL_CANNON_5
	size = small
	icon = GFX_esc_crystal_cannon_5
	icon_frame = 1
	type = instant

	damage = { min = 22 max = 58 }
	windup = { min = 4 max = 14 }
	total_fire_time = 20
	range = @ESC_WEAPON_RANGE_S_3
	accuracy = 0.85
	power = -24

	inline_script = {
		script = component_costs/shorthands/esc_inlines_crystalline_cost
		COMPONENT_TYPE = WEAPON
		SIZE = s
		TIER = 7
	}

	hull_damage = @ESC_WEAPON_crystalline_hull_damage
	armor_penetration = @ESC_WEAPON_crystalline_armor_penetration
	armor_damage = @ESC_WEAPON_crystalline_armor_damage
	shield_penetration = @ESC_WEAPON_crystalline_shields_penetration
	shield_damage = @ESC_WEAPON_crystalline_shields_damage
	tracking = 0.5

	prerequisites = { "esc_tech_crystal_cannon_5" }
	component_set = ESC_CRYSTAL_CANNON_5
	projectile_gfx = "green_crystal_ship_projectile"
	tags = { weapon_type_kinetic s_slot }
	ai_tags = { weapon_role_anti_shield brawler gunship }

	inline_script = {
		script = weapon_effects/esc_critical_hit
		CRITICAL_HIT_CHANCE = 20
		NORMAL_HIT_CHANCE = 80
		CRITICAL_DAMAGE_AMOUNT = 40 # (min damage + max damage) / 2
	}

	# only regular empires and xenophile FE should use this component
	valid_for_country = {
		ESC_TRIGGER_is_normal_empire_or_xenophile_fe = yes
	}

	ai_weight = {
		weight = 1
		### AI shouldn't use this component if it can't afford at least some upgrades right away
		modifier = {
			factor = 0.0
			no_resource_for_component = { RESOURCE = rare_crystals }
		}
	}
}

# medium
weapon_component_template = {
	key = MEDIUM_ESC_CRYSTAL_CANNON_5
	size = medium
	icon = GFX_esc_crystal_cannon_5
	icon_frame = 1
	type = instant

	damage = { min = 72 max = 162 }
	windup = { min = 5 max = 17 }
	total_fire_time = 25
	range = @ESC_WEAPON_RANGE_M_3
	accuracy = 0.85
	power = -46

	inline_script = {
		script = component_costs/shorthands/esc_inlines_crystalline_cost
		COMPONENT_TYPE = WEAPON
		SIZE = m
		TIER = 7
	}

	hull_damage = @ESC_WEAPON_crystalline_hull_damage
	armor_penetration = @ESC_WEAPON_crystalline_armor_penetration
	armor_damage = @ESC_WEAPON_crystalline_armor_damage
	shield_penetration = @ESC_WEAPON_crystalline_shields_penetration
	shield_damage = @ESC_WEAPON_crystalline_shields_damage
	tracking = 0.25

	prerequisites = { "esc_tech_crystal_cannon_5" }
	component_set = ESC_CRYSTAL_CANNON_5
	projectile_gfx = "green_crystal_ship_projectile"
	tags = { weapon_type_kinetic m_slot }
	ai_tags = { weapon_role_anti_shield brawler gunship }

	inline_script = {
		script = weapon_effects/esc_critical_hit
		CRITICAL_HIT_CHANCE = 20
		NORMAL_HIT_CHANCE = 80
		CRITICAL_DAMAGE_AMOUNT = 117 # (min damage + max damage) / 2
	}

	# only regular empires and xenophile FE should use this component
	valid_for_country = {
		ESC_TRIGGER_is_normal_empire_or_xenophile_fe = yes
	}

	ai_weight = {
		weight = 1
		### AI shouldn't use this component if it can't afford at least some upgrades right away
		modifier = {
			factor = 0.0
			no_resource_for_component = { RESOURCE = rare_crystals }
		}
	}
}

# large
weapon_component_template = {
	key = LARGE_ESC_CRYSTAL_CANNON_5
	size = large
	icon = GFX_esc_crystal_cannon_5
	icon_frame = 1
	type = instant

	damage = { min = 154 max = 326 }
	windup = { min = 5 max = 20 }
	total_fire_time = 30
	range = @ESC_WEAPON_RANGE_L_3
	min_range = @ESC_WEAPON_MIN_RANGE_4
	accuracy = 0.85
	power = -90

	inline_script = {
		script = component_costs/shorthands/esc_inlines_crystalline_cost
		COMPONENT_TYPE = WEAPON
		SIZE = l
		TIER = 7
	}

	hull_damage = @ESC_WEAPON_crystalline_hull_damage
	armor_penetration = @ESC_WEAPON_crystalline_armor_penetration
	armor_damage = @ESC_WEAPON_crystalline_armor_damage
	shield_penetration = @ESC_WEAPON_crystalline_shields_penetration
	shield_damage = @ESC_WEAPON_crystalline_shields_damage
	tracking = 0.1

	prerequisites = { "esc_tech_crystal_cannon_5" }
	component_set = ESC_CRYSTAL_CANNON_5
	projectile_gfx = "green_crystal_ship_projectile"
	tags = { weapon_type_kinetic l_slot }
	ai_tags = { weapon_role_anti_shield artillery }

	inline_script = {
		script = weapon_effects/esc_critical_hit
		CRITICAL_HIT_CHANCE = 20
		NORMAL_HIT_CHANCE = 80
		CRITICAL_DAMAGE_AMOUNT = 240 # (min damage + max damage) / 2
	}

	# only regular empires and xenophile FE should use this component
	valid_for_country = {
		ESC_TRIGGER_is_normal_empire_or_xenophile_fe = yes
	}

	ai_weight = {
		weight = 1
		### AI shouldn't use this component if it can't afford at least some upgrades right away
		modifier = {
			factor = 0.0
			no_resource_for_component = { RESOURCE = rare_crystals }
		}
	}
}

############################################################
##                 Crystal Javelin Thrower                ##
############################################################

weapon_component_template = {
	key = ESC_CRYSTAL_LANCE_1
	size = extra_large
	icon = GFX_esc_crystal_lance_1
	icon_frame = 1
	type = instant

    damage = { min = 1250 max = 2000 }
	windup = { min = 20 max = 60 }
	total_fire_time = 80
	range = @ESC_WEAPON_RANGE_X_2
	accuracy = 0.85
	power = -175

	inline_script = {
		script = component_costs/shorthands/esc_inlines_crystalline_cost
		COMPONENT_TYPE = WEAPON
		SIZE = xl
		TIER = 6
	}

	hull_damage = @ESC_WEAPON_crystalline_lance_hull_damage
	armor_penetration = @ESC_WEAPON_crystalline_armor_penetration
	armor_damage = @ESC_WEAPON_crystalline_armor_damage
	shield_penetration = @ESC_WEAPON_crystalline_shields_penetration
	shield_damage = @ESC_WEAPON_crystalline_shields_damage
	tracking = 0.1

	firing_arc = 25.0
	min_range = @ESC_WEAPON_MIN_RANGE_2
	#use_ship_kill_target = no

	prerequisites = { "esc_tech_crystal_lance_1" }
	component_set = ESC_CRYSTAL_LANCE_1
	projectile_gfx = "yellow_crystal_ship_projectile"
	upgrades_to = ESC_CRYSTAL_LANCE_2
	tags = { weapon_type_kinetic x_slot weapon_role_artillery }
	ai_tags = { weapon_role_artillery artillery }

	inline_script = {
		script = weapon_effects/esc_critical_hit
		CRITICAL_HIT_CHANCE = 25
		NORMAL_HIT_CHANCE = 75
		CRITICAL_DAMAGE_AMOUNT = 1625 # (min damage + max damage) / 2
	}

	target_weights = {
		titan = 3
		battleship = 2
		stinger_stage_1 = 2
		stinger_stage_2 = 2
		stinger_stage_3 = 2
	}

	# only regular empires and xenophile FE should use this component
	valid_for_country = {
		ESC_TRIGGER_is_normal_empire_or_xenophile_fe = yes
	}

	ai_weight = {
		weight = 1
		### AI shouldn't use this component if it can't afford at least some upgrades right away
		modifier = {
			factor = 0.0
			no_resource_for_component = { RESOURCE = rare_crystals }
		}
	}
}

############################################################
##                 Crystal Javelin Cannon                 ##
############################################################

weapon_component_template = {
	key = ESC_CRYSTAL_LANCE_2
	size = extra_large
	icon = GFX_esc_crystal_lance_2
	icon_frame = 1
	type = instant

    damage = { min = 1750 max = 3000 }
	windup = { min = 20 max = 60 }
	total_fire_time = 80
	range = @ESC_WEAPON_RANGE_X_2
	accuracy = 0.85
	power = -225

	inline_script = {
		script = component_costs/shorthands/esc_inlines_crystalline_cost
		COMPONENT_TYPE = WEAPON
		SIZE = xl
		TIER = 7
	}

	hull_damage = @ESC_WEAPON_crystalline_lance_hull_damage
	armor_penetration = @ESC_WEAPON_crystalline_armor_penetration
	armor_damage = @ESC_WEAPON_crystalline_armor_damage
	shield_penetration = @ESC_WEAPON_crystalline_shields_penetration
	shield_damage = @ESC_WEAPON_crystalline_shields_damage
	tracking = 0.1

	firing_arc = 25.0
	min_range = @ESC_WEAPON_MIN_RANGE_2
	#use_ship_kill_target = no

	prerequisites = { "esc_tech_crystal_lance_2" }
	component_set = ESC_CRYSTAL_LANCE_2
	projectile_gfx = "yellow_crystal_ship_projectile"
	upgrades_to = ESC_CRYSTAL_LANCE_3
	tags = { weapon_type_kinetic x_slot weapon_role_artillery }
	ai_tags = { weapon_role_artillery artillery }

	inline_script = {
		script = weapon_effects/esc_critical_hit
		CRITICAL_HIT_CHANCE = 25
		NORMAL_HIT_CHANCE = 75
		CRITICAL_DAMAGE_AMOUNT = 2375 # (min damage + max damage) / 2
	}

	target_weights = {
		titan = 3
		battleship = 2
		stinger_stage_1 = 2
		stinger_stage_2 = 2
		stinger_stage_3 = 2
	}

	# only regular empires and xenophile FE should use this component
	valid_for_country = {
		ESC_TRIGGER_is_normal_empire_or_xenophile_fe = yes
	}

	ai_weight = {
		weight = 1
		### AI shouldn't use this component if it can't afford at least some upgrades right away
		modifier = {
			factor = 0.0
			no_resource_for_component = { RESOURCE = rare_crystals }
		}
	}
}

############################################################
##                  Crystal Lance Cannon                  ##
############################################################

weapon_component_template = {
	key = ESC_CRYSTAL_LANCE_3
	size = extra_large
	icon = GFX_esc_crystal_lance_3
	icon_frame = 1
	type = instant

    damage = { min = 2000 max = 3500 }
	windup = { min = 20 max = 60 }
	total_fire_time = 80
	range = @ESC_WEAPON_RANGE_X_2
	accuracy = 0.85
	power = -275

	inline_script = {
		script = component_costs/shorthands/esc_inlines_crystalline_cost
		COMPONENT_TYPE = WEAPON
		SIZE = xl
		TIER = 8
	}

	hull_damage = @ESC_WEAPON_crystalline_lance_hull_damage
	armor_penetration = @ESC_WEAPON_crystalline_armor_penetration
	armor_damage = @ESC_WEAPON_crystalline_armor_damage
	shield_penetration = @ESC_WEAPON_crystalline_shields_penetration
	shield_damage = @ESC_WEAPON_crystalline_shields_damage
	tracking = 0.1

	firing_arc = 25.0
	min_range = @ESC_WEAPON_MIN_RANGE_2
	#use_ship_kill_target = no

	prerequisites = { "esc_tech_crystal_lance_3" }
	component_set = ESC_CRYSTAL_LANCE_3
	projectile_gfx = "yellow_crystal_ship_projectile"
	upgrades_to = ESC_CRYSTAL_LANCE_JUGGERNAUT
	tags = { weapon_type_kinetic x_slot weapon_role_artillery }
	ai_tags = { weapon_role_artillery artillery }

	inline_script = {
		script = weapon_effects/esc_critical_hit
		CRITICAL_HIT_CHANCE = 25
		NORMAL_HIT_CHANCE = 75
		CRITICAL_DAMAGE_AMOUNT = 2750 # (min damage + max damage) / 2
	}

	target_weights = {
		titan = 3
		battleship = 2
		stinger_stage_1 = 2
		stinger_stage_2 = 2
		stinger_stage_3 = 2
	}

	# only regular empires and xenophile FE should use this component
	valid_for_country = {
		ESC_TRIGGER_is_normal_empire_or_xenophile_fe = yes
	}

	ai_weight = {
		weight = 1
		### AI shouldn't use this component if it can't afford at least some upgrades right away
		modifier = {
			factor = 0.0
			no_resource_for_component = { RESOURCE = rare_crystals }
		}
	}
}

############################################################
##                 Crystalline Impaler                    ##
############################################################

# titan
weapon_component_template = {
	key = ESC_CRYSTAL_LANCE_TITANIC
	size = titanic
	icon = GFX_esc_crystal_lance_titanic
	icon_frame = 1
	type = instant

    inline_script = { # damage and collateral damage
		script = weapon_effects/esc_inlines_collateral_damage
		MIN_DAMAGE = 5000
		MAX_DAMAGE = 8000
		COLLATERAL_RANGE = @ESC_COLLATERAL_RANGE_KINETIC_t
		COLLATERAL_SCALE_MULTIPLIER = @ESC_COLLATERAL_MULTIPLIER
	}

	windup = { min = 20 max = 60 }
	total_fire_time = 160
	range = @ESC_WEAPON_RANGE_T_3
	accuracy = 0.85
	power = -500

	inline_script = {
		script = component_costs/shorthands/esc_inlines_crystalline_cost
		COMPONENT_TYPE = WEAPON
		SIZE = t
		TIER = 8
	}

	hull_damage = @ESC_WEAPON_crystalline_lance_hull_damage
	armor_penetration = @ESC_WEAPON_crystalline_armor_penetration
	armor_damage = @ESC_WEAPON_crystalline_armor_damage
	shield_penetration = @ESC_WEAPON_crystalline_shields_penetration
	shield_damage = @ESC_WEAPON_crystalline_shields_damage
	tracking = 0.1

	firing_arc = 25.0
	min_range = @ESC_WEAPON_MIN_RANGE_3
	#use_ship_kill_target = no

	prerequisites = { "esc_tech_crystal_lance_titanic" }
	component_set = ESC_CRYSTAL_LANCE_TITANIC
	projectile_gfx = "yellow_crystal_ship_projectile"
	tags = { weapon_type_kinetic t_slot weapon_role_artillery }
	ai_tags = { weapon_role_artillery artillery }

	inline_script = {
		script = weapon_effects/esc_critical_hit
		CRITICAL_HIT_CHANCE = 25
		NORMAL_HIT_CHANCE = 75
		CRITICAL_DAMAGE_AMOUNT = 6500 # (min damage + max damage) / 2
	}

	inline_script = {
		script = ship_components_general/esc_inlines_titanic_standard
		ARKSHIP_WEAPON = no
	}

	target_weights = {
		titan = 3
		battleship = 2
		stinger_stage_1 = 2
		stinger_stage_2 = 2
		stinger_stage_3 = 2
	}

	# only regular empires and xenophile FE should use this component
	valid_for_country = {
		ESC_TRIGGER_is_normal_empire_or_xenophile_fe = yes
	}

	ai_weight = {
		weight = 1
		### AI shouldn't use this component if it can't afford at least some upgrades right away
		modifier = {
			factor = 0.0
			no_resource_for_component = { RESOURCE = rare_crystals }
		}
	}
}

# juggernaut
weapon_component_template = {
	key = ESC_CRYSTAL_LANCE_JUGGERNAUT
	size = extra_large
	icon = GFX_esc_crystal_lance_titanic
	icon_frame = 1
	type = instant

    inline_script = { # damage and collateral damage
		script = weapon_effects/esc_inlines_collateral_damage
		MIN_DAMAGE = 5000
		MAX_DAMAGE = 8000
		COLLATERAL_RANGE = @ESC_COLLATERAL_RANGE_KINETIC_t
		COLLATERAL_SCALE_MULTIPLIER = @ESC_COLLATERAL_MULTIPLIER
	}

	windup = { min = 20 max = 60 }
	total_fire_time = 155
	range = @ESC_WEAPON_RANGE_J_3
	accuracy = 0.85
	power = -500

	inline_script = {
		script = component_costs/shorthands/esc_inlines_crystalline_cost
		COMPONENT_TYPE = WEAPON
		SIZE = t
		TIER = 8
	}

	hull_damage = @ESC_WEAPON_crystalline_lance_hull_damage
	armor_penetration = @ESC_WEAPON_crystalline_armor_penetration
	armor_damage = @ESC_WEAPON_crystalline_armor_damage
	shield_penetration = @ESC_WEAPON_crystalline_shields_penetration
	shield_damage = @ESC_WEAPON_crystalline_shields_damage
	tracking = 0.1

	firing_arc = 25.0
	min_range = @ESC_WEAPON_MIN_RANGE_3
	#use_ship_kill_target = no

	prerequisites = { "esc_tech_crystal_lance_titanic" }
	component_set = ESC_CRYSTAL_LANCE_JUGGERNAUT
	projectile_gfx = "yellow_crystal_ship_projectile"
	tags = { weapon_type_kinetic x_slot weapon_role_artillery }
	ai_tags = { weapon_role_artillery artillery }

	potential = {
		ESC_ship_uses_juggernaut_components = yes
	}

	inline_script = {
		script = weapon_effects/esc_critical_hit
		CRITICAL_HIT_CHANCE = 25
		NORMAL_HIT_CHANCE = 75
		CRITICAL_DAMAGE_AMOUNT = 6500 # (min damage + max damage) / 2
	}

	target_weights = {
		titan = 3
		battleship = 2
		stinger_stage_1 = 2
		stinger_stage_2 = 2
		stinger_stage_3 = 2
	}

	# only regular empires and xenophile FE should use this component
	valid_for_country = {
		ESC_TRIGGER_is_normal_empire_or_xenophile_fe = yes
	}

	ai_weight = {
		weight = 1
		### AI shouldn't use this component if it can't afford at least some upgrades right away
		modifier = {
			factor = 0.0
			no_resource_for_component = { RESOURCE = rare_crystals }
		}
	}
}

# arkship
weapon_component_template = {
	key = ESC_CRYSTAL_LANCE_ARKSHIP
	size = titanic
	icon = GFX_esc_crystal_lance_titanic
	icon_frame = 1
	type = instant

    inline_script = { # damage and collateral damage
		script = weapon_effects/esc_inlines_collateral_damage
		MIN_DAMAGE = 5000
		MAX_DAMAGE = 13000
		COLLATERAL_RANGE = @ESC_COLLATERAL_RANGE_KINETIC_t
		COLLATERAL_SCALE_MULTIPLIER = @ESC_COLLATERAL_MULTIPLIER
	}

	windup = { min = 20 max = 60 }
	total_fire_time = 160
	range = @ESC_WEAPON_RANGE_ARKSHIP_4
	accuracy = 0.75
	power = 0

	resources = {
		category = ship_components
		upkeep = {
			alloys = @titanic_t7_upkeep_alloys
			energy = @titanic_t7_upkeep_energy
		}
	}

	hull_damage = @ESC_WEAPON_crystalline_lance_hull_damage
	armor_penetration = @ESC_WEAPON_crystalline_armor_penetration
	armor_damage = @ESC_WEAPON_crystalline_armor_damage
	shield_penetration = @ESC_WEAPON_crystalline_shields_penetration
	shield_damage = @ESC_WEAPON_crystalline_shields_damage
	tracking = 0.1

	firing_arc = 25.0
	min_range = @ESC_WEAPON_MIN_RANGE_3
	#use_ship_kill_target = no

	prerequisites = { "esc_tech_crystal_lance_titanic" }
	component_set = ESC_CRYSTAL_LANCE_ARKSHIP
	projectile_gfx = "yellow_crystal_ship_projectile"
	tags = { weapon_type_kinetic t_slot weapon_role_artillery }
	ai_tags = { weapon_role_artillery artillery }

	inline_script = {
		script = weapon_effects/esc_critical_hit
		CRITICAL_HIT_CHANCE = 25
		NORMAL_HIT_CHANCE = 75
		CRITICAL_DAMAGE_AMOUNT = 6500 # (min damage + max damage) / 2
	}

	inline_script = {
		script = ship_components_general/esc_inlines_titanic_standard
		ARKSHIP_WEAPON = yes
	}

	target_weights = {
		titan = 3
		battleship = 2
		stinger_stage_1 = 2
		stinger_stage_2 = 2
		stinger_stage_3 = 2
	}

	# only regular empires and xenophile FE should use this component
	valid_for_country = {
		ESC_TRIGGER_is_normal_empire_or_xenophile_fe = yes
	}

	ai_weight = {
		weight = 1
	}
}
