# Author(s): Fredys
# Thanks for the code part to the author Angriest Bird
Build_industry_building = {
	Build_infrastructure = {
		icon = generic_construction

		fire_only_once = no

		days_re_enable = 0

		days_remove = 120

		available = {
			any_owned_state = { free_building_slots = { building = infrastructure size > 1 include_locked = no }}			
		}

		visible = {	
		}

		custom_cost_trigger = {
			check_variable = { treasury > 0 }
		}

		modifier = {
		}
		custom_cost_text = cost_0

		complete_effect = {
			set_temp_variable = { money_amount = gdp_total }
			divide_temp_variable = { money_amount = -300 }
			multiply_temp_variable = { money_amount = 0.6 }
			set_temp_variable = { treasury_change = money_amount }
			modify_treasury_effect = yes
		}

		remove_effect = {
			random_owned_controlled_state = {
				limit = {
					free_building_slots = {
						building = infrastructure
						size > 0
						include_locked = yes
					}
					OR = {
						is_in_home_area = yes
						NOT = {
							owner = {
								any_owned_state = {
									free_building_slots = {
										building = infrastructure
										size > 0
										include_locked = yes
									}
									is_in_home_area = yes
								}
							}
						}
					}
				}
				add_building_construction = {
					type = infrastructure
					level = 1
					instant_build = yes
				}
			}
		}
		
		ai_will_do = {
			factor = 0
		}		
	}

	Build_civilian_factory = {
		icon = generic_construction

		fire_only_once = no

		days_re_enable = 0
		
		days_remove = 180

		available = {
			any_owned_state = { free_building_slots = { building = industrial_complex size > 1 include_locked = no }}			
		}

		visible = {	
		}

		custom_cost_trigger = {
			check_variable = { treasury > 0 }
		}

		custom_cost_text = cost_0

		complete_effect = {
			set_temp_variable = { money_amount = gdp_total }
			divide_temp_variable = { money_amount = -300 }
			multiply_temp_variable = { money_amount = 1.2 }
			set_temp_variable = { treasury_change = money_amount }
			modify_treasury_effect = yes			
		}

		remove_effect = {
			random_owned_controlled_state = {
				limit = {
					free_building_slots = {
						building = industrial_complex
						size > 0
						include_locked = yes
					}
					OR = {
						is_in_home_area = yes
						NOT = {
							owner = {
								any_owned_state = {
									free_building_slots = {
										building = industrial_complex
										size > 0
										include_locked = yes
									}
									is_in_home_area = yes
								}
							}
						}
					}
				}
				add_extra_state_shared_building_slots = 1
				add_building_construction = {
					type = industrial_complex
					level = 1
					instant_build = yes
				}
			}
		}
		
		ai_will_do = {
			factor = 0
		}		
	}

	Build_military_factory = {
		icon = generic_construction

		fire_only_once = no

		days_re_enable = 0

		days_remove = 180

		available = {
			any_owned_state = { free_building_slots = { building = arms_factory size > 1 include_locked = no }}			
		}

		visible = {	
		}

		custom_cost_trigger = {
			check_variable = { treasury > 0 }
		}

		custom_cost_text = cost_0

		complete_effect = {
			set_temp_variable = { money_amount = gdp_total }
			divide_temp_variable = { money_amount = -300 }
			multiply_temp_variable = { money_amount = 1.2 }
			set_temp_variable = { treasury_change = money_amount }
			modify_treasury_effect = yes
		}

		remove_effect = {
			random_owned_controlled_state = {
				limit = {
					free_building_slots = {
						building = arms_factory
						size > 0
						include_locked = yes
					}
					OR = {
						is_in_home_area = yes
						NOT = {
							owner = {
								any_owned_state = {
									free_building_slots = {
										building = arms_factory
										size > 0
										include_locked = yes
									}
									is_in_home_area = yes
								}
							}
						}
					}
				}
				add_extra_state_shared_building_slots = 1
				add_building_construction = {
					type = arms_factory
					level = 1
					instant_build = yes
				}
			}
		}
		
		ai_will_do = {
			factor = 0
		}		
	}	

	Build_offices_sector = {
		icon = generic_construction

		fire_only_once = no

		days_re_enable = 0

		days_remove = 180

		available = {
			any_owned_state = { free_building_slots = { building = offices size > 1 include_locked = no }}			
		}

		visible = {	
		}

		custom_cost_trigger = {
			check_variable = { treasury > 0 }
		}

		custom_cost_text = cost_0


		complete_effect = {
			set_temp_variable = { money_amount = gdp_total }
			divide_temp_variable = { money_amount = -300 }
			multiply_temp_variable = { money_amount = 1.5 }
			set_temp_variable = { treasury_change = money_amount }
			modify_treasury_effect = yes
		}

		remove_effect = {
			random_owned_controlled_state = {
				limit = {
					free_building_slots = {
						building = offices
						size > 0
						include_locked = yes
					}
					OR = {
						is_in_home_area = yes
						NOT = {
							owner = {
								any_owned_state = {
									free_building_slots = {
										building = offices
										size > 0
										include_locked = yes
									}
									is_in_home_area = yes
								}
							}
						}
					}
				}

				add_extra_state_shared_building_slots = 1
				add_building_construction = {
					type = offices
					level = 1
					instant_build = yes
				}
			}
		}
		
		ai_will_do = {
			factor = 0
		}		
	}

	Build_dockyard = {
		icon = generic_construction

		fire_only_once = no

		days_re_enable = 0

		days_remove = 180

		available = {
			any_owned_state = { free_building_slots = { building = dockyard size > 1 include_locked = no }}			
		}

		visible = {	
		}

		custom_cost_trigger = {
			check_variable = { treasury > 0 }
		}

		custom_cost_text = cost_0


		complete_effect = {
			set_temp_variable = { money_amount = gdp_total }
			divide_temp_variable = { money_amount = -300 }
			multiply_temp_variable = { money_amount = 1.3 }
			set_temp_variable = { treasury_change = money_amount }
			modify_treasury_effect = yes
		}

		remove_effect = {
			if = {
				limit = {
					NOT = {
						any_owned_state = {
							dockyard > 0
							free_building_slots = {
								building = dockyard
								size > 2
								include_locked = yes
							}
						}
					}
					any_owned_state = {
						is_coastal = yes
					}
				}
				random_owned_controlled_state = {
					limit = {
						is_coastal = yes
						free_building_slots = {
							building = dockyard
							size > 2
							include_locked = yes
						}
					}
					add_extra_state_shared_building_slots = 1
					add_building_construction = {
						type = dockyard
						level = 1
						instant_build = yes
					}
				}
			}
			if = {
				limit = {
					NOT = { has_country_flag = naval_effort_built }
					any_owned_state = {
						dockyard > 0
						free_building_slots = {
							building = dockyard
							size > 1
							include_locked = yes
						}
					}
				}
				random_owned_controlled_state = {
					limit = {
						dockyard > 0
						free_building_slots = {
							building = dockyard
							size > 1
							include_locked = yes
						}
					}
					add_extra_state_shared_building_slots = 1
					add_building_construction = {
						type = dockyard
						level = 1
						instant_build = yes
					}
				}
			}
			if = {
				limit = {
					NOT = { has_country_flag = naval_effort_built }
					NOT = {
						any_owned_state = {
							free_building_slots = {
								building = dockyard
								size > 1
								include_locked = yes
							}
						}
					}
				}
				random_state = {
					limit = {
						controller = { tag = ROOT }
						free_building_slots = {
							building = dockyard
							size > 1
							include_locked = yes
						}
					}
					add_extra_state_shared_building_slots = 1
					add_building_construction = {
						type = dockyard
						level = 1
						instant_build = yes
					}
				}
			}
		}
		
		ai_will_do = {
			factor = 0
		}		
	}

	Build_agriculture_district= {
		icon = generic_construction

		fire_only_once = no

		days_re_enable = 0
		
		days_remove = 180

		available = {
			any_owned_state = { free_building_slots = { building = agriculture_district size > 1 include_locked = no }}			
		}

		visible = {	
		}

		custom_cost_trigger = {
			check_variable = { treasury > 0 }
		}

		custom_cost_text = cost_0

		complete_effect = {
			set_temp_variable = { money_amount = gdp_total }
			divide_temp_variable = { money_amount = -300 }
			multiply_temp_variable = { money_amount = 1.2 }
			set_temp_variable = { treasury_change = money_amount }
			modify_treasury_effect = yes			
		}

		remove_effect = {
			random_owned_controlled_state = {
				limit = {
					free_building_slots = {
						building = agriculture_district
						size > 0
						include_locked = yes
					}
					OR = {
						is_in_home_area = yes
						NOT = {
							owner = {
								any_owned_state = {
									free_building_slots = {
										building = agriculture_district
										size > 0
										include_locked = yes
									}
									is_in_home_area = yes
								}
							}
						}
					}
				}
				add_extra_state_shared_building_slots = 1
				add_building_construction = {
					type = agriculture_district
					level = 1
					instant_build = yes
				}
			}
		}
		
		ai_will_do = {
			factor = 0
		}		
	}

	Expand_building_slots = {
		icon = generic_construction

		fire_only_once = no

		days_re_enable = 0

		days_remove = 180

		available = {
		}

		custom_cost_trigger = {
			check_variable = { treasury > 0 }
		}

		custom_cost_text = cost_0

		complete_effect = {
			if = {
				limit = {
					check_variable = { gdp_total < 501 }		
				}
				set_temp_variable = { money_amount = gdp_total }
				divide_temp_variable = { money_amount = -300 }
				multiply_temp_variable = { money_amount = 0.5 }
				multiply_temp_variable = { money_amount = 1 }
				set_temp_variable = { treasury_change = money_amount }
				modify_treasury_effect = yes			
			}
			if = {
				limit = {
					check_variable = { gdp_total > 500 }
					check_variable = { gdp_total < 1001 }					
				}
				set_temp_variable = { money_amount = gdp_total }
				divide_temp_variable = { money_amount = -300 }
				multiply_temp_variable = { money_amount = 0.5 }
				multiply_temp_variable = { money_amount = 2 }
				set_temp_variable = { treasury_change = money_amount }
				modify_treasury_effect = yes								
			}
			if = {
				limit = {
					check_variable = { gdp_total > 1000 }
					check_variable = { gdp_total < 1501 }										
				}
				set_temp_variable = { money_amount = gdp_total }
				divide_temp_variable = { money_amount = -300 }
				multiply_temp_variable = { money_amount = 0.5 }
				multiply_temp_variable = { money_amount = 3 }
				set_temp_variable = { treasury_change = money_amount }
				modify_treasury_effect = yes	
			}
			if = {
				limit = {
					check_variable = { gdp_total > 1500 }
					check_variable = { gdp_total < 2001 }								
				}
				set_temp_variable = { money_amount = gdp_total }
				divide_temp_variable = { money_amount = -300 }
				multiply_temp_variable = { money_amount = 0.5 }
				multiply_temp_variable = { money_amount = 4 }
				set_temp_variable = { treasury_change = money_amount }
				modify_treasury_effect = yes
			}
			if = {
				limit = {
					check_variable = { gdp_total > 2000 }
					check_variable = { gdp_total < 2501 }								
				}
				set_temp_variable = { money_amount = gdp_total }
				divide_temp_variable = { money_amount = -300 }
				multiply_temp_variable = { money_amount = 0.5 }
				multiply_temp_variable = { money_amount = 5 }
				set_temp_variable = { treasury_change = money_amount }
				modify_treasury_effect = yes
			}
			if = {
				limit = {
					check_variable = { gdp_total > 2500 }
					check_variable = { gdp_total < 3001 }					
				}
				set_temp_variable = { money_amount = gdp_total }
				divide_temp_variable = { money_amount = -300 }
				multiply_temp_variable = { money_amount = 0.5 }
				multiply_temp_variable = { money_amount = 6 }
				set_temp_variable = { treasury_change = money_amount }
				modify_treasury_effect = yes
			}
			if = {
				limit = {
					check_variable = { gdp_total > 3000 }
					check_variable = { gdp_total < 5001 }							
				}
				set_temp_variable = { money_amount = gdp_total }
				divide_temp_variable = { money_amount = -300 }
				multiply_temp_variable = { money_amount = 0.5 }
				multiply_temp_variable = { money_amount = 7 }
				set_temp_variable = { treasury_change = money_amount }
				modify_treasury_effect = yes
			}
			if = {
				limit = {
					check_variable = { gdp_total > 5000 }
					check_variable = { gdp_total < 7501 }						
				}
				set_temp_variable = { money_amount = gdp_total }
				divide_temp_variable = { money_amount = -300 }
				multiply_temp_variable = { money_amount = 0.5 }
				multiply_temp_variable = { money_amount = 8 }
				set_temp_variable = { treasury_change = money_amount }
				modify_treasury_effect = yes
			}
			if = {
				limit = {
					check_variable = { gdp_total > 7500 }
					check_variable = { gdp_total < 10001 }					
				}
				set_temp_variable = { money_amount = gdp_total }
				divide_temp_variable = { money_amount = -300 }
				multiply_temp_variable = { money_amount = 0.5 }
				multiply_temp_variable = { money_amount = 9 }
				set_temp_variable = { treasury_change = money_amount }
				modify_treasury_effect = yes
			}
			if = {
				limit = {
					check_variable = { gdp_total > 10000 }							
				}
				set_temp_variable = { money_amount = gdp_total }
				divide_temp_variable = { money_amount = -300 }
				multiply_temp_variable = { money_amount = 0.5 }
				multiply_temp_variable = { money_amount = 10 }
				set_temp_variable = { treasury_change = money_amount }
				modify_treasury_effect = yes
			}
		}

		remove_effect = {
			if = {
				limit = {
					check_variable = { gdp_total < 501 }		
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
			}
			if = {
				limit = {
					check_variable = { gdp_total > 500 }
					check_variable = { gdp_total < 1001 }					
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}						
			}
			if = {
				limit = {
					check_variable = { gdp_total > 1000 }
					check_variable = { gdp_total < 1501 }										
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
			}
			if = {
				limit = {
					check_variable = { gdp_total > 1500 }
					check_variable = { gdp_total < 2001 }								
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
			}
			if = {
				limit = {
					check_variable = { gdp_total > 2000 }
					check_variable = { gdp_total < 2501 }								
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
			}
			if = {
				limit = {
					check_variable = { gdp_total > 2500 }
					check_variable = { gdp_total < 3001 }					
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
			}
			if = {
				limit = {
					check_variable = { gdp_total > 3000 }
					check_variable = { gdp_total < 5001 }							
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
			}
			if = {
				limit = {
					check_variable = { gdp_total > 5000 }
					check_variable = { gdp_total < 7501 }						
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
			}
			if = {
				limit = {
					check_variable = { gdp_total > 7500 }
					check_variable = { gdp_total < 10001 }					
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
			}
			if = {
				limit = {
					check_variable = { gdp_total > 10000 }							
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
				}
			}			
		}
	}

	Build_Renewable_Energy_Infrastructure = {
		icon = generic_construction

		fire_only_once = no

		days_re_enable = 0

		days_remove = 365

		available = {
			any_owned_state = { free_building_slots = { building = synthetic_refinery size > 1 include_locked = no }}			
		}

		visible = {	
		}

		custom_cost_trigger = {
			check_variable = { treasury > 0 }
		}

		custom_cost_text = cost_0


		complete_effect = {
			set_temp_variable = { money_amount = gdp_total }
			divide_temp_variable = { money_amount = -300 }
			multiply_temp_variable = { money_amount = 1.2 }
			set_temp_variable = { treasury_change = money_amount }
			modify_treasury_effect = yes
		}

		remove_effect = {
			random_owned_controlled_state = {
				limit = {
					free_building_slots = {
						building = synthetic_refinery
						size > 0
						include_locked = yes
					}
					OR = {
						is_in_home_area = yes
						NOT = {
							owner = {
								any_owned_state = {
									free_building_slots = {
										building = synthetic_refinery
										size > 0
										include_locked = yes
									}
									is_in_home_area = yes
								}
							}
						}
					}
				}

				add_extra_state_shared_building_slots = 1
				add_building_construction = {
					type = synthetic_refinery
					level = 1
					instant_build = yes
				}
			}
		}
		
		ai_will_do = {
			factor = 0
		}		
	}

	Build_fossil_powerplant = {
		icon = generic_construction

		fire_only_once = no

		days_re_enable = 0

		days_remove = 365

		available = {
			any_owned_state = { free_building_slots = { building = fossil_powerplant size > 1 include_locked = no }}			
		}

		visible = {	
		}

		custom_cost_trigger = {
			check_variable = { treasury > 0 }
		}

		custom_cost_text = cost_0


		complete_effect = {
			set_temp_variable = { money_amount = gdp_total }
			divide_temp_variable = { money_amount = -300 }
			multiply_temp_variable = { money_amount = 1.5 }
			set_temp_variable = { treasury_change = money_amount }
			modify_treasury_effect = yes
		}

		remove_effect = {
			random_owned_controlled_state = {
				limit = {
					free_building_slots = {
						building = fossil_powerplant
						size > 0
						include_locked = yes
					}
					OR = {
						is_in_home_area = yes
						NOT = {
							owner = {
								any_owned_state = {
									free_building_slots = {
										building = fossil_powerplant
										size > 0
										include_locked = yes
									}
									is_in_home_area = yes
								}
							}
						}
					}
				}

				add_extra_state_shared_building_slots = 1
				add_building_construction = {
					type = fossil_powerplant
					level = 1
					instant_build = yes
				}
			}
		}
		
		ai_will_do = {
			factor = 0
		}		
	}

	Build_nuclear_power = {
		icon = generic_construction

		fire_only_once = no

		days_re_enable = 0

		days_remove = 730


		available = {
			any_owned_state = { free_building_slots = { building = nuclear_reactor size > 1 include_locked = no }}			
		}

		visible = {	
		}

		custom_cost_trigger = {
			check_variable = { treasury > 0 }
		}

		custom_cost_text = cost_0


		complete_effect = {
			set_temp_variable = { money_amount = gdp_total }
			divide_temp_variable = { money_amount = -300 }
			multiply_temp_variable = { money_amount = 2.6 }
			set_temp_variable = { treasury_change = money_amount }
			modify_treasury_effect = yes
		}

		remove_effect = {
			random_owned_controlled_state = {
				limit = {
					free_building_slots = {
						building = nuclear_reactor
						size > 0
						include_locked = yes
					}
					OR = {
						is_in_home_area = yes
						NOT = {
							owner = {
								any_owned_state = {
									free_building_slots = {
										building = nuclear_reactor
										size > 0
										include_locked = yes
									}
									is_in_home_area = yes
								}
							}
						}
					}
				}
				add_extra_state_shared_building_slots = 1
				add_building_construction = {
					type = nuclear_reactor
					level = 1
					instant_build = yes
				}
			}
		}
		
		ai_will_do = {
			factor = 0
		}		
	}
}