﻿# old stuff
#el_landed_invit_adventurer_interaction = {
#	common_interaction = yes
#	category = interaction_category_diplomacy
#	cooldown_against_recipient = { years = 5 }
#	greeting = positive
#	icon = landless_adventurer_government
#	desc = el_landed_invit_adventurer_interaction_desc
#
#	popup_on_receive = yes
#	pause_on_receive = yes
#
#	interface_priority = 60
#	ai_min_reply_days = 4
#	ai_max_reply_days = 9
#	send_options_exclusive = no
#	is_shown = {
#		has_ep3_dlc_trigger = yes
#		scope:actor = { 
#			is_landed = yes 
#			is_ai = no
#			}
#		NOT = { scope:recipient = scope:actor }
#		scope:recipient = {
#			is_landless_adventurer = yes
#		}
#	}
#	is_valid_showing_failures_only  = {
#		scope:actor = {
#			is_at_war = no
#			is_ai = no
#			is_adult = yes
#			is_travelling = no
#			NOT = {
#				capital_county ?= {
#					any_county_province = {
#						this = scope:recipient.domicile.domicile_location
#					}
#				}
#			}
#					
#		}
#		scope:recipient = {
#			in_diplomatic_range = scope:actor
#			is_travelling = no
#			is_at_war = no
#			is_adult = yes
#			is_landless_adventurer = yes
#			is_busy_in_events_unlocalised = no
#		}
#	}
#	send_option = {
#		is_shown = {
#			exists = scope:recipient
#		}
#		flag = use_gold 
#		localization = el_landed_invit_adventurer_interaction_use_gold
#	}
#	send_option = {
#		is_shown = {
#			exists = scope:recipient
#		}
#		flag = use_prestige
#		localization = el_landed_invit_adventurer_interaction_use_prestige
#	}
#	send_option = {
#		is_valid = {
#			scope:actor = {
#				has_usable_hook = scope:recipient
#			}
#		}
#		flag = hook
#		localization = SCHEME_HOOK
#	}
#	on_accept = {
#		scope:actor = {
#			send_interface_toast = {
#				type = event_toast_text_and_effect_good
#				title = el_landed_invit_adventurer_interaction.toast.t
#				left_icon = scope:recipient
#				desc = el_landed_invit_adventurer_interaction.toast.t.desc
#			}
#		}
#		scope:actor.capital_county = {
#			random_county_province = {
#				save_scope_as = relocation_destination
#			}
#		}
#		if = {
#			limit = { always = scope:hook }
#			scope:actor = {
#				use_hook = scope:recipient
#			}
#		}
#		
#		scope:recipient = {
#			add_character_flag = el_check_provision
#			custom_tooltip =  el_landed_invit_adventurer_interaction.t
#			show_as_tooltip = {
#				domicile = {
#					move_domicile = scope:relocation_destination
#				}
#			}
#			start_travel_plan = {
#				destination = scope:relocation_destination
#				on_start_on_action = on_travel_relocation_start
#				on_arrival_on_action = on_travel_relocation_end
#				on_arrival_destinations = last
#				return_trip = no 
#				travel_with_domicile = yes
#			}
#		}
#		if = {
#			limit = { always = scope:use_gold  }
#			scope:actor = {
#				pay_short_term_gold = {
#					gold = {
#						value = bribe_value
#						multiply = 0.15
#					}
#					target = scope:recipient
#				}
#				stress_impact = {
#					greedy = minor_stress_impact_gain
#				}
#			}
#		}
#		if = {
#			limit = { always = scope:use_prestige }
#			scope:actor = {
#				add_prestige = medium_prestige_loss
#				stress_impact = {
#					greedy = minor_stress_impact_gain
#				}
#			}
#			scope:recipient = {
#				add_prestige = medium_prestige_gain
#			}
#		}
#	}
#
#	ai_frequency = 0
#	
#	ai_accept = {
# 		base = -50
# 		opinion_modifier = {
# 			opinion_target = scope:actor
# 			multiplier = 0.5
# 			step = 5
# 			max = 50
# 		}
#		modifier = {
#			add = {
#				value = 40
#				if = {
#					limit = {
#						has_trait = greedy
#					}
#					multiply = 1.5
#				}
#				else_if = {
#					limit = {
#						has_trait = generous
#					}
#					multiply = 0.5
#				}
#			}
#			scope:use_gold = yes
#			desc = el_landed_invit_adventurer_interaction_ai_use_gold
#		}
#		modifier = {
#			add = {
#				value = 40
#				if = {
#					limit = {
#						has_trait = ambitious
#					}
#					multiply = 1.5
#				}
#				else_if = {
#					limit = {
#						has_trait = lazy
#					}
#					multiply = 0.5
#				}
#			}
#			scope:use_prestige = yes
#			desc = el_landed_invit_adventurer_interaction_ai_use_gold
#		}
#		
#		modifier = {
#			add = {
#				value =  0
#				if = {
#					limit = {
#						scope:recipient = {
#							exists = domicile
#							domicile = { provisions <= provisions_threshold_low_value }
#							scope:recipient.domicile.domicile_location = { squared_distance = { target = scope:actor.capital_province value > squared_distance_medium } }							
#							}							
#						}
#						add = -1000
#					}
#					else_if = {
#						limit = {
#						scope:recipient = {
#							exists = domicile
#							domicile = { provisions <= provisions_threshold_mid_value }
#							scope:recipient.domicile.domicile_location = { squared_distance = { target = scope:actor.capital_province value > squared_distance_large } }							
#							}							
#						}
#						add = -1000
#					}
#					else_if = {
#						limit = {
#						scope:recipient = {
#							exists = domicile
#							scope:recipient.domicile.domicile_location = { squared_distance = { target = scope:actor.capital_province value > squared_distance_huge } }							
#							}							
#						}
#						add = -1000
#					}
#					else_if = {
#						limit = {
#						scope:recipient = {
#							exists = domicile
#							domicile = { provisions <= provisions_threshold_critical_low_value }						
#							}							
#						}
#						add = -1000
#					}
#				}
#				desc = el_landed_invit_adventurer_interaction_ai_low_provision
#			}
#		}	
#	}			


el_landed_invit_adventurer_interaction = {
	common_interaction = yes
	category = interaction_category_diplomacy
	cooldown = { years = 1 }
	greeting = positive
	icon = contract
	desc = el_landed_invit_adventurer_interaction_desc

	popup_on_receive = yes
	pause_on_receive = yes

	interface_priority = 60
	send_options_exclusive = no
	is_shown = {
		has_ep3_dlc_trigger = yes
		scope:actor = { 
			is_landed = yes 
			is_ai = no
			NOT = {
				is_target_in_variable_list = {
					name = el_landed_refuted_list
					target = scope:recipient
				}
			}
		}
		scope:recipient = {
			is_landless_adventurer = yes
			is_ai = yes
		}
	}
	is_valid_showing_failures_only  = {
		scope:actor = {
			is_at_war = no
			is_ai = no
			is_adult = yes
			is_travelling = no
			is_imprisoned = no
			is_incapable = no
			is_in_army = no		
			NOT = { is_decision_on_cooldown = landed_el_decision }
			NOT = {
				is_target_in_variable_list = {
					name = el_landed_refuted_list
					target = scope:recipient
				}
			}
		}
		scope:recipient = {
			in_diplomatic_range = scope:actor
			has_government = landless_adventurer_government
			is_travelling = no
			is_at_war = no
			is_ai = yes
			is_in_army = no
			is_incapable = no
			NOT = { has_trait = infirm }
			is_adult = yes
			is_imprisoned = no
			NOT = { has_relation_rival = scope:actor }
			is_busy_in_events_unlocalised = no
			custom_tooltip = {
				text = el_landed_invit_adventurer_interaction_tt1
				domicile.domicile_location = {
					squared_distance = { target = scope:actor.capital_province value < el_squared_distance_camp }
				}
			}
		}
	}
	auto_accept = yes
	on_accept = {
		scope:recipient = {
			save_scope_as = el_adventurer_fin
			add_character_flag = {
				flag = is_in_task_contract_event_chain
				days = 365
			}
			custom_tooltip =  el_landed_invit_adventurer_interaction.t
		}
		scope:actor = {
			save_scope_as = el_employer
			add_character_flag = { 
				flag = el_is_employing_adventurer
				days = 365
			}
			add_character_flag = { 
				flag = el_is_employing_adventurer_interac
				days = 365
			}
		}
		scope:el_adventurer_fin = {
			location = {
				random_neighboring_province ={
					limit = { county.holder ?= { this = scope:el_employer } }
					save_scope_as = el_location_event
				}
			}
			if = {
				limit = { location = { this = scope:el_employer.capital_province } }
				start_travel_plan = {
					destination = scope:el_location_event
					on_arrival_event =  el_landed_trigger.0004
				}
			}
			else = {
				start_travel_plan = {
					destination = scope:el_employer.capital_province
					on_arrival_event =  el_landed_trigger.0004
				}
			}
		}
		scope:el_employer = {
			send_interface_toast = {
				type = event_toast_text_and_effect_good
				title = el_landed_trigger.0004.toast.b
				left_icon = scope:el_adventurer_fin
				desc = el_landed_trigger.0004.toast.b.desc
			}
		}
	}
	ai_frequency = 0	
}			


el_landed_refute_adventurer_interaction = {
	common_interaction = yes
	category = interaction_category_diplomacy
	greeting = positive
	icon = contract_refute
	desc = el_landed_refute_adventurer_interaction_desc

	popup_on_receive = yes
	pause_on_receive = yes

	interface_priority = 60
	send_options_exclusive = no
	is_shown = {
		has_ep3_dlc_trigger = yes
		scope:actor = { 
			is_landed = yes 
			is_ai = no
			NOT = {
				is_target_in_variable_list = {
					name = el_landed_refuted_list
					target = scope:recipient
				}
			}
		}
		NOT = { scope:recipient = scope:actor }
		scope:recipient = {
			is_landless_adventurer = yes
			is_ai = yes
			is_adult = yes
		}
	}
	is_valid_showing_failures_only  = {
		scope:actor = {
			is_ai = no
			NOT = {
				is_target_in_variable_list = {
					name = el_landed_refuted_list
					target = scope:recipient
				}
			}
		}
		scope:recipient = {
			in_diplomatic_range = scope:actor
			has_government = landless_adventurer_government
			is_ai = yes
			is_adult = yes			
		}
	}
	auto_accept = yes
	on_accept = {
		scope:actor = {
			add_to_variable_list = {
				name = el_landed_refuted_list
				target = scope:recipient
			}
		}
		scope:recipient = {
			custom_tooltip =  el_landed_refute_adventurer_interaction.t
		}
	}
	ai_frequency = 0	
}			


el_landed_restore_adventurer_interaction = {
	common_interaction = yes
	category = interaction_category_diplomacy
	greeting = positive
	icon = contract
	desc = el_landed_restore_adventurer_interaction_desc

	popup_on_receive = yes
	pause_on_receive = yes

	interface_priority = 60
	send_options_exclusive = no
	is_shown = {
		has_ep3_dlc_trigger = yes
		scope:actor = { 
			is_landed = yes 
			is_ai = no
			is_target_in_variable_list = {
				name = el_landed_refuted_list
				target = scope:recipient
			}
		}
		NOT = { scope:recipient = scope:actor }
		scope:recipient = {
			is_landless_adventurer = yes
			is_ai = yes
			is_adult = yes
		}
	}
	is_valid_showing_failures_only  = {
		scope:actor = {
			is_ai = no
			is_target_in_variable_list = {
				name = el_landed_refuted_list
				target = scope:recipient
			}
		}
		scope:recipient = {
			in_diplomatic_range = scope:actor
			has_government = landless_adventurer_government
			is_ai = yes
			is_adult = yes
		}
	}
	auto_accept = yes
	on_accept = {
		scope:recipient = {
			custom_tooltip =  el_landed_restore_adventurer_interaction.t
		}
		scope:actor = {
			remove_list_variable = {
				name = el_landed_refuted_list
				target = scope:recipient
			}
			if = {
				limit = {
					has_variable_list = el_landed_refuted_list
					variable_list_size = {
						name = el_landed_refuted_list
						value = 0
					}
				}
				clear_variable_list = el_landed_refuted_list
			}
		}
	}
	ai_frequency = 0	
}