plot_decisions = {

	plot_gain_title_decision = {
		is_high_prio = yes
		ai_check_interval = 12
		
		potential = {
			age = 16
			has_plot = plot_depose_defeat
			NOT = { has_character_flag = plot_gain_title_decision_taken }
		}
		allow = {
			plot_power = 1.0
			num_of_plot_backers = 4
			plot_target_char = {
				prisoner = no
				NOT = {
					any_war = {
						defender = {
							character = PREVPREV
						}
					}
				}
			}
			will_liege_enforce_peace = no
			has_liege_enforced_peace = no
		}
		effect = {
			plot_target_char = {
				save_event_target_as = doge_defeated
			}
			ROOT = {
				character_event = {
					id = republican.19
				}
			}
			hidden_tooltip = {
				set_character_flag = plot_gain_title_decision_taken
				activate_plot = yes
			}
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				NOT = { plot_power = 0.9 }
			}
		}
	}
}
title_decisions = {
	
	make_republican_title = {
		is_high_prio = no
		ai_check_interval = 12
		filter = owned
		
		from_potential = {
			has_landed_title = k_genoa
			is_merchant_republic = yes
		}
		potential = {
			NOT = { has_title_flag = republican_genoese_title }
		}
		effect = {
			custom_tooltip = {
				text = "the doge will inherit this title"
				set_title_flag = republican_genoese_title
			}
			FROM = {
				prestige = 300
				wealth = -150
				any_vassal = {
					limit = { is_patrician = yes }
					opinion = {
						modifier = opinion_gave_to_the_republic
						who = FROM
						years = 10
					}
				}
			}
		}
		ai_will_do = {
			factor = 0.1
			modifier = {
				ROOT = { lower_tier_than = COUNT }
				factor = 0
			}
			modifier = {
				ROOT = { lower_tier_than = DUKE }
				FROM = { num_of_count_titles < 4 }
				factor = 0.1
			}
			modifier = {
				ROOT = { lower_tier_than = DUKE }
				FROM = { num_of_count_titles >= 4 }
				factor = 1.1
			}
			modifier = {
				ROOT = { 
					lower_tier_than = KING
					higher_tier_than = COUNT
				}
				factor = 4
			}
			modifier = {
				ROOT = { 
					lower_tier_than = EMPEROR
					higher_tier_than = DUKE
				}
				factor = 10
			}
			modifier = {
				ROOT = {
					higher_tier_than = KING
				}
				factor = 40
			}
			modifier = {
				FROM = { trait = reformer }
				factor = 0.5
			}
			modifier = {
				FROM = { trait = conservative }
				factor = 2
			}
		}
	}

	take_republican_title = {
		is_high_prio = no
		ai_check_interval = 12
		filter = owned
		
		from_potential = {
			has_landed_title = k_genoa
			is_merchant_republic = yes
		}
		potential = {
			has_title_flag = republican_genoese_title
			NOR = {
				title = b_genoa
				title = c_genoa
				title = d_genoa
				title = k_genoa
				ROOT = { higher_tier_than = KING }
			}
		}
		effect = {
			custom_tooltip = {
				text = "the doge will no more inherit this title"
				clr_title_flag = republican_genoese_title
			}
			FROM = {
				prestige = -300
				wealth = -150
				any_vassal = {
					limit = { is_patrician = yes }
					opinion = {
						modifier = opinion_took_from_republic
						who = FROM
						years = 10
					}
				}
			}
		}
		ai_will_do = {
			factor = 0.1
			modifier = {
				ROOT = { lower_tier_than = COUNT }
				FROM = { num_of_baron_titles < 4 }
				factor = 8
			}
			modifier = {
				ROOT = { lower_tier_than = DUKE }
				FROM = { num_of_count_titles < 4 }
				factor = 4
			}
			modifier = {
				ROOT = { lower_tier_than = DUKE }
				FROM = { num_of_count_titles >= 4 }
				factor = 0.1
			}
			modifier = {
				ROOT = { 
					lower_tier_than = KING
					higher_tier_than = COUNT
				}
				factor = 0.2
			}
			modifier = {
				ROOT = { 
					lower_tier_than = EMPEROR
					higher_tier_than = DUKE
				}
				factor = 0.1
			}
			modifier = {
				ROOT = {
					higher_tier_than = KING
				}
				factor = 0
			}
			modifier = {
				FROM = { trait = reformer }
				factor = 2
			}
			modifier = {
				FROM = { trait = conservative }
				factor = 0.5
			}
		}
	}
}