################################################
#
# Events for Wards
#
# ID 78000 - 78999 is reserved
#
# The basic events are triggered by on actions
#
#################################################
#
# Designed by Johan Andersson
# Written by Sara Wendel-rtqvist

# A fosterling in your court is calling your court inferior to the child's father's court
character_event = {
	id = 78000
	desc = EVTDESC78000
	picture = GFX_evt_guardian

	is_triggered_only = yes # on_yearly_pulse, random_events

	only_rulers = yes
	prisoner = no
	only_capable = yes

	trigger = {
		any_ward = {
			father = {
				higher_real_tier_than = ROOT
				is_alive = yes
			}
		}
	}

	weight_multiplier = {
		factor = 1
	}

	immediate = {
		random_ward = {
			limit = {
				father = {
					higher_real_tier_than = ROOT
					is_alive = yes
				}
			}

			save_event_target_as = target_ward
		}
	}

	option = {
		name = EVTOPTA78000

		scaled_wealth = -0.1

		reverse_opinion = {
			name = opinion_impressed
			who = event_target:target_ward
			years = 5
		}
	}

	option = {
		name = EVTOPTB78000

		trigger = {
			NOR = {
				trait = ambitious
				trait = content
			}
		}

		random = {
			chance = 25
			add_trait_content_effect = yes
		}
	}

	option = {
		name = EVTOPTC78000

		trigger = {
			NOT = { trait = wroth }
		}

		reverse_opinion = {
			name = opinion_upset
			who = event_target:target_ward
			years = 5
		}
	}

	option = {
		name = EVTOPTD78000
		tooltip_info = wroth

		trigger = { trait = wroth }

		reverse_opinion = {
			name = opinion_mad_at_guardian
			who = event_target:target_ward
			years = 5
		}
	}
}

# Being a fosterling in a court superior to your father's is improving your stature
character_event = {
	id = 78005
	desc = EVTDESC78005
	picture = GFX_evt_guardian

	is_triggered_only = yes # on_yearly_pulse, random_events

	min_age = 6
	max_age = 16
	prisoner = no
	only_capable = yes

	trigger = {
		has_guardian = yes

		guardian = {
			ROOT = {
				father = {
					lower_real_tier_than = PREVPREV
					is_alive = yes
					prisoner = no
				}
			}
		}
	}

	weight_multiplier = {
		factor = 1
	}

	option = {
		name = EVTOPTA78005

		prestige = 10

		father = {
			show_scope_change = no

			character_event = {
				id = 78006
				tooltip = EVTTOOLTIP78006
			}
		}
	}
}

# Father is notified about child's progress
character_event = {
	id = 78006
	desc = EVTDESC78006
	picture = GFX_evt_guardian

	is_triggered_only = yes

	option = {
		name = EVTOPTA78006

		prestige = 10
	}
}

# A fosterling in your court has led one of your own children into unacceptable behaviour
character_event = {
	id = 78010
	desc = EVTDESC78010
	picture = GFX_evt_guardian

	is_triggered_only = yes # on_yearly_pulse, random_events

	prisoner = no
	only_capable = yes

	trigger = {
		any_child = {
			is_adult = no
			practical_age >= 6
			is_abroad = no
			prisoner = no
			is_incapable = no

			OR = {
				trait = lustful
				trait = gluttonous
				trait = greedy
				trait = slothful
				trait = envious
				trait = wroth
				trait = proud
			}
		}

		any_ward = {
			NOT = { dynasty = ROOT }
			is_adult = no
			practical_age >= 6
			prisoner = no
			is_incapable = no
		}
	}

	weight_multiplier = {
		factor = 1
	}

	immediate = {
		random_child = {
			limit = {
				is_adult = no
				practical_age >= 6
				is_abroad = no
				prisoner = no
				is_incapable = no

				OR = {
					trait = lustful
					trait = gluttonous
					trait = greedy
					trait = slothful
					trait = envious
					trait = wroth
					trait = proud
				}
			}

			save_event_target_as = target_child
		}

		random_ward = {
			limit = {
				NOT = { dynasty = ROOT }
				is_adult = no
				practical_age >= 6
				prisoner = no
				is_incapable = no
			}

			save_event_target_as = target_ward
		}
	}

	option = {
		name = EVTOPTA78010

		random = {
			chance = 25
			add_trait_fully_arbitrary_effect = yes
		}

		reverse_opinion = {
			name = opinion_upset
			who = event_target:target_ward
			years = 5
		}

		reverse_opinion = {
			name = opinion_approves
			who = event_target:target_child
			years = 5
		}
	}

	option = {
		name = EVTOPTB78010

		random = {
			chance = 25
			add_trait_fully_just_effect = yes
		}

		reverse_opinion = {
			name = opinion_upset
			who = event_target:target_ward
			years = 5
		}

		reverse_opinion = {
			name = opinion_upset
			who = event_target:target_child
			years = 5
		}
	}

	option = {
		name = EVTOPTC78010

		random = {
			chance = 25
			add_trait_fully_kind_effect = yes
		}
	}

	option = {
		name = EVTOPTD78010

		trigger = {
			event_target:target_ward = {
				father = {
					prisoner = no
					higher_real_tier_than = ROOT
				}
			}
		}

		random = {
			chance = 25
			add_trait_fully_deceitful_effect = yes
		}

		reverse_opinion = {
			name = opinion_happy_with_guardian
			who = event_target:target_ward
			years = 5
		}

		reverse_opinion = {
			name = opinion_crestfallen
			who = event_target:target_child
			years = 5
		}
	}
}

# Having a fosterling in your court has made your wife more eager to have more children of her own
character_event = {
	id = 78015
	desc = EVTDESC78015
	picture = GFX_evt_family

	is_married = yes
	only_men = yes
	only_capable = yes
	prisoner = no

	is_triggered_only = yes # on_yearly_pulse, random_events

	trigger = {
		has_children = no

		any_ward = {
			NOT = { dynasty = ROOT }
			practical_age >= 6
		}

		spouse = {
			has_children = no
			is_ruler = no
		}
	}

	weight_multiplier = {
		factor = 1
	}

	option = {
		name = EVTOPTA78015

		fertility = 0.05
	}
}

# A fosterling claims to always being bullied by other children at the court
character_event = {
	id = 78020
	desc = EVTDESC78020
	picture = GFX_evt_child_bully

	is_triggered_only = yes # on_yearly_pulse, random_events

	only_capable = yes

	trigger = {
		any_ward = {
			OR = {
				trait = shy
				trait = craven
				trait = kind
				trait = trusting
			}

			is_adult = no
			practical_age >= 6
			prisoner = no
			is_incapable = no

			ROOT = {
				any_courtier = {
					is_adult = no
					practical_age >= 6

					OR = {
						trait = wroth
						trait = cruel
						trait = deceitful
						trait = envious
					}

					is_abroad = no
					prisoner = no
					is_incapable = no
					NOT = { character = PREVPREV } # ward
				}
			}
		}
	}

	immediate = {
		random_ward = {
			limit = {
				is_adult = no
				practical_age >= 6

				OR = {
					trait = shy
					trait = craven
					trait = kind
					trait = trusting
				}

				prisoner = no
				is_incapable = no
			}

			save_event_target_as = bullied_ward
		}

		random_courtier = {
			limit = {
				is_adult = no
				practical_age >= 6

				OR = {
					trait = wroth
					trait = cruel
					trait = deceitful
					trait = envious
				}

				is_abroad = no
				prisoner = no
				is_incapable = no
				NOT = { character = event_target:bullied_ward }
			}

			save_event_target_as = child_bully
		}
	}

	option = {
		name = EVTOPTA78020

		event_target:bullied_ward = {
			show_scope_change = no

			random = {
				chance = 25
				add_trait_stressed_effect = yes
			}

			opinion = {
				name = opinion_unhappy
				who = ROOT
				years = 5
			}
		}
	}

	option = {
		name = EVTOPTB78020

		event_target:bullied_ward = {
			show_scope_change = no

			if = {
				limit = {
					NOR = {
						trait = craven
						trait = shy
					}
				}

				random = {
					chance = 25
					change_martial = 1
				}
			}
			else = {
				random = {
					chance = 25
					remove_trait_shy_effect = yes
				}

				random = {
					chance = 25
					remove_trait_craven_effect = yes
				}
			}

			add_trait_silently_stressed_effect = yes

			opinion = {
				name = opinion_upset
				who = ROOT
				years = 5
			}
		}
	}

	option = {
		name = EVTOPTC78020

		reverse_opinion = {
			name = opinion_angry
			who = event_target:child_bully
			years = 5
		}
	}
}

# This fosterling has learned important lessons of life from the experience of living in a foreign court
character_event = {
	id = 78025
	desc = EVTDESC78025
	picture = GFX_evt_guardian

	is_triggered_only = yes # on_yearly_pulse, random_events

	only_capable = yes

	trigger = {
		any_ward = {
			practical_age >= 6
			prisoner = no

			NOR = {
				is_child_of = ROOT
				trait = bastard
			}

			father = {
				NOT = { same_realm = ROOT }
			}
		}
	}

	weight_multiplier = {
		factor = 1
	}

	option = {
		name = EVTOPTA78025

		random_ward = {
			limit = {
				practical_age >= 6
				prisoner = no

				NOR = {
					is_child_of = ROOT
					trait = bastard
				}

				father = {
					NOT = { same_realm = ROOT }
				}
			}

			random_list = {
				20 = { change_diplomacy = 1 }
				20 = { change_martial = 1 }
				20 = { change_stewardship = 1 }
				20 = { change_intrigue = 1 }
				20 = { change_learning = 1 }
			}

			father = {
				show_scope_change = no

				character_event = {
					id = 78026
					tooltip = EVTTOOLTIP78026
				}
			}
		}
	}
}

# Father is notified
character_event = {
	id = 78026
	desc = EVTDESC78026
	picture = GFX_evt_guardian

	is_triggered_only = yes

	option = {
		name = EVTOPTA78026

		prestige = 10
	}
}

# You have formed an unusually strong mentor-relationship with your educator
character_event = {
	id = 78030
	desc = EVTDESC78030
	picture = GFX_evt_guardian

	is_triggered_only = yes # on_yearly_pulse, random_events

	min_age = 6
	max_age = 10
	prisoner = no
	only_capable = yes

	trigger = {
		has_guardian = yes

		guardian = {
			opinion = {
				who = ROOT
				value >= 15
			}

			reverse_opinion = {
				who = ROOT
				value >= 15
			}

			NOT = { is_friend = ROOT }
		}
	}

	weight_multiplier = {
		factor = 1
	}

	option = {
		name = EVTOPTA78030

		guardian = {
			show_scope_change = no

			tooltip = {
				add_friend = ROOT
			}

			character_event = {
				id = 78031
				tooltip = EVTTOOLTIP78031
			}
		}
	}

	option = {
		name = EVTOPTB78030

		random_list = {
			20 = { change_diplomacy = 1 }
			20 = { change_martial = 1 }
			20 = { change_stewardship = 1 }
			20 = { change_intrigue = 1 }
			20 = { change_learning = 1 }
		}
	}
}

# Guardian is notified
character_event = {
	id = 78031
	desc = EVTDESC78031
	picture = GFX_evt_guardian

	is_triggered_only = yes

	option = {
		name = EVTOPTA78031

		prestige = 10
		add_friend = FROM
	}
}