﻿namespace = brb

brb.1 = {
	type = character_event
	title = brb.1.t
	desc = brb.1.desc
	theme = realm
	left_portrait = {
		character = root
		animation = dismissal
	}
	
	immediate = {
		scope:brb_prev_liege = {
			every_close_or_extended_family_member = {
				limit = {
					is_independent_ruler = no
					root = {
						any_close_family_member = {
							even_if_dead = yes
							exists = killer
							killer = prev
						}
					}
				}
				save_temporary_scope_as = brb_tbi
				root = {
					imprison = { target = scope:brb_tbi }
				}
			}
		}
	}
	
	option = { # accept the title
		name = brb.1.a
		trigger = {
			scope:brb_liege.primary_title = {
				root = {
					has_claim_on = prev
				}
			}
		}
		root = {
			create_title_and_vassal_change = {
				type = faction_demand
				save_scope_as = change
			}		
		}
		scope:brb_liege = {
			every_held_title = {
				change_title_holder_include_vassals = {
					holder = root
					change = scope:change
				}
			}
		}
		root = {
			resolve_title_and_vassal_change = scope:change
			trigger_event = {
				id = brb.2
			}
		}
		custom_tooltip = brb_ruler_fate
		ai_chance = {
			base = 25

			modifier = {
				add = 100
				root = {
					has_trait = ambitious
				}
			}
			
			modifier = {
				add = -15
				root = {
					has_trait = content
				}
			}
		}
		
	}

	option = { # decline
		name = brb.1.b
		root = {
			trigger_event = {
				id = brb.2
			}
		}
		ai_chance = {
			base = 20

			modifier = {
				add = 20
				root = {
					has_trait = content
				}
			}
			
			modifier = {
				add = -50
				root = {
					has_trait = ambitious
				}
			}
		}
		custom_tooltip = brb_ruler_fate
	}
	
	option = { #independence
		name = brb.1.c
		trigger = {
			OR = {
				AND = {
					scope:brb_liege = {
						highest_held_title_tier = tier_empire
					}
					root = {
						highest_held_title_tier = tier_kingdom
					}
				}
				AND = {
					scope:brb_liege = {
						highest_held_title_tier = tier_kingdom
					}
					root = {
						highest_held_title_tier = tier_duchy
					}				
				}
			}
		}
		create_title_and_vassal_change = {
			type = independency 
			save_scope_as = change
		}
		becomes_independent = {
			change = scope:change
		}
		resolve_title_and_vassal_change = scope:change
		hidden_effect = {
			root = {
				trigger_event = {
					id = brb.2
				}
			}
		}
		ai_chance = {
			base = 0

			modifier = {
				add = 20
				root = {
					has_trait = ambitious
				}
			}
			
			modifier = {
				add = -50
				root = {
					has_trait = content
				}
			}
		}
	}
}

brb.2 = {
	type = character_event
	
	title = brb.2.t
	desc = brb.2.d

	theme = intrigue
	left_portrait = {
		character = root
		animation = admiration
	}
	right_portrait = {
		character = scope:brb_prev_liege
		animation = beg
	}
	
	option = { #execute him
		name = brb.2.a
		scope:brb_prev_liege = {
			death = {
				death_reason = death_execution
				killer = root
			}
		}
		root = {
			trigger_event = {
				id = brb.21
			}
		}
	}
	
	option = { #do nothing
		name = brb.2.c
		trigger = {
			scope:brb_prev_liege = {
				NOT = { is_liege_or_above_of = root }
			}
		}
		root = {
			trigger_event = {
				id = brb.21
			}
		}
		custom_tooltip = brb_do_nothing
	}
	
	option = { #imprison him
		name = brb.2.d1
		root = { imprison = { target = scope:brb_prev_liege } }
		root = {
			trigger_event = {
				id = brb.21
			}
		}
	}	
	
}

brb.21 = {
	type = character_event
	
	title = brb.21.t
	desc = brb.21.d

	theme = intrigue
	left_portrait = {
		character = root
		animation = admiration
	}
	right_portrait = {
		character = scope:brb_liege
		animation = beg
	}

	trigger = {
		scope:brb_liege = {
			has_diarchy_active_parameter = diarchy_type_is_entrenched_regency
			is_liege_or_above_of = root
		}
		NOT = {
			is_diarch_of_target = scope:brb_liege
		}
	}
	
	option = { #become regent
		name = brb.21.a
		scope:brb_liege = { set_diarch = root }
	}
	
	option = { #do nothing
		name = brb.21.b
	}
	
}

brb.3 = {
	type = character_event
	
	title = brb.3.t
	desc = brb.3.d

	theme = realm
	left_portrait = {
		character = root
		animation = rage
	}
	lower_center_portrait = {
		character = scope:killed_man
	}
	right_portrait = {
		character = root.liege
		animation = marshal
	}
	
	trigger = {
		NOT = { root = root.liege }
		scope:killed_man = {
			NOT = {
				OR = {
					death_reason = death_disappearance
					death_reason = death_mysterious
				}
			}
		}
	}
	
	option = {
		name = brb.3.a
		start_war = {
			casus_belli = refused_liege_demand_war
			target = root.liege
		}
		ai_chance = {
			base = -50

			modifier = {
				add = 20
				desc = cft_is_rival_accept_potential
				liege = {
					has_relation_potential_rival = root
				}
			}

			modifier = {
				add = 100
				desc = cft_is_rival_accept
				liege = {
					has_relation_rival = root
				}
			}

			opinion_modifier = { # Opinion Factor
				who = root.liege
				opinion_target = root
				multiplier = -2
			}
			
			modifier = {
				add = 20
				root = {
					has_trait = vengeful
				}
			}
			
			modifier = {
				add = -20
				root.current_military_strength > root.liege.current_military_strength
				root = {
					has_trait = craven
				}
			}
			
			modifier = {
				add = 20
				ai_honor > 0
			}
			
			modifier = {
				add = 30
				ai_vengefulness > medium_positive_ai_value
			}

			modifier = {
				add = -15
				liege = {
					has_dread_level_towards = {
						target = root
						level = 1
					}
				}
			}
			
			modifier = {
				add = -15
				liege = {
					has_dread_level_towards = {
						target = root
						level = 2
					}
				}
			}
			
			modifier = { #Comparative military strength.
				add = {
					value = 1
					subtract = {
						value = root.liege.current_military_strength
						divide = { value = root.current_military_strength min = 1 }
					}
					multiply = 50
					max = 20
				}
			}
		}
	}
	option = {
		name = brb.3.b
	}
}

brb.4 = {
	type = character_event
	
	title = brb.4.t
	desc = brb.4.d

	theme = realm
	left_portrait = {
		character = scope:brb_highest_title_man
		animation = rage
	}
	lower_center_portrait = {
		character = scope:killed_man
	}
	right_portrait = {
		character = root.liege
		animation = marshal
	}
	
	trigger = {
		scope:brb_highest_title_man = {
			is_at_war_with_liege = yes
		}
	}
	
	option = {
		name = brb.4.a
		scope:brb_highest_title_man = {
			random_character_war = {
				limit = {
					is_civil_war = yes
				}
				add_attacker = root
			}
		}
		ai_chance = {
			base = -50

			modifier = {
				add = 20
				liege = {
					has_relation_potential_rival = root
				}
			}

			modifier = {
				add = 100

				liege = {
					has_relation_rival = root
				}
			}

			opinion_modifier = { # Opinion Factor
				who = root.liege
				opinion_target = root
				multiplier = -0.8
			}
			
			opinion_modifier = { # Opinion Factor
				who = scope:brb_highest_title_man
				opinion_target = root
				multiplier = 0.8
			}
			
			modifier = {
				add = 20
				root = {
					has_trait = vengeful
				}
			}
			
			modifier = {
				add = -20
				root.current_military_strength > root.liege.current_military_strength
				scope:recipient = {
					has_trait = craven
				}
			}
			
			modifier = {
				add = 20
				ai_honor > 0
			}
			
			modifier = {
				add = 30
				ai_vengefulness > medium_positive_ai_value
			}

			modifier = {
				add = -15
				liege = {
					has_dread_level_towards = {
						target = root
						level = 1
					}
				}
			}
			
			modifier = {
				add = -15
				liege = {
					has_dread_level_towards = {
						target = root
						level = 2
					}
				}
			}
			
			modifier = { #Comparative military strength.
				add = {
					value = 1
					subtract = {
						value = root.liege.current_military_strength
						divide = { value = root.current_military_strength min = 1 }
					}
					multiply = 50
					max = 20
				}
			}
		}
	}
	option = {
		name = brb.4.b
	}
}