###########################################
#                                         #
# Horse Lords Raiding Adventurers 		  #
#                                         #
# ID HL.100-HL.199      	              #
#                                         #
###########################################

# Written by Joel Hansson

namespace = HL

# An ambitious character with no inheritance begins to plan an adventure for a foreign title
character_event = {
	id = HL.100
	
	hide_window = yes # Only fires for unplayable landless characters
	
	min_age = 16
	max_age = 50
	only_men = yes
	capable_only = yes
	prisoner = no
	
	trigger = {
		has_dlc = "Horse Lords"
		has_global_flag = viking_age_started
		
		NOT = {
			has_game_rule = {
				name = adventurers
				value = none
			}
		}
		
		is_ruler = no
		is_allowed_to_loot = yes
		
		health = 4
		OR = {
			martial = 8
			trait = ambitious
			trait = possessed
		}
		calc_true_if = {
			amount = 2
			martial = 12
			martial = 16
			diplomacy = 8
			trait = brave
			is_strong_trigger = yes
			trait = viking
			prestige = 500
		}
		
		NOR = {
			dynasty = none
			trait = content
			trait = craven
			trait = humble
			trait = depressed
			trait = imbecile
			trait = wounded
			is_maimed_trigger = yes
			trait = incapable
			trait = celibate
			trait = blinded
			trait = eunuch
			is_weak_trigger = yes
			trait = nun
			trait = monk
			any_liege = { holy_order = yes }
			any_liege = { mercenary = yes }
			any_spouse = { is_ruler = yes }
			any_heir_title = { always = yes }
		}
		
		OR = {
			AND = {
				any_liege = { government = nomadic_government }
				culture_group = altaic
			}
			religion = norse_pagan
			religion = norse_pagan_reformed
		}
		
		NOT = { # Handled by event TOG.1200
			any_claim = {
				has_holder = yes
				is_titular = no
				is_landless_type_title = no
				OR = {
					higher_tier_than = COUNT
					holder_scope = { tier = PREV }
				}
				OR = {
					ROOT = { has_strong_claim = PREV }
					holder_scope = { is_female = yes }
					holder_scope = { has_regent = yes }
					holder_scope = { trait = uncrowned }
					ROOT = { trait = ambitious }
				}
				OR = {
					AND = {
						ROOT = { is_female = no }
						NOT = { has_law = enatic_succession }
					}
					AND = {
						ROOT = { is_female = yes }
						ROOT = { trait = ambitious }
						NOT = { has_law = agnatic_succession }
					}
				}		
				holder_scope = {
					independent = yes
					demesne_size = 1
					OR = {
						is_theocracy = no
						NOT = { religion = ROOT }
					}
					NAND = {
						government = nomadic_government
						OR = {
							clan_title = { title = PREVPREV }
							primary_title = { title = PREVPREV }
						}
					}
					NOR = {
						trait = pf_rebel
						any_spouse = { character = ROOT }
						reverse_opinion = { who = ROOT value = 25 }
						has_character_modifier = holy_truce_timer
						has_character_modifier = adventurer_target_timer
					}
					OR = {
						NOT = { reverse_opinion = { who = ROOT value = -25 } }
						NOT = { is_close_relative = ROOT }
						ROOT = { trait = bastard }
					}
					OR = {
						is_merchant_republic = no
						NOT = { capital_holding = { de_jure_liege_or_above = PREVPREV } }
					}
				}
			}
		}
		
		OR = {
			AND = {
				martial = 12
				calc_true_if = {
					amount = 2
					martial = 16
					diplomacy = 12
					trait = brave
					trait = ambitious
					trait = viking
				}
			}
			father_even_if_dead = {
				OR = {
					primary_title = { higher_tier_than = BARON }
					father_even_if_dead = {
						primary_title = { higher_tier_than = BARON }
					}
					mother_even_if_dead = {
						primary_title = { higher_tier_than = BARON }
					}
				}
			}
			mother_even_if_dead = {
				OR = {
					primary_title = { higher_tier_than = BARON }
					father_even_if_dead = {
						primary_title = { higher_tier_than = BARON }
					}
					mother_even_if_dead = {
						primary_title = { higher_tier_than = BARON }
					}
				}
			}
		}
	}
	
	mean_time_to_happen = {
		years = 30
		modifier = {
			factor = 0.5
			trait = ambitious
		}
		modifier = {
			factor = 0.5
			has_character_flag = potential_adventurer
		}
		modifier = {
			factor = 0.5
			OR = {
				AND = {
					culture = norman
					NOT = { year = 1250 }
				}
				AND = {
					culture_group = north_germanic
					NOT = { year = 1066 }
				}
			}
		}
		modifier = {
			factor = 0.2
			has_character_flag = flag_denied_title
		}
		modifier = {
			factor = 0.2
			has_character_flag = demon_child_non_pagan
		}
		modifier = {
			factor = 0.2
			trait = changeling
		}
		modifier = {
			factor = 0.75
			diplomacy = 12
		}
		modifier = {
			factor = 0.75
			martial = 12
		}
		modifier = {
			factor = 0.75
			combat_rating = 3
		}
		modifier = {
			factor = 0.75
			trait = brave
		}
		modifier = {
			factor = 0.85
			trait = proud
		}
		modifier = {
			factor = 0.85
			trait = impaler
		}
		modifier = {
			factor = 0.85
			trait = greedy
		}
		modifier = {
			factor = 0.85
			trait = envious
		}
		modifier = {
			factor = 0.85
			trait = zealous
		}
		modifier = {
			factor = 3.0
			trait = slothful
		}
		modifier = {
			factor = 3.0
			trait = humble
		}
		modifier = {
			factor = 3.0
			trait = kind
		}
		modifier = {
			factor = 3.0
			any_liege = { ai = no }
		}
		modifier = {
			factor = 2.0
			NOR = {
				father_even_if_dead = {
					OR = {
						primary_title = { higher_tier_than = BARON }
						father_even_if_dead = {
							primary_title = { higher_tier_than = BARON }
						}
						mother_even_if_dead = {
							primary_title = { higher_tier_than = BARON }
						}
					}
				}
				mother_even_if_dead = {
					OR = {
						primary_title = { higher_tier_than = BARON }
						father_even_if_dead = {
							primary_title = { higher_tier_than = BARON }
						}
						mother_even_if_dead = {
							primary_title = { higher_tier_than = BARON }
						}
					}
				}
			}
		}
		modifier = {
			factor = 50
			has_game_rule = {
				name = adventurers
				value = rare
			}
		}
	}
	
	immediate = {
		end_inaccessibility_effect = yes #removes in hiding or in_seclusion
		random = {
			chance = 25
			modifier = {
				factor = 1.5
				year = 950
			}
			modifier = {
				factor = 2
				NOT = { martial = 12 }
			}
			modifier = {
				factor = 0
				OR = {
					martial = 16
					trait = viking
				}
			}
			character_event = { id = plus_adventurer.160 }
			break = yes
		}
		
		
		add_trait = adventurer
		log = "[Root.GetTitledName] of the [Root.Liege.PrimaryTitle.GetFullName] has become a raiding adventurer"
		
		liege = {
			save_event_target_as = previous_liege
			character_event = {
				id = HL.101
				days = 1
			}
			
			capital_scope = {
				save_event_target_as = target_province
				county = { save_event_target_as = home_title }
				ROOT = {
					set_defacto_liege = THIS
					create_title = {
						tier = DUKE
						landless = yes
						adventurer = yes
						culture = ROOT
						name = "CLAIMANT_ADVENTURE"
						holder = ROOT
						base_title = event_target:home_title
					}
					clear_event_target = home_title
					set_character_flag = raiding_adventurer
					change_variable = { which = global_raiding_adventurer_spawn_by_courtier_MTTH value = 1 }
					if = {
						limit = {
							event_target:previous_liege = {
								government = nomadic_government
							}
						}
						character_event = { id = HL.105 } #create troops steppe
					}
					if = {
						limit = {
							event_target:previous_liege = {
								NOT = { government = nomadic_government }
							}
						}
						character_event = { id = HL.102 } #create troops vikings
					}
					
					create_random_soldier = {
						random_traits = yes
						dynasty = none
						religion = ROOT
						culture = ROOT
						female = no
						age = 30
					}
					create_random_soldier = {
						random_traits = yes
						dynasty = none
						religion = ROOT
						culture = ROOT
						female = no
						age = 27
					}
					create_random_soldier = {
						random_traits = yes
						dynasty = none
						religion = ROOT
						culture = ROOT
						female = no
						age = 25
					}
					
					if  = {
						limit = { is_seafarer = yes }
						
						# Create a fleet, just to be sure
						spawn_fleet = {
							province = closest # closest sea zone
							owner = ROOT
							cannot_inherit = yes
							troops = {
								galleys = { 110 110 }
							}
						}
					}
				}
			}
		}
		character_event = { id = HL.110 days = 1095 } # Ping to see if he's ready to settle, repeating every 3 years.
	}
}

character_event = {
	id = HL.101
	desc = EVTDESC_HL_101
	picture = GFX_evt_crusaders
	border = GFX_event_normal_frame_war
	
	show_from_from = yes
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA_TOG_1203"
	}
}

character_event = {
	id = HL.102
	is_triggered_only = yes
	hide_window = yes
	
	immediate = {
		random_list = {
			30 = { #3
				modifier = {
					factor = 1.4
					NOT = { year = 850 }
				}
				modifier = {
					factor = 1.4
					NOT = { year = 950 }
				}
				modifier = {
					factor = 1.2
					NOT = { year = 1050 }
				}
				modifier = {
					factor = 0.6
					year = 1150
				}
				character_event = { id = HL.104 }
				character_event = { id = HL.103 }
				character_event = { id = HL.103 }
			}
			30 = { #6
				modifier = {
					factor = 0.7
					year = 1100
				}
				character_event = { id = HL.104 }
				character_event = { id = HL.103 }
				character_event = { id = HL.103 }
				character_event = { id = HL.103 }
				character_event = { id = HL.103 }
				character_event = { id = HL.103 }
			}
			30 = { #9
				modifier = {
					factor = 0.7
					NOT = { year = 900 }
				}
				modifier = {
					factor = 0.7
					NOT = { year = 950 }
				}
				modifier = {
					factor = 0.7
					NOT = { year = 1000 }
				}
				modifier = {
					factor = 0.7
					NOT = { year = 1050 }
				}
				modifier = {
					factor = 0.7
					NOT = { martial = 12 }
				}
				modifier = {
					factor = 0.7
					NOT = { martial = 14 }
				}
				character_event = { id = HL.104 }
				character_event = { id = HL.103 }
				character_event = { id = HL.103 }
				character_event = { id = HL.103 }
				character_event = { id = HL.103 }
				character_event = { id = HL.103 }
				character_event = { id = HL.103 }
				character_event = { id = HL.103 }
				character_event = { id = HL.103 }
			}
			30 = { #12
				modifier = {
					factor = 0
					NOT = { year = 1150 }
				}
				modifier = {
					factor = 0.7
					NOT = { year = 1180 }
				}
				modifier = {
					factor = 0.7
					NOT = { year = 1200 }
				}
				modifier = {
					factor = 0.7
					NOT = { martial = 15 }
				}
				modifier = {
					factor = 0.7
					NOT = { martial = 20 }
				}
				character_event = { id = HL.104 }
				character_event = { id = HL.103 }
				character_event = { id = HL.103 }
				character_event = { id = HL.103 }
				character_event = { id = HL.103 }
				character_event = { id = HL.103 }
				character_event = { id = HL.103 }
				character_event = { id = HL.103 }
				character_event = { id = HL.103 }
				character_event = { id = HL.103 }
				character_event = { id = HL.103 }
				character_event = { id = HL.103 }
			}
		}
	}
}

character_event = {
	id = HL.103
	is_triggered_only = yes
	hide_window = yes
	
	immediate = {
		random_list = {
			30 = { #250
				modifier = {
					factor = 1.3
					NOT = { martial = 2 }
				}
				modifier = {
					factor = 1.3
					NOT = { martial = 4 }
				}
				modifier = {
					factor = 1.3
					NOT = { martial = 6 }
				}
				modifier = {
					factor = 0.7
					martial = 15
				}
				modifier = {
					factor = 0.7
					martial = 18
				}
				modifier = {
					factor = 0.7
					martial = 21
				}
				modifier = {
					factor = 0.7
					martial = 24
				}
				spawn_unit = {
					province = event_target:target_province
					home = event_target:target_province
					owner = ROOT
					#leader = none
					attrition = 0
#					disband_on_peace = yes
					reinforces = yes
					is_looter = yes
					can_toggle_looting = no
					cannot_inherit = yes
					merge = yes
					troops = {
						archers = { 70 70 }
						light_infantry = { 170 170 }
						heavy_infantry = { 10 10 }
					}
				}
			}
			30 = { #380
				modifier = {
					factor = 1.3
					NOT = { martial = 4 }
				}
				modifier = {
					factor = 1.3
					NOT = { martial = 6 }
				}
				modifier = {
					factor = 1.3
					NOT = { martial = 8 }
				}
				modifier = {
					factor = 0.7
					martial = 17
				}
				modifier = {
					factor = 0.7
					martial = 20
				}
				modifier = {
					factor = 0.7
					martial = 23
				}
				modifier = {
					factor = 0.7
					martial = 26
				}
				spawn_unit = {
					province = event_target:target_province
					home = event_target:target_province
					owner = ROOT
					#leader = none
					attrition = 0
#					disband_on_peace = yes
					reinforces = yes
					is_looter = yes
					can_toggle_looting = no
					cannot_inherit = yes
					merge = yes
					troops = {
						archers = { 90 90 }
						light_infantry = { 215 215 }
						heavy_infantry = { 15 15 }
					}
				}
				
			}
			30 = { #420
				modifier = {
					factor = 1.3
					NOT = { martial = 9 }
				}
				modifier = {
					factor = 1.3
					NOT = { martial = 12 }
				}
				modifier = {
					factor = 1.3
					NOT = { martial = 15 }
				}
				modifier = {
					factor = 0.7
					martial = 20
				}
				modifier = {
					factor = 0.7
					martial = 24
				}
				spawn_unit = {
					province = event_target:target_province
					home = event_target:target_province
					owner = ROOT
					#leader = none
					attrition = 0
#					disband_on_peace = yes
					reinforces = yes
					is_looter = yes
					can_toggle_looting = no
					cannot_inherit = yes
					merge = yes
					troops = {
						archers = { 100 100 }
						light_infantry = { 225 225 }
						heavy_infantry = { 15 15 }
					}
				}
			}
			30 = { #490
				modifier = {
					factor = 1.3
					martial = 24
				}
				modifier = {
					factor = 1.3
					martial = 28
				}
				modifier = {
					factor = 0.5
					NOT = { martial = 10 }
				}
				modifier = {
					factor = 0.5
					NOT = { martial = 15 }
				}
				modifier = {
					factor = 0.7
					NOT = { martial = 20 }
				}
				spawn_unit = {
					province = event_target:target_province
					home = event_target:target_province
					owner = ROOT
					#leader = none
					attrition = 0
#					disband_on_peace = yes
					reinforces = yes
					is_looter = yes
					can_toggle_looting = no
					cannot_inherit = yes
					merge = yes
					troops = {
						archers = { 140 140 }
						light_infantry = { 330 330 }
						heavy_infantry = { 20 20 }
					}
				}
			}
			30 = { #570
				modifier = {
					factor = 0.7
					NOT = { martial = 14 }
				}
				modifier = {
					factor = 0.7
					NOT = { martial = 20 }
				}
				modifier = {
					factor = 0.7
					NOT = { martial = 26 }
				}
				spawn_unit = {
					province = event_target:target_province
					home = event_target:target_province
					owner = ROOT
					#leader = none
					attrition = 0
#					disband_on_peace = yes
					reinforces = yes
					is_looter = yes
					can_toggle_looting = no
					cannot_inherit = yes
					merge = yes
					troops = {
						archers = { 170 170 }
						light_infantry = { 360 360 }
						heavy_infantry = { 40 40 }
					}
				}
			}
		}
	}
}

character_event = {
	id = HL.104
	is_triggered_only = yes
	hide_window = yes
	
	immediate = {
		random_list = {
			30 = { #250
				modifier = {
					factor = 1.3
					NOT = { martial = 2 }
				}
				modifier = {
					factor = 1.3
					NOT = { martial = 4 }
				}
				modifier = {
					factor = 1.3
					NOT = { martial = 6 }
				}
				modifier = {
					factor = 0.7
					martial = 15
				}
				modifier = {
					factor = 0.7
					martial = 18
				}
				modifier = {
					factor = 0.7
					martial = 21
				}
				modifier = {
					factor = 0.7
					martial = 24
				}
				spawn_unit = {
					province = event_target:target_province
					home = event_target:target_province
					owner = ROOT
					#leader = ROOT
					attrition = 0
#					disband_on_peace = yes
					reinforces = yes
					is_looter = yes
					can_toggle_looting = no
					cannot_inherit = yes
					merge = yes
					troops = {
						archers = { 70 70 }
						light_infantry = { 170 170 }
						heavy_infantry = { 10 10 }
					}
				}
			}
			30 = { #380
				modifier = {
					factor = 1.3
					NOT = { martial = 4 }
				}
				modifier = {
					factor = 1.3
					NOT = { martial = 6 }
				}
				modifier = {
					factor = 1.3
					NOT = { martial = 8 }
				}
				modifier = {
					factor = 0.7
					martial = 17
				}
				modifier = {
					factor = 0.7
					martial = 20
				}
				modifier = {
					factor = 0.7
					martial = 23
				}
				modifier = {
					factor = 0.7
					martial = 26
				}
				spawn_unit = {
					province = event_target:target_province
					home = event_target:target_province
					owner = ROOT
					#leader = ROOT
					attrition = 0
#					disband_on_peace = yes
					reinforces = yes
					is_looter = yes
					can_toggle_looting = no
					cannot_inherit = yes
					merge = yes
					troops = {
						archers = { 90 90 }
						light_infantry = { 215 215 }
						heavy_infantry = { 15 15 }
					}
				}
				
			}
			30 = { #420
				modifier = {
					factor = 1.3
					NOT = { martial = 9 }
				}
				modifier = {
					factor = 1.3
					NOT = { martial = 12 }
				}
				modifier = {
					factor = 1.3
					NOT = { martial = 15 }
				}
				modifier = {
					factor = 0.7
					martial = 20
				}
				modifier = {
					factor = 0.7
					martial = 24
				}
				spawn_unit = {
					province = event_target:target_province
					home = event_target:target_province
					owner = ROOT
					#leader = ROOT
					attrition = 0
#					disband_on_peace = yes
					reinforces = yes
					is_looter = yes
					can_toggle_looting = no
					cannot_inherit = yes
					merge = yes
					troops = {
						archers = { 100 100 }
						light_infantry = { 225 225 }
						heavy_infantry = { 15 15 }
					}
				}
			}
			30 = { #490
				modifier = {
					factor = 1.3
					martial = 24
				}
				modifier = {
					factor = 1.3
					martial = 28
				}
				modifier = {
					factor = 0.5
					NOT = { martial = 10 }
				}
				modifier = {
					factor = 0.5
					NOT = { martial = 15 }
				}
				modifier = {
					factor = 0.7
					NOT = { martial = 20 }
				}
				spawn_unit = {
					province = event_target:target_province
					home = event_target:target_province
					owner = ROOT
					#leader = ROOT
					attrition = 0
#					disband_on_peace = yes
					reinforces = yes
					is_looter = yes
					can_toggle_looting = no
					cannot_inherit = yes
					merge = yes
					troops = {
						archers = { 140 140 }
						light_infantry = { 330 330 }
						heavy_infantry = { 20 20 }
					}
				}
			}
			30 = { #570
				modifier = {
					factor = 0.7
					NOT = { martial = 14 }
				}
				modifier = {
					factor = 0.7
					NOT = { martial = 20 }
				}
				modifier = {
					factor = 0.7
					NOT = { martial = 26 }
				}
				spawn_unit = {
					province = event_target:target_province
					home = event_target:target_province
					owner = ROOT
					#leader = ROOT
					attrition = 0
#					disband_on_peace = yes
					reinforces = yes
					is_looter = yes
					can_toggle_looting = no
					cannot_inherit = yes
					merge = yes
					troops = {
						archers = { 170 170 }
						light_infantry = { 360 360 }
						heavy_infantry = { 40 40 }
					}
				}
			}
		}
	}
}

character_event = {
	id = HL.105
	is_triggered_only = yes
	hide_window = yes
	
	immediate = {
		random_list = {
			30 = { #3
				modifier = {
					factor = 1.4
					NOT = { year = 850 }
				}
				modifier = {
					factor = 1.4
					NOT = { year = 950 }
				}
				modifier = {
					factor = 1.2
					NOT = { year = 1050 }
				}
				modifier = {
					factor = 0.6
					year = 1150
				}
				character_event = { id = HL.107 }
				character_event = { id = HL.106 }
				character_event = { id = HL.106 }
			}
			30 = { #6
				modifier = {
					factor = 0.7
					year = 1100
				}
				character_event = { id = HL.107 }
				character_event = { id = HL.106 }
				character_event = { id = HL.106 }
				character_event = { id = HL.106 }
				character_event = { id = HL.106 }
				character_event = { id = HL.106 }
			}
			30 = { #9
				modifier = {
					factor = 0.7
					NOT = { year = 900 }
				}
				modifier = {
					factor = 0.7
					NOT = { year = 950 }
				}
				modifier = {
					factor = 0.7
					NOT = { year = 1000 }
				}
				modifier = {
					factor = 0.7
					NOT = { year = 1050 }
				}
				modifier = {
					factor = 0.7
					NOT = { martial = 12 }
				}
				modifier = {
					factor = 0.7
					NOT = { martial = 14 }
				}
				character_event = { id = HL.107 }
				character_event = { id = HL.106 }
				character_event = { id = HL.106 }
				character_event = { id = HL.106 }
				character_event = { id = HL.106 }
				character_event = { id = HL.106 }
				character_event = { id = HL.106 }
				character_event = { id = HL.106 }
				character_event = { id = HL.106 }
			}
			30 = { #12
				modifier = {
					factor = 0
					NOT = { year = 1150 }
				}
				modifier = {
					factor = 0.7
					NOT = { year = 1180 }
				}
				modifier = {
					factor = 0.7
					NOT = { year = 1200 }
				}
				modifier = {
					factor = 0.7
					NOT = { martial = 15 }
				}
				modifier = {
					factor = 0.7
					NOT = { martial = 20 }
				}
				character_event = { id = HL.107 }
				character_event = { id = HL.106 }
				character_event = { id = HL.106 }
				character_event = { id = HL.106 }
				character_event = { id = HL.106 }
				character_event = { id = HL.106 }
				character_event = { id = HL.106 }
				character_event = { id = HL.106 }
				character_event = { id = HL.106 }
				character_event = { id = HL.106 }
				character_event = { id = HL.106 }
				character_event = { id = HL.106 }
			}
		}
	}
}

character_event = {
	id = HL.106
	is_triggered_only = yes
	hide_window = yes
	
	immediate = {
		random_list = {
			30 = { #180
				modifier = {
					factor = 1.3
					NOT = { martial = 2 }
				}
				modifier = {
					factor = 1.3
					NOT = { martial = 4 }
				}
				modifier = {
					factor = 1.3
					NOT = { martial = 6 }
				}
				modifier = {
					factor = 0.7
					martial = 15
				}
				modifier = {
					factor = 0.7
					martial = 18
				}
				modifier = {
					factor = 0.7
					martial = 21
				}
				modifier = {
					factor = 0.7
					martial = 24
				}
				spawn_unit = {
					province = event_target:target_province
					home = event_target:target_province
					owner = ROOT
					attrition = 0
#					disband_on_peace = yes
					reinforces = yes
					is_looter = yes
					can_toggle_looting = no
					cannot_inherit = yes
					merge = yes
					troops = {
						light_cavalry = { 100 100 }
						horse_archers = { 80 80 }
					}
				}
			}
			30 = { #280
				modifier = {
					factor = 1.3
					NOT = { martial = 4 }
				}
				modifier = {
					factor = 1.3
					NOT = { martial = 6 }
				}
				modifier = {
					factor = 1.3
					NOT = { martial = 8 }
				}
				modifier = {
					factor = 0.7
					martial = 17
				}
				modifier = {
					factor = 0.7
					martial = 20
				}
				modifier = {
					factor = 0.7
					martial = 23
				}
				modifier = {
					factor = 0.7
					martial = 26
				}
				spawn_unit = {
					province = event_target:target_province
					home = event_target:target_province
					owner = ROOT
					attrition = 0
#					disband_on_peace = yes
					reinforces = yes
					is_looter = yes
					can_toggle_looting = no
					cannot_inherit = yes
					merge = yes
					troops = {
						light_cavalry = { 150 150 }
						horse_archers = { 130 130 }
					}
				}
				
			}
			30 = { #315
				modifier = {
					factor = 1.3
					NOT = { martial = 9 }
				}
				modifier = {
					factor = 1.3
					NOT = { martial = 12 }
				}
				modifier = {
					factor = 1.3
					NOT = { martial = 15 }
				}
				modifier = {
					factor = 0.7
					martial = 20
				}
				modifier = {
					factor = 0.7
					martial = 24
				}
				spawn_unit = {
					province = event_target:target_province
					home = event_target:target_province
					owner = ROOT
					attrition = 0
#					disband_on_peace = yes
					reinforces = yes
					is_looter = yes
					can_toggle_looting = no
					cannot_inherit = yes
					merge = yes
					troops = {
						light_cavalry = { 165 165 }
						horse_archers = { 150 150 }
					}
				}
			}
			30 = { #365
				modifier = {
					factor = 1.3
					martial = 24
				}
				modifier = {
					factor = 1.3
					martial = 28
				}
				modifier = {
					factor = 0.5
					NOT = { martial = 10 }
				}
				modifier = {
					factor = 0.5
					NOT = { martial = 15 }
				}
				modifier = {
					factor = 0.7
					NOT = { martial = 20 }
				}
				spawn_unit = {
					province = event_target:target_province
					home = event_target:target_province
					owner = ROOT
					attrition = 0
#					disband_on_peace = yes
					reinforces = yes
					is_looter = yes
					can_toggle_looting = no
					cannot_inherit = yes
					merge = yes
					troops = {
						light_cavalry = { 190 190 }
						horse_archers = { 175 175 }
					}
				}
			}
			30 = { #420
				modifier = {
					factor = 0.7
					NOT = { martial = 14 }
				}
				modifier = {
					factor = 0.7
					NOT = { martial = 20 }
				}
				modifier = {
					factor = 0.7
					NOT = { martial = 26 }
				}
				spawn_unit = {
					province = event_target:target_province
					home = event_target:target_province
					owner = ROOT
					attrition = 0
#					disband_on_peace = yes
					reinforces = yes
					is_looter = yes
					can_toggle_looting = no
					cannot_inherit = yes
					merge = yes
					troops = {
						light_cavalry = { 220 220 }
						horse_archers = { 200 200 }
					}
				}
			}
		}
	}
}

character_event = {
	id = HL.107
	is_triggered_only = yes
	hide_window = yes
	
	immediate = {
		random_list = {
			30 = { #180
				modifier = {
					factor = 1.3
					NOT = { martial = 2 }
				}
				modifier = {
					factor = 1.3
					NOT = { martial = 4 }
				}
				modifier = {
					factor = 1.3
					NOT = { martial = 6 }
				}
				modifier = {
					factor = 0.7
					martial = 15
				}
				modifier = {
					factor = 0.7
					martial = 18
				}
				modifier = {
					factor = 0.7
					martial = 21
				}
				modifier = {
					factor = 0.7
					martial = 24
				}
				spawn_unit = {
					province = event_target:target_province
					home = event_target:target_province
					owner = ROOT
					#leader = ROOT
					attrition = 0
#					disband_on_peace = yes
					reinforces = yes
					is_looter = yes
					can_toggle_looting = no
					cannot_inherit = yes
					merge = yes
					troops = {
						light_cavalry = { 100 100 }
						horse_archers = { 80 80 }
					}
				}
			}
			30 = { #280
				modifier = {
					factor = 1.3
					NOT = { martial = 4 }
				}
				modifier = {
					factor = 1.3
					NOT = { martial = 6 }
				}
				modifier = {
					factor = 1.3
					NOT = { martial = 8 }
				}
				modifier = {
					factor = 0.7
					martial = 17
				}
				modifier = {
					factor = 0.7
					martial = 20
				}
				modifier = {
					factor = 0.7
					martial = 23
				}
				modifier = {
					factor = 0.7
					martial = 26
				}
				spawn_unit = {
					province = event_target:target_province
					home = event_target:target_province
					owner = ROOT
					#leader = ROOT
					attrition = 0
#					disband_on_peace = yes
					reinforces = yes
					is_looter = yes
					can_toggle_looting = no
					cannot_inherit = yes
					merge = yes
					troops = {
						light_cavalry = { 150 150 }
						horse_archers = { 130 130 }
					}
				}
				
			}
			30 = { #315
				modifier = {
					factor = 1.3
					NOT = { martial = 9 }
				}
				modifier = {
					factor = 1.3
					NOT = { martial = 12 }
				}
				modifier = {
					factor = 1.3
					NOT = { martial = 15 }
				}
				modifier = {
					factor = 0.7
					martial = 20
				}
				modifier = {
					factor = 0.7
					martial = 24
				}
				spawn_unit = {
					province = event_target:target_province
					home = event_target:target_province
					owner = ROOT
					#leader = ROOT
					attrition = 0
#					disband_on_peace = yes
					reinforces = yes
					is_looter = yes
					can_toggle_looting = no
					cannot_inherit = yes
					merge = yes
					troops = {
						light_cavalry = { 165 165 }
						horse_archers = { 150 150 }
					}
				}
			}
			30 = { #365
				modifier = {
					factor = 1.3
					martial = 24
				}
				modifier = {
					factor = 1.3
					martial = 28
				}
				modifier = {
					factor = 0.5
					NOT = { martial = 10 }
				}
				modifier = {
					factor = 0.5
					NOT = { martial = 15 }
				}
				modifier = {
					factor = 0.7
					NOT = { martial = 20 }
				}
				spawn_unit = {
					province = event_target:target_province
					home = event_target:target_province
					owner = ROOT
					#leader = ROOT
					attrition = 0
#					disband_on_peace = yes
					reinforces = yes
					is_looter = yes
					can_toggle_looting = no
					cannot_inherit = yes
					merge = yes
					troops = {
						light_cavalry = { 190 190 }
						horse_archers = { 175 175 }
					}
				}
			}
			30 = { #420
				modifier = {
					factor = 0.7
					NOT = { martial = 14 }
				}
				modifier = {
					factor = 0.7
					NOT = { martial = 20 }
				}
				modifier = {
					factor = 0.7
					NOT = { martial = 26 }
				}
				spawn_unit = {
					province = event_target:target_province
					home = event_target:target_province
					owner = ROOT
					#leader = ROOT
					attrition = 0
#					disband_on_peace = yes
					reinforces = yes
					is_looter = yes
					can_toggle_looting = no
					cannot_inherit = yes
					merge = yes
					troops = {
						light_cavalry = { 220 220 }
						horse_archers = { 200 200 }
					}
				}
			}
		}
	}
}

character_event = {
	id = HL.110
	is_triggered_only = yes
	hide_window = yes
	
	
	has_character_flag = raiding_adventurer
	
	trigger = {
		primary_title = {
			temporary = yes
		}
	}
	
	immediate = {
#		log = "Ping event for raiding adventurer: [Root.GetBestName]."
		if = {
			limit = { # If this is true, prepare to settle.
				OR = {
					wealth = 300
					had_character_flag = { flag = raiding_adventurer days = 1825 }
				}
				any_independent_ruler = {
					has_opinion_modifier = { who = ROOT modifier = opinion_looted }
					NOT = { realm_levy_diff = { who = ROOT value = 3000 } }
					demesne_size = 1
					NOT = { has_character_flag = negotiating_with_adventurer }
					NOT = { any_realm_province = { has_province_modifier = settled_adventurer } }
				}
			}
			random_list = {
				50 = {
					modifier = {
						trait = cruel
						factor = 2
					}
					modifier = {
						trait = ambitious
						factor = 2
					}
					log = "[Root.GetBestName] prepares to settle."
					character_event = { id = HL.111 }
					break = yes
				}
				20 = {
					modifier = {
						NOT = { has_character_flag = flag_denied_title }
						factor = 0
					}
					modifier = {
						trait = ambitious
						factor = 2
					}
					modifier = {
						trait = ambitious
						trait = arbitrary
						factor = 3
					}
					modifier = {
						trait = envious
						factor = 2
					}
					log = "[Root.GetBestName] returns home in a state of war."
					character_event = { id = HL.113 }
					break = yes
				}
				50 = {
					modifier = {
						had_character_flag = { flag = raiding_adventurer days = 2555}
						factor = 0.5
					}
					modifier = {
						had_character_flag = { flag = raiding_adventurer days = 3285}
						factor = 0.5
					}
					modifier = {
						had_character_flag = { flag = raiding_adventurer days = 4015}
						factor = 0.5
					}
					modifier = {
						had_character_flag = { flag = raiding_adventurer days = 10950}
						factor = 0
					}
					repeat_event = { id = HL.110 days = 365 } # continue raiding
					break = yes
				}
			}
		}
		# Check for stagnant raider
		if = {
			limit = {
				had_character_flag = { flag = raiding_adventurer days = 10950 }	
			}
			character_event = { id = HL.198 }
			break = yes
		}
		# Else continue raiding.
		log = "[Root.GetBestName] continues raiding."
		repeat_event = { id = HL.110 days = 365 }
	}
}

# Raider is prepared to settle
character_event = {
	id = HL.111
	is_triggered_only = yes
	hide_window = yes
	
	immediate = {
		random_independent_ruler = {
			limit = {
				has_opinion_modifier = { who = ROOT modifier = opinion_looted }
				NOT = { realm_levy_diff = { who = ROOT value = 3000 } }
				demesne_size = 1
				NOT = { has_character_flag = negotiating_with_adventurer }
				NOT = { any_realm_province = { has_province_modifier = settled_adventurer } }
			}

			if = {
				limit = {
					higher_real_tier_than = DUKE
					OR = {
						any_demesne_province = {
							is_capital = no 
							num_of_settlements = 1
							NOT = {
								has_province_modifier = nomad_agitation
							}
							OR = {
								AND = {
									ROOT = { is_seafarer = yes }
									port = yes
								}
								ROOT = { is_seafarer = no }
								NOT = { any_demesne_province = { port = yes } }
							}
						}
						any_vassal = {
							any_demesne_province = {
								is_capital = no 
								num_of_settlements = 1
								NOT = {
									has_province_modifier = nomad_agitation
								}
								OR = {
									AND = {
										ROOT = { is_seafarer = yes }
										port = yes
									}
									ROOT = { is_seafarer = no }
									NOT = { any_demesne_province = { port = yes } }
								}
							}
						}
					}
				}

				#Adventurer negotiation complex
				set_character_flag = negotiating_with_adventurer
				character_event = { id = ADV.1 }

				#Checks if they should go back to raiding
				ROOT = {
					character_event = { id = HL.200 days = 65 }
				}

				break = yes
			}
			
			if = {
				limit = { NOT = { higher_real_tier_than = DUKE } }	
				clr_character_flag = raiding_adventurer			
				if = {
					limit = {
						ROOT = { is_seafarer = yes }
					}
					random_realm_province = {
						limit = {
							port = yes
							OR = {
								region = custom_livonia
								region = custom_novgorod
								region = custom_muscovy
								region = custom_rus
								duchy = { title = d_normandy }
							}
						}
						ROOT = {
							unsafe_war = {
								target = PREVPREV
								casus_belli = duchy_adventure
								thirdparty_title = PREV
								tier = DUKE
							}
							any_army = {
								set_can_toggle_looting = yes
								set_looting = no
							}
							PREVPREV = {
								character_event = { id = HL.112 }
							}
						}
						break = yes
					}
					random_realm_province = {
						limit = {
							port = yes
						}
						ROOT = {
							unsafe_war = {
								target = PREVPREV
								casus_belli = duchy_adventure
								thirdparty_title = PREV
								tier = DUKE
							}
							PREVPREV = {
								character_event = { id = HL.112 }
							}
						}
						break = yes
					}
					random_realm_province = {
						limit = {
							any_neighbor_province = {
								NOT = { owner = { same_realm = PREVPREVPREV } }
							}
						}
						ROOT = {
							unsafe_war = {
								target = PREVPREV
								casus_belli = duchy_adventure
								thirdparty_title = PREV
								tier = DUKE
							}
							any_army = {
								set_can_toggle_looting = yes
								set_looting = no
							}
							PREVPREV = {
								character_event = { id = HL.112 }
							}
						}
						break = yes
					}
				}
				if = {
					limit = {
						ROOT = { is_seafarer = no }
					}
					random_realm_province = {
						limit = {
							any_neighbor_province = {
								NOT = { owner = { same_realm = PREVPREVPREV } }
							}
						}
						ROOT = {
							unsafe_war = {
								target = PREVPREV
								casus_belli = duchy_adventure
								thirdparty_title = PREV
								tier = DUKE
							}
							any_army = {
								set_can_toggle_looting = yes
								set_looting = no
							}
							PREVPREV = {
								character_event = { id = HL.112 }
							}
						}
						break = yes
					}
				}
			
				random_realm_province = {
					ROOT = {
						unsafe_war = {
							target = PREVPREV
							casus_belli = duchy_adventure
							thirdparty_title = PREV
							tier = DUKE
						}
						PREVPREV = {
							character_event = { id = HL.112 }
						}
					}
				}
				if = {
					limit = { war = yes }
					break = yes
				}
			}
		}

		#If neither break succeeded, kill it with fire
		clr_character_flag = raiding_adventurer
		log = "[SERIOUS] [Root.GetTitledFirstName] failed to find a target after trying to end his raiding adventure."
		character_event = { id = HL.199 }		
	}
}

character_event = {
	id = HL.112
	is_triggered_only = yes
	picture = GFX_evt_crusaders
	border = GFX_event_normal_frame_war
	desc = EVTDESC_HL_112
	
	option = {
		name = EVTOPTA_HL_112
	}
}

# Raider returns home in a state of war
character_event = {
	id = HL.113
	is_triggered_only = yes
	hide_window = yes
	
	immediate = {
		any_army = {
			set_can_toggle_looting = yes
			set_looting = no
		}
		clr_character_flag = raiding_adventurer
		event_target:target_province = {
			owner = {
				top_liege = {
					character_event = { id = HL.112 }
					if = {
						limit = {
							ROOT = { is_seafarer = yes }
						}
						random_realm_province = {
							limit = { port = yes }
							ROOT = {
								war = {
									target = PREVPREV
									casus_belli = duchy_adventure
									thirdparty_title = PREV
									tier = DUKE
								}
							}
							break = yes
						}
					}
					random_realm_province = {
						limit = {
							any_neighbor_province = {
								NOT = { owner = { same_realm = PREVPREVPREV } }
							}
						}
						ROOT = {
							war = {
								target = PREVPREV
								casus_belli = duchy_adventure
								thirdparty_title = PREV
								tier = DUKE
							}
						}
						break = yes
					}
					random_realm_province = {
						ROOT = {
							war = {
								target = PREVPREV
								casus_belli = duchy_adventure
								thirdparty_title = PREV
								tier = DUKE
							}
						}
						break = yes
					}
				}
			}
		}
		if = {
			limit = {
				war = no
			}
			log = "[SERIOUS] [Root.GetTitledFirstName] failed to find a target after trying to end his raiding adventure."
			character_event = { id = HL.199 }
		}
	}
}

character_event = {
	id = HL.120
	is_triggered_only = yes
	hide_window = yes
	
	immediate = {
		event_target:target_ruler = {
			letter_event = { id = HL.121 }
		}
	}
}

letter_event = {
	id = HL.121
	is_triggered_only = yes
	desc = EVTDESC_HL_121
	
	option = {
		name = EVTOPTA_HL_121
		ai_chance = { factor = 1 }
		event_target:target_title = {
			grant_title = FROM
		}
		hidden_tooltip = {
			FROM = {
				wealth = -150
				if = {
					limit = {
						ROOT = {
							primary_title = {
								higher_tier_than = COUNT
							}
						}
					}
					set_defacto_liege = ROOT
				}
			}
		}
		wealth = 150
	}
	
	option = {
		name = ANSWER_NO
		ai_chance = { factor = 0 }
		add_character_modifier = { name = raider_buy_land_timer duration = 3650 hidden = yes }
	}
}

character_event = {
	id = HL.130
	
	hide_window = yes
	is_triggered_only = yes
	
	trigger = {
		has_game_started = yes
		is_alive = yes
		is_dying = no
		is_nomadic = yes
		prisoner = no
		NOT = { trait = incapable }
		#NOT = { has_character_flag = raiding_adventurer_nomad }
	}
	
	immediate = {
		log = "HL.130 fired for [Root.GetBestName]"
		location = {
			log = "[Root.GetBestName] is located in [This.GetName]"
		}		
		clan_title = {
			capital_scope = {
				log = "[Root.GetBestName]'s capital is in [This.GetName]"
				save_event_target_as = last_province
				
				holder_scope = {
					top_liege = {
						reverse_opinion = {
							modifier = opinion_driven_from_my_lands
							who = ROOT
							months = 1200
						}
						reverse_opinion = {
							modifier = forbidden_raid_target
							who = ROOT
							months = 1200
						}
					}
				}
			}
		}
		
		liege = {
			ROOT = {
				any_vassal = {
					set_defacto_liege = PREVPREV
				}
			}
		}
		
		if = {
			limit = {
				independent = yes
			}
			if = {
				limit = {
					NOT = {
						any_vassal = {
							clan = yes
						}
					}
				}
				any_vassal = {
					set_defacto_liege = THIS
				}
			}
			random_vassal = {
				limit = {
					clan = yes
				}
				primary_title = {
					gain_title = PREVPREV
				}
			}
		}
		set_defacto_liege = THIS
			
		clan_title = {
			set_title_adventurer = { title = THIS status = yes }
			set_title_landless = { title = THIS status = yes }
			set_defacto_liege = THIS
		}
		
		set_character_flag = raiding_adventurer
		change_variable = { which = global_raiding_adventurer_spawn_by_displacement value = 1 }
		
		any_army = {
			set_can_toggle_looting = yes
			set_looting = yes
			set_can_toggle_looting = no
		}
		
		if = {
			limit = {
				NOT = { unused_manpower = 250 }
			}
			manpower = 250
		}
		
		character_event = { id = HL.132 }
		character_event = { id = HL.110 days = 1095 } # Ping to see if he's ready to settle, repeating every 3 years.
	}
}

character_event = {
	id = HL.132
	hide_window = yes
	is_triggered_only = yes
	
	immediate = {
		log = "HL.132 fired for [Root.GetBestName]"
		if = {
			limit = {
				NOT = {
					unused_manpower = 250
				}
			}
			log = "HL.132 failed initial trigger for [Root.GetBestName]"
			break = yes
		}
		location = { log = "HL.132 ROOT is [Root.GetBestName], ROOT's location is [This.GetName] last_province is [last_province.GetName]" }
		spawn_unit = {
			owner = ROOT
			province = event_target:last_province
			home = event_target:last_province
			troops = {
				light_cavalry = { 200 200 }
				horse_archers = { 50 50 }
			}
			attrition = 1.0
			is_looter = yes
			can_toggle_looting = no
			reinforces = yes
			merge = yes
		}
		log = "HL.132 spawned troops for [Root.GetBestName]"
		manpower = -250
		repeat_event = { id = HL.132 }
	}
}

# On-action landless nomad gains title
character_event = {
	id = HL.140
	is_triggered_only = yes
	hide_window = yes
	
	trigger = {
		has_character_flag = raiding_adventurer
		FROM = { NOT = { adventurer = yes } }
	}
	
	immediate = {
		log = "[Root.GetBestName] has received event HL.140 while having government [Root.Government.GetName]"
		clr_character_flag = raiding_adventurer
		any_army = {
			set_can_toggle_looting = yes
			set_looting = no
		}
	}
}

# On-action battle lost Check raiding adventurer defeat
character_event = {
	id = HL.180
	is_triggered_only = yes
	hide_window = yes
	
	only_rulers = yes
	war = no
	has_character_flag = raiding_adventurer
	
	trigger = {
		has_regiments = no
	}
	
	immediate = {
		character_event = { id = HL.199 }
	}
}

# On-action imprisoned pre-war
character_event = {
	id = HL.190
	is_triggered_only = yes
	hide_window = yes
	
	has_character_flag = raiding_adventurer
	war = no
		
	trigger = {
	}
	
	immediate = {
		log = "[Root.GetTitledFirstName] got imprisoned while being a raiding adventurer."
		character_event = { id = HL.199 }
	}
}

# On-action ai end raid
character_event = {
	id = HL.191
	is_triggered_only = yes
	hide_window = yes
	
	has_character_flag = raiding_adventurer
	war = no
		
	trigger = {
	}
	
	immediate = {
#		log = "[Root.GetTitledFirstName] stopped raiding while being a raiding adventurer."
		character_event = { id = HL.199 }
	}
}

#Last try war declaration
character_event = {
	id = HL.198
	is_triggered_only = yes
	hide_window = yes
	
	immediate = {
		random_independent_ruler = {
			limit = {
				has_opinion_modifier = { who = ROOT modifier = opinion_looted }
				NOT = { realm_levy_diff = { who = ROOT value = 3000 } }
				demesne_size = 1
				NOT = { has_character_flag = negotiating_with_adventurer }
				NOT = { any_realm_province = { has_province_modifier = settled_adventurer } }
			}

			if = {
				limit = {
					higher_real_tier_than = DUKE
					OR = {
						any_demesne_province = {
							is_capital = no 
							num_of_settlements = 1
							NOT = {
								has_province_modifier = nomad_agitation
							}
							OR = {
								AND = {
									ROOT = { is_seafarer = yes }
									port = yes
								}
								ROOT = { is_seafarer = no }
								NOT = { any_demesne_province = { port = yes } }
							}
						}
						any_vassal = {
							any_demesne_province = {
								is_capital = no 
								num_of_settlements = 1
								NOT = {
									has_province_modifier = nomad_agitation
								}
								OR = {
									AND = {
										ROOT = { is_seafarer = yes }
										port = yes
									}
									ROOT = { is_seafarer = no }
									NOT = { any_demesne_province = { port = yes } }
								}
							}
						}
					}
				}

				#Adventurer negotiation complex
				set_character_flag = negotiating_with_adventurer
				character_event = { id = ADV.1 }
				
				change_variable = { which = global_adventurer_negotiations value = 1 }
				ROOT = {
					export_to_variable = { 
						which = logging_adventurer_wealth
						value = wealth
					}
					log = "[This.GetBestName] starts to negotiate with [Prev.GetBestName]."
					log = "[This.GetBestName] currently has [This.logging_adventurer_wealth.GetValue] ducats."
				}

				break = yes
			}

			if = {
				limit = { NOT = { higher_real_tier_than = DUKE } }

				clr_character_flag = raiding_adventurer

				if = {
					limit = {
						ROOT = { is_seafarer = yes }
					}
					random_realm_province = {
						limit = {
							port = yes
							OR = {
								region = custom_livonia
								region = custom_novgorod
								region = custom_muscovy
								region = custom_rus
								duchy = { title = d_normandy }
							}
						}
						ROOT = {
							unsafe_war = {
								target = PREVPREV
								casus_belli = duchy_adventure
								thirdparty_title = PREV
								tier = DUKE
							}
							any_army = {
								set_can_toggle_looting = yes
								set_looting = no
							}
							PREVPREV = {
								character_event = { id = HL.112 }
							}
						}
						break = yes
					}
					random_realm_province = {
						limit = {
							port = yes
						}
						ROOT = {
							unsafe_war = {
								target = PREVPREV
								casus_belli = duchy_adventure
								thirdparty_title = PREV
								tier = DUKE
							}
							any_army = {
								set_can_toggle_looting = yes
								set_looting = no
							}
							PREVPREV = {
								character_event = { id = HL.112 }
							}
						}
						break = yes
					}
					random_realm_province = {
						limit = {
							any_neighbor_province = {
								NOT = { owner = { same_realm = PREVPREVPREV } }
							}
						}
						ROOT = {
							unsafe_war = {
								target = PREVPREV
								casus_belli = duchy_adventure
								thirdparty_title = PREV
								tier = DUKE
							}
							any_army = {
								set_can_toggle_looting = yes
								set_looting = no
							}
							PREVPREV = {
								character_event = { id = HL.112 }
							}
						}
						break = yes
					}
				}
				if = {
					limit = {
						ROOT = { is_seafarer = no }
					}
					random_realm_province = {
						limit = {
							any_neighbor_province = {
								NOT = { owner = { same_realm = PREVPREVPREV } }
							}
						}
						ROOT = {
							unsafe_war = {
								target = PREVPREV
								casus_belli = duchy_adventure
								thirdparty_title = PREV
								tier = DUKE
							}
							any_army = {
								set_can_toggle_looting = yes
								set_looting = no
							}
							PREVPREV = {
								character_event = { id = HL.112 }
							}
						}
						break = yes
					}
				}
				
				random_realm_province = {
					ROOT = {
						unsafe_war = {
							target = PREVPREV
							casus_belli = duchy_adventure
							thirdparty_title = PREV
							tier = DUKE
						}
						any_army = {
							set_can_toggle_looting = yes
							set_looting = no
						}
						PREVPREV = {
							character_event = { id = HL.112 }
						}
					}
				}
				if = {
					limit = { war = yes }
					break = yes
				}
			}
		}

		#If neither break succeeded, kill it with fire
		clr_character_flag = raiding_adventurer
		log = "[SERIOUS] [Root.GetTitledFirstName] failed to find a target after trying to end his raiding adventure."
		character_event = { id = HL.199 }
	}
}


# Clean-up
character_event = {
	id = HL.199
	
	is_triggered_only = yes
	
	hide_window = yes
	
	immediate = {
#		log = "Cleaning up adventurer: [Root.GetTitledFirstName]."
		clr_character_flag = raiding_adventurer
		disband_event_forces = yes
		clan_title = {
			if = {
				limit = {
					owner = { is_landed = no }
				}
				ROOT = { any_courtier = { banish = yes } }
				activate_title = { title = THIS status = no }
				unsafe_destroy_landed_title = THIS
			}
		}
		primary_title = {
			if = {
				limit = {
					temporary = yes
				}
				owner = {
					if = {
						limit = {
							OR = {
								AND = {
									tier = DUKE
									PREV = { adventurer = yes }
								}
								tier = EMPEROR
							}
						}
						any_courtier = {
							banish = yes
						}
						activate_title = { title = PREV status = no }
						unsafe_destroy_landed_title = PREV
					}
				}
			}
		}
		if = { # Add other clean-up effects before this if-block since this block includes breaks
			limit = {
				prisoner = no
				is_ruler = no
			}
			if = {
				limit = {
					father = {
						is_alive = yes
					}
				}
				father = {
					if = {
						limit = {
							is_ruler = yes
						}
						ROOT = {
							set_defacto_liege = PREV
							break = yes
						}
					}
					if = {
						limit = {
							is_ruler = no
						}
						liege = {
							ROOT = {
								set_defacto_liege = PREV
								break = yes
							}
						}
					}
				}
			}
		}
		if = {
           limit = {
               at_location = 0
           }
           banish = yes
       }
	}
}

#Should adventurer continue to raid?
character_event = {
	id = HL.200
	
	is_triggered_only = yes
	
	hide_window = yes

	#If not at war and still holding an adventurer title... 
	trigger = {
	 	war = no
	 	primary_title = { 
	 		temporary = yes 
	 		adventurer = yes
	 	}
	}

	#...go forth and adventure!
	immediate = {
		character_event = { id = HL.110 }
	}
}

