###########################################
#                                         #
# Horse Lords nomad horse events          #
# ID HL.6000-6499                         #
#                                         #
###########################################

# Written by Tobias Bodlund

namespace = HL

# Select and name horse
long_character_event = {
	id = HL.6000
	desc = EVTDESC_HL_6000
	picture = GFX_evt_horse_friend
	border = GFX_event_long_frame_war

	is_triggered_only = yes # choose_warhorse_nomad, minor_decisions.txt

	option = {
		name = EVTOPTA_HL_6000 # Dragon

		set_character_flag = nomad_warhorse_name_dragon
	}

	option = {
		name = EVTOPTB_HL_6000 # Sky

		set_character_flag = nomad_warhorse_name_sky
	}

	option = {
		name = EVTOPTC_HL_6000 # Arrow

		set_character_flag = nomad_warhorse_name_arrow
	}

	option = {
		name = EVTOPTD_HL_6000 # Lightning

		set_character_flag = nomad_warhorse_name_lightning
	}

	after = {
		add_character_modifier = {
			name = nomad_warhorse
			duration = -1
		}
	}
}

# Your ward is four years old and still cant ride a horse. Shocking.
character_event = {
	id = HL.6010
	desc = EVTDESC_HL_6010
	picture = GFX_evt_child_sword_altaic
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes # on_yearly_pulse, random_events

	only_capable = yes
	prisoner = no

	trigger = {
		is_nomadic = yes

		any_ward = {
			age == 7
		}
	}

	immediate = {
		random_ward = {
			limit = { age == 7 }
			save_event_target_as = ward_cant_ride
		}
	}

	option = {
		name = EVTOPTA_HL_6010 # Teach them myself

		reverse_opinion = {
			name = opinion_happy_with_guardian
			who = event_target:ward_cant_ride
			years = 5
		}
	}

	option = {
		name = EVTOPTB_HL_6010 # Let the brat flounder, I don't have the time

		event_target:ward_cant_ride = {
			show_scope_change = no

			prestige = -30
		}
	}
}

# Dangerous river crossing - save spouse or horse?
narrative_event = {
	id = HL.6020
	title = EVTTITLE_HL_6020
	desc = EVTDESC_HL_6020
	picture = GFX_evt_horse_friend
	border = GFX_event_narrative_frame_diplomacy

	is_triggered_only = yes # on_yearly_pulse, random_events

	is_married = yes
	only_capable = yes
	prisoner = no

	trigger = {
		is_nomadic = yes
		has_character_modifier = nomad_warhorse
		is_inaccessible_trigger = no

		any_spouse = {
			at_location = ROOT
			is_inaccessible_or_incapable_trigger = no
			ai = yes
		}
	}

	immediate = {
		random_spouse = {
			limit = {
				at_location = ROOT
				is_inaccessible_or_incapable_trigger = no
				ai = yes
			}

			save_event_target_as = spouse_danger_nomad_river_crossing
		}
	}

	option = {
		name = EVTOPTA_HL_6020 # Save spouse

		remove_character_modifier = nomad_warhorse

		hidden_effect = {
			random_list = {
				50 = { character_event = { id = HL.6021 } } # Grateful
				50 = { character_event = { id = HL.6022 } } # Angry
			}
		}
	}

	option = { # Save horse
		name = {
			text = EVTOPTB_HL_6020
			trigger = { has_character_flag = nomad_warhorse_name_dragon }
		}
		name = {
			text = EVTOPTC_HL_6020
			trigger = { has_character_flag = nomad_warhorse_name_sky }
		}
		name = {
			text = EVTOPTD_HL_6020
			trigger = { has_character_flag = nomad_warhorse_name_arrow }
		}
		name = {
			text = EVTOPTE_HL_6020
			trigger = { has_character_flag = nomad_warhorse_name_lightning }
		}

		event_target:spouse_danger_nomad_river_crossing = {
			show_scope_change = no

			death = { death_reason = death_accident_drowning }
		}
	}
}

# River crossing - saved spouse and spouse is grateful
character_event = {
	id = HL.6021
	desc = EVTDESC_HL_6021
	picture = GFX_evt_nomad_camp
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	option = {
		name = EVTOPTA_HL_6021  # Great

		if = {
			limit = { is_lover = event_target:spouse_danger_nomad_river_crossing }

			reverse_opinion = {
				name = opinion_grateful
				who = event_target:spouse_danger_nomad_river_crossing
				years = 5
			}
		}
		else = {
			event_target:spouse_danger_nomad_river_crossing = { # Scoped this way for tooltip
				show_scope_change = no

				add_lover = ROOT
			}
		}
	}

	option = { # But did I do the right thing...?
		name = {
			text = EVTOPTB_HL_6021
			trigger = { has_character_flag = nomad_warhorse_name_dragon }
		}
		name = {
			text = EVTOPTC_HL_6021
			trigger = { has_character_flag = nomad_warhorse_name_sky }
		}
		name = {
			text = EVTOPTD_HL_6021
			trigger = { has_character_flag = nomad_warhorse_name_arrow }
		}
		name = {
			text = EVTOPTE_HL_6021
			trigger = { has_character_flag = nomad_warhorse_name_lightning }
		}

		reverse_opinion = {
			name = opinion_grateful
			who = event_target:spouse_danger_nomad_river_crossing
			years = 5
		}

		opinion = {
			name = horse_regret
			who = event_target:spouse_danger_nomad_river_crossing
			years = 5
		}
	}

	after = {
		set_character_flag = nomad_warhorse_ignore_grief
		character_event = { id = HL.6999 } # Horse clean-up
	}
}

# River crossing - saved spouse but spouse is angry - why didn't you save the horse?
character_event = {
	id = HL.6022
	desc = EVTDESC_HL_6022
	picture = GFX_evt_horse_friend
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	option = {
		name = EVTOPTA_HL_6022 # I, too, now question my decision

		reverse_opinion = {
			name = opinion_angry
			who = event_target:spouse_danger_nomad_river_crossing
			years = 5
		}
	}
}

# A loyal retinue warrior's family have lost their horses to sickness, will you help them?
character_event = {
	id = HL.6030
	desc = EVTDESC_HL_6030
	picture = GFX_evt_nomad_camp
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes # on_yearly_pulse, random_events

	only_capable = yes
	prisoner = no

	trigger = {
		is_nomadic = yes
		is_inaccessible_trigger = no
	}

	option = {
		name = EVTOPTA_HL_6030 # Give them horses from my personal herd

		wealth = -12
		prestige = 30
	}

	option = {
		name = EVTOPTB_HL_6030 # Don't help

		prestige = -10
	}
}