############################################################
###           ESC TECHNOLOGIES : NANITE WEAPONS          ###
############################################################

# ── Nanite Cannon									: tier 1 nanite cannon
#     └─ Improved Nanite Cannon						: tier 2 nanite cannon
# ── Nanite Reconstruction Beam						: special weapon
# ── Nanite Warhead Torpedo							: tier 1 nanite torpedo
#     └─ Gray Goo Torpedo							: tier 2 nanite torpedo
#         └─ Nanite Warhead Missile Launcher		: tier 1 nanile XL weapon
#             └─ N. W. Multi-Missile Launcher		: tier 2 nanite XL weapon
#                 └─ N. W. Rocket Artillery			: titanic nanite weapon
# ── Nanite Bombers									: nanite strikecrafts
# ── Nanite Aggressiveness Protocols				: nanite weapon damage repeatable
# ── Nanite Self-Replication Protocols				: nanite rate of fire repeatable

############################################################
##                       Nanite Cannon                    ##
############################################################

esc_tech_nanite_cannon_1 = {
	area = society
	category = { materials }
	tier = 5
	cost = @tier5cost2
	weight = @tier5weight2
	ai_update_type = military
	prerequisites = { "esc_tech_synthetic_lifeform_studies" }
	gateway = ESC_NANITE_CANNONS

	technology_swap = {
		name = esc_tech_nanite_cannon_1_bio
		inherit_icon = no
		inherit_effects = yes
		trigger = { country_uses_bio_ships = yes }
		weight = { factor = 1 }
	}

	potential = {
		NOT = { has_global_flag = ESC_GLOBAL_FLAG_nanite_weapons_forbidden }
	}

	weight_modifier = {
		modifier = {
			factor = 1.1
			has_ethic = ethic_xenophile
		}
		modifier = {
			factor = 1.2
			has_ethic = ethic_fanatic_xenophile
		}
	}

	ai_weight = {
		factor = @ESC_AI_tech_weight_multiplier
		modifier = {
			factor = 1.1
			has_ethic = ethic_xenophile
		}
		modifier = {
			factor = 1.2
			has_ethic = ethic_fanatic_xenophile
		}
	}
}

############################################################
##                  Improved Nanite Cannon                ##
############################################################

esc_tech_nanite_cannon_2 = {
	area = society
	category = { materials }
	tier = 5
	cost = @tier5cost3
	weight = @tier5weight3
	ai_update_type = military
	prerequisites = { "esc_tech_nanite_cannon_1" }
	is_rare = yes
	is_reverse_engineerable = no

	technology_swap = {
		name = esc_tech_nanite_cannon_2_bio
		inherit_icon = no
		inherit_effects = yes
		trigger = { country_uses_bio_ships = yes }
		weight = { factor = 1 }
	}

	potential = {
		NOT = { has_global_flag = ESC_GLOBAL_FLAG_nanite_weapons_forbidden }
	}

	weight_modifier = {
		modifier = {
			factor = 0
			ESC_TRIGGER_may_research_nanite_weapons_advanced = no
		}
		modifier = {
			factor = 1.1
			has_ethic = ethic_xenophile
		}
		modifier = {
			factor = 1.2
			has_ethic = ethic_fanatic_xenophile
		}
		modifier = {
			factor = @ESC_TECH_Technology_Ascendancy_weight_modifier
			has_ascension_perk = ap_technological_ascendancy
		}
		modifier = {
			factor = @federation_perk_factor
			has_federation = yes
			federation = {
				has_federation_perk = rare_tech_boost
				any_member = { has_technology = esc_tech_nanite_cannon_2 }
			}
		}
	}

	ai_weight = {
		factor = @ESC_AI_tech_weight_multiplier
		modifier = {
			factor = 0
			ESC_TRIGGER_may_research_nanite_weapons_advanced = no
		}
		modifier = {
			factor = 1.1
			has_ethic = ethic_xenophile
		}
		modifier = {
			factor = 1.2
			has_ethic = ethic_fanatic_xenophile
		}
		modifier = {
			factor = @ESC_TECH_Technology_Ascendancy_weight_modifier
			has_ascension_perk = ap_technological_ascendancy
		}
		modifier = {
			factor = @federation_perk_factor
			has_federation = yes
			federation = {
				has_federation_perk = rare_tech_boost
				any_member = { has_technology = esc_tech_nanite_cannon_2 }
			}
		}
	}
}

############################################################
##                Nanite Reconstruction Beam              ##
############################################################

esc_tech_nanite_reconstructor = {
	area = society
	category = { materials }
	tier = 5
	cost = @tier5cost3
	weight = @tier5weight3
	ai_update_type = military
	prerequisites = { "esc_tech_nanite_cannon_1" }
	is_rare = yes
	is_reverse_engineerable = no

	technology_swap = {
		name = esc_tech_nanite_reconstructor_bio
		inherit_icon = yes
		inherit_effects = yes
		trigger = { country_uses_bio_ships = yes }
		weight = { factor = 1 }
	}

	potential = {
		NOT = { has_global_flag = ESC_GLOBAL_FLAG_nanite_weapons_forbidden }
	}

	weight_modifier = {
		modifier = {
			factor = 0
			ESC_TRIGGER_may_research_nanite_weapons_advanced = no
		}
		modifier = {
			factor = 1.1
			has_ethic = ethic_xenophile
		}
		modifier = {
			factor = 1.2
			has_ethic = ethic_fanatic_xenophile
		}
		modifier = {
			factor = @ESC_TECH_Technology_Ascendancy_weight_modifier
			has_ascension_perk = ap_technological_ascendancy
		}
		modifier = {
			factor = @federation_perk_factor
			has_federation = yes
			federation = {
				has_federation_perk = rare_tech_boost
				any_member = { has_technology = esc_tech_nanite_cannon_2 }
			}
		}
	}

	ai_weight = {
		factor = @ESC_AI_tech_weight_multiplier
		modifier = {
			factor = 0
			ESC_TRIGGER_may_research_nanite_weapons_advanced = no
		}
		modifier = {
			factor = 1.1
			has_ethic = ethic_xenophile
		}
		modifier = {
			factor = 1.2
			has_ethic = ethic_fanatic_xenophile
		}
		modifier = {
			factor = @ESC_TECH_Technology_Ascendancy_weight_modifier
			has_ascension_perk = ap_technological_ascendancy
		}
		modifier = {
			factor = @federation_perk_factor
			has_federation = yes
			federation = {
				has_federation_perk = rare_tech_boost
				any_member = { has_technology = esc_tech_nanite_cannon_2 }
			}
		}
	}
}

############################################################
##                  Nanite Warhead Torpedo                ##
############################################################

esc_tech_nanite_torpedo_1 = {
	area = society
	category = { materials }
	tier = 5
	cost = @tier5cost2
	weight = @tier5weight2
	ai_update_type = military
	prerequisites = { "esc_tech_synthetic_lifeform_studies" }
	gateway = ESC_NANITE_TORPEDOES

	technology_swap = {
		name = esc_tech_nanite_torpedo_1_bio
		inherit_icon = no
		inherit_effects = yes
		trigger = { country_uses_bio_ships = yes }
		weight = { factor = 1 }
	}

	potential = {
		NOT = { has_global_flag = ESC_GLOBAL_FLAG_nanite_weapons_forbidden }
	}

	weight_modifier = {
		modifier = {
			factor = 0
			country_uses_bio_ships = no
			NOT = { has_technology = tech_torpedoes_3 }
		}
		modifier = {
			factor = 1.1
			has_ethic = ethic_xenophile
		}
		modifier = {
			factor = 1.2
			has_ethic = ethic_fanatic_xenophile
		}
	}

	ai_weight = {
		factor = @ESC_AI_tech_weight_multiplier
		modifier = {
			factor = 0
			country_uses_bio_ships = no
			NOT = { has_technology = tech_torpedoes_3 }
		}
		modifier = {
			factor = 1.1
			has_ethic = ethic_xenophile
		}
		modifier = {
			factor = 1.2
			has_ethic = ethic_fanatic_xenophile
		}
	}
}

############################################################
##                    Gray Goo Torpedo                    ##
############################################################

esc_tech_nanite_torpedo_2 = {
	area = society
	category = { materials }
	tier = 5
	cost = @tier5cost3
	weight = @tier5weight3
	ai_update_type = military
	prerequisites = { "esc_tech_nanite_torpedo_1" }
	is_rare = yes
	is_reverse_engineerable = no

	technology_swap = {
		name = esc_tech_nanite_torpedo_2_bio
		inherit_icon = no
		inherit_effects = yes
		trigger = { country_uses_bio_ships = yes }
		weight = { factor = 1 }
	}

	potential = {
		NOT = { has_global_flag = ESC_GLOBAL_FLAG_nanite_weapons_forbidden }
	}

	weight_modifier = {
		modifier = {
			factor = 0
			ESC_TRIGGER_may_research_nanite_weapons_advanced = no
		}
		modifier = {
			factor = 1.1
			has_ethic = ethic_xenophile
		}
		modifier = {
			factor = 1.2
			has_ethic = ethic_fanatic_xenophile
		}
		modifier = {
			factor = @ESC_TECH_Technology_Ascendancy_weight_modifier
			has_ascension_perk = ap_technological_ascendancy
		}
		modifier = {
			factor = @federation_perk_factor
			has_federation = yes
			federation = {
				has_federation_perk = rare_tech_boost
				any_member = { has_technology = esc_tech_nanite_torpedo_2 }
			}
		}
	}

	ai_weight = {
		factor = @ESC_AI_tech_weight_multiplier
		modifier = {
			factor = 0
			ESC_TRIGGER_may_research_nanite_weapons_advanced = no
		}
		modifier = {
			factor = 1.1
			has_ethic = ethic_xenophile
		}
		modifier = {
			factor = 1.2
			has_ethic = ethic_fanatic_xenophile
		}
		modifier = {
			factor = @ESC_TECH_Technology_Ascendancy_weight_modifier
			has_ascension_perk = ap_technological_ascendancy
		}
		modifier = {
			factor = @federation_perk_factor
			has_federation = yes
			federation = {
				has_federation_perk = rare_tech_boost
				any_member = { has_technology = esc_tech_nanite_torpedo_2 }
			}
		}
	}
}

############################################################
##              Nanite Warhead Missile Launcher           ##
############################################################

esc_tech_nanite_missile_x_1 = {
	area = society
	category = { materials }
	tier = 6
	cost = @ESC_TECH_tier6_cost1
	weight = @ESC_TECH_tier6_weight1
	ai_update_type = military
	prerequisites = { "esc_tech_nanite_torpedo_2" "esc_tech_advanced_heavy_weapons" }
	is_rare = yes
	is_reverse_engineerable = no
	gateway = ESC_NANITE_X_WEAPONS

	technology_swap = {
		name = esc_tech_nanite_missile_x_1_bio
		inherit_icon = no
		inherit_effects = yes
		trigger = { country_uses_bio_ships = yes }
		weight = { factor = 1 }
	}

	potential = {
		NOT = { has_global_flag = ESC_GLOBAL_FLAG_nanite_x_weapons_forbidden }
	}

	weight_modifier = {
		modifier = {
			factor = 0
			ESC_TRIGGER_may_research_nanite_weapons_advanced = no
		}
		modifier = {
			factor = 1.1
			has_ethic = ethic_xenophile
		}
		modifier = {
			factor = 1.2
			has_ethic = ethic_fanatic_xenophile
		}
		modifier = {
			factor = @ESC_TECH_Technology_Ascendancy_weight_modifier
			has_ascension_perk = ap_technological_ascendancy
		}
		modifier = {
			factor = @federation_perk_factor
			has_federation = yes
			federation = {
				has_federation_perk = rare_tech_boost
				any_member = { has_technology = esc_tech_nanite_missile_x_1 }
			}
		}
	}

	ai_weight = {
		factor = @ESC_AI_tech_weight_multiplier
		modifier = {
			factor = 0
			ESC_TRIGGER_may_research_nanite_weapons_advanced = no
		}
		modifier = {
			factor = 1.1
			has_ethic = ethic_xenophile
		}
		modifier = {
			factor = 1.2
			has_ethic = ethic_fanatic_xenophile
		}
		modifier = {
			factor = @ESC_TECH_Technology_Ascendancy_weight_modifier
			has_ascension_perk = ap_technological_ascendancy
		}
		modifier = {
			factor = @federation_perk_factor
			has_federation = yes
			federation = {
				has_federation_perk = rare_tech_boost
				any_member = { has_technology = esc_tech_nanite_missile_x_1 }
			}
		}
	}
}

############################################################
##           Nanite Warhead Multi-Missile Launcher        ##
############################################################

esc_tech_nanite_missile_x_2 = {
	area = society
	category = { materials }
	tier = 6
	cost = @ESC_TECH_tier6_cost2
	weight = @ESC_TECH_tier6_weight2
	ai_update_type = military
	prerequisites = { "esc_tech_nanite_missile_x_1" }
	is_rare = yes
	is_reverse_engineerable = no
	gateway = ESC_NANITE_X_WEAPONS

	technology_swap = {
		name = esc_tech_nanite_missile_x_2_bio
		inherit_icon = no
		inherit_effects = yes
		trigger = { country_uses_bio_ships = yes }
		weight = { factor = 1 }
	}

	potential = {
		NOT = { has_global_flag = ESC_GLOBAL_FLAG_nanite_x_weapons_forbidden }
	}

	weight_modifier = {
		modifier = {
			factor = 0
			ESC_TRIGGER_may_research_nanite_weapons_advanced = no
		}
		modifier = {
			factor = 1.1
			has_ethic = ethic_xenophile
		}
		modifier = {
			factor = 1.2
			has_ethic = ethic_fanatic_xenophile
		}
		modifier = {
			factor = @ESC_TECH_Technology_Ascendancy_weight_modifier
			has_ascension_perk = ap_technological_ascendancy
		}
		modifier = {
			factor = @federation_perk_factor
			has_federation = yes
			federation = {
				has_federation_perk = rare_tech_boost
				any_member = { has_technology = esc_tech_nanite_missile_x_2 }
			}
		}
	}

	ai_weight = {
		factor = @ESC_AI_tech_weight_multiplier
		modifier = {
			factor = 0
			ESC_TRIGGER_may_research_nanite_weapons_advanced = no
		}
		modifier = {
			factor = 1.1
			has_ethic = ethic_xenophile
		}
		modifier = {
			factor = 1.2
			has_ethic = ethic_fanatic_xenophile
		}
		modifier = {
			factor = @ESC_TECH_Technology_Ascendancy_weight_modifier
			has_ascension_perk = ap_technological_ascendancy
		}
		modifier = {
			factor = @federation_perk_factor
			has_federation = yes
			federation = {
				has_federation_perk = rare_tech_boost
				any_member = { has_technology = esc_tech_nanite_missile_x_2 }
			}
		}
	}
}

############################################################
##              Nanite Warhead Rocket Artillery           ##
############################################################

esc_tech_nanite_missile_titanic = {
	area = society
	category = { materials }
	tier = 6
	cost = @ESC_TECH_tier6_cost3
	weight = @ESC_TECH_tier6_weight3
	ai_update_type = military
	prerequisites = { "esc_tech_nanite_missile_x_2" }
	is_rare = yes
	is_reverse_engineerable = no

	technology_swap = {
		name = esc_tech_nanite_missile_titanic_bio
		inherit_icon = no
		inherit_effects = yes
		trigger = { country_uses_bio_ships = yes }
		weight = { factor = 1 }
	}

	potential = {
		ESC_TRIGGER_may_research_oversized_weapons = yes
		NOT = { has_global_flag = ESC_GLOBAL_FLAG_nanite_x_weapons_forbidden }
	}

	weight_modifier = {
		modifier = {
			factor = 0
			ESC_TRIGGER_may_research_nanite_weapons_advanced = no
		}
		modifier = {
			factor = 0
			NOR = {
				has_technology = tech_titans
				has_technology = tech_juggernaut
			}
		}
		modifier = {
			factor = 1.1
			has_ethic = ethic_xenophile
		}
		modifier = {
			factor = 1.2
			has_ethic = ethic_fanatic_xenophile
		}
		modifier = {
			factor = @ESC_TECH_Technology_Ascendancy_weight_modifier
			has_ascension_perk = ap_technological_ascendancy
		}
		modifier = {
			factor = @federation_perk_factor
			has_federation = yes
			federation = {
				has_federation_perk = rare_tech_boost
				any_member = { has_technology = esc_tech_nanite_missile_titanic }
			}
		}
	}

	ai_weight = {
		factor = @ESC_AI_tech_weight_multiplier
		modifier = {
			factor = 0
			ESC_TRIGGER_may_research_nanite_weapons_advanced = no
		}
		modifier = {
			factor = 0
			NOR = {
				has_technology = tech_titans
				has_technology = tech_juggernaut
			}
		}
		modifier = {
			factor = 1.1
			has_ethic = ethic_xenophile
		}
		modifier = {
			factor = 1.2
			has_ethic = ethic_fanatic_xenophile
		}
		modifier = {
			factor = @ESC_TECH_Technology_Ascendancy_weight_modifier
			has_ascension_perk = ap_technological_ascendancy
		}
		modifier = {
			factor = @federation_perk_factor
			has_federation = yes
			federation = {
				has_federation_perk = rare_tech_boost
				any_member = { has_technology = esc_tech_nanite_missile_titanic }
			}
		}
	}
}

############################################################
##                      Nanite Bombers                    ##
############################################################

esc_tech_nanite_bomber = {
	area = society
	category = { voidcraft }
	tier = 5
	cost = @tier5cost3
	weight = @tier5weight3
	ai_update_type = military
	prerequisites = { "tech_strike_craft_3" "esc_tech_synthetic_lifeform_studies" }
	is_rare = yes

	technology_swap = {
		name = esc_tech_nanite_bomber_bio
		inherit_icon = no
		inherit_effects = yes
		trigger = { country_uses_bio_ships = yes }
		weight = { factor = 1 }
	}

	potential = {
		NOT = { has_global_flag = ESC_GLOBAL_FLAG_nanite_weapons_forbidden }
	}

	weight_modifier = {
		modifier = {
			factor = 1.1
			has_ethic = ethic_xenophile
		}
		modifier = {
			factor = 1.2
			has_ethic = ethic_fanatic_xenophile
		}
		modifier = {
			factor = @ESC_TECH_Technology_Ascendancy_weight_modifier
			has_ascension_perk = ap_technological_ascendancy
		}
		modifier = {
			factor = @federation_perk_factor
			has_federation = yes
			federation = {
				has_federation_perk = rare_tech_boost
				any_member = { has_technology = esc_tech_nanite_bomber }
			}
		}
	}

	ai_weight = {
		factor = @ESC_AI_tech_weight_multiplier
		modifier = {
			factor = 1.1
			has_ethic = ethic_xenophile
		}
		modifier = {
			factor = 1.2
			has_ethic = ethic_fanatic_xenophile
		}
		modifier = {
			factor = @ESC_TECH_Technology_Ascendancy_weight_modifier
			has_ascension_perk = ap_technological_ascendancy
		}
		modifier = {
			factor = @federation_perk_factor
			has_federation = yes
			federation = {
				has_federation_perk = rare_tech_boost
				any_member = { has_technology = esc_tech_nanite_bomber }
			}
		}
	}
}

############################################################
##           Nanite Aggressiveness Protocols              ##
############################################################

esc_tech_repeatable_nanite_damage = {
	area = physics
	cost = @repeatableTechBaseCost
	cost_per_level = @repeatableTechLevelCost
	tier = @repeatableTechTier
	category = { computing }
	levels = -1
	prerequisites = { "esc_tech_synthetic_lifeform_studies" }
	weight = @repeatableTechWeight

	potential = {
		NOT = { has_global_flag = ESC_GLOBAL_FLAG_nanite_weapons_forbidden }
	}

	modifier = {
		weapon_type_nanite_weapon_damage_mult = 0.05
	}

	weight_modifier = {
		factor = @repatableTechFactor
		modifier = {
			factor = 0
			NOR = {
				has_technology = esc_tech_nanite_cannon_1
				has_technology = esc_tech_nanite_torpedo_1
				has_technology = esc_tech_nanite_bomber
			}
		}
		modifier = {
			factor = 0
			ESC_TRIGGER_may_research_nanite_weapon_damage_repeatable = no
		}
	}

	ai_weight = {
		factor = @repatableTechFactor
		modifier = {
			factor = 0
			NOR = {
				has_technology = esc_tech_nanite_cannon_1
				has_technology = esc_tech_nanite_torpedo_1
				has_technology = esc_tech_nanite_bomber
			}
		}
		modifier = {
			factor = 0
			ESC_TRIGGER_may_research_nanite_weapon_damage_repeatable = no
		}
	}
}

############################################################
##           Nanite Self-Replication Protocols            ##
############################################################

esc_tech_repeatable_nanite_fire_rate = {
	area = physics
	cost = @repeatableTechBaseCost
	cost_per_level = @repeatableTechLevelCost
	tier = @repeatableTechTier
	category = { computing }
	levels = -1
	prerequisites = { "esc_tech_synthetic_lifeform_studies" }
	weight = @repeatableTechWeight

	potential = {
		NOT = { has_global_flag = ESC_GLOBAL_FLAG_nanite_weapons_forbidden }
	}

	modifier = {
		weapon_type_nanite_weapon_fire_rate_mult = 0.05
	}

	weight_modifier = {
		factor = @repatableTechFactor
		modifier = {
			factor = 0
			NOR = {
				has_technology = esc_tech_nanite_cannon_1
				has_technology = esc_tech_nanite_torpedo_1
				has_technology = esc_tech_nanite_bomber
			}
		}
		modifier = {
			factor = 0
			ESC_TRIGGER_may_research_nanite_weapon_fire_rate_repeatable = no
		}
	}

	ai_weight = {
		factor = @repatableTechFactor
		modifier = {
			factor = 0
			NOR = {
				has_technology = esc_tech_nanite_cannon_1
				has_technology = esc_tech_nanite_torpedo_1
				has_technology = esc_tech_nanite_bomber
			}
		}
		modifier = {
			factor = 0
			ESC_TRIGGER_may_research_nanite_weapon_fire_rate_repeatable = no
		}
	}
}
