﻿##########
# Duchy Capital Buildings
# These are built in the first barony of the first county of any duchy
# Holding the associated duchy is required both to build, and for the buildings to be enabled
##########

# SPECIAL DUCHY BUILDINGS
# We place these at the top to make them more visible in the building interface.

##########################
### WATER FILTER MILLS ###
##########################

water_filter_mills_01 = {
	construction_time = slow_construction_time

	can_construct_potential = {
		building_requirement_castle_city_church = { LEVEL = 01 }
		building_requirement_tribal = no
	}
	
	can_construct_showing_failures_only = {
		
		culture ?= {
			has_innovation = innovation_manorialism
		}
	}
	
	is_enabled = {
		county.holder = { has_title = prev.duchy }
	}
	show_disabled = yes
	
	cost_gold = expensive_building_tier_3_cost
	
	duchy_capital_county_modifier = {
		supply_limit_mult = 0.25
		levy_reinforcement_rate = 0.25
		development_growth_factor = 0.1
		tax_mult = 0.05
	}
	
	next_building = water_filter_mills_02

	type_icon = "icon_building_watermills.dds"
	
	type = duchy_capital
	
	flag = duchy_building
	
	ai_value = {
		base = 20
		modifier = {
			factor = 2
			scope:holder.capital_province = this
		}
		modifier = {
			factor = 2
			AND = {
				building_watermills_requirement_terrain = yes
				building_windmills_requirement_terrain = yes
			}
		}
		modifier = {
			factor = 2
			OR = {
				has_building_or_higher = watermills_01
				has_building_or_higher = windmills_01
				has_building_or_higher = caravanserai_01
			}
		}
		modifier = { # Fill all building slots before going for duchy buildings
			factor = 0
			free_building_slots > 0
		}
		modifier = { # Less likely when the AI should build regular buildings first
			factor = 0.1
			scope:holder = { ai_should_focus_on_building_in_their_capital = yes }
		}
	}
}

water_filter_mills_02 = {
	construction_time = slow_construction_time

	can_construct_potential = {
		building_requirement_castle_city_church = { LEVEL = 01 }
		building_requirement_tribal = no
	}
	
	can_construct_showing_failures_only = {
		
		culture ?= {
			has_innovation = innovation_windmills
		}
	}
	
	is_enabled = {
		county.holder = { has_title = prev.duchy }
	}
	show_disabled = yes
	
	cost_gold = expensive_building_tier_4_cost
	
	duchy_capital_county_modifier = {
		supply_limit_mult = 0.5
		levy_reinforcement_rate = 0.5
		development_growth_factor = 0.2
		tax_mult = 0.10
	}
	
	next_building = water_filter_mills_03
	
	type = duchy_capital
	
	flag = duchy_building
	
	ai_value = {
		base = 20
		modifier = {
			factor = 2
			scope:holder.capital_province = this
		}
	}
}

water_filter_mills_03 = {
	construction_time = slow_construction_time

	can_construct_potential = {
		building_requirement_castle_city_church = { LEVEL = 01 }
		building_requirement_tribal = no
	}
	
	can_construct_showing_failures_only = {
		
		culture ?= {
			has_innovation = innovation_cranes
		}
	}
	
	is_enabled = {
		county.holder = { has_title = prev.duchy }
	}
	show_disabled = yes
	
	cost_gold = expensive_building_tier_5_cost
	
	duchy_capital_county_modifier = {
		supply_limit_mult = 1
		levy_reinforcement_rate = 1
		development_growth_factor = 0.3
		tax_mult = 0.15
	}
	
	type = duchy_capital
	
	flag = duchy_building
	flag = fully_upgraded_duchy_capital_building
	
	ai_value = {
		base = 20
		modifier = {
			factor = 2
			scope:holder.capital_province = this
		}
	}
}


#####################
### Edenic garden ###
#####################
edenic_garden_01 = {
	construction_time = slow_construction_time
	effect_desc = edenic_garden_effect_desc #increases send gift opinion by +33%

	can_construct_potential = {
		building_requirement_tribal = no
		building_requirement_castle_city_church = { LEVEL = 01 }
		scope:holder = {
			rite = {
				rite_has_parameter = can_build_edenic_garden
			}
		}
	}
	
	is_enabled = {
		county.rite = { rite_has_parameter = can_build_edenic_garden }
		county.holder = { has_title = prev.duchy }
	}
	show_disabled = yes
	
	cost_gold = expensive_building_tier_3_cost
	
	character_modifier = {
		monthly_piety_gain_mult = 0.05
		stress_gain_mult = -0.10
		clergy_opinion = 5
		legitimacy_gain_mult = 0.05
	}
	duchy_capital_county_modifier = {
		county_opinion_add = 5
		epidemic_resistance = 20
	}
	
	next_building = edenic_garden_02

	type_icon = "icon_building_royal_forest.dds"
	
	type = duchy_capital
	
	flag = duchy_building
	
	ai_value = {
		base = 20
		modifier = {
			factor = 2
			scope:holder.capital_province = this
		}
		modifier = { # Fill all building slots before going for duchy buildings
			factor = 0
			free_building_slots > 0
		}
		modifier = { # Less likely when the AI should build regular buildings first
			factor = 0.1
			scope:holder = { ai_should_focus_on_building_in_their_capital = yes }
		}
	}
}

edenic_garden_02 = {
	construction_time = slow_construction_time
	effect_desc = edenic_garden_effect_desc

	can_construct_potential = {
		building_requirement_tribal = no
		building_requirement_castle_city_church = { LEVEL = 01 }
		scope:holder = {
			rite = {
				rite_has_parameter = can_build_edenic_garden
			}
		}
	}
	
	is_enabled = {
		county.rite = { rite_has_parameter = can_build_edenic_garden }
		county.holder = { has_title = prev.duchy }
	}
	show_disabled = yes
	
	cost_gold = expensive_building_tier_4_cost
	
	character_modifier = {
		monthly_piety_gain_mult = 0.10
		stress_gain_mult = -0.20
		clergy_opinion = 10
		legitimacy_gain_mult = 0.1
	}
	duchy_capital_county_modifier = {
		county_opinion_add = 10
		epidemic_resistance = 30
	}
	
	next_building = edenic_garden_03
	
	type = duchy_capital
	
	flag = duchy_building
	
	ai_value = {
		base = 20
		modifier = {
			factor = 2
			scope:holder.capital_province = this
		}
	}
}

edenic_garden_03 = {
	construction_time = slow_construction_time
	effect_desc = edenic_garden_effect_desc

	can_construct_potential = {
		building_requirement_tribal = no
		building_requirement_castle_city_church = { LEVEL = 01 }
		scope:holder = {
			rite = {
				rite_has_parameter = can_build_edenic_garden
			}
		}
	}
	
	is_enabled = {
		county.rite = { rite_has_parameter = can_build_edenic_garden }
		county.holder = { has_title = prev.duchy }
	}
	show_disabled = yes
	
	cost_gold = expensive_building_tier_5_cost
	
	province_modifier = {
		monthly_income = good_building_tax_tier_4
	}
	
	character_modifier = {
		monthly_piety_gain_mult = 0.15
		stress_gain_mult = -0.30
		clergy_opinion = 15
		legitimacy_gain_mult = 0.15
		court_grandeur_baseline_add = 12
	}
	duchy_capital_county_modifier = {
		county_opinion_add = 15
		epidemic_resistance = 40
	}
	type = duchy_capital
	
	flag = duchy_building
	flag = fully_upgraded_duchy_capital_building
	
	ai_value = {
		base = 20
		modifier = {
			factor = 2
			scope:holder.capital_province = this
		}
	}
}