	# change_seniority_succession_law
# change_primogeniture_succession_law
# change_feudal_elective_succession_law
# change_gavelkind_succession_law
# lower_crown_authority_law
# lower_tribal_organization_law
# increase_council_power_war
# cb_faction_independence
# cb_install_antiking

# 7 - Disabled in CK2Plus
change_seniority_succession_law = {
	name = CB_NAME_SENIORITY_SUCCESSION_LAW
	war_name = WAR_NAME_SENIORITY_SUCCESSION_LAW
	sprite = 6
	truce_days = 3650

	attacker_can_call_allies = no
	can_ask_to_join_war = no
	major_revolt = yes
	is_permanent = no # Disabled in CK2Plus

	can_use_gui = {
		check_if_crusader_trigger = yes
	}

	can_use = {
		always = no # Disabled in CK2Plus

		ROOT = {
			vassal_of = FROM
		}
	}

	is_valid = {
		# Attacker
		ROOT = {
			liege_before_war = { character = FROM }
		}

		# Defender
		FROM = {
			in_revolt = no

			liege_before_war = {
				in_revolt = no

				liege_before_war = {
					in_revolt = no
				}
			}
		}
	}

	is_valid_title = {
		OR = {
			higher_real_tier_than = DUKE
			is_primary_holder_title = yes
		}

		NOT = { has_law = succ_seniority }
	}

	on_add = {
		fire_haruspicy_event_effect = yes
		anger_china_effect = yes
	}

	on_success = {
		attacker = {
			show_scope_change = no

			participation_scaled_prestige = 100
			hidden_effect = { disband_event_forces = faction_revolters }
		}

		any_attacker = {
			limit = { NOT = { character = attacker } }

			hidden_effect = {
				participation_scaled_prestige = 100
				disband_event_forces = faction_revolters
			}
		}

		defender = {
			show_scope_change = no

			hidden_effect = { disband_event_forces = faction_loyalists }

			if = { # lower crown authority
				limit = { NOT = { has_dlc = "Conclave" } }

				any_demesne_title = { # All titles
					limit = { is_crown_law_title = yes }

					set_title_flag = non_manual_law_change # No prestige loss

					trigger_switch = {
						on_trigger = has_law

						crown_authority_1 = { add_law = crown_authority_0 }
						crown_authority_2 = { add_law = crown_authority_1 }
						crown_authority_3 = { add_law = crown_authority_2 }
						crown_authority_4 = { add_law = crown_authority_3 }
					}

					clr_title_flag = non_manual_law_change # No prestige loss
				}
			}
		}
	}

	on_success_title = {
		succession_w_cooldown = seniority
	}

	on_fail = {
		attacker = {
			show_scope_change = no

			prestige = -100
		}

		any_attacker = {
			hidden_effect = {
				disband_event_forces = faction_revolters

				add_character_modifier = {
					name = faction_succ_seniority_ultimatum_timer
					years = 10
					hidden = yes
				}
			}
		}

		defender = {
			show_scope_change = no

			participation_scaled_prestige = 50
			hidden_effect = { disband_event_forces = faction_loyalists }
		}

		any_defender = {
			limit = { NOT = { character = defender } }
			hidden_effect = { participation_scaled_prestige = 50 }
		}
	}

	on_reverse_demand = {
		attacker = {
			show_scope_change = no

			prestige = -200
			imprison = defender
		}

		any_attacker = {
			limit = { vassal_of = defender }

			hidden_effect = {
				imprison = defender
				disband_event_forces = faction_revolters

				add_character_modifier = {
					name = faction_succ_seniority_ultimatum_timer
					years = 10
					hidden = yes
				}
			}
		}

		defender = {
			show_scope_change = no

			participation_scaled_prestige = 100

			hidden_effect = {
				disband_event_forces = faction_loyalists

				if = {
					limit = {
						NOT = {
							has_opinion_modifier = { # Allow free revocation of a title
								name = opinion_traitor
								who = attacker
							}
						}
					}

					opinion = {
						name = opinion_traitor
						who = attacker
					}
				}
			}
		}

		any_defender = {
			limit = { NOT = { character = defender } }
			hidden_effect = { participation_scaled_prestige = 100 }
		}
	}

	attacker_ai_victory_worth = {
		factor = -1 # always accept
	}

	attacker_ai_defeat_worth = {
		factor = 100
	}

	defender_ai_victory_worth = {
		factor = -1 # always accept
	}

	defender_ai_defeat_worth = {
		factor = 100
	}
}

# 8 - Disabled in CK2Plus
change_primogeniture_succession_law = {
	name = CB_NAME_PRIMOGENITURE_SUCCESSION_LAW
	war_name = WAR_NAME_PRIOGENITURE_SUCCESSION_LAW
	sprite = 6
	truce_days = 3650

	attacker_can_call_allies = no
	can_ask_to_join_war = no
	major_revolt = yes
	is_permanent = no # Disabled in CK2Plus

	can_use_gui = {
		check_if_crusader_trigger = yes
	}

	can_use = {
		always = no # Disabled in CK2Plus

		ROOT = {
			vassal_of = FROM
		}
	}

	is_valid = {
		# Attacker
		ROOT = {
			liege_before_war = { character = FROM }
		}

		# Defender
		FROM = {
			in_revolt = no

			liege_before_war = {
				in_revolt = no

				liege_before_war = {
					in_revolt = no
				}
			}
		}
	}

	is_valid_title = {
		OR = {
			higher_real_tier_than = DUKE
			is_primary_holder_title = yes
		}

		NOT = { has_law = succ_primogeniture }
	}

	on_add = {
		fire_haruspicy_event_effect = yes
		anger_china_effect = yes
	}

	on_success = {
		attacker = {
			show_scope_change = no

			participation_scaled_prestige = 100
			hidden_effect = { disband_event_forces = faction_revolters }
		}

		any_attacker = {
			limit = { NOT = { character = attacker } }

			hidden_effect = {
				participation_scaled_prestige = 100
				disband_event_forces = faction_revolters
			}
		}

		defender = {
			show_scope_change = no

			hidden_effect = { disband_event_forces = faction_loyalists }

			if = { # lower crown authority
				limit = { NOT = { has_dlc = "Conclave" } }

				any_demesne_title = { # All titles
					limit = { is_crown_law_title = yes }

					set_title_flag = non_manual_law_change # No prestige loss

					trigger_switch = {
						on_trigger = has_law

						crown_authority_1 = { add_law = crown_authority_0 }
						crown_authority_2 = { add_law = crown_authority_1 }
						crown_authority_3 = { add_law = crown_authority_2 }
						crown_authority_4 = { add_law = crown_authority_3 }
					}

					clr_title_flag = non_manual_law_change # No prestige loss
				}
			}
		}
	}

	on_success_title = {
		succession_w_cooldown = primogeniture
	}

	on_fail = {
		attacker = {
			show_scope_change = no

			prestige = -100
		}

		any_attacker = {
			hidden_effect = {
				disband_event_forces = faction_revolters

				add_character_modifier = {
					name = faction_succ_primogeniture_ultimatum_timer
					years = 10
					hidden = yes
				}
			}
		}

		defender = {
			show_scope_change = no

			participation_scaled_prestige = 50
			hidden_effect = { disband_event_forces = faction_loyalists }
		}

		any_defender = {
			limit = { NOT = { character = defender } }
			hidden_effect = { participation_scaled_prestige = 50 }
		}
	}

	on_reverse_demand = {
		attacker = {
			show_scope_change = no

			prestige = -200
			imprison = defender
		}

		any_attacker = {
			limit = { vassal_of = defender }

			hidden_effect = {
				imprison = defender
				disband_event_forces = faction_revolters

				add_character_modifier = {
					name = faction_succ_primogeniture_ultimatum_timer
					years = 10
					hidden = yes
				}
			}
		}

		defender = {
			show_scope_change = no

			participation_scaled_prestige = 100

			hidden_effect = {
				disband_event_forces = faction_loyalists

				if = { # Allow free revocation of a title
					limit = {
						NOT = {
							has_opinion_modifier = {
								name = opinion_traitor
								who = attacker
							}
						}
					}

					opinion = {
						name = opinion_traitor
						who = attacker
					}
				}
			}
		}

		any_defender = {
			limit = { NOT = { character = defender } }
			hidden_effect = { participation_scaled_prestige = 100 }
		}
	}

	attacker_ai_victory_worth = {
		factor = -1 # always accept
	}

	attacker_ai_defeat_worth = {
		factor = 100
	}

	defender_ai_victory_worth = {
		factor = -1 # always accept
	}

	defender_ai_defeat_worth = {
		factor = 100
	}
}

# 9 - Disabled in CK2Plus
change_feudal_elective_succession_law = {
	name = CB_NAME_FEUDAL_ELECTIVE_SUCCESSION_LAW
	war_name = WAR_NAME_FEUDAL_ELECTIVE_SUCCESSION_LAW
	sprite = 6
	truce_days = 3650

	attacker_can_call_allies = no
	can_ask_to_join_war = no
	major_revolt = yes
	is_permanent = no # Disabled in CK2Plus

	can_use = {
		always = no # Disabled in CK2Plus

		ROOT = {
			vassal_of = FROM
		}
	}

	can_use_gui = {
		check_if_crusader_trigger = yes
	}

	is_valid = {
		# Attacker
		ROOT = {
			liege_before_war = { character = FROM }
		}

		# Defender
		FROM = {
			in_revolt = no

			liege_before_war = {
				in_revolt = no

				liege_before_war = {
					in_revolt = no
				}
			}
		}
	}

	is_valid_title = {
		OR = {
			higher_real_tier_than = DUKE
			is_primary_holder_title = yes
		}

		NOR = {
			has_law = succ_feudal_elective
			has_law = succ_hre_elective
		}
	}

	on_success = {
		attacker = {
			show_scope_change = no

			participation_scaled_prestige = 100
			hidden_effect = { disband_event_forces = faction_revolters }
		}

		any_attacker = {
			limit = { NOT = { character = attacker } }

			hidden_effect = {
				participation_scaled_prestige = 100
				disband_event_forces = faction_revolters
			}
		}

		defender = {
			show_scope_change = no

			hidden_effect = { disband_event_forces = faction_loyalists }

			if = { # lower crown authority
				limit = { NOT = { has_dlc = "Conclave" } }

				any_demesne_title = { # All titles
					limit = { is_crown_law_title = yes }

					set_title_flag = non_manual_law_change # No prestige loss

					trigger_switch = {
						on_trigger = has_law

						crown_authority_1 = { add_law = crown_authority_0 }
						crown_authority_2 = { add_law = crown_authority_1 }
						crown_authority_3 = { add_law = crown_authority_2 }
						crown_authority_4 = { add_law = crown_authority_3 }
					}

					clr_title_flag = non_manual_law_change # No prestige loss
				}
			}
		}
	}

	on_success_title = {
		set_title_flag = non_manual_law_change # No prestige loss

		if = {
			limit = {
				OR = {
					title = e_hre
					has_title_flag = alternate_hre
				}
			}
			add_law_w_cooldown = succ_hre_elective
		}
		else = {
			add_law_w_cooldown = succ_feudal_elective
		}

		clr_title_flag = non_manual_law_change # No prestige loss
	}

	on_fail = {
		attacker = {
			show_scope_change = no

			prestige = -100
		}

		any_attacker = {
			hidden_effect = {
				disband_event_forces = faction_revolters

				add_character_modifier = {
					name = faction_succ_feudal_elective_ultimatum_timer
					years = 10
					hidden = yes
				}
			}
		}

		# Defenders
		defender = {
			show_scope_change = no

			participation_scaled_prestige = 50
			hidden_effect = { disband_event_forces = faction_loyalists }
		}

		any_defender = {
			limit = { NOT = { character = defender } }
			hidden_effect = { participation_scaled_prestige = 50 }
		}
	}

	on_reverse_demand = {
		attacker = {
			show_scope_change = no

			prestige = -200
			imprison = defender
		}

		any_attacker = {
			limit = { vassal_of = defender }

			hidden_effect = {
				imprison = defender
				disband_event_forces = faction_revolters

				add_character_modifier = {
					name = faction_succ_feudal_elective_ultimatum_timer
					years = 10
					hidden = yes
				}
			}
		}

		defender = {
			show_scope_change = no

			participation_scaled_prestige = 100

			hidden_effect = {
				disband_event_forces = faction_loyalists

				if = {
					limit = {
						NOT = {
							has_opinion_modifier = { # Allow free revocation of a title
								name = opinion_traitor
								who = attacker
							}
						}
					}

					opinion = {
						name = opinion_traitor
						who = attacker
					}
				}
			}
		}

		any_defender = {
			limit = { NOT = { character = defender } }
			hidden_effect = { participation_scaled_prestige = 100 }
		}
	}

	attacker_ai_victory_worth = {
		factor = -1 # always accept
	}

	attacker_ai_defeat_worth = {
		factor = 100
	}

	defender_ai_victory_worth = {
		factor = -1 # always accept
	}

	defender_ai_defeat_worth = {
		factor = 100
	}
}

# 20 - Disabled in CK2Plus
change_gavelkind_succession_law = {
	name = CB_NAME_GAVELKIND_SUCCESSION_LAW
	war_name = WAR_NAME_GAVELKIND_SUCCESSION_LAW
	sprite = 6
	truce_days = 3650

	attacker_can_call_allies = no
	can_ask_to_join_war = no
	major_revolt = yes
	is_permanent = no # Disabled in CK2Plus

	can_use_gui = {
		check_if_crusader_trigger = yes
	}

	can_use = {
		always = no # Disabled in CK2Plus

		# Attacker
		ROOT = {
			vassal_of = FROM
		}
	}

	is_valid = {
		# Attacker
		ROOT = {
			liege_before_war = {
				character = FROM
			}
		}

		# Defender
		FROM = {
			in_revolt = no

			liege_before_war = {
				in_revolt = no

				liege_before_war = {
					in_revolt = no
				}
			}
		}
	}

	is_valid_title = {
		OR = {
			higher_real_tier_than = DUKE
			is_primary_holder_title = yes
		}

		NOT = { has_law = succ_gavelkind }
	}

	on_add = {
		fire_haruspicy_event_effect = yes
		anger_china_effect = yes
	}

	on_success = {
		attacker = {
			show_scope_change = no

			participation_scaled_prestige = 100
			hidden_effect = { disband_event_forces = faction_revolters }
		}

		any_attacker = {
			limit = { NOT = { character = attacker } }

			hidden_effect = {
				participation_scaled_prestige = 100
				disband_event_forces = faction_revolters
			}
		}

		defender = {
			show_scope_change = no

			hidden_effect = { disband_event_forces = faction_loyalists }

			if = { # lower crown authority
				limit = { NOT = { has_dlc = "Conclave" } }

				any_demesne_title = {
					limit = { is_crown_law_title = yes }

					set_title_flag = non_manual_law_change # No prestige loss

					trigger_switch = {
						on_trigger = has_law

						crown_authority_1 = { add_law = crown_authority_0 }
						crown_authority_2 = { add_law = crown_authority_1 }
						crown_authority_3 = { add_law = crown_authority_2 }
						crown_authority_4 = { add_law = crown_authority_3 }
					}

					clr_title_flag = non_manual_law_change # No prestige loss
				}
			}
		}
	}

	on_success_title = {
		succession_w_cooldown = gavelkind
	}

	on_fail = {
		attacker = {
			show_scope_change = no

			prestige = -100
		}

		any_attacker = {
			hidden_effect = {
				disband_event_forces = faction_revolters

				add_character_modifier = {
					name = faction_succ_gavelkind_ultimatum_timer
					years = 10
					hidden = yes
				}
			}
		}

		defender = {
			show_scope_change = no

			participation_scaled_prestige = 50
			hidden_effect = { disband_event_forces = faction_loyalists }
		}

		any_defender = {
			limit = { NOT = { character = defender } }
			hidden_effect = { participation_scaled_prestige = 50 }
		}
	}

	on_reverse_demand = {
		attacker = {
			show_scope_change = no

			prestige = -200
			imprison = defender
		}

		any_attacker = {
			limit = { vassal_of = defender }

			hidden_effect = {
				imprison = defender
				disband_event_forces = faction_revolters

				add_character_modifier = {
					name = faction_succ_gavelkind_ultimatum_timer
					years = 10
					hidden = yes
				}
			}
		}

		defender = {
			show_scope_change = no

			participation_scaled_prestige = 100

			hidden_effect = {
				if = {
					limit = {
						NOT = {
							has_opinion_modifier = { # Allow free revocation of a title
								name = opinion_traitor
								who = attacker
							}
						}
					}

					opinion = {
						name = opinion_traitor
						who = attacker
					}
				}

				disband_event_forces = faction_loyalists
			}
		}

		any_defender = {
			limit = { NOT = { character = defender } }
			hidden_effect = { participation_scaled_prestige = 100 }
		}
	}

	attacker_ai_victory_worth = {
		factor = -1 # always accept
	}

	attacker_ai_defeat_worth = {
		factor = 100
	}

	defender_ai_victory_worth = {
		factor = -1 # always accept
	}

	defender_ai_defeat_worth = {
		factor = 100
	}
}

# 21 - Disabled in CK2Plus
lower_crown_authority_law = {
	name = CB_NAME_LOWER_CROWN_AUTHORITY_LAW
	war_name = WAR_NAME_LOWER_CROWN_AUTHORITY_LAW
	sprite = 6
	truce_days = 3650

	can_call_allies = no
	can_ask_to_join_war = no
	major_revolt = yes
	is_permanent = no # Disabled in CK2Plus

	can_use_gui = {
		check_if_crusader_trigger = yes
	}

	can_use = {
		always = no # Disabled in CK2Plus

		# Attacker
		ROOT = {
			vassal_of = FROM
		}

		NOT = { has_dlc = "Conclave" }
	}

	can_use_title = {
		is_crown_law_title = yes
		holder_scope = { independent = yes }

		OR = {
			has_law = crown_authority_1
			has_law = crown_authority_2
			has_law = crown_authority_3
			has_law = crown_authority_4
		}
	}

	is_valid = {
		# Attacker
		ROOT = {
			liege_before_war = {
				character = FROM
			}
		}

		# Defender
		FROM = {
			in_revolt = no

			liege_before_war = {
				in_revolt = no

				liege_before_war = {
					in_revolt = no
				}
			}
		}
	}

	on_add = {
		fire_haruspicy_event_effect = yes
		anger_china_effect = yes
	}

	on_success = {
		attacker = {
			show_scope_change = no

			participation_scaled_prestige = 100

			opinion = {
				name = opinion_lowered_crown_authority
				who = defender
				years = 1
			}

			hidden_effect = {
				disband_event_forces = faction_revolters
			}
		}

		any_attacker = {
			limit = { NOT = { character = attacker } }

			hidden_effect = {
				participation_scaled_prestige = 100
				disband_event_forces = faction_revolters
			}
		}

		defender = {
			hidden_effect = {
				disband_event_forces = faction_loyalists
			}
		}
	}

	on_success_title = {
		set_title_flag = non_manual_law_change # No prestige loss

		trigger_switch = { # lower crown authority
			on_trigger = has_law

			crown_authority_1 = { add_law_w_cooldown = crown_authority_0 }
			crown_authority_2 = { add_law_w_cooldown = crown_authority_1 }
			crown_authority_3 = { add_law_w_cooldown = crown_authority_2 }
			crown_authority_4 = { add_law_w_cooldown = crown_authority_3 }
		}

		clr_title_flag = non_manual_law_change # No prestige loss
	}

	on_fail = {
		attacker = {
			show_scope_change = no

			prestige = -100
		}

		any_attacker = {
			hidden_effect = {
				disband_event_forces = faction_revolters

				add_character_modifier = {
					name = faction_lower_CA_ultimatum_timer
					years = 10
					hidden = yes
				}
			}
		}

		defender = {
			show_scope_change = no

			participation_scaled_prestige = 50
			hidden_effect = { disband_event_forces = faction_loyalists }
		}

		any_defender = {
			limit = { NOT = { character = defender } }
			hidden_effect = { participation_scaled_prestige = 50 }
		}
	}

	on_reverse_demand = {
		attacker = {
			show_scope_change = no

			prestige = -200
			imprison = defender
		}

		any_attacker = {
			limit = { vassal_of = defender }

			hidden_effect = {
				imprison = defender
				disband_event_forces = faction_revolters

				add_character_modifier = {
					name = faction_lower_CA_ultimatum_timer
					years = 10
					hidden = yes
				}
			}
		}

		defender = {
			show_scope_change = no

			participation_scaled_prestige = 100

			hidden_effect = {
				disband_event_forces = faction_loyalists

				if = {
					limit = {
						NOT = {
							has_opinion_modifier = { # Allow free revocation of a title
								name = opinion_traitor
								who = attacker
							}
						}
					}

					opinion = {
						name = opinion_traitor
						who = attacker
					}
				}
			}
		}

		any_defender = {
			limit = { NOT = { character = defender } }
			hidden_effect = { participation_scaled_prestige = 100 }
		}
	}

	attacker_ai_victory_worth = {
		factor = -1 # always accept
	}

	attacker_ai_defeat_worth = {
		factor = 100
	}

	defender_ai_victory_worth = {
		factor = -1 # always accept
	}

	defender_ai_defeat_worth = {
		factor = 100
	}
}

# 22 - Disabled in CK2Plus
lower_tribal_organization_law = {
	name = CB_NAME_LOWER_TRIBAL_ORGANIZATION_LAW
	war_name = WAR_NAME_LOWER_TRIBAL_ORGANIZATION_LAW
	sprite = 6
	truce_days = 3650

	can_call_allies = no
	can_ask_to_join_war = no
	major_revolt = yes
	is_permanent = no # Disabled in CK2Plus

	can_use_gui = {
		check_if_crusader_trigger = yes
	}

	can_use = {
		always = no # Disabled in CK2Plus

		# Attacker
		ROOT = {
			vassal_of = FROM
		}
	}

	can_use_title = {
		holder_scope = { independent = yes }
		higher_real_tier_than = COUNT

		OR = {
			has_law = tribal_organization_1
			has_law = tribal_organization_2
			has_law = tribal_organization_3
			has_law = tribal_organization_4
		}
	}

	is_valid = {
		# Attacker
		ROOT = {
			liege_before_war = {
				character = FROM
			}
		}

		# Defender
		FROM = {
			is_tribal = yes
			in_revolt = no

			liege_before_war = {
				in_revolt = no

				liege_before_war = {
					in_revolt = no
				}
			}
		}
	}

	on_add = {
		fire_haruspicy_event_effect = yes
		anger_china_effect = yes
	}

	on_success = {
		attacker = {
			show_scope_change = no

			participation_scaled_prestige = 100

			opinion = {
				name = opinion_lowered_tribal_organization
				who = defender
				years = 1
			}

			hidden_effect = {
				disband_event_forces = faction_revolters
			}
		}

		any_attacker = {
			limit = { NOT = { character = attacker } }

			hidden_effect = {
				participation_scaled_prestige = 100
				disband_event_forces = faction_revolters
			}
		}

		defender = {
			hidden_effect = {
				disband_event_forces = faction_loyalists
			}
		}
	}

	on_success_title = {
		set_title_flag = non_manual_law_change # No prestige loss

		trigger_switch = { # lower tribal organization
			on_trigger = has_law

			tribal_organization_1 = { add_law_w_cooldown = tribal_organization_0 }
			tribal_organization_2 = { add_law_w_cooldown = tribal_organization_1 }
			tribal_organization_3 = { add_law_w_cooldown = tribal_organization_2 }
			tribal_organization_4 = { add_law_w_cooldown = tribal_organization_3 }
		}

		clr_title_flag = non_manual_law_change # No prestige loss
	}

	on_fail = {
		attacker = {
			show_scope_change = no

			prestige = -100
		}

		any_attacker = {
			hidden_effect = {
				disband_event_forces = faction_revolters

				add_character_modifier = {
					name = faction_lower_TO_ultimatum_timer
					years = 10
					hidden = yes
				}
			}
		}

		defender = {
			show_scope_change = no

			participation_scaled_prestige = 50
			hidden_effect = { disband_event_forces = faction_loyalists }
		}

		any_defender = {
			limit = { NOT = { character = defender } }
			hidden_effect = { participation_scaled_prestige = 50 }
		}
	}

	on_reverse_demand = {
		attacker = {
			show_scope_change = no

			prestige = -200
			imprison = defender
		}

		any_attacker = {
			limit = { vassal_of = defender }

			hidden_effect = {
				imprison = defender
				disband_event_forces = faction_revolters

				add_character_modifier = {
					name = faction_lower_TO_ultimatum_timer
					years = 10
					hidden = yes
				}
			}
		}

		defender = {
			show_scope_change = no

			participation_scaled_prestige = 100

			hidden_effect = {
				disband_event_forces = faction_loyalists

				if = {
					limit = {
						NOT = {
							has_opinion_modifier = { # Allow free revocation of a title
								name = opinion_traitor
								who = attacker
							}
						}
					}

					opinion = {
						name = opinion_traitor
						who = attacker
					}
				}
			}
		}

		any_defender = {
			limit = { NOT = { character = defender } }
			hidden_effect = { participation_scaled_prestige = 100 }
		}
	}

	attacker_ai_victory_worth = {
		factor = -1 # always accept
	}

	attacker_ai_defeat_worth = {
		factor = 100
	}

	defender_ai_victory_worth = {
		factor = -1 # always accept
	}

	defender_ai_defeat_worth = {
		factor = 100
	}
}

increase_council_power_war = {
	name = CB_NAME_INCREASE_COUNCIL_POWER
	war_name = WAR_NAME_INCREASE_COUNCIL_POWER
	sprite = 6
	truce_days = 3650

	can_call_allies = no
	can_ask_to_join_war = no
	major_revolt = yes

	can_use_gui = {
		check_if_crusader_trigger = yes
	}

	can_use = {
		# Attacker
		ROOT = {
			vassal_of = FROM
		}
	}

	can_use_title = {
		is_primary_holder_title = yes
		higher_real_tier_than = BARON

		OR = {
			has_law = law_voting_power_0
			has_law = banish_voting_power_0
			has_law = execution_voting_power_0
			has_law = revoke_title_voting_power_0
			has_law = grant_title_voting_power_0
			has_law = imprison_voting_power_0
			has_law = war_voting_power_0
		}
	}

	is_valid = {
		# Attacker
		ROOT = {
			liege_before_war = {
				character = FROM
			}
		}

		# Defender
		FROM = {
			in_revolt = no

			liege_before_war = {
				in_revolt = no

				liege_before_war = {
					in_revolt = no
				}
			}
		}
	}

	on_add = {
		fire_haruspicy_event_effect = yes
		anger_china_effect = yes
	}

	on_success = {
		attacker = {
			show_scope_change = no

			opinion = {
				name = opinion_increased_council_power
				who = defender
				years = 1
			}

			participation_scaled_prestige = 100
			hidden_effect = { disband_event_forces = faction_revolters }
		}

		any_attacker = {
			limit = { NOT = { character = attacker } }

			hidden_effect = {
				participation_scaled_prestige = 100
				disband_event_forces = faction_revolters
			}
		}

		defender = {
			hidden_effect = { disband_event_forces = faction_loyalists }
		}
	}

	on_success_title = {
		increase_council_power_effect = yes
		increase_vassal_freedom_effect = yes
	}

	on_fail = {
		attacker = {
			show_scope_change = no

			prestige = -100
		}

		any_attacker = {
			hidden_effect = {
				disband_event_forces = faction_revolters

				add_character_modifier = {
					name = faction_council_power_ultimatum_timer
					years = 10
					hidden = yes
				}
			}
		}

		defender = {
			show_scope_change = no

			participation_scaled_prestige = 50
			hidden_effect = { disband_event_forces = faction_loyalists }
		}

		any_defender = {
			limit = { NOT = { character = defender } }
			hidden_effect = { participation_scaled_prestige = 50 }
		}
	}

	on_reverse_demand = {
		attacker = {
			show_scope_change = no

			prestige = -200
			imprison = defender
		}

		any_attacker = {
			limit = { vassal_of = defender }

			hidden_effect = {
				imprison = defender
				disband_event_forces = faction_revolters

				add_character_modifier = {
					name = faction_council_power_ultimatum_timer
					years = 10
					hidden = yes
				}
			}
		}

		defender = {
			show_scope_change = no

			participation_scaled_prestige = 100

		#	hidden_effect = {
		#		disband_event_forces = faction_loyalists
		#		if = {
		#			limit = {
		#				NOT = {
		#					has_opinion_modifier = { # Allow free revocation of a title
		#						name = opinion_traitor
		#						who = attacker
		#					}
		#				}
		#			}
		#
		#			opinion = {
		#				name = opinion_traitor
		#				who = attacker
		#			}
		#		}
		#	}
		}

		any_defender = {
			limit = { NOT = { character = defender } }
			hidden_effect = { participation_scaled_prestige = 100 }
		}
	}

	attacker_ai_victory_worth = {
		factor = -1 # always accept
	}

	attacker_ai_defeat_worth = {
		factor = 100
	}

	defender_ai_victory_worth = {
		factor = -1 # always accept
	}

	defender_ai_defeat_worth = {
		factor = 100
	}
}

cb_faction_independence = {
	name = CB_NAME_INDEPENDENCE
	war_name = WAR_NAME_FACTION_INDEPENDENCE
	sprite = 12
	truce_days = 3650

	major_revolt = yes
	attacker_can_call_allies = no
	can_ask_to_join_war = no
	# is_independence = yes

	can_use_gui = {
		check_if_crusader_trigger = yes
	}

	can_use = {
		# Attacker
		ROOT = {
			vassal_of = FROM

			has_opinion_modifier = {
				name = revolting_against
				who = FROM
			}
		}
	}

	is_valid = {
		# Attacker
		ROOT = {
			liege_before_war = {
				character = FROM
			}

			has_opinion_modifier = {
				name = revolting_against
				who = FROM
			}
		}

		# Defender
		FROM = {
			independent = yes
			in_revolt = no

			# Need a proper title of at least equal tier to possibly have ROOT as a vassal at all
			any_demesne_title = {
				NOT = { lower_real_tier_than = ROOT }
				temporary = no
			}

			liege_before_war = {
				in_revolt = no

				liege_before_war = {
					in_revolt = no
				}
			}
		}
	}

	on_add = {
		fire_haruspicy_event_effect = yes
		anger_china_effect = yes

		# CK2Plus
		log = "CB(cb_faction_independence): START: [Root.GetTitledFirstName] of [Root.PrimaryTitle.GetBaseName] (ID: [Root.GetID]) vs. [From.GetTitledFirstName] of [From.PrimaryTitle.GetBaseName] (ID: [From.GetID])"

		FROM = { pf_log_state_effect = yes }
		ROOT = { pf_log_state_effect = yes }
	}

	on_success = {
		log = "CB(cb_faction_independence): VICTORY: [Root.GetTitledFirstName] of [Root.PrimaryTitle.GetBaseName] (ID: [Root.GetID]) vs. [From.GetTitledFirstName] of [From.PrimaryTitle.GetBaseName] (ID: [From.GetID])"

		# CK2Plus
		hidden_effect = {
			# Apply immediate effects to the revolters
			any_attacker = {
				limit = {
					has_opinion_modifier = {
						name = revolting_against
						who = FROM
					}
				}

				# and also are grateful to each other for their victory
				FROM = {
					any_opinion_modifier_target = {
						limit = {
							reverse_has_opinion_modifier = {
								name = revolting_against_me
								who = PREV
							}

							NOT = { character = PREVPREV }
						}

						reverse_opinion = {
							name = opinion_very_grateful
							who = PREVPREV
							years = 10
						}
					}
				}
			}
		}

		# revolters will become independent
		if = {
			limit = { FROM = { independent = yes } }

			FROM = {
				show_scope_change = no

				any_opinion_modifier_target = {
					show_scope_change = no

					limit = { pf_part_of_this_revolt_trigger = yes }

					set_defacto_liege = THIS

					hidden_effect = {
						prestige = 100

						reverse_opinion = {
							name = opinion_independent
							who = PREV
							years = 50
						}

						# Weakly held territories may declare independence
						any_vassal = {
							character_event = {
								id = Plus.430
								days = 3
							}
						}
					}
				}

				# Weakly held territories may declare independence
				any_vassal = {
					limit = { pf_part_of_this_revolt_trigger = no }

					character_event = {
						id = Plus.430
						days = 3
					}
				}
			}
		}

		hidden_tooltip = {
			any_attacker = {
				limit = {
					leads_faction = faction_separatist
					independent = yes
				}

				set_character_flag = former_faction_leader
				pf_clear_war_flags_effect = yes
			}

			any_attacker = {
				limit = {
					in_faction = faction_separatist
					independent = yes
				}

				pf_leave_faction_effect = yes
				pf_clear_war_flags_effect = yes
			}
		}

		# Clean up remaining TOMs
		pf_civil_war_cleanup_effect = yes

		attacker = {
			show_scope_change = no

			participation_scaled_prestige = 200
		}

		any_attacker = {
			limit = { NOT = { character = attacker } }
			hidden_effect = { participation_scaled_prestige = 200 }
		}

		defender = {
			show_scope_change = no

			prestige = -500

			# Check whether title will be destroyed (CK2Plus only)
			any_demesne_title = {
				limit = { can_destroy_title_trigger = yes }

				custom_tooltip = {
					text = TITLE_ENDANGERED_NO_NAME

					set_title_flag = destroy_title

					log = "[This.GetFullName] should be destroyed as a result of the revolt"
				}
			}

			# Always lower CA/TO, even if it wasn't a revolt demand
			pf_lower_CA_effect = yes # lower Crown Authority
			pf_lower_TO_effect = yes # lower Tribal Organization

			# Check whether the primary title should be destroyed due to CA loss
			if = {
				limit = {
					primary_title = {
						has_title_flag = destroy_title
					}
				}

				character_event = {
					id = Plus.1620 # Destroy title
					days = 4
				}
			}
		}

		# Change faction moods
		attacker = {
			character_event = {
				id = PlusFaction.200
				days = 1
			}
		}

		defender = {
			character_event = {
				id = PlusFaction.200
				days = 1
			}
		}

		hidden_effect = {
			check_if_reconquista_finished_effect = yes

			defender = {
				landless_pope_effect = yes
			}
		}
	}

	on_fail = {
		log = "CB(cb_faction_independence): WHITEPEACE: [Root.GetTitledFirstName] of [Root.PrimaryTitle.GetBaseName] (ID: [Root.GetID]) vs. [From.GetTitledFirstName] of [From.PrimaryTitle.GetBaseName] (ID: [From.GetID])"

		# Clean up remaining TOMs
		pf_civil_war_cleanup_effect = yes

		attacker = {
			show_scope_change = no

			prestige = -100

			hidden_effect = {
				add_character_modifier = {
					name = faction_independence_ultimatum_timer
					years = 10
					hidden = yes
				}
			}
		}

		any_attacker = {
			limit = { NOT = { character = attacker } }

			hidden_effect = {
				add_character_modifier = {
					name = faction_independence_ultimatum_timer
					years = 10
					hidden = yes
				}

				participation_scaled_prestige = -100
			}
		}

		defender = {
			hidden_effect = {
				remove_opinion = {
					name = declared_war
					who = ROOT
				}
			}
		}
	}

	on_reverse_demand = {
		log = "CB(cb_faction_independence): DEFEAT: [Root.GetTitledFirstName] of [Root.PrimaryTitle.GetBaseName] (ID: [Root.GetID]) vs. [From.GetTitledFirstName] of [From.PrimaryTitle.GetBaseName] (ID: [From.GetID])"

		# Apply immediate effects to the revolters
		any_attacker = {
			show_scope_change = no

			limit = {
				has_opinion_modifier = {
					name = revolting_against
					who = defender
				}
			}

			imprison = defender

			hidden_effect = {
				reverse_opinion = {
					name = opinion_civil_war_loser
					who = defender
					years = 5
				}

				opinion = {
					name = opinion_coerced_into_leaving_faction
					who = defender
					years = 5
				}
			}
		}

		# Mark loyalists and neutrals for the reward event
		hidden_effect = {
			defender = {
				# Remove any previously-existing loser TOMs
				pf_civil_war_clear_old_opinions_effect = yes

				any_vassal = {
					limit = {
						reverse_has_opinion_modifier = {
							name = pf_loyal_to_me
							who = PREV
						}
					}

					reverse_opinion = {
						name = opinion_civil_war_supporter
						who = PREV
						years = 5
					}
				}

				any_vassal = {
					limit = {
						reverse_has_opinion_modifier = {
							name = pf_neutral_to_me
							who = PREV
						}
					}

					reverse_opinion = {
						name = opinion_civil_war_neutral
						who = PREV
						years = 5
					}
				}
			}
		}

		# Clean up remaining civil war state
		pf_civil_war_cleanup_effect = yes

		attacker = {
			show_scope_change = no

			prestige = -200

			add_character_modifier = {
				name = faction_independence_ultimatum_timer
				years = 10
				hidden = yes
			}

			character_event = {
				id = PlusFaction.200 # Recalculate faction moods
				days = 1
			}
		}

		any_attacker = {
			limit = { NOT = { character = attacker } }

			hidden_effect = {
				participation_scaled_prestige = -200

				add_character_modifier = {
					name = faction_independence_ultimatum_timer
					years = 10
					hidden = yes
				}
			}
		}

		defender = {
			show_scope_change = no

			prestige = 200
			participation_scaled_prestige = 100

			# Post-civil war event to reward allies
			character_event = { id = PlusFaction.450 }

			character_event = {
				id = PlusFaction.200 # Recalculate faction moods
				days = 1
			}
		}

		any_defender = {
			limit = { NOT = { character = defender } }
			hidden_effect = { participation_scaled_prestige = 100 }
		}
	}

	on_invalidation = {
		log = "CB(cb_faction_independence): INVALIDATED: [Root.GetTitledFirstName] of [Root.PrimaryTitle.GetBaseName] (ID: [Root.GetID]) vs. [From.GetTitledFirstName] of [From.PrimaryTitle.GetBaseName] (ID: [From.GetID])"

		# Clean up remaining civil war state
		pf_civil_war_cleanup_effect = yes
	}

	on_attacker_leader_death = {
		any_defender = {
			letter_event = { id = 251 } # Our enemy has died, the war has ended
		}

		end_war = invalid
	}

	attacker_ai_victory_worth = {
		factor = -1 # always accept
	}

	attacker_ai_defeat_worth = {
		factor = 100
	}

	defender_ai_victory_worth = {
		factor = -1 # always accept
	}

	defender_ai_defeat_worth = {
		factor = 100
	}
}

cb_install_antiking = {
	name = CB_NAME_INSTALL_ANTIKING
	war_name = WAR_NAME_INSTALL_ANTIKING
	sprite = 11
	truce_days = 3650

	major_revolt = yes
	# attacker_can_call_allies = no
	attacker_rel_head_is_ally = yes # The attacker can call his (main) Pope into the war

	can_use_gui = {
		check_if_crusader_trigger = yes
	}

	can_use = {
		# Attacker
		ROOT = {
			OR = {
				religion = catholic
				religion = fraticelli
			}

			vassal_of = FROM
			religion = FROM
		}

		# CK2Plus
		# Defender
		FROM = {
			rightful_religious_head_scope = {
				is_vassal_or_below_of = PREV

				OR = {
					has_claim = k_papacy
					has_claim = d_fraticelli
				}
			}
		}
	}

	is_valid = {
		# Attacker
		ROOT = {
			OR = {
				religion = catholic
				religion = fraticelli
			}

			religion = FROM
			liege_before_war = { character = FROM }
		}

		# CK2Plus
		# Defender
		FROM = {
			rightful_religious_head_scope = {
				is_vassal_or_below_of = PREV

				OR = {
					has_claim = k_papacy
					has_claim = d_fraticelli
				}
			}
		}
	}

	is_valid_title = {
		NOT = { holder = ROOT }
	}

	on_add = {
		fire_haruspicy_event_effect = yes
		anger_china_effect = yes
	}

	on_success = {
		log = "[Root.GetBestName] (ID: [Root.GetID]) succeeded with [Root.GetHerHis] install antiking CB against [From.GetBestName] (ID: [From.GetID])"

		attacker = {
			show_scope_change = no

			participation_scaled_piety = 500
			participation_scaled_prestige = 250

			religion_authority = {
				name = deposed_antipope
				years = 50
			}

			rightful_religious_head_scope = {
				show_scope_change = no

				opinion = {
					name = opinion_deposed_antipope
					who = attacker
				}
			}
		}

		any_attacker = {
			limit = { NOT = { character = attacker } }

			hidden_effect = {
				participation_scaled_piety = 500
				participation_scaled_prestige = 250
			}
		}

		defender = {
			show_scope_change = no

			piety = -500
			prestige = -250

			rightful_religious_head_scope = {
				show_scope_change = no
				custom_tooltip = {
					text = ANTIPOPE_DEPOSED
					depose_antipope_effect = yes
				}
			}

			primary_title = {
				show_scope_change = no

				usurp_title = {
					target = attacker
					type = revolt
				}

				set_title_flag = non_manual_law_change # No prestige loss

				if = {
					limit = { has_law = investiture_law_1 }
					add_law_w_cooldown = investiture_law_0
				}

				clr_title_flag = non_manual_law_change # No prestige loss
			}
		}
	}

	on_fail = {
		attacker = {
			show_scope_change = no

			piety = -250
			prestige = -125
		}

		defender = {
			show_scope_change = no

			piety = 100
			prestige = 50
		}
	}

	on_reverse_demand = {
		attacker = {
			show_scope_change = no

			transfer_scaled_wealth = {
				to = defender
				value = 4.0
			}

			piety = -500
			prestige = -250
			imprison = defender
			pf_tradition_minus2_effect = yes
		}

		defender = {
			show_scope_change = no

			piety = 500
			prestige = 250
			pf_tradition_plus2_effect = yes

			hidden_effect = {
				if = {
					limit = {
						NOT = {
							has_opinion_modifier = {
								name = opinion_traitor
								who = attacker
							}
						}
					}

					opinion = { # Allow free revocation of a title
						name = opinion_traitor
						who = attacker
					}
				}
			}
		}
	}

	attacker_ai_victory_worth = {
		factor = -1 # always accept
	}

	attacker_ai_defeat_worth = {
		factor = 100
	}

	defender_ai_victory_worth = {
		factor = -1 # always accept
	}

	defender_ai_defeat_worth = {
		factor = 100
	}
}

powerful_vassal_takeover_war = {
	name = CB_NAME_POWERFUL_VASSAL_TAKEOVER
	war_name = WAR_NAME_POWERFUL_VASSAL_TAKEOVER
	sprite = 6
	truce_days = 3650

	can_call_allies = no
	can_ask_to_join_war = no
	major_revolt = yes

	can_use_gui = {
		check_if_crusader_trigger = yes
	}

	can_use = {
		# Attacker
		ROOT = {
			vassal_of = FROM
		}
	}

	can_use_title = {
		is_primary_holder_title = yes
		higher_real_tier_than = BARON
	}

	is_valid = {
		# Attacker
		ROOT = {
			liege_before_war = {
				character = FROM
			}
		}

		# Defender
		FROM = {
			has_character_flag = powerful_vassal_takeover_target
			in_revolt = no
		}
	}

	on_add = {
		fire_haruspicy_event_effect = yes
		anger_china_effect = yes
	}

	on_success = {
		# Attackers
		any_attacker = {
			participation_scaled_prestige = 100
			hidden_effect = { disband_event_forces = faction_revolters }
		}

		# Defender
		defender = {
			hidden_effect = { disband_event_forces = faction_loyalists }
		}
	}

	on_success_title = {
		set_title_flag = non_manual_law_change # No prestige loss

		if = {
			limit = { has_law = law_voting_power_0 }
			add_law_w_cooldown = law_voting_power_1
		}

		if = {
			limit = { has_law = war_voting_power_0 }
			add_law_w_cooldown = war_voting_power_1
		}

		if = {
			limit = {
				NOR = {
					has_law = succ_feudal_elective
					has_law = succ_hre_elective
					has_law = succ_byzantine_elective
				}
			}

			if = {
				limit = {
					OR = {
						title = e_hre
						has_title_flag = alternate_hre
					}
				}
				add_law_w_cooldown = succ_hre_elective
			}
			else_if = {
				limit = {
					OR = {
						title = e_byzantium
						title = e_roman_empire
						has_title_flag = alternate_byz
					}
				}
				add_law_w_cooldown = succ_byzantine_elective
			}
			else = {
				add_law_w_cooldown = succ_feudal_elective
			}
		}

		clr_title_flag = non_manual_law_change # No prestige loss

		holder_scope = {
			show_scope_change = no

			clr_character_flag = powerful_vassal_takeover_target

			most_popular_vassal = {
				limit = {
					higher_real_tier_than = BARON
					is_feudal = yes
					is_adult = yes
					prisoner = no
					is_inaccessible_trigger = yes
					is_incapable = no
					NOT = { trait = eunuch }

					trigger_if = {
						limit = { is_female = yes }
						attacker = { has_law = true_cognatic_succession }
					}
				}

				usurp_title = {
					target = PREVPREV
					type = faction_demand
				}

				save_event_target_as = new_title_holder

				hidden_effect = {
					any_attacker = {
						limit = { NOT = { character = PREV } }
						set_character_flag = helped_win_war
					}
				}

				character_event = {
					id = 8226 # Winning war notification - New title holder
					days = 1
				}
			}
		}

		hidden_effect = {
			check_if_reconquista_finished_effect = yes

			defender = {
				landless_pope_effect = yes
			}
		}
	}

	on_fail = {
		attacker = {
			show_scope_change = no

			prestige = -100
		}

		any_attacker = {
			hidden_effect = {
				disband_event_forces = faction_revolters

				add_character_modifier = {
					name = faction_powerful_vassal_takeover_ultimatum_timer
					years = 10
					hidden = yes
				}
			}
		}

		defender = {
			show_scope_change = no

			participation_scaled_prestige = 50

			hidden_effect = {
				disband_event_forces = faction_loyalists
				clr_character_flag = powerful_vassal_takeover_target
			}
		}

		any_defender = {
			limit = { NOT = { character = defender } }
			hidden_effect = { participation_scaled_prestige = 50 }
		}
	}

	on_reverse_demand = {
		attacker = {
			show_scope_change = no

			prestige = -200
			imprison = defender
		}

		any_attacker = {
			limit = { vassal_of = defender }

			hidden_effect = {
				imprison = defender
				disband_event_forces = faction_revolters

				add_character_modifier = {
					name = faction_powerful_vassal_takeover_ultimatum_timer
					years = 10
					hidden = yes
				}
			}
		}

		defender = {
			show_scope_change = no

			participation_scaled_prestige = 100

			hidden_effect = {
				disband_event_forces = faction_loyalists
				clr_character_flag = powerful_vassal_takeover_target

		#		if = {
		#			limit = {
		#				NOT = {
		#					has_opinion_modifier = { # Allow free revocation of a title
		#						name = opinion_traitor
		#						who = attacker
		#					}
		#				}
		#			}
		#
		#			opinion = {
		#				name = opinion_traitor
		#				who = attacker
		#			}
		#		}
			}
		}

		any_defender = {
			limit = { NOT = { character = defender } }
			hidden_effect = { participation_scaled_prestige = 100 }
		}
	}

	attacker_ai_victory_worth = {
		factor = -1 # always accept
	}

	attacker_ai_defeat_worth = {
		factor = 100
	}

	defender_ai_victory_worth = {
		factor = -1 # always accept
	}

	defender_ai_defeat_worth = {
		factor = 100
	}
}