﻿namespace = bp2_decision

##################################################
#
#	FIND WET NURSE
# 0001	Find a character to be a wet nurse
#
##################################################

bp2_decision.0001 = { #find wet nurse candidates
	type = character_event
	content_source = dlc_009
	title = bp2_decision.0001.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { exists = root.primary_spouse }
				desc = bp2_decision.0001.desc
			}
			desc = bp2_decision.0001.desc_widower
		}
	}
	theme = family
	override_background = {
		reference = bp2_nursery
	}
	left_portrait = {
		character = scope:wet_nurse_candidate_1
	}
	right_portrait = {
		character = scope:wet_nurse_candidate_2
	}

	immediate = {
		if = {
			limit = {
				any_spouse = { }
			}
			random_spouse = {
				save_scope_as = spouse
			}
		}
		hidden_effect = {
			if = {
				limit = {
					exists = capital_province
					any_pool_character = {
						province = root.capital_province
						age <= 25
						can_be_employed_as = wet_nurse_court_position
					}
				}
				random_pool_character = {
					province = root.capital_province
					limit = {
						can_be_employed_as = wet_nurse_court_position
						age <= 25
						is_ai = yes
					}
					save_scope_as = wet_nurse_candidate_1
				}
				if = {
					limit = {
						exists = capital_province
						any_pool_character = {
							province = root.capital_province
							age <= 25
							can_be_employed_as = wet_nurse_court_position
							this != scope:wet_nurse_candidate_1
						}
					}
					save_scope_as = wet_nurse_candidate_2
				}
				else = {
					create_character = { #create poor candidate without a child
						template = generic_peasant_character
						gender = female
						age = { 18 25 }
						culture = root.culture
						faith = root.faith
						rite = root.rite
						location = root.location
						save_scope_as = wet_nurse_candidate_2
					}
				}
			}
			else = {
				create_character = { #create a good candidate with a child
					template = bp2_wet_nurse_template
					location = root.location
					save_scope_as = wet_nurse_candidate_1
				}
				create_character = {
					template = peasant_child_character
					age = { 0 5 }
					culture = root.culture
					faith = root.faith
					rite = root.rite
					location = root.location
					save_scope_as = wet_nurse_candidate_1_child
				}
				scope:wet_nurse_candidate_1_child = {
					set_mother = scope:wet_nurse_candidate_1
				}
				create_character = { #create poor candidate without a child
					template = generic_peasant_character
					gender = female
					age = { 18 25 }
					culture = root.culture
					faith = root.faith
					rite = root.rite
					location = root.location
					save_scope_as = wet_nurse_candidate_2
				}
			}
		}
	}

	# Expensive wet nurse with great health and a chance for good trait
	option = {
		name = bp2_decision.0001.a
		custom_tooltip = bp2_decision.0001.a.aptitude
		pay_treasury_or_gold = {
			target = scope:wet_nurse_candidate_1
			value = tiny_treasury_or_gold_value
		}
		hidden_effect = {
			add_courtier = scope:wet_nurse_candidate_1
			add_courtier = scope:wet_nurse_candidate_1_child
		}
		if = { #reappoint the former wet nurse, fire current one if exists
			limit = {
				employs_court_position = wet_nurse_court_position
			}
			every_court_position_holder = {
				type = wet_nurse_court_position
				save_temporary_scope_as = current_wet_nurse
			}
			replace_court_position = {
				recipient = scope:wet_nurse_candidate_1
				holder = scope:current_wet_nurse
				court_position = wet_nurse_court_position
			}
		}
		else = {
			appoint_court_position = {
				recipient = scope:wet_nurse_candidate_1
				court_position = wet_nurse_court_position
			}
		}
		stress_and_fulfillment_impact = {
			greedy = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = greedy
				add = -100
			}
			modifier = {
				short_term_gold < minor_gold_value
				factor = 0
			}
		}
	}
	
	# Cheaper wet nurse; all random traits
	option = {
		name = bp2_decision.0001.b
		custom_tooltip = bp2_decision.0001.b.aptitude
		pay_treasury_or_gold = {
			target = scope:wet_nurse_candidate_2
			value = {
				add = tiny_treasury_or_gold_value
				divide = 3
			}
		}
		hidden_effect = {
			add_courtier = scope:wet_nurse_candidate_2
		}
		if = { #reappoint the former wet nurse, fire current one if exists
			limit = {
				employs_court_position = wet_nurse_court_position
			}
			every_court_position_holder = {
				type = wet_nurse_court_position
				save_temporary_scope_as = current_wet_nurse
			}
			replace_court_position = {
				recipient = scope:wet_nurse_candidate_2
				holder = scope:current_wet_nurse
				court_position = wet_nurse_court_position
			}
		}
		else = {
			appoint_court_position = {
				recipient = scope:wet_nurse_candidate_2
				court_position = wet_nurse_court_position
			}
		}
		stress_and_fulfillment_impact = {
			greedy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 50
			modifier = {
				short_term_gold < tiny_gold_value_check
				factor = 0
			}
		}
	}
	
	# On seconds thoughts, I won't hire a wet nurse at all...
	option = {
		name = bp2_decision.0001.c
		ai_chance = {
			base = 0
			modifier = {
				short_term_gold < tiny_gold_value_check
				add = 10
			}
		}
	}

	after = {
		if = {
			limit = { scope:wet_nurse_candidate_1 = { has_court_position = wet_nurse_court_position } }
			scope:wet_nurse_candidate_2 = {
				silent_disappearance_effect = yes
			}
		}
		else_if = {
			limit = { scope:wet_nurse_candidate_2 = { has_court_position = wet_nurse_court_position } }
			scope:wet_nurse_candidate_1 = {
				silent_disappearance_effect = yes
			}
			scope:wet_nurse_candidate_1_child = {
				silent_disappearance_effect = yes
			}
		}
		else = {
			scope:wet_nurse_candidate_1 = {
				silent_disappearance_effect = yes
			}
			scope:wet_nurse_candidate_2 = {
				silent_disappearance_effect = yes
			}
			scope:wet_nurse_candidate_1_child = {
				silent_disappearance_effect = yes
			}
		}
	}
}
