# Plot tags need to start with 'plot_'

# Supported types:
# character, spouse, rivals, friends, liege_titles, vassal_titles, realm_titles, realm_characters, realm_characters_plus, independent_rulers

###############
# PLOTS
###############
# Get a consul deposed
plot_depose_defeat = {
	type = realm_characters_plus # All characters in the same realm, plus rivals and relatives of self, parents, children and spouse
	intrigue_plot = yes
	vassal_intrigue_plot = yes
	vassal_rank_plot = yes
	murder_plot = yes
	
	# Plotter scope
	potential = {
		liege = { is_merchant_republic = yes }
	}
	
	# Target character scope
	allow = {
	    has_landed_title = k_genoa
		OR = {
			has_character_modifier = g_defeated
			has_character_modifier = discovered_siphoning_funds
		}
		OR = {
			AND = {
				has_law = term_prolongation_0
				has_character_modifier = first_year_half
			}
			AND = {
				has_law = term_prolongation_1
				has_character_modifier = second_year_half
			}
			AND = {
				has_law = term_prolongation_2
				has_character_modifier = third_year_half
			}
			AND = {
				has_law = term_prolongation_3
				has_character_modifier = fourth_year_half
			}
			has_law = term_prolongation_4
		}
	}	
	
	# Target allow trigger for when players target a specific character in the GUI
	player_allow = {
		custom_tooltip = {
			text = "must have dragged the republic in danger, either by losing a war or taking the republic wealth in his hands"
			OR = {
				has_character_modifier = g_defeated
				has_character_modifier = discovered_siphoning_funds
			}
		}
	}
	
	chance = {
		factor = 0.5
		modifier = {
			factor = 10
			OR = {
				AND = {
					has_character_flag = guelph_cb
					liege = { has_character_flag = ghibelline_cb }
				}
				AND = {
					has_character_flag = ghibelline_cb
					liege = { has_character_flag = guelph_cb }
				}
			}
		}		
		modifier = {
			factor = 2
			trait = envious
		}		
		modifier = {
			factor = 0
			FROM = {
				ai = yes
				OR = {
					trait = content
					trait = honest
					trait = kind
					trait = charitable
				}
			}
		}
		modifier = {
			factor = 0
			FROM = {
				ai = yes
				opinion = {
					who = ROOT
					value = 75
				}
			}
		}	
		modifier = {
			factor = 0
			FROM = { spouse = { character = ROOT } }
			FROM = { opinion = { who = ROOT value = 0 } }
		}		
		modifier = {
			factor = 0.25
			FROM = { opinion = { who = ROOT value = 50 } }
		}
		modifier = {
			factor = 0.5
			FROM = { opinion = { who = ROOT value = 25 } }
		}		
		modifier = {
			factor = 1.5
			FROM = { NOT = { opinion = { who = ROOT value = -25 } } }
		}
		modifier = {
			factor = 1.5
			FROM = { NOT = { opinion = { who = ROOT value = -50 } } }
		}
		modifier = {
			factor = 2.0
			FROM = { NOT = { opinion = { who = ROOT value = -75 } } }
		}
		modifier = {
			factor = 0.25
			FROM = { NOT = { intrigue = 10 } }
		}
		modifier = {
			factor = 3
			FROM = { intrigue = 15 }
		}
		modifier = {
			factor = 4
			FROM = { intrigue = 20 }
		}		
		modifier = {
			factor = 2.0
			FROM = { trait = deceitful }
		}
		modifier = {
			factor = 4.0
			FROM = { trait = ambitious }
		}
	}
	
	success = {
		ROOT = {
			OR = {
				is_alive = no
				NOT = {
					has_character_flag = genoese_consul
					has_landed_title = k_genoa
				}
			}
			has_character_flag = g_deposed
		} 
	}
	abort = {
		OR = {
			ROOT = {
				is_alive = no
			}
			ROOT = {
				NOT = { has_character_flag = genoese_consul }
			}
		}
	}
	
	abort_effect = {	
	    prestige = -100
	}
	effect = {
		FROM = {
			any_plot_backer = {
				reverse_opinion = {
					modifier = opinion_grateful
					who = FROM
					years = 5
				}
			}
			any_plot_backer = {
				opinion = {
					modifier = opinion_grateful
					who = FROM
					years = 5
				}
			}
			random = {
			    chance = 25
				change_intrigue = 1
			}
		}
	}
}