﻿namespace = bp2_yearly

# bp2_yearly.3000 - Asserting yourself in your studies or loafing

################################
# What's a Study Day Worth?    #
# by Claudia Baldassi          #
# bp2_yearly.3000              #
################################

# Asserting yourself in your studies or loafing

bp2_yearly.3000 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.3000.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:educator
				}
				desc = bp2_yearly.3000.desc
			}
			desc = bp2_yearly.3000.desc_no_educator
		}
		desc = bp2_yearly.3000.desc_ending
	}
	theme = education
	left_portrait = {
		character = root
		animation = boredom
	}
	right_portrait = {
		trigger = { exists = scope:educator }
		character = scope:educator
		animation = personality_rational
	}
	cooldown = { years = 10 } #Should not happen more than once for the same child

	trigger = {
		has_bp2_dlc_trigger = yes
		age >= 8
		is_available_child = yes
		has_education_focus_trigger = yes
		OR = {
			exists = warden
			any_relation = {
				type = guardian
				location = root.location
			}
			exists = liege
			AND = {
				top_liege = this
				employs_court_position = court_tutor_court_position
			}
			any_parent = {
				is_alive = yes
				location = root.location
			}
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		if = {
			limit = {
				is_hostage = yes
				location = warden.location
			}
			warden = {
				save_scope_as = educator
			}
		}
		else_if = {
			limit = {
				any_relation = {
					type = guardian
					location = root.location
				}
			}
			random_relation = {
				type = guardian
				limit = {
					location = root.location
				}
				save_scope_as = educator
			}
		}
		else_if = {
			limit = {
				exists = liege
				root.liege = {
					employs_court_position = court_tutor_court_position
					court_position:court_tutor_court_position = { location = root.location }
				}
			}
			root.liege.court_position:court_tutor_court_position = {
				save_scope_as = educator
			}
		}
		else_if = {
			limit = {
				top_liege = this
				employs_court_position = court_tutor_court_position
				court_position:court_tutor_court_position = { location = root.location }
			}
			court_position:court_tutor_court_position = {
				save_scope_as = educator
			}
		}
		else_if = {
			limit = {
				any_parent = {
					is_alive = yes
					location = root.location
				}
			}
			random_parent = {
				limit = {
					is_alive = yes
					location = root.location
				}
				save_scope_as = educator
			}
		}
		else_if = {
			limit = { exists = liege }
			liege = {
				save_scope_as = educator
			}
		}
	}

	# Option A: study hard
	option = {
		name = bp2_yearly.3000.a
		if = {
			limit = {
				has_focus = education_diplomacy
			}
			add_diplomacy_skill = 1
		}
		else_if = {
			limit = {
				has_focus = education_martial
			}
			add_martial_skill = 1
		}
		else_if = {
			limit = {
				has_focus = education_stewardship
			}
			add_stewardship_skill = 1
		}
		else_if = {
			limit = {
				has_focus = education_intrigue
			}
			add_intrigue_skill = 1
		}
		else_if = {
			limit = {
				has_focus = education_learning
			}
			add_learning_skill = 1
		}
		else_if = {
			limit = {
				has_focus = education_nht_prowess
			}
			add_martial_skill = 1
		}
		else_if = {
			limit = {
				has_focus = education_nht_leadership
			}
			add_stewardship_skill = 1
		}
		hidden_effect = { education_point_acquisition_effect = yes }
		custom_tooltip = bp2_yearly.3000.a.tt

		stress_impact = {
			base = medium_stress_impact_gain
			diligent = medium_stress_impact_loss
			lazy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = diligent
				add = 100
			}
			modifier = {
				has_trait = lazy
				add = -100
			}
			modifier = {
				has_trait = curious
				add = 100
			}
			modifier = {
				has_trait = pensive
				add = 150
			}
		}
	}

	# Option B: study a bit
	option = {
		name = bp2_yearly.3000.b
		hidden_effect = { education_point_acquisition_effect = yes }
		custom_tooltip = bp2_yearly.3000.a.tt
		stress_impact = {
			base = minor_stress_impact_gain
			diligent = minor_stress_impact_loss
			lazy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = diligent
				add = 50
			}
			modifier = {
				has_trait = lazy
				add = -50
			}
			modifier = {
				has_trait = curious
				add = 50
			}
			modifier = {
				has_trait = pensive
				add = 75
			}
		}
	}

	# Option C: play
	option = {
		name = bp2_yearly.3000.c
		add_prowess_skill = 1
		stress_impact = {
			base = minor_stress_impact_loss
			diligent = major_stress_impact_gain
			pensive = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = diligent
				add = -100
			}
			modifier = {
				has_trait = lazy
				add = 100
			}
			modifier = {
				has_trait = pensive
				add = -75
			}
			modifier = {
				has_trait = rowdy
				add = 100
			}
		}
	}
}

################################
# SheHe Knows This Room 	   #
# by Claudia Baldassi          #
# bp2_yearly.3010              #
################################

# Child returns home: This home is unfamiliar to me: parent POV

bp2_yearly.3010 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.3010.t
	desc = bp2_yearly.3010.desc
	theme = hostage
	left_portrait = {
		character = root
		animation = worry
	}
	right_portrait = {
		character = scope:child
		animation = sadness
	}
	
	override_background = {	reference = corridor_day }

	cooldown = { years = 20 }

	trigger = {
		has_bp2_dlc_trigger = yes
		is_available_adult = yes
		is_landless_adventurer = no
		any_child = {
			any_memory = {
				memory_type = hostage_returned_hostage
				memory_age_years <= 1
			}
			any_memory = {
				memory_type = hostage_created_hostage
				memory_age_years >= 6
			}
			age >= 12
			location = root.location
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 1
			has_trait = compassionate
		}
	}

	immediate = {
		# for the responding event
		save_scope_as = parent
		random_child = {
			limit = {
				any_memory = {
					memory_type = hostage_returned_hostage
					memory_age_years <= 1
				}
				any_memory = {
					memory_type = hostage_created_hostage
					memory_age_years >= 6
				}
				age >= 12
				location = root.location
			}
			save_scope_as = child
		}
	}

	# Option A: I wanna help
	option = {
		name = bp2_yearly.3010.a
		scope:child = {
			add_character_flag = helpful_parent_flag
			add_opinion = {
				target = scope:parent
				modifier = feel_accepted_opinion
				opinion = 20
			}
			trigger_event = bp2_yearly.3011
		}
		stress_impact = {
			callous = medium_stress_impact_gain
			fickle = medium_stress_impact_gain
			paranoid = medium_stress_impact_gain
			content = minor_stress_impact_gain
			lazy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
		}
	}

	# Option B: he'll manage
	option = {
		name = bp2_yearly.3010.b
		scope:child = {
			add_opinion = {
				target = root
				modifier = ignored_opinion
				opinion = -15
			}
			scope:child = { trigger_event = bp2_yearly.3011 }
		}
		stress_impact = {
			compassionate = medium_stress_impact_gain
			gregarious = medium_stress_impact_gain
			family_first = medium_stress_impact_gain
			patient = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = callous
				add = 50
			}
		}
	}
}

# Child returns home: This home is unfamiliar to me: child POV

bp2_yearly.3011 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.3011.t
	desc = {
		desc = bp2_yearly.3011.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					has_character_flag = helpful_parent_flag
				}
				desc = bp2_yearly.3011.desc_parent
			}
			desc = bp2_yearly.3011.desc_no_parent
		}
	}
	theme = hostage
	left_portrait = {
		character = root
		animation = sadness
	}
	right_portrait = {
		character = scope:parent
		animation = worry
	}

	override_background = { reference = corridor_day }

	# Option A: accept you're a stranger now
	option = {
		name = bp2_yearly.3011.a
		if = {
			limit = {
				has_character_flag = helpful_parent_flag
			}
			scope:parent = {
				send_interface_toast = {
					title = bp2_yearly.3010.a.tt
					left_icon = scope:child
					scope:child = {
						add_character_modifier = {
							modifier = bp2_stranger_at_home_modifier
							years = 30
						}
					}
				}
			}
		}
		else = {
			add_character_modifier = {
				modifier = bp2_stranger_at_home_modifier
				years = 30
			}
		}
		stress_impact = {
			gregarious = medium_stress_impact_gain
			humble = medium_stress_impact_gain
			patient = minor_stress_impact_gain
			pensive = medium_stress_impact_loss
			bossy = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_vengefulness = 0.5
			}
			modifier = {
				has_trait = pensive
				add = 100
			}
			modifier = {
				has_trait = bossy
				add = 100
			}
		}
	}

	# Option B: try to integrate again
	option = {
		name = bp2_yearly.3011.b
		if = {
			limit = {
				has_character_flag = helpful_parent_flag
			}
			scope:parent = {
				send_interface_toast = {
					title = bp2_yearly.3010.b.tt
					left_icon = scope:child
					scope:child = {
						add_character_modifier = {
							modifier = bp2_stranger_no_more_modifier
							years = 30
						}
					}
				}
			}
		}
		else = {
			add_character_modifier = {
				modifier = bp2_stranger_no_more_modifier
				years = 30
			}
		}
		stress_impact = {
			stubborn = major_stress_impact_gain
			lazy = medium_stress_impact_gain
			reclusive = medium_stress_impact_gain
			arrogant = medium_stress_impact_gain
			wrathful = minor_stress_impact_gain
			impatient = minor_stress_impact_gain
			charming = medium_stress_impact_loss
			curious = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				has_character_flag = helpful_parent_flag
				add = 100
			}
			modifier = {
				has_trait = lazy
				add = -50
			}
			modifier = {
				has_trait = reclusive
				add = -50
			}
			modifier = {
				has_trait = charming
				add = 100
			}
			modifier = {
				has_trait = curious
				add = 100
			}
			ai_value_modifier = {
				ai_energy = -0.5
			}
		}
	}

	after = {
		if = {
			limit = {
				has_character_flag = helpful_parent_flag
			}
			remove_character_flag = helpful_parent_flag
		}
	}
}
