# TO DO - uncomment drayd limiter and remove existing one from conquest CB when and if brokilon is split in multiple kingdoms 

pogrom = { # Usable against nearby non-human counties, convert province, if have a claim grab county of otherwise just loot
	name = CB_NAME_POGROM
	war_name = WAR_NAME_POGROM
	sprite = 21
	truce_days = 3650
	hostile_against_others = yes
	can_ask_to_join_war = no
	is_permanent = yes
	check_all_titles = yes
	
	allowed_to_target_tributaries = no
	
	can_use_gui = {
		ROOT = {
			OR = {
				NOT = { same_realm = FROM }
				AND = {
					crownlaw_title = { has_law = tolerance_1 }
					trait = racist
				}
				crownlaw_title = { has_law = tolerance_2 }
			}
		}
	}
	
	can_use = {
		FROM = { 
			NOT = { culture = wilderness }
			OR = {
				trait = elf_race
				trait = dwarf_race
				trait = halfelf_race
				trait = halfdwarf_race
				trait = halfling_race
				trait = halfhalfling_race
				trait = gnome_race
				trait = halfgnome_race
			}
		}
		ROOT = {
			NOT = { culture = wilderness }
			trait = human_race
		}
	}
	
	can_use_title = {
		# OR = {
			# location = { NOT = { terrain = dryad_forest } }
			# ROOT = { trait = dryad_race }
		# }
		tier = count
		holder_scope = {
			OR = {
				character = FROM
				is_liege_or_above = FROM
			}
			OR = {
				trait = elf_race
				trait = dwarf_race
				trait = halfelf_race
				trait = halfdwarf_race
				trait = halfling_race
				trait = halfhalfling_race
				trait = gnome_race
				trait = halfgnome_race
			}
		}
		# The attacker needs at least one county in the target kingdom, or a border, or be only two sea zones away from one of your counties
		any_direct_de_jure_vassal_title = {
			OR = {
				holder_scope = {
					OR = {
						character = ROOT
						is_liege_or_above = ROOT
					}
				}
				location = {
					any_neighbor_province = {
						OR = {
							AND = {
								has_owner = yes
								owner = {
									OR = {
										character = ROOT
										is_liege_or_above = ROOT
									}
								}
							}
							any_neighbor_province = {
								OR = {
									AND = {
										has_owner = yes
										owner = {
											OR = {
												character = ROOT
												is_liege_or_above = ROOT
											}
										}
									}
									AND = {
										is_land = no
										any_neighbor_province = {
											owner = {
												OR = {
													character = ROOT
													is_liege_or_above = ROOT
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
	
	is_valid = {
		FROM = {
			OR = {
				trait = elf_race
				trait = dwarf_race
				trait = halfelf_race
				trait = halfdwarf_race
				trait = halfling_race
				trait = halfhalfling_race
				trait = gnome_race
				trait = halfgnome_race
			}
		}
	}
	
	is_valid_title = {
		OR = {
			FROM = {
				has_landed_title = PREV
			}
			holder_scope = {
				is_liege_or_above = FROM
				OR = {
					trait = elf_race
					trait = dwarf_race
					trait = halfelf_race
					trait = halfdwarf_race
					trait = halfling_race
					trait = halfhalfling_race
					trait = gnome_race
					trait = halfgnome_race
				}
			}
		}
	}
	
	on_success_title = {
		if = {
			limit = {
				ROOT = { 
					has_claim = PREV
				}
			}
			usurp_title_plus_barony_if_unlanded = ROOT
		}
		if = {
			limit = {
				ROOT = { 
					NOT = { has_claim = PREV }
				}
			}
			create_character = {
			    female = no
				random_traits = yes
				religion = ROOT
				culture = ROOT
				age = 30
			}
			new_character = {
			    usurp_title_plus_barony_if_unlanded = PREV
				set_defacto_liege = ROOT
			}
			FROM = { transfer_scaled_wealth = { to = ROOT value = 2.0 } }
		}
		location = {
			province_event = { id = conversion.4 }
		}
		any_attacker = {
			limit = { character = ROOT }
			participation_scaled_prestige = 100
		}
		any_attacker = {
			limit = { NOT = { character = ROOT } }
			hidden_tooltip = { participation_scaled_prestige = 100 }
		}
		
		FROM = {
			prestige = -100
		}
	}

	on_fail_title = {
		ROOT = {
			prestige = -100
		}
		any_defender = {
			limit = { character = FROM }
			participation_scaled_prestige = 100
		}
		any_defender = {
			limit = { NOT = { character = FROM } }
			hidden_tooltip = { participation_scaled_prestige = 100 }
		}
	}

	on_reverse_demand_title = {
		ROOT = {
			prestige = -150
			transfer_scaled_wealth = {
				to = FROM
				value = 4.0
			}
		}
		any_defender = {
			limit = { character = FROM }
			participation_scaled_prestige = 150
		}
		any_defender = {
			limit = { NOT = { character = FROM } }
			hidden_tooltip = { participation_scaled_prestige = 150 }
		}
	}
	
	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 }
	
	ai_will_do = {
		factor = 1
		modifier = { factor = 0 ROOT = { NOT = { trait = racist } } }
		modifier = { factor = 0 ROOT = { trait = tolerant } }
		modifier = { factor = 2 ROOT = { religion = eternal_fire } }
		modifier = { factor = 1.2 ROOT = { trait = cruel } }
		modifier = { factor = 1.2 ROOT = { trait = impaler } }
		modifier = { factor = 1.2 ROOT = { trait = envious } }
		modifier = { factor = 1.2 ROOT = { trait = greedy } }
		modifier = { factor = 1.5 ROOT = { trait = ambitious } }
		modifier = { factor = 0.5 ROOT = { trait = content } }
		modifier = { factor = 0.7 ROOT = { trait = kind } }
		modifier = { factor = 0.7 ROOT = { trait = gregarious } }
		modifier = { factor = 0.3 ROOT = { tier = EMPEROR } }
		modifier = { factor = 0.7 ROOT = { tier = KING } }
	}
}

scoiatael_revolt = {
	name = CB_NAME_SCOIATAEL_REVOLT
	war_name = WAR_NAME_SCOIATAEL_REVOLT
	sprite = 24
	truce_days = 365
	hostile_against_others = yes
	is_permanent = no # Only triggered through scripting
	can_ask_to_join_war = no
	is_independence = yes
	
	can_use = {
		FROM = { NOT = { culture = wilderness } }
		ROOT = { NOT = { culture = wilderness } }
		ROOT = {
			primary_title = { temporary = yes } # Revolter or adventurer trigger
			war = no
			NOT = { is_liege_or_above = FROM }
		}
	}
	
	can_use_title = {
		tier = count
	}
	
	is_valid_title = {
		OR = {
			FROM = {
				has_landed_title = PREV
			}
			holder_scope = {
				is_liege_or_above = FROM
			}
		}
	}
	
	on_success_title = {
		usurp_title_plus_barony_if_unlanded = ROOT
		ROOT = { set_defacto_liege = ROOT }
		FROM = {
			prestige = -100
		}
		ROOT = { character_event = { id = scoiatael.100 } }
	}
	
	on_fail_title = {
		FROM = {
			prestige = 10
			hidden_tooltip = {
				opinion = {
					modifier = opinion_rebel_traitor 
					who = ROOT
					months = 1200
				}
			}
		}
		ROOT = { 
			imprison = FROM
			hidden_tooltip = {
				add_character_modifier = { 
					name = broken_spirit
					days = -1
				}
			}
		}
		capital_scope = {
			remove_province_modifier = scoiatael_presence
			any_neighbor_province = {
				remove_province_modifier = scoiatael_presence
			}
		}
	}
	
	on_reverse_demand_title = {
		FROM = {
			prestige = 20
			hidden_tooltip = {
				opinion = {
					modifier = opinion_rebel_traitor 
					who = ROOT
					months = 1200
				}
				add_character_modifier = { 
					name = crushed_revolt
					days = 3650
				}
			}
		}
		ROOT = {
			imprison = FROM 
			hidden_tooltip = {
				add_character_modifier = { 
					name = broken_spirit
					days = -1
				}
			}
		}
		capital_scope = {
			remove_province_modifier = scoiatael_presence
			any_neighbor_province = {
				remove_province_modifier = scoiatael_presence
			}
		}
	}
	
	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 }
}

change_tanistry_succession_law = {
	name = CB_NAME_TANISTRY_SUCCESSION_LAW
	war_name = WAR_NAME_TANISTRY_SUCCESSION_LAW
	sprite = 6
	truce_days = 3650
	can_call_allies = no
	can_ask_to_join_war = no
	major_revolt = yes
	
	can_use = {
		ROOT = {
			vassal_of = FROM
		}
	}
	
	is_valid = {
		ROOT = {
			OR = {
				liege = {
					character = PREV # either independent
				}
				liege = { 
					FROM = { 
						is_liege_or_above = PREV # or have shared liege
					}
				}
			}
		}
	}
	
	is_valid_title = {
		NOT = {
			has_law = succ_tanistry
		}
		OR = {
			tier = emperor
			tier = king
			is_primary_holder_title = yes
		}
	}
	
	on_success = {
		FROM = {
			hidden_tooltip = { disband_event_forces = faction_loyalists }
			any_demesne_title = { # All titles
				limit = {
					OR = {
						tier = king
						tier = emperor
					}
#					is_titular = no
					NOT = { has_law = crown_levy_0 }
				}
				if = {
					limit = { has_law = crown_levy_1 }
					add_law = crown_levy_0
				}
				if = {
					limit = { has_law = crown_levy_2 }
					add_law = crown_levy_1
				}
				if = {
					limit = { has_law = crown_levy_3 }
					add_law = crown_levy_2
				}
			}
			any_demesne_title = { # All titles
				limit = {
					OR = {
						tier = king
						tier = emperor
					}
#					is_titular = no
					NOT = { has_law = crown_authority_0 }
				}
				if = {
					limit = { has_law = crown_authority_1 }
					add_law = crown_authority_0
				}
				if = {
					limit = { has_law = crown_authority_2 }
					add_law = crown_authority_1
				}
				if = {
					limit = { has_law = crown_authority_3 }
					add_law = crown_authority_2
				}
				if = {
					limit = { has_law = crown_authority_4 }
					add_law = crown_authority_3
				}
			}
		}
		
		any_attacker = {
			limit = { character = ROOT }
			participation_scaled_prestige = 100
			hidden_tooltip = {
				disband_event_forces = faction_revolters
			}
		}
		any_attacker = {
			limit = { NOT = { character = ROOT } }
			hidden_tooltip = {
				participation_scaled_prestige = 100 
				disband_event_forces = faction_revolters
			}
		}
	}
	
	on_success_title = {
		succession_w_cooldown = tanistry
	}
	
	on_fail = {
		ROOT = {
			prestige = -100
		}
		any_defender = {
			limit = { character = FROM }
			participation_scaled_prestige = 50
		}
		any_defender = {
			limit = { NOT = { character = FROM } }
			hidden_tooltip = { participation_scaled_prestige = 50 }
		}
		
		hidden_tooltip = {
			any_attacker = {
				disband_event_forces = faction_revolters
				add_character_modifier = {
					name = faction_succ_tanistry_ultimatum_timer
					hidden = yes
					duration = 3650
				}
			}
		}
		FROM = { hidden_tooltip = { disband_event_forces = faction_loyalists } }
	}
	
	on_reverse_demand = {
		ROOT = {
			prestige = -200
			prisoner = FROM
		}
		any_defender = {
			limit = { character = FROM }
			participation_scaled_prestige = 100
		}
		any_defender = {
			limit = { NOT = { character = FROM } }
			hidden_tooltip = { participation_scaled_prestige = 100 }
		}
		
		hidden_tooltip = {
			any_attacker = {
				limit = { liege = { character = FROM } }
				prisoner = FROM
				disband_event_forces = faction_revolters
				add_character_modifier = {
					name = faction_succ_tanistry_ultimatum_timer
					hidden = yes
					duration = 3650
				}
			}
		}
		
		FROM = { hidden_tooltip = { disband_event_forces = faction_loyalists } }
	}
	
	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 }
}

change_ultimogeniture_succession_law = {
	name = CB_NAME_ULTIMOGENITURE_SUCCESSION_LAW
	war_name = WAR_NAME_ULTIMOGENITURE_SUCCESSION_LAW
	sprite = 6
	truce_days = 3650
	can_call_allies = no
	can_ask_to_join_war = no
	major_revolt = yes
	
	can_use = {
		ROOT = {
			vassal_of = FROM
		}
	}
	
	is_valid = {
		ROOT = {
			OR = {
				liege = {
					character = PREV # either independent
				}
				liege = { 
					FROM = { 
						is_liege_or_above = PREV # or have shared liege
					}
				}
			}
		}
	}
	
	is_valid_title = {
		NOT = {
			has_law = succ_ultimogeniture
		}
		OR = {
			tier = emperor
			tier = king
			is_primary_holder_title = yes
		}
	}
	
	
	on_success = {
		FROM = {
			hidden_tooltip = { disband_event_forces = faction_loyalists }
			any_demesne_title = { # All titles
				limit = {
					OR = {
						tier = king
						tier = emperor
					}
#					is_titular = no
					NOT = { has_law = crown_levy_0 }
				}
				if = {
					limit = { has_law = crown_levy_1 }
					add_law = crown_levy_0
				}
				if = {
					limit = { has_law = crown_levy_2 }
					add_law = crown_levy_1
				}
				if = {
					limit = { has_law = crown_levy_3 }
					add_law = crown_levy_2
				}
			}
			any_demesne_title = { # All titles
				limit = {
					OR = {
						tier = king
						tier = emperor
					}
#					is_titular = no
					NOT = { has_law = crown_authority_0 }
				}
				if = {
					limit = { has_law = crown_authority_1 }
					add_law = crown_authority_0
				}
				if = {
					limit = { has_law = crown_authority_2 }
					add_law = crown_authority_1
				}
				if = {
					limit = { has_law = crown_authority_3 }
					add_law = crown_authority_2
				}
				if = {
					limit = { has_law = crown_authority_4 }
					add_law = crown_authority_3
				}
			}
		}
		
		any_attacker = {
			limit = { character = ROOT }
			participation_scaled_prestige = 100
			hidden_tooltip = {
				disband_event_forces = faction_revolters
			}
		}
		any_attacker = {
			limit = { NOT = { character = ROOT } }
			hidden_tooltip = {
				participation_scaled_prestige = 100 
				disband_event_forces = faction_revolters
			}
		}
	}
	
	on_success_title = {
		succession_w_cooldown = ultimogeniture
	}
	
	on_fail = {
		ROOT = {
			prestige = -100
		}
		any_defender = {
			limit = { character = FROM }
			participation_scaled_prestige = 50
		}
		any_defender = {
			limit = { NOT = { character = FROM } }
			hidden_tooltip = { participation_scaled_prestige = 50 }
		}
		
		hidden_tooltip = {
			any_attacker = {
				disband_event_forces = faction_revolters
				add_character_modifier = {
					name = faction_succ_ultimogeniture_ultimatum_timer
					hidden = yes
					duration = 3650
				}
			}
		}
		
		FROM = { hidden_tooltip = { disband_event_forces = faction_loyalists } }
	}
	
	on_reverse_demand = {
		ROOT = {
			prestige = -200
			prisoner = FROM
		}
		any_defender = {
			limit = { character = FROM }
			participation_scaled_prestige = 100
		}
		any_defender = {
			limit = { NOT = { character = FROM } }
			hidden_tooltip = { participation_scaled_prestige = 100 }
		}
		
		hidden_tooltip = {
			any_attacker = {
				limit = { liege = { character = FROM } }
				prisoner = FROM
				disband_event_forces = faction_revolters
				add_character_modifier = {
					name = faction_succ_ultimogeniture_ultimatum_timer
					hidden = yes
					duration = 3650
				}
			}
		}
		
		FROM = { hidden_tooltip = { disband_event_forces = faction_loyalists } }
	}
	
	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 }
}

nilfgaard_invasion = { # Usable by Nilfgaard against Northern kingdoms
	name = CB_NAME_NILFGAARD_INVASION
	war_name = WAR_NAME_NILFGAARD_INVASION
	sprite = 27
	truce_days = 3650
	hostile_against_others = yes
	is_permanent = yes
	check_de_jure_tier = KING # this scans all de jure kingdoms for the counties which are held by or vassals(or below) of selected character. Only valid if is_permanent = yes
	can_ask_to_join_war = no
	
	infamy_modifier = 2
	
	allowed_to_target_tributaries = no
	
	can_use = {
		FROM = { NOT = { culture = wilderness } }
		ROOT = { NOT = { culture = wilderness } }
		e_nilfgaard = {
			OR = {
				has_law = imperial_authority_2
				has_law = imperial_authority_3
			}
		}
		ROOT = {
			has_landed_title = e_nilfgaard
			NOT = { is_liege_or_above = FROM }
		}
		FROM = {
			culture_group = northern_group
		}
	}
	
	can_use_title = {
		# OR = {
			# location = { NOT = { terrain = dryad_forest } }
			# ROOT = { trait = dryad_race }
		# }
		# The attacker needs at least one county in the target kingdom, or a border, or be only two sea zones away from one of your counties
		any_direct_de_jure_vassal_title = {
			any_direct_de_jure_vassal_title = {
				OR = {
					holder_scope = {
						OR = {
							character = ROOT
							is_liege_or_above = ROOT
						}
					}
					location = {
						any_neighbor_province = {
							OR = {
								AND = {
									has_owner = yes
									owner = {
										OR = {
											character = ROOT
											is_liege_or_above = ROOT
										}
									}
								}
								AND = {
									is_land = no
									any_neighbor_province = {
										OR = {
											AND = {
												has_owner = yes
												owner = {
													OR = {
														character = ROOT
														is_liege_or_above = ROOT
													}
												}
											}
											AND = {
												is_land = no
												any_neighbor_province = {
													AND = {
														has_owner = yes
														owner = {
															OR = {
																character = ROOT
																is_liege_or_above = ROOT
															}
														}
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
	
	is_valid_title = {
		FROM = {
			any_realm_title = {
				de_jure_liege_or_above = PREVPREV
			}
		}
	}
	
	on_add = {
		FROM = { narrative_event = { id = nilfgaard.100 } }
	}
	
	on_success = {
		ROOT = {
			prestige = 200
		}
		any_attacker = {
			limit = { character = ROOT }
			participation_scaled_prestige = 200
		}
		any_attacker = {
			limit = { NOT = { character = ROOT } }
			hidden_tooltip = { participation_scaled_prestige = 200 }
		}
		FROM = {
			prestige = -200
			opinion = { modifier = opinion_invaded who = ROOT }
		}
		ROOT = {
			if = {
				limit = { has_character_flag = obj_expand_by_conquest_taken }
				set_character_flag = obj_expand_by_conquest_succeeded
			}
		}
	}
	
	on_success_title = {
		# Usurp the target kingdom, if the enemy holds it
		if = {
			limit = { holder_scope = { character = FROM } }
			custom_tooltip = {
				text = nilfgaard_invasion_succ_tip_1
				hidden_tooltip = {
					ROOT = { usurp_title = PREV }
				}
			}
		}
		custom_tooltip = {
			text = nilfgaard_invasion_succ_tip_2
			hidden_tooltip = {
				# Usurp the enemy's titles within target kingdom
				FROM = {
					any_demesne_title = {
						limit = { de_jure_liege_or_above = PREVPREV }
						ROOT = { usurp_title = PREV }
					}
				}
				# Vassalize all the target kingdom's direct de jure vassals
				any_de_jure_vassal_title = {
					limit = { holder_scope = { liege = { character = FROM } } }
					holder_scope = { set_defacto_liege = ROOT }
				}
				# Take all occupied titles
				ROOT = { gain_all_occupied_titles = FROM }
			}
		}
		# Fire event, if you usurped the target kingdom from enemy
		if = {
			limit = { holder_scope = { character = ROOT } }
			hidden_tooltip = {
				ROOT = {
					random_realm_province = {
						limit = { de_jure_liege_or_above = PREVPREV }
						province_event = { id = nilfgaard.110 }
					}
				}
			}
		}
	}
	
	on_fail = {
		FROM = {
			prestige = 100
		}
		any_defender = {
			limit = { character = FROM }
			participation_scaled_prestige = 100
		}
		any_defender = {
			limit = { NOT = { character = FROM } }
			hidden_tooltip = { participation_scaled_prestige = 100 }
		}
		ROOT = {
			prestige = -200
		}
	}
	
	on_reverse_demand = {
		ROOT = {
			prestige = -200
			transfer_scaled_wealth = {
				to = FROM
				value = 4.0
			}
		}
		FROM = {
			prestige = 200
		}
		any_defender = {
			limit = { character = FROM }
			participation_scaled_prestige = 200
		}
		any_defender = {
			limit = { NOT = { character = FROM } }
			hidden_tooltip = { participation_scaled_prestige = 200 }
		}
	}
	
	attacker_ai_victory_worth = { factor = 200 }
	attacker_ai_defeat_worth = { factor = 100 }
	defender_ai_victory_worth = { factor = -1 } # always accept
	defender_ai_defeat_worth = { factor = 100 }
	
	ai_will_do = { 
		factor = 1
		modifier = { factor = 0 ROOT = { trait = content } }
		modifier = { factor = 2.5 ROOT = { trait = ambitious } }
		modifier = { factor = 1.5 ROOT = { trait = greedy } }
		modifier = { factor = 1.5 ROOT = { trait = wroth } }
		modifier = { factor = 0.01 any_independent_ruler = { culture_group = southern_group } }
		modifier = { factor = 0.1 ROOT = { war = yes } }
		modifier = { factor = 0.01 FROM = { war = yes } }
		modifier = { factor = 5 FROM = { has_regent = yes} }
		modifier = { factor = 1.5 FROM = { NOT = { piety = 0 } } }
		modifier = { factor = 1.5 FROM = { NOT = { prestige = 0 } } }
		modifier = { factor = 2 FROM = { NOT = { wealth = 0 } } }
		modifier = { factor = 1.5 FROM = { NOT = { realm_martial = 10 } } }
		modifier = { factor = 1.2 FROM = { NOT = { realm_martial = 15 } } }
		modifier = { factor = 0.8 FROM = { realm_martial = 20 } }
		modifier = { factor = 0.8 FROM = { realm_martial = 25 } }
		modifier = { factor = 0.8 FROM = { realm_martial = 30 } }
		# modifier = { factor = 0.1 FROM = { job_mage = { trait = sorcerer } } }
		modifier = { factor = 0.01 ROOT = { relative_power = { who = FROM power = 3 } } }
		modifier = { factor = 0.05 ROOT = { relative_power = { who = FROM power = 2 } } }
		modifier = { factor = 0.1 ROOT = { relative_power = { who = FROM power = 1 } } }
		modifier = { factor = 0.5 ROOT = { relative_power = { who = FROM power = 0.5 } } }
		modifier = { factor = 0.5 ROOT = { relative_power = { who = FROM power = 0.1 } } }
	}
}

nilfgaard_reconquest = { # Usable by Nilfgaard against Southern kingdoms
	name = CB_NAME_NILFGAARD_RECONQUEST
	war_name = WAR_NAME_NILFGAARD_RECONQUEST
	sprite = 23
	truce_days = 3650
	hostile_against_others = yes
	is_permanent = yes
	check_de_jure_tier = KING # this scans all de jure kingdoms for the counties which are held by or vassals(or below) of selected character. Only valid if is_permanent = yes
	can_ask_to_join_war = no
	
	allowed_to_target_tributaries = no
	
	can_use = {
		FROM = { NOT = { culture = wilderness } }
		ROOT = { NOT = { culture = wilderness } }
		e_nilfgaard = {
			OR = {
				has_law = imperial_authority_1
				has_law = imperial_authority_2
				has_law = imperial_authority_3
			}
		}
		ROOT = {
			has_landed_title = e_nilfgaard
			NOT = { is_liege_or_above = FROM }
		}
		FROM ={
			OR ={
				culture_group = southern_group
				culture_group = nilfgaardian_group
			}
		}
	}
	
	is_valid_title = {
		FROM = {
			any_realm_title = {
				de_jure_liege_or_above = PREVPREV
			}
		}
	}
	
	on_success = {
		ROOT = {
			prestige = 200
		}
		any_attacker = {
			limit = { character = ROOT }
			participation_scaled_prestige = 200
		}
		any_attacker = {
			limit = { NOT = { character = ROOT } }
			hidden_tooltip = { participation_scaled_prestige = 200 }
		}
		FROM = {
			prestige = -200
			opinion = { modifier = opinion_conquered who = ROOT }
		}
		ROOT = {
			if = {
				limit = { has_character_flag = obj_expand_by_conquest_taken }
				set_character_flag = obj_expand_by_conquest_succeeded
			}
		}
	}
	
	on_success_title = {
		custom_tooltip = {
			text = nilfgaard_reconquest_succ_tip
			hidden_tooltip = {
				usurp_title = ROOT
			}
		}
	}
	
	on_fail = {
		FROM = {
			prestige = 100
		}
		any_defender = {
			limit = { character = FROM }
			participation_scaled_prestige = 100
		}
		any_defender = {
			limit = { NOT = { character = FROM } }
			hidden_tooltip = { participation_scaled_prestige = 100 }
		}
		ROOT = {
			prestige = -200
		}
	}
	
	on_reverse_demand = {
		ROOT = {
			prestige = -200
			transfer_scaled_wealth = {
				to = FROM
				value = 4.0
			}
		}
		FROM = {
			prestige = 200
		}
		any_defender = {
			limit = { character = FROM }
			participation_scaled_prestige = 200
		}
		any_defender = {
			limit = { NOT = { character = FROM } }
			hidden_tooltip = { participation_scaled_prestige = 200 }
		}
	}
	
	attacker_ai_victory_worth = { factor = 200 }
	attacker_ai_defeat_worth = { factor = 100 }
	defender_ai_victory_worth = { factor = -1 } # always accept
	defender_ai_defeat_worth = { factor = 100 }
	
	ai_will_do = { 
		factor = 1
		modifier = { factor = 2.5 ROOT = { trait = ambitious } }
		modifier = { factor = 1.5 ROOT = { trait = greedy } }
		modifier = { factor = 1.5 ROOT = { trait = wroth } }
	}
}

lower_crown_levy_law = {
	name = CB_NAME_LOWER_CROWN_LEVY_LAW
	war_name = WAR_NAME_LOWER_CROWN_LEVY_LAW
	sprite = 6
	truce_days = 3650
	can_call_allies = no
	can_ask_to_join_war = no
	major_revolt = yes
	
	can_use = {
		ROOT = {
			vassal_of = FROM
		}
	}
	
	can_use_title = {
		holder_scope = { independent = yes }
		OR = {
			tier = king
			tier = emperor
		}
		OR = {
			has_law = crown_levy_2
			has_law = crown_levy_3
		}
	}
	
	is_valid = {
		FROM = {
			in_revolt = no
			liege_before_war = {
				in_revolt = no
				liege_before_war = {
					in_revolt = no
				}
			}
		}
		ROOT = {
			OR = {
				liege = {
					character = PREV # either independent
				}
				liege = { 
					FROM = { 
						is_liege_or_above = PREV # or have shared liege
					}
				}
			}
		}
	}

	on_success = {
		ROOT = {
			opinion = {
				modifier = opinion_lowered_crown_levy
				who = FROM
				months = 12
			}
		}
		any_attacker = {
			limit = { character = ROOT }
			participation_scaled_prestige = 100
			hidden_tooltip = {
				disband_event_forces = faction_revolters
			}
		}
		any_attacker = {
			limit = { NOT = { character = ROOT } }
			hidden_tooltip = { participation_scaled_prestige = 100 }
			hidden_tooltip = {
				disband_event_forces = faction_revolters
			}
		}
		FROM = { hidden_tooltip = { disband_event_forces = faction_loyalists } }
	}

	on_success_title = {
		if = {
			limit = { has_law = crown_levy_2 }
			add_law_w_cooldown = crown_levy_1
		}
		if = {
			limit = { has_law = crown_levy_3 }
			add_law_w_cooldown = crown_levy_2
		}
	}

	on_fail = {
		ROOT = {
			prestige = -100
		}
		
		any_defender = {
			limit = { character = FROM }
			participation_scaled_prestige = 50
		}
		any_defender = {
			limit = { NOT = { character = FROM } }
			hidden_tooltip = { participation_scaled_prestige = 50 }
		}
		
		hidden_tooltip = {
			any_attacker = {
				disband_event_forces = faction_revolters
				add_character_modifier = {
					name = faction_lower_crown_levy_ultimatum_timer
					hidden = yes
					duration = 3650
				}
			}
		}
		FROM = { hidden_tooltip = { disband_event_forces = faction_loyalists } }
	}

	on_reverse_demand = {
		ROOT = {
			prestige = -200
			prisoner = FROM
		}
		
		any_defender = {
			limit = { character = FROM }
			participation_scaled_prestige = 100
		}
		any_defender = {
			limit = { NOT = { character = FROM } }
			hidden_tooltip = { participation_scaled_prestige = 100 }
		}
		
		hidden_tooltip = {
			any_attacker = {
				limit = { liege = { character = FROM } }
				prisoner = FROM
				disband_event_forces = faction_revolters
				add_character_modifier = {
					name = faction_lower_crown_levy_ultimatum_timer
					hidden = yes
					duration = 3650
				}
			}
		}
		FROM = { hidden_tooltip = { disband_event_forces = faction_loyalists } }
	}

	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
	}
}

lower_crown_obligation_law = {
	name = CB_NAME_LOWER_CROWN_OBLIGATION_LAW
	war_name = WAR_NAME_LOWER_CROWN_OBLIGATION_LAW
	sprite = 6
	truce_days = 3650
	can_call_allies = no
	can_ask_to_join_war = no
	major_revolt = yes
	
	can_use = {
		ROOT = {
			vassal_of = FROM
		}
	}
	
	can_use_title = {
		holder_scope = { independent = yes }
		OR = {
			tier = king
			tier = emperor
		}
		OR = {
			has_law = crown_authority_1
			has_law = crown_authority_2
			has_law = crown_authority_3
			has_law = crown_authority_4
		}
	}
	
	is_valid = {
		FROM = {
			in_revolt = no
			liege_before_war = {
				in_revolt = no
				liege_before_war = {
					in_revolt = no
				}
			}
		}
		ROOT = {
			OR = {
				liege = {
					character = PREV # either independent
				}
				liege = { 
					FROM = { 
						is_liege_or_above = PREV # or have shared liege
					}
				}
			}
		}
	}

	on_success = {
		ROOT = {
			opinion = {
				modifier = opinion_lowered_crown_obligation
				who = FROM
				months = 12
			}
		}
		any_attacker = {
			limit = { character = ROOT }
			participation_scaled_prestige = 100
			hidden_tooltip = {
				disband_event_forces = faction_revolters
			}
		}
		any_attacker = {
			limit = { NOT = { character = ROOT } }
			hidden_tooltip = { participation_scaled_prestige = 100 }
			hidden_tooltip = {
				disband_event_forces = faction_revolters
			}
		}
		FROM = { hidden_tooltip = { disband_event_forces = faction_loyalists } }
	}

	on_success_title = {
		if = {
			limit = { has_law = crown_authority_1 }
			add_law_w_cooldown = crown_authority_0
		}
		if = {
			limit = { has_law = crown_authority_2 }
			add_law_w_cooldown = crown_authority_1
		}
		if = {
			limit = { has_law = crown_authority_3 }
			add_law_w_cooldown = crown_authority_2
		}
		if = {
			limit = { has_law = crown_authority_4 }
			add_law_w_cooldown = crown_authority_3
		}
	}

	on_fail = {
		ROOT = {
			prestige = -100
		}
		
		any_defender = {
			limit = { character = FROM }
			participation_scaled_prestige = 50
		}
		any_defender = {
			limit = { NOT = { character = FROM } }
			hidden_tooltip = { participation_scaled_prestige = 50 }
		}
		
		hidden_tooltip = {
			any_attacker = {
				disband_event_forces = faction_revolters
				add_character_modifier = {
					name = faction_lower_crown_obligation_ultimatum_timer
					hidden = yes
					duration = 3650
				}
			}
		}
		FROM = { hidden_tooltip = { disband_event_forces = faction_loyalists } }
	}

	on_reverse_demand = {
		ROOT = {
			prestige = -200
			prisoner = FROM
		}
		
		any_defender = {
			limit = { character = FROM }
			participation_scaled_prestige = 100
		}
		any_defender = {
			limit = { NOT = { character = FROM } }
			hidden_tooltip = { participation_scaled_prestige = 100 }
		}
		
		hidden_tooltip = {
			any_attacker = {
				limit = { liege = { character = FROM } }
				prisoner = FROM
				disband_event_forces = faction_revolters
				add_character_modifier = {
					name = faction_lower_crown_obligation_ultimatum_timer
					hidden = yes
					duration = 3650
				}
			}
		}
		FROM = { hidden_tooltip = { disband_event_forces = faction_loyalists } }
	}

	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
	}
}

lower_tolerance_law = {
	name = CB_NAME_LOWER_TOLERANCE_LAW
	war_name = WAR_NAME_LOWER_TOLERANCE_LAW
	sprite = 6
	truce_days = 3650
	can_call_allies = no
	can_ask_to_join_war = no
	major_revolt = yes
	
	can_use = {
		ROOT = { vassal_of = FROM }
	}
	
	can_use_title = {
		holder_scope = { independent = yes }
		OR = {
			tier = king
			tier = emperor
		}
		OR = {
			has_law = tolerance_1
			has_law = tolerance_2
		}
	}
	
	is_valid = {
		ROOT = {
			OR = {
				liege = {
					character = PREV # either independent
				}
				liege = { 
					FROM = { 
						is_liege_or_above = PREV # or have shared liege
					}
				}
			}
		}
	}
	
	on_success = {
		ROOT = { opinion = { modifier = opinion_lowered_tolerance who = FROM months = 12 } }
		any_attacker = {
			limit = { character = ROOT }
			participation_scaled_prestige = 100
			hidden_tooltip = { disband_event_forces = faction_revolters }
		}
		any_attacker = {
			limit = { NOT = { character = ROOT } }
			hidden_tooltip = { participation_scaled_prestige = 100 }
			hidden_tooltip = { disband_event_forces = faction_revolters }
		}
		FROM = { hidden_tooltip = { disband_event_forces = faction_loyalists } }
	}
	
	on_success_title = {
		if = {
			limit = { has_law = tolerance_1 }
			add_law_w_cooldown = tolerance_0
		}
		if = {
			limit = { has_law = tolerance_2 }
			add_law_w_cooldown = tolerance_1
		}
	}
	
	on_fail = {
		ROOT = { prestige = -100 }
		any_defender = {
			limit = { character = FROM }
			participation_scaled_prestige = 50
		}
		any_defender = {
			limit = { NOT = { character = FROM } }
			hidden_tooltip = { participation_scaled_prestige = 50 }
		}
		hidden_tooltip = {
			any_attacker = {
				disband_event_forces = faction_revolters
				add_character_modifier = { name = faction_lower_or_raise_tolerance_ultimatum_timer hidden = yes duration = 3650 }
			}
		}
		FROM = { hidden_tooltip = { disband_event_forces = faction_loyalists } }
	}
	
	on_reverse_demand = {
		ROOT = { 
			prestige = -200
			prisoner = FROM
		}
		any_defender = {
			limit = { character = FROM }
			participation_scaled_prestige = 100
		}
		any_defender = {
			limit = { NOT = { character = FROM } }
			hidden_tooltip = { participation_scaled_prestige = 100 }
		}
		hidden_tooltip = {
			any_attacker = {
				limit = { liege = { character = FROM } }
				prisoner = FROM
				disband_event_forces = faction_revolters
				add_character_modifier = { name = faction_lower_or_raise_tolerance_ultimatum_timer hidden = yes duration = 3650 }
			}
		}
		FROM = { hidden_tooltip = { disband_event_forces = faction_loyalists } }
	}
	
	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 }
}

raise_tolerance_law = {
	name = CB_NAME_RAISE_TOLERANCE_LAW
	war_name = WAR_NAME_RAISE_TOLERANCE_LAW
	sprite = 6
	truce_days = 3650
	can_call_allies = no
	can_ask_to_join_war = no
	major_revolt = yes
	
	can_use = {
		ROOT = { 
			vassal_of = FROM
		}
	}
	
	can_use_title = {
		holder_scope = { independent = yes }
		OR = {
			tier = king
			tier = emperor
		}
		OR = {
			has_law = tolerance_0
			has_law = tolerance_1
		}
	}
	
	is_valid = {
		ROOT = {
			OR = {
				liege = {
					character = PREV # either independent
				}
				liege = { 
					FROM = { 
						is_liege_or_above = PREV # or have shared liege
					}
				}
			}
		}
	}
	
	on_success = {
		ROOT = { opinion = { modifier = opinion_raised_tolerance who = FROM months = 12 } }
		any_attacker = {
			limit = { character = ROOT }
			participation_scaled_prestige = 100
			hidden_tooltip = { disband_event_forces = faction_revolters }
		}
		any_attacker = {
			limit = { NOT = { character = ROOT } }
			hidden_tooltip = { participation_scaled_prestige = 100 }
			hidden_tooltip = { disband_event_forces = faction_revolters }
		}
		FROM = { hidden_tooltip = { disband_event_forces = faction_loyalists } }
	}
	
	on_success_title = {
		if = {
			limit = { has_law = tolerance_1 }
			add_law_w_cooldown = tolerance_2
		}
		if = {
			limit = { has_law = tolerance_0 }
			add_law_w_cooldown = tolerance_1
		}
	}
	
	on_fail = {
		ROOT = { prestige = -100 }
		any_defender = {
			limit = { character = FROM }
			participation_scaled_prestige = 50
		}
		any_defender = {
			limit = { NOT = { character = FROM } }
			hidden_tooltip = { participation_scaled_prestige = 50 }
		}
		hidden_tooltip = {
			any_attacker = {
				disband_event_forces = faction_revolters
				add_character_modifier = { name = faction_lower_or_raise_tolerance_ultimatum_timer hidden = yes duration = 3650 }
			}
		}
		FROM = { hidden_tooltip = { disband_event_forces = faction_loyalists } }
	}
	
	on_reverse_demand = {
		ROOT = { 
			prestige = -200
			prisoner = FROM
		}
		any_defender = {
			limit = { character = FROM }
			participation_scaled_prestige = 100
		}
		any_defender = {
			limit = { NOT = { character = FROM } }
			hidden_tooltip = { participation_scaled_prestige = 100 }
		}
		hidden_tooltip = {
			any_attacker = {
				limit = { liege = { character = FROM } }
				prisoner = FROM
				disband_event_forces = faction_revolters
				add_character_modifier = { name = faction_lower_or_raise_tolerance_ultimatum_timer hidden = yes duration = 3650 }
			}
		}
		FROM = { hidden_tooltip = { disband_event_forces = faction_loyalists } }
	}
	
	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 }
}

conquest = { # Usable once against nearby duchies when you take ambition
	name = CB_NAME_CONQUEST
	war_name = WAR_NAME_CONQUEST
	sprite = 7
	truce_days = 3650
	is_permanent = yes
	check_de_jure_tier = DUKE
	hostile_against_others = yes
	
	allowed_to_target_tributaries = no
	
	can_use = {
		FROM = { NOT = { culture = wilderness } }
		ROOT = { NOT = { culture = wilderness } }
		ROOT = {
			has_character_flag = obj_expand_by_conquest_taken
			NOT = { has_character_flag = obj_expand_by_conquest_succeeded }
			NOT = { has_character_flag = obj_expand_by_conquest_cb_used } # One-time CB
			NOT = { is_liege_or_above = FROM }
		}
	}
	
	on_add = {
		ROOT = {
			set_character_flag = obj_expand_by_conquest_cb_used
		}
	}
	
	can_use_title = {
		# OR = {
			# location = { NOT = { terrain = dryad_forest } }
			# ROOT = { trait = dryad_race }
		# }
		tier = duke
		any_direct_de_jure_vassal_title = { # The attacker a border or be only one sea zones away
			OR = {
				holder_scope = {
					OR = {
						character = ROOT
						is_liege_or_above = ROOT
					}
				}
				location = {
					any_neighbor_province = {
						OR = {
							AND = {
								has_owner = yes
								owner = {
									OR = {
										character = ROOT
										is_liege_or_above = ROOT
									}
								}
							}
							AND = {
								is_land = no
								any_neighbor_province = {
									OR = {
										AND = {
											has_owner = yes
											owner = {
												OR = {
													character = ROOT
													is_liege_or_above = ROOT
												}
											}
										}
										AND = {
											is_land = no
											any_neighbor_province = {
												owner = {
													OR = {
														character = ROOT
														is_liege_or_above = ROOT
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
	
	on_invalidation = {
		ROOT = {
			clr_character_flag = obj_expand_by_conquest_cb_used
		}
	}
	
	on_success = {
		ROOT = { prestige = 200 }
		any_attacker = {
			limit = { character = ROOT }
			participation_scaled_prestige = 200
		}
		any_attacker = {
			limit = { NOT = { character = ROOT } }
			hidden_tooltip = { participation_scaled_prestige = 200 }
		}
		FROM = { prestige = -200 }
		ROOT = {
			if = {
				limit = { 
					has_character_flag = obj_expand_by_conquest_taken
				}
				set_character_flag = obj_expand_by_conquest_succeeded
			}
		}
	}
	
	on_success_title = {
		custom_tooltip = {
			text = religious_cb_succ_tip
			hidden_tooltip = {
				ROOT = {
					vassalize_or_take_under_title_destroy_duchies = {
						title = PREV
						enemy = FROM
					}
				}
			}
		}
	}
	
	on_fail = {
		ROOT = { prestige = -200 }
		FROM = { prestige = 100 }
		any_defender = {
			limit = { character = FROM }
			participation_scaled_prestige = 100
		}
		any_defender = {
			limit = { NOT = { character = FROM } }
			hidden_tooltip = { participation_scaled_prestige = 100 }
		}
		ROOT = {
			clr_character_flag = obj_expand_by_conquest_cb_used
		}
	}
	
	on_reverse_demand = {
		ROOT = {
			prestige = -200
			transfer_scaled_wealth = { to = FROM value = 4.0 }
		}
		FROM = { prestige = 200 }
		any_defender = {
			limit = { character = FROM }
			participation_scaled_prestige = 200
		}
		any_defender = {
			limit = { NOT = { character = FROM } }
			hidden_tooltip = { participation_scaled_prestige = 200 }
		}
		ROOT = {
			clr_character_flag = obj_expand_by_conquest_cb_used
		}
	}
	
	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 }
	
	ai_will_do = {
		factor = 1
		modifier = { factor = 0.5 ROOT = { has_landed_title = e_nilfgaard } }
		modifier = { factor = 0.5 ROOT = { has_landed_title = e_hen_caerme } }
		modifier = { factor = 0.5 ROOT = { has_landed_title = e_dwarf_empire } }
		modifier = { factor = 0.5 ROOT = { has_landed_title = e_hakland } }
	}
}

elven_liberation = { # Usable against elven culture province with human top liege 
	name = CB_NAME_ELVEN_LIBERATION
	war_name = WAR_NAME_ELVEN_LIBERATION
	sprite = 25
	truce_days = 1825
	hostile_against_others = yes
	is_permanent = yes
	check_all_titles = yes # if permanent, setting this to true will check against all of someones titles, including vassal held titles
	can_ask_to_join_war = no
	
	allowed_to_target_tributaries = no
	
	can_use = {
		ROOT = {
			independent = yes
			OR = {
				trait = elf_race
				trait = scoiatael_leader
			}
			NOT = { is_liege_or_above = FROM }
		}
		FROM = { trait = human_race }
	}
	
	can_use_title = {
		tier = count
		OR = {
			holder_scope = { # Non-human title holder
				OR = {
					trait = elf_race
					AND = {
						trait = halfelf_race
						culture = aen_seidhe
					}
				}
			}
			culture = aen_seidhe # Non-human province
		}
		OR = {
			FROM = {
				has_landed_title = PREV
			}
			holder_scope = {
				is_liege_or_above = FROM
				NOT = { same_realm = ROOT }
			}
		}
		NOT = {
			OR = {
				ROOT = {
					has_landed_title = PREV
				}
				holder_scope = {
					is_liege_or_above = ROOT
				}
			}
		}
	}
	
	is_valid_title = {
		OR = {
			FROM = {
				has_landed_title = PREV
			}
			holder_scope = {
				is_liege_or_above = FROM
			}
		}
	}
	
	on_success_title = {
		if = {
			limit = {
				holder_scope = {
					trait = elf_race
					lower_tier_than = ROOT
				}
			}
			holder_scope = { set_defacto_liege = ROOT }
		}
		if = {
			limit = {
				holder_scope = {
					trait = elf_race
					ROOT = { tier = count }
				}
			}
			holder_scope = { set_defacto_liege = THIS }
		}
		if = {
			limit = {
				holder_scope = {
					NOT = { trait = elf_race }
				}
			}
			usurp_title_plus_barony_if_unlanded = ROOT
			any_de_jure_vassal_title = {
				limit = {
					has_holder = yes
					NOT = { de_facto_liege = PREV }
					holder_scope = {
						OR = {
							character = FROM
							is_liege_or_above = FROM
						}
					}
				}
				usurp_title_plus_barony_if_unlanded = ROOT
			}
		}
		any_attacker = {
			limit = { character = ROOT }
			participation_scaled_prestige = 100
		}
		any_attacker = {
			limit = { NOT = { character = ROOT } }
			hidden_tooltip = { participation_scaled_prestige = 100 }
		}
	}
	
	on_fail_title = {
		ROOT = {
			prestige = -100
		}
		any_defender = {
			limit = { character = FROM }
			participation_scaled_prestige = 50
		}
		any_defender = {
			limit = { NOT = { character = FROM } }
			hidden_tooltip = { participation_scaled_prestige = 50 }
		}
	}
	
	on_reverse_demand = {
		ROOT = {
			prestige = -200
			transfer_scaled_wealth = {
				to = FROM
				value = 4.0
			}
		}
		any_defender = {
			limit = { character = FROM }
			participation_scaled_prestige = 100
		}
		any_defender = {
			limit = { NOT = { character = FROM } }
			hidden_tooltip = { participation_scaled_prestige = 100 }
		}
	}
	
	attacker_ai_victory_worth = { factor = -1 }
	attacker_ai_defeat_worth = { factor = 100 }
	defender_ai_victory_worth = { factor = -1 }
	defender_ai_defeat_worth = { factor = 100 }
}

dwarven_liberation = { # Usable against dwarven culture province with human top liege 
	name = CB_NAME_DWARVEN_LIBERATION
	war_name = WAR_NAME_DWARVEN_LIBERATION
	sprite = 25
	truce_days = 1825
	hostile_against_others = yes
	is_permanent = yes
	check_all_titles = yes # if permanent, setting this to true will check against all of someones titles, including vassal held titles
	can_ask_to_join_war = no
	
	allowed_to_target_tributaries = no
	
	can_use = {
		ROOT = {
			independent = yes
			OR = {
				trait = dwarf_race
				trait = scoiatael_leader
			}
			NOT = { is_liege_or_above = FROM }
		}
		FROM = { trait = human_race }
	}
	
	can_use_title = {
		tier = count
		OR = {
			holder_scope = { # Non-human title holder
				OR = {
					trait = dwarf_race
					AND = {
						trait = halfdwarf_race
						culture = dwarven
					}
				}
			}
			culture = dwarven # Non-human province
		}
		OR = {
			FROM = {
				has_landed_title = PREV
			}
			holder_scope = {
				is_liege_or_above = FROM
				NOT = { same_realm = ROOT }
			}
		}
		NOT = {
			OR = {
				ROOT = {
					has_landed_title = PREV
				}
				holder_scope = {
					is_liege_or_above = ROOT
				}
			}
		}
	}
	
	is_valid_title = {
		OR = {
			FROM = {
				has_landed_title = PREV
			}
			holder_scope = {
				is_liege_or_above = FROM
			}
		}
	}
	
	on_success_title = {
		if = {
			limit = {
				holder_scope = {
					trait = dwarf_race
					lower_tier_than = ROOT
				}
			}
			holder_scope = { set_defacto_liege = ROOT }
		}
		if = {
			limit = {
				holder_scope = {
					trait = dwarf_race
					ROOT = { tier = count }
				}
			}
			holder_scope = { set_defacto_liege = THIS }
		}
		if = {
			limit = {
				holder_scope = {
					NOT = { trait = dwarf_race }
				}
			}
			usurp_title_plus_barony_if_unlanded = ROOT
			any_de_jure_vassal_title = {
				limit = {
					has_holder = yes
					NOT = { de_facto_liege = PREV }
					holder_scope = {
						OR = {
							character = FROM
							is_liege_or_above = FROM
						}
					}
				}
				usurp_title_plus_barony_if_unlanded = ROOT
			}
		}
		any_attacker = {
			limit = { character = ROOT }
			participation_scaled_prestige = 100
		}
		any_attacker = {
			limit = { NOT = { character = ROOT } }
			hidden_tooltip = { participation_scaled_prestige = 100 }
		}
	}
	
	on_fail_title = {
		ROOT = {
			prestige = -100
		}
		any_defender = {
			limit = { character = FROM }
			participation_scaled_prestige = 50
		}
		any_defender = {
			limit = { NOT = { character = FROM } }
			hidden_tooltip = { participation_scaled_prestige = 50 }
		}
	}
	
	on_reverse_demand = {
		ROOT = {
			prestige = -200
			transfer_scaled_wealth = {
				to = FROM
				value = 4.0
			}
		}
		any_defender = {
			limit = { character = FROM }
			participation_scaled_prestige = 100
		}
		any_defender = {
			limit = { NOT = { character = FROM } }
			hidden_tooltip = { participation_scaled_prestige = 100 }
		}
	}
	
	attacker_ai_victory_worth = { factor = -1 }
	attacker_ai_defeat_worth = { factor = 100 }
	defender_ai_victory_worth = { factor = -1 }
	defender_ai_defeat_worth = { factor = 100 }
}

gnomish_liberation = { # Usable against gnomish culture province with human top liege 
	name = CB_NAME_GNOMISH_LIBERATION
	war_name = WAR_NAME_GNOMISH_LIBERATION
	sprite = 25
	truce_days = 1825
	hostile_against_others = yes
	is_permanent = yes
	check_all_titles = yes # if permanent, setting this to true will check against all of someones titles, including vassal held titles
	can_ask_to_join_war = no
	
	allowed_to_target_tributaries = no
	
	can_use = {
		ROOT = {
			independent = yes
			OR = {
				trait = gnome_race
				trait = scoiatael_leader
			}
			NOT = { is_liege_or_above = FROM }
		}
		FROM = { trait = human_race }
	}
	
	can_use_title = {
		tier = count
		OR = {
			holder_scope = { # Non-human title holder
				OR = {
					trait = gnome_race
					AND = {
						trait = halfgnome_race
						culture = gnomish
					}
				}
			}
			culture = gnomish # Non-human province
		}
		OR = {
			FROM = {
				has_landed_title = PREV
			}
			holder_scope = {
				is_liege_or_above = FROM
				NOT = { same_realm = ROOT }
			}
		}
		NOT = {
			OR = {
				ROOT = {
					has_landed_title = PREV
				}
				holder_scope = {
					is_liege_or_above = ROOT
				}
			}
		}
	}
	
	is_valid_title = {
		OR = {
			FROM = {
				has_landed_title = PREV
			}
			holder_scope = {
				is_liege_or_above = FROM
			}
		}
	}
	
	on_success_title = {
		if = {
			limit = {
				holder_scope = {
					trait = gnome_race
					lower_tier_than = ROOT
				}
			}
			holder_scope = { set_defacto_liege = ROOT }
		}
		if = {
			limit = {
				holder_scope = {
					trait = gnome_race
					ROOT = { tier = count }
				}
			}
			holder_scope = { set_defacto_liege = THIS }
		}
		if = {
			limit = {
				holder_scope = {
					NOT = { trait = gnome_race }
				}
			}
			usurp_title_plus_barony_if_unlanded = ROOT
			any_de_jure_vassal_title = {
				limit = {
					has_holder = yes
					NOT = { de_facto_liege = PREV }
					holder_scope = {
						OR = {
							character = FROM
							is_liege_or_above = FROM
						}
					}
				}
				usurp_title_plus_barony_if_unlanded = ROOT
			}
		}
		any_attacker = {
			limit = { character = ROOT }
			participation_scaled_prestige = 100
		}
		any_attacker = {
			limit = { NOT = { character = ROOT } }
			hidden_tooltip = { participation_scaled_prestige = 100 }
		}
	}
	
	on_fail_title = {
		ROOT = {
			prestige = -100
		}
		any_defender = {
			limit = { character = FROM }
			participation_scaled_prestige = 50
		}
		any_defender = {
			limit = { NOT = { character = FROM } }
			hidden_tooltip = { participation_scaled_prestige = 50 }
		}
	}
	
	on_reverse_demand = {
		ROOT = {
			prestige = -200
			transfer_scaled_wealth = {
				to = FROM
				value = 4.0
			}
		}
		any_defender = {
			limit = { character = FROM }
			participation_scaled_prestige = 100
		}
		any_defender = {
			limit = { NOT = { character = FROM } }
			hidden_tooltip = { participation_scaled_prestige = 100 }
		}
	}
	
	attacker_ai_victory_worth = { factor = -1 }
	attacker_ai_defeat_worth = { factor = 100 }
	defender_ai_victory_worth = { factor = -1 }
	defender_ai_defeat_worth = { factor = 100 }
}

halfling_liberation = { # Usable against halfling culture province with human top liege 
	name = CB_NAME_HALFLING_LIBERATION
	war_name = WAR_NAME_HALFLING_LIBERATION
	sprite = 25
	truce_days = 1825
	hostile_against_others = yes
	is_permanent = yes
	check_all_titles = yes # if permanent, setting this to true will check against all of someones titles, including vassal held titles
	can_ask_to_join_war = no
	
	allowed_to_target_tributaries = no
	
	can_use = {
		ROOT = {
			independent = yes
			OR = {
				trait = halfling_race
				trait = scoiatael_leader
			}
			NOT = { is_liege_or_above = FROM }
		}
		FROM = { trait = human_race }
	}
	
	can_use_title = {
		tier = count
		OR = {
			holder_scope = { # Non-human title holder
				OR = {
					trait = halfling_race
					AND = {
						trait = halfhalfling_race
						culture = halfling
					}
				}
			}
			culture = halfling # Non-human province
		}
		OR = {
			FROM = {
				has_landed_title = PREV
			}
			holder_scope = {
				is_liege_or_above = FROM
				NOT = { same_realm = ROOT }
			}
		}
		NOT = {
			OR = {
				ROOT = {
					has_landed_title = PREV
				}
				holder_scope = {
					is_liege_or_above = ROOT
				}
			}
		}
	}
	
	is_valid_title = {
		OR = {
			FROM = {
				has_landed_title = PREV
			}
			holder_scope = {
				is_liege_or_above = FROM
			}
		}
	}
	
	on_success_title = {
		if = {
			limit = {
				holder_scope = {
					trait = halfling_race
					lower_tier_than = ROOT
				}
			}
			holder_scope = { set_defacto_liege = ROOT }
		}
		if = {
			limit = {
				holder_scope = {
					trait = halfling_race
					ROOT = { tier = count }
				}
			}
			holder_scope = { set_defacto_liege = THIS }
		}
		if = {
			limit = {
				holder_scope = {
					NOT = { trait = halfling_race }
				}
			}
			usurp_title_plus_barony_if_unlanded = ROOT
			any_de_jure_vassal_title = {
				limit = {
					has_holder = yes
					NOT = { de_facto_liege = PREV }
					holder_scope = {
						OR = {
							character = FROM
							is_liege_or_above = FROM
						}
					}
				}
				usurp_title_plus_barony_if_unlanded = ROOT
			}
		}
		any_attacker = {
			limit = { character = ROOT }
			participation_scaled_prestige = 100
		}
		any_attacker = {
			limit = { NOT = { character = ROOT } }
			hidden_tooltip = { participation_scaled_prestige = 100 }
		}
	}
	
	on_fail_title = {
		ROOT = {
			prestige = -100
		}
		any_defender = {
			limit = { character = FROM }
			participation_scaled_prestige = 50
		}
		any_defender = {
			limit = { NOT = { character = FROM } }
			hidden_tooltip = { participation_scaled_prestige = 50 }
		}
	}
	
	on_reverse_demand = {
		ROOT = {
			prestige = -200
			transfer_scaled_wealth = {
				to = FROM
				value = 4.0
			}
		}
		any_defender = {
			limit = { character = FROM }
			participation_scaled_prestige = 100
		}
		any_defender = {
			limit = { NOT = { character = FROM } }
			hidden_tooltip = { participation_scaled_prestige = 100 }
		}
	}
	
	attacker_ai_victory_worth = { factor = -1 }
	attacker_ai_defeat_worth = { factor = 100 }
	defender_ai_victory_worth = { factor = -1 }
	defender_ai_defeat_worth = { factor = 100 }
}

reclamation = { # Usable by elven and dwarven empires
	name = CB_NAME_RECLAMATION
	war_name = WAR_NAME_RECLAMATION
	sprite = 17
	truce_days = 3650
	hostile_against_others = yes
	is_permanent = yes
	check_de_jure_tier = DUKE # this scans all de jure kingdoms for the counties which are held by or vassals(or below) of selected character. Only valid if is_permanent = yes
	
	allowed_to_target_tributaries = no
	
	can_use = {
		ROOT = {
			NOT = { culture = wilderness }
			independent = yes
			OR = {
				culture = aen_seidhe
				culture = dwarven
				culture = gnomish
				culture = halfling
			}
			NOT = { same_realm = FROM }
		}
		FROM = {
			NOT = { culture = wilderness }
			NOR = {
				culture = aen_seidhe
				culture = dwarven
				culture = gnomish
				culture = halfling
			}
		}
	}
	
	can_use_title = {
		# The attacker needs at least one county in the target kingdom, or a border, or be only two sea zones away from one of your counties
		any_direct_de_jure_vassal_title = {
			OR = {
				holder_scope = {
					OR = {
						character = ROOT
						is_liege_or_above = ROOT
					}
				}
				location = {
					any_neighbor_province = {
						OR = {
							AND = {
								has_owner = yes
								owner = {
									OR = {
										character = ROOT
										is_liege_or_above = ROOT
									}
								}
							}
							AND = {
								is_land = no
								any_neighbor_province = {
									OR = {
										AND = {
											has_owner = yes
											owner = {
												OR = {
													character = ROOT
													is_liege_or_above = ROOT
												}
											}
										}
										AND = {
											is_land = no
											any_neighbor_province = {
												owner = {
													OR = {
														character = ROOT
														is_liege_or_above = ROOT
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
	
	is_valid = {
		ROOT = {
			NOT = { same_realm = FROM }
		}
	}
	
	on_success = {
		ROOT = {
			prestige = 100
		}
		any_attacker = {
			limit = { character = ROOT }
			participation_scaled_prestige = 100
		}
		any_attacker = {
			limit = { NOT = { character = ROOT } }
			hidden_tooltip = { participation_scaled_prestige = 100 }
		}
		FROM = {
			prestige = -100
		}
		ROOT = {
			if = {
				limit = { has_character_flag = obj_expand_by_conquest_taken }
				set_character_flag = obj_expand_by_conquest_succeeded
			}
		}
	}
	
	on_success_title = {
		custom_tooltip = { 
			text = religious_cb_succ_tip
			hidden_tooltip = {
				ROOT = {
					vassalize_or_take_under_title = {
						title = PREV
						enemy = FROM
						same_religion = yes # Only vassalize rulers of my religion
					}
				}
			}
		}
		if = {
			limit = { holder_scope = { character = FROM } }
			usurp_title_only = ROOT
		}
	}
	
	on_fail = {
		FROM = {
			prestige = 50
		}
		any_defender = {
			limit = { character = FROM }
			participation_scaled_prestige = 50
		}
		any_defender = {
			limit = { NOT = { character = FROM } }
			hidden_tooltip = { participation_scaled_prestige = 50 }
		}
		ROOT = {
			prestige = -100
		}
	}
	
	on_reverse_demand = {
		ROOT = {
			prestige = -100
			transfer_scaled_wealth = {
				to = FROM
				value = 4.0
			}
		}
		FROM = {
			prestige = 100
		}
		any_defender = {
			limit = { character = FROM }
			participation_scaled_prestige = 100
		}
		any_defender = {
			limit = { NOT = { character = FROM } }
			hidden_tooltip = { 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 }
}

claim_lormark = { # Special version of normal claim for Assassin of Kings bookmark that will call storyline events
	name = CB_NAME_CLAIM
	war_name = WAR_NAME_CLAIM
	sprite = 1
	truce_days = 3650
	hostile_against_others = yes
	can_ask_to_join_war = no
	is_permanent = no # Only usable via scripting
	
	press_claim = yes
	
	allowed_to_target_tributaries = no
	
	is_valid_title = {
		OR = {
			FROM = {
				has_landed_title = PREV
			}
			holder_scope = {
				is_liege_or_above = FROM
			}
		}
		ROOT = { has_claim = PREV }
	}
	
	on_success_title = {  # Attacker wins
		log = "(AoK) claim_lormark on_success_title"
		usurp_title_plus_barony_if_unlanded = ROOT
		
		if = {
			limit = {
				higher_tier_than = BARON
				NOT = { culture = ROOT }
			}
			hidden_tooltip = { conquest_culture = ROOT }
		}
		
		any_attacker = {
			limit = { character = ROOT }
			participation_scaled_prestige = 100
		}
		any_attacker = {
			limit = { NOT = { character = ROOT } }
			hidden_tooltip = { participation_scaled_prestige = 100 }
		}
		
		FROM = {
			prestige = -100
		}
		
		hidden_tooltip = {
			ROOT = {
				clr_character_flag = claimant_adventurer
			}
		}
		hidden_tooltip = {
			any_attacker = {
				limit = { has_character_flag = aok_henselt }
				narrative_event = { id = aok.1100 }
			}
			any_defender = {
				limit = { has_character_flag = aok_stennis }
				narrative_event = { id = aok.1103 }
			}
		}
	}
	
	on_fail_title = { # Attacker white peaces out
		log = "(AoK) claim_lormark on_fail_title"
		# Workaround bug causing d_upper_aedirn to be vassalized by k_kaedwen
		d_upper_aedirn = {
			set_defacto_liege = THIS
		}
		ROOT = {
			prestige = -100
			hidden_tooltip = {
				disband_event_forces = yes
				clr_character_flag = claimant_adventurer
			}
		}
		any_defender = {
			limit = { character = FROM }
			participation_scaled_prestige = 100
		}
		any_defender = {
			limit = { NOT = { character = FROM } }
			hidden_tooltip = { participation_scaled_prestige = 100 }
		}
		hidden_tooltip = {
			any_attacker = {
				limit = { has_character_flag = aok_henselt }
				narrative_event = { id = aok.1110 }
			}
			if = {
				limit = { 
					most_participating_defender = { has_character_flag = aok_saskia }
				}
				any_defender = {
					limit = { has_character_flag = aok_saskia }
					narrative_event = { id = aok.1111 }
					character_event = { id = aok.1120 days = 1 }
				}
				any_defender = {
					limit = { has_character_flag = aok_stennis }
					narrative_event = { id = aok.1112 }
				}
			}
			if = {
				limit = { 
					most_participating_defender = { has_character_flag = aok_stennis }
				}
				any_defender = {
					limit = { has_character_flag = aok_saskia }
					narrative_event = { id = aok.1113 }
					character_event = { id = aok.1120 days = 1 }
				}
				any_defender = {
					limit = { has_character_flag = aok_stennis }
					narrative_event = { id = aok.1114 }
				}
			}
		}
	}
	
	on_reverse_demand = { # Attacker looses
		log = "(AoK) claim_lormark on_reverse_demand"
		# Workaround bug causing d_upper_aedirn to be vassalized by k_kaedwen
		d_upper_aedirn = {
			set_defacto_liege = THIS
		}
		ROOT = {
			prestige = -150
			transfer_scaled_wealth = {
				to = FROM
				value = 4.0
			}
		}
		if = {
			limit = {
				ROOT = { has_character_flag = claimant_adventurer }
			}
			ROOT = { imprison = FROM }
		}
		any_defender = {
			limit = { character = FROM }
			participation_scaled_prestige = 150
		}
		any_defender = {
			limit = { NOT = { character = FROM } }
			hidden_tooltip = { participation_scaled_prestige = 150 }
		}
		hidden_tooltip = {
			any_attacker = {
				limit = { has_character_flag = aok_henselt }
				narrative_event = { id = aok.1110 }
			}
			if = {
				limit = { most_participating_defender = { has_character_flag = aok_saskia } }
				any_defender = {
					limit = { has_character_flag = aok_saskia }
					narrative_event = { id = aok.1111 }
					character_event = { id = aok.1120 days = 1 }
				}
				any_defender = {
					limit = { has_character_flag = aok_stennis }
					narrative_event = { id = aok.1112 }
				}
			}
			if = {
				limit = { most_participating_defender = { has_character_flag = aok_stennis } }
				any_defender = {
					limit = { has_character_flag = aok_saskia }
					narrative_event = { id = aok.1113 }
					character_event = { id = aok.1120 days = 1 }
				}
				any_defender = {
					limit = { has_character_flag = aok_stennis }
					narrative_event = { id = aok.1114 }
				}
			}
		}
	}

	on_reverse_demand_title = {
		ROOT = {
			remove_claim = PREV
			hidden_tooltip = {
				disband_event_forces = yes
				clr_character_flag = claimant_adventurer
			}
		}
	}
	
	on_attacker_leader_death = {
		if = {
			limit = {
				ROOT = { has_character_flag = claimant_adventurer }
			}
			ROOT = {
				hidden_tooltip = {
					disband_event_forces = yes
					clr_character_flag = claimant_adventurer
				}
			}
			end_war = invalid
		}
	}
	
	on_invalidation = {
		log = "(AoK) claim_lormark on_invalidation"
		any_defender = {
			limit = { has_character_flag = aok_saskia }
			character_event = { id = aok.1120 days = 1 }
		}
	}
	
	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
	}
}

#haak_invasion
#border_conflict