﻿## old stuff
#on_travel_plan_movement = { 
#	on_actions = {
#		el_landed_on_action
#		}
#}
#
#on_travel_plan_complete = {
#	on_actions = {
#		el_landed_on_action_clear
#		}
#}
#
#el_landed_on_action = {
#	trigger = {
#		is_playable_character = yes
#		is_adult = yes
#		is_alive = yes
#		is_landless_adventurer = yes
#		has_character_flag = el_check_provision
#		domicile = { provisions <= provisions_threshold_low_value }		
#	}		
#	effect = {
#		domicile = { change_provisions = medium_provisions_gain }
#	}
#}
#
#el_landed_on_action_clear = {
#	trigger = {
#		is_playable_character = yes
#		is_adult = yes
#		is_alive = yes
#		is_landless_adventurer = yes
#		has_character_flag = el_check_provision
#	}
#	effect = {
#		remove_character_flag = el_check_provision 
#	}
#}

random_yearly_playable_pulse ={
	on_actions = {
		el_landed_rival_adv_on_action
	}
}

el_landed_rival_adv_on_action = {
	trigger = {
		is_ruler = yes
		is_landed = yes
		is_alive = yes
		any_sub_realm_county = {
			holder = root
			any_county_province = {
				NOT = { has_variable = el_landed_des_nei_cournty_already }
				any_character_in_location = {
					NOT = { has_character_flag = el_landed_cant_raid }
					has_government = landless_adventurer_government
					is_incapable = no
					NOT = { has_trait = infirm }
					is_adult = yes
					is_ai = yes
					is_imprisoned = no
					NOT = {
						OR = {
							has_relation_friend = root
							has_relation_best_friend = root
							has_relation_lover = root
							has_relation_soulmate = root
							has_relation_blood_brother = root
						}
					}
					OR = {
						has_relation_rival = root
						has_relation_nemesis = root
						has_realm_law = camp_purpose_brigands
					}
					domicile.domicile_location = prev
				}
			}
		}	
	}
	effect = {
		save_scope_as = el_employer
		every_sub_realm_county = {
			limit = { holder = scope:el_employer }
			every_county_province = {
				limit = { NOT = { has_variable = el_landed_des_nei_cournty_already } }
				random_character_in_location = {
					limit = {
						NOT = { has_character_flag = el_landed_cant_raid }
						has_government = landless_adventurer_government
						is_incapable = no
						NOT = { has_trait = infirm }
						is_adult = yes
						is_ai = yes
						is_imprisoned = no
						NOT = {
							OR = {
								has_relation_friend = scope:el_employer
								has_relation_best_friend = scope:el_employer
								has_relation_lover = scope:el_employer
								has_relation_soulmate = scope:el_employer
								has_relation_blood_brother = scope:el_employer
							}
						}
						OR = {
							has_relation_rival = scope:el_employer
							has_relation_nemesis = scope:el_employer
							has_realm_law = camp_purpose_brigands
						}
						domicile.domicile_location = prev
					}
					domicile.domicile_location.county = { save_scope_as = location_county }
					save_scope_as = el_adventurer_fin
				}
			}
		}
		if = {
			limit = {
				scope:el_adventurer_fin = { 
					has_realm_law = camp_purpose_brigands 
					el_landed_rival_wont_raid_trigger = yes
				}
			}
			random = {
				chance = 2
				trigger_event = el_landed_rival_landless_events.0001
			}
		}
		else_if = {
			limit = {
				scope:el_adventurer_fin = {
					OR = {
						has_relation_rival = scope:el_employer
						has_relation_nemesis = scope:el_employer
					}
					el_landed_rival_wont_raid_trigger = yes
				}
			}
			random = {
				chance = 10
				trigger_event = el_landed_rival_landless_events.0001
			}
		}
	}
}

on_death = {
	on_actions = {
		el_landed_refuted_clear
	}
}

el_landed_refuted_clear = {
	trigger = {
		has_variable_list = el_landed_refuted_list
	}
	effect = {
		every_in_list = {
			variable = el_landed_refuted_list
			limit = { 
				is_alive = yes 
			}
			root = {
				remove_list_variable = {
					name = el_landed_refuted_list
					target = prev
				}
			}
		}
		clear_variable_list = el_landed_refuted_list
	}
}