#############################################
#
# EVENTS FOR LOVE, PREGNANCY AND BIRTH
#
#############################################
# by Henrik Fhraeus
#############################################

#############################################
# EVENTS LEADING UP TO BASTARD PREGNANCY
# (Attraction grows between the male ruler and a female courtier)
#############################################

# A female courtier initiates romance with her liege
character_event = {
	id = 450
	desc = EVTDESC450
	picture = GFX_evt_lovers
	

	capable_only = yes
	prisoner = no
	
	trigger = {
		OR = {
			is_ruler = no
			liege = {
				at_location = ROOT
			}
		}
		is_marriage_adult = yes
		OR = {
			is_female = no
			NOT = { age = 40 }
		}
		independent = no
		has_lover = no
		is_pregnant = no
		is_consort = no
		NOT = { trait = homosexual }
		NOT = { trait = infirm }
		NOT = { trait = incapable }
		NOT = { trait = celibate }
		liege = {
			NOT = { character = ROOT }
			demesne_size = 1
			NOT = { is_close_relative = ROOT }
			OR = {
				AND = {
					NOT = { trait = homosexual }
					ROOT = { NOT = { trait = homosexual } }
					is_female = no
					ROOT = { is_female = yes }
				}
				AND = {
					NOT = { trait = homosexual }
					ROOT = { NOT = { trait = homosexual } }
					is_female = yes
					ROOT = { is_female = no }
				}
				AND = {
					trait = homosexual
					is_female = yes
					ROOT = { is_female = yes }
				}
				AND = {
					trait = homosexual
					is_female = no
					ROOT = { is_female = no }
				}
			}
			NOT = { num_of_lovers = 5 }
			is_pregnant = no
			prisoner = no
			is_marriage_adult = yes
			OR = {
				is_female = no
				NOT = { age = 40 }
			}
			NOT = {
				has_character_modifier = lustful_affair_timer
			}
			NOT = {
				is_former_lover = ROOT
			}
			NOT = { trait = infirm }
			NOT = { trait = incapable }
			NOT = { trait = celibate }
			NOT = { trait = eunuch }
			NOT = { any_spouse = { character = ROOT } }
			NOT = { any_consort = { character = ROOT } }
			opinion = { who = ROOT value = 0 }
			reverse_opinion = { who = ROOT value = 0 }
			OR = {
				is_married = no
				NOT = { trait = chaste }
			}
			NOT = { trait = in_hiding }
		}
#		has_lover = no		#redundant (previous instance of has_lover = no at ROOT scope)
#		is_pregnant = no	#redundant (previous instance of is_pregnant = no at ROOT scope)
		prisoner = no
		NOT = { trait = infirm }
		NOT = { trait = incapable }
		NOT = { trait = celibate }
		NOT = { trait = eunuch }
		NOT = { trait = in_hiding }
	}


	mean_time_to_happen = {
		months = 600

		modifier = {
			factor = 10.0 #make it possible (but unlikely) for a courtier to 'come out of the closet' to make a pass at the liege
			OR = {
				AND = {
					NOT = { trait = homosexual }
					liege = { trait = homosexual }
					is_female = yes
					ROOT = { is_female = yes }
				}
				AND = {
					NOT = { trait = homosexual }
					liege = { trait = homosexual }
					is_female = no
					ROOT = { is_female = no }
				}
			}
		}
		modifier = {
			factor = 2.0
			liege = { num_of_lovers = 1 }
		}		
		modifier = {
			factor = 3.0
			liege = { num_of_lovers = 2 }
		}
		modifier = {
			factor = 4.0
			liege = { num_of_lovers = 3 }
		}
		modifier = {
			factor = 5.0
			liege = { num_of_lovers = 4 }
		}
		modifier = {
			factor = 0.5
			is_married = no
		}
		modifier = {
			factor = 2.0
			is_ruler = yes
		}
		modifier = {
			factor = 2.0
			religion_group = muslim
		}
		modifier = {
			factor = 2.0
			liege = { religion_group = muslim }
		}
		modifier = {
			factor = 0.33
			trait = homosexual #to balance for fewer potential lovers
		}
		modifier = {
			factor = 0.2
			has_character_flag = debutante
			NOT = {
				had_character_flag = {
					flag = debutante
					days = 1095
				}
			}
		}
		modifier = {
			factor = 0.75
			NOT = { age = 20 }
		}
		modifier = {
			factor = 2.0
			liege = {
				spouse = {
					NOT = { age = 30 }
				}
			}
		}
		modifier = {
			factor = 0.5
			liege = {
				spouse = {
					age = 40
				}
			}
		}
		modifier = {
			factor = 2.0
			age = 30
		}
		modifier = {
			factor = 0.5
			trait = hedonist
		}
		modifier = {
			factor = 0.5
			liege = { trait = hedonist }
		}
		modifier = {
			factor = 0.5
			trait = lustful
		}
		modifier = {
			factor = 0.5
			liege = { trait = lustful }
		}
		modifier = {
			factor = 0.5
			trait = fair
		}
		modifier = {
			factor = 0.5
			liege = { trait = fair }
		}
		modifier = {
			factor = 2.0
			trait = ugly
		}
		modifier = {
			factor = 2.0
			liege = { trait = ugly }
		}
		modifier = {
			factor = 2.0
			NOT = { opinion = { who = liege value = 0 } }
		}
		modifier = {
			factor = 1.5
			NOT = { reverse_opinion = { who = liege value = 0 } }
		}
		modifier = {
			factor = 2.0
			NOT = { opinion = { who = liege value = 25 } }
		}
		modifier = {
			factor = 1.5
			NOT = { reverse_opinion = { who = liege value = 25 } }
		}
		modifier = {
			factor = 0.25
			opinion = { who = liege value = 50 }
		}
		modifier = {
			factor = 0.5
			reverse_opinion = { who = liege value = 50 }
		}
		modifier = {
			factor = 0.25
			opinion = { who = liege value = 75 }
		}
		modifier = {
			factor = 0.5
			reverse_opinion = { who = liege value = 75 }
		}
		modifier = {
			factor = 10.0
			trait = chaste
		}
		modifier = {
			factor = 10.0
			liege = { trait = chaste }
		}
		modifier = {
			factor = 2.0
			liege = { any_child = { trait = bastard } }
		}
	}

	option = {
		name = EVTOPTA450
		if = {
			limit = {
				OR = {
					AND = {
						NOT = { trait = homosexual }
						liege = { trait = homosexual }
						is_female = yes
						ROOT = { is_female = yes }
					}
					AND = {
						NOT = { trait = homosexual }
						liege = { trait = homosexual }
						is_female = no
						ROOT = { is_female = no }
					}
				}
			}
			add_trait = homosexual
		}
		liege = {
			add_character_modifier = {
				name = lustful_affair_timer
				duration = 365
				hidden = yes
			}
			character_event = { id = 451 days = 7 tooltip = EVTTOOLTIP451 }
		}
	}
	option = {
		name = EVTOPTB450
		trigger = {
			ai = no
		}
		piety = 5
	}
}

# The liege responds to his/her advances
character_event = {
	id = 451
	desc = EVTDESC451
	picture = GFX_evt_lovers

	is_triggered_only = yes
	option = {
		name = EVTOPTA451
		ai_chance = { factor = 90 }
		FROM = { character_event = { id = 452 days = 7 tooltip = EVTTOOLTIP452 } }
	}

	option = {
		name = EVTOPTB451
		trigger = {
			NOT = { trait = lustful }
			NOT = { trait = hedonist }
		}
		ai_chance = {
			factor = 10
			modifier = {
				factor = 10
				trait = chaste
			}
			modifier = {
				factor = 2
				trait = temperate
			}
			modifier = {
				factor = 0.5
				trait = greedy
			}
		}
		if = {
			limit = {
				NOT = { religion_group = zoroastrian_group }
			}
			piety = 5
		}
		if = {
			limit = {
				religion_group = zoroastrian_group
			}
			piety = -5
		}
	}
	option = {
		name = EVTOPTC451
		trigger = {
			ai = no
			OR = {
				trait = lustful
				trait = hedonist
			}
		}
		prestige = -5
	}
}

# The courtier accepts or spurns the liege lord
character_event = {
	id = 452

	is_triggered_only = yes

	desc = EVTDESC452
	picture = GFX_evt_lovers

	option = {
		name = EVTOPTA452
		ai_chance = { factor = 90 }
		trigger = {
			fertility = 0.33
			FROM = { fertility = 0.33 }
		}
		if = {
			limit = {
				is_female = yes
				NOT = { age = 45 }
				FROM = { is_female = no }
			}
			if = {
				limit = { is_married = no }
				random_list = {
					50 = { impregnate = FROM }
					50 = { }
				}
			}
			if = {
				limit = { is_married = yes }
				random_list = {
					50 = { impregnate_cuckoo = FROM }
					50 = { }
				}
			}
		}
		if = {
			limit = {
				is_female = no
				FROM = {
					NOT = { age = 45 }
					is_female = yes
				}
			}
			if = {
				limit = { is_married = no }
				random_list = {
					50 = { impregnate = FROM }
					50 = { }
				}
			}
			if = {
				limit = { is_married = yes }
				random_list = {
					50 = { impregnate_cuckoo = FROM }
					50 = { }
				}
			}
		}
		add_lover = FROM
		FROM = { character_event = { id = 453 tooltip = EVTTOOLTIP453 } }
	}
	option = {
		name = EVTOPTA452
		ai_chance = { factor = 90 }
		trigger = {
			OR = {
				NOT = { fertility = 0.33 }
				NOT = { FROM = { fertility = 0.33 } }
			}
		}
		add_lover = FROM
		FROM = { character_event = { id = 453 tooltip = EVTTOOLTIP453 } }
	}

	option = {
		name = EVTOPTB452
		ai_chance = {
			factor = 5
			modifier = {
				factor = 10
				trait = chaste
			}
			modifier = {
				factor = 2
				FROM = { is_female = no }
				is_female = yes
			}
			modifier = {
				factor = 2
				trait = temperate
			}
			modifier = {
				factor = 0.5
				trait = greedy
			}
		}
		trigger = {
			NOT = { trait = lustful }
			NOT = { trait = hedonist }
		}
		FROM = { character_event = { id = 454 tooltip = EVTTOOLTIP454 } }
	}

	option = {
		name = EVTOPTC452
		trigger = {
			FROM = { is_female = no }
			is_female = yes
			NOT = { trait = lustful }
			NOT = { trait = hedonist }
		}
		ai_chance = {
			factor = 5
			modifier = {
				factor = 10
				trait = chaste
			}
			modifier = {
				factor = 2
				trait = temperate
			}
			modifier = {
				factor = 0.5
				trait = greedy
			}
		}
		FROM = { character_event = { id = 455 tooltip = EVTTOOLTIP455 } }
	}
}

# The ruler becomes his/her lover
character_event = {
	id = 453

	is_triggered_only = yes

	desc = EVTDESC453
	picture = GFX_evt_lovers

	option = {
		name = EVTOPTA453
		add_lover = FROM
	}
}

# The ruler is spurned and disappointed
character_event = {
	id = 454
	picture = GFX_evt_quarrel

	is_triggered_only = yes

	desc = EVTDESC454

	option = {
		name = EVTOPTA454
		opinion = {
			who = FROM
			modifier = opinion_spurned
			years = 5
		}
	}
}

# The ruler is spurned and embarrassed
character_event = {
	id = 455
	picture = GFX_evt_quarrel

	is_triggered_only = yes

	desc = EVTDESC455

	option = {
		name = EVTOPTA455
		opinion = {
			who = FROM
			modifier = opinion_embarrassed
			years = 5
		}
	}
}

# A courtier initiates romance with another courtier
character_event = {
	id = 456
	desc = EVTDESC450
	picture = GFX_evt_lovers

	capable_only = yes
	prisoner = no

	trigger = {
		is_ruler = no
		is_marriage_adult = yes
		OR = {
			is_female = no
			NOT = { age = 40 }
		}
		liege = {
			ai = no		# otherwise we get too many unnecessary children in the game
			demesne_size = 1
			any_courtier = {
				is_ruler = no	
				NOT = { is_close_relative = ROOT }
				OR = {
					AND = {
						NOT = { trait = homosexual }
						ROOT = { NOT = { trait = homosexual } }
						is_female = no
						ROOT = { is_female = yes }
					}
					AND = {
						NOT = { trait = homosexual }
						ROOT = { NOT = { trait = homosexual } }
						is_female = yes
						ROOT = { is_female = no }
					}
					AND = {
						trait = homosexual
						ROOT = { trait = homosexual }
						is_female = yes
						ROOT = { is_female = yes }
					}
					AND = {
						trait = homosexual
						ROOT = { trait = homosexual }
						is_female = no
						ROOT = { is_female = no }
					}
				}
				has_lover = no
				is_pregnant = no
				prisoner = no
				is_marriage_adult = yes
				OR = {
					is_female = no
					NOT = { age = 40 }
				}
				NOT = {
					has_character_modifier = lustful_affair_timer
				}
				NOT = { trait = infirm }
				NOT = { trait = incapable }
				NOT = { trait = celibate }
				NOT = { trait = eunuch }
				NOT = { trait = chaste }
				NOT = { spouse = { character = ROOT } }
				opinion = { who = ROOT value = 0 }
				reverse_opinion = { who = ROOT value = 0 }
				NOT = {
					is_former_lover = ROOT
				}
			}
		}
		has_lover = no
		is_pregnant = no
		prisoner = no
		NOT = { trait = chaste }
		NOT = { trait = infirm }
		NOT = { trait = incapable }
		NOT = { trait = celibate }
		NOT = { trait = eunuch }
		NOT = { trait = in_hiding }
	}


	mean_time_to_happen = {
		months = 2000

		modifier = {
			factor = 0.5
			spouse = { is_ruler = yes }
		}
		modifier = {
			factor = 0.5
			spouse = { has_lover = yes }
		}
		modifier = {
			factor = 0.5
			NOT = { age = 30 }
			spouse = { age = 40 }
		}
		modifier = {
			factor = 0.33
			trait = homosexual #to balance for fewer potential lovers
		}
		modifier = {
			factor = 0.75
			NOT = { age = 20 }
		}
		modifier = {
			factor = 2.0
			age = 30
		}
		modifier = {
			factor = 0.5
			trait = hedonist
		}
		modifier = {
			factor = 0.5
			trait = lustful
		}
	}

	option = {
		name = EVTOPTA450
		liege = {
			random_courtier = {
				limit = {
					is_ruler = no
					NOT = { is_close_relative = ROOT }
					OR = {
						AND = {
							NOT = { trait = homosexual }
							ROOT = { NOT = { trait = homosexual } }
							is_female = no
							ROOT = { is_female = yes }
						}
						AND = {
							NOT = { trait = homosexual }
							ROOT = { NOT = { trait = homosexual } }
							is_female = yes
							ROOT = { is_female = no }
						}
						AND = {
							trait = homosexual
							ROOT = { trait = homosexual }
							is_female = yes
							ROOT = { is_female = yes }
						}
						AND = {
							trait = homosexual
							ROOT = { trait = homosexual }
							is_female = no
							ROOT = { is_female = no }
						}
					}
					has_lover = no
					is_pregnant = no
					prisoner = no
					is_marriage_adult = yes
					NOT = {
						has_character_modifier = lustful_affair_timer
					}
					NOT = { trait = infirm }
					NOT = { trait = incapable }
					NOT = { trait = celibate }
					NOT = { trait = eunuch }
					NOT = { trait = chaste }
					NOT = { spouse = { character = ROOT } }
					NOT = { trait = in_hiding }
					opinion = { who = ROOT value = 0 }
					reverse_opinion = { who = ROOT value = 0 }
					NOT = {
						is_former_lover = ROOT
					}
				}
				add_character_modifier = {
					name = lustful_affair_timer
					duration = 365
					hidden = yes
				}
				character_event = { id = 451 days = 7 tooltip = EVTTOOLTIP451 }
			}
		}
	}
}

#############################################
# PREGNANCY STARTS SHOWING EVENTS
#############################################

# On-action event: Pregnancy starts showing
character_event = {
	id = 400
	desc = EVTDESC400
	picture = GFX_evt_pregnancy
	
	is_triggered_only = yes
	
	trigger = {
		NOT = { trait = pregnant }
		father_of_unborn = {
			any_spouse = {
				character = ROOT
			}
		}
	}
	
	option = {
		name = OK
		add_trait = pregnant
		prestige = 10
		
		if = {
			limit = {
				father_of_unborn = {
					is_alive = yes
				}
			}
			father_of_unborn = { character_event = { id = 403 tooltip = EVTTOOLTIP403 } }
		}
	}
}

# On-action event: Pregnancy out of wedlock!
character_event = {
	id = 401
	desc = EVTDESC401
	picture = GFX_evt_pregnancy
	
	is_triggered_only = yes
	
	trigger = {
		NOT = { trait = pregnant }
		is_married = no
		is_consort = no
		father_of_unborn = {
			NOT = {
				any_spouse = {
					character = ROOT
				}				
			}
		}
	}
	
	option = {
		name = OK
		add_trait = pregnant
		piety = -50
		prestige = -50
	}
}

# On-action event: Pregnancy in matrimony, with another father!
character_event = {
	id = 402
	desc = EVTDESC402
	picture = "GFX_evt_pregnancy"
	
	is_triggered_only = yes
	
	trigger = {
		NOT = { trait = pregnant }
		is_married = yes
		father_of_unborn = {
			NOT = {
				any_spouse = {
					character = ROOT
				}			
			}
		}
	}
	
	option = {
		name = EVTOPTA402
		add_trait = pregnant
		spouse = { character_event = { id = 404 tooltip = EVTTOOLTIP404 } }
	}
}

# The husband is a proud father!
character_event = {
	id = 403
	picture = GFX_evt_pregnancy
	
	is_triggered_only = yes 
	
	desc = EVTDESC403

	option = {
		name = OK
		prestige = 5
	}
}

# The husband suspects something ain't right
character_event = {
	id = 404
	picture = GFX_evt_pregnancy
	
	is_triggered_only = yes 
	
	desc = EVTDESC404

	option = {
		name = EVTOPTA404
		if = {
			limit = {
				FROM = {
					father_of_unborn_known = yes
				}
			}
			opinion = {
				who = FROM
				modifier = opinion_potential_cuckold
				months = 7
			}
		}
	}
}

# Consort: Pregnancy starts showing
character_event = {
	id = 410
	desc = EVTDESC410
	picture = GFX_evt_pregnancy
	
	is_triggered_only = yes
	
	trigger = {
		NOT = { trait = pregnant }
		father_of_unborn = {
			is_consort = ROOT
		}
	}
	
	option = {
		name = OK
		add_trait = pregnant
		prestige = 10
		
		if = {
			limit = {
				father_of_unborn = {
					is_alive = yes
				}
			}
			father_of_unborn = { character_event = { id = 413 tooltip = EVTTOOLTIP413 } }
		}
	}
}

# Consort: Pregnancy with another father!
character_event = {
	id = 412
	desc = EVTDESC412
	picture = "GFX_evt_pregnancy"
	
	is_triggered_only = yes
	
	trigger = {
		NOT = { trait = pregnant }
		is_consort = yes
		father_of_unborn = {
			NOT = {
				is_consort = ROOT		
			}
		}
	}
	
	option = {
		name = EVTOPTA412
		add_trait = pregnant
		consort = { character_event = { id = 414 tooltip = EVTTOOLTIP414 } }
	}
}

# The consort's liege is a proud father!
character_event = {
	id = 413
	picture = GFX_evt_pregnancy
	
	is_triggered_only = yes 
	
	desc = EVTDESC413

	option = {
		name = OK
		prestige = 5
	}
}

# The consort's liege suspects something ain't right
character_event = {
	id = 414
	picture = GFX_evt_pregnancy
	
	is_triggered_only = yes 
	
	desc = EVTDESC414

	option = {
		name = EVTOPTA414
		if = {
			limit = {
				FROM = {
					father_of_unborn_known = yes
				}
			}
			opinion = {
				who = FROM
				modifier = opinion_potential_cuckold
				months = 7
			}
		}
	}
}

#############################################
# EVENTS ON THE BIRTH OF A BASTARD CHILD
#############################################

# On-action event: A child is born out of wedlock
character_event = {
	id = 300
	hide_window = yes
	
	is_triggered_only = yes
	
	trigger = {
		was_conceived_a_bastard = yes
		NOT = { real_father = { always = yes } } # There is no 'real_father' set, i.e. this is not a hidden, cuckoo bastard
		mother = {
			OR = {
				is_ruler = no
				is_married_matrilineally = no
				AND = {
					is_ruler = yes
					primary_title = {
						PREV = {
							spouse = {
								is_ruler = yes
								primary_title = {
									NOT = {
										lower_tier_than = PREVPREVPREV
									}
								}
							}
						}
					}
				}
			}
		}
	}

	option = {
		father = {
			if = {
				limit = {
					religion_group = christian
				} 
				character_event = { id = 301 days = 1 } # The father's reaction
			}
		}
	}
}

# The father reacts to the bastard birth
character_event = {
	id = 301
	desc = EVTDESC301
	picture = GFX_evt_birth
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA301 # Legitimize the child
		FROM = {
			character_event = { id = 302 tooltip = EVTTOOLTIP302 } # The child gets the father's dynasty
			mother = {
				character_event = { id = 303 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 = {
				NOT = { character = FROM }
				dynasty = ROOT
				NOT = { trait = bastard }
			}
			opinion = {
				who = ROOT
				modifier = legitimized_bastard
				months = 12
			}
		}
	}
	
	option = {
		name = EVTOPTB301 # Acknowledge the child
		FROM = {
			character_event = { id = 306 tooltip = EVTTOOLTIP306 } # The child gets the father's dynasty, but is not legitimized.
			mother = {
				character_event = { id = 307 tooltip = EVTTOOLTIP307 } # The child's mother is 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
				}				
			}
		}
	}
	
	option = {
		name = EVTOPTC301 # Denounce the child
		
		FROM = {
			character_event = { id = 309 tooltip = EVTTOOLTIP309 } #  The child founds a new bastard dynasty
			if = {
				limit = { trait = born_in_the_purple }
				remove_trait = born_in_the_purple
			}
			if = {
				limit = { trait = saoshyant_descendant }
				remove_trait = saoshyant_descendant
			}
			if = {
				limit = { trait = sayyid }
				remove_trait = sayyid
			}
			mother = {
				character_event = { id = 310 tooltip = EVTTOOLTIP310 } # The child's mother is dishonoured
				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
				}				
			}
		}
	}
}

# The child gets the father's dynasty
character_event = {
	id = 302
	
	is_triggered_only = yes 
	desc = EVTDESC302
	picture = GFX_evt_birth

	option = {
		name = OK
		dynasty = FROM
		remove_trait = bastard
		add_trait = legit_bastard
		
		father = {
			spouse = {
				character_event = { id = 305 tooltip = EVTTOOLTIP305 } # The father's wife is enraged
			}
		}
	}
}

# The child's mother is very pleased
character_event = {
	id = 303
	
	is_triggered_only = yes 
	desc = EVTDESC303
	picture = GFX_evt_birth

	option = {
		name = EVTOPTA303
		opinion = {
			who = FROM
			modifier = legitimized_child
			years = 10
		}
	}
}

# The child's mother's husband is pissed off
character_event = {
	id = 304
	picture = GFX_evt_quarrel
	desc = EVTDESC304
	
	is_triggered_only = yes 

	option = {
		name = EVTOPTA304
		FROMFROM = {
			real_father = {
				reverse_opinion = {
					who = ROOT
					modifier = cuckolded
					years = 10
				}
			}
			mother = {
				reverse_opinion = {
					who = ROOT
					modifier = unfaithful
					years = 10
				}
			}
		}
	}
}

# The father's wife is enraged
character_event = {
	id = 305
	desc = EVTDESC305
	picture = GFX_evt_quarrel
	
	is_triggered_only = yes 

	option = {
		name = EVTOPTA305
		FROM = {
			mother = {
				reverse_opinion = {
					who = ROOT
					modifier = slut_seductress
					years = 20
				}
			}
		}
		
		spouse = {
			reverse_opinion = {
				who = ROOT
				modifier = legitimized_bastard
				years = 20
			}
		}
	}
}

# The child gets the father's dynasty, but is not legitimized.
character_event = {
	id = 306
	
	is_triggered_only = yes 
		
	desc = EVTDESC306
	picture = GFX_evt_birth

	option = {
		name = OK
		dynasty = FROM
		add_trait = bastard
		
		father = {
			spouse = {
				character_event = { id = 308 tooltip = EVTTOOLTIP308 } # The father's wife is angered
			}
		}
	}
}

# The child's mother is pleased
character_event = {
	id = 307
	
	is_triggered_only = yes 
		
	desc = EVTDESC307
	picture = GFX_evt_birth

	option = {
		name = EVTOPTA307
		opinion = {
			who = FROM
			modifier = acknowledged_child
			years = 10
		}
	}
}

# The father's wife is angered
character_event = {
	id = 308
	picture = GFX_evt_quarrel
	
	is_triggered_only = yes 
		
	desc = EVTDESC308

	option = {
		name = EVTOPTA308
		FROM = {
			mother = {
				reverse_opinion = {
					who = ROOT
					modifier = slut_seductress
					years = 20
				}
			}
		}
		
		spouse = {
			reverse_opinion = {
				who = ROOT
				modifier = acknowledged_bastard
				years = 10
			}
		}
	}
}

# The child is denounced
character_event = {
	id = 309
	
	is_triggered_only = yes 
		
	desc = EVTDESC309
	picture = GFX_evt_birth

	option = {
		name = OK
		dynasty = mother_bastard
		
		father = {
			spouse = {
				character_event = { id = 311 } # The father's wife is displeased
			}
		}
		set_father = 0
		set_real_father = FROM
	}
}

# The child's mother is dishonoured
character_event = {
	id = 310
	picture = GFX_evt_quarrel
	
	is_triggered_only = yes 
		
	desc = EVTDESC310

	option = {
		name = EVTOPTA310
		opinion = {
			who = FROM
			modifier = denounced_child
			years = 10
		}
	}
}

# The father's wife is displeased
character_event = {
	id = 311
	picture = GFX_evt_quarrel
	
	is_triggered_only = yes 
		
	desc = EVTDESC311

	option = {
		name = EVTOPTA311
		FROM = {
			mother = {
				reverse_opinion = {
					who = ROOT
					modifier = slut_seductress
					years = 20
				}
			}
		}
		
		spouse = {
			reverse_opinion = {
				who = ROOT
				modifier = unfaithful
				years = 5
			}
		}
	}
}

#On-action: birth to consort
character_event = {
	id = 312
	hide_window = yes
	
	is_triggered_only = yes 	
	
	trigger = {
		mother = {
			is_consort = yes #TODO: Should probably track this in code instead, in case consort status changes during pregnancy
		}
	}	
	
	option = {
		add_trait = child_of_consort
	}
}

namespace = matribastard
#On-action event: Bastard is born to a mother who is married matrilineally, or is higher rank than her husband and the real father
character_event = {
	id = matribastard.300
	hide_window = yes
	is_triggered_only = yes
	
	trigger = {
		was_conceived_a_bastard = yes
		mother = {
			is_married = yes
			OR = {
				is_married_matrilineally = yes
				AND = {
					is_ruler = yes
					primary_title = {
						PREV = {
							spouse = {
								primary_title = {
									lower_tier_than = PREVPREVPREV
								}
							}
						}
					}
					OR = {
						NOT = {
							ROOT = {
								real_father = {
									always = yes
								}
							}
						}
						ROOT = {
							real_father = {
								is_ruler = no
							}
						}
						primary_title = {
							ROOT = {
								real_father = {
									primary_title = {
										lower_tier_than = PREVPREVPREV
									}
								}
							}
						}
					}
				}
			}
		}
	}
	#Mother is married matrilineally
	option = {
		trigger = {
			mother = {
				is_married_matrilineally = yes
			}
		}
		mother = {
			character_event = {
				id = matribastard.301	#Mother reacts
			}
		}
	}
	#Mother outranks husband
	option = {
		trigger = {
			mother = {
				is_married_matrilineally = no
			}
		}
		mother = {
			character_event = {
				id = matribastard.302	#Mother reacts
			}
		}
	}
}

#Matrilineally married mother reacts to bastard birth
character_event = {
	id = matribastard.301
	desc = EVTDESCmb301
	picture = GFX_evt_birth
	is_triggered_only = yes
	
	option = {
		name = EVTOPTAmb301
		ai_chance = {
			factor = 100
			modifier = {
				factor = 0.5
				trait = honest
			}
			modifier = {
				factor = 2.0
				trait = deceitful
			}
			modifier = {
				factor = 1.5
				trait = quick
			}
			modifier = {
				factor = 2.0
				trait = genius
			}
			modifier = {
				factor = 1.25
				trait = diligent
			}
			modifier = {
				factor = 1.25
				trait = patient
			}
			modifier = {
				factor = 1.50
				trait = trusting
			}
		}
		hidden_tooltip = {
			FROM = {
				character_event = {
					id = matribastard.303	#Husband reacts
				}
			}
		}
	}
	option = {
		name = EVTOPTBmb301
		ai_chance = {
			factor = 100
			modifier = {
				factor = 1.5
				trait = proud
			}
			modifier = {
				factor = 1.50
				trait = arbitrary
			}
		}
		FROM = {
			add_trait = legit_bastard
			dynasty = ROOT
		}
		hidden_tooltip = {
			FROM = {
				character_event = {
					id = matribastard.304	#Husband reacts
				}
			}
		}
	}
}

#Non-matrilineally married mother who outranks spouse and father reacts to bastard birth
character_event = {
	id = matribastard.302
	desc = EVTDESCmb302
	picture = GFX_evt_birth
	is_triggered_only = yes
	option = {
		name = EVTOPTAmb301
		ai_chance = {
			factor = 100
			modifier = {
				factor = 0.5
				trait = honest
			}
			modifier = {
				factor = 2.0
				trait = deceitful
			}
			modifier = {
				factor = 1.5
				trait = quick
			}
			modifier = {
				factor = 2.0
				trait = genius
			}
			modifier = {
				factor = 1.25
				trait = diligent
			}
			modifier = {
				factor = 1.25
				trait = patient
			}
			modifier = {
				factor = 1.50
				trait = trusting
			}
			modifier = {
				factor = 0.1
				NOT = {
					any_child = {
						dynasty = ROOT
						is_alive = yes
					}
				}
			}
		}
		hidden_tooltip = {
			FROM = {
				character_event = {
					id = matribastard.307	#Husband reacts
				}
			}
		}
	}
	option = {
		name = EVTOPTBmb301
		ai_chance = {
			factor = 100
			modifier = {
				factor = 1.5
				trait = proud
			}
			modifier = {
				factor = 1.50
				trait = arbitrary
			}
		}
		FROM = {
			add_trait = legit_bastard
			dynasty = ROOT
		}
		hidden_tooltip = {
			FROM = {
				character_event = {
					id = matribastard.304	#Husband reacts
				}
			}
		}
	}
}

#(Hidden) Matrilineally married husband reacts to request to recognize child as legitimate
character_event = {
	id = matribastard.303
	hide_window = yes
	is_triggered_only = yes
	
	option = {
		FROM = {
			spouse = {
				character_event = {
					id = matribastard.305
				}
			}
		}
	}
}

#(Hidden) Matrilineally married husband reacts to decision to ignore his opinion
character_event = {
	id = matribastard.304
	hide_window = yes
	is_triggered_only = yes
	
	option = {
		FROM = {
			spouse = {
				character_event = {
					id = matribastard.306
				}
			}
		}
	}
}

#Matrilineally married husband reacts to request to recognize child as legitimate
character_event = {
	id = matribastard.305
	desc = EVTDESCmb305
	picture = GFX_evt_birth
	is_triggered_only = yes
	
	option = {
		name = EVTOPTAmb305
		ai_chance = {
			factor = 100
			modifier = {
				factor = 2.0
				trait = trusting
			}
			modifier = {
				factor = 2.0
				trait = content
			}
			modifier = {
				factor = 1.5
				trait = slothful
			}
		}
		custom_tooltip = { # Mother is pleased
			text = EVTTOOLTIPmb309
			hidden_tooltip = {
				reverse_opinion = {
					modifier = acknowledged_child
					who = FROMFROM
					years = 10
				}
				FROMFROM = {
					character_event = {
						id = matribastard.309
						days = 3
					}
				}
			}
		}
	}
	option = {
		name = EVTOPTBmb305
		ai_chance = {
			factor = 100
			modifier = {
				factor = 2.0
				trait = paranoid
			}
			modifier = {
				factor = 1.5
				trait = envious
			}
			modifier = {
				factor = 1.5
				trait = proud
			}
		}
		custom_tooltip = {
			text = EVTTOOLTIPmb310
			hidden_tooltip = {
				reverse_opinion = {
					modifier = denounced_child
					who = FROMFROM
					years = 10
				}
				FROMFROM = {
					character_event = {
						id = matribastard.310
					}
				}
			}
		}
	}
}

#Matrilineally married husband reacts to decision to ignore his opinion
character_event = {
	id = matribastard.306
	desc = EVTDESCmb306
	picture = GFX_evt_birth
	is_triggered_only = yes
	
	option = {
		name = EVTOPTAmb306
		FROM = {
			mother = {
				reverse_opinion = {
					who = ROOT
					modifier = furious
					years = 10
				}
			}
		}
	}
}

#(Hidden) Lower ranking husband reacts to request to recognize child as legitimate
character_event = {
	id = matribastard.307
	hide_window = yes
	is_triggered_only = yes
	
	option = {
		FROM = {
			spouse = {
				character_event = {
					id = matribastard.308
				}
			}
		}
	}
}

#Lower ranking husband reacts to request to recognize child as legitimate
character_event = {
	id = matribastard.308
	desc = EVTDESCmb308
	picture = GFX_evt_birth
	is_triggered_only = yes
	
	option = {
		name = EVTOPTAmb308
		ai_chance = {
			factor = 100
			modifier = {
				factor = 2.0
				trait = trusting
			}
			modifier = {
				factor = 2.0
				trait = content
			}
			modifier = {
				factor = 1.5
				trait = slothful
			}
			modifier = {
				factor = 2.0
				NOT = {
					any_child = {
						dynasty = ROOT
						is_alive = yes
					}
				}
			}
		}
		custom_tooltip = { # Mother is pleased
			text = EVTTOOLTIPmb309
			hidden_tooltip = {
				reverse_opinion = {
					modifier = acknowledged_child
					who = FROMFROM
					years = 10
				}
				FROMFROM = {
					character_event = {
						id = matribastard.309
						days = 3
					}
				}
			}
		}
	}
	option = {
		name = EVTOPTBmb308
		ai_chance = {
			factor = 100
			modifier = {
				factor = 2.0
				trait = paranoid
			}
			modifier = {
				factor = 1.5
				trait = envious
			}
			modifier = {
				factor = 1.5
				trait = proud
			}
		}
		custom_tooltip = {
			text = EVTTOOLTIPmb310
			hidden_tooltip = {
				reverse_opinion = {
					modifier = denounced_child
					who = FROMFROM
					years = 10
				}
				FROMFROM = {
					character_event = {
						id = matribastard.310
					}
				}
			}
		}
	}
}

#Mother reacts: husband acknowledges child as his own.
character_event = {
	id = matribastard.309
	desc = EVTDESCmb309
	picture = GFX_evt_birth
	is_triggered_only = yes
	
	option = {
		name = EVTOPTAmb309
		custom_tooltip = {
			text = EVTTOOLTIPmb309A
			reverse_opinion = {
				modifier = irritated
				who = FROM
				years = 10
			}
		}
		FROMFROM = {
			dynasty = FROM
		}
	}
}

#Mother reacts: Husband refused request to acknowledge child
character_event = {
	id = matribastard.310
	desc = EVTDESCmb310
	picture = GFX_evt_quarrel
	is_triggered_only = yes
	
	option = {
		name = EVTOPTAmb310
		FROMFROM = {
			dynasty = ROOT
			add_trait = legit_bastard
		}
		opinion = {
			who = FROM
			modifier = denounced_child
			years = 10
		}
	}
}
		

# On-action event: Birth complications
character_event = {
	id = 313
	desc = OK
	
	hide_window = yes
	
	is_triggered_only = yes
	
	trigger = {
		NOT = { age = 1 }
	}

	immediate = {
		random_list = {
			80 = {
				# All is well
			}
			10 = {
				add_trait = sickly
			}
			10 = {
				add_trait = ill
			}
		}
	}

	option = { # No complications
		name = OK
		ai_chance = {
			factor = 120
			modifier = {
				factor = 2.0
				mother = {
					health = 6
				}
			}
			modifier = {
				factor = 2.0
				mother = {
					health = 7
				}
			}
			modifier = {
				factor = 2.0
				mother = {
					num_of_children = 3
				}
			}
			modifier = {
				factor = 1.2
				age = 20
			}
			modifier = {
				factor = 1.2
				age = 25
			}
			modifier = {
				factor = 1.2
				age = 30
			}
		}
	}
	option = { # Mother gets ill
		name = OK
		ai_chance = {
			factor = 12
			modifier = {
				factor = 0
				mother = {
					trait = pneumonic
				}
			}
			modifier = {
				factor = 2.0
				mother = {
					NOT = { health = 4.1 }
				}
			}
			modifier = {
				factor = 1.5
				mother = {
					NOT = { num_of_children = 2 }
				}
			}
		}
		
		mother = {
			if = {
				limit = {
					trait = ill
				}
				character_event = { id = 316 }
			}
			if = {
				limit = {
					NOT = { trait = ill }
				}
				character_event = { id = 315 }
			}
		}
	}
	option = { # Mother gets pneumonia
		name = OK
		ai_chance = {
			factor = 8
			
			modifier = {
				factor = 2.0
				mother = {
					NOT = { health = 4.1 }
				}
			}
			modifier = {
				factor = 6.0
				mother = {
					NOT = { health = 3.1 }
				}
			}
			modifier = {
				factor = 1.5
				mother = {
					NOT = { num_of_children = 2 }
				}
			}
		}
		
		mother = {
			if = {
				limit = {
					OR = {
						trait = pneumonic 
						has_epidemic = yes
					}
				}
				death = {
					death_reason = death_childbirth
				}
			}
			if = {
				limit = {
					NOT = {
						OR = {
							trait = pneumonic 
							has_epidemic = yes
						}
					}
				}
				character_event = { id = 316 }
			}
		}
	}
	option = { # Mother dies
		name = OK
		ai_chance = {
			factor = 2
			modifier = {
				factor = 2.0
				mother = {
					NOT = { health = 4.1 }
				}
			}
			modifier = {
				factor = 6.0
				mother = {
					NOT = { health = 3.1 }
				}
			}
			modifier = {
				factor = 1.5
				mother = {
					NOT = { num_of_children = 2 }
				}
			}
		}
		mother = {
			death = {
				death_reason = death_childbirth
			}
		}
	}
}

# On-action event: Birth complications after a stillbirth
character_event = {
	id = 314
	desc = OK
	
	hide_window = yes
	
	is_triggered_only = yes
	
	trigger = {
		age = 1
	}
	
	option = { # No complications
		name = OK
		ai_chance = {
			factor = 66
			modifier = {
				factor = 2.0
				health = 6
			}
			modifier = {
				factor = 2.0
				health = 7
			}
			modifier = {
				factor = 2.0
				num_of_children = 3
			}
			modifier = {
				factor = 1.2
				age = 20
			}
			modifier = {
				factor = 1.2
				age = 25
			}
			modifier = {
				factor = 1.2
				age = 30
			}
		}
	}
	option = { # Mother gets ill
		name = OK
		ai_chance = {
			factor = 22
			modifier = {
				factor = 0
				trait = pneumonic
			}
			modifier = {
				factor = 2.0
				NOT = { health = 4.1 }
			}
			modifier = {
				factor = 1.5
				NOT = { num_of_children = 2 }
			}
		}
		
		if = {
			limit = {
				trait = ill
			}
			character_event = { id = 315 }
		}
		if = {
			limit = {
				NOT = { trait = ill }
			}
			character_event = { id = 314 }
		}
	}
	option = { # Mother gets pneumonia
		name = OK
		ai_chance = {
			factor = 10
			
			modifier = {
				factor = 2.0
				NOT = { health = 4.1 }
			}
			modifier = {
				factor = 6.0
				NOT = { health = 3.1 }
			}
			modifier = {
				factor = 1.5
				NOT = { num_of_children = 2 }
			}
		}
		
		if = {
			limit = {
				OR = {
					trait = pneumonic 
					has_epidemic = yes
				}
			}
			death = {
				death_reason = death_childbirth
			}
		}
		if = {
			limit = {
				NOT = {
					OR = {
						trait = pneumonic 
						has_epidemic = yes
					}
				}
			}
			character_event = { id = 315 }
		}
	}
	option = { # Mother dies
		name = OK
		ai_chance = {
			factor = 2
			modifier = {
				factor = 2.0
				NOT = { health = 4.1 }
			}
			modifier = {
				factor = 6.0
				NOT = { health = 3.1 }
			}
			modifier = {
				factor = 1.5
				NOT = { num_of_children = 2 }
			}
		}
		death = {
			death_reason = death_childbirth
		}
	}
}

# Mother ill after giving birth
character_event = {
	id = 315
	desc = EVTDESC315
	picture = GFX_evt_illness
	
	is_triggered_only = yes
	
	immediate = {
		add_trait = ill
	}

	option = {
		name = EVTOPTA315
		tooltip = {
			add_trait = ill
		}
	}
}

# Mother pneumonic after giving birth
character_event = {
	id = 316
	desc = EVTDESC315
	picture = GFX_evt_illness
	
	is_triggered_only = yes
	
	immediate = {
		add_trait = pneumonic
	}

	option = {
		name = EVTOPTA315
		tooltip = {
			add_trait = pneumonic
		}
	}
}
	
# On-action event: A bastard child is born, but is not recognized as such by the spouse of the mother
character_event = {
	id = 318
	hide_window = yes
	
	is_triggered_only = yes 
	
	trigger = {
		real_father = {
			is_alive = yes
			ROOT = {
				father = {
					NOT = { character = PREVPREV }
				}
			}
		}
		mother = {
			OR = {
				is_married_matrilineally = no
				ROOT = {
					real_father = {
						lower_tier_than = PREVPREV
					}
				}
				spouse = {
					lower_tier_than = PREV
				}
			}
		}
	}

	option = {
		real_father = {
			character_event = { id = 319 } # The real father is notified
		}
	}
}

character_event = {
	id = 319
	desc = "EVTDESC319"
	picture = "GFX_evt_birth"
	
	is_triggered_only = yes 
	
	option = {
		name = "EVTOPTA319"
		piety = -1
	}
}
