﻿namespace = oathbound_heir_events

oathbound_heir_events.0001 = { # Random Chance Trigger
	hidden = yes
	is_triggered_only = yes

	immediate = {
		random_list = {
			20 = { 
				trigger_event = 0 # Nothing happens
			}
			80 = { 
				trigger_event = oathbound_heir_events.0002
			}
		}
	}
}

oathbound_heir_events.0002 = { # The Forced Oath - Adventurer Perspective
	type = character_event
	title = oathbound_heir_events.0002.t
	desc = oathbound_heir_events.0002.desc
	theme = crown

	override_background = {
		reference = throne_room
	}

	left_portrait = {
		character = root
		animation = personality_honorable
	}

	right_portrait = {
		character = var:val_oathholder_heir
		animation = personality_content
	}

	is_triggered_only = yes

	immediate = {
		var:val_oathholder_heir = {
			save_scope_as = scope_oathholder_primary_heir
		}
		var:val_oathholder = {
			save_scope_as = scope_oathholder
		}
	}

	option = {
		name = oathbound_heir_events.0002.a
        custom_tooltip = {
			text = oathbound_heir_events.0002.a.desc
		}

		# ---------- Set up root's relationship ---------- 

		set_relation_oathholder = {
			target = var:val_oathholder_heir
		}

		oathholder_assigned = { CHARACTER = var:val_oathholder_heir }

		var:val_oathholder_heir = {
			add_hook = {
				target = root
				type = obligation_hook
			}
			oathkeeper_assigned = { CHARACTER = root }
			add_character_modifier = { modifier = oathholder_life }
		}
	}
}

oathbound_heir_events.1002 = { # The Forced Oath - Ruler Perspective
	type = character_event
	title = oathbound_heir_events.1002.t
	desc = oathbound_heir_events.1002.desc
	theme = crown

	override_background = {
		reference = throne_room
	}

	left_portrait = {
		character = var:val_oathkeeper
		animation = personality_honorable
	}

	lower_center_portrait = {
		character = primary_heir
		animation = personality_honorable
	}

	is_triggered_only = yes

	immediate = {
		primary_heir = {
			save_scope_as = scope_primary_heir
		}
		var:val_oathkeeper = {
			save_scope_as = scope_oathkeeper
		}
	}

	option = {
		name = oathbound_heir_events.1002.a
        custom_tooltip = {
			text = oathbound_heir_events.1002.a.desc
		}
		# ---------- Set up Oathbound's relationship ---------- 
		var:val_oathkeeper = {
			set_relation_oathholder = {
				target = root.primary_heir
			}
			oathholder_assigned = { CHARACTER = root.primary_heir }
		}

		primary_heir = {
			add_hook = {
				target = root.var:val_oathkeeper
				type = obligation_hook
			}
			oathkeeper_assigned = { CHARACTER = root.var:val_oathkeeper }

			add_character_modifier = { modifier = oathholder_life }
		}
	}
	option = { # "I do not accept."
		name = oathbound_heir_events.1002.b
		custom_tooltip = {
			text = oathbound_heir_events.1002.b.desc
		}
	}

}