#commission_legend_artifact_decision
#clear_ground_for_legendary_building
#isolate_capital_decision
#isolate_family_decision

### Commission Legend Artifact ###
commission_legend_artifact_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_smith.dds"
	}
	cooldown = { days = standard_commission_artifact_cooldown_time }
	sort_order = 100
	decision_group_type = major

	is_shown = {
		is_landed = yes
		highest_held_title_tier >= tier_county
		exists = capital_province
		has_dlc_feature = legends
		custom_tooltip = {
			text = commission_legend_artifact_decision_var_tt
			has_variable = finished_legend_var
		}
	}

	is_valid_showing_failures_only = {
		# Only valid for characters with an antiquaria OR chronicler
		custom_tooltip = {
			text = commision_legend_artifact_decision_court_positions_tt
			OR = {
				employs_court_position = antiquarian_court_position
				employs_court_position = chronicler_court_position
			}
		}
		custom_tooltip = {
			text = commision_legend_artifact_decision_disappearing_tt
			any_realm_province = {
				any_province_legend = {
					has_variable = my_legend_var
				}
			}
		}
	}

	cost = {
		gold = {
			if = {
				limit = {
					has_variable = finished_mythical_legend_var
				}
				value = 800
			}
			else_if = {
				limit = {
					has_variable = finished_illustrious_legend_var
				}
				value = 600
			}
			else = {
				value = 400
			}
			if = {
				limit = { # Estate discount bonus
					domicile ?= { has_domicile_parameter = estate_reduce_commission_artifact_cost }
				}
				multiply = estate_reduce_commission_artifact_cost_value
			}
		}
	}

	effect = {
		if = {
			limit = {
				any_court_position_holder = {
					type = chronicler_court_position
				}
			}
			random_court_position_holder = {
				type = chronicler_court_position
				save_scope_as = chronicler
			}
		}
		if = {
			limit = {
				any_court_position_holder = {
					type = antiquarian_court_position
				}
			}
			random_court_position_holder = {
				type = antiquarian_court_position
				save_scope_as = chronicler
			}
		}
		# Explanatory Tooltip
		custom_tooltip = commission_legend_artifact_decision_effect

		hidden_effect = {
			trigger_event = ce1_decision_events.0001
		}
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 36
		empire = 36
		hegemony = 36
	}

	ai_potential = {
		is_at_war = no
		ai_greed < medium_positive_ai_value
		short_term_gold > ai_war_chest_desired_gold_value
		war_chest_gold >= halved_ai_war_chest_gold_maximum
	}

	ai_will_do = {
		base = 100 #AI should always create the book
	}
}

clear_ground_for_legendary_building = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_legend.dds"
	}
	decision_group_type = major
	sort_order = 100

	is_shown = {
		exists = var:legendary_reward_location
		has_dlc_feature = legends
		is_landed = yes
	}

	is_valid_showing_failures_only = {
		custom_tooltip = {
			text = clear_ground_for_legendary_building_no_barony_tt
			any_held_title = {
				title_tier = barony
				title_province = { has_special_building_slot = no }
				is_capital_barony = yes
				holder = root
				is_leased_out = no
			}
		}
	}

	widget = {
		gui = "decision_view_widget_option_list_generic"
		controller = decision_option_list_controller
		decision_to_second_step_button = "CHOOSE_LEGENDARY_BUILDING"
		show_from_start = yes

		item = { # Shrine
			value = clear_ground_legendary_shrine
			is_valid = {
				custom_tooltip = { # The legend you finished is valid for a legendary shrine
					text = clear_ground_legendary_shrine_tt
					has_character_flag = legendary_shrine_flag
				}
			}
			current_description = clear_ground_legendary_shrine_desc
			localization = clear_ground_legendary_shrine
			icon = "gfx/interface/icons/building_types/icon_building_legendary_shrine.dds"
			flat = yes
			ai_chance = { value = 10 }
		}
		item = { # Statue
			value = clear_ground_legendary_statue
			is_valid = {
				custom_tooltip = { # The legend you finished is valid for a legendary statue
					text = clear_ground_legendary_statue_tt
					has_character_flag = legendary_statue_flag
				}
			}
			current_description = clear_ground_legendary_statue_desc
			localization = clear_ground_legendary_statue
			icon = "gfx/interface/icons/building_types/icon_building_legendary_statue.dds"
			flat = yes
			ai_chance = { value = 10 }
		}
		item = { # Palace
			value = clear_ground_legendary_palace
			is_valid = {
				custom_tooltip = { # The legend you finished is valid for a legendary palace
					text = clear_ground_legendary_palace_tt
					has_character_flag = legendary_palace_flag
				}
			}
			current_description = clear_ground_legendary_palace_desc
			localization = clear_ground_legendary_palace
			icon = "gfx/interface/icons/building_types/icon_building_legendary_palace.dds"
			flat = yes
			ai_chance = { value = 10 }
		}
		item = { # Watchtower
			value = clear_ground_legendary_watchtower
			is_valid = {
				custom_tooltip = { # The legend you finished is valid for a legendary watchtower
					text = clear_ground_legendary_watchtower_tt
					has_character_flag = legendary_watchtower_flag
				}
			}
			current_description = clear_ground_legendary_watchtower_desc
			localization = clear_ground_legendary_watchtower
			icon = "gfx/interface/icons/building_types/icon_building_legendary_watchtower.dds"
			flat = yes
			ai_chance = { value = 10 }
		}
		item = { # Hunting lodge
			value = clear_ground_legendary_hunting_lodge
			is_valid = {
				custom_tooltip = { # The legend you finished is valid for a legendary hunting_lodge
					text = clear_ground_legendary_hunting_lodge_tt
					has_character_flag = legendary_hunting_lodge_flag
				}
			}
			current_description = clear_ground_legendary_hunting_lodge_desc
			localization = clear_ground_legendary_hunting_lodge
			icon = "gfx/interface/icons/building_types/icon_building_legendary_hunting_grounds.dds"
			flat = yes
			ai_chance = { value = 10 }
		}
	}

	effect = {
		custom_tooltip = clear_ground_for_legendary_building_custom_tt
        switch = {
            trigger = yes
            scope:clear_ground_legendary_shrine = {
                set_variable = {
                    name = clear_ground
                    value = flag:legendary_shrine
                }
            }
            scope:clear_ground_legendary_palace = {
                set_variable = {
                    name = clear_ground
                    value = flag:legendary_palace
                }
            }
            scope:clear_ground_legendary_statue = {
                set_variable = {
                    name = clear_ground
                    value = flag:legendary_statue
                }
            }
            scope:clear_ground_legendary_watchtower = {
                set_variable = {
                    name = clear_ground
                    value = flag:legendary_watchtower
                }
            }
            scope:clear_ground_legendary_hunting_lodge = {
                set_variable = {
                    name = clear_ground
                    value = flag:legendary_hunting_lodge
                }
            }
        }
        open_view_data = {
            view = decision_detail
            data = decision:pick_legendary_barony_decision
            player = root
        }
    }
    ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 36
		empire = 36
		hegemony = 36
	}
    ai_potential = {
        is_at_war = no
        ai_greed < medium_positive_ai_value
        short_term_gold > ai_war_chest_desired_gold_value
        war_chest_gold >= halved_ai_war_chest_gold_maximum
    }
    ai_will_do = {
        base = 100 #AI should always reap rewards
    }
}

### $clear_ground_for_legendary_building$ ###
pick_legendary_barony_decision = {
    picture = {
        reference = "gfx/interface/illustrations/decisions/decision_legend.dds"
    }
	decision_group_type = major
    ai_goal = yes
    is_invisible = yes
    widget = {
        controller = create_holy_order
        barony_valid = {
            trigger_if = {
                limit = { exists = this }
				title_province = { has_special_building_slot = no }
				is_capital_barony = yes
				holder = scope:ruler
				is_leased_out = no
            }
        }
    }
    is_valid_showing_failures_only = { # Error suppressing
		has_variable = clear_ground
    }
    cost = {
    }
    effect = {
        send_interface_toast = {
            type = event_toast_effect_good
            title = clear_ground_for_legendary_building.toast
            switch = {
                trigger = root.var:clear_ground
                flag:legendary_shrine = {
                    scope:barony.title_province ?= {
                        add_special_building_slot = legendary_shrine
                    }
                }
                flag:legendary_palace = {
                    scope:barony.title_province ?= {
                        add_special_building_slot = legendary_palace
                    }
                }
                flag:legendary_statue = {
                    scope:barony.title_province ?= {
                        add_special_building_slot = legendary_statue
                    }
                }
                flag:legendary_watchtower = {
                    scope:barony.title_province ?= {
                        add_special_building_slot = legendary_watchtower
                    }
                }
                flag:legendary_hunting_lodge = {
                    scope:barony.title_province ?= {
                        add_special_building_slot = legendary_hunting_lodge
                    }
                }
            }
        }
        hidden_effect = {
            remove_variable = clear_ground
            # Shift the legend protagonist to the province
            if = {
                limit = {
                    exists = var:legendary_figure
                }
                scope:barony.title_province ?= {
                    set_variable = {
                        name = legendary_figure
                        value =  root.var:legendary_figure
                    }
                }
                remove_variable = legendary_figure
            }
            # Cleanup
            if = {
                limit = {
                    has_character_flag = legendary_shrine_flag
                }
                remove_character_flag = legendary_shrine_flag
            }
            if = {
                limit = {
                    has_character_flag = legendary_statue_flag
                }
                remove_character_flag = legendary_statue_flag
            }
            if = {
                limit = {
                    has_character_flag = legendary_palace_flag
                }
                remove_character_flag = legendary_palace_flag
            }
            if = {
                limit = {
                    has_character_flag = legendary_watchtower_flag
                }
                remove_character_flag = legendary_watchtower_flag
            }
            if = {
                limit = {
                    has_character_flag = legendary_hunting_lodge_flag
                }
                remove_character_flag = legendary_hunting_lodge_flag
            }
            if = {
                limit = {
                    exists = var:legendary_reward_location
                }
                remove_variable = legendary_reward_location
            }
        }
    }
    
    ai_potential = {
        is_playable_character = yes
    }
    ai_will_do = {
        base = 200
    }
}

### Isolate Capital ###
isolate_capital_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_black_plague.dds"
	}
	decision_group_type = major
	sort_order = 100

	title = {
		first_valid = {
			triggered_desc = {
				trigger = { capital_county = { has_county_modifier = isolate_capital_decision_modifier } }
				desc = unisolate_capital_decision
			}
			desc = isolate_capital_decision
		}
	}

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { capital_county = { has_county_modifier = isolate_capital_decision_modifier } }
				desc = unisolate_capital_decision_desc
			}
			desc = isolate_capital_decision_desc
		}
	}

	confirm_text = {
		first_valid = {
			triggered_desc = {
				trigger = { capital_county = { has_county_modifier = isolate_capital_decision_modifier } }
				desc = unisolate_family_decision_confirm
			}
			desc = isolate_capital_decision_confirm
		}
	}

	is_shown = {
		is_landed = yes
		exists = capital_county
		highest_held_title_tier >= tier_county
		trigger_if = {
			limit = {
				is_ai = yes
			}
			OR = {
				any_held_title = {
					title_tier = county
					has_province_with_epidemic = { intensity = any }
				}
				capital_county = {
                    any_neighboring_county = {
                        any_county_province_epidemic = {
                            count >= 1
                        }
                    }
                }
				capital_county = { has_county_modifier = isolate_capital_decision_modifier }
			}
		}
		trigger_else = {
			OR = {
				realm_has_any_epidemic = {
					SIZE = 1
					INTENSITY = minor
				}
				capital_county = {
                    any_neighboring_county = {
                        any_county_province_epidemic = {
                            count >= 1
                        }
                    }
                }
				capital_county = { has_county_modifier = isolate_capital_decision_modifier }
			}
		}
	}

	widget = {
		gui = "decision_view_widget_option_list_generic"
		controller = decision_option_list_controller
		decision_to_second_step_button = "SELECT_ACTION"
		show_from_start = yes

		item = { # Isolate your capital
			value = isolate_capital_decision
			is_valid = {
				capital_county ?= { NOT = { has_county_modifier = isolate_capital_decision_modifier } }
				custom_tooltip = {
					text = isolate_capital_decision_tt
					any_sub_realm_county = {
						has_province_with_epidemic = { intensity = any }
					}
				}
			}
			current_description = isolate_capital_decision_desc
			localization = isolate_capital_decision
			icon = "gfx/interface/icons/message_feed/plague.dds"
			ai_chance = {
				value = 100
			}
		}

		item = { # End isolation of your capital
			value = unisolate_capital_decision
			is_valid = {
				custom_tooltip = {
					text = unisolate_capital_decision_tt
					exists = capital_county
					capital_county ?= { has_county_modifier = isolate_capital_decision_modifier }
				}
			}
			current_description = unisolate_capital_decision_desc
			localization = unisolate_capital_decision
			icon = "gfx/interface/icons/court_position_types/cave_hermit_court_position.dds"
			ai_chance = {
				value = 100
			}
		}
	}

	cooldown = { days = 365 }

	effect = {
		if = {
			limit = {
				scope:isolate_capital_decision = yes
			}
			add_legitimacy_effect = { LEGITIMACY = minor_legitimacy_loss }
			capital_county = {
				add_county_modifier = {
					modifier = isolate_capital_decision_modifier
					years = 15
				}
			}
			add_character_flag = {
				flag = ai_capital_isolation_cooldown
				years = 1
			}
		}
		if = {
			limit = {
				scope:unisolate_capital_decision = yes
			}
			capital_county = {
				remove_county_modifier = isolate_capital_decision_modifier
			}
		}
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 6
		duchy = 6
		kingdom = 6
		empire = 6
		hegemony = 6
	}

	ai_potential = {
		NOT = { has_character_flag = ai_capital_isolation_cooldown }
	}

	ai_will_do = {
		base = 0
		modifier = {
			add = 100
			NOT = { capital_county = { has_county_modifier = isolate_capital_decision_modifier } }
		}
		modifier = {
			add = 100
			NOT = { capital_county = { has_county_modifier = isolate_capital_decision_modifier } }
			has_trait = paranoid
		}
		modifier = {
			add = -50
			NOT = { capital_county = { has_county_modifier = isolate_capital_decision_modifier } }
			has_trait = brave
		}
		modifier = {
			add = -50
			NOT = { capital_county = { has_county_modifier = isolate_capital_decision_modifier } }
			has_trait = greedy
		}
		modifier = {
			add = -50
			NOT = { capital_county = { has_county_modifier = isolate_capital_decision_modifier } }
			ai_rationality <= -50
		}
		modifier = {
			add = 50
			NOT = { capital_county = { has_county_modifier = isolate_capital_decision_modifier } }
			any_held_title = {
				title_tier = county
				has_province_with_epidemic = { intensity = any }
			}
		}
		modifier = {
			add = 50
			NOT = { capital_county = { has_county_modifier = isolate_capital_decision_modifier } }
			any_held_title = {
				title_tier = county
				has_province_with_epidemic = { intensity >= major }
			}
		}
		modifier = {
			add = ai_rationality
			NOT = { capital_county = { has_county_modifier = isolate_capital_decision_modifier } }
			ai_rationality > 0
			any_held_title = {
				title_tier = county
				has_province_with_epidemic = { intensity = any }

			}
		}
		modifier = {
			add = 100
			capital_county = { has_county_modifier = isolate_capital_decision_modifier }
			NOT = {
				any_held_title = {
					title_tier = county
					has_province_with_epidemic = { intensity = any }

				}
			}
		}
	}
}

### Enter Seclusion ###
isolate_family_decision = {
	picture = {
		trigger = {
			tgp_natural_disaster_character_is_affected_by_any_imminent_disaster_trigger = yes
		}
		reference = "gfx/interface/illustrations/decisions/disaster.dds"
	}
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_black_plague.dds"
	}
	decision_group_type = major
	sort_order = 100

	title = {
		first_valid = {
			triggered_desc = {
				trigger = { 
					has_character_modifier = isolating_modifier
					tgp_natural_disaster_character_is_affected_by_any_imminent_disaster_trigger = yes
				}
				desc = unisolate_family_disaster_decision
			}
			triggered_desc = {
				trigger = { has_character_modifier = isolating_modifier }
				desc = unisolate_family_decision
			}
			triggered_desc = {
				trigger = {
					tgp_natural_disaster_character_is_affected_by_any_imminent_disaster_trigger = yes
				}
				desc = isolate_family_disaster_decision
			}
			desc = isolate_family_decision
		}
	}

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { 
					has_character_modifier = isolating_modifier
					tgp_natural_disaster_character_is_affected_by_any_imminent_disaster_trigger = yes
				}
				desc = unisolate_family_disaster_decision_desc
			}
			triggered_desc = {
				trigger = { has_character_modifier = isolating_modifier }
				desc = unisolate_family_decision_desc
			}
			triggered_desc = {
				trigger = {
					tgp_natural_disaster_character_is_affected_by_any_imminent_disaster_trigger = yes
				}
				desc = isolate_family_disaster_decision_desc
			}
			desc = isolate_family_decision_desc
		}
	}

	confirm_text = {
		first_valid = {
			triggered_desc = {
				trigger = { 
					has_character_modifier = isolating_modifier
					tgp_natural_disaster_character_is_affected_by_any_imminent_disaster_trigger = yes
				}
				desc = unisolate_family_disaster_decision_confirm
			}
			triggered_desc = {
				trigger = { 
					has_character_modifier = isolating_modifier 
				}
				desc = unisolate_family_decision_confirm
			}
			triggered_desc = {
				trigger = {
					tgp_natural_disaster_character_is_affected_by_any_imminent_disaster_trigger = yes
				}
				desc = isolate_family_disaster_decision_confirm
			}
			desc = isolate_family_decision_confirm
		}
	}

	is_shown = {
		OR = {
			is_landed = yes
			any_held_title = { is_noble_family_title = yes } # Still exclude adventurers
		}
		OR = {
			has_character_modifier = isolating_modifier
			OR = {
				capital_county ?= { # Includes landless noble families
					OR = {
						# Own capital
						has_province_with_epidemic = { intensity = any }
						# Neighborng own capital
						any_neighboring_county = {
							has_province_with_epidemic = { intensity = any }
						}
					}
				}
				# Somewhere in realm
				any_sub_realm_county = {
					has_province_with_epidemic = { intensity = any }
				}
			}
			tgp_natural_disaster_character_is_affected_by_any_imminent_disaster_trigger = yes
		}
	}

	ai_potential = {
		NOT = { has_character_flag = ai_unisolate_cooldown }
		OR = {
			has_character_modifier = isolating_modifier
			capital_county ?= {
				OR = {
					# Own capital
					has_province_with_epidemic = { intensity = any }
					# Neighboring own capital
					any_neighboring_county = {
						has_province_with_epidemic = { intensity = any }
					}
				}
			}
			# Somewhere in domain
			any_held_title = {
				title_tier = county
				has_province_with_epidemic = { intensity = any }
			}
			tgp_natural_disaster_character_is_affected_by_any_imminent_disaster_trigger = yes
		}
	}

	widget = {
		gui = "decision_view_widget_option_list_generic"
		controller = decision_option_list_controller
		decision_to_second_step_button = "SELECT_ACTION"
		show_from_start = yes
		item = { # Isolate your family from disasters
			value = isolate_family_disaster_decision
			is_shown = {
				tgp_natural_disaster_character_is_affected_by_any_imminent_disaster_trigger = yes
			}
			is_valid = {
				NOT = { has_character_modifier = isolating_modifier }
				OR = {
					is_landed = yes
					any_held_title = { is_noble_family_title = yes } # Still exclude adventurers
				}
				trigger_if = {
					limit = { exists = current_travel_plan }
					is_available_travelling_adult = yes
				}
				trigger_else = {
					custom_tooltip = {
						text = you_are_at_your_capital_tt
						exists = root.capital_province
						location = root.capital_province
					}
					trigger_if = {
						limit = {
							involved_activity.activity_location ?= capital_province
						}
						is_physically_able = yes
					}
					trigger_else = {
						is_available = yes
					}
				}
				custom_tooltip = {
					text = ai_unisolate_cooldown_tt
					NOT = { has_variable = isolating_cooldown_var }
				}
			}
			current_description = isolate_family_disaster_decision_desc
			localization = isolate_family_disaster_decision
			icon = "gfx/interface/icons/situation_types/natural_disaster_earthquake.dds"
			ai_chance = {
				value = 100
			}
		}
		item = { # Isolate your family from epidemics
			value = isolate_family_decision
			is_shown = {
				OR = {
					capital_county ?= {
						OR = {
							# Own capital
							has_province_with_epidemic = { intensity = any }
							# Neighboring own capital
							any_neighboring_county = {
								has_province_with_epidemic = { intensity = any }
							}
						}
					}
					# Somewhere in realm
					any_sub_realm_county = {
						has_province_with_epidemic = { intensity = any }
					}
				}
			}
			is_valid = {
				NOT = { has_character_modifier = isolating_modifier }
				OR = {
					is_landed = yes
					any_held_title = { is_noble_family_title = yes } # Still exclude adventurers
				}
				custom_tooltip = {
					text = you_are_at_your_capital_tt
					exists = root.capital_province
					location = root.capital_province
				}
				is_available = yes
				custom_tooltip = {
					text = ai_unisolate_cooldown_tt
					NOT = { has_variable = isolating_cooldown_var }
				}
			}
			current_description = isolate_family_decision_desc
			localization = isolate_family_decision
			icon = "gfx/interface/icons/message_feed/plague.dds"
			ai_chance = {
				value = 100
			}
		}
		item = { # Unisolate your family from disasters
			value = unisolate_family_decision
			is_valid = {
				has_character_modifier = isolating_modifier
			}
			current_description = unisolate_family_disaster_decision_desc
			localization = unisolate_family_disaster_decision
			icon = "gfx/interface/icons/court_position_types/cave_hermit_court_position.dds"
			ai_chance = {
				value = 100
			}
		}
	}

	effect = {
		if = {
			limit = {
				scope:isolate_family_disaster_decision = yes
			}
			show_as_tooltip = { 
				isolate_family_decision_effect = yes
				if = {
					limit = { capital_province ?= location }
					add_legitimacy_effect = { LEGITIMACY = minor_legitimacy_loss }
				}
				add_prestige = major_prestige_loss
			}
			hidden_effect = {
				set_variable = isolated_due_to_disaster
				trigger_event = natural_disaster.0110
			}
		}
		else_if = {
			limit = {
				scope:isolate_family_decision = yes
			}
			show_as_tooltip = { 
				isolate_family_decision_effect = yes
				add_legitimacy_effect = { LEGITIMACY = minor_legitimacy_loss }
				add_prestige = major_prestige_loss
			}
			hidden_effect = {
				trigger_event = epidemic_events.0100
			}
		}
		else_if = {
			limit = {
				scope:unisolate_family_decision = yes
				has_variable = isolated_due_to_disaster
			}
			show_as_tooltip = { unisolate_family_decision_effect = yes }
			hidden_effect = {
				remove_variable = isolated_due_to_disaster
				trigger_event = natural_disaster.0111
			}
		}
		else = {
			show_as_tooltip = { unisolate_family_decision_effect = yes }
			hidden_effect = {
				trigger_event = epidemic_events.0101
			}
		}
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 6
		duchy = 6
		kingdom = 6
		empire = 6
		hegemony = 6
	}

	ai_will_do = {
		base = 0
		modifier = {
			add = 100
			NOT = { has_character_modifier = isolating_modifier }
			has_trait = paranoid
		}
		modifier = {
			add = -50
			NOT = { has_character_modifier = isolating_modifier }
			has_trait = brave
		}
		modifier = {
			add = -50
			NOT = { has_character_modifier = isolating_modifier }
			ai_rationality <= -50
		}
		modifier = {
			add = 50
			NOT = { has_character_modifier = isolating_modifier }
			any_held_title = {
				title_tier = county
				has_province_with_epidemic = { intensity = any }
			}
		}
		modifier = {
			add = 50
			NOT = { has_character_modifier = isolating_modifier }
			any_held_title = {
				title_tier = county
				has_province_with_epidemic = { intensity >= major }
			}
		}
		modifier = {
			add = ai_rationality
			NOT = { has_character_modifier = isolating_modifier }
			ai_rationality > 0
			any_held_title = {
				title_tier = county
				has_province_with_epidemic = { intensity = any }
			}
		}
		modifier = {
			add = 100
			has_character_modifier = isolating_modifier
			NOR = {
				has_character_flag = ai_unisolate_cooldown # We keep you isolating for 1y
				capital_province = { # For barons to not exit too early
					any_province_epidemic = { }
				}
				any_held_title = {
					title_tier = county
					has_province_with_epidemic = { intensity = any }
				}

				tgp_natural_disaster_character_is_affected_by_any_imminent_disaster_trigger = yes
			}
		}
	}
}

