##### SBX 3.0 STARBASE MODULES #####


# possible section models:
# SHIPYARD_STARBASE_SECTION
# REFINERY_STARBASE_SECTION
# SCIENCE_STARBASE_SECTION
# HANGAR_STARBASE_SECTION
# ASSEMBLYYARD_STARBASE_SECTION

##### SBX 3.0 VANILLA STARBASE MODULE OVERWRITES #####


detection_array = {
	icon = "GFX_spaceport_module_detecton_array"
	section = "SCIENCE_STARBASE_SECTION"
	construction_days = 60
	category = sm_naval_support_cat

	potential = {
		exists = owner
		owner = { has_technology = tech_detection_array }
		count_starbase_modules = { type = titanic_battery count < 5 }
		is_normal_starbase = yes
		is_orbital_ring = no
	}

	possible = {
		NOT = {
			has_starbase_building = dark_matter_listening_post
		}
	}

	resources = {
		category = starbase_modules
		cost = { alloys = 25 }
		upkeep = { energy = 0.25 }
	}

	station_modifier = {
		ship_cloaking_detection_add = 1
	}

	ai_build_at_chokepoint = yes
	ai_build_outside_chokepoint = yes
	ai_weight = {
		weight = 100 #use same weight here - ai weighting is done in starbase_types.txt
		modifier = {
			add = 1000
			owner = {
				NOT = {
					any_owned_starbase = {
						has_starbase_module = detection_array
					}
				}
			}
		}
	}

	show_in_tech = "tech_detection_array"

	show_tech_unlock_if = {
		is_nomadic = no
	}
}

##### SBX 3.0 STARBASE MODULES
# ORBITAL RESEARCH LAB
orbital_lab = {
	section = "ANCHORAGE_STARBASE_SECTION"
	icon = "GFX_starbase_starbase_lab"
	construction_days = 120
	category = sm_research_cat
	
	resources = {
		category = starbase_modules
		cost = { alloys = 50 }
		produces = { physics_research = 2 society_research = 2 engineering_research = 2 }
		produces = { trigger = { has_starbase_building = orbital_physics_support_lab } physics_research = 2 }
		produces = { trigger = { has_starbase_building = orbital_society_support_lab } society_research = 2 }
		produces = { trigger = { has_starbase_building = orbital_engineering_support_lab } engineering_research = 2 }
		upkeep = { energy = 1 }
	}	
	ai_build_at_chokepoint = no
	ai_build_outside_chokepoint = yes
	ai_weight = {
		weight = 50
		modifier = { add = 500 has_starbase_size < starbase_starport }
		modifier = { add = 100 count_starbase_modules = { type = orbital_lab count > 1 } }
		modifier = { add = 100 count_starbase_modules = { type = orbital_lab count > 2 } }
		modifier = { add = 100 count_starbase_modules = { type = orbital_lab count > 3 } }
		modifier = { add = 100 count_starbase_modules = { type = orbital_lab count > 4 } }
		modifier = { add = 100 count_starbase_modules = { type = orbital_lab count > 5 } }
	}

	show_tech_unlock_if = {
		is_nomadic = no
	}

}


pd_battery = {
	section = "PD_STARBASE_SECTION"
	icon = "GFX_starbase_pd_battery"
	construction_days = 150
	category = sm_defense_cat
	
	resources = {
		category = starbase_modules
		cost = { alloys = 50 }
		upkeep = { energy = 1 }
	}
	
	station_modifier = {
		weapon_type_point_defense_weapon_damage_mult = 0.025
		ship_hull_mult = 0.01 
		ship_armor_mult = 0.01 

	}
	
	ai_build_at_chokepoint = yes
	ai_build_outside_chokepoint = no
	
	potential = { 
		exists = owner 
		owner = { 
			OR = {
				has_technology = tech_pd_tracking_1 
				has_technology = tech_pd_tracking_2
				has_technology = tech_pd_tracking_3 
				has_technology = tech_flak_batteries_1 
				has_technology = tech_flak_batteries_2
				has_technology = tech_flak_batteries_3
			}
		}
		is_normal_starbase = yes
		count_starbase_modules = { type = pd_battery count < 5 } 
		has_starbase_size >= starbase_starport

	}
	
	ai_weight = {
		weight = 100
		modifier = { factor = 0 has_starbase_size < starbase_starfortress }
		modifier = { factor = 0 count_starbase_modules = { type = pd_battery count = 2 } }
	}
}

# TORPEDO BATTERY / EX MISSILE BATTERY
missile_battery = {
	section = "MISSILE_STARBASE_SECTION"
	icon = "GFX_starbase_missile_battery"
	construction_days = 180
	category = sm_defense_cat

	potential = {
		exists = owner
		owner = { has_technology = tech_torpedoes_1 }
		is_normal_starbase = yes
	}

	resources = {
		category = starbase_modules
		cost = {
			alloys = 50
		}

		upkeep = {
			energy = 1
		}
	}

	station_modifier = {
		ship_hull_mult = 0.10
		ship_armor_mult = 0.10
		starbase_defense_platform_capacity_add = 1
	}

	ai_build_at_chokepoint = yes
	ai_build_outside_chokepoint = no
	
	potential = { 
		has_starbase_size >= starbase_starport
		count_starbase_modules = { type = missile_battery count < 5 }
	}

	ai_weight = {
		weight = 100 #use same weight here - ai weighting is done in starbase_types.txt
		modifier = {
			factor = 2
			exists = owner
			owner = { is_preferred_weapons = weapon_type_explosive }
		}
	}

	show_in_tech = "tech_torpedoes_1"

	show_tech_unlock_if = {
		is_nomadic = no
	}

}

# HANGAR BAY
hangar_bay = {
	section = "HANGAR_STARBASE_SECTION"
	icon = "GFX_starbase_hangar_bay"
	construction_days = 180
	category = sm_defense_cat

	potential = {
		exists = owner
		owner = { has_technology = tech_strike_craft_1 }
		is_normal_starbase = yes
	}

	resources = {
		category = starbase_modules
		cost = {
			alloys = 50
		}

		upkeep = {
			energy = 1
		}
	}

	station_modifier = {
		ship_hull_mult = 0.10
		ship_armor_mult = 0.10
		starbase_defense_platform_capacity_add = 1
	}

	ai_build_at_chokepoint = yes
	ai_build_outside_chokepoint = no
	
	potential = { 
		has_starbase_size >= starbase_starport
		count_starbase_modules = { type = hangar_bay count < 5 }
	}

	ai_weight = {
		weight = 100 #use same weight here - ai weighting is done in starbase_types.txt
		modifier = {
			factor = 2
			exists = owner
			owner = { is_preferred_weapons = weapon_type_strike_craft }
		}
	}

	show_in_tech = "tech_strike_craft_1"

	show_tech_unlock_if = {
		is_nomadic = no
	}

}
 

gun_battery = {
	section = "BATTERY_STARBASE_SECTION"
	icon = GFX_spaceport_modules
	construction_days = 180
	category = sm_defense_cat

	potential = {
		is_normal_starbase = yes
	}

	resources = {
		category = starbase_modules
		cost = {
			alloys = 50
		}

		upkeep = {
			energy = 1
		}
	}

	station_modifier = {
		ship_hull_mult = 0.10
		ship_armor_mult = 0.10
		starbase_defense_platform_capacity_add = 1
	}

	ai_build_at_chokepoint = yes
	ai_build_outside_chokepoint = no
	potential = { 
		has_starbase_size >= starbase_starport
		count_starbase_modules = { type = gun_battery count < 10 }
	}

	ai_weight = {
		weight = 100 
		modifier = {
			factor = 2
			exists = owner
			owner = {
				OR = {
					is_preferred_weapons = weapon_type_energy
					is_preferred_weapons = weapon_type_kinetic
				}
			}
		}
	}

	show_in_tech = "tech_mass_drivers_1"

	show_tech_unlock_if = {
		is_nomadic = no
	}

}

large_battery = {
	section = "LARGE_STARBASE_SECTION"
	icon = "GFX_starbase_large_battery"
	construction_days = 240
	category = sm_defense_cat

	potential = {
		is_orbital_ring = no
		is_normal_starbase = yes
		has_starbase_size >= starbase_starfortress 
		count_starbase_modules = { type = large_battery count < 5 }
	}
	
	resources =	{
		category = starbase_modules
		cost = { alloys = 125 }
		upkeep = { energy = 1 }
	}
	
	station_modifier = {
		ship_hull_mult = 0.10
		ship_armor_mult = 0.10
	}
	
	ai_build_at_chokepoint = yes
	ai_build_outside_chokepoint = no
	
	
	ai_weight = {
		weight = 100
		modifier = { factor = 0 has_starbase_size < starbase_starfortress }
		modifier = { factor = 0 count_starbase_modules = { type = large_battery count = 5 } }
	}	
}

# EXTRA LARGE GUN BATTERY
xl_battery = {
	section = "EXTRA_LARGE_STARBASE_SECTION"
	icon = "GFX_starbase_xl_battery"
	construction_days = 320
	category = sm_defense_cat
	
	resources ={
		category = starbase_modules
		cost = { alloys = 300 }
		upkeep = { energy = 1 }
	}
	station_modifier = {
		ship_hull_mult = 0.05 
		ship_armor_mult = 0.05 
	}
	ai_build_at_chokepoint = yes
	ai_build_outside_chokepoint = no
	potential = { 
		exists = owner 
		owner = { 
			OR = {
				has_technology = tech_energy_lance_1 
				has_technology = tech_energy_lance_2 
				has_technology = tech_arc_emitter_1 
				has_technology = tech_arc_emitter_2 
				has_technology = tech_mass_accelerator_1
				has_technology = tech_mass_accelerator_2 
			}
		}
		has_starbase_size >= starbase_citadel
		count_starbase_modules = { type = xl_battery count < 5 }
	}
	ai_weight = {
		weight = 50
		modifier = { factor = 2.0 has_starbase_module = large_battery }
		modifier = { factor = 0 has_starbase_size < starbase_citadel }
		modifier = { factor = 0.5 count_starbase_modules = { type = xl_battery count > 1 } }
		modifier = { factor = 0.5 count_starbase_modules = { type = xl_battery count > 2 } }
		modifier = { factor = 0 count_starbase_modules = { type = xl_battery count >= 5 } }
	}

	show_in_tech = "tech_starbase_5"

	show_tech_unlock_if = {
		is_nomadic = no
	}

}

titanic_battery = {
	section = "TITANIC_STARBASE_SECTION"
	icon = "GFX_starbase_titanic_battery"
	construction_days = 420
	category = sm_defense_cat

	resources = {
		category = starbase_modules
		cost = { alloys = 750 }
		upkeep = { alloys = 3 energy = 5 }
	}

	station_modifier = { 
		ship_hull_mult = 0.025
		ship_armor_mult = 0.025
	}

	ai_build_at_chokepoint = yes
	ai_build_outside_chokepoint = no

	potential = { 
		exists = owner owner = { has_technology = tech_titans }
		is_normal_starbase = yes
		has_starbase_size >= starbase_citadel
		count_starbase_modules = { type = titanic_battery count < 2 }
		is_orbital_ring = no
	}

	ai_weight = {
		weight = 100
	}

	show_in_tech = "tech_titans"

	show_tech_unlock_if = {
		is_nomadic = no
	}

}

shield_module = {
	section = "ANCHORAGE_STARBASE_SECTION"
	icon = "GFX_starbase_shield_module"
	construction_days = 180
	category = sm_defense_cat
	
	resources = {
		category = starbase_modules
		cost = { alloys = 75 }
		upkeep = { energy = 1 }
	}

	station_modifier = { 
		ship_shield_add = 8000
		ship_shield_regen_add_perc = 0.10
	}

	ai_build_at_chokepoint = yes
	ai_build_outside_chokepoint = yes
	
	potential = { 
		count_starbase_modules = { type = shield_module count < 4 } 
		has_starbase_size >= starbase_starport #not for outposts
	}
	ai_weight = {
		weight = 20
		modifier = { factor = 0.5 count_starbase_modules = { type = shield_module count > 1 } }
		modifier = { factor = 0.5 count_starbase_modules = { type = shield_module count > 2 } }
		modifier = { factor = 0 count_starbase_modules = { type = shield_module count >= 4 } }
	}

	show_tech_unlock_if = {
		is_nomadic = no
	}

}

armor_module = {
	section = "ANCHORAGE_STARBASE_SECTION"
	icon = "GFX_starbase_armor_module"
	construction_days = 180
	category = sm_defense_cat
	
	resources = {
		category = starbase_modules
		cost = { alloys = 75 }
		upkeep = { alloys = 1 }
	}
	station_modifier = { 
		ship_armor_add = 8000
		ship_armor_regen_add_perc = 0.10
	}
	ai_build_at_chokepoint = yes
	ai_build_outside_chokepoint = yes
	potential = {
		count_starbase_modules = { type = armor_module count < 4 } 
		has_starbase_size >= starbase_starport #not for outposts
	}
	ai_weight = {
		weight = 20
		modifier = { factor = 0.5 count_starbase_modules = { type = armor_module count > 1 } }
		modifier = { factor = 0.5 count_starbase_modules = { type = armor_module count > 2 } }
		modifier = { factor = 0 count_starbase_modules = { type = armor_module count >= 4 } }
	}

	show_tech_unlock_if = {
		is_nomadic = no
	}


}

asteroid_mining = {
	section = "HANGAR_STARBASE_SECTION"
	icon = "GFX_starbase_asteroid_mining"
	construction_days = 120
	category = sm_economy_cat
	
	resources =	{
		category = starbase_modules
		cost = { alloys = 50 }
		produces = { minerals = 10 }
		produces = { trigger = { has_starbase_building = mining_manager } minerals = 2 }
		upkeep = { energy = 2 }
	}
	
	potential = {
		is_normal_starbase = yes
		is_orbital_ring = no
	}
	
	possible = {
		custom_tooltip = { fail_text = "nsc.requires.asteroid" solar_system = { any_system_planet = { is_asteroid = yes } } }
	}

	ai_build_at_chokepoint = no
	ai_build_outside_chokepoint = yes
	ai_weight = {
		weight = 50
		modifier = { factor = 5 has_starbase_size < starbase_starport }
		modifier = { factor = 4 count_starbase_modules = { type = asteroid_mining count > 1 } }
		modifier = { factor = 3 count_starbase_modules = { type = asteroid_mining count > 2 } }
		modifier = { factor = 2 count_starbase_modules = { type = asteroid_mining count > 3 } }
		modifier = { factor = 1 count_starbase_modules = { type = asteroid_mining count > 4 } }
		modifier = { factor = 0 count_starbase_modules = { type = asteroid_mining count > 5 } }
	}

	show_tech_unlock_if = {
		is_nomadic = no
	}

}

space_foundry = {
	section = "REFINERY_STARBASE_SECTION"
	icon = "GFX_starbase_space_foundry"
	construction_days = 120
	category = sm_economy_cat
	
	resources = {
		category = starbase_modules
		cost = { alloys = 75 }
		
		produces = { 
			alloys = 8
		}
		upkeep = {
			minerals = 16
			energy = 2
		}
		produces = {
			trigger = { has_starbase_building = assembly_line_manufacturing }
			alloys = 1
		}
		upkeep = {
			trigger = { has_starbase_building = assembly_line_manufacturing }
			minerals = 2
			energy = 1
		}
	}
	
	ai_build_at_chokepoint = no
	ai_build_outside_chokepoint = yes
	
	potential = { 
		exists = owner owner = { has_technology = tech_alloys_1 } 
		is_orbital_ring = no 
		is_normal_starbase = yes
	}
	
	ai_weight = {
		weight = 50
		modifier = { factor = 5 has_starbase_size < starbase_starport }
		modifier = { factor = 4 count_starbase_modules = { type = space_foundry count > 1 } }
		modifier = { factor = 3 count_starbase_modules = { type = space_foundry count > 2 } }
		modifier = { factor = 2 count_starbase_modules = { type = space_foundry count > 3 } }
		modifier = { factor = 1 count_starbase_modules = { type = space_foundry count > 4 } }
		modifier = { factor = 0 count_starbase_modules = { type = space_foundry count > 5 } }
	}
	show_in_tech = "tech_alloys_1"

	show_tech_unlock_if = {
		is_nomadic = no
	}

}

space_factory = {
	section = "REFINERY_STARBASE_SECTION"
	icon = "GFX_starbase_space_factory"
	construction_days = 120
	category = sm_economy_cat
	
	resources = {
		category = starbase_modules
		cost = { alloys = 75 }
		
		produces = { 
			consumer_goods = 10
		}
		upkeep = {
			minerals = 10
			energy = 2
		}
		produces = {
			trigger = { has_starbase_building = assembly_line_manufacturing }
			consumer_goods = 2
		}
		upkeep = {
			trigger = { has_starbase_building = assembly_line_manufacturing }
			minerals = 2
			energy = 1
		}
	}

	ai_build_at_chokepoint = no
	ai_build_outside_chokepoint = yes
	
	potential = {
		exists = owner 
		owner = { has_technology = tech_luxuries_1 }
		is_orbital_ring = no
		is_normal_starbase = yes
	}

	ai_weight = {
		weight = 50
		modifier = { factor = 5 has_starbase_size < starbase_starport }
		modifier = { factor = 4 count_starbase_modules = { type = space_factory count > 1 } }
		modifier = { factor = 3 count_starbase_modules = { type = space_factory count > 2 } }
		modifier = { factor = 2 count_starbase_modules = { type = space_factory count > 3 } }
		modifier = { factor = 1 count_starbase_modules = { type = space_factory count > 4 } }
		modifier = { factor = 0 count_starbase_modules = { type = space_factory count > 5 } }
	}
	show_in_tech = "tech_luxuries_1"

	show_tech_unlock_if = {
		is_nomadic = no
	}

}

security_branch_office = {
	section = "ANCHORAGE_STARBASE_SECTION"
	icon = "GFX_starbase_security_branch_office"
	construction_days = 120
	category = sm_economy_cat

	potential = {
		is_orbital_ring = no
		is_normal_starbase = yes
		exists = owner
		owner = { is_gestalt = no }
	}
	resources = {
		category = starbase_modules
		cost = { alloys = 50 }
		upkeep = { energy = 1 }
	}

	system_modifier = { 
		planet_crime_add = -15
		job_enforcer_add = 100 
	}
	
	ai_build_at_chokepoint = no
	ai_build_outside_chokepoint = yes
	ai_weight = {
		weight = 50
	}

	show_tech_unlock_if = {
		is_nomadic = no
	}


}





##### EOF