#########################################################
#
# Landless Character Adventures for The Old Gods DLC
#
#########################################################

# Original Written by Henrik Fahraeus
# Re-Written by Rylock

namespace = plus_adventurer

### CLAIMANT ADVENTURES

# A landless claimant considers an adventure to take their title
character_event = {
	id = plus_adventurer.100
	
	hide_window = yes
	
	has_dlc = "The Old Gods"
	min_age = 16
	max_age = 50
	capable_only = yes
	prisoner = no

	trigger = {
		is_ruler = no
		num_of_claims = 1
		
		NOT = {
			has_game_rule = {
				name = adventurers
				value = none
			}
		}

		OR = {
			is_female = no
			liege = { has_law = female_council_law_4 }
			liege = { has_law = true_cognatic_succession }
			AND = {			
				liege = { is_feminist_trigger = yes }
				is_feminist_trigger = yes
			}
			has_game_rule = {
				name = gender
				value = all
			}
			has_game_rule = {
				name = gender
				value = plus
			}
		}
		
		# Must be competent and healthy
		health = 4
		OR = {
			diplomacy = 7
			trait = ambitious
			trait = decadent
			has_character_flag = event_adventurer
		}
		OR = {
			diplomacy = 14
			martial = 10
			prestige = 500
			wealth = 200
			has_character_modifier = estates_5
			has_character_flag = event_adventurer
		}
		
		# Has a claim that can be seized
		any_claim = { plus_valid_adv_target_title_trigger = yes }
		
		NOR = {
			trait = content
			trait = craven
			trait = depressed
			trait = imbecile
			trait = eunuch
			trait = horse
			trait = abdicated
			trait = nun
			trait = monk
			trait = desert_mother
			trait = desert_father
			trait = druid
			trait = bad_druid
			trait = retired_vestalis
			trait = vestalis
			is_consort = yes
			any_spouse = { is_ruler = yes }
			any_heir_title = { always = yes }
			any_liege = { holy_order = yes }
			any_liege = { mercenary = yes }
			has_character_modifier = planning_claimant_adventure
			has_character_flag = claimant_adventurer
			has_character_flag = was_claimant_adventurer
			has_character_flag = claim_being_pressed
		}
	}
	
	mean_time_to_happen = {
		years = 50
		modifier = {
			factor = 0.2
			has_character_flag = flag_denied_title
		}
		modifier = {
			factor = 0.2
			OR = {
				has_character_flag = demon_child_non_pagan
				trait = changeling
			}
		}
		modifier = {
			factor = 0.5
			has_character_flag = justified_claimant
		}
		modifier = {
			factor = 0.5
			trait = ambitious
		}
		modifier = {
			factor = 0.5
			trait = decadent
		}
		modifier = {
			factor = 0.5
			OR = {
				trait = lunatic
				trait = possessed
			}
		}
		modifier = {
			factor = 0.75
			OR = {
				trait = genius
				trait = brilliant_strategist
			}
		}
		modifier = {
			factor = 0.75
			trait = brave
		}
		modifier = {
			factor = 0.75
			trait = proud
		}
		modifier = {
			factor = 0.75
			trait = greedy
		}
		modifier = {
			factor = 0.75
			trait = envious
		}
		modifier = {
			factor = 0.75
			trait = wroth
		}
		modifier = {
			factor = 0.75
			trait = sayyid
		}
		modifier = {
			factor = 0.75
			OR = {
				wealth = 100
				has_character_modifier = estates_3
				has_character_modifier = estates_4
			}
		}
		modifier = {
			factor = 0.75
			OR = {
				wealth = 200
				has_character_modifier = estates_5
			}
		}
		modifier = {
			factor = 0.75
			wealth = 300
		}
		modifier = {
			factor = 0.75
			diplomacy = 12
		}
		modifier = {
			factor = 1.5
			trait = slothful
		}
		modifier = {
			factor = 1.5
			trait = charitable
		}
		modifier = {
			factor = 1.5
			trait = patient
		}
		modifier = {
			factor = 2.0
			trait = kind
		}
		modifier = {
			factor = 2.0
			trait = humble
		}
		modifier = {
			factor = 2.0
			NOT = { diplomacy = 7 }
		}
		modifier = {
			factor = 2.0
			NOT = { diplomacy = 5 }
		}
		modifier = {
			factor = 2.0
			NOT = { diplomacy = 3 }
		}
		modifier = {
			factor = 50
			has_game_rule = {
				name = adventurers
				value = rare
			}
		}
	}

	immediate = {
		# Pick highest-tier adventurer target possible
		random_claim = {
			limit = {
				tier = EMPEROR
				plus_valid_adv_target_title_trigger = yes
			}
			save_event_target_as = target_adventurer_title
		}
		random_claim = {
			limit = {
				tier = KING
				NOT = { event_target:target_adventurer_title = { always = yes } }
				plus_valid_adv_target_title_trigger = yes
			}
			save_event_target_as = target_adventurer_title
		}
		random_claim = {
			limit = {
				tier = DUKE
				NOT = { event_target:target_adventurer_title = { always = yes } }
				plus_valid_adv_target_title_trigger = yes
			}
			save_event_target_as = target_adventurer_title
		}
		random_claim = {
			limit = {
				tier = COUNT
				NOT = { event_target:target_adventurer_title = { always = yes } }
				plus_valid_adv_target_title_trigger = yes
			}
			save_event_target_as = target_adventurer_title
		}
		
		# Safety check
		if = {
			limit = { NOT = { event_target:target_adventurer_title = { always = yes } } }
			break = yes
		}
		
		# Start the adventure
		event_target:target_adventurer_title = {
			log = "plus_adventurer.100: [Root.GetBestName] ([Root.GetID]) begins an adventure to take the [This.GetFullName] ([This.GetID]) from [This.Holder.GetBestName] ([This.Holder.GetID])"
			ROOT = {
				set_character_flag = was_claimant_adventurer
				set_character_flag = planning_claimant_adventure
				set_character_flag = adventurer_target_title_@PREV
				add_character_modifier = { name = planning_claimant_adventure hidden = yes duration = 1825 }
				
				# Sell off estates
				sell_estates_effect = yes
				
				# Must drop out of hiding
				end_inaccessibility_effect = yes #removes in hiding or in_seclusion

			}
			
			# Warn the target
			holder_scope = {
				reverse_opinion = { who = ROOT modifier = opinion_claimant_adventure_target years = 10 }
				add_character_modifier = { name = adventurer_target_timer duration = 1825 hidden = yes }
				character_event = { id = plus_adventurer.101 }
			}
		}
		character_event = { id = plus_adventurer.102 }
	}
}
	
# Targeted ruler receives word of the adventurer
character_event = {
	id = plus_adventurer.101
	desc = EVTDESC_plus_adventurer_101
	picture = GFX_evt_crusaders
	border = GFX_event_normal_frame_war
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_plus_adventurer_101
		opinion = { who = FROM modifier = opinion_targeted_by_adventurer months = 36 }
	}
}

# Claimant begins their adventure
character_event = {
	id = plus_adventurer.102
	
	hide_window = yes
	is_triggered_only = yes
	
	capable_only = yes
	prisoner = no
	
	immediate = {
		plus_find_adventurer_target_effect = yes
		
		# Save origin and starting location
		event_target:adventurer_target = {
			capital_scope = {
				ROOT = { set_character_flag = adventurer_origin_@PREV }
			}
		}
		liege = {
			capital_scope = {
				ROOT = { set_character_flag = adventurer_location_@PREV }
			}
		}
		
		# Create adventurer title
		event_target:adventurer_target = {
			capital_scope = {
				ROOT = {
					create_title = {
						tier = DUKE
						landless = yes
						adventurer = yes
						culture = THIS
						name = "CLAIMANT_ADVENTURE"
						holder = THIS
						ruler = "LORD"
						ruler_female = "LADY"
						base_title = THIS
					}
				}
			}
		}
		set_defacto_liege = ROOT
		
		# Move family & friends to their court
		any_child = {
			limit = {
				is_ruler = no
				is_adult = yes
				prisoner = no
				opinion = { who = ROOT value = 50 }
				liege = {
					NOT = { reverse_opinion = { who = PREV value = 0 } }
					NOT = { dynasty = PREV }
				}
			}
			move_character = ROOT
			any_child = {
				limit = {
					is_ruler = no
					is_adult = yes
					prisoner = no
					opinion = { who = ROOT value = 25 }
					liege = {
						NOT = { reverse_opinion = { who = PREV value = 0 } }
						NOT = { dynasty = PREV }
					}
				}
				move_character = ROOT
			}
		}
		any_friend = {
			limit = {
				is_ruler = no
				is_adult = yes
				prisoner = no
				NOR = {
					is_inaccessible_trigger = yes
					trait = incapable
					opinion = { who = event_target:adventurer_target value = 25 }
					opinion = { who = liege value = 50 }
				}
			}
			move_character = ROOT
		}
		event_target:adventurer_target = {
			any_realm_character = {
				count = 3
				limit = {
					is_ruler = no
					is_adult = yes
					prisoner = no
					is_councillor = no
					is_voter = no
					OR = {
						opinion = { who = ROOT value = 40 }
						AND = {
							NOT = { opinion = { who = event_target:adventurer_target value = -40 } }
							opinion = { who = ROOT value = 20 }
						}
					}
					NOR = {
						is_inaccessible_trigger = yes
						trait = incapable
						is_married = event_target:adventurer_target
						opinion = { who = event_target:adventurer_target value = 0 }
						opinion = { who = liege value = 25 }
					}
				}
				move_character = ROOT
			}
		}

		# Create some courtiers
		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 = 25
		}
		create_random_soldier = {
			random_traits = yes
			dynasty = none
			religion = ROOT
			culture = ROOT
			female = no
			age = 29
		}
		
		# Begin approaching rulers
		character_event = { id = plus_adventurer.110 days = 1 }
	}
}

# Adventurer seeks a court to begin recruiting in
character_event = {
	id = plus_adventurer.110
	
	hide_window = yes
	is_triggered_only = yes
	
	trigger = {
		ROOT = { plus_valid_adventurer_trigger = yes }
		NOT = { has_character_flag = began_adventure }
		NOT = { wealth = 1000 }
	}
	
	immediate = {
		remove_do_not_disturb_effect = yes
		plus_find_adventurer_target_effect = yes
		plus_find_adventurer_origin_effect = yes
		plus_find_adventurer_location_effect = yes
		plus_find_adventurer_target_title_effect = yes
		
		# First ask from the top liege of their current location
		if = {
			limit = {
				event_target:adventurer_location = {
					owner = {
						top_liege = { plus_adventurer_can_approach_trigger = yes }
					}
				}
			}
			event_target:adventurer_location = {
				owner = {
					top_liege = { plus_travel_to_ruler_effect = yes }
				}
			}
		}
		
		# Then seek out rulers with common cause who don't like my target
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				plus_common_cause_trigger = yes
				plus_likes_adventurer_target_trigger = no
				plus_closest_to_adventurer_trigger = yes
			}
			plus_travel_to_ruler_effect = yes
		}
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				plus_common_cause_trigger = yes
				plus_likes_adventurer_target_trigger = no
				plus_close_to_adventurer_trigger = yes
			}
			plus_travel_to_ruler_effect = yes
		}
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				plus_common_cause_trigger = yes
				plus_likes_adventurer_target_trigger = no
				plus_not_close_to_adventurer_trigger = yes
			}
			plus_travel_to_ruler_effect = yes
		}
		
		# Then seek out rulers with common cause and are not bad candidates
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				plus_common_cause_trigger = yes
				plus_not_bad_candidate_trigger = yes
				plus_closest_to_adventurer_trigger = yes
			}
			plus_travel_to_ruler_effect = yes
		}
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				plus_common_cause_trigger = yes
				plus_not_bad_candidate_trigger = yes
				plus_close_to_adventurer_trigger = yes
			}
			plus_travel_to_ruler_effect = yes
		}
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				plus_common_cause_trigger = yes
				plus_not_bad_candidate_trigger = yes
				plus_not_close_to_adventurer_trigger = yes
			}
			plus_travel_to_ruler_effect = yes
		}
		
		# Then seek out rulers with common cause who don't like my target and who are further away
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				plus_common_cause_trigger = yes
				plus_likes_adventurer_target_trigger = no
				plus_far_from_adventurer_trigger = yes
			}
			plus_travel_to_ruler_effect = yes
		}
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				plus_common_cause_trigger = yes
				plus_likes_adventurer_target_trigger = no
				plus_furthest_from_adventurer_trigger = yes
			}
			plus_travel_to_ruler_effect = yes
		}
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				plus_common_cause_trigger = yes
				plus_likes_adventurer_target_trigger = no
			}
			plus_travel_to_ruler_effect = yes
		}
		
		# Then seek out rulers with common cause and are not bad candidates and who are further away
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				plus_common_cause_trigger = yes
				plus_not_bad_candidate_trigger = yes
				plus_far_from_adventurer_trigger = yes
			}
			plus_travel_to_ruler_effect = yes
		}
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				plus_common_cause_trigger = yes
				plus_not_bad_candidate_trigger = yes
				plus_furthest_from_adventurer_trigger = yes
			}
			plus_travel_to_ruler_effect = yes
		}
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				plus_common_cause_trigger = yes
				plus_not_bad_candidate_trigger = yes
			}
			plus_travel_to_ruler_effect = yes
		}

		# Then seek out rulers of my culture AND religion who are not bad candidates
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				culture = ROOT
				religion = ROOT
				plus_not_bad_candidate_trigger = yes
				plus_closest_to_adventurer_trigger = yes
			}
			plus_travel_to_ruler_effect = yes
		}
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				culture = ROOT
				religion = ROOT
				plus_not_bad_candidate_trigger = yes
				plus_close_to_adventurer_trigger = yes
			}
			plus_travel_to_ruler_effect = yes
		}
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				culture = ROOT
				religion = ROOT
				plus_not_bad_candidate_trigger = yes
				plus_not_close_to_adventurer_trigger = yes
			}
			plus_travel_to_ruler_effect = yes
		}
		
		# Then seek out rulers of my culture AND religion
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				culture = ROOT
				religion = ROOT
				plus_closest_to_adventurer_trigger = yes
			}
			plus_travel_to_ruler_effect = yes
		}
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				culture = ROOT
				religion = ROOT
				plus_close_to_adventurer_trigger = yes
			}
			plus_travel_to_ruler_effect = yes
		}
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				culture = ROOT
				religion = ROOT
				plus_not_close_to_adventurer_trigger = yes
			}
			plus_travel_to_ruler_effect = yes
		}

		# Then seek out rulers of my culture OR religion who are not bad candidates
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				OR = {
					culture = ROOT
					religion = ROOT
				}
				plus_not_bad_candidate_trigger = yes
				plus_closest_to_adventurer_trigger = yes
			}
			plus_travel_to_ruler_effect = yes
		}
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				OR = {
					culture = ROOT
					religion = ROOT
				}
				plus_not_bad_candidate_trigger = yes
				plus_close_to_adventurer_trigger = yes
			}
			plus_travel_to_ruler_effect = yes
		}
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				OR = {
					culture = ROOT
					religion = ROOT
				}
				plus_not_bad_candidate_trigger = yes
				plus_not_close_to_adventurer_trigger = yes
			}
			plus_travel_to_ruler_effect = yes
		}
		
		# Then seek out rulers of my culture OR religion
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				OR = {
					culture = ROOT
					religion = ROOT
				}
				plus_closest_to_adventurer_trigger = yes
			}
			plus_travel_to_ruler_effect = yes
		}
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				OR = {
					culture = ROOT
					religion = ROOT
				}
				plus_close_to_adventurer_trigger = yes
			}
			plus_travel_to_ruler_effect = yes
		}
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				OR = {
					culture = ROOT
					religion = ROOT
				}
				plus_not_close_to_adventurer_trigger = yes
			}
			plus_travel_to_ruler_effect = yes
		}

		# Then seek out rulers of my culture AND religion who are not bad candidates and who are further away
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				culture = ROOT
				religion = ROOT
				plus_not_bad_candidate_trigger = yes
				plus_far_from_adventurer_trigger = yes
			}
			plus_travel_to_ruler_effect = yes
		}
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				culture = ROOT
				religion = ROOT
				plus_not_bad_candidate_trigger = yes
				plus_furthest_from_adventurer_trigger = yes
			}
			plus_travel_to_ruler_effect = yes
		}
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				culture = ROOT
				religion = ROOT
				plus_not_bad_candidate_trigger = yes
			}
			plus_travel_to_ruler_effect = yes
		}
		
		# Then seek out rulers of my culture AND religion who are further away
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				culture = ROOT
				religion = ROOT
				plus_far_from_adventurer_trigger = yes
			}
			plus_travel_to_ruler_effect = yes
		}
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				culture = ROOT
				religion = ROOT
				plus_furthest_from_adventurer_trigger = yes
			}
			plus_travel_to_ruler_effect = yes
		}
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				culture = ROOT
				religion = ROOT
			}
			plus_travel_to_ruler_effect = yes
		}

		# Then seek out rulers of my culture OR religion who are not bad candidates and who are further away
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				OR = {
					culture = ROOT
					religion = ROOT
				}
				plus_not_bad_candidate_trigger = yes
				plus_far_from_adventurer_trigger = yes
			}
			plus_travel_to_ruler_effect = yes
		}
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				OR = {
					culture = ROOT
					religion = ROOT
				}
				plus_not_bad_candidate_trigger = yes
				plus_furthest_from_adventurer_trigger = yes
			}
			plus_travel_to_ruler_effect = yes
		}
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				OR = {
					culture = ROOT
					religion = ROOT
				}
				plus_not_bad_candidate_trigger = yes
			}
			plus_travel_to_ruler_effect = yes
		}
		
		# Then seek out rulers of my culture OR religion who are further away
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				OR = {
					culture = ROOT
					religion = ROOT
				}
				plus_far_from_adventurer_trigger = yes
			}
			plus_travel_to_ruler_effect = yes
		}
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				OR = {
					culture = ROOT
					religion = ROOT
				}
				plus_furthest_from_adventurer_trigger = yes
			}
			plus_travel_to_ruler_effect = yes
		}
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				OR = {
					culture = ROOT
					religion = ROOT
				}
			}
			plus_travel_to_ruler_effect = yes
		}
		
		# Then seek out anyone valid
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				plus_closest_to_adventurer_trigger = yes
			}
			plus_travel_to_ruler_effect = yes
		}
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				plus_close_to_adventurer_trigger = yes
			}
			plus_travel_to_ruler_effect = yes
		}
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				plus_not_close_to_adventurer_trigger = yes
			}
			plus_travel_to_ruler_effect = yes
		}
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				plus_far_from_adventurer_trigger = yes
			}
			plus_travel_to_ruler_effect = yes
		}
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
				plus_furthest_from_adventurer_trigger = yes
			}
			plus_travel_to_ruler_effect = yes
		}
		random_playable_ruler = {
			limit = {
				plus_adventurer_can_approach_trigger = yes
			}
			plus_travel_to_ruler_effect = yes
		}
		
		# Failing all that, wait a month
		ROOT = { add_character_modifier = { name = do_not_disturb duration = 30 hidden = yes } }
		character_event = { id = plus_adventurer.110 days = 30 }
	}
}

# Adventurer arrives at a foreign court and asks for support
character_event = {
	id = plus_adventurer.115
	picture = GFX_evt_emissary
	border = GFX_event_normal_frame_diplomacy
	
	desc = {
		text = EVTDESC_plus_adventurer_115
		trigger = { independent = yes }
	}
	desc = {
		text = EVTDESC_plus_adventurer_115_vassal
		trigger = { independent = no }
	}
	
	is_triggered_only = yes
	
	trigger = {
		FROM = {
			plus_valid_adventurer_trigger = yes
			NOT = { has_character_flag = began_adventure }
			NOR = {
				has_opinion_modifier = { who = ROOT  modifier = backed_adventurer }
				has_opinion_modifier = { who = ROOT  modifier = let_adventurer_stay }
				has_opinion_modifier = { who = ROOT  modifier = turned_adventurer_away }
				has_opinion_modifier = { who = ROOT  modifier = betrayed_adventurer }
			}
		}
	}
	
	immediate = {
		FROM = { remove_do_not_disturb_effect = yes }
	}
	
	option = {
		name = EVTOPTA_plus_adventurer_115 # I will give him my full support
		trigger = {
			wealth = 10
		}
		ai_chance = {
			factor = 20
			modifier = {
				factor = 0.75
				war = yes
			}
			modifier = {
				factor = 0.5
				FROM = { wealth = 500 }
			}
			modifier = {
				factor = 0.5
				FROM = { wealth = 750 }
			}
			modifier = {
				factor = 0.5
				FROM = { wealth = 1000 }
			}
			modifier = {
				factor = 5
				is_friend = FROM
			}
			modifier = {
				factor = 5
				is_rival = event_target:adventurer_target
			}
			modifier = {
				factor = 0
				OR = {
					is_friend = event_target:adventurer_target
					is_rival = FROM
					NOT = { opinion = { who = FROM value = -50 } }
					opinion = { who = event_target:adventurer_target value = 50 }
				}
			}
			modifier = {
				factor = 1.5
				religion = FROM
				NOT = { religion = event_target:adventurer_target }
			}
			modifier = {
				factor = 1.5
				culture = FROM
				NOT = { culture = event_target:adventurer_target }
			}
			modifier = {
				factor = 2
				is_close_relative = FROM
				NOT = { is_close_relative = event_target:adventurer_target }
			}
			modifier = {
				factor = 1.5
				OR = {
					dynasty = FROM
					is_allied_with = FROM
				}
				NOT = {
					is_close_relative = FROM
					dynasty = event_target:adventurer_target
					is_allied_with = event_target:adventurer_target
					has_non_aggression_pact_with = event_target:adventurer_target
				}
			}
			modifier = {
				factor = 0.1
				has_character_modifier = ai_austerity
			}
			modifier = {
				factor = 1.5
				trait = charitable
			}
			modifier = {
				factor = 0.25
				is_allied_with = event_target:adventurer_target
			}
			modifier = {
				factor = 0.5
				NOT = { is_allied_with = event_target:adventurer_target }
				has_non_aggression_pact_with = event_target:adventurer_target
			}
			modifier = {
				factor = 0.5
				trait = greedy
			}
			modifier = {
				factor = 0.5
				NOT = { religion = FROM }
			}
			modifier = {
				factor = 0.5
				NOT = { culture_group = FROM }
			}
			modifier = {
				factor = 0.75
				NOT = { opinion = { who = FROM value = 0 } }
			}
			modifier = {
				factor = 0.5
				NOT = { opinion = { who = FROM value = -25 } }
			}
			modifier = {
				factor = 1.25
				opinion = { who = FROM value = 25 }
			}
			modifier = {
				factor = 1.5
				opinion = { who = FROM value = 50 }
			}
			modifier = {
				factor = 2
				opinion = { who = FROM value = 75 }
			}
			modifier = {
				factor = 1.25
				NOT = { opinion = { who = event_target:adventurer_target value = -25 } }
			}
			modifier = {
				factor = 1.5
				NOT = { opinion = { who = event_target:adventurer_target value = -50 } }
			}
			modifier = {
				factor = 2
				NOT = { opinion = { who = event_target:adventurer_target value = -75 } }
			}
			modifier = {
				factor = 0.5
				opinion = { who = event_target:adventurer_target value = 25 }
			}
			modifier = {
				factor = 0.5
				FROM = { NOT = { diplomacy = 6 } }
			}
			modifier = {
				factor = 1.1
				FROM = { diplomacy = 10 }
			}
			modifier = {
				factor = 1.1
				FROM = { diplomacy = 12 }
			}
			modifier = {
				factor = 1.2
				FROM = { diplomacy = 14 }
			}
			modifier = {
				factor = 1.2
				FROM = { diplomacy = 16 }
			}
		}
		log = "plus_adventurer.115: [From.GetBestName] ([From.GetID]) has received full support for [From.GetHerHis] adventure from [Root.GetBestName] ([Root.GetID])"
		plus_donate_to_adventurer_effect = yes
		custom_tooltip = { text = ADVENTURER_RECRUITS_FROM_MY_LANDS }
		reverse_opinion = { who = FROM modifier = backed_adventurer years = 20 }
		reverse_opinion = { who = event_target:adventurer_target modifier = supported_adventurer_against_me multiplier = 2 years = 10 }
		
		hidden_tooltip = {
			# Inform targeted ruler
			if = {
				limit = {
					is_within_diplo_range = event_target:adventurer_target
					FROM = { NOT = { has_character_flag = not_interested_in_movement } }
				}
				event_target:adventurer_target = { character_event = { id = plus_adventurer.116 days = 1 } }
			}
			# Adventurer recruits in the demesne before moving on
			plus_adventurer_recruits_demesne = yes
		}		
	}
	option = {
		name = EVTOPTB_plus_adventurer_115 # He may raise support in my lands
		ai_chance = {
			factor = 30
			modifier = {
				factor = 0.75
				war = yes
			}
			modifier = {
				factor = 5
				is_friend = FROM
			}
			modifier = {
				factor = 5
				is_rival = event_target:adventurer_target
			}
			modifier = {
				factor = 0
				OR = {
					is_friend = event_target:adventurer_target
					is_rival = FROM
					NOT = { opinion = { who = FROM value = -50 } }
					opinion = { who = event_target:adventurer_target value = 50 }
				}
			}
			modifier = {
				factor = 1.5
				religion = FROM
				NOT = { religion = event_target:adventurer_target }
			}
			modifier = {
				factor = 1.5
				culture = FROM
				NOT = { culture = event_target:adventurer_target }
			}
			modifier = {
				factor = 2
				is_close_relative = FROM
				NOT = { is_close_relative = event_target:adventurer_target }
			}
			modifier = {
				factor = 1.5
				OR = {
					dynasty = FROM
					is_allied_with = FROM
				}
				NOR = {
					is_close_relative = FROM
					dynasty = event_target:adventurer_target
					is_allied_with = event_target:adventurer_target
					has_non_aggression_pact_with = event_target:adventurer_target
				}
			}
			modifier = {
				factor = 0.25
				is_allied_with = event_target:adventurer_target
			}
			modifier = {
				factor = 0.5
				NOT = { is_allied_with = event_target:adventurer_target }
				has_non_aggression_pact_with = event_target:adventurer_target
			}
			modifier = {
				factor = 0.5
				NOT = { religion = FROM }
			}
			modifier = {
				factor = 0.5
				NOT = { culture_group = FROM }
			}
			modifier = {
				factor = 0.75
				NOT = { opinion = { who = FROM value = 0 } }
			}
			modifier = {
				factor = 0.5
				NOT = { opinion = { who = FROM value = -25 } }
			}
			modifier = {
				factor = 1.25
				opinion = { who = FROM value = 25 }
			}
			modifier = {
				factor = 1.5
				opinion = { who = FROM value = 50 }
			}
			modifier = {
				factor = 2
				opinion = { who = FROM value = 75 }
			}
			modifier = {
				factor = 1.25
				NOT = { opinion = { who = event_target:adventurer_target value = -25 } }
			}
			modifier = {
				factor = 1.5
				NOT = { opinion = { who = event_target:adventurer_target value = -50 } }
			}
			modifier = {
				factor = 2
				NOT = { opinion = { who = event_target:adventurer_target value = -75 } }
			}
			modifier = {
				factor = 0.5
				opinion = { who = event_target:adventurer_target value = 25 }
			}
			modifier = {
				factor = 0.5
				FROM = { NOT = { diplomacy = 6 } }
			}
			modifier = {
				factor = 1.1
				FROM = { diplomacy = 10 }
			}
			modifier = {
				factor = 1.1
				FROM = { diplomacy = 12 }
			}
			modifier = {
				factor = 1.2
				FROM = { diplomacy = 14 }
			}
			modifier = {
				factor = 1.2
				FROM = { diplomacy = 16 }
			}
		}
		log = "plus_adventurer.115: [From.GetBestName] ([From.GetID]) has been permitted to recruit for [From.GetHerHis] adventure from [Root.GetBestName] ([Root.GetID])"
		custom_tooltip = { text = ADVENTURER_RECRUITS_FROM_MY_LANDS }
		reverse_opinion = { who = FROM modifier = let_adventurer_stay years = 20 }
		reverse_opinion = { who = event_target:adventurer_target modifier = supported_adventurer_against_me years = 10 }
		hidden_tooltip = {
			# Inform targeted ruler
			if = {
				limit = {
					is_within_diplo_range = event_target:adventurer_target
					FROM = { NOT = { has_character_flag = not_interested_in_movement } }
				}
				event_target:adventurer_target = { character_event = { id = plus_adventurer.117 days = 15 } }
			}
			# Adventurer recruits in the demesne before moving on
			plus_adventurer_recruits_demesne = yes
		}
	}
	option = {
		name = EVTOPTC_plus_adventurer_115 # He can do as he wishes, but not here
		ai_chance = {
			factor = 50
			modifier = {
				factor = 2
				NOT = { religion = FROM }
			}
			modifier = {
				factor = 1.5
				NOT = { culture = FROM }
			}
			modifier = {
				factor = 1.5
				NOT = { culture_group = FROM }
			}
		}
		log = "plus_adventurer.115: [From.GetBestName] ([From.GetID]) has been turned away by [Root.GetBestName] ([Root.GetID])"
		custom_tooltip = { text = ADVENTURER_MUST_MOVE_ON }
		reverse_opinion = { who = FROM modifier = turned_adventurer_away years = 20 }
		hidden_tooltip = {
			FROM = { character_event = { id = plus_adventurer.110 } }
		}
	}
	option = {
		name = EVTOPTD_plus_adventurer_115 # Betray him for a ransom
		trigger = {
			intrigue = 8
			NOT = { trait = honest }
		}
		ai_chance = {
			factor = 10
			modifier = {
				factor = 2
				NOT = { religion_group = FROM }
			}
			modifier = {
				factor = 4
				trait = deceitful
			}
			modifier = {
				factor = 2
				likes_better_than = { who = event_target:adventurer_target than = FROM }
			}
			modifier = {
				factor = 0.5
				likes_better_than = { who = FROM than = event_target:adventurer_target }
			}
			modifier = {
				factor = 1.5
				is_allied_with = event_target:adventurer_target
			}
			modifier = {
				factor = 1.5
				trait = cruel
			}
			modifier = {
				factor = 3
				trait = greedy
			}
			modifier = {
				factor = 1.25
				trait = arbitrary
			}
			modifier = {
				factor = 1.25
				has_character_modifier = ai_austerity
			}
			modifier = {
				factor = 1.25
				FROM = { NOT = { diplomacy = 6 } }
			}
			modifier = {
				factor = 0.8
				FROM = { diplomacy = 10 }
			}
			modifier = {
				factor = 0.8
				FROM = { diplomacy = 14 }
			}
			modifier = {
				factor = 0.8
				FROM = { diplomacy = 18 }
			}
			modifier = {
				factor = 0.5
				is_close_relative = FROM
			}
			modifier = {
				factor = 0.5
				trait = just
			}
			modifier = {
				factor = 0
				NOR = {
					trait = deceitful
					trait = ambitious
					trait = cruel
					is_allied_with = event_target:adventurer_target
				}
			}
			modifier = {
				factor = 0
				OR = {
					trait = kind
					has_truce = event_target:adventurer_target
					has_non_aggression_pact_with = event_target:adventurer_target
					war_with = event_target:adventurer_target
					is_rival = event_target:adventurer_target
					is_friend = FROM
				}
			}	
		}
		if = {
			limit = { trait = kind }
			random = {
				chance = 50
				remove_trait = kind
			}
		}
		if = {
			limit = { NOT = { trait = deceitful } }
			random = {
				chance = 50
				add_trait = deceitful
				
			}
		}
		tooltip_info = intrigue
		reverse_opinion = { who = FROM modifier = betrayed_adventurer years = 100 }
		random_list = {
			50 = {
				modifier = {
					factor = 1.2
					FROM = { attribute_diff = { character = ROOT attribute = intrigue value = 1 } }
				}
				modifier = {
					factor = 1.2
					FROM = { attribute_diff = { character = ROOT attribute = intrigue value = 3 } }
				}
				modifier = {
					factor = 1.2
					FROM = { attribute_diff = { character = ROOT attribute = intrigue value = 5 } }
				}
				modifier = {
					factor = 1.5
					FROM = { attribute_diff = { character = ROOT attribute = intrigue value = 7 } }
				}
				modifier = {
					factor = 1.5
					FROM = { attribute_diff = { character = ROOT attribute = intrigue value = 9 } }
				}
				modifier = {
					factor = 2.0
					FROM = { attribute_diff = { character = ROOT attribute = intrigue value = 11 } }
				}
				prestige = -50
				custom_tooltip = { text = ADVENTURER_ESCAPES }
				hidden_tooltip = {
					character_event = { id = plus_adventurer.120 }
					FROM = { character_event = { id = plus_adventurer.110 } } # Adventurer moves on
				}
			}
			50 = {
				modifier = {
					factor = 1.2
					attribute_diff = { character = FROM attribute = intrigue value = 1 }
				}
				modifier = {
					factor = 1.2
					attribute_diff = { character = FROM attribute = intrigue value = 3 }
				}
				modifier = {
					factor = 1.2
					attribute_diff = { character = FROM attribute = intrigue value = 5 }
				}
				modifier = {
					factor = 1.2
					attribute_diff = { character = FROM attribute = intrigue value = 7 }
				}
				modifier = {
					factor = 1.2
					attribute_diff = { character = FROM attribute = intrigue value = 9 }
				}
				FROM = { imprison = ROOT }
				event_target:adventurer_target = { letter_event = { id = plus_adventurer.122 tooltip = OFFER_ADVENTURER_FOR_RANSOM days = 3 } }
				hidden_tooltip = {
					character_event = { id = plus_adventurer.121 }
					FROM = { add_character_modifier = { name = do_not_disturb duration = 3 hidden = yes } }
				}
			}
		}
	}
}

# Targeted ruler hears that adventurer is being supported
character_event = {
	id = plus_adventurer.116
	desc = EVTDESC_plus_adventurer_116
	picture = GFX_evt_crusaders
	border = GFX_event_normal_frame_war
	
	is_triggered_only = yes
	show_from_from = yes
	
	trigger = {
		ai = no
		has_opinion_modifier = { who = FROMFROM modifier = opinion_targeted_by_adventurer }
		FROMFROM = { plus_valid_adventurer_trigger = yes }
		NOT = { has_character_flag = not_interested_in_movements }
	}
	
	option = {
		name = EVTOPTA_plus_adventurer_116
	}
	option = {
		name = EVTOPTB_plus_adventurer_116
		hidden_tooltip = {
			FROMFROM = { set_character_flag = not_interested_in_movements }
		}
	}
}

# Targeted ruler hears that adventurer is being allowed to recruit
character_event = {
	id = plus_adventurer.117
	desc = EVTDESC_plus_adventurer_117
	picture = GFX_evt_crusaders
	border = GFX_event_normal_frame_war
	
	is_triggered_only = yes
	show_from_from = yes
	
	trigger = {
		ai = no
		has_opinion_modifier = { who = FROMFROM modifier = opinion_targeted_by_adventurer }
		FROMFROM = { plus_valid_adventurer_trigger = yes }
		NOT = { has_character_flag = not_interested_in_movements }
	}
	
	option = {
		name = EVTOPTA_plus_adventurer_117
	}
	option = {
		name = EVTOPTB_plus_adventurer_116
		hidden_tooltip = {
			FROMFROM = { set_character_flag = not_interested_in_movements }
		}
	}
}

# Adventurer asks those in the realm for support
letter_event = {
	id = plus_adventurer.118
	desc = EVTDESC_plus_adventurer_118
	border = GFX_event_letter_frame_diplomacy
	
	is_triggered_only = yes
	show_from_from = yes
	
	trigger = {
		FROMFROM = { plus_valid_adventurer_trigger = yes }
	}
	
	option = {
		name = EVTOPTA_plus_adventurer_118 # Agree
		trigger = { wealth = 10 }
		ai_chance = {
			factor = 35
			modifier = {
				factor = 0.5
				FROMFROM = { wealth = 500 }
			}
			modifier = {
				factor = 0.5
				FROMFROM = { wealth = 750 }
			}
			modifier = {
				factor = 0.5
				FROMFROM = { wealth = 1000 }
			}
			modifier = {
				factor = 0.75
				NOT = { wealth = 25 }
			}
			modifier = {
				factor = 5
				is_friend = FROMFROM
			}
			modifier = {
				factor = 5
				is_rival = event_target:adventurer_target
			}
			modifier = {
				factor = 0
				OR = {
					is_friend = event_target:adventurer_target
					is_rival = FROMFROM
					NOT = { opinion = { who = FROMFROM value = -50 } }
					opinion = { who = event_target:adventurer_target value = 50 }
				}
			}
			modifier = {
				factor = 1.5
				religion = FROMFROM
				NOT = { religion = event_target:adventurer_target }
			}
			modifier = {
				factor = 1.5
				culture = FROMFROM
				NOT = { culture = event_target:adventurer_target }
			}
			modifier = {
				factor = 2
				is_close_relative = FROMFROM
				NOT = { is_close_relative = event_target:adventurer_target }
			}
			modifier = {
				factor = 1.5
				OR = {
					dynasty = FROMFROM
					is_allied_with = FROMFROM
				}
				NOR = {
					is_close_relative = FROMFROM
					dynasty = event_target:adventurer_target
					is_allied_with = event_target:adventurer_target
					has_non_aggression_pact_with = event_target:adventurer_target
				}
			}
			modifier = {
				factor = 0.1
				has_character_modifier = ai_austerity
			}
			modifier = {
				factor = 1.5
				trait = charitable
			}
			modifier = {
				factor = 0.25
				is_allied_with = event_target:adventurer_target
			}
			modifier = {
				factor = 0.5
				NOT = { is_allied_with = event_target:adventurer_target }
				has_non_aggression_pact_with = event_target:adventurer_target
			}
			modifier = {
				factor = 0.5
				trait = greedy
			}
			modifier = {
				factor = 0.5
				NOT = { religion = FROMFROM }
			}
			modifier = {
				factor = 0.8
				NOT = { culture = FROMFROM }
			}
			modifier = {
				factor = 0.5
				NOT = { culture_group = FROMFROM }
			}
			modifier = {
				factor = 0.75
				NOT = { opinion = { who = FROMFROM value = 0 } }
			}
			modifier = {
				factor = 0.5
				NOT = { opinion = { who = FROMFROM value = -25 } }
			}
			modifier = {
				factor = 1.25
				opinion = { who = FROMFROM value = 25 }
			}
			modifier = {
				factor = 1.5
				opinion = { who = FROMFROM value = 50 }
			}
			modifier = {
				factor = 2
				opinion = { who = FROMFROM value = 75 }
			}
			modifier = {
				factor = 1.25
				NOT = { opinion = { who = event_target:adventurer_target value = -25 } }
			}
			modifier = {
				factor = 1.5
				NOT = { opinion = { who = event_target:adventurer_target value = -50 } }
			}
			modifier = {
				factor = 2
				NOT = { opinion = { who = event_target:adventurer_target value = -75 } }
			}
			modifier = {
				factor = 0.5
				opinion = { who = event_target:adventurer_target value = 25 }
			}
			modifier = {
				factor = 0.5
				FROMFROM = { NOT = { diplomacy = 6 } }
			}
			modifier = {
				factor = 1.2
				FROMFROM = { diplomacy = 10 }
			}
			modifier = {
				factor = 1.2
				FROMFROM = { diplomacy = 12 }
			}
			modifier = {
				factor = 1.2
				FROMFROM = { diplomacy = 14 }
			}
			modifier = {
				factor = 1.2
				FROMFROM = { diplomacy = 16 }
			}
		}
		if = {
			limit = {
				wealth = 10
				NOT = { wealth = 40 }
			}
			wealth = -10
			FROMFROM = { wealth = 10 }
		}
		if = {
			limit = {
				wealth = 40
				NOT = { wealth = 80 }
			}
			wealth = -20
			FROMFROM = { wealth = 20 }
		}
		if = {
			limit = {
				wealth = 80
				NOT = { wealth = 120 }
			}
			wealth = -40
			FROMFROM = { wealth = 40 }
		}
		if = {
			limit = {
				wealth = 120
				NOT = { wealth = 160 }
			}
			wealth = -60
			FROMFROM = { wealth = 60 }
		}
		if = {
			limit = {
				wealth = 160
				NOT = { wealth = 200 }
			}
			wealth = -80
			FROMFROM = { wealth = 80 }
		}
		if = {
			limit = {
				wealth = 200
				NOT = { wealth = 300 }
			}
			wealth = -100
			FROMFROM = { wealth = 100 }
		}
		if = {
			limit = {
				wealth = 300
			}
			wealth = -150
			FROMFROM = { wealth = 150 }
		}
		reverse_opinion = { who = FROMFROM modifier = backed_adventurer years = 20 }
	}
	option = {
		name = EVTOPTB_plus_adventurer_118 # Refuse
		ai_chance = {
			factor = 65
		}
		reverse_opinion = { who = FROMFROM modifier = refused_adventurer years = 20 }
	}
}

# Adventurer recruits from a province in the realm
province_event = {
	id = plus_adventurer.119
	
	hide_window = yes
	is_triggered_only = yes
	
	trigger = {
		FROMFROM = { plus_valid_adventurer_trigger = yes }
	}
	
	immediate = {
		add_province_modifier = {
			name = adventurer_recruited
			duration = 900
		}
		if = {
			limit = {
				culture_group = FROMFROM
				religion = FROMFROM
			}
			random_list = {
				50 = {
					modifier = {
						factor = 0.8
						FROMFROM = {
							diplomacy = 10
							NOT = { diplomacy = 15 }
						}
					}
					modifier = {
						factor = 0.4
						FROMFROM = { diplomacy = 15 }
					}
					#no bonus
				}
				40 = {
					modifier = {
						factor = 0.75
						FROMFROM = { diplomacy = 10 }
					}
					FROMFROM = { wealth = 10 }
				}
				10 = {
					modifier = {
						factor = 2.0
						FROMFROM = {
							diplomacy = 10
							NOT = { diplomacy = 15 }
						}
					}
					modifier = {
						factor = 3.0
						FROMFROM = { diplomacy = 15 }
					}
					FROMFROM = { wealth = 20 }
				}
				10 = {
					modifier = {
						factor = 0
						FROMFROM = { NOT = { diplomacy = 10 } }
					}
					modifier = {
						factor = 2.0
						FROMFROM = { diplomacy = 15 }
					}
					FROMFROM = { wealth = 30 }
				}
			}
		}
		if = {
			limit = {
				OR = {
					NOT = { culture_group = FROMFROM }
					NOT = { religion = FROMFROM }
				}
				OR = {
					culture_group = FROMFROM
					religion = FROMFROM
				}
			}
			random_list = {
				60 = {
					modifier = {
						factor = 0.83
						FROMFROM = {
							diplomacy = 10
							NOT = { diplomacy = 15 }
						}
					}
					modifier = {
						factor = 0.58
						FROMFROM = { diplomacy = 15 }
					}
					#no bonus
				}
				30 = {
					modifier = {
						factor = 0.66
						FROMFROM = {
							diplomacy = 10
							NOT = { diplomacy = 15 }
						}
					}
					modifier = {
						factor = 1.17
						FROMFROM = { diplomacy = 15 }
					}
					FROMFROM = { wealth = 10 }
				}
				10 = {
					modifier = {
						factor = 2.0
						FROMFROM = { diplomacy = 10 }
					}
					FROMFROM = { wealth = 20 }
				}
				10 = {
					modifier = {
						factor = 0
						FROMFROM = { NOT = { diplomacy = 10 } }
					}
					FROMFROM = { wealth = 30 }
				}
			}
		}
		if = {
			limit = {
				NOT = { culture_group = FROMFROM }
				NOT = { religion = FROMFROM }
			}
			random_list = {
				80 = {
					modifier = {
						factor = 0.75
						FROMFROM = {
							diplomacy = 10
							NOT = { diplomacy = 15 }
						}
					}
					modifier = {
						factor = 0.56
						FROMFROM = { diplomacy = 15 }
					}
					FROMFROM = { wealth = 0 }
				}
				10 = {
					modifier = {
						factor = 3.0
						FROMFROM = {
							diplomacy = 10
							NOT = { diplomacy = 15 }
						}
					}
					modifier = {
						factor = 3.5
						FROMFROM = { diplomacy = 15 }
					}
					FROMFROM = { wealth = 10 }
				}
				10 = {
					modifier = {
						factor = 1.5
						FROMFROM = { diplomacy = 15 }
					}
					FROMFROM = { wealth = 20 }
				}
				5 = {
					modifier = {
						factor = 0
						FROMFROM = { NOT = { diplomacy = 15 } }
					}
					FROMFROM = { wealth = 30 }
				}
			}
		}
	}
}

# Adventurer escapes the trap and flees the realm
character_event = {
	id = plus_adventurer.120
	desc = EVTDESC_plus_adventurer_120
	picture = GFX_evt_bandits
	
	is_triggered_only = yes
	show_from_from = yes
	
	option = {
		name = CURSES
		log = "plus_adventurer.120: [FromFrom.GetBestName] ([FromFrom.GetID]) narrowly escaped a trap set by [Root.GetBestName] ([Root.GetID])"
	}
}

# Adventurer is imprisoned and can now be offered for ransom
character_event = {
	id = plus_adventurer.121
	desc = EVTDESC_plus_adventurer_121
	picture = GFX_evt_bandits
	
	is_triggered_only = yes
	show_from_from = yes
	
	option = {
		name = EXCELLENT
		log = "plus_adventurer.121: [FromFrom.GetBestName] ([FromFrom.GetID]) has been betrayed by [Root.GetBestName] ([Root.GetID]) and imprisoned"
	}
}

# Adventurer offered to the targeted ruler for ransom
letter_event = {
	id = plus_adventurer.122
	desc = EVTDESC_plus_adventurer_122
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_plus_adventurer_122 # Pay the ransom
		ai_chance = {
			factor = 75
			modifier = {
				factor = 0
				NOT = { wealth = 50 }
			}
			modifier = {
				factor = 0.5
				has_character_modifier = ai_austerity
			}
			modifier = {
				factor = 0.5
				trait = greedy
			}
			modifier = {
				factor = 0.75
				FROMFROM = { NOT = { wealth = 250 } }
			}
			modifier = {
				factor = 0.75
				FROMFROM = { NOT = { wealth = 200 } }
			}
			modifier = {
				factor = 0.75
				FROMFROM = { NOT = { wealth = 150 } }
			}
			modifier = {
				factor = 0.75
				FROMFROM = { NOT = { wealth = 100 } }
			}
		}
		log = "plus_adventurer.122: [FromFrom.GetBestName] ([FromFrom.GetID]) has been ransomed by [Root.GetBestName] ([Root.GetID]), ending the adventure"
		wealth = -50
		hidden_tooltip = {
			save_event_target_as = new_court_home
			FROM = { letter_event = { id = plus_adventurer.123 } }
			FROMFROM = {
				prisoner = no
				plus_abandon_adventure_effect = yes
				reverse_opinion = { who = ROOT modifier = opinion_traitor }
			}
		}
		FROMFROM = { imprison = ROOT }
	}
	option = {
		name = EVTOPTB_plus_adventurer_122 # Refuse
		ai_chance = {
			factor = 25
			modifier = {
				factor = 2
				trait = greedy
			}
		}
		hidden_tooltip = {
			FROM = { letter_event = { id = plus_adventurer.124 days = 3 } }
		}
	}
}

# Notification that the ransom has been paid
letter_event = {
	id = plus_adventurer.123
	desc = EVTDESC_plus_adventurer_123
	
	is_triggered_only = yes
	
	option = {
		name = EXCELLENT
		wealth = 50
		reverse_opinion = { who = FROM modifier = opinion_grateful years = 10 }
	}
}

# Notification that the ransom has been refused
letter_event = {
	id = plus_adventurer.124
	desc = EVTDESC_plus_adventurer_124
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_plus_adventurer_124 # Let him go
		log = "plus_adventurer.124: [From.GetBestName] ([From.GetID]) refused to pay the ransom for [FromFromFrom.GetBestName] ([FromFromFrom.GetID]), and [FromFromFrom.GetSheHe] was released"
		FROMFROMFROM = {
			prisoner = no
			hidden_tooltip = {
				character_event = { id = plus_adventurer.110 }
			}
		}
	}
	option = {
		name = EVTOPTB_plus_adventurer_124 # Leave him where he is
		custom_tooltip = { text = ADVENTURER_STAYS_IN_PRISON }
		log = "plus_adventurer.124: [From.GetBestName] ([From.GetID]) refused to pay the ransom for [FromFromFrom.GetBestName] ([FromFromFrom.GetID])"
	}
}

# Adventurer seeks support in the targeted liege's realm
character_event = {
	id = plus_adventurer.130
	
	hide_window = yes
	
	min_age = 16
	capable_only = yes
	prisoner = no
	has_character_flag = planning_claimant_adventure
	
	trigger = {
		plus_valid_adventurer_trigger = yes
		NOT = { has_character_flag = began_adventure }
		NOT = { wealth = 1000 }
		any_opinion_modifier_target = {
			is_alive = yes
			independent = yes
			has_opinion_modifier = { who = ROOT modifier = opinion_targeted_by_adventurer }
			any_realm_character = {
				wealth = 10
				is_within_diplo_range = ROOT
				is_adult = yes
				prisoner = no
				OR = {
					dynasty = ROOT
					is_close_relative = ROOT
					any_spouse = { is_close_relative = ROOT }
					opinion = { who = ROOT value = 40 }
					NOT = { opinion = { who = PREV value = -40 } }
				}
				NOR = {
					trait = incapable
					has_opinion_modifier = { who = ROOT modifier = opinion_targeted_by_adventurer }
					reverse_has_opinion_modifier = { who = ROOT modifier = turned_adventurer_away }
					reverse_has_opinion_modifier = { who = ROOT modifier = let_adventurer_stay }
					reverse_has_opinion_modifier = { who = ROOT modifier = backed_adventurer }
					reverse_has_opinion_modifier = { who = ROOT modifier = betrayed_adventurer }
					reverse_has_opinion_modifier = { who = ROOT modifier = refused_adventurer }
				}
			}
		}
	}
	
	mean_time_to_happen = {
		days = 20
		modifier = {
			factor = 0.5
			NOT = { wealth = 100 }
		}
		modifier = {
			factor = 1.5
			wealth = 300
		}
		modifier = {
			factor = 1.5
			wealth = 400
		}
		modifier = {
			factor = 2
			wealth = 500
		}
		modifier = {
			factor = 2
			wealth = 600
		}
		modifier = {
			factor = 2
			wealth = 700
		}
	}
	
	immediate = {
		random_opinion_modifier_target = {
			limit = { has_opinion_modifier = { who = ROOT modifier = opinion_targeted_by_adventurer } }
			random_realm_character = {
				limit = {
					wealth = 10
					is_within_diplo_range = ROOT
					is_adult = yes
					prisoner = no
					OR = {
						dynasty = ROOT
						is_close_relative = ROOT
						any_spouse = { is_close_relative = ROOT }
						opinion = { who = ROOT value = 40 }
						NOT = { opinion = { who = PREV value = -40 } }
					}
					NOR = {
						trait = incapable
						has_opinion_modifier = { who = ROOT modifier = opinion_targeted_by_adventurer }
						reverse_has_opinion_modifier = { who = ROOT modifier = turned_adventurer_away }
						reverse_has_opinion_modifier = { who = ROOT modifier = let_adventurer_stay }
						reverse_has_opinion_modifier = { who = ROOT modifier = backed_adventurer }
						reverse_has_opinion_modifier = { who = ROOT modifier = betrayed_adventurer }
						reverse_has_opinion_modifier = { who = ROOT modifier = refused_adventurer }
					}
				}
				letter_event = { id = plus_adventurer.131 }
			}
		}
	}
}

# Member of targeted ruler's realm receives plea for support
letter_event = {
	id = plus_adventurer.131
	desc = EVTDESC_plus_adventurer_131
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_plus_adventurer_131 # Agree
		ai_chance = {
			factor = 35
			modifier = {
				factor = 5
				OR = {
					in_faction = faction_pretender
					leads_faction = faction_pretender
				}
				supported_claimant = { character = FROM }
			}
			modifier = {
				factor = 0.75
				NOT = { wealth = 25 }
			}
			modifier = {
				factor = 0.5
				FROM = { wealth = 500 }
			}
			modifier = {
				factor = 0.5
				FROM = { wealth = 750 }
			}
			modifier = {
				factor = 0.5
				FROM = { wealth = 1000 }
			}
			modifier = {
				factor = 5
				is_friend = FROM
			}
			modifier = {
				factor = 5
				top_liege = { is_rival = ROOT }
			}
			modifier = {
				factor = 0
				OR = {
					top_liege = { is_friend = ROOT }
					is_rival = FROM
					NOT = { opinion = { who = FROM value = -50 } }
					top_liege = { reverse_opinion = { who = ROOT value = 50 } }
				}
			}
			modifier = {
				factor = 1.25
				religion = FROM
				top_liege = { NOT = { religion = ROOT } }
			}
			modifier = {
				factor = 1.25
				culture = FROM
				top_liege = { NOT = { culture = ROOT } }
			}
			modifier = {
				factor = 2
				is_close_relative = FROM
				top_liege = { NOT = { is_close_relative = ROOT } }
			}
			modifier = {
				factor = 1.5
				OR = {
					dynasty = FROM
					is_allied_with = FROM
				}
				NOR = {
					is_close_relative = FROM
					top_liege = { dynasty = ROOT }
					top_liege = { is_allied_with = ROOT }
					top_liege = { has_non_aggression_pact_with = ROOT }
				}
			}
			modifier = {
				factor = 0.1
				has_character_modifier = ai_austerity
			}
			modifier = {
				factor = 1.5
				trait = charitable
			}
			modifier = {
				factor = 0.5
				top_liege = { is_allied_with = ROOT }
			}
			modifier = {
				factor = 0.75
				top_liege = {
					NOT = { is_allied_with = ROOT }
					has_non_aggression_pact_with = ROOT
				}
			}
			modifier = {
				factor = 0.5
				trait = greedy
			}
			modifier = {
				factor = 0.5
				NOT = { religion = FROM }
			}
			modifier = {
				factor = 0.8
				NOT = { culture = FROM }
			}
			modifier = {
				factor = 0.5
				NOT = { culture_group = FROM }
			}
			modifier = {
				factor = 0.75
				NOT = { opinion = { who = FROM value = 0 } }
			}
			modifier = {
				factor = 0.5
				NOT = { opinion = { who = FROM value = -25 } }
			}
			modifier = {
				factor = 1.25
				opinion = { who = FROM value = 25 }
			}
			modifier = {
				factor = 1.5
				opinion = { who = FROM value = 50 }
			}
			modifier = {
				factor = 2
				opinion = { who = FROM value = 75 }
			}
			modifier = {
				factor = 1.25
				top_liege = { NOT = { reverse_opinion = { who = ROOT value = -25 } } }
			}
			modifier = {
				factor = 1.5
				top_liege = { NOT = { reverse_opinion = { who = ROOT value = -50 } } }
			}
			modifier = {
				factor = 2
				top_liege = { NOT = { reverse_opinion = { who = ROOT value = -75 } } }
			}
			modifier = {
				factor = 0.5
				top_liege = { reverse_opinion = { who = ROOT value = 25 } }
			}
			modifier = {
				factor = 0.5
				FROM = { NOT = { diplomacy = 6 } }
			}
			modifier = {
				factor = 1.2
				FROM = { diplomacy = 10 }
			}
			modifier = {
				factor = 1.2
				FROM = { diplomacy = 12 }
			}
			modifier = {
				factor = 1.2
				FROM = { diplomacy = 14 }
			}
			modifier = {
				factor = 1.2
				FROM = { diplomacy = 16 }
			}
		}
		plus_donate_to_adventurer_effect = yes
		reverse_opinion = { who = FROM modifier = backed_adventurer years = 20 }
		hidden_tooltip = {
			if = {
				limit = { wealth = 50 }
				random = {
					chance = 50
					modifier = {
						factor = 0.5
						top_liege = { NOT = { realm_intrigue = 20 } }
					}
					modifier = {
						factor = 1.5
						top_liege = { realm_intrigue = 40 }
					}
					top_liege = { character_event = { id = plus_adventurer.132 } }
				}
			}
		}
	}
	option = {
		name = EVTOPTB_plus_adventurer_131 # Refuse
		ai_chance = {
			factor = 65
		}
		reverse_opinion = { who = FROM modifier = refused_adventurer years = 20 }
	}
}

# Targeted ruler hears that someone prominent in their realm is supporting the adventurer
character_event = {
	id = plus_adventurer.132
	desc = EVTDESC_plus_adventurer_132
	picture = GFX_evt_crusaders
	border = GFX_event_normal_frame_war
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_plus_adventurer_132
		opinion = { who = FROM modifier = supported_adventurer_against_me multiplier = 2 years = 10 }
	}
}

# Adventurer is at least half way to raising their army
character_event = {
	id = plus_adventurer.133
	
	hide_window = yes
	
	min_age = 16
	capable_only = yes
	prisoner = no
	has_character_flag = planning_claimant_adventure
	
	trigger = {
		had_character_flag = { flag = planning_claimant_adventure days = 180 }
		NOT = { has_character_flag = warned_adventurer_target }
		plus_valid_adventurer_trigger = yes
		OR = {
			wealth = 200
			AND = {
				wealth = 100
				diplomacy = 10
				martial = 10
				OR = {
					diplomacy = 16
					trait = genius
					trait = brilliant_strategist
				}
			}
		}
	}
	
	mean_time_to_happen = {
		days = 1
	}
	
	immediate = {
		set_character_flag = warned_adventurer_target
		random_opinion_modifier_target = {
			limit = { reverse_has_opinion_modifier = { who = ROOT modifier = opinion_claimant_adventure_target } }
			character_event = { id = plus_adventurer.134 }
		}
	}
}

# Notify targeted ruler that adventurer is halfway to raising an army
character_event = {
	id = plus_adventurer.134
	desc = EVTDESC_plus_adventurer_134
	picture = GFX_evt_crusaders
	border = GFX_event_normal_frame_war

	is_triggered_only = yes
	
	trigger = { ai = no }
	
	option = {
		name = EVTOPTA_plus_adventurer_134
	}
}

# When adventurer is idle, send them off to a new realm (if possible}
character_event = {
	id = plus_adventurer.135
	
	hide_window = yes
	
	min_age = 16
	capable_only = yes
	prisoner = no
	has_character_flag = planning_claimant_adventure
	
	trigger = {
		plus_valid_adventurer_trigger = yes
		NOR = {
			has_character_flag = began_adventure
			wealth = 1000
		}
		is_not_busy_trigger = yes
	}
	
	mean_time_to_happen = {
		days = 30
		modifier = {
			factor = 2
			wealth = 400
		}
		modifier = {
			factor = 2
			wealth = 600
		}
		modifier = {
			factor = 2
			wealth = 800
		}
	}
	
	immediate = {
		character_event = { id = plus_adventurer.110 } # Adventurer moves on
	}
}

# Adventurer is ready to abandon their quest
character_event = {
	id = plus_adventurer.140
	
	hide_window = yes
	
	min_age = 16
	prisoner = no
	has_character_flag = planning_claimant_adventure
	
	trigger = {
		has_character_modifier = planning_claimant_adventure
		NOT = { has_character_flag = began_adventure }
		OR = {
			any_demesne_title = { adventurer = no }
			trait = incapable
			NOT = {
				any_opinion_modifier_target = {
					is_alive = yes
					independent = yes
					demesne_size = 1
					reverse_has_opinion_modifier = { who = ROOT modifier = opinion_claimant_adventure_target }
					has_opinion_modifier = { who = ROOT modifier = opinion_targeted_by_adventurer }
					any_demesne_title = { claimed_by = ROOT }
				}
			}
		}
	}
	
	mean_time_to_happen = {
		days = 1
	}
	
	immediate = {
		plus_find_adventurer_target_effect = yes
		plus_find_adventurer_location_effect = yes
		plus_find_friendly_court_effect = yes
		
		# If this is a timeout, tell the targeted ruler
		if = {
			limit = {
				NOT = { any_demesne_title = { adventurer = no } }
				NOT = { trait = incapable }
			}
			random_opinion_modifier_target = {
				limit = { reverse_has_opinion_modifier = { who = ROOT modifier = opinion_claimant_adventure_target } }
				log = "plus_adventurer.140: [Root.GetBestName] ([Root.GetID]) has abandoned [Root.GetHerHis] adventure against [This.GetBestName] ([This.GetID]) due to a time out"
				character_event = { id = plus_adventurer.141 }
			}
		}
		# If the adventurer has become incapable, tell the targeted ruler
		if = {
			limit = { trait = incapable }
			random_opinion_modifier_target = {
				limit = { reverse_has_opinion_modifier = { who = ROOT modifier = opinion_claimant_adventure_target } }
				log = "plus_adventurer.140: [Root.GetBestName] ([Root.GetID]) has abandoned [Root.GetHerHis] adventure against [This.GetBestName] ([This.GetID]) due to becoming incapable"
				character_event = { id = plus_adventurer.142 }
			}
		}
		# If the adventurer has become a ruler, tell the targeted ruler
		if = {
			limit = {
				NOT = { trait = incapable }
				any_demesne_title = { adventurer = no }
			}
			random_opinion_modifier_target = {
				limit = { reverse_has_opinion_modifier = { who = ROOT modifier = opinion_claimant_adventure_target } }
				log = "plus_adventurer.140: [Root.GetBestName] ([Root.GetID]) has abandoned [Root.GetHerHis] adventure against [This.GetBestName] ([This.GetID]) due to gaining a title"
				character_event = { id = plus_adventurer.143 }
			}
		}
		
		# Remove all adventurer statuses
		log = "plus_adventurer.140: [Root.GetBestName] ([Root.GetID]) will retire to the court of [new_court_home.GetBestName] ([new_court_home.GetID])"
		plus_abandon_adventure_effect = yes
	}
}

# Notify ruler that adventurer has abandoned their quest after too long
character_event = {
	id = plus_adventurer.141
	desc = EVTDESC_plus_adventurer_141
	picture = GFX_evt_crusaders
	border = GFX_event_normal_frame_war

	is_triggered_only = yes
	
	trigger = { ai = no }
	
	option = {
		name = EVTOPTA_plus_adventurer_141
	}
}

# Notify ruler that adventurer has abandoned their quest because they are incapable
character_event = {
	id = plus_adventurer.142
	desc = EVTDESC_plus_adventurer_142
	picture = GFX_evt_crusaders
	border = GFX_event_normal_frame_war

	is_triggered_only = yes
	
	trigger = { ai = no }
	
	option = {
		name = EVTOPTA_plus_adventurer_142
	}
}

# Notify ruler that adventurer has abandoned their quest because they are now a ruler themselves
character_event = {
	id = plus_adventurer.143
	desc = EVTDESC_plus_adventurer_143
	picture = GFX_evt_crusaders
	border = GFX_event_normal_frame_war

	is_triggered_only = yes
	
	trigger = { ai = no }
	
	option = {
		name = EVTOPTA_plus_adventurer_143
	}
}

# Adventurer dies while holding the title
character_event = {
	id = plus_adventurer.144
	
	is_triggered_only = yes
	hide_window = yes
	
	trigger = {
		any_demesne_title = { adventurer = yes }
		OR = {
			has_character_flag = claimant_adventurer
			has_character_modifier = planning_claimant_adventure
		}
	}
	
	immediate = {
		log = "plus_adventurer.144: [Root.GetBestName] ([Root.GetID]) has died, ending their adventure"
		
		# Deal with adventurer's wealth
		if = {
			limit = {
				current_heir = {
					OR = {
						is_child_of = ROOT
						is_married = ROOT
						dynasty = ROOT
					}
				}
			}
			current_heir = {
				ROOT = {
					transfer_scaled_wealth = {
						to = PREV
						value = all
					}
				}
			}
		}
		if = {
			limit = {
				current_heir = {
					NOR = {
						is_child_of = ROOT
						is_married = ROOT
						dynasty = ROOT
					}
				}
			}
			clear_wealth = yes
		}
		
		plus_find_adventurer_target_effect = yes
		event_target:adventurer_target = { character_event = { id = plus_adventurer.145 } } # notify target
		
		# Remove all adventurer statuses
		plus_find_friendly_court_effect = yes
		plus_abandon_adventure_effect = yes
	}
}

# Notify ruler of adventurer's death
character_event = {
	id = plus_adventurer.145
	desc = EVTDESC_plus_adventurer_145
	picture = GFX_evt_crusaders
	border = GFX_event_normal_frame_war

	is_triggered_only = yes
	
	trigger = { ai = no }
	
	option = {
		name = EVTOPTA_plus_adventurer_145
	}	
}

# Adventurer is ready to begin the war
character_event = {
	id = plus_adventurer.146
	
	hide_window = yes
	
	min_age = 16
	capable_only = yes
	prisoner = no
	has_character_flag = planning_claimant_adventure
	
	trigger = {
		had_character_flag = { flag = planning_claimant_adventure days = 365 }
		plus_valid_adventurer_trigger = yes
		NOR = {
			trait = wounded
			is_maimed_trigger = yes
			is_ill = yes
			has_character_flag = began_adventure
		}
		OR = {
			# Has enough wealth on their own
			wealth = 400
			# Has half the wealth and is very capable
			AND = {
				wealth = 200
				diplomacy = 10
				martial = 10
				OR = {
					diplomacy = 16
					trait = genius
					trait = brilliant_strategist
				}
			}
		}
	}
	
	mean_time_to_happen = {
		months = 6
		modifier = {
			factor = 2.0
			trait = patient
		}
		modifier = {
			factor = 2.0
			trait = paranoid
		}
		modifier = {
			factor = 0.75
			martial = 10
		}
		modifier = {
			factor = 0.75
			martial = 12
		}
		modifier = {
			factor = 0.75
			martial = 14
		}
		modifier = {
			factor = 0.75
			martial = 16
		}
		modifier = {
			factor = 0.75
			martial = 18
		}
		modifier = {
			factor = 0.75
			martial = 20
		}
		modifier = {
			factor = 1.5
			NOT = { martial = 8 }
		}
		modifier = {
			factor = 0.5
			trait = wroth
		}
		modifier = {
			factor = 0.1
			OR = {
				trait = lunatic
				trait = possessed
			}
		}
		modifier = {
			factor = 0.5
			had_character_flag = { flag = planning_claimant_adventure days = 730 }
		}
		modifier = {
			factor = 0.1
			had_character_flag = { flag = planning_claimant_adventure days = 900 }
		}
		modifier = {
			factor = 0.01
			had_character_flag = { flag = planning_claimant_adventure days = 1000 }
		}
	}
	
	immediate = {
		set_character_flag = began_adventure
		remove_do_not_disturb_effect = yes
		plus_find_adventurer_target_effect = yes
		plus_find_adventurer_target_title_effect = yes
		
		# Find a friendly court near the target realm, if possible
		random_playable_ruler = {
			limit = {
				is_landed = yes
				NOT = { same_realm = event_target:adventurer_target }
				OR = {
					reverse_has_opinion_modifier = { who = ROOT modifier = let_adventurer_stay }
					reverse_has_opinion_modifier = { who = ROOT modifier = backed_adventurer }
				}
				capital_scope = {
					event_target:adventurer_target = {
						capital_scope = {
							NOT = { distance = { where = PREVPREV value = 150 } }
						}
					}
				}
			}
			ROOT = { set_character_flag = found_attack_court }
			capital_scope = { save_event_target_as = attack_court }
		}
		random_playable_ruler = {
			limit = {
				is_landed = yes
				NOT = { same_realm = event_target:adventurer_target }
				OR = {
					reverse_has_opinion_modifier = { who = ROOT modifier = let_adventurer_stay }
					reverse_has_opinion_modifier = { who = ROOT modifier = backed_adventurer }
				}
				capital_scope = {
					event_target:adventurer_target = {
						capital_scope = {
							NOT = { distance = { where = PREVPREV value = 300 } }
						}
					}
				}
			}
			ROOT = { set_character_flag = found_attack_court }
			capital_scope = { save_event_target_as = attack_court }
		}
		if = {
			limit = { NOT = { has_character_flag = found_attack_court } }
			plus_find_adventurer_location_effect = yes
			event_target:adventurer_location = { save_event_target_as = attack_court }
		}
		clr_character_flag = found_attack_court
		
		# Now spawn the armies
		event_target:attack_court = {
			ROOT = {
				set_character_flag = claimant_adventurer
				# Base troops
				random_list = {
					30 = {
						spawn_unit = {
							province = PREV
							home = PREV
							owner = THIS
							leader = THIS
							match_character = event_target:adventurer_target
							match_mult = 0.2
							match_min = 1000
							match_max = 15000
							attrition = 0.25
							earmark = claimant_adventure
							cannot_inherit = yes
						}
						spawn_unit = {
							province = PREV
							home = PREV
							owner = THIS
							leader = THIS
							match_character = event_target:adventurer_target
							match_mult = 0.2
							match_min = 1000
							match_max = 15000
							attrition = 0.25
							earmark = claimant_adventure
							cannot_inherit = yes
						}
						spawn_unit = {
							province = PREV
							home = PREV
							owner = THIS
							leader = THIS
							match_character = event_target:adventurer_target
							match_mult = 0.2
							match_min = 1000
							match_max = 15000
							attrition = 0.25
							earmark = claimant_adventure
							cannot_inherit = yes
						}
					}
					40 = {
						spawn_unit = {
							province = PREV
							home = PREV
							owner = THIS
							leader = THIS
							match_character = event_target:adventurer_target
							match_mult = 0.175
							match_min = 1000
							match_max = 15000
							attrition = 0.25
							earmark = claimant_adventure
							cannot_inherit = yes
						}
						spawn_unit = {
							province = PREV
							home = PREV
							owner = THIS
							leader = THIS
							match_character = event_target:adventurer_target
							match_mult = 0.175
							match_min = 1000
							match_max = 15000
							attrition = 0.25
							earmark = claimant_adventure
							cannot_inherit = yes
						}
						spawn_unit = {
							province = PREV
							home = PREV
							owner = THIS
							leader = THIS
							match_character = event_target:adventurer_target
							match_mult = 0.175
							match_min = 1000
							match_max = 15000
							attrition = 0.25
							earmark = claimant_adventure
							cannot_inherit = yes
						}
					}
					30 = {
						spawn_unit = {
							province = PREV
							home = PREV
							owner = THIS
							leader = THIS
							match_character = event_target:adventurer_target
							match_mult = 0.15
							match_min = 1000
							match_max = 15000
							attrition = 0.25
							earmark = claimant_adventure
							cannot_inherit = yes
						}
						spawn_unit = {
							province = PREV
							home = PREV
							owner = THIS
							leader = THIS
							match_character = event_target:adventurer_target
							match_mult = 0.15
							match_min = 1000
							match_max = 15000
							attrition = 0.25
							earmark = claimant_adventure
							cannot_inherit = yes
						}
						spawn_unit = {
							province = PREV
							home = PREV
							owner = THIS
							leader = THIS
							match_character = event_target:adventurer_target
							match_mult = 0.15
							match_min = 1000
							match_max = 15000
							attrition = 0.25
							earmark = claimant_adventure
							cannot_inherit = yes
						}
					}
				}
				# Troops bought with wealth
				plus_adventurer_buy_troops_effect = yes
				plus_adventurer_buy_troops_effect = yes
				plus_adventurer_buy_troops_effect = yes
				plus_adventurer_buy_troops_effect = yes
				plus_adventurer_buy_troops_effect = yes
				plus_adventurer_buy_troops_effect = yes
				plus_adventurer_buy_troops_effect = yes
				plus_adventurer_buy_troops_effect = yes
				plus_adventurer_buy_troops_effect = yes
				plus_adventurer_buy_troops_effect = yes
				plus_adventurer_buy_troops_effect = yes
				plus_adventurer_buy_troops_effect = yes
				plus_adventurer_buy_troops_effect = yes
				plus_adventurer_buy_troops_effect = yes
				plus_adventurer_buy_troops_effect = yes
				plus_adventurer_buy_troops_effect = yes
				plus_adventurer_buy_troops_effect = yes
				plus_adventurer_buy_troops_effect = yes
				plus_adventurer_buy_troops_effect = yes
				plus_adventurer_buy_troops_effect = yes
				# Diplomacy/leadership troops
				if = {
					limit = { diplomacy = 12 }
					spawn_unit = {
						province = PREV
						home = PREV
						owner = THIS
						match_character = event_target:adventurer_target
						match_mult = 0.05
						match_min = 100
						match_max = 2000
						attrition = 0.25
						earmark = claimant_adventure
						merge = yes
						cannot_inherit = yes
					}
				}
				if = {
					limit = { diplomacy = 14 }
					spawn_unit = {
						province = PREV
						home = PREV
						owner = THIS
						match_character = event_target:adventurer_target
						match_mult = 0.05
						match_min = 100
						match_max = 2000
						attrition = 0.25
						earmark = claimant_adventure
						merge = yes
						cannot_inherit = yes
					}
				}
				if = {
					limit = { diplomacy = 16 }
					spawn_unit = {
						province = PREV
						home = PREV
						owner = THIS
						match_character = event_target:adventurer_target
						match_mult = 0.075
						match_min = 100
						match_max = 2000
						attrition = 0.25
						earmark = claimant_adventure
						merge = yes
						cannot_inherit = yes
					}
				}
				if = {
					limit = { diplomacy = 18 }
					spawn_unit = {
						province = PREV
						home = PREV
						owner = THIS
						match_character = event_target:adventurer_target
						match_mult = 0.075
						match_min = 100
						match_max = 2000
						attrition = 0.25
						earmark = claimant_adventure
						merge = yes
						cannot_inherit = yes
					}
				}
				if = {
					limit = { diplomacy = 20 }
					spawn_unit = {
						province = PREV
						home = PREV
						owner = THIS
						match_character = event_target:adventurer_target
						match_mult = 0.075
						match_min = 100
						match_max = 2000
						attrition = 0.25
						earmark = claimant_adventure
						merge = yes
						cannot_inherit = yes
					}
				}
				if = {
					limit = { 
						diplomacy = 10
						martial = 10
						OR = {
							trait = genius
							trait = brilliant_strategist
						}
					}
					spawn_unit = {
						province = PREV
						home = PREV
						owner = THIS
						match_character = event_target:adventurer_target
						match_mult = 0.125
						match_min = 300
						match_max = 5000
						attrition = 0.25
						earmark = claimant_adventure
						merge = yes
						cannot_inherit = yes
					}
				}
			}
		}
		
		# create a fleet, just to be sure
		spawn_fleet = {
			province = closest # closest sea zone
			owner = ROOT
			disband_on_peace = yes
			troops = {
				galleys = { 100 100 }
			}
			earmark = claimant_adventure
		}
		
		event_target:adventurer_target_title = {
			if = {
				limit = { holder = event_target:adventurer_target }
				log = "plus_adventurer.146: [Root.GetBestName] ([Root.GetID]) starts claim adventure for the [This.GetFullName]"
				holder_scope = {
					reverse_war = {
						target = ROOT
						casus_belli = claim
						thirdparty_title = PREV
						infamy = 0
					}
					reverse_remove_opinion = { who = ROOT modifier = opinion_claimant_adventure_target }
					remove_opinion = { who = ROOT modifier = opinion_targeted_by_adventurer }
				}
			}
		}
		
		character_event = { id = plus_adventurer.147 days = 1 } # double-check that we're at war
	}
}

character_event = {
	id = plus_adventurer.147
	
	hide_window = yes
	is_triggered_only = yes
	
	immediate = {
		if = {
			limit = { war = yes }
			add_trait = adventurer
			remove_character_modifier = planning_claimant_adventure
			clr_character_flag = planning_claimant_adventure
			clr_character_flag = warned_adventurer_target
			clr_character_flag = not_interested_in_movements
			break = yes
		}
		
		log = "ERROR: [Root.GetBestName] ([Root.GetID]) had an invalid adventure war, and thus must have their adventurer status removed"
		# Remove all adventurer statuses
		clr_character_flag = claimant_adventurer
		plus_find_friendly_court_effect = yes
		plus_abandon_adventure_effect = yes
	}
}

# Armies disbanded after five years of peace
character_event = {
	id = plus_adventurer.148
	desc = EVTDESC_plus_adventurer_148
	picture = GFX_evt_crusaders
	
	only_rulers = yes
	
	trigger = {
		has_earmarked_regiments = claimant_adventure
		war = no
		OR = {
			had_character_flag = { flag = claimant_adventurer days = 1825 }
			NOT = { has_character_flag = claimant_adventurer }
		}
	}
	
	mean_time_to_happen = {
		days = 30
	}
	
	option = {
		name = EVTOPTA_plus_adventurer_148
		clr_character_flag = claimant_adventurer
		disband_event_forces = claimant_adventure
	}
}

### DUCHY ADVENTURES

# An ambitious character with no inheritance begins to plan an adventure for a foreign title
character_event = {
	id = plus_adventurer.160
	
	hide_window = yes # Only fires for unplayable landless characters
	
	has_dlc = "The Old Gods"
	has_global_flag = viking_age_started
	min_age = 16
	max_age = 50
	capable_only = yes
	prisoner = no
	
	trigger = {
		NOT = {
			has_game_rule = {
				name = adventurers
				value = none
			}
		}
		
		NOT = { any_spouse = { is_ruler = yes } }

		OR = {
			is_female = no
			liege = { has_law = female_council_law_4 }
			liege = { has_law = true_cognatic_succession }
			AND = {			
				liege = { is_feminist_trigger = yes }
				is_feminist_trigger = yes
			}
			has_game_rule = {
				name = gender
				value = all
			}
			has_game_rule = {
				name = gender
				value = plus
			}
		}
		
		is_ruler = no
		is_ill = no
		
		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 = { # Only these for now
			culture_group = north_germanic
			culture_group = west_germanic
			culture_group = altaic
			culture = norman
			culture = frankish
			culture = breton
			culture = catalan
			AND = {
				culture = hungarian
				is_pagan_religion = yes
			}
			has_character_flag = demon_child_non_pagan
			trait = changeling
		}
		
		# Handled by event plus_adventurer.100
		NOT = { any_claim = { plus_valid_adv_target_title_trigger = yes } }
		
		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 }
					}
				}
			}
		}
		
		NOT = { has_character_modifier = planning_duchy_adventure }
	}
	
	mean_time_to_happen = {
		years = 100
		modifier = {
			factor = 0.5
			trait = ambitious
		}
		modifier = {
			factor = 0.5
			OR = {
				AND = {
					culture = norman
					NOT = { year = 1250 }
				}
				AND = {
					culture_group = north_germanic
					NOT = { year = 1066 }
				}
			}
		}
		modifier = {
			factor = 0.5
			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 = 0.5
			NOT = { year = 900 }
		}
		modifier = {
			factor = 0.75
			year = 900
			NOT = { year = 1000 }
		}
		modifier = {
			factor = 1.25
			year = 1000
		}
		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 = {
		if = {
			limit = { culture = norse }
			random = {
				chance = 75
				# Norse characters will first target low-levy realms in Britain, Normandy & Russia
				random_province = {
					limit = {
						NOT = { event_target:adventure_target_province = { always = yes } }
						owner = {
							top_liege = {
								plus_duchy_target_trigger = yes
								NOT = { culture_group = ROOT }
								NOT = { realm_levies = 2000 }
							}
						}
						same_sea_zone_province_trigger = yes
						OR = {
							port = yes
							borders_major_river = yes
						}
						OR = {
							region = custom_livonia
							region = custom_novgorod
							region = custom_muscovy
							region = custom_rus
							region = custom_england
							region = custom_scotland
							duchy = { title = d_normandy }
						}
					}
					save_event_target_as = adventure_target_province
				}
				# Norse characters will then target small realms in Britain, Normandy & Russia
				random_province = {
					limit = {
						NOT = { event_target:adventure_target_province = { always = yes } }
						owner = {
							top_liege = {
								plus_duchy_target_trigger = yes
								NOT = { culture_group = ROOT }
								NOT = { realm_size = 30 }
							}
						}
						same_sea_zone_province_trigger = yes
						OR = {
							port = yes
							borders_major_river = yes
						}
						OR = {
							region = custom_livonia
							region = custom_novgorod
							region = custom_muscovy
							region = custom_rus
							region = custom_england
							region = custom_scotland
							duchy = { title = d_normandy }
						}
					}
					save_event_target_as = adventure_target_province
				}
				# Norse characters will then target any realms in Britain, Normandy & Russia
				random_province = {
					limit = {
						NOT = { event_target:adventure_target_province = { always = yes } }
						owner = {
							top_liege = {
								plus_duchy_target_trigger = yes
								NOT = { culture_group = ROOT }
							}
						}
						same_sea_zone_province_trigger = yes
						OR = {
							port = yes
							borders_major_river = yes
						}
						OR = {
							region = custom_livonia
							region = custom_novgorod
							region = custom_muscovy
							region = custom_rus
							region = custom_england
							region = custom_scotland
							duchy = { title = d_normandy }
						}
					}
					save_event_target_as = adventure_target_province
				}
			}
		}

		# Seafaring cultures will target low-levy coastal realms of a different culture group first
		random_province = {
			limit = {
				ROOT = { is_seafarer = yes }
				NOT = { event_target:adventure_target_province = { always = yes } }
				owner = {
					top_liege = {
						plus_duchy_target_trigger = yes
						NOT = { culture_group = ROOT }
						NOT = { realm_levies = 2000 }
					}
				}
				OR = {
					port = yes
					borders_major_river = yes
				}
				same_sea_zone_province_trigger = yes
			}
			save_event_target_as = adventure_target_province
		}
		# Seafaring cultures will target smaller coastal realms of a different culture group first
		random_province = {
			limit = {
				ROOT = { is_seafarer = yes }
				NOT = { event_target:adventure_target_province = { always = yes } }
				owner = {
					top_liege = {
						plus_duchy_target_trigger = yes
						NOT = { culture_group = ROOT }
						NOT = { realm_size = 30 }
					}
				}
				OR = {
					port = yes
					borders_major_river = yes
				}
				same_sea_zone_province_trigger = yes
			}
			save_event_target_as = adventure_target_province
		}
		# Seafaring cultures will target low-levy tribal realms of a different culture group next
		random_province = {
			limit = {
				ROOT = { is_seafarer = yes }
				NOT = { event_target:adventure_target_province = { always = yes } }
				owner = {
					top_liege = {
						is_tribal = yes
						plus_duchy_target_trigger = yes
						NOT = { culture_group = ROOT }
						NOT = { realm_levies = 2000 }
						NOT = { prestige = 250 }
					}
				}
				OR = {
					port = yes
					borders_major_river = yes
				}
				same_sea_zone_province_trigger = yes
			}
			save_event_target_as = adventure_target_province
		}
		# Seafaring cultures will target low-levy coastal realms of a different culture next
		random_province = {
			limit = {
				ROOT = { is_seafarer = yes }
				NOT = { event_target:adventure_target_province = { always = yes } }
				owner = {
					top_liege = {
						plus_duchy_target_trigger = yes
						NOT = { culture = ROOT }
						NOT = { realm_levies = 2000 }
					}
				}
				OR = {
					port = yes
					borders_major_river = yes
				}
				same_sea_zone_province_trigger = yes
			}
			save_event_target_as = adventure_target_province
		}
		# Seafaring cultures will target smaller coastal realms of a different culture next
		random_province = {
			limit = {
				ROOT = { is_seafarer = yes }
				NOT = { event_target:adventure_target_province = { always = yes } }
				owner = {
					top_liege = {
						plus_duchy_target_trigger = yes
						NOT = { culture = ROOT }
						NOT = { realm_size = 30 }
					}
				}
				OR = {
					port = yes
					borders_major_river = yes
				}
				same_sea_zone_province_trigger = yes
			}
			save_event_target_as = adventure_target_province
		}
		# Seafaring cultures will target smaller tribal realms of a different culture next
		random_province = {
			limit = {
				ROOT = { is_seafarer = yes }
				NOT = { event_target:adventure_target_province = { always = yes } }
				owner = {
					top_liege = {
						is_tribal = yes
						plus_duchy_target_trigger = yes
						NOT = { culture = ROOT }
						NOT = { realm_size = 30 }
						NOT = { prestige = 250 }
					}
				}
				OR = {
					port = yes
					borders_major_river = yes
				}
				same_sea_zone_province_trigger = yes
			}
			save_event_target_as = adventure_target_province
		}
		# Seafaring cultures will then target any realms of a different culture group
		random_province = {
			limit = {
				ROOT = { is_seafarer = yes }
				NOT = { event_target:adventure_target_province = { always = yes } }
				owner = {
					top_liege = {
						plus_duchy_target_trigger = yes
						NOT = { culture_group = ROOT }
					}
				}
				OR = {
					port = yes
					borders_major_river = yes
				}
				same_sea_zone_province_trigger = yes
			}
			save_event_target_as = adventure_target_province
		}
		# Seafaring cultures will then target any realms of a different culture
		random_province = {
			limit = {
				ROOT = { is_seafarer = yes }
				NOT = { event_target:adventure_target_province = { always = yes } }
				owner = {
					top_liege = {
						plus_duchy_target_trigger = yes
						NOT = { culture = ROOT }
					}
				}
				OR = {
					port = yes
					borders_major_river = yes
				}
				same_sea_zone_province_trigger = yes
			}
			save_event_target_as = adventure_target_province
		}

		# Others will first target low-levy realms of a different culture neighboring their liege
		random_province = {
			limit = {
				NOT = { event_target:adventure_target_province = { always = yes } }
				owner = {
					top_liege = {
						plus_duchy_target_trigger = yes
						NOT = { realm_levies = 2000 }
						NOT = { culture = ROOT }
						any_realm_province = {
							any_neighbor_province = {
								owner = { is_liege_of = ROOT }
							}
						}
					}
				}
			}
			save_event_target_as = adventure_target_province
		}
		# Others will then target smaller realms of a different culture neighboring their liege
		random_province = {
			limit = {
				NOT = { event_target:adventure_target_province = { always = yes } }
				owner = {
					top_liege = {
						plus_duchy_target_trigger = yes
						NOT = { realm_size = 30 }
						NOT = { culture = ROOT }
						any_realm_province = {
							any_neighbor_province = {
								owner = { is_liege_of = ROOT }
							}
						}
					}
				}
			}
			save_event_target_as = adventure_target_province
		}
		# Others will then target realms of a different culture neighboring their liege
		random_province = {
			limit = {
				NOT = { event_target:adventure_target_province = { always = yes } }
				owner = {
					top_liege = {
						plus_duchy_target_trigger = yes
						NOT = { culture = ROOT }
						any_realm_province = {
							any_neighbor_province = {
								owner = { is_liege_of = ROOT }
							}
						}
					}
				}
			}
			save_event_target_as = adventure_target_province
		}
		# Others will then target low-levy realms of a different culture group neighboring their top liege's realm
		random_province = {
			limit = {
				NOT = { event_target:adventure_target_province = { always = yes } }
				owner = {
					top_liege = {
						plus_duchy_target_trigger = yes
						NOT = { culture_group = ROOT }
						NOT = { realm_levies = 2000 }
					}
				}
				any_neighbor_province = {
					owner = { same_realm = ROOT }
				}
			}
			save_event_target_as = adventure_target_province
		}
		# Others will then target smaller realms of a different culture group neighboring their top liege's realm
		random_province = {
			limit = {
				NOT = { event_target:adventure_target_province = { always = yes } }
				owner = {
					top_liege = {
						plus_duchy_target_trigger = yes
						NOT = { culture_group = ROOT }
						NOT = { realm_size = 30 }
					}
				}
				any_neighbor_province = {
					owner = { same_realm = ROOT }
				}
			}
			save_event_target_as = adventure_target_province
		}
		# Others will then target low-levy tribal realms of a different culture group neighboring their top liege's realm
		random_province = {
			limit = {
				NOT = { event_target:adventure_target_province = { always = yes } }
				owner = {
					top_liege = {
						is_tribal = yes
						plus_duchy_target_trigger = yes
						NOT = { culture_group = ROOT }
						NOT = { realm_levies = 2000 }
						NOT = { prestige = 250 }
					}
				}
				any_neighbor_province = {
					owner = { same_realm = ROOT }
				}
			}
			save_event_target_as = adventure_target_province
		}
		# Others will then target low-levy realms of a different culture neighboring their top liege's realm
		random_province = {
			limit = {
				NOT = { event_target:adventure_target_province = { always = yes } }
				owner = {
					top_liege = {
						plus_duchy_target_trigger = yes
						NOT = { culture = ROOT }
						NOT = { realm_levies = 2000 }
					}
				}
				any_neighbor_province = {
					owner = { same_realm = ROOT }
				}
			}
			save_event_target_as = adventure_target_province
		}
		# Others will then target smaller realms of a different culture neighboring their top liege's realm
		random_province = {
			limit = {
				NOT = { event_target:adventure_target_province = { always = yes } }
				owner = {
					top_liege = {
						plus_duchy_target_trigger = yes
						NOT = { culture = ROOT }
						NOT = { realm_size = 30 }
					}
				}
				any_neighbor_province = {
					owner = { same_realm = ROOT }
				}
			}
			save_event_target_as = adventure_target_province
		}
		# Others will then target smaller tribal realms of a different culture neighboring their top liege's realm
		random_province = {
			limit = {
				NOT = { event_target:adventure_target_province = { always = yes } }
				owner = {
					top_liege = {
						is_tribal = yes
						plus_duchy_target_trigger = yes
						NOT = { culture = ROOT }
						NOT = { realm_size = 30 }
						NOT = { prestige = 250 }
					}
				}
				any_neighbor_province = {
					owner = { same_realm = ROOT }
				}
			}
			save_event_target_as = adventure_target_province
		}
		# Others will then target any realm of a different culture group neighboring their top liege's realm
		random_province = {
			limit = {
				NOT = { event_target:adventure_target_province = { always = yes } }
				owner = {
					top_liege = {
						plus_duchy_target_trigger = yes
						NOT = { culture_group = ROOT }
					}
				}
				any_neighbor_province = {
					owner = { same_realm = ROOT }
				}
			}
			save_event_target_as = adventure_target_province
		}
		# Others will then target any realm of a different culture neighboring their top liege's realm
		random_province = {
			limit = {
				NOT = { event_target:adventure_target_province = { always = yes } }
				owner = {
					top_liege = {
						plus_duchy_target_trigger = yes
						NOT = { culture = ROOT }
					}
				}
				any_neighbor_province = {
					owner = { same_realm = ROOT }
				}
			}
			save_event_target_as = adventure_target_province
		}
		
		# Stop it here if nothing's found
		if = {
			limit = { NOT = { event_target:adventure_target_province = { always = yes } } }
			log = "plus_adventurer.160: [Root.GetBestName] ([Root.GetID]) wanted to become a duchy adventurer, but found no suitable target"
			break = yes
		}
		
		# come out of hiding if necessary
		end_inaccessibility_effect = yes #removes in hiding or in_seclusion
		
		add_character_modifier = { name = do_not_disturb hidden = yes duration = 365 }
		
		# Fire the event
		event_target:adventure_target_province = {
			owner = {
				top_liege = {
					ROOT = {
						opinion = { who = PREV years = 3 modifier = opinion_duchy_adventure_target }
						add_character_modifier = { name = planning_duchy_adventure hidden = yes duration = 720 }
						character_event = { id = plus_adventurer.162 days = 720 } # Fire the attack
					}
					character_event = { id = plus_adventurer.161 } # Warn the target
				}
			}
		}
	}
}

character_event = {
	id = plus_adventurer.161
	desc = EVTDESC_plus_adventurer_161
	picture = GFX_evt_crusaders
	border = GFX_event_normal_frame_war
	
	is_triggered_only = yes
	
	immediate = {
		opinion = {
			who = FROM
			modifier = opinion_targeted_by_adventurer
			months = 24
		}
	}
	
	option = {
		name = EVTOPTA_plus_adventurer_161
	}
}

# An ambitious character with no inheritance starts an adventure for a foreign title
# (Temporary title created and a war declared)
character_event = {
	id = plus_adventurer.162
	
	hide_window = yes # Only fires for unplayable landless characters
	is_triggered_only = yes
	
	trigger = {
		ai = yes
		is_ruler = no
		prisoner = no
		NOR = {
			trait = incapable
			any_heir_title = { always = yes }
		}
	}
	
	immediate = {
		# Check if the target is no longer applicable
		event_target:adventure_target_province = {
			owner = { top_liege = { save_event_target_as = duchy_adventure_target } }
		}
		
		if = {
			limit = {
				NOT = {
					event_target:duchy_adventure_target = {
						reverse_has_opinion_modifier = { who = ROOT modifier = opinion_duchy_adventure_target }
						NOR = {
							is_allied_with = ROOT
							has_non_aggression_pact_with = ROOT
							any_spouse = { character = ROOT }
						}
					}
				}
			}
			any_opinion_modifier_target = {
				limit = {
					is_alive = yes
					reverse_has_opinion_modifier = { who = ROOT modifier = opinion_duchy_adventure_target }
				}
				reverse_remove_opinion = { who = ROOT modifier = opinion_duchy_adventure_target }
			}
			character_event = { id = plus_adventurer.160 }
			break = yes
		}
		
		remove_do_not_disturb_effect = yes
		
		# Target is good: start the war
		log = "plus_adventurer.162 [Root.GetBestName] ([Root.GetID]) has begun their duchy adventure against [duchy_adventure_target.GetBestName] ([duchy_adventure_target.GetID]) for the [adventure_target_province.Duchy.GetFullName] ([adventure_target_province.Duchy.GetID])"
		
		liege = {
			character_event = { id = plus_adventurer.163 days = 1 }
		}
		
		liege = {
			capital_scope = {		
				save_event_target_as = adventure_home_province
				duchy = { save_event_target_as = adventure_home_duchy }
				event_target:adventure_target_province = {
					event_target:duchy_adventure_target = {
						ROOT = {
							create_title = {
								tier = DUKE
								landless = yes
								temporary = yes
								adventurer = yes
								culture = ROOT
								name = "CLAIMANT_ADVENTURE"
								holder = ROOT
								ruler = "LORD"
								ruler_female = "LADY"
								base_title = event_target:adventure_home_duchy
							}
							
							set_defacto_liege = ROOT
							set_character_flag = duchy_adventurer
							clear_event_target = adventure_home_duchy
							
							# Base troops
							spawn_unit = {
								province = PREVPREVPREV
								home = PREVPREVPREV
								owner = THIS
								match_character = PREV
								match_mult = 0.125
								match_min = 1500
								match_max = 10000
								attrition = 0.25
								cannot_inherit = yes
							}
							spawn_unit = {
								province = PREVPREVPREV
								home = PREVPREVPREV
								owner = THIS
								match_character = PREV
								match_mult = 0.125
								match_min = 1500
								match_max = 10000
								attrition = 0.25
								cannot_inherit = yes
							}
							spawn_unit = {
								province = PREVPREVPREV
								home = PREVPREVPREV
								owner = THIS
								match_character = PREV
								match_mult = 0.125
								match_min = 1500
								match_max = 10000
								attrition = 0.25
								cannot_inherit = yes
							}
							if = {
								limit = { NOT = { year = 1000 } }
								random = {
									chance = 25
									spawn_unit = {
										province = PREVPREVPREV
										home = PREVPREVPREV
										owner = THIS
										match_character = PREV
										match_mult = 0.125
										match_min = 500
										match_max = 1500
										attrition = 0.25
										cannot_inherit = yes
										merge = yes
									}
								}
								random = {
									chance = 25
									spawn_unit = {
										province = PREVPREVPREV
										home = PREVPREVPREV
										owner = THIS
										match_character = PREV
										match_mult = 0.125
										match_min = 500
										match_max = 1500
										attrition = 0.25
										cannot_inherit = yes
										merge = yes
									}
								}
							}
							
							# Extra troops based on qualities
							if = {
								limit = { martial = 12 }
								spawn_unit = {
									province = PREVPREVPREV
									home = PREVPREVPREV
									owner = THIS
									match_character = PREV
									match_mult = 0.125
									match_min = 500
									match_max = 1500
									attrition = 0.25
									cannot_inherit = yes
									merge = yes
								}
							}
							if = {
								limit = { martial = 16 }
								spawn_unit = {
									province = PREVPREVPREV
									home = PREVPREVPREV
									owner = THIS
									match_character = PREV
									match_mult = 0.125
									match_min = 500
									match_max = 1500
									attrition = 0.25
									cannot_inherit = yes
									merge = yes
								}
							}
							if = {
								limit = { diplomacy = 12 }
								spawn_unit = {
									province = PREVPREVPREV
									home = PREVPREVPREV
									owner = THIS
									match_character = PREV
									match_mult = 0.125
									match_min = 500
									match_max = 1500
									attrition = 0.25
									cannot_inherit = yes
									merge = yes
								}
							}
							if = {
								limit = { trait = brave }
								spawn_unit = {
									province = PREVPREVPREV
									home = PREVPREVPREV
									owner = THIS
									match_character = PREV
									match_mult = 0.125
									match_min = 500
									match_max = 1500
									attrition = 0.25
									cannot_inherit = yes
									merge = yes
								}
							}
							if = {
								limit = { is_strong_trigger = yes }
								spawn_unit = {
									province = PREVPREVPREV
									home = PREVPREVPREV
									owner = THIS
									match_character = PREV
									match_mult = 0.125
									match_min = 500
									match_max = 1500
									attrition = 0.25
									cannot_inherit = yes
									merge = yes
								}
							}
							if = {
								limit = {
									prestige = 500
									NOT = { year = 1000 }
								}
								spawn_unit = {
									province = PREVPREVPREV
									home = PREVPREVPREV
									owner = THIS
									match_character = PREV
									match_mult = 0.125
									match_min = 500
									match_max = 1500
									attrition = 0.25
									cannot_inherit = yes
									merge = yes
								}
							}
							war = {
								target = PREV
								casus_belli = duchy_adventure
								thirdparty_title = PREVPREV
								tier = DUKE
								infamy = 0
							}
							remove_opinion = { who = PREV modifier = opinion_duchy_adventure_target }
						}
					}
				}
			}
		}
		
		# Create some decent commander characters
		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 = 25
		}
		create_random_soldier = {
			random_traits = yes
			dynasty = none
			religion = ROOT
			culture = ROOT
			female = no
			age = 25
		}
		
		if  = {
			limit = { 
				OR = {
					is_seafarer = yes 					
					event_target:adventure_home_province = { is_island = yes }					
					event_target:adventure_target_province = { is_island = yes }					
				}
			}
			# Create a fleet, just to be sure
			spawn_fleet = {
				province = closest # closest sea zone
				owner = ROOT
				disband_on_peace = yes
				troops = {
					galleys = { 200 200 }
				}
			}
		}
	}
}

character_event = {
	id = plus_adventurer.163
	desc = EVTDESC_plus_adventurer_163
	picture = GFX_evt_crusaders
	border = GFX_event_normal_frame_war
	
	is_triggered_only = yes
	
	trigger = {
		FROM = { is_ruler = yes } # The DoW worked and the adventurer has a temporary title
	}
	
	immediate = {
		FROM = { add_trait = adventurer }
		any_liege = {
			character_event = {
				id = plus_adventurer.164
			}
		}
	}
	
	option = {
		name = EVTOPTA_plus_adventurer_163
	}
}

character_event = {
	id = plus_adventurer.164
	desc = EVTDESC_plus_adventurer_164
	picture = GFX_evt_crusaders
	border = GFX_event_normal_frame_war
	
	show_from_from = yes
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_plus_adventurer_163
	}
}

# Extra norse adventurers appear after the Viking Age begins
character_event = {
	id = plus_adventurer.165
	
	hide_window = yes
	
	has_dlc = "The Old Gods"
	has_global_flag = viking_age_started	
	ai = yes
	only_playable = yes
	culture = norse
	religion = norse_pagan
	
	trigger = {
		holy_order = no
		mercenary = no
		NOT = {
			has_game_rule = {
				name = adventurers
				value = none
			}
		}
		NOT = { any_spouse = { is_ruler = yes } }

		OR = {
			is_female = no
			liege = { has_law = female_council_law_4 }
			liege = { has_law = true_cognatic_succession }
			AND = {			
				liege = { is_feminist_trigger = yes }
				is_feminist_trigger = yes
			}
			has_game_rule = {
				name = gender
				value = all
			}
			has_game_rule = {
				name = gender
				value = plus
			}
		}
		OR = {
			war = yes
			is_looting = yes
			year = 950
		}
		NOR = {
			year = 1000
			any_courtier = { has_character_modifier = planning_duchy_adventure }
		}
		capital_scope = {
			port = yes
			region = world_europe_north
		}
		OR = {
			NOT = { has_global_flag = extra_norse_adventurers }
			had_global_flag = { flag = extra_norse_adventurers days = 3650 }
			AND = {
				year = 950
				had_global_flag = { flag = extra_norse_adventurers days = 1825 }
			}
		}
	}
	
	mean_time_to_happen = {
		months = 12
		modifier = {
			factor = 0.5
			independent = yes
		}
		modifier = {
			factor = 2.0
			year = 950
			capital_scope = {
				NOR = {
					region = custom_norway
					region = custom_denmark
				}
			}
		}
		modifier = {
			factor = 5
			NOT = { has_global_flag = extra_norse_adventurers }
		}
		modifier = {
			factor = 50
			has_game_rule = {
				name = adventurers
				value = rare
			}
		}
	}
	
	immediate = {
		set_global_flag = extra_norse_adventurers
		create_random_soldier = {
			random_traits = yes
			dynasty = none
			religion = ROOT
			culture = ROOT
			female = no
			age = 30
			health = 6
			attributes = {
				martial = 8
				diplomacy = 8
			}
			trait = viking
			trait = skilled_tactician
			trait = ambitious
		}
		new_character = {
			prestige = 250
			remove_trait = humble
			remove_trait = depressed
			remove_trait = imbecile
			remove_trait = weak
			remove_trait = feeble
			remove_trait = blinded
			remove_trait = celibate
			remove_trait = craven
			random = {
				chance = 50
				remove_trait = skilled_tactician
				add_trait = brilliant_strategist
			}
			random = {
				chance = 50
				add_trait = brave
			}
			character_event = { id = plus_adventurer.160 }
		}
	}
}

