@b0time = 120
@b0cost = 30
@b0effect = 1
@b0upkeep = 0.5

@b1time = 210
@b1cost = 60
@b1effect = 2
@b1upkeep = 1

@b2time = 180
@b2cost = 90
@b2effect = 3
@b2upkeep = 1.5

@b3time = 180
@b3cost = 120
@b3effect = 4
@b3upkeep = 2

@b4time = 180
@b4cost = 150
@b4effect = 5
@b4upkeep = 2.5

@b5time = 180
@b5cost = 180
@b5effect = 8
@b5upkeep = 3

@science1 = 1
@science2 = 2
@science3 = 3
@science4 = 4
@science5 = 6

@natural_equilibrium_happiness = 0.02

### Aesthetics 5- Wonders ###
@wonder_build_time = 1080
@wonder_build_cost = 4000
@wonder_influence_cost = 200
@wonder_unity_prod = 2

########################
# Aesthetics Buildings #
########################

#(Terranight): Added building sets to all Wonders - Fixed needed pop amount - Removed unnecessary flags

building_est_aesthetics_5_wonder_garden = {
	icon = "building_est_aesthetics_5_wonder_garden"
	base_buildtime = @wonder_build_time
	base_cap_amount = 1
	category = unity	#(Terranight): Added to unity category

	empire_limit = {
		base = 1
	}

	building_sets = {
		government
		urban
	}

	resources = {
		category = planet_buildings
		cost = {
			minerals = @wonder_build_cost
			influence = @wonder_influence_cost
		}
		produces = {
			unity = @wonder_unity_prod
		}
	}	
	
	planet_modifier = {
		pop_environment_tolerance = 0.10
		logistic_growth_mult = 0.20	#(Terranight): Fixed and Buffed
	}
	
	country_modifier = {
		logistic_growth_mult = 0.05	#(Terranight): Fixed
	}
	
	allow = {
		has_major_upgraded_capital = yes
		sapient_pop_amount >= 7500
	}
	
	potential = {
		planet = {
			NOT = { 
				has_building = building_est_aesthetics_5_wonder_monument
				has_building_construction =  building_est_aesthetics_5_wonder_monument
				has_building = building_est_aesthetics_5_wonder_stage
				has_building_construction =building_est_aesthetics_5_wonder_stage
				has_building = building_est_aesthetics_5_wonder_halls
				has_building_construction =building_est_aesthetics_5_wonder_halls
				has_building = building_est_aesthetics_5_wonder_museum
				has_building_construction =building_est_aesthetics_5_wonder_museum
			}			
		}
		owner = {
			has_active_tradition = tr_est_aesthetics_5
		}
	}

	ai_weight = {
		factor = 30 
	}	
}

building_est_aesthetics_5_wonder_monument = {
	icon = "building_est_aesthetics_5_wonder_monument"
	base_buildtime = @wonder_build_time
	base_cap_amount = 1
	category = unity
		
	empire_limit = {
		base = 1
	}

	building_sets = {	#(Terranight): Added building sets
		government
		urban
	}

	resources = {
		category = planet_buildings
		cost = {
			minerals = @wonder_build_cost
			influence = @wonder_influence_cost
		}
		produces = {
			unity = @wonder_unity_prod
		}
	}	
	
	planet_modifier = {
		planet_jobs_unity_produces_mult = 0.25	#(Terranight): Buffed
	}
	
	country_modifier = {
		pop_government_ethic_attraction = 0.2	#(Terranight): Buffed
	}
	
	allow = {
		has_major_upgraded_capital = yes
		sapient_pop_amount >= 7500
	}
	
	potential = {
		planet = {
			NOT = { 
				has_building = building_est_aesthetics_5_wonder_garden
				has_building_construction = building_est_aesthetics_5_wonder_garden
				has_building = building_est_aesthetics_5_wonder_stage
				has_building_construction =building_est_aesthetics_5_wonder_stage
				has_building = building_est_aesthetics_5_wonder_halls
				has_building_construction =building_est_aesthetics_5_wonder_halls
				has_building = building_est_aesthetics_5_wonder_museum
				has_building_construction =building_est_aesthetics_5_wonder_museum
			}			
		}
		owner = {
			has_active_tradition = tr_est_aesthetics_5
		}
	}

	ai_weight = {
		factor = 30 
	}	
}

building_est_aesthetics_5_wonder_stage = {
	icon = "building_est_aesthetics_5_wonder_stage"
	base_buildtime = @wonder_build_time
	base_cap_amount = 1
	category = unity
	
	empire_limit = {
		base = 1
	}

	building_sets = {
		government
		urban
	}

	resources = {
		category = planet_buildings
		cost = {
			minerals = @wonder_build_cost
			influence = @wonder_influence_cost
		}
		produces = {
			unity = @wonder_unity_prod
		}
	}	
	
	planet_modifier = {
		pop_happiness = 0.1	#(Terranight): Buffed
	}
	
	country_modifier = {
		country_base_influence_produces_add = 0.5
	}
	
	allow = {
		has_major_upgraded_capital = yes
		sapient_pop_amount >= 7500
	}
	
	potential = {
		planet = {
			NOT = {  
				has_building = building_est_aesthetics_5_wonder_garden
				has_building_construction = building_est_aesthetics_5_wonder_garden
				has_building = building_est_aesthetics_5_wonder_monument
				has_building_construction =  building_est_aesthetics_5_wonder_monument
				has_building = building_est_aesthetics_5_wonder_halls
				has_building_construction =building_est_aesthetics_5_wonder_halls
				has_building = building_est_aesthetics_5_wonder_museum
				has_building_construction =building_est_aesthetics_5_wonder_museum
			}			
		}
		owner = {
			has_active_tradition = tr_est_aesthetics_5
		}
	}

	ai_weight = {
		factor = 30 
	}	
}

building_est_aesthetics_5_wonder_halls = {
	icon = "building_est_aesthetics_5_wonder_halls"
	base_buildtime = @wonder_build_time
	base_cap_amount = 1
	category = unity
		
	empire_limit = {
		base = 1
	}

	building_sets = {
		government
		urban
	}


	resources = {
		category = planet_buildings
		cost = {
			minerals = @wonder_build_cost
			influence = @wonder_influence_cost
		}
		produces = {
			unity = @wonder_unity_prod
		}
	}	
	
	planet_modifier = {
		planet_stability_add = 10	#(Terranight): Buffed
	}
	
	country_modifier = {
		species_leader_exp_gain = 0.25	#(Terranight): Buffed
	}
	
	allow = {
		has_major_upgraded_capital = yes
		sapient_pop_amount >= 7500
	}
	
	potential = {
		planet = {
			NOT = { 
				has_building = building_est_aesthetics_5_wonder_garden
				has_building_construction = building_est_aesthetics_5_wonder_garden
				has_building = building_est_aesthetics_5_wonder_monument
				has_building_construction =  building_est_aesthetics_5_wonder_monument
				has_building = building_est_aesthetics_5_wonder_stage
				has_building_construction =building_est_aesthetics_5_wonder_stage
				has_building = building_est_aesthetics_5_wonder_museum
				has_building_construction =building_est_aesthetics_5_wonder_museum
			}			
		}
		owner = {
			has_active_tradition = tr_est_aesthetics_5
		}
	}

	ai_weight = {
		factor = 30 
	}	
}

building_est_aesthetics_5_wonder_museum = {
	icon = "building_est_aesthetics_5_wonder_museum"
	base_buildtime = @wonder_build_time
	base_cap_amount = 1
	category = unity

	empire_limit = {
		base = 1
	}

	building_sets = {
		government
		urban
	}
	
	resources = {
		category = planet_buildings
		cost = {
			minerals = @wonder_build_cost
			influence = @wonder_influence_cost
		}
		produces = {
			unity = @wonder_unity_prod
		}
	}	
	
	planet_modifier = {
		planet_amenities_add = 2500	#(Terranight): Fixed (x100 to account for 4.0)
	}
	
	country_modifier = {
		country_unity_produces_mult = 0.05
	}
	
	allow = {
		has_major_upgraded_capital = yes
		sapient_pop_amount >= 7500
	}
	
	potential = {
		planet = {
			NOT = { 
				has_building = building_est_aesthetics_5_wonder_garden
				has_building_construction = building_est_aesthetics_5_wonder_garden
				has_building = building_est_aesthetics_5_wonder_monument
				has_building_construction =  building_est_aesthetics_5_wonder_monument
				has_building = building_est_aesthetics_5_wonder_stage
				has_building_construction =building_est_aesthetics_5_wonder_stage
				has_building = building_est_aesthetics_5_wonder_halls
				has_building_construction =building_est_aesthetics_5_wonder_halls
			}			
		}
		owner = {
			has_active_tradition = tr_est_aesthetics_5
		}
	}

	ai_weight = {
		factor = 30 
	}	
}

#######################
# Archivist Buildings #
#######################

building_est_archivist_finish_archive = {
	icon = "building_est_archivist_finish_archive"
	base_buildtime = 360
	base_cap_amount = 1

	category = research
	
	building_sets = {
		government
		research
		urban
	}

	resources = {
		category = planet_buildings
		cost = {
			minerals = 600
		}
		produces = {
			unity = 6
		}
		upkeep = {
			energy = 2
		}
	}	
	
	planet_modifier = {
		planet_researchers_produces_mult = 0.05
	}
	
	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = { 
				is_regular_empire = yes 
			}
		}
		modifier = {
			job_bureaucrat_add = 25
			job_physicist_add = 25
			job_biologist_add = 25
			job_engineer_add = 25
		}
	}
	
	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = { 
				is_gestalt = yes
			}
		}
		modifier = {
			job_coordinator_add = 25
			job_calculator_physicist_add = 25
			job_calculator_biologist_add = 25
			job_calculator_engineer_add = 25
		}
	}
	
	allow = {
		has_upgraded_capital = yes
	}
	
	potential = {
		owner = {
			has_tradition = tr_est_archivist_finish
		}
	}

	ai_weight = {
		factor = 15 
	}	
}

#########################
# Cybernetics Buildings #
#########################

#(Terranight): Added building sets to all buildings - Changed amount per planet to 1 - removed production, added upkeep - gave the buildings a workfoce multiplier so it seems "automated" - changed AI weight as AI should know to use it

building_est_cybernetics_finish_automated_power_plant = {
	icon = "building_est_cybernetics_finish_automated_power_plant"
	base_buildtime = 360
	base_cap_amount = 1
	category = resource
	
	building_sets = {
		generator
	}

	
	resources = {
		category = planet_buildings
		cost = {
			minerals = 240
		}
		upkeep = {
			energy = 2
		}
	}	

	planet_modifier = {
		pop_technician_bonus_workforce_mult = 0.1
	}
	
	allow = {
		has_upgraded_capital = yes
	}
	
	potential = {
		planet = {
			NOT = { is_planet_class = pc_habitat }
		}
		owner = {
			has_active_tradition = tr_est_cybernetics_finish
		}
	}
	
	ai_weight = {
		factor = 1
	}		
}

building_est_cybernetics_finish_automated_farm = {
	icon = "building_est_cybernetics_finish_automated_farm"
	base_buildtime = 360
	base_cap_amount = 1	
	category = resource
	
	building_sets = {
		farming
	}
	
	resources = {
		category = planet_buildings
		cost = {
			minerals = 240
		}
		upkeep = {
			energy = 2
		}
	}	

	planet_modifier = {
		pop_farmer_bonus_workforce_mult = 0.1	
	}
	
	allow = {
		has_upgraded_capital = yes
	}
	
	potential = {
		planet = {
			NOT = { is_planet_class = pc_habitat }
		}
		owner = {
			has_active_tradition = tr_est_cybernetics_finish
		}
	}

	ai_weight = {
		factor = 1
	}	
}


building_est_cybernetics_finish_automated_mine = {
	icon = "building_est_cybernetics_finish_automated_mine"
	base_buildtime = 360
	base_cap_amount = 1
	category = resource
	
	building_sets = {
		mining
	}
	
	resources = {
		category = planet_buildings
		cost = {
			minerals = 240
		}
		upkeep = {
			energy = 2
		}
	}	

	planet_modifier = {
		pop_miner_bonus_workforce_mult = 0.1	
	}
	
	allow = {
		has_upgraded_capital = yes
	}
	
	
	potential = {
		planet = {
			NOT = { is_planet_class = pc_habitat }
		}
		owner = {
			has_active_tradition = tr_est_cybernetics_finish
		}
	}

	ai_weight = {
		factor = 1
	}	
}

######################
# Industry Buildings #
######################

#(Terranight): Added building sets - added potential and destroy trigger - 

building_est_industry_3_blast_furnace = {
	base_buildtime = 480
	base_cap_amount = 1
	icon = "building_est_industry_3_blast_furnace"

	category = manufacturing
	
	building_sets = {
		industrial
		foundry
	}
	
	potential = {
		NOR = {
			has_modifier = resort_colony
			has_modifier = slave_colony
		}
		AND = {
			exists = owner
			owner = {
				is_wilderness_empire = no
				has_tradition = tr_est_industry_3
			}
		}
	}
	destroy_trigger = {
		OR = {
			has_modifier = resort_colony
			has_modifier = slave_colony
		}
	}

	resources = {
		category = planet_buildings
		cost = {
			minerals = 480
		}
		produces = {
			trigger = {
				exists = owner
				owner = {
					has_technology = tech_est_industry_2_4
				}
			}
			unity = 2
		}
		upkeep = {
			energy = 4
		}
	}

	planet_modifier = {
		planet_metallurgists_alloys_produces_add = 1
		planet_metallurgists_energy_upkeep_add = 2
	}
	
	allow = {
		has_major_upgraded_capital = yes
	}

	ai_weight = {
		weight = 0.1
		modifier = {
			factor = 100
			
		}
	}
}

########################
# Mechanicum Buildings #
########################

#(Terranight): Fixed job amount - added building sets

building_est_mechanicum_5_guild_of_engineers_1 = {
	base_buildtime = 360
	base_cap_amount = 1

	category = research
	
	building_sets = {
		research
	}


	resources = {
		category = planet_buildings
		cost = {
			minerals = 480
		}
		upkeep = {
			energy = 5
		}
	}
	
	potential = {
		owner = { 
			Or = {
				has_active_tradition = tr_est_mechanicum_5
				has_active_tradition = tr_est_mechanicum_5_robots
			}
		}
		NOT = { has_modifier = resort_colony }	
		NOT = { has_modifier = slave_colony }
		NOT = { is_planet_class = pc_habitat }
	}
	
	allow = {
		has_major_upgraded_capital = yes
	}

	planet_modifier = {
		planet_jobs_engineering_research_produces_mult = 0.10
	}
	
	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = { 
				is_regular_empire = yes 
				Not = {
					est_uses_robots = yes
				}
			}
		}
		modifier = {
			job_engineer_add = 300
			# job_est_engineer_add = 300
			job_technician_add = 300
		}
	}
	
	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = { 
				is_regular_empire = yes 
				est_uses_robots = yes
			}
		}
		modifier = {
			job_engineer_add = 200
			# job_est_engineer_add = 200
			job_technician_add = 200
			job_roboticist_add = 100
		}
	}

	# triggered_planet_modifier = {
	# 	potential = {
	# 		exists = owner
	# 		owner = { 
	# 			exists = owner
	# 			owner = { 
	# 				is_hive_empire = yes
	# 			}
	# 		}
	# 	}
	# 	modifier = {
	# 		job_calculator_engineer_add = 300
	# 		# job_est_engineer_add = 300
	# 		job_technician_drone_add = 300
	# 	}
	# }

	# triggered_planet_modifier = {
	# 	potential = {
	# 		exists = owner
	# 		owner = { 
	# 			exists = owner
	# 			owner = { 
	# 				is_machine_empire = yes
	# 			}
	# 		}
	# 	}
	# 	modifier = {
	# 		job_calculator_engineer_add = 200
	# 		# job_est_engineer_add = 200
	# 		job_technician_drone_add = 200
	# 		job_replicator_add = 100
	# 	}
	# }
	
	upgrades = {
		building_est_mechanicum_5_guild_of_engineers_2
	}
	
	triggered_desc = {
		trigger = { 
			exists = owner
			owner = { 
				is_regular_empire = yes 
			}
		}
		text = job_technician_effect_desc
	}	
	triggered_desc = {
		trigger = { 
			exists = owner
			owner = { 
				is_regular_empire = yes 
			}
		}
		text = job_est_engineer_effect_desc
	}
	triggered_desc = {
		trigger = { 
			exists = owner
			owner = { 
				is_regular_empire = yes 
				est_uses_robots = yes
			}
		}
		text = job_roboticist_effect_desc
	}

	# Gestalt idea added by Sartek
	# triggered_desc = {
	# 	trigger = { 
	# 		exists = owner
	# 		owner = { 
	# 			is_gestalt = yes 
	# 		}
	# 	}
	# 	text = job_technician_drone_effect_desc
	# }	
	# triggered_desc = {
	# 	trigger = { 
	# 		exists = owner
	# 		owner = { 
	# 			is_gestalt = yes 
	# 		}
	# 	}
	# 	text = job_calculator_engineer_effect_desc
	# }
	# triggered_desc = {
	# 	trigger = { 
	# 		exists = owner
	# 		owner = { 
	# 			is_machine_empire = yes
	# 		}
	# 	}
	# 	text = job_replicator_effect_desc
	# }
	
	ai_weight = {
		weight = 3
	}
}

building_est_mechanicum_5_guild_of_engineers_2 = {
	base_buildtime = 360
	can_build = no

	category = research

	building_sets = {
		research
	}

	resources = {
		category = planet_buildings
		cost = {
			minerals = 720
			rare_crystals = 50
		}
		upkeep = {
			energy = 7
			rare_crystals = 1
		}
	}
	
	potential = {
		owner = { 
			Or = {
				has_active_tradition = tr_est_mechanicum_5
				has_active_tradition = tr_est_mechanicum_5_robots
			}
		}
		NOT = { has_modifier = resort_colony }	
		NOT = { has_modifier = slave_colony }
		NOT = { is_planet_class = pc_habitat }
	}
	
	planet_modifier = {
		planet_jobs_engineering_research_produces_mult = 0.15
	}

	allow = {
		has_fully_upgraded_capital = yes
	}
	
	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = { 
				is_regular_empire = yes 
				Not = {
					est_uses_robots = yes
				}
			}
		}
		modifier = {
			job_engineer_add = 500
			# job_est_engineer_add = 500
			job_technician_add = 500
		}
	}
	
	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = { 
				is_regular_empire = yes 
				est_uses_robots = yes
			}
		}
		modifier = {
			job_engineer_add = 350
			# job_est_engineer_add = 350
			job_technician_add = 350
			job_roboticist_add = 200
		}
	}

	# triggered_planet_modifier = {
	# 	potential = {
	# 		exists = owner
	# 		owner = { 
	# 			exists = owner
	# 			owner = { 
	# 				is_hive_empire = yes
	# 			}
	# 		}
	# 	}
	# 	modifier = {
	# 		job_calculator_engineer_add = 300
	# 		# job_est_engineer_add = 300
	# 		job_technician_drone_add = 300
	# 	}
	# }

	# triggered_planet_modifier = {
	# 	potential = {
	# 		exists = owner
	# 		owner = { 
	# 			exists = owner
	# 			owner = { 
	# 				is_machine_empire = yes
	# 			}
	# 		}
	# 	}
	# 	modifier = {
	# 		job_calculator_engineer_add = 200
	# 		# job_est_engineer_add = 200
	# 		job_technician_drone_add = 200
	# 		job_replicator_add = 100
	# 	}
	# }
	
	prerequisites = {
		"tech_basic_science_lab_3"
	}
	
	triggered_desc = {
		trigger = { 
			exists = owner
			owner = { 
				is_regular_empire = yes 
			}
		}
		text = job_technician_effect_desc
	}
	triggered_desc = {
		trigger = { 
			exists = owner
			owner = { 
				is_regular_empire = yes 
			}
		}
		text = job_est_engineer_effect_desc
	}
	triggered_desc = {
		trigger = { 
			exists = owner
			owner = { 
				is_regular_empire = yes 
				est_uses_robots = yes
			}
		}
		text = job_roboticist_effect_desc
	}

	# Gestalt stuff added by Sartek
	# triggered_desc = {
	# 	trigger = { 
	# 		exists = owner
	# 		owner = { 
	# 			is_gestalt = yes 
	# 		}
	# 	}
	# 	text = job_technician_drone_effect_desc
	# }	
	# triggered_desc = {
	# 	trigger = { 
	# 		exists = owner
	# 		owner = { 
	# 			is_gestalt = yes 
	# 		}
	# 	}
	# 	text = job_calculator_engineer_effect_desc
	# }
	# triggered_desc = {
	# 	trigger = { 
	# 		exists = owner
	# 		owner = { 
	# 			is_machine_empire = yes
	# 		}
	# 	}
	# 	text = job_replicator_effect_desc
	# }
	
	ai_weight = {
		weight = 3
	}
}

####################
# Nature Buildings #
####################

#(Terranight): Added building sets

building_est_nature_preservation = {
	base_buildtime = 540
	base_cap_amount = 1

	category = unity
	
	building_sets = {
		government
		unity
		research
	}

	destroy_trigger = {
		owner = {
			Nor = {
				has_active_tradition = tr_est_nature_finish
				has_active_tradition = tr_est_nature_5_GC
			}
		}
	}

	on_destroy = {
		if = {
			limit = {
				owner = {
					Or = {
						has_active_tradition = tr_est_nature_finish
						has_active_tradition = tr_est_nature_5_GC
					}
				}
			}
			add_modifier = {
				modifier = mod_est_nature_5
				years = 20
			}
		}
	}

	resources = {
		category = planet_buildings
		cost = {
			minerals = 180
		}
		produces = {
			unity = 12
		}
		upkeep = {
			energy = 1
		}
	}	
	
	planet_modifier = {
		planet_non_artificial_max_districts_add = -2
		planet_jobs_minerals_produces_mult = -0.2
		planet_jobs_society_research_produces_mult = 0.2
	}

	allow = {
		free_district_slots > 0
	}
	
	potential = {
		has_upgraded_capital = yes
		owner = {
			Or = {
				has_active_tradition = tr_est_nature_finish
				has_active_tradition = tr_est_nature_5_GC
			}
		}
	}

	ai_weight = {
		factor = 0
	}	
}