﻿# for secluding pregnant close family members
on_pregnancy_mother = {
	events = {
		lmf_birth.2000 #Liege's spymaster suspects unwed close relative is pregnant
	}
}

# to add post-partum complications for mothers
on_birth_mother = {
	on_actions = {
		on_lmf_birth_complications
	}
}

# complications/postpartum depression after childbirth
on_lmf_birth_complications = {
	trigger = {
		NOT = { has_game_rule = lmf_no_birth_fertility_modifiers }
	}
	effect = {
		trigger_event = {
			id = lmf_birth.1100 # Mother possibly experiences complications
			days = { 7 14 }
		}
	}
}

# yearly pregnancy check
on_lmf_pregnancy_check = {
	trigger = {
		highest_held_title_tier >= tier_county
		NOR = {
			has_government = mercenary_government
			has_government = republic_government
			has_government = theocracy_government
			has_government = holy_order_government
		}
	}
	events = {
		lmf_heir.1531 #yearly check for courtiers of the liege's dynasty, to give them a better chance of at least one child
	}
}

# to give an initial "wedding night" chance at an initial child when Realistic Pregnancies is active
on_lmf_wedding_night = {
	trigger = {
		has_game_rule = lmf_realistic_pregnancies_active
	}
	effect = {
		if = {
			limit = {
				fertility >= 0.30
				scope:spouse.fertility >= 0.30
				is_attracted_to_gender_of = scope:spouse
				scope:spouse = {
					is_attracted_to_gender_of = root
					is_at_same_location = root
				}
				NOR = {
					has_no_real_status_trigger = yes
					exists = involved_activity
					exists = scope:spouse.involved_activity
					has_character_flag = is_ansf_character
					scope:spouse = { has_character_flag = is_ansf_character }
				}
			}
			had_sex_with_effect = { CHARACTER = scope:spouse PREGNANCY_CHANCE = pregnancy_chance }
		}
	}
}

# to make infertile trait inactive on birth
on_lmf_birth_infertile = {
	trigger = {
		NOT = { has_game_rule = lmf_no_birth_fertility_modifiers }
		has_trait = infertile
	}
	effect = {
		make_trait_inactive = infertile
	}
}

