﻿
namespace = historical_char_creation_events

historical_char_creation_events.1 = {
	type = character_event
	title = historical_char_creation_events.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:historical_character = {
						has_variable = alternative_origin_courtier
					}
				}
				desc = historical_char_creation_events_alternative.desc
			}
			desc = historical_char_creation_events.desc
		}
	}
	theme = friendly
	override_effect_2d = legend_glow
	
	override_background = {
		trigger = {
			scope:historical_character.faith = faith:norse_pagan
		}
		reference = fp1_runestone_circle
	}
	
	override_background = {
		trigger = {
			scope:historical_character = { has_variable = alternative_origin_courtier }
		}
		reference = throne_room
	}
	
	override_background = {
		trigger = {
			scope:historical_character = {
				has_trait = lifestyle_poet
			}
		}
		reference = relaxing_room
	}
	
	override_background = {
		trigger = {
			scope:historical_character = {
				OR = {
					has_trait = eunuch_1
					has_trait = beardless_eunuch
				}
			}
		}
		reference = relaxing_room
	}
	
	override_background = {
		trigger = {
			scope:birth_location.title_province = {
				is_coastal = yes
			}
			scope:historical_character = {
				has_trait = adventurer
			}
		}
		reference = docks
	}
	
	override_background = {
		trigger = {
			scope:historical_character = {
				has_trait = adventurer
			}
		}
		reference = terrain_scope
	}
	
	override_background = {
		trigger = {
			scope:historical_character = {
				religion = scope:birth_location.religion
				OR = {
					has_trait = devoted
					has_trait = theologian
				}
			}
		}
		reference = holy_site_generic_scope
	}
	
	override_background = {
		trigger = {
			scope:historical_character = {
				OR = {
					has_trait = scholar
					has_trait = administrator
				}
			}
		}
		reference = bp2_university_scope
	}
	
	override_background = {
		trigger = {
			scope:historical_character = {
				OR = {
					has_education_martial_trigger = yes
					has_trait = gallant
					has_trait = strategist
				}
			}
		}
		reference = courtyard
	}
	
	override_background = {
		trigger = {
			scope:birth_location.title_province = { has_holding = yes }
		}
		reference = market_scope
	}
	
	override_background = {
		reference = terrain_scope
	}
	
	right_portrait = {
		character = scope:historical_character_2
		animation = flirtation_left
	}
	
	left_portrait = {
		character = scope:historical_character
		triggered_animation = {
			trigger = {
				exists = scope:historical_character_2
			}
			animation = admiration
		}
		triggered_animation = {
			trigger = {
				has_variable = hodja
			}
			animation = laugh
		}
		triggered_animation = {
			trigger = {
				OR = {
					has_variable = takezaki_suenaga
					has_variable = sakata_kintoki
				}
			}
			animation = hasso_no_kamae
		}
		triggered_animation = {
			trigger = {
				OR = {
					has_variable = yue_fei
					has_variable = wen_tianxiang
					has_variable = pham_ngu_lao
				}
			}
			animation = relaxed_spear
		}
		triggered_animation = {
			trigger = {
				has_trait = diplomat
			}
			animation = chancellor
		}
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = eunuch_1
					has_trait = beardless_eunuch
				}
				has_education_intrigue_trigger = yes
			}
			animation = scheme
		}
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = eunuch_1
					has_trait = beardless_eunuch
				}
			}
			animation = obsequious_bow
		}
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = berserker
					has_trait = gallant
					has_trait = strategist
				}
			}
			animation = inspect_weapon
		}
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = organizer
					has_trait = lifestyle_traveler
					has_trait = architect
					has_trait = adventurer
				}
			}
			animation = survey
		}
		triggered_animation = {
			trigger = {
				has_trait = possessed_1
			}
			animation = eccentric
		}
		triggered_animation = {
			trigger = {
				has_trait = lifestyle_poet
				OR = {
					has_trait = theologian
					has_trait = scholar
				}
			}
			animation = happy_teacher
		}
		triggered_animation = {
			trigger = {
				has_character_flag = murasaki
			}
			animation = fanning_coyly
		}
		triggered_animation = {
			trigger = {
				has_trait = lifestyle_poet
			}
			animation = storyteller
		}
		triggered_animation = {
			trigger = {
				has_trait = lifestyle_mystic
			}
			animation = personality_zealous
		}
		triggered_animation = {
			trigger = {
				has_trait = lifestyle_physician
			}
			animation = physician
		}
		triggered_animation = {
			trigger = {
				has_education_martial_trigger = yes
			}
			animation = sword_coup_degrace
		}
		triggered_animation = {
			trigger = {
				has_education_stewardship_trigger = yes
			}
			animation = steward
		}
		triggered_animation = {
			trigger = {
				has_variable = legendary_author
			}
			animation = writing
		}
		triggered_animation = {
			trigger = {
				has_trait = devoted
			}
			animation = prayer
		}
		animation = writing
	}
	
	immediate = {
		scope:birth_location = {
			save_scope_as = background_terrain_scope
			title_province = { save_scope_as = background_market_scope }
			title_province = { save_scope_as = background_university_scope }
		}
		scope:historical_character.location = { save_scope_as = holy_site_scope }
	}
	
	option = {
		name = historical_char_creation_events.1.a
		add_internal_flag = dangerous
		
		trigger = {
			has_ep3_dlc_trigger = yes
		}
		flavor = danger_dynasty_abandon_tt
		if = {
			limit = {
				is_ai = no
			}
			add_achievement_global_variable_effect = {
				VARIABLE = finished_historically_inaccurate_achievement
				VALUE = yes
			}
		}
		scope:historical_character = {
			create_landless_adventurer_title_effect = {
				REASON = flag:voluntary
				FLAVOR_CHAR = root
			}
		}
		set_player_character = scope:historical_character
		
		hidden_effect = {
			scope:historical_character = {
				populate_location_with_contracts_effect = {
					AREA_CHAR = scope:historical_character
					AMOUNT = 3
				}
				if = {
					limit = {
						exists = scope:historical_character_2
					}
					add_courtier = scope:historical_character_2
				}
			}
		}

		ai_chance = {
			base = 0
		}
	}
	
	option = {
		name = historical_char_creation_events.1.b
		
		custom_tooltip = obligation_hook_tt
		add_courtier = scope:historical_character
		add_hook = {
			type = obligation_hook
			target = scope:historical_character
		}
		
		if = {
			limit = {
				exists = scope:historical_character_2
			}
			add_courtier = scope:historical_character_2
			add_hook = {
				type = obligation_hook
				target = scope:historical_character_2
			}
		}

		ai_chance = {
			base = 100
		}
	}
	
	option = {
		name = historical_char_creation_events.1.c
		flavor = will_wander_tt
		
		add_prestige = minor_prestige_gain
		
		if = {
			limit = {
				has_ep3_dlc_trigger = yes
				exists = scope:explorer
			}
			scope:historical_character = {
				create_landless_adventurer_title_effect = {
					REASON = flag:voluntary
					FLAVOR_CHAR = root
				}
			}
		}
		else_if = {
			limit = {
				has_ep3_dlc_trigger = yes
				is_ai = yes
			}
			random = {
				chance = 15
				scope:historical_character = {
					create_landless_adventurer_title_effect = {
						REASON = flag:voluntary
						FLAVOR_CHAR = root
					}
				}
			}
		}

		ai_chance = {
			base = 100
			modifier = {
				add = 150
				scope:historical_character.culture = {
					has_cultural_parameter = much_more_likely_to_be_laamps
				}
			}
			modifier = {
				add = 50
				scope:historical_character.culture = {
					has_cultural_parameter = more_likely_to_be_laamps
				}
			}
		}
	}
	
	after = {
		remove_character_flag = need_military_outfit
	}
}

# Major religious inspiration outcome
historical_char_creation_events.2 = {
	type = character_event
	title = historical_char_creation_events.2.t
	desc = historical_char_creation_events.2.desc
	theme = faith
	override_effect_2d = legend_glow
	left_portrait = {
		character = scope:inspiration_owner
		animation = personality_zealous
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
	}

	option = {
		name = historical_char_creation_events.2.a
		add_character_flag = major_religious_inspiration
		add_character_modifier = {
			modifier = religious_reformer_modifier
		}
		custom_tooltip = mass_conversion_tt
	}
}

