﻿#Events for pregnancy on actions
#Edited by Ranger for IC

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 (edited by Ranger)
pregnancy.0001 = {
	hidden = yes
	immediate = {
		#PREGNANCY COMPLICATION CALCULATIONS & FLAG-SETTING
		random_list = { #apparently total is 232?
			120 = { #All goes smoothly! #previously 200
				#Less likely if health is bad
				modifier = {
					health >= excellent_health
					add = 10
				}

				modifier = {
					health >= good_health
					add = 10
				}

				modifier = {
					health <= poor_health
					add = -10 
				}

				modifier = {
					health <= dying_health
					add = -10 
				}

				#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
					}
				}

				#Age affects safety of pregnancy
				modifier = {
					age >= 40
					add = -5
				}
				modifier = {
					age >= 32
					add = -5
				}
				modifier = {
					age <= 23
					add = -5
				}
				modifier = {
					age <= 17
					add = -5
				}

				#More likely if you have sacred childbirth
				modifier = {
					factor = 2 # Religious doctrine focusing on providing a sanitary birthing chamber and supplies should have a substantial impact on birth complications.
					faith = {
						has_doctrine_parameter = safer_childbirths_active
					}
				}
				#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
				}
			}

			20 = { #Pregnancy ends prematurely
				trigger_event = {
					id = pregnancy.2101
					days = { 80 120 }
				}
			}

			20 = { #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 }
				}
			}

			10 = { #Mother dies
				add_character_flag = { #Flags blocks other birth events
					flag = birth_mother_will_die
					days = 270
				}
			}

			10 = { #Mother and child dies (this triggers when the birth "should" have gone down, since we don't want to create the baby)
				trigger_event = {
					id = birth.3021
					days = { 180 200 }
				}
			}

			32 = { #Sickly child (all other events happen as usual)
				modifier = {
					factor = 0.5 # Religious doctrine focusing on providing a sanitary birthing chamber and supplies should have a substantial impact on birth complications.
					faith = {
						has_doctrine_parameter = healthier_children_active
					}
				}
				add_character_flag = { #Flags blocks other birth events
					flag = birth_child_will_become_sickly
					days = 270
				}
			}
			
			20 = { #Ill mother (all other events happen as usual)
				add_character_flag = { #Flags blocks other birth events
					flag = birth_mother_will_become_ill
					days = 270
				}
			}
		}
	}
}