decisions = {
	ai_austerity = {
		only_playable = yes
		only_rulers = yes
		ai_check_interval = 3
		potential = {
			ai = yes
			is_ruler = yes
			is_playable = yes
			higher_tier_than = BARON
			NOT = {
				has_character_modifier = ai_austerity
				has_character_modifier = ai_austerity_timer
			}
		}
		allow = {
			OR = {
				#is an adventurer
				has_character_modifier = planning_claimant_adventure
				#has a loan
				check_variable = { which = "loan_amount" value = 49.5 }
				#needs to get crowned
				AND = {
					trait = uncrowned
					is_adult = yes
				}
				#is excommunicated
				AND = {
					OR = {
						NOT = { has_character_flag = ask_for_repentance }
						had_character_flag = { flag = ask_for_repentance days = 1825 }
					}
					rightful_religious_head_scope = {
						ROOT = { excommunicated_for = PREV }
					}
				}
				#any part of the realm is occupied
				any_realm_title = { NOT = { higher_tier_than = count } is_occupied = yes }
				#losing a war
				any_war = {
					OR = {
						attacker = {
							character = ROOT
							NOT = { war_score = -15 }
						}
						defender = {
							character = ROOT
							war_score = 15
						}
					}
				}				
				#king with enough titles to become emperor
				AND = {
					tier = KING
					num_of_king_titles = 2
					realm_size = 150
				}
				#duke with enough titles to become king
				AND = {
					tier = DUKE
					num_of_duke_titles = 2
				}
				#has all the counties in a duchy and can create or usurp it
				any_realm_province = {
					duchy = {
						OR = {
							has_holder = no
							holder_scope = {
								NOT = { character = ROOT }
								NOT = { is_liege_or_above = ROOT }
								NOT = { is_vassal_or_below = ROOT }
							}
						}
						NOT = {
							any_direct_de_jure_vassal_title ={
								holder_scope = {
									NOT = { character = ROOT }
									NOT = { is_vassal_or_below = ROOT }
								}
							}
						}
					}
				}
			}
		}
		effect = {
			add_character_modifier = {
				name = ai_austerity
				duration = 3650
				hidden = yes
			}
			add_character_modifier = {
				name = ai_austerity_timer
				duration = 5475
				hidden = yes
			}
		}
		ai_will_do = {
			factor = 1
		}
	}

	ai_austerity_baron = {
		only_rulers = yes
		ai_check_interval = 3
		potential = {
			ai = yes
			is_ruler = yes
			primary_title = { tier = BARON }
			is_republic = yes
			is_patrician = no
			is_merchant_republic = no
			independent = no
			liege = {
				NOT = { is_father = ROOT }
				NOT = { is_mother = ROOT }
			}
			primary_title = {
				location = {
					port = yes
					TECH_TRADE_PRACTICES = 1
				}
			}
			OR = {
				primary_title = { title = b_amalfi }
				primary_title = { title = b_venezia }
				primary_title = { title = b_genoa }
				primary_title = { title = b_pisa }
				primary_title = { title = b_ancona }
				primary_title = { title = b_gaeta }
				primary_title = { title = b_novgorod }
				primary_title = { title = b_noli }
				primary_title = { title = b_lubeck }
				dejure_liege_title = { title = c_hamburg }
				dejure_liege_title = { title = c_gotland }
				primary_title = {
					location = {
						NOT = {
							duchy = { capital_scope = { province_id = PREVPREV } }
							kingdom = { capital_scope = { province_id = PREVPREV } }
						}
					}
					OR = {
						has_building = ct_port_3
						has_building = ct_port_4
						has_building = ct_port_5
					}
				}
			}
			NOT = {
				has_character_modifier = ai_austerity
				has_character_modifier = ai_austerity_timer
			}
		}
		allow = {
			wealth = 50
			prisoner = no
			is_adult = yes			
			trait = ambitious
			NOR = {
				trait = incapable
				is_dumb_trigger = yes
				trait = humble
				trait = craven
			}
			liege = {
				ai = yes
				is_feudal = yes
				ROOT = {
					primary_title = {
						dejure_liege_title = {
							current_heir = { NOT = { character = PREVPREVPREV } }
							holder_scope = { character = PREVPREVPREVPREV }
						}
					}
				}
			}
		}
		effect = {
			add_character_modifier = {
				name = ai_austerity
				duration = 3650
				hidden = yes
			}
			add_character_modifier = {
				name = ai_austerity_timer
				duration = 5475
				hidden = yes
			}
		}
		ai_will_do = {
			factor = 1
		}
	}
	
	ai_austerity_end = {
		only_rulers = yes
		ai_check_interval = 3
		potential = {
			ai = yes
			is_ruler = yes
			higher_tier_than = BARON
			has_character_modifier = ai_austerity
		}
		allow = {
			NOT = {
				#is an adventurer
				has_character_modifier = planning_claimant_adventure
				#has a loan
				check_variable = { which = "loan_amount" value = 49.5 }
				#needs to get crowned
				AND = {
					trait = uncrowned
					is_adult = yes
				}
				#is excommunicated
				AND = {
					OR = {
						NOT = { has_character_flag = ask_for_repentance }
						had_character_flag = { flag = ask_for_repentance days = 1825 }
					}
					rightful_religious_head_scope = {
						ROOT = { excommunicated_for = PREV }
					}
				}
				#any part of the realm is occupied
				any_realm_title = { NOT = { higher_tier_than = count } is_occupied = yes }
				#losing a war
				any_war = {
					OR = {
						attacker = {
							character = ROOT
							NOT = { war_score = -15 }
						}
						defender = {
							character = ROOT
							war_score = 15
						}
					}
				}				
				#king with enough titles to become emperor
				AND = {
					tier = KING
					num_of_king_titles = 2
					realm_size = 150
				}
				#duke with enough titles to become king
				AND = {
					tier = DUKE
					num_of_duke_titles = 2
				}
				#has all the counties in a duchy and can create or usurp it
				any_realm_province = {
					duchy = {
						OR = {
							has_holder = no
							holder_scope = {
								NOT = { character = ROOT }
								NOT = { is_liege_or_above = ROOT }
								NOT = { is_vassal_or_below = ROOT }
							}
						}
						NOT = {
							any_direct_de_jure_vassal_title ={
								holder_scope = {
									NOT = { character = ROOT }
									NOT = { is_vassal_or_below = ROOT }
								}
							}
						}
					}
				}
			}
		}
		effect = {
			remove_character_modifier = ai_austerity
			remove_character_modifier = ai_austerity_timer
		}
		ai_will_do = {
			factor = 1
		}
	}
}

