namespace = bastard

################################################
# Legitamize hidden bastard from VIET
################################################
# Legitimize a hidden bastard if old and childless?
character_event = {
	id = bastard.1
	desc = EVTDESCbastard.1
	picture = GFX_evt_son_asking_father
	
	only_rulers = yes
	
	trigger = {
		has_character_modifier = old_age
		NOT = { has_law = succ_feudal_elective }
		is_feudal = yes
		current_heir = { NOT = { dynasty = ROOT } }
		NOT = {
			any_child = {
				dynasty = ROOT
				is_female = no
			}
		}
		any_child = {
			was_conceived_a_bastard = yes
			father = {
				NOT = { character = ROOT }
			}
			is_female = no
			NOT = { trait = bastard }
			NOT = { trait = legit_bastard }
		}
	}
	
	mean_time_to_happen = { 
		years = 1 
	}
	
	option = {
		name = EVTOPTA301 # Legitimize the child
		recalc_succession = yes
		ai_chance = { factor = 80 }
		random_child = {
			limit = {
				was_conceived_a_bastard = yes
				father = {
					NOT = { character = ROOT }
				}
				is_female = no
				NOT = { trait = bastard }
				NOT = { trait = legit_bastard }
			}
			character_event = { id = 302 tooltip = EVTTOOLTIP302 } # The child gets the father's dynasty
			mother = {
				character_event = { id = bastard.2 tooltip = EVTTOOLTIP303 } # The child's mother is very pleased
				spouse = {
					character_event = { id = 304 tooltip = EVTTOOLTIP304 } # The child's mother's husband is pissed off
				}
				consort = {
					character_event = { id = 304 tooltip = EVTTOOLTIP304 } # The child's mother's lord is pissed off
				}
			}
		}
		any_child = {
			limit = {
				dynasty = ROOT
				was_conceived_a_bastard = no
			}
			opinion = {
				who = ROOT
				modifier = legitimized_bastard
				months = 12
			}
		}
	}
	option = {
		name = EVTOPTBbastard.1
		ai_chance = { factor = 20 }
	}
}
# The child's mother is very pleased
character_event = {
	id = bastard.2
	desc = EVTDESCbastard.2
	picture = GFX_evt_courtiers_talking
	
	is_triggered_only = yes 
	
	option = {
		name = EVTOPTAbastard.2
		opinion = {
			who = FROM
			modifier = legitimized_child
			years = 10
		}
	}
}
