﻿# More Personality Depth — overrides vanilla 00_wet_nurse_tasks.txt
#
# Modification: each task now sets a `mpd_wn_active_task` variable on the
# employer (scope:liege) when it starts, and removes it when the task ends.
# This lets our XP calculator (mpd_calculate_trait_xp) detect which task is
# currently active and adjust trait XP accordingly:
#   - virtue task → faith trait_is_virtue boost / trait_is_sin penalty
#   - relationships task → WN_SOCIAL bonus per trait
#   - competition task → WN_COMPETE bonus per trait
#
# All vanilla content preserved verbatim except for the on_start/on_end blocks.
# Regenerated from the current vanilla file by mpd_sync_vanilla_overrides.py.
# Compat note: incompatible with mods that override the same wet_nurse tasks.
### Wet Nurse Tasks ###

wet_nurse_instill_virtue = {
	court_position_types = { wet_nurse_court_position }

	# Monthly cost for the task
	cost = {
		round = no
		prestige = {
			add = {
				value = monthly_court_position_task_cost
				desc = COURT_POSITION_TASK_COST_BREAKDOWN_BASE
				format = "BASE_VALUE_FORMAT_DECIMALS_PLUS_NEGATIVE"
			}
		}
	}

	is_valid_showing_failures_only = {
		faith = scope:liege.faith
	}

	employee_modifier = {
		child_opinion = 10
	}

	on_start = {
		custom_tooltip = wet_nurse_instill_virtue_fallback_tt
		# MPD: flag the lord so our XP calculator knows this task is active
		scope:liege = {
			set_variable = { name = mpd_wn_active_task value = flag:virtue }
		}
	}

	on_end = {
		# MPD: clear the flag if it was set by THIS task
		scope:liege = {
			if = {
				limit = { has_variable = mpd_wn_active_task var:mpd_wn_active_task = flag:virtue }
				remove_variable = mpd_wn_active_task
			}
		}
	}

	on_monthly = {
		save_scope_as = wetnurse_trait_giver
		liege_or_court_owner = { save_scope_as = notification_character }
		scope:notification_character = {
			random_courtier_or_guest = {
				limit = {
					is_adult = no
					age >= 6
					number_of_personality_traits < 3
					trigger_if = {
						limit = {
							any_relation = { type = guardian }
						}
						any_relation = {
							type = guardian
							NOT = { this = scope:notification_character }
						}
					}
				}
				random = {
					chance = {
						value = 1
						add = {
							value = "scope:wetnurse_trait_giver.aptitude(wet_nurse_court_position)"
							multiply = 0.4
						}
					}
					instill_virtue_trait_effect = yes
				}
			}
			if = {
				limit = {
					is_adult = no
					number_of_personality_traits < 3
					age >= 6
				}
				random = {
					chance = {
						value = 1
						add = "scope:wetnurse_trait_giver.aptitude(court_tutor_court_position)"
					}
					instill_virtue_trait_effect = yes
				}
			}
		}
	}

	ai_will_do = {
		value = 0 # Never used by AI
	}
}

wet_nurse_promote_relationships = {
	court_position_types = { wet_nurse_court_position }

	# Monthly cost for the task
	cost = {
		round = no
		prestige = {
			add = {
				value = monthly_court_position_task_cost
				desc = COURT_POSITION_TASK_COST_BREAKDOWN_BASE
				format = "BASE_VALUE_FORMAT_DECIMALS_PLUS_NEGATIVE"
			}
		}
	}

	base_employer_modifier = {
		child_opinion = 5
	}

	employee_modifier = {
		diplomacy = 2
	}

	on_start = {
		custom_tooltip = wet_nurse_promote_relationships_fallback_tt
		# MPD: flag the lord so our XP calculator knows this task is active
		scope:liege = {
			set_variable = { name = mpd_wn_active_task value = flag:relationships }
		}
	}

	on_end = {
		# MPD: clear the flag if it was set by THIS task
		scope:liege = {
			if = {
				limit = { has_variable = mpd_wn_active_task var:mpd_wn_active_task = flag:relationships }
				remove_variable = mpd_wn_active_task
			}
		}
	}

	on_monthly = {
		liege_or_court_owner = { save_scope_as = notification_character }
		scope:notification_character = {
			random = {
				chance = {
					value = 2
					add = {
						value = "aptitude(wet_nurse_court_position)"
						multiply = 0.3
					}
				}
				random_courtier_or_guest = {
					limit = {
						is_adult = no
					}
					save_scope_as = child_character
					scope:notification_character = {
						random_courtier_or_guest = {
							limit = {
								is_adult = no
								this != scope:child_character
							}
							save_scope_as = child_character_2
						}
					}
					random_list = {
						5 = { # Remove bully
							trigger = {
								any_relation = {
									type = bully
								}
							}
							promote_relationships_remove_relation_effect = { RELATION = bully }
						}
						5 = { # Remove victim
							trigger = {
								any_relation = {
									type = victim
								}
							}
							promote_relationships_remove_relation_effect = { RELATION = victim }
						}
						2 = { # Build friendship
							trigger = {
								exists = scope:child_character_2
							}
							scope:child_character = {
								progress_towards_friend_effect = {
									CHARACTER = scope:child_character_2
									OPINION = 15
									REASON = friend_upgrade_generic
								}
							}
						}
					}
				}
			}
		}
	}

	ai_will_do = {
		value = 0 # Never used by AI
	}
}

wet_nurse_promote_competition = {
	court_position_types = { wet_nurse_court_position }

	# Monthly cost for the task
	cost = {
		round = no
		prestige = {
			add = {
				value = monthly_court_position_task_cost
				desc = COURT_POSITION_TASK_COST_BREAKDOWN_BASE
				format = "BASE_VALUE_FORMAT_DECIMALS_PLUS_NEGATIVE"
			}
		}
	}

	employee_modifier = {
		intrigue = 1
		prowess = 1
		child_opinion = -5
	}

	on_start = {
		custom_tooltip = wet_nurse_promote_competition_fallback_tt
		# MPD: flag the lord so our XP calculator knows this task is active
		scope:liege = {
			set_variable = { name = mpd_wn_active_task value = flag:competition }
		}
	}

	on_end = {
		# MPD: clear the flag if it was set by THIS task
		scope:liege = {
			if = {
				limit = { has_variable = mpd_wn_active_task var:mpd_wn_active_task = flag:competition }
				remove_variable = mpd_wn_active_task
			}
		}
	}

	on_monthly = {
		liege_or_court_owner = { save_scope_as = notification_character }
		scope:notification_character = {
			random = {
				chance = {
					value = 1
					add = {
						value = "aptitude(wet_nurse_court_position)"
						multiply = 0.4
					}
				}
				random_courtier_or_guest = {
					limit = {
						is_adult = no
						NOT = { has_variable = wet_nurse_promote_competition_char_cooldown }
					}
					set_variable = {
						name = wet_nurse_promote_competition_char_cooldown
						months = 6
					}
					save_scope_as = child_character
					scope:notification_character = {
						random_courtier_or_guest = {
							limit = {
								is_adult = no
								this != scope:child_character
							}
							save_scope_as = child_character_2
						}
					}
					random_list = {
						5 = { # Gain intrigue
							add_intrigue_skill = 1
						}
						5 = { # Gain prowess
							add_prowess_skill = 1
						}
					}
					if = {
						limit = {
							exists = scope:child_character_2
						}
						random = {
							chance = 50
							progress_towards_rival_effect = {
								REASON = rival_ignored_suffering
								CHARACTER = scope:child_character_2
								OPINION = default_rival_opinion
							}
						}
					}
				}
			}
		}
	}

	ai_will_do = {
		value = 0 # Never used by AI
	}
}
