
#######################
# Research Technology #
#######################

tech_storm_manipulation = {
	cost = {
		factor = @tier2cost2
		inline_script = {
			script = technologies/cosmic_storms_technologies_cost_modifiers
		}
	}
	area = physics
	category = { field_manipulation }
	tier = 2
	is_rare = no
	weight = @tier2weight2

	prerequisites = { "tech_industrial_storm_protection" }

	potential = {
		has_cosmic_storms_dlc = yes
	}

	weight_modifier = {
		inline_script = {
			script = technologies/cosmic_storms_technologies_weight_modifiers
		}

		modifier = {
			factor = 0
			has_origin = origin_storm_chasers # Unlocked in the origin situation
		}

		modifier = {
			factor = 0
			is_nomadic = no
			num_cosmic_storms_encountered < 3
		}
	}

	gateway = tech_advanced_storm_manipulation

	ai_weight = {
		weight = 10
		modifier = {
			add = 1
			has_technology = tech_industrial_storm_protection
		}
		modifier = {
			add = 1
			num_cosmic_storms_encountered >= 3
		}
	}
}

tech_advanced_storm_manipulation = {
	cost = {
		factor = @tier3cost1
		inline_script = {
			script = technologies/cosmic_storms_technologies_cost_modifiers
		}
	}
	area = physics
	category = { field_manipulation }
	tier = 3
	is_rare = yes
	weight = @tier3weight1
	prerequisites = { "tech_storm_manipulation" }

	feature_flags = {
		sustain_cosmic_storm_unlocked
	}

	potential = {
		has_cosmic_storms_dlc = yes
	}

	weight_modifier = {
		inline_script = {
			script = technologies/cosmic_storms_technologies_weight_modifiers
		}
		modifier = {
			factor = 0.5
			num_cosmic_storms_encountered < 5
		}
	}
	ai_weight = {
		weight = 1
		modifier = {
			add = 1
			num_cosmic_storms_encountered >= 3
		}
	}
}

tech_industrial_storm_protection = {
	cost = {
		factor = @tier1cost1
		inline_script = {
			script = technologies/cosmic_storms_technologies_cost_modifiers
		}
	}
	area = engineering
	category = { industry }
	tier = 1
	is_rare = no
	weight = @tier1weight1

	potential = {
		has_cosmic_storms_dlc = yes
	}

	technology_swap = { # Wilderness icon swap
		name = tech_storm_relief_center
		inherit_icon = no
		inherit_effects = yes
		trigger = {
			is_wilderness_empire = yes
		}
	}

	weight_modifier = {
		inline_script = {
			script = technologies/cosmic_storms_technologies_weight_modifiers
		}

		modifier = {
			factor = 0
			is_nomadic = no
			num_cosmic_storms_encountered < 1
		}
		modifier = {
			factor = 2
			OR = {
				has_origin = origin_storm_chasers
				has_storm_attraction_civic = yes
			}
		}
	}

	gateway = tech_advanced_industrial_storm_protection

	modifier = {
		country_storm_protection_tech_level_add = 1
		show_only_custom_tooltip = yes
	}

	ai_weight = {
		weight = 5
		modifier = {
			add = 2
			OR = {
				num_cosmic_storms_encountered >= 1
				any_neighbor_country = {
					num_cosmic_storms_encountered >= 1
				}
			}
		}

		modifier = {
			add = 1
			has_technology = tech_storm_manipulation
		}
	}
}

tech_advanced_industrial_storm_protection = {
	cost = {
		factor = @tier2cost1
		inline_script = {
			script = technologies/cosmic_storms_technologies_cost_modifiers
		}
	}
	area = engineering
	category = { industry }
	tier = 2
	is_rare = no
	weight = @tier2weight1
	prerequisites = { "tech_industrial_storm_protection" }

	potential = {
		has_cosmic_storms_dlc = yes
		is_wilderness_empire = no
	}

	weight_modifier = {
		inline_script = {
			script = technologies/cosmic_storms_technologies_weight_modifiers
		}

		modifier = {
			factor = 0.5
			num_cosmic_storms_encountered < 4
		}

		modifier = {
			factor = 2
			OR = {
				has_origin = origin_storm_chasers
				has_storm_attraction_civic = yes
			}
		}
	}

	modifier = {
		country_storm_protection_tech_level_add = 1
	}

	ai_weight = {
		weight = 5

		modifier = {
			add = 1
			num_buildings = { type = building_storm_resistant_production value > 0 }
		}
	}
}

tech_storm_prediction_1 = {
	cost = {
		factor = @tier1cost2
		inline_script = {
			script = technologies/cosmic_storms_technologies_cost_modifiers
		}
	}
	area = physics
	category = { computing }
	tier = 1
	is_rare = no
	weight = @tier1weight3

	prerequisites = { "tech_industrial_storm_protection" }

	modifier = {
		country_storm_location_intel_add = 1
		country_storm_movement_intel_add = 1
		custom_tooltip = BLANK_STRING
	}

	prereqfor_desc = {
		hide_prereq_for_desc = component
		custom = {
			title = tech_storm_prediction_1_title
			desc = tech_storm_prediction_1_tooltip
		}
	}

	potential = {
		has_cosmic_storms_dlc = yes
	}

	weight_modifier = {
		inline_script = {
			script = technologies/cosmic_storms_technologies_weight_modifiers
		}

		modifier = {
			factor = 0
			is_nomadic = no
			num_cosmic_storms_encountered < 1
		}

		modifier = {
			factor = 2
			OR = {
				has_origin = origin_storm_chasers
				has_storm_attraction_civic = yes
			}
		}
	}

	gateway = tech_storm_prediction

	ai_weight = {
		weight = 1

		modifier = {
			factor = 2
			has_origin = origin_storm_chasers
		}
	}
}

tech_storm_prediction_2 = {
	cost = {
		factor = @tier3cost2
		inline_script = {
			script = technologies/cosmic_storms_technologies_cost_modifiers
		}
	}
	area = physics
	category = { computing }
	tier = 3
	is_rare = yes
	weight = @tier3weight3

	prerequisites = { "tech_storm_prediction_1" }

	modifier = {
		country_storm_location_intel_add = 2
		country_storm_movement_intel_add = 2
		custom_tooltip = BLANK_STRING
	}

	prereqfor_desc = {
		hide_prereq_for_desc = component
		custom = {
			title = tech_storm_prediction_2_title
			desc = tech_storm_prediction_2_tooltip
		}
	}

	potential = {
		has_cosmic_storms_dlc = yes
	}

	weight_modifier = {
		inline_script = {
			script = technologies/cosmic_storms_technologies_weight_modifiers
		}
		modifier = {
			factor = 0.5
			num_cosmic_storms_encountered < 3
		}
		modifier = {
			factor = 2
			OR = {
				has_origin = origin_storm_chasers
				has_storm_attraction_civic = yes
			}
		}
	}

	ai_weight = {
		weight = 1
		modifier = {
			factor = 2
			has_origin = origin_storm_chasers
		}
	}
}

tech_ship_hull_storm_breaker_1 = {
	cost = {
		factor = @tier1cost2
		inline_script = {
			script = technologies/cosmic_storms_technologies_cost_modifiers
		}
	}
	area = engineering
	category = { materials }
	tier = 1
	is_rare = no
	weight = @tier1weight1

	prerequisites = { "tech_storm_prediction_1" }

	potential = {
		has_cosmic_storms_dlc = yes
	}

	modifier = {
		storm_ship_hull_breaker_mult = -0.45
		custom_tooltip = MOD_SHIP_HULL_STORM_BREAKER_1
	}

	weight_modifier = {
		inline_script = {
			script = technologies/cosmic_storms_technologies_weight_modifiers
		}

		modifier = {
			factor = 0
			is_nomadic = no
			num_cosmic_storms_encountered < 1
		}
		modifier = {
			factor = 2
			OR = {
				has_origin = origin_storm_chasers
				has_storm_attraction_civic = yes
			}
		}
	}
	ai_weight = {
		weight = 5
		modifier = {
			factor = 2
			num_cosmic_storms_encountered >= 3
		}
	}

	gateway = tech_ship_hull_storm_breaker
}

tech_ship_hull_storm_breaker_2 = {
	cost = {
		factor = @tier2cost1
		inline_script = {
			script = technologies/cosmic_storms_technologies_cost_modifiers
		}
	}
	area = engineering
	category = { materials }
	tier = 2
	is_rare = no
	weight = @tier2weight2

	prerequisites = { "tech_ship_hull_storm_breaker_1" }

	potential = {
		has_cosmic_storms_dlc = yes
	}

	weight_modifier = {
		inline_script = {
			script = technologies/cosmic_storms_technologies_weight_modifiers
		}

		modifier = {
			factor = 0.5
			num_cosmic_storms_encountered < 3
		}

		modifier = {
			factor = 2
			OR = {
				has_origin = origin_storm_chasers
				has_storm_attraction_civic = yes
			}
		}
	}

	ai_weight = {
		weight = 1
		modifier = {
			factor = 2
			num_cosmic_storms_encountered >= 5
		}
	}

	modifier = {
		storm_ship_hull_breaker_mult = -0.45
		custom_tooltip = MOD_SHIP_HULL_STORM_BREAKER_2
	}
}

tech_ship_storm_weapons_1 = {
	cost = {
		factor = @tier1cost2
		inline_script = {
			script = technologies/cosmic_storms_technologies_cost_modifiers
		}
	}
	area = engineering
	category = { voidcraft }
	tier = 1
	is_rare = no
	weight = @tier1weight1

	prerequisites = { "tech_storm_prediction_1" }

	potential = {
		has_cosmic_storms_dlc = yes
	}

	weight_modifier = {
		inline_script = {
			script = technologies/cosmic_storms_technologies_weight_modifiers
		}

		modifier = {
			factor = 0
			is_nomadic = no
			num_cosmic_storms_encountered < 1
		}
		modifier = {
			factor = 2
			OR = {
				has_origin = origin_storm_chasers
				has_storm_attraction_civic = yes
			}
		}
	}

	gateway = tech_ship_hull_storm_weapons

	modifier = {
		custom_tooltip = MOD_SHIP_STORM_WEAPONS_1
	}

	ai_weight = {
		weight = 5
		modifier = {
			factor = 2
			num_cosmic_storms_encountered >= 3
		}
	}
}

tech_ship_storm_weapons_2 = {
	cost = {
		factor = @tier2cost1
		inline_script = {
			script = technologies/cosmic_storms_technologies_cost_modifiers
		}
	}
	area = engineering
	category = { voidcraft }
	tier = 2
	is_rare = no
	weight = @tier2weight3
	prerequisites = { "tech_ship_storm_weapons_1" }

	potential = {
		has_cosmic_storms_dlc = yes
	}

	weight_modifier = {
		inline_script = {
			script = technologies/cosmic_storms_technologies_weight_modifiers
		}

		modifier = {
			factor = 0.5
			num_cosmic_storms_encountered < 3
		}

		modifier = {
			factor = 2
			OR = {
				has_origin = origin_storm_chasers
				has_storm_attraction_civic = yes
			}
		}
	}

	modifier = {
		custom_tooltip = MOD_SHIP_STORM_WEAPONS_2
	}

	ai_weight = {
		weight = 1
		modifier = {
			factor = 2
			num_cosmic_storms_encountered >= 5
		}
	}
}
