﻿namespace = oathbound_heir_events

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

	immediate = {
		random_list = {
			20 = { 
				
			}
			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
	}


	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 }
		create_character_memory = {
			type = swore_oathbound_contract_memory
			participants = {
				new_boss = var:val_oathholder_heir
			}
		}

		var:val_oathholder_heir = {
			add_hook = {
				target = root
				type = obligation_hook
			}
			oathkeeper_assigned = { CHARACTER = root }
			create_character_memory = {
                type = gained_oathbound_contract_memory
                participants = {
                    new_servant = root
                }
            }
			add_character_modifier = { modifier = oathholder_life }
			if = {
				limit = { is_female = yes }
				add_trait = oathholder_female
			}
			else = {
				add_trait = oathholder_male
			}
		}
	}
}

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
	}

	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 }
			create_character_memory = {
                type = swore_oathbound_contract_memory
                participants = {
                    new_boss = root.primary_heir
                }
            }
		}

		primary_heir = {
			add_hook = {
				target = root.var:val_oathkeeper
				type = obligation_hook
			}
			oathkeeper_assigned = { CHARACTER = root.var:val_oathkeeper }
			create_character_memory = {
                type = gained_oathbound_contract_memory
                participants = {
                    new_servant = root.var:val_oathkeeper
                }
            }

			add_character_modifier = { modifier = oathholder_life }
			if = {
				limit = { is_female = yes }
				add_trait = oathholder_female
			}
			else = {
				add_trait = oathholder_male
			}
		}
	}
	option = { # "I do not accept."
		name = oathbound_heir_events.1002.b
		custom_tooltip = {
			text = oathbound_heir_events.1002.b.desc
		}
	}

}