﻿#Events for pregnancy on actions

namespace = pregnancy



# This event is always called on pregnancy start. Determines if the pregnancy will continue smoothly, if it will continue with complications, or be terminated prematurely.
#If either the birth goes smoothly, the mother grows sick, or the child grows sick, it will trigger the ordinary birth event (birth.0001). Otherwise a custom event will be triggered.

# by Linnéa Thimrén
pregnancy.0001 = {
	hidden = yes
	immediate = {
		#PREGNANCY COMPLICATION CALCULATIONS & FLAG-SETTING
		random_list = {
			65 = { #All goes smoothly!
				#Less likely if health is bad
				modifier = {
					health <= fine_health
					add = -10
				}
				modifier = {
					health <= poor_health
					add = -15
				}

				#More kids means less risk of complications!
				modifier = {
					add = 5
					any_child = {
						even_if_dead = yes
						count >= 2
					}
				}
				modifier = {
					add = 5
					any_child = {
						even_if_dead = yes
						count >= 4
					}
				}

				#More likely if you have sacred childbirth
				modifier = {
					factor = 2 # Religious doctrine focusing on providing a sanitary birthing chamber and supplied should have a substantial impact on birth complications.
					faith = {
						has_doctrine = tenet_sacred_childbirth
					}
				}
				#More likely if the Dynasty has the Kin legacy
				modifier = {
					factor = 1.5 # So too should constant care of pregnant/birthing mothers.
					has_dynasty = yes
					dynasty = {
						has_dynasty_perk = kin_legacy_3
					}
				}

				add_character_flag = {
					flag = birth_will_go_smoothly
					days = 270
				}
			}
			10 = { #Pregnancy ends prematurely
				trigger_event = {
					id = pregnancy.2101
					days = { 80 120 }
				}
			}
			7 = { #Child dies during delivery (this triggers when the birth "should" have gone down, since we don't want to create the baby)
				trigger_event = {
					id = birth.3001
					days = { 180 200 }
				}
			}
			15 = { #Mother dies
				modifier = { #to keep players from dying excessively
					add = -6
					is_ai = no
				}
				add_character_flag = { #Flags blocks other birth events
					flag = birth_mother_will_die
					days = 270
				}
			}
			12 = { #Mother and child dies (this triggers when the birth "should" have gone down, since we don't want to create the baby)
				modifier = { #to keep players from dying excessively
					add = -6
					is_ai = no
				}
				trigger_event = {
					id = birth.3021
					days = { 180 200 }
				}
			}
			10 = { #Sickly child (all other events happen as usual)
				add_character_flag = { #Flags blocks other birth events
					flag = birth_child_will_become_sickly
					days = 270
				}
			}
			5 = { #Ill mother (all other events happen as usual)
				modifier = { #to keep players from dying excessively
					add = -4
					is_ai = no
				}
				add_character_flag = { #Flags blocks other birth events
					flag = birth_mother_will_become_ill
					days = 270
				}
			}
		}
	}
}

