namespace = tgp_movement_events

###################################################################################
## By Veronica Pazos
## tgp_movement_events.0001 - Marshal urges you to prepare for Expansion
## tgp_movement_events.0010 - Try to convince an undecided ruler to join your movement
## tgp_movement_events.0020 - Another Advancement member wants to focus on innovations
## tgp_movement_events.0030 - Movement member sends you a letter asking for support
## tgp_movement_events.0040 - Hegemon sends envoy thanking you for being Pro-Song
## tgp_movement_events.0050 - Elder takes interest in you
## tgp_movement_events.0060 - Antagonize another movement
## tgp_movement_events.0070 - Councillor of your highest skill helps you study
## tgp_movement_events.0080 - Family member asks you to focus on your family
## tgp_movement_events.0090 - Movement member wants to make amends
## tgp_movement_events.0100 - Ask a Movement Leader to abandon their Movement
## tgp_movement_events.0110 - Movement member sends you some books
## tgp_movement_events.0120 - Movement member teaches you Confucianism
## tgp_movement_events.0130 - Movement member teaches you the language of the capital
## tgp_movement_events.0140 - Disciple brings you a gift
## tgp_movement_events.0150 - Shinto visitor at court
## tgp_movement_events.0160 - Promise Movement leader to not scheme against each other
###################################################################################

# Marshal urges you to prepare for Expansion
tgp_movement_events.0001 = {
	type = character_event
	title = tgp_movement_events.0001.t
	desc = tgp_movement_events.0001.desc
	left_portrait = {
		character = root
		animation = interested
	}
	right_portrait = {
		character = scope:marshal
		animation = relaxed_spear
	}
	theme = dynastic_cycle
	override_background = { reference = courtyard }
	cooldown = { years = 10 }

	trigger = {
		is_available_adult = yes
		has_tgp_dlc_trigger = yes
		government_has_flag = government_is_celestial
		top_participant_group:dynastic_cycle ?= {
			participant_group_type = expansion_movement
		}
		NOT = {
			situation:dynastic_cycle ?= {
				situation_current_phase = situation_dynastic_cycle_phase_stability_expansion
			}
		}
	}

	immediate = {
		top_participant_group:dynastic_cycle ?= {
			save_scope_as = my_movement
		}
		if = {
			limit = {
				exists = cp:councillor_marshal
				cp:councillor_marshal = { 
					is_available_healthy_ai_adult = yes 
					is_ruler = no
				}
			}
			cp:councillor_marshal = { save_scope_as = marshal }
		}
		else_if = {
			limit = {
				any_knight = { 
					is_available_healthy_ai_adult = yes 
					is_ruler = no
				}
			}
			ordered_knight = {
				limit = { 
					is_available_healthy_ai_adult = yes 
					is_ruler = no
				}
				order_by = martial
				save_scope_as = marshal
			}
		}
		else = {
			hidden_effect_new_object = {
				create_character = {
					template = knight
					dynasty = none
					location = root.location
					culture = root.location.culture
					faith = root.location.faith
					gender_female_chance = root_soldier_female_chance
					save_scope_as = marshal
				}
			}
		}
		scope:marshal = {
			assign_quirk_effect = yes
			add_character_flag = need_military_outfit
			hidden_effect = {
				if = {
					limit = { NOT = { is_courtier_of = root } }
					root = { add_courtier = prev }
				}
			}
		}
	}

	option = { # Get a military trait
		name = tgp_movement_events.0001.aa
		trigger = {
			vassal_contract_has_flag = celestial_military_appointment
			number_of_commander_traits < 3
		}
		add_internal_flag = special
		reason = celestial_military_appointment
		custom_tooltip = {
			text = tgp_movement_events.0001.c.tt
			give_random_commander_trait_effect = yes
		}
		stress_impact = {
			diligent = medium_stress_impact_loss
			brave = medium_stress_impact_loss
			lazy = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = diligent
					has_trait = brave
				}
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = ambitious
					has_trait = lazy
				}
				factor = 0
			}
		}
	}

	option = { # Get movement power
		name = tgp_movement_events.0001.a
		custom_tooltip = event_increase_movement_power_medium_effect_tooltip
		scope:my_movement = {
			event_change_movement_power_effect = {
				VALUE = event_increase_movement_power_medium_value
			}
		}
		stress_impact = {
			ambitious = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = ambitious
				factor = 2
			}
		}
	}

	option = { # Get influence
		name = tgp_movement_events.0001.b
		change_influence = medium_influence_gain
		stress_impact = {
			deceitful = medium_stress_impact_loss
			honest = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = deceitful
				factor = 2
			}
			modifier = {
				has_trait = honest
				factor = 0
			}
		}
	}

	option = { # Just some martial XP
		name = tgp_movement_events.0001.c
		trigger = {
			NOT = { vassal_contract_has_flag = celestial_military_appointment }
		}
		add_martial_lifestyle_xp = medium_lifestyle_xp
		stress_impact = {
			ambitious = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_lifestyle = martial_lifestyle
				factor = 3
			}
			modifier = {
				has_trait = ambitious
				factor = 0
			}
		}
	}
}

# Try to convince an undecided ruler to join your movement
scripted_trigger tpg_movement_events_0010_valid_ruler = {
	is_available_healthy_ai_adult = yes
	government_has_flag = government_is_celestial
	top_participant_group:dynastic_cycle ?= {
		participant_group_type = undecided_movement
	}
	opinion = {
		target = root
		value >= 0
	}
}

scripted_trigger tgp_movement_events_0010_valid_courtier = {
	is_available_healthy_ai_adult = yes
	is_councillor = no
	NOT = { is_close_family_or_spouse_trigger = { CHARACTER = scope:other_ruler } }
}

tgp_movement_events.0010 = {
	type = character_event
	title = tgp_movement_events.0010.t
	desc = tgp_movement_events.0010.desc
	left_portrait = {
		character = root
		animation = debating
	}
	right_portrait = {
		character = scope:courtier
		animation = interested
	}
	lower_right_portrait = scope:other_ruler
	theme = dynastic_cycle
	override_background = { reference = courtyard }
	cooldown = { years = 10 }

	trigger = {
		is_available_adult = yes
		has_tgp_dlc_trigger = yes
		government_has_flag = government_is_celestial
		top_participant_group:dynastic_cycle ?= {
			OR = {
				participant_group_type = expansion_movement
				participant_group_type = advancement_movement
				participant_group_type = pro_hegemon_movement
				participant_group_type = conservative_movement
			}
		}
		any_ruler = {
			tpg_movement_events_0010_valid_ruler = yes
		}
	}

	immediate = {
		assign_quirk_effect = yes
		top_participant_group:dynastic_cycle ?= {
			save_scope_as = my_movement
		}
		random_ruler = {
			limit = { tpg_movement_events_0010_valid_ruler = yes }
			weight = {
				base = 1
				modifier = {
					is_close_family_of = root
					add = 10
				}
				modifier = {
					is_extended_family_of = root
					add = 5
				}
				modifier = {
					OR = {
						has_relation_friend = root
						has_relation_lover = root
					}
					add = 5
				}
			}
			save_scope_as = other_ruler
			if = {
				limit = {
					any_courtier = { tgp_movement_events_0010_valid_courtier = yes }
				}
				ordered_courtier = {
					limit = {
						tgp_movement_events_0010_valid_courtier = yes
					}
					order_by = diplomacy
					set_location = root.location
					save_scope_as = courtier
				}
			}
			else = {
				hidden_effect_new_object = {
					create_character = {
						location = root.location
						template = diplomacy_court_position_holder_template
						gender_female_chance = root_soldier_female_chance
						faith = scope:other_ruler.capital_county.faith
						culture = scope:other_ruler.capital_county.culture
						save_scope_as = courtier
					}
				}
				hidden_effect = {
					add_courtier = scope:courtier
				}
			}
		}
	}

	option = { # They switch movements
		name = tgp_movement_events.0010.a
		change_influence = medium_influence_gain
		duel = {
			skill = diplomacy
			value = average_skill_rating
			50 = {
			 	compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
				}
				desc = tgp_movement_events.0010.a.success
			 	send_interface_toast = {
				 	title = tgp_movement_events.0010.a.success
				 	left_icon = scope:other_ruler
				 	tgp_dynastic_cycle_add_to_movement_effect = { CHAR = scope:other_ruler }
			 	}
		 	}
		 	50 = {
			 	compare_modifier = {
				 	value = scope:duel_value
				 	multiplier = -3.5
			 	}
				desc = tgp_movement_events.0010.a.failure
			 	send_interface_toast = {
				 	title = tgp_movement_events.0010.a.failure
				 	left_icon = scope:other_ruler
				 	scope:other_ruler = {
						add_opinion = {
							target = root
							modifier = annoyed_opinion
							opinion = -5
						}
					}
			 	}
		 	}
		}
		stress_impact = {
			arrogant = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = arrogant
				factor = 2
			}
		}
	}

	option = { # You get Movement Power
		name = tgp_movement_events.0010.b
		custom_tooltip = event_increased_personal_movement_power_tt
		event_change_movement_power_effect = {
			VALUE = event_increase_movement_power_major_value
		}
		stress_impact = {
			ambitious = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = ambitious
				factor = 2
			}
		}
	}

	option = { # Get Merit
		name = tgp_movement_events.0010.c
		change_merit = medium_merit_gain
		scope:other_ruler = {
			add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 15
			}
		}
		stress_impact = {
			ambitious = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = ambitious
				factor = 2
			}
		}
	}
}

# Another Advancement member wants to focus on innovations
scripted_trigger tpg_movement_events_0020_valid_ruler = {
	this != root
	is_available_healthy_ai_adult = yes
	government_has_flag = government_is_celestial
	top_participant_group:dynastic_cycle ?= {
		participant_group_type = advancement_movement
	}
	culture = root.culture
}

tgp_movement_events.0020 = {
	type = character_event
	title = tgp_movement_events.0020.t
	desc = tgp_movement_events.0020.desc
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = arbitrary
					has_trait = arrogant
					has_trait = ambitious
				}
			}
			animation = dismissal
		}
		animation = interested
		camera = camera_event_crowd
	}
	right_portrait = {
		character = scope:courtier
		animation = gongshou
	}
	lower_right_portrait = scope:other_ruler
	theme = dynastic_cycle
	override_background = { reference = throne_room }
	cooldown = { years = 10 }

	trigger = {
		is_available_adult = yes
		has_tgp_dlc_trigger = yes
		government_has_flag = government_is_celestial
		top_participant_group:dynastic_cycle ?= {
			participant_group_type = advancement_movement
		}
		any_ruler = {
			tpg_movement_events_0020_valid_ruler = yes
		}
	}

	immediate = {
		culture = { save_scope_as = my_culture }
		top_participant_group:dynastic_cycle ?= {
			save_scope_as = my_movement
		}
		random_ruler = {
			limit = { tpg_movement_events_0020_valid_ruler = yes }
			save_scope_as = other_ruler
			if = {
				limit = {
					any_courtier = { tgp_movement_events_0010_valid_courtier = yes }
				}
				ordered_courtier = {
					limit = {
						tgp_movement_events_0010_valid_courtier = yes
					}
					order_by = diplomacy
					set_location = root.location
					save_scope_as = courtier
				}
			}
			else = {
				hidden_effect_new_object = {
					create_character = {
						location = root.location
						template = diplomacy_court_position_holder_template
						gender_female_chance = root_soldier_female_chance
						faith = scope:other_ruler.capital_county.faith
						culture = scope:other_ruler.capital_county.culture
						save_scope_as = courtier
					}
				}
				hidden_effect = {
					add_courtier = scope:courtier
				}
			}
		}
		scope:courtier = { assign_quirk_effect = yes }
	}

	option = { # Get extra bonuses
		name = tgp_movement_events.0020.aa
		trigger = {
			has_trait = architect
			NOT = { has_character_modifier = tgp_advancement_innovations_modifier }
		}
		add_character_modifier = tgp_advancement_innovations_modifier # Forever
		scope:my_culture = {
			add_fascination_progress = 5
		}
		if = {
			limit = {
				is_ai = no
				has_any_nickname = no
			}
			random = {
				chance = 25
				give_nickname = nick_the_wise
			}
		}
		stress_impact = {
			diligent = medium_stress_impact_loss
			brave = medium_stress_impact_loss
			ambitious = medium_stress_impact_gain
			lazy = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = diligent
					has_trait = brave
				}
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = ambitious
					has_trait = lazy
				}
				factor = 0
			}
		}
	}

	option = { # Get Innovation Progress
		name = tgp_movement_events.0020.a
		trigger = {
			NOT = { has_trait = architect }
		}
		scope:my_culture = {
			add_fascination_progress = 5
		}
		custom_tooltip = event_decrease_movement_power_minor_effect_tooltip
		scope:my_movement = {
			event_change_movement_power_effect = {
				VALUE = event_decrease_movement_power_minor_value
			}
		}
		stress_impact = {
			ambitious = medium_stress_impact_gain
			arrogant = medium_stress_impact_gain
			diligent = medium_stress_impact_loss
			humble = medium_stress_impact_loss
		}
		ai_chance = {
			base = 50
			modifier = {
				OR = {
					has_trait = ambitious
					has_trait = arrogant
				}
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = diligent
					has_trait = humble
				}
				factor = 0
			}
		}
	}

	option = { # Focus on movement
		name = tgp_movement_events.0020.b
		custom_tooltip = event_increase_movement_power_medium_effect_tooltip
		scope:my_movement = {
			event_change_movement_power_effect = {
				VALUE = event_increase_movement_power_medium_value
			}
		}
		stress_impact = {
			ambitious = medium_stress_impact_loss
			arrogant = medium_stress_impact_loss
			diligent = medium_stress_impact_gain
			humble = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = ambitious
					has_trait = arrogant
				}
				factor = 0
			}
			modifier = {
				OR = {
					has_trait = diligent
					has_trait = humble
				}
				factor = 2
			}
		}
	}

	option = { # Get Merit
		name = tgp_movement_events.0020.c
		change_merit = medium_merit_gain
		stress_impact = {
			diligent = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				has_lifestyle = learning_lifestyle
				factor = 2
			}
			modifier = {
				has_trait = diligent
				factor = 2
			}
		}
	}
}

# Movement member sends you a letter asking for support
scripted_trigger tpg_movement_events_0030_valid_ruler = {
	this != root
	is_available_healthy_ai_adult = yes
	government_has_flag = government_is_celestial
	top_participant_group:dynastic_cycle ?= root.top_participant_group:dynastic_cycle
	opinion = {
		target = root
		value >= 0
	}
}

tgp_movement_events.0030 = {
	type = letter_event
	opening = tgp_movement_events.0030.opening
	desc = tgp_movement_events.0030.desc
	sender = scope:other_ruler

	cooldown = { years = 5 }

	trigger = {
		is_available_adult = yes
		has_tgp_dlc_trigger = yes
		government_has_flag = government_is_celestial
		exists = top_participant_group:dynastic_cycle
		any_ruler = { tpg_movement_events_0030_valid_ruler = yes }
	}

	immediate = {
		top_participant_group:dynastic_cycle ?= {
			save_scope_as = my_movement
		}
		random_ruler = {
			limit = { tpg_movement_events_0030_valid_ruler = yes }
			weight = {
				base = 1
				modifier = {
					has_relation_potential_friend = root
					add = 25
				}
				modifier = {
					is_close_family_of = root
					add = 10
				}
				modifier = {
					is_extended_family_of = root
					add = 5
				}
				modifier = {
					OR = {
						has_relation_friend = root
						has_relation_lover = root
						has_relation_disciple = root
					}
					add = 5
				}
			}
			save_scope_as = other_ruler
		}
	}

	option = { # Sure
		name = tgp_movement_events.0030.a
		change_merit = medium_merit_gain
		scope:other_ruler = { change_merit = medium_merit_gain }
		progress_towards_friend_effect = {
			REASON = friend_same_movement_reason
			CHARACTER = scope:other_ruler
			OPINION = default_friend_opinion
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = gregarious
					has_trait = generous
				}
				factor = 2
			}
		}
	}

	option = { # Nah
		name = tgp_movement_events.0030.b
		change_influence = major_influence_gain
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = deceitful
					has_trait = callous
					has_trait = arrogant
				}
				factor = 2
			}
		}
	}
}

# Hegemon sends envoy thanking you for being Pro-Song
scripted_trigger tgp_movement_events_0040_valid_courtier = {
	is_available_healthy_ai_adult = yes
	is_councillor = no
	NOT = { is_close_family_or_spouse_trigger = { CHARACTER = scope:hegemon } }
	can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = scope:hegemon }
}

tgp_movement_events.0040 = {
	type = character_event
	title = tgp_movement_events.0040.t
	desc = tgp_movement_events.0040.desc
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = arbitrary
					has_trait = arrogant
					has_trait = ambitious
				}
			}
			animation = dismissal
		}
		animation = interested
		camera = camera_event_left_crowning_observation
	}
	right_portrait = {
		character = scope:courtier
		animation = gongshou_with_hu
	}
	lower_right_portrait = scope:hegemon
	theme = dynastic_cycle
	override_background = { reference = throne_room }
	cooldown = { years = 10 }

	trigger = {
		is_available_adult = yes
		has_tgp_dlc_trigger = yes
		government_has_flag = government_is_celestial
		top_participant_group:dynastic_cycle ?= {
			participant_group_type = pro_hegemon_movement
		}
		exists = title:h_china.holder # There's an Hegemon
	}

	immediate = {
		top_participant_group:dynastic_cycle ?= {
			save_scope_as = my_movement
		}
		title:h_china.holder = {
			save_scope_as = hegemon
			if = {
				limit = {
					any_courtier = { tgp_movement_events_0040_valid_courtier = yes }
				}
				ordered_courtier = {
					limit = {
						tgp_movement_events_0040_valid_courtier = yes
					}
					order_by = diplomacy
					set_location = root.location
					save_scope_as = courtier
				}
			}
			else = {
				hidden_effect_new_object = {
					create_character = {
						location = root.location
						template = diplomacy_court_position_holder_template
						gender_female_chance = root_soldier_female_chance
						faith = scope:hegemon.capital_county.faith
						culture = scope:hegemon.capital_county.culture
						save_scope_as = courtier
					}
				}
				hidden_effect = {
					add_courtier = scope:courtier
				}
			}
		}
	}

	option = { # Yippieeee
		name = tgp_movement_events.0040.a
		custom_tooltip = event_increase_movement_power_major_effect_tooltip
		change_influence = minor_influence_gain
		scope:my_movement = {
			event_change_movement_power_effect = {
				VALUE = event_increase_movement_power_major_value
			}
		}
		stress_impact = {
			ambitious = medium_stress_impact_gain
			arrogant = medium_stress_impact_gain
			diligent = medium_stress_impact_loss
			humble = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = ambitious
					has_trait = arrogant
				}
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = diligent
					has_trait = humble
				}
				factor = 0
			}
		}
	}

	option = { # I will always be loyal!
		name = tgp_movement_events.0040.b
		custom_tooltip = {
			text = dynastic_cycle_cannot_leave_movement_tt
			set_variable = {
				name = dynastic_cycle_cannot_leave_movement_var
				years = 15
			}
		}
		add_character_modifier = {
			modifier = tgp_loyal_subject_modifier
			years = 15
		}
		stress_impact = {
			ambitious = medium_stress_impact_loss
			arrogant = medium_stress_impact_loss
			diligent = medium_stress_impact_gain
			humble = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = ambitious
					has_trait = arrogant
				}
				factor = 0
			}
			modifier = {
				OR = {
					has_trait = diligent
					has_trait = humble
				}
				factor = 2
			}
		}
	}

	option = { # Please please please tell everyone
		name = tgp_movement_events.0040.c
		add_prestige = medium_prestige_gain
		every_vassal = {
			limit = { has_vassal_stance = courtly }
			custom = every_courtly_vassal
			add_opinion = {
				target = root
				modifier = admiration_opinion
				opinion = 15
			}
		}
		stress_impact = {
			diligent = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				has_lifestyle = learning_lifestyle
				factor = 2
			}
			modifier = {
				has_trait = diligent
				factor = 2
			}
		}
	}
}

# Elder takes interest in you
scripted_trigger tgp_movement_events_0050_valid_elder = {
	is_available_healthy_ai_adult = yes
	government_allows = merit
	merit_level >= root.merit_level
	OR = {
		merit_level >= merit_level_expected_empire_value
		has_trait = confucian_education
	}
	top_liege = root.top_liege # Someone that makes sense
	NOR = {
		this = root.liege
		this = root.top_liege
	}
}

tgp_movement_events.0050 = {
	type = character_event
	title = tgp_movement_events.0050.t
	desc = {
		desc = tgp_movement_events.0050.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = { highest_skill = diplomacy }
				desc = tgp_movement_events.0050.desc.diplomacy
			}
			triggered_desc = {
				trigger = { highest_skill = stewardship }
				desc = tgp_movement_events.0050.desc.stewardship
			}
			triggered_desc = {
				trigger = { highest_skill = intrigue }
				desc = tgp_movement_events.0050.desc.intrigue
			}
			triggered_desc = {
				trigger = { highest_skill = learning }
				desc = tgp_movement_events.0050.desc.learning
			}
			triggered_desc = {
				trigger = { highest_skill = martial }
				desc = tgp_movement_events.0050.desc.martial
			}
		}
		desc = tgp_movement_events.0050.desc.outro
	}
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = content
					has_trait = craven
					stress_level >= 1
				}
			}
			animation = worry
		}
		animation = interested
	}
	right_portrait = {
		character = scope:new_elder
		animation = debating
	}
	lower_left_portrait = {
		trigger = { exists = scope:old_elder }
		character = scope:old_elder
	}
	theme = merit
	override_background = { reference = study }
	cooldown = { years = 10 }

	trigger = {
		is_available_adult = yes
		has_tgp_dlc_trigger = yes
		government_allows = merit # Not Celestial specific
		OR = { # You're good or a player
			AND = {
				is_ai = no
				has_any_decent_skill_rating = yes
			}
			has_any_high_skill_rating = yes
		}
		NOT = { any_relation = { type = disciple } } # You're not an elder yourself
		OR = { # You don't have an elder or they're pretty bad
			NOT = {	any_relation = { type = elder } }
			any_relation = {
				type = elder
				OR = {
					merit_level <= root.merit_level
					merit_level <= merit_level_expected_empire_value
				}
			}
		}
		any_ruler = {
			tgp_movement_events_0050_valid_elder = yes
		}
	}

	immediate = {
		top_participant_group:dynastic_cycle ?= {
			save_scope_as = my_movement
		}
		if = {
			limit = {
				any_relation = { type = elder }
			}
			random_relation = {
				type = elder
				save_scope_as = old_elder
			}
		}
		random_ruler = {
			limit = { tgp_movement_events_0050_valid_elder = yes }
			weight = {
				base = 1
				modifier = {
					has_same_highest_skill = { CHARACTER = root }
					add = 100
				}
			}
			save_scope_as = new_elder
		}
	}

	option = { # Get a new Elder
		name = tgp_movement_events.0050.a
		if = {
			limit = { exists = scope:old_elder }
			remove_relation_disciple = scope:old_elder
			scope:old_elder = {
				add_opinion = {
					target = root
					modifier = disappointed_opinion
					opinion = -10
				}
			}
		}
		scope:new_elder = { set_relation_disciple = root }
		change_merit = medium_merit_gain
		stress_impact = {
			ambitious = medium_stress_impact_gain
			arrogant = medium_stress_impact_gain
			diligent = medium_stress_impact_loss
			humble = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = ambitious
					has_trait = arrogant
				}
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = diligent
					has_trait = humble
				}
				factor = 0
			}
		}
	}

	option = { # I will ALWAYS be loyal to old_elder
		name = tgp_movement_events.0050.b
		trigger = { exists = scope:old_elder }
		add_prestige = minor_prestige_gain
		scope:old_elder = {
			add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 20
			}
		}
		if = {
			limit = { NOT = { has_trait = loyal } }
			add_trait = loyal
		}
		stress_impact = {
			ambitious = medium_stress_impact_loss
			arrogant = medium_stress_impact_loss
			diligent = medium_stress_impact_gain
			humble = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = ambitious
					has_trait = arrogant
				}
				factor = 0
			}
			modifier = {
				OR = {
					has_trait = diligent
					has_trait = humble
				}
				factor = 2
			}
		}
	}

	option = { # I need to focus on STUDYING
		name = tgp_movement_events.0050.c
		gain_appropriate_lifestyle_major_xp_effect = yes
		stress_impact = {
			diligent = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				has_lifestyle = learning_lifestyle
				factor = 2
			}
			modifier = {
				has_trait = diligent
				factor = 2
			}
		}
	}
}

# Antagonize another movement
scripted_trigger tgp_movement_events_0060_valid_rival = {
	is_available_healthy_ai_adult = yes
	government_has_flag = government_is_celestial
	top_participant_group:dynastic_cycle ?= {
		NOT = {
			participant_group_type = undecided_movement
		}
		trigger_if = {
			limit = {
				exists = root.top_participant_group:dynastic_cycle
			}
			this != root.top_participant_group:dynastic_cycle
		}
	}
	opinion = {
		target = root
		value <= -10
	}
}

tgp_movement_events.0060 = {
	type = character_event
	title = tgp_movement_events.0060.t
	desc = tgp_movement_events.0060.desc
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = compassionate
					has_trait = calm
				}
			}
			animation = stress
		}
		animation = scheme
	}
	lower_right_portrait = {
		character = scope:rival
	}
	theme = dynastic_cycle
	override_background = { reference = study }
	cooldown = { years = 10 }

	trigger = {
		is_available_adult = yes
		has_tgp_dlc_trigger = yes
		government_has_flag = government_is_celestial
		top_participant_group:dynastic_cycle ?= {
			NOT = { participant_group_type = undecided_movement }
		}
		any_ruler = {
			tgp_movement_events_0060_valid_rival = yes
		}
	}

	immediate = {
		assign_quirk_effect = yes
		top_participant_group:dynastic_cycle ?= {
			save_scope_as = my_movement
		}
		random_ruler = {
			limit = { tgp_movement_events_0060_valid_rival = yes }
			weight = {
				base = 1
				modifier = {
					OR = {
						has_relation_potential_rival = root
						has_relation_rival = root
					}
					add = 25
				}
				modifier = {
					is_any_movement_leader = yes
					add = 15
				}
			}
			top_participant_group:dynastic_cycle ?= {
				save_scope_as = rival_movement
			}
			save_scope_as = rival
		}
	}

	option = { # You convince everyone
		name = tpg_movement_events.0060.aa
		trigger = {
			has_focus_or_focus_trait_trigger = { FOCUS = intrigue_skulduggery_focus }
		}
		reason = lifestyle_focus
		add_internal_flag = special
		custom_tooltip = tgp_movement_events.0060.a.rival_tt
		scope:rival_movement = {
			event_change_movement_power_effect = {
				VALUE = event_decrease_movement_power_medium_value
			}
		}
		custom_tooltip = event_increase_movement_power_major_effect_tooltip
		scope:my_movement = {
			event_change_movement_power_effect = {
				VALUE = event_increase_movement_power_major_value
			}
		}
		add_intrigue_lifestyle_xp = medium_lifestyle_xp
		stress_impact = {
			deceitful = major_stress_impact_loss
			honest = major_stress_impact_gain
			forgiving = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = deceitful
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = honest
					has_trait = forgiving
				}
				factor = 0
			}
		}
	}

	option = { # Scheme against them
		name = tgp_movement_events.0060.a
		if = {
			limit = {
				NOT = {
					any_scheme = {
						is_hostile = yes
						scheme_target_character = scope:rival
					}
				}
			}
			start_scheme = {
				type = challenge_status
				target_character = scope:rival
			}
			custom_tooltip = {
				text = tgp_movement_events.0060.a.tt
				random_scheme = {
					limit = {
						scheme_type = challenge_status
						scheme_target_character = scope:rival
					}
					add_scheme_modifier = { type = extra_success_chance_modifier }
				}
			}
		}
		else = {
			random_scheme = {
				limit = {
					is_hostile = yes
					scheme_target_character = scope:guest
				}
				add_scheme_modifier = {
					type = massive_extra_success_chance_modifier
				}
			}
		}
		custom_tooltip = tgp_movement_events.0060.a.rival_tt
		scope:rival_movement = {
			event_change_movement_power_effect = {
				VALUE = event_decrease_movement_power_medium_value
			}
		}
		stress_impact = {
			deceitful = medium_stress_impact_loss
			vengeful = medium_stress_impact_loss
			honest = medium_stress_impact_gain
			compassionate = medium_stress_impact_gain
			forgiving = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = deceitful
					has_trait = vengeful
				}
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = honest
					has_trait = compassionate
					has_trait = forgiving
				}
				factor = 0
			}
		}
	}

	option = { # Focus on getting Movement Power
		name = tgp_movement_events.0060.b
		custom_tooltip = event_increase_movement_power_medium_effect_tooltip
		scope:my_movement = {
			event_change_movement_power_effect = {
				VALUE = event_increase_movement_power_medium_value
			}
		}
		stress_impact = {
			ambitious = medium_stress_impact_loss
			deceitful = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = ambitious
				factor = 2
			}
			modifier = {
				has_trait = deceitful
				factor = 0
			}
		}
	}

	option = { # Forgive and forget
		name = tgp_movement_events.0060.c
		if = {
			limit = {
				faith = {
					OR = {
						trait_is_virtue = calm
						trait_is_virtue = compassionate
					}
				}
			}
			add_piety = medium_piety_gain
			if = {
				limit = { exists = cp:councillor_court_chaplain }
				cp:councillor_court_chaplain = {
					add_opinion = {
						target = root
						modifier = pious_opinion
						opinion = 15
					}
				}
			}
		}
		else = {
			add_prestige = minor_prestige_gain
		}
		stress_impact = {
			forgiving = major_stress_impact_loss
			callous = major_stress_impact_gain
			vengeful = major_stress_impact_gain
			deceitful = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = forgiving
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = callous
					has_trait = vengeful
					has_trait = deceitful
				}
				factor = 2
			}
		}
	}
}

# Councillor of your highest skill helps you study
scripted_trigger tgp_movement_events_0070_valid_councillor = {
	is_available_healthy_ai_adult = yes
	government_has_flag = government_is_celestial
	has_same_highest_skill = { CHARACTER = root }
	opinion = {
		target = root
		value >= 10
	}
}

tgp_movement_events.0070 = {
	type = character_event
	title = tgp_movement_events.0070.t
	desc = tgp_movement_events.0070.desc
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = lazy
					has_trait = intellect_bad
				}
			}
			animation = stress
		}
		animation = interested
	}
	right_portrait = {
		character = scope:councillor
		animation = happy_teacher
	}
	theme = merit
	override_background = { reference = study }
	cooldown = { years = 10 }

	trigger = {
		is_available_adult = yes
		has_tgp_dlc_trigger = yes
		government_has_flag = government_is_celestial
		any_councillor = { tgp_movement_events_0070_valid_councillor = yes }
	}

	immediate = {
		top_participant_group:dynastic_cycle ?= {
			save_scope_as = my_movement
		}
		random_councillor = {
			limit = { tgp_movement_events_0070_valid_councillor = yes }
			weight = {
				base = 1
				modifier = {
					has_relation_potential_friend = root
					add = 5
				}
			}
			assign_quirk_effect = yes
			save_scope_as = councillor
		}
	}

	option = { # Become friends
		name = tgp_movement_events.0070.a
		progress_towards_friend_effect = {
			REASON = friend_studied_together
			CHARACTER = scope:councillor
			OPINION = default_friend_opinion
		}
		stress_impact = {
			base = medium_stress_impact_loss
			gregarious = medium_stress_impact_loss
			lazy = medium_stress_impact_loss
			diligent = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = gregarious
					has_trait = lazy
				}
				factor = 2
			}
			modifier = {
				has_trait = diligent
				factor = 0
			}
		}
	}

	option = { # Encourage _them_ to focus on their job
		name = {
			trigger = {
				scope:councillor = { is_spouse_of = root }
			}
			text = tgp_movement_events.0070.b.spouse
		}
		name = {
			trigger = {
				NOT = { scope:councillor = { is_spouse_of = root } }
			}
			text = tgp_movement_events.0070.b.councillor
		}
		if = {
			limit = { scope:councillor = { is_spouse_of = root } }
			scope:councillor = { add_highest_skill_two_points_effect = yes }
		}
		else = {
			scope:councillor = {
				councillor_increase_relevant_skill_two_points_effect = yes
			}
		}
		stress_impact = {
			callous = medium_stress_impact_loss
			lazy = medium_stress_impact_loss
			diligent = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = callous
					has_trait = lazy
				}
				factor = 2
			}
			modifier = {
				has_trait = diligent
				factor = 0
			}
		}
	}

	option = { # Study
		name = tgp_movement_events.0070.c
		add_highest_skill_point_effect = yes
		scope:councillor = { add_highest_skill_point_effect = yes }
		stress_impact = {
			base = medium_stress_impact_gain
			diligent = medium_stress_impact_loss
			lazy = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_lifestyle = learning_lifestyle
					has_trait = diligent
				}
				factor = 2
			}
			modifier = {
				has_trait = lazy
				factor = 0
			}
		}
	}
}

# Family member asks you to focus on your family
scripted_trigger tgp_movement_events_0080_valid_family_member = {
	is_available_healthy_ai_adult = yes
	government_has_flag = government_is_celestial
	house = root.house # Just in case
	opinion = {
		target = root
		value >= 10
	}
	gold >= major_gold_value
	NOT = { has_trait = greedy }
	OR = { # Someone that'd want you to focus on Family
		top_participant_group:dynastic_cycle ?= {
			participant_group_type = conservative_movement
		}
		influence_level >= 2
		prestige_level >= 2
		has_trait = ambitious
		has_trait = arrogant
		has_trait = generous
		has_relation_friend = root
		has_relation_lover = root
	}
}

tgp_movement_events.0080 = {
	type = character_event
	title = tgp_movement_events.0080.t
	desc = tgp_movement_events.0080.desc
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = humble
					has_trait = content
					has_trait = lazy
				}
			}
			animation = dismissal
		}
		animation = interested
	}
	right_portrait = {
		character = scope:family_member
		animation = fanning
	}
	theme = administrative
	override_background = { reference = relaxing_room }
	cooldown = { years = 10 }

	trigger = {
		is_available_adult = yes
		has_tgp_dlc_trigger = yes
		government_has_flag = government_is_celestial
		any_close_or_extended_family_member = {
			tgp_movement_events_0080_valid_family_member = yes
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			top_participant_group:dynastic_cycle ?= {
				participant_group_type = conservative_movement
			}
			add = 1
		}
	}

	immediate = {
		save_scope_as = root_scope
		top_participant_group:dynastic_cycle ?= {
			save_scope_as = my_movement
		}
		random_close_or_extended_family_member = {
			limit = { tgp_movement_events_0080_valid_family_member = yes }
			weight = {
				base = 1
				modifier = {
					OR = {
						has_relation_potential_friend = root
						has_relation_friend = root
					}
					add = 5
				}
			}
			assign_quirk_effect = yes
			save_scope_as = family_member
		}
		domicile ?= {
			set_variable = {
				name = subsidised_estate_var
				value = 3
			}
		}
	}

	option = { # Get extra stuff if you are a Conservative
		name = tgp_movement_events.0080.aa
		trigger = {
			top_participant_group:dynastic_cycle ?= {
				participant_group_type = conservative_movement
			}
		}
		add_internal_flag = special
		reason = movement
		add_character_modifier = tgp_subsidised_estate_buildings_modifier
		scope:family_member = {
			remove_short_term_gold = medium_gold_value
		}
		add_prestige = medium_prestige_gain
		stress_impact = {
			generous = medium_stress_impact_gain
			humble = medium_stress_impact_gain
			content = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = diligent
				factor = 2
			}
			modifier = {
				has_trait = arrogant
				factor = 0
			}
		}
	}

	option = { # Thank you mate
		name = tgp_movement_events.0080.a
		trigger = {
			NOT = {
				top_participant_group:dynastic_cycle ?= {
					participant_group_type = conservative_movement
				}
			}
		}
		add_character_modifier = tgp_subsidised_estate_buildings_modifier
		scope:family_member = {
			remove_short_term_gold = medium_gold_value
		}

		stress_impact = {
			generous = medium_stress_impact_gain
			humble = medium_stress_impact_gain
			content = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = gregarious
					has_trait = lazy
				}
				factor = 2
			}
			modifier = {
				has_trait = diligent
				factor = 0
			}
		}
	}

	option = { # This is not the way, focus on our movement
		name = tpg_movement_events.0080.b
		change_influence = medium_influence_gain
		custom_tooltip = event_increase_movement_power_medium_effect_tooltip
		scope:my_movement = {
			event_change_movement_power_effect = {
				VALUE = event_increase_movement_power_medium_value
			}
		}
		scope:family_member = {
			remove_short_term_gold = medium_gold_value
			add_opinion = {
				target = root
				modifier = annoyed_opinion
				opinion = -10
			}
		}

		stress_impact = {
			generous = medium_stress_impact_gain
			humble = medium_stress_impact_gain
			content = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = callous
					has_trait = lazy
				}
				factor = 2
			}
			modifier = {
				has_trait = diligent
				factor = 0
			}
		}
	}

	option = { # Keep the money, bestie
		name = tgp_movement_events.0080.c
		progress_towards_friend_effect = {
			REASON = friend_rejected_funds
			CHARACTER = scope:family_member
			OPINION = default_friend_opinion
		}
		if = {
			limit = {
				faith = {
					OR = {
						trait_is_virtue = generous
						trait_is_virtue = humble
					}
				}
			}
			add_piety = medium_piety_gain
			every_vassal = {
				limit = { has_vassal_stance = zealot }
				custom = every_zealot_vassal
				add_opinion = {
					target = root
					modifier = pious_opinion
					opinion = 5
				}
			}
		}
		stress_impact = {
			gregarious = medium_stress_impact_loss
			generous = medium_stress_impact_loss
			content = medium_stress_impact_loss
			humble = medium_stress_impact_loss
			arrogant = major_stress_impact_gain
			greedy = major_stress_impact_gain
			avaricious = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_lifestyle = learning_lifestyle
					has_trait = diligent
				}
				factor = 2
			}
			modifier = {
				has_trait = lazy
				factor = 0
			}
		}
	}
}

# Movement member wants to make ammnds
scripted_trigger tpg_movement_events_0090_valid_ruler = {
	this != root
	is_available_healthy_ai_adult = yes
	government_has_flag = government_is_celestial
	top_participant_group:dynastic_cycle ?= root.top_participant_group:dynastic_cycle
	opinion = {
		target = root
		value <= -10
	}
	NOT = { has_trait = vengeful } # They would NEVER
}

tgp_movement_events.0090 = {
	type = character_event
	title = tgp_movement_events.0090.t
	desc = tgp_movement_events.0090.desc
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = callous
					has_trait = vengeful
					has_trait = wrathful
				}
			}
			animation = dismissal
		}
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = arrogant
					has_trait = brave
				}
			}
			animation = laugh
		}
		animation = japanese_war_fan
		camera = camera_event_left_pointing_right
	}
	right_portrait = {
		character = scope:courtier
		animation = gongshou
	}
	lower_right_portrait = scope:other_ruler
	theme = dynastic_cycle
	override_background = { reference = garden }
	cooldown = { years = 10 }

	trigger = {
		is_available_adult = yes
		has_tgp_dlc_trigger = yes
		government_has_flag = government_is_celestial
		top_participant_group:dynastic_cycle ?= {
			NOT = { participant_group_type = undecided_movement }
		}
		situation:dynastic_cycle ?= {
			NOT = { situation_current_phase = situation_dynastic_cycle_phase_chaos }
		}
		any_ruler = { tpg_movement_events_0090_valid_ruler = yes }
	}

	weight_multiplier = {
		base = 1
		modifier = {
			any_relation = { type = rival }
			add = 1
		}
	}

	immediate = {
		top_participant_group:dynastic_cycle ?= {
			save_scope_as = my_movement
		}
		random_ruler = {
			limit = { tpg_movement_events_0090_valid_ruler = yes }
			weight = {
				base = 1
				modifier = {
					has_relation_nemesis = root
					add = 100
				}
				modifier = {
					has_relation_rival = root
					add = 100
				}
				modifier = {
					any_memory = {
						has_memory_category = negative
						any_memory_participant = { this = root }
					}
					add = 50
				}
				modifier = {
					has_trait = forgiving
					add = 10
				}
				modifier = {
					opinion = {
						target = root
						value < -25
					}
					add = 5
				}
				modifier = {
					opinion = {
						target = root
						value < -50
					}
					add = 5
				}
			}
			assign_quirk_effect = yes
			save_scope_as = other_ruler
			if = {
				limit = {
					any_courtier = { tgp_movement_events_0010_valid_courtier = yes }
				}
				ordered_courtier = {
					limit = {
						tgp_movement_events_0010_valid_courtier = yes
					}
					order_by = diplomacy
					set_location = root.location
					save_scope_as = courtier
				}
			}
			else = {
				hidden_effect_new_object = {
					create_character = {
						location = root.location
						template = diplomacy_court_position_holder_template
						gender_female_chance = root_soldier_female_chance
						faith = scope:other_ruler.capital_county.faith
						culture = scope:other_ruler.capital_county.culture
						save_scope_as = courtier
					}
				}
				hidden_effect = {
					add_courtier = scope:courtier
				}
			}
		}
	}

	option = { # They should KNEEL
		name = tgp_movement_events.0090.aa
		trigger = {
			OR = {
				has_trait = callous
				has_trait = vengeful
				has_trait = wrathful
			}
		}
		add_dread = medium_dread_gain
		scope:other_ruler = {
			add_opinion = {
				target = root
				modifier = humiliated_opinion
				opinion = -15
			}
		}
		every_vassal = {
			limit = { has_vassal_stance = belligerent }
			custom = every_belligerent_vassal
			add_opinion = {
				target = root
				modifier = respect_opinion
				opinion = 10
			}
		}
		stress_impact = {
			ambitious = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = ambitious
				factor = 2
			}
		}
	}

	option = { # Nah
		name = tgp_movement_events.0090.a
		change_influence = major_influence_gain
		stress_impact = {
			ambitious = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = ambitious
				factor = 2
			}
		}
	}

	option = { # I do this ONLY for our party
		name = tgp_movement_events.0090.b
		custom_tooltip = event_increase_movement_power_medium_effect_tooltip
		scope:my_movement = {
			event_change_movement_power_effect = {
				VALUE = event_increase_movement_power_medium_value
			}
		}
		stress_impact = {
			deceitful = medium_stress_impact_loss
			honest = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = deceitful
				factor = 2
			}
			modifier = {
				has_trait = honest
				factor = 0
			}
		}
	}

	option = { # Apology accepted
		name = tgp_movement_events.0090.c
		if = {
			limit = { has_relation_nemesis = scope:other_ruler }
			remove_relation_nemesis = scope:other_ruler
		}
		else_if = {
			limit = { has_relation_rival = scope:other_ruler }
			remove_relation_rival = scope:other_ruler
		}
		progress_towards_friend_effect = {
			REASON = friend_same_movement_reason
			CHARACTER = scope:other_ruler
			OPINION = default_friend_opinion
		}
		stress_impact = {
			ambitious = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_lifestyle = martial_lifestyle
				factor = 3
			}
			modifier = {
				has_trait = ambitious
				factor = 0
			}
		}
	}
}

# Ask a Movement Leader to abandon their Movement
scripted_trigger tgp_movement_events_0100_valid_rival = {
	this != root
	is_available_healthy_ai_adult = yes
	government_has_flag = government_is_celestial
	is_any_movement_leader = yes
	NOR = {
		top_participant_group:dynastic_cycle ?= root.top_participant_group:dynastic_cycle
		top_participant_group:dynastic_cycle ?= { participant_group_type = undecided_movement }
	}
}

scripted_trigger tgp_movement_events_0100_valid_spymaster = {
	is_available_healthy_ai_adult = yes
	intrigue >= decent_skill_rating
}

scripted_effect tgp_movement_events_0100_remove_from_movement_effect = {
	custom_tooltip = tgp_movement_events_0100_remove_from_movement_effect_tt
	set_variable = {
		name = movement_member
		value = flag:undecided
	}
	scope:rival_movement = {
		set_variable = {
			name = movement_power
			value = movement_power_value
		}
	}
}

tgp_movement_events.0100 = {
	type = character_event
	title = tgp_movement_events.0100.t
	desc = tgp_movement_events.0100.desc
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = compassionate
					has_trait = forgiving
					has_trait = content
				}
			}
			animation = worry
		}
		animation = spymaster
		camera = camera_event_very_left
	}
	right_portrait = {
		character = scope:spymaster
		animation = scheme
		camera = camera_event_very_right
	}
	lower_right_portrait = scope:rival
	theme = dynastic_cycle
	override_background = { reference = corridor_night }
	cooldown = { years = 10 }

	trigger = {
		is_available_adult = yes
		has_tgp_dlc_trigger = yes
		government_has_flag = government_is_celestial
		top_participant_group:dynastic_cycle ?= {
			NOT = { participant_group_type = undecided_movement }
		}
		situation:dynastic_cycle = {
			any_situation_participant = { tgp_movement_events_0100_valid_rival = yes }
		}
		OR = { # You are important enough
			is_any_movement_leader = yes
			influence_level >= 4
			merit_level >= 4
		}
		OR = { # You have someone that can do the job
			exists = cp:councillor_spymaster
			any_courtier = { tgp_movement_events_0100_valid_spymaster = yes }
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			any_relation = { type = rival }
			add = 1
		}
	}

	immediate = {
		top_participant_group:dynastic_cycle ?= {
			save_scope_as = my_movement
		}
		if = {
			limit = {
				exists = cp:councillor_spymaster
			}
			cp:councillor_spymaster = { save_scope_as = spymaster }
		}
		else = {
			ordered_courtier = {
				limit = { tgp_movement_events_0100_valid_spymaster = yes }
				order_by = intrigue
				save_scope_as = spymaster
			}
		}
		scope:spymaster = { assign_quirk_effect = yes }
		situation:dynastic_cycle = {
			random_situation_participant = {
				limit = { tgp_movement_events_0100_valid_rival = yes }
				weight = {
					base = 1
					modifier = {
						has_relation_nemesis = root
						add = 100
					}
					modifier = {
						has_relation_rival = root
						add = 100
					}
					modifier = {
						any_memory = {
							has_memory_category = negative
							any_memory_participant = { this = root }
						}
						add = 50
					}
					modifier = {
						has_trait = forgiving
						add = 10
					}
					modifier = {
						opinion = {
							target = root
							value < -25
						}
						add = 5
					}
					modifier = {
						opinion = {
							target = root
							value < -50
						}
						add = 5
					}
				}
				assign_quirk_effect = yes
				save_scope_as = rival
				top_participant_group:dynastic_cycle = { save_scope_as = rival_movement }
			}
		}
	}

	option = { # If you have a hook/secret on them, insta win
		name = tgp_movement_events.0100.aa
		trigger = {
			OR = {
				has_hook = scope:rival
				scope:rival = {
					any_secret = {
						is_known_by = root
					}
				}
			}
		}
		add_internal_flag = special
		reason = hook
		remove_hook = { target = scope:rival }
		scope:rival = {
			tgp_movement_events_0100_remove_from_movement_effect = yes
		}
	}

	option = { # Ask them to leave
		name = tgp_movement_events.0100.a
		change_influence = major_influence_loss
		scope:spymaster = {
			duel = {
				skill = intrigue
				target = scope:rival
				25 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3.5
					}
					desc = tgp_movement_events.0100.a.success
					root = {
						send_interface_toast = {
							title = tgp_movement_events.0100.a.success
							left_icon = scope:rival
							scope:rival = {
								tgp_movement_events_0100_remove_from_movement_effect = yes
							}
						}
					}
				}
				75 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
					}
					desc = tgp_movement_events.0100.a.failure
					root = {
						send_interface_toast = {
							title = tgp_movement_events.0100.a.failure
							left_icon = root
							add_prestige = medium_prestige_loss
						}
					}
				}
			}
		}
		stress_impact = {
			ambitious = medium_stress_impact_loss
			deceitful = medium_stress_impact_loss
			honest = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = ambitious
					has_trait = deceitful
				}
				factor = 2
			}
			modifier = {
				has_trait = honest
				factor = 0
			}
		}
	}

	option = { # Pay them to leave
		name = tgp_movement_events.0100.b
		pay_short_term_gold = {
			target = scope:rival
			gold = major_gold_value
		}
		duel = {
			skills = { diplomacy intrigue }
			target = scope:rival
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
				}
				modifier = {
					scope:rival = { has_trait = greedy }
					add = 25
				}
				modifier = {
					scope:rival = { gold <= medium_gold_value }
					add = 10
				}
				desc = tgp_movement_events.0100.a.success
				send_interface_toast = {
					title = tgp_movement_events.0100.a.success
					left_icon = scope:rival
					scope:rival = {
						tgp_movement_events_0100_remove_from_movement_effect = yes
					}
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
				}
				desc = tgp_movement_events.0100.a.failure
				send_interface_toast = {
					title = tgp_movement_events.0100.a.failure
					left_icon = root
					root = { add_prestige = medium_prestige_loss }
				}
			}
		}
		stress_impact = {
			ambitious = medium_stress_impact_loss
			honest = major_stress_impact_gain
			greedy = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = deceitful
				factor = 2
			}
			modifier = {
				OR = {
					gold <= massive_gold_value
					has_trait = greedy
					has_trait = honest
				}
				factor = 0
			}
		}
	}

	option = { # Just undermine them
		name = tgp_movement_events.0100.c
		custom_tooltip = tgp_movement_events.0060.a.rival_tt
		scope:rival_movement = {
			event_change_movement_power_effect = {
				VALUE = event_decrease_movement_power_medium_value
			}
		}
		stress_impact = {
			ambitious = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = ambitious
				factor = 0
			}
		}
	}
}

# Movement member sends you some books
scripted_trigger tpg_movement_events_0110_valid_ruler = {
	this != root
	is_available_healthy_ai_adult = yes
	government_has_flag = government_is_celestial
	trigger_if = {
		limit = {
			exists = top_participant_group:dynastic_cycle
		}
		top_participant_group:dynastic_cycle ?= root.top_participant_group:dynastic_cycle
	}
	top_participant_group:dynastic_cycle ?= {
		NOT = { participant_group_type = undecided_movement }
	}
	learning >= decent_skill_rating
	opinion = {
		target = root
		value >= 0
	}
}

tgp_movement_events.0110 = {
	type = letter_event
	opening = tgp_movement_events.0110.opening
	desc = tgp_movement_events.0110.desc
	sender = scope:other_ruler

	cooldown = { years = 5 }

	trigger = {
		is_available_adult = yes
		has_tgp_dlc_trigger = yes
		government_has_flag = government_is_celestial
		exists = top_participant_group:dynastic_cycle
		any_ruler = { tpg_movement_events_0110_valid_ruler = yes }
	}

	immediate = {
		save_scope_as = root_scope
		top_participant_group:dynastic_cycle ?= {
			save_scope_as = my_movement
		}
		random_ruler = {
			limit = { tpg_movement_events_0110_valid_ruler = yes }
			weight = {
				base = 1
				modifier = {
					has_relation_potential_friend = root
					add = 25
				}
				modifier = {
					is_close_family_of = root
					add = 10
				}
				modifier = {
					is_extended_family_of = root
					add = 5
				}
				modifier = {
					OR = {
						has_relation_friend = root
						has_relation_lover = root
						has_relation_disciple = root
					}
					add = 5
				}
			}
			save_scope_as = other_ruler
			hidden_effect_new_object = {
				create_artifact_book_effect = {
					OWNER = scope:other_ruler
					CREATOR = scope:other_ruler
					SET_SUBJECT = flag:no
					SET_TOPIC = flag:no
				}
			}
		}
		hidden_effect = {
			scope:newly_created_artifact = {
				set_artifact_description = artifact_movement_gift_desc
				set_artifact_rarity = masterwork
			}
		}
	}

	option = { # So nice of you!
		name = tgp_movement_events.0110.a
		gain_appropriate_lifestyle_medium_xp_effect = yes
		progress_towards_friend_effect = {
			REASON = friend_sent_books_reason
			CHARACTER = scope:other_ruler
			OPINION = default_friend_opinion
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = gregarious
					has_trait = diligent
				}
				factor = 2
			}
		}
	}

	option = { # I'll put it in my library
		name = tgp_movement_events.0110.b
		add_prestige = medium_prestige_gain
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = arrogant
					has_trait = lazy
				}
				factor = 2
			}
		}
	}

	after = {
		scope:newly_created_artifact = { set_owner = root }
	}
}

# Movement member teaches you Confucianism
scripted_trigger tpg_movement_events_0120_valid_ruler = {
	this != root
	is_ai = yes
	is_adult = yes
	government_has_flag = government_is_celestial
	top_participant_group:dynastic_cycle ?= root.top_participant_group:dynastic_cycle
	has_trait = confucian_education
	opinion = {
		target = root
		value >= 0
	}
}

scripted_effect tpg_movement_events_0120_confucian_education_effect = {
	if = {
		limit = {
			NOT = { has_trait = confucian_education }
		}
		add_trait_force_tooltip = confucian_education
	}
	else = {
		add_trait_xp = {
			trait = confucian_education
			value = lifestyle_confucian_education_xp_gain_medium_value
		}
	}
}

scripted_effect tpg_movement_events_0120_lifestyle_reveler_effect = {
	if = {
		limit = {
			NOT = { has_trait = lifestyle_reveler }
		}
		random = {
			chance = 25
			add_trait_force_tooltip = lifestyle_reveler
		}
	}
	else = {
		add_trait_xp = {
			trait = lifestyle_reveler
			value = lifestyle_confucian_education_xp_gain_medium_value
		}
	}
}

tgp_movement_events.0120 = {
	type = activity_event
	title = tgp_movement_events.0120.t
	desc = tgp_movement_events.0120.desc
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = arrogant
					has_trait = callous
				}
			}
			animation = eyeroll
		}
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = lazy
					learning <= decent_skill_rating
				}
				NOT = { has_trait = diligent }
			}
			animation = boredom
		}
		animation = drink
	}
	right_portrait = {
		character = scope:other_ruler
		animation = debating
	}
	theme = feast_activity
	cooldown = { years = 10 }

	trigger = {
		is_available_adult = yes
		has_tgp_dlc_trigger = yes
		government_has_flag = government_is_celestial
		exists = top_participant_group:dynastic_cycle
		OR = { # You don't have the trait or you don't have the trait maxed out
			NOT = { has_trait = confucian_education }
			has_trait_xp = { trait = confucian_education value <= 75 }
		}
		involved_activity = {
			any_attending_character = { tpg_movement_events_0120_valid_ruler = yes }
		}
	}

	immediate = {
		top_participant_group:dynastic_cycle ?= {
			save_scope_as = my_movement
		}
		involved_activity = {
			save_scope_as = activity
			activity_host = { save_scope_as = host }
			random_attending_character = {
				limit = { tpg_movement_events_0120_valid_ruler = yes }
				weight = {
					base = 1
					modifier = {
						has_relation_potential_friend = root
						add = 25
					}
					modifier = {
						is_close_family_of = root
						add = 10
					}
					modifier = {
						is_extended_family_of = root
						add = 5
					}
					modifier = {
						OR = {
							has_relation_friend = root
							has_relation_lover = root
							has_relation_disciple = root
						}
						add = 5
					}
				}
				save_scope_as = other_ruler
				assign_quirk_effect = yes
			}
		}
	}

	option = { # Teach me!
		name = tgp_movement_events.0120.a
		tpg_movement_events_0120_confucian_education_effect = yes
		stress_impact = {
			diligent = major_stress_impact_loss
			arrogant = major_stress_impact_gain
			lazy = major_stress_impact_gain
			lifestyle_reveler = major_stress_impact_gain
			drunkard = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = arrogant
					has_trait = lifestyle_reveler
					has_trait = lazy
					has_trait = drunkard
				}
				factor = 0
			}
			modifier = {
				has_trait = diligent
				factor = 2
			}
		}
	}

	option = { # We are here to spread the word of my_movement
		name = tgp_movement_events.0120.b
		custom_tooltip = event_increase_movement_power_minor_effect_tooltip
		scope:my_movement = {
			event_change_movement_power_effect = {
				VALUE = event_increase_movement_power_minor_value
			}
		}
		stress_impact = {
			ambitious = medium_stress_impact_loss
			diligent = medium_stress_impact_gain
			lifestyle_reveler = major_stress_impact_gain
			drunkard = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = ambitious
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = diligent
					has_trait = lifestyle_reveler
					has_trait = drunkard
				}
				factor = 0
			}
		}
	}

	option = { # This is a FEAST
		name = tgp_movement_events.0120.c
		tpg_movement_events_0120_lifestyle_reveler_effect = yes
		 scope:activity = {
        	every_attending_character = {
	            limit = { NOT = { this = root } }
				custom = custom.every_attending_character
	            add_opinion = {
	                target = root
	                modifier = amused_opinion
	                opinion = 5
	            }
	        }
        }
		stress_impact = {
			base = medium_stress_impact_loss
			lifestyle_reveler = medium_stress_impact_loss
			drunkard = medium_stress_impact_loss
			diligent = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = lifestyle_reveler
					has_trait = drunkard
				}
				factor = 2
			}
			modifier = {
				has_trait = diligent
				factor = 0
			}
		}
	}
}

# Movement member teaches you the language of the capital
scripted_trigger tpg_movement_events_0130_valid_ruler = {
	this != root
	is_ai = yes
	is_adult = yes
	government_has_flag = government_is_celestial
	top_participant_group:dynastic_cycle ?= root.top_participant_group:dynastic_cycle
	opinion = {
		target = root
		value >= 0
	}
	knows_language_of_culture = top_liege.capital_county.culture # They are of the same culture
}

scripted_trigger tgp_movement_events_0130_valid_courtier = {
	is_available_healthy_ai_adult = yes
	is_councillor = no
	NOT = { is_close_family_or_spouse_trigger = { CHARACTER = scope:other_ruler } }
	knows_language_of_culture = scope:capital_culture
}

tgp_movement_events.0130 = {
	type = character_event
	title = tgp_movement_events.0130.t
	desc = tgp_movement_events.0130.desc
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = arrogant
					has_trait = callous
				}
			}
			animation = eyeroll
		}
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = lazy
					learning <= decent_skill_rating
				}
				NOT = { has_trait = diligent }
			}
			animation = worry
		}
		animation = interested
		camera = camera_event_crowd
	}
	right_portrait = {
		character = scope:courtier
		animation = obsequious_bow
	}
	lower_right_portrait = scope:other_ruler
	theme = dynastic_cycle
	override_background = { reference = throne_room }
	cooldown = { years = 10 }

	trigger = {
		is_available_adult = yes
		has_tgp_dlc_trigger = yes
		government_has_flag = government_is_celestial
		exists = top_participant_group:dynastic_cycle
		NOT = { knows_language_of_culture = top_liege.capital_county.culture }
		any_ruler = { tpg_movement_events_0130_valid_ruler = yes }
	}

	immediate = {
		top_liege.capital_county.culture = { save_scope_as = capital_culture }
		top_participant_group:dynastic_cycle ?= {
			save_scope_as = my_movement
		}
		random_ruler = {
			limit = { tpg_movement_events_0130_valid_ruler = yes }
			weight = {
				base = 1
				modifier = {
					has_relation_potential_friend = root
					add = 25
				}
				modifier = {
					is_close_family_of = root
					add = 10
				}
				modifier = {
					is_extended_family_of = root
					add = 5
				}
				modifier = {
					OR = {
						has_relation_friend = root
						has_relation_lover = root
						has_relation_disciple = root
					}
					add = 5
				}
			}
			save_scope_as = other_ruler
			if = {
				limit = {
					any_courtier = { tgp_movement_events_0130_valid_courtier = yes }
				}
				ordered_courtier = {
					limit = {
						tgp_movement_events_0130_valid_courtier = yes
					}
					order_by = diplomacy
					set_location = root.location
					save_scope_as = courtier
				}
			}
			else = {
				hidden_effect_new_object = {
					create_character = {
						location = root.location
						template = diplomacy_court_position_holder_template
						gender_female_chance = root_soldier_female_chance
						faith = scope:other_ruler.faith
						culture = scope:capital_culture
						save_scope_as = courtier
					}
				}
				hidden_effect = {
					add_courtier = scope:courtier
				}
			}
			scope:courtier = { assign_quirk_effect = yes }
		}
	}

	option = { # Learn the language!
		name = tgp_movement_events.0130.a
		start_scheme = {
			type = learn_language
			target_character = scope:other_ruler
		}
		custom_tooltip = diplomacy_family.2250.b.tt
		hidden_effect = {
			random_scheme = {
				limit = {
					scheme_type = learn_language
					scheme_target_character = scope:other_ruler
				}
				add_scheme_modifier = {
					type = extra_success_chance_modifier
				}
			}
		}

		stress_impact = {
			diligent = medium_stress_impact_loss
			humble = medium_stress_impact_loss
			lazy = medium_stress_impact_gain
			arrogant = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = humble
					has_trait = diligent
				}
				factor = 0
			}
			modifier = {
				OR = {
					has_trait = arrogant
					has_trait = lazy
				}
				factor = 0
			}
		}
	}

	option = { # Convert
		name = tgp_movement_events.0130.b
		add_prestige = major_prestige_loss
		set_culture = scope:capital_culture
		stress_impact = {
			base = massive_stress_impact_gain
			arrogant = medium_stress_impact_gain
		}
		ai_chance = {
			base = 25
			modifier = {
				has_trait = humble
				add = 75
			}
			modifier = {
				has_trait = arrogant
				factor = 0
			}
		}
	}

	option = { # I'm good tyyyy
		name = tgp_movement_events.0130.c
		culture = {
			change_cultural_acceptance = {
				target = scope:capital_culture
				value = minor_cultural_acceptance_gain
				desc = cultural_acceptance_gain_event
			}
		}
		add_character_modifier = {
			modifier = tgp_cultural_harmony_modifier
			years = 15
		}
		stress_impact = {
			arrogant = medium_stress_impact_loss
			lazy = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = arrogant
					has_trait = lazy
				}
				factor = 2
			}
		}
	}
}

# Disciple brings you a gift
scripted_trigger tgp_movement_events_0140_valid_disciple = {
	is_available_healthy_ai_adult = yes
	opinion = {
		target = root
		value >= 10
	}
}

scripted_trigger tgp_movement_events_0140_valid_artifact = {
	is_equipped = no
	NOT = { rarity = common }
	artifact_can_be_gift_to_trigger = { RECIPIENT = root }
}

scripted_effect tgp_movement_events_0140_create_artifact_effect = {
	random_list = {
		10 = {
			create_artifact_weapon_effect = {
				OWNER = scope:disciple
				CREATOR = scope:disciple
				SET_WEAPON_TYPE = flag:no
			}
		}
		10 = {
			create_artifact_armor_effect = {
				OWNER = scope:disciple
				CREATOR = scope:disciple
				SET_ARMOR_TYPE = flag:no
			}
		}
		10 = {
			create_artifact_book_effect = {
				OWNER = scope:disciple
				CREATOR = scope:disciple
				SET_SUBJECT = flag:no
				SET_TOPIC = flag:no
			}
		}
	}
	hidden_effect = {
		scope:newly_created_artifact = {
			save_scope_as = disciple_gift
			set_artifact_description = disciple_gift_desc
			set_artifact_rarity = masterwork
		}
	}
}

tgp_movement_events.0140 = {
	type = character_event
	title = tgp_movement_events.0140.t
	desc = tgp_movement_events.0140.desc
	left_portrait = {
		character = root
		animation = happiness
		camera = camera_event_crowd
	}
	right_portrait = {
		character = scope:disciple
		animation = gongshou
	}
	artifact = {
		position = lower_right_portrait
		target = scope:disciple_gift
	}
	theme = dynastic_cycle
	override_background = { reference = garden }
	cooldown = { years = 10 }

	trigger = {
		is_available_adult = yes
		has_tgp_dlc_trigger = yes
		government_has_flag = government_is_celestial
		top_participant_group:dynastic_cycle ?= {
			NOT = { participant_group_type = undecided_movement }
		}
		any_relation = {
			type = disciple
			tgp_movement_events_0140_valid_disciple = yes
		}
	}

	immediate = {
		save_scope_as = root_scope
		top_participant_group:dynastic_cycle ?= {
			save_scope_as = my_movement
		}
		ordered_relation = {
			type = disciple
			limit = { tgp_movement_events_0140_valid_disciple = yes }
			order_by = "opinion(root)"
			assign_quirk_effect = yes
			save_scope_as = disciple
			if = {
				limit = {
					any_character_artifact = { tgp_movement_events_0140_valid_artifact = yes }
				}
				ordered_character_artifact = {
					limit = { tgp_movement_events_0140_valid_artifact = yes }
					order_by = artifact_rarity
					save_scope_as = disciple_gift
				}
			}
			else = {
				tgp_movement_events_0140_create_artifact_effect = yes
			}
		}
	}

	option = { # Thank you for the gift!
		name = tgp_movement_events.0140.a
		scope:disciple_gift = { set_owner = root }
		scope:disciple = {
			add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 15
			}
		}
		stress_impact = {
			humble = medium_stress_impact_loss
			greedy = medium_stress_impact_loss
			diligent = medium_stress_impact_gain
			ambitious = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = humble
					has_trait = greedy
				}
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = diligent
					has_trait = ambitious
				}
				factor = 0
			}
		}
	}

	option = { # Remember we do this for the MOVEMENT
		name = tgp_movement_events.0140.b
		custom_tooltip = event_increase_movement_power_medium_effect_tooltip
		scope:my_movement = {
			event_change_movement_power_effect = {
				VALUE = event_increase_movement_power_medium_value
			}
		}
		stress_impact = {
			greedy = medium_stress_impact_gain
			ambitious = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = ambitious
				factor = 2
			}
			modifier = {
				has_trait = greedy
				factor = 0
			}
		}
	}

	option = { # No time to waste, we must study!!!!
		name = tgp_movement_events.0140.c
		change_merit = medium_merit_gain
		scope:disciple = { change_merit = medium_merit_gain }
		if = {
			limit = {
				has_trait = confucian_education
			}
			add_trait_xp = {
				trait = confucian_education
				value = lifestyle_confucian_education_xp_gain_medium_value
			}
		}
		stress_impact = {
			ambitious = medium_stress_impact_gain
			greedy = medium_stress_impact_gain
			diligent = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = diligent
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = greedy
					has_trait = ambitious
				}
				factor = 0
			}
		}
	}
}

# Shinto visitor at court
scripted_trigger tgp_movement_events_0150_valid_monk = {
	is_available_healthy_ai_adult = yes
	has_trait = devoted
	religion = religion:shintoism_religion
	is_councillor = no # Don't steal someone important
}

scripted_trigger tgp_movement_events_0150_valid_ruler = {
	is_available_healthy_ai_adult = yes
	is_landed = yes
	primary_title.tier >= tier_county
	religion = religion:shintoism_religion
}

tgp_movement_events.0150 = {
	type = character_event
	title = tgp_movement_events.0150.t
	desc = {
		desc = tgp_movement_events.0150.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = { exists = scope:other_ruler }
				desc = tgp_movement_events.0150.desc.other_ruler
			}
			triggered_desc = {
				trigger = { NOT = { exists = scope:other_ruler } }
				desc = tgp_movement_events.0150.desc.alone
			}
		}
		desc = tgp_movement_events.0150.desc.outro
	}
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { has_trait = cynical }
			animation = dismissal
		}
		triggered_animation = {
			trigger = { has_trait = zealous }
			animation = anger
		}
		animation = interested
		camera = camera_event_crowd
	}
	right_portrait = {
		character = scope:monk
		animation = prayer
	}
	lower_right_portrait = {
		trigger = { exists = scope:other_ruler }
		character = scope:other_ruler
	}
	theme = faith
	override_background = { reference = throne_room }
	cooldown = { years = 10 }

	trigger = {
		is_available_adult = yes
		has_tgp_dlc_trigger = yes
		government_has_flag = government_is_celestial
		exists = top_participant_group:dynastic_cycle
		NOT = { religion = religion:shintoism_religion }
		highest_held_title_tier >= tier_duchy # You need to be somewhat important
	}

	weight_multiplier = {
		base = 0.5
		modifier = {
			highest_held_title_tier >= tier_duchy
			add = root.primary_title.tier
		}
	}

	immediate = {
		if = { # If there's a valid ruler they're an envoy from them
			limit = {
				faith:shinto = {
					any_faith_ruler = { tgp_movement_events_0150_valid_ruler = yes }
				}
			}
			faith:shinto = {
				random_faith_ruler = {
					limit = { tgp_movement_events_0150_valid_ruler = yes }
					weight = {
						base = 1
						modifier = {
							highest_held_title_tier >= tier_kingdom
							add = 50
						}
						modifier = {
							any_courtier = { tgp_movement_events_0150_valid_monk = yes }
							add = 20
						}
					}
					save_scope_as = other_ruler
					if = {
						limit = {
							any_courtier = {
								tgp_movement_events_0150_valid_monk = yes
							}
						}
						random_courtier = {
							limit = { tgp_movement_events_0150_valid_monk = yes }
							save_scope_as = monk
						}
					}
					else = {
						create_character = {
							location = root.capital_province
							template = monk_character_template
							gender_female_chance = root_faith_dominant_gender_adjusted_female_chance
							faith = scope:other_ruler.faith
							culture = scope:other_ruler.capital_county.culture
							save_scope_as = monk
							after_creation = {
								add_character_flag = created
							}
						}
						hidden_effect = { add_courtier = scope:monk }
					}
				}
			}
		}
		else = { # Otherwise they're a random monk
			create_character = {
				location = root.capital_province
				template = monk_character_template
				gender_female_chance = root_faith_dominant_gender_adjusted_female_chance
				faith = faith:shinto
				culture = culture:japanese
				save_scope_as = monk
				after_creation = {
					add_character_flag = created
				}
			}
		}
		scope:monk = { assign_quirk_effect = yes }
	}

	option = { # Get an alliance out of this
		name = tgp_movement_events.0150.aa
		trigger = {
			has_trait = diplomat
			exists = scope:other_ruler
		}
		add_opinion = {
			target = scope:other_ruler
			modifier = event_negotiated_alliance_opinion
		}
		custom_tooltip = tgp_movement_events.0150.aa.alliance
		create_alliance = {
			target = scope:other_ruler
			allied_through_owner = root
			allied_through_target = scope:other_ruler
		}
		stress_impact = {
			humble = medium_stress_impact_loss
			greedy = medium_stress_impact_loss
			diligent = medium_stress_impact_gain
			ambitious = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
		}
	}

	option = { # Get Faith discount
		name = tgp_movement_events.0150.a
		custom_tooltip = cheaper_to_convert_to_monk_faith_tt
		set_variable = {
			name = discounted_faith_to_convert_to_var
			value = scope:monk.faith
		}
		add_courtier = scope:monk
		every_vassal = {
			limit = { has_vassal_stance = zealot }
			custom = every_zealot_vassal
			add_opinion = {
				target = root
				modifier = impious_opinion
				opinion = -20
			}
		}
		stress_impact = {
			humble = medium_stress_impact_loss
			zealous = major_stress_impact_gain
			cynical = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = humble
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = zealous
					has_trait = cynical
				}
				factor = 0
			}
		}
	}

	option = { # Try to convert them
		name = tgp_movement_events.0150.b
		duel = {
			skill = diplomacy
			target = scope:monk
			35 = {
			 	compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
				}
				desc = tgp_movement_events.0150.b.success
			 	send_interface_toast = {
				 	title = tgp_movement_events.0150.b.success
				 	left_icon = scope:monk
				 	scope:monk = { set_character_faith = root.faith }
					add_courtier = scope:monk
			 	}
		 	}
		 	65 = {
			 	compare_modifier = {
				 	value = scope:duel_value
				 	multiplier = -3.5
			 	}
				desc = tgp_movement_events.0150.b.failure
			 	send_interface_toast = {
				 	title = tgp_movement_events.0150.b.failure
				 	left_icon = scope:monk
				 	scope:monk = {
						add_opinion = {
							target = root
							modifier = disrespect_opinion
							opinion = -25
						}
					}
			 	}
		 	}
		}
		add_piety = medium_piety_gain
		stress_impact = {
			zealous = major_stress_impact_loss
			cynical = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = zealous
				factor = 2
			}
			modifier = {
				has_trait = cynical
				factor = 0
			}
		}
	}

	option = { # You're welcome here
		name = tgp_movement_events.0150.c
		add_courtier = scope:monk
		if = {
			limit = { has_lifestyle = diplomacy_lifestyle }
			add_diplomacy_lifestyle_xp = medium_lifestyle_xp
		}
		else = { add_prestige = medium_prestige_gain }
		if = {
			limit = { exists = scope:other_ruler }
			scope:other_ruler = {
				add_opinion = {
					target = root
					modifier = respect_opinion
					opinion = 15
				}
			}
		}
		stress_impact = {
			gregarious = medium_stress_impact_loss
			callous = medium_stress_impact_gain
			zealous = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = gregarious
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = callous
					has_trait = zealous
				}
				factor = 0
			}
		}
	}

	after = {
		scope:monk = {
			silent_disappearance_ai_if_created_effect = yes
		}
	}
}

# Ask a Movement Leader to abandon their Movement
scripted_trigger tgp_movement_events_0160_valid_rival = {
	this != root
	is_available_healthy_ai_adult = yes
	government_has_flag = government_is_celestial
	is_any_movement_leader = yes
	NOR = {
		top_participant_group:dynastic_cycle ?= root.top_participant_group:dynastic_cycle
		top_participant_group:dynastic_cycle ?= { participant_group_type = undecided_movement }
	}
	NOT = { has_trait = deceitful }
}

scripted_effect tgp_movement_events_0160_scheme_blocking_effect = {
	custom_tooltip = tgp_movement_events_0160_scheme_blocking_effect_tt
	set_variable = {
		name = no_scheming_allowed_var
		value = scope:rival
		years = 15
	}
	scope:rival = {
		set_variable = {
			name = no_scheming_allowed_var
			value = root
			years = 15
		}
	}
}

tgp_movement_events.0160 = {
	type = character_event
	title = tgp_movement_events.0160.t
	desc = tgp_movement_events.0160.desc
	left_portrait = {
		character = root
		animation = writing
	}
	lower_right_portrait = scope:rival
	theme = dynastic_cycle
	override_background = { reference = study }
	cooldown = { years = 10 }

	trigger = {
		NOT = { has_variable = no_scheming_allowed_var }
		is_available_adult = yes
		has_tgp_dlc_trigger = yes
		government_has_flag = government_is_celestial
		top_participant_group:dynastic_cycle ?= {
			NOT = { participant_group_type = undecided_movement }
		}
		any_ruler = { tgp_movement_events_0160_valid_rival = yes }
		OR = { # You are important enough
			is_any_movement_leader = yes
			influence_level >= 3
			merit_level >= 3
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			any_relation = { type = rival }
			add = 1
		}
	}

	immediate = {
		assign_quirk_effect = yes
		top_participant_group:dynastic_cycle ?= {
			save_scope_as = my_movement
		}
		random_ruler = {
			limit = { tgp_movement_events_0160_valid_rival = yes }
			weight = {
				base = 1
				modifier = {
					has_relation_nemesis = root
					add = 100
				}
				modifier = {
					has_relation_rival = root
					add = 100
				}
				modifier = {
					any_memory = {
						has_memory_category = negative
						any_memory_participant = { this = root }
					}
					add = 50
				}
				modifier = {
					has_trait = greedy
					add = 5
				}
			}
			save_scope_as = rival
			top_participant_group:dynastic_cycle = { save_scope_as = rival_movement }
		}
	}

	option = { # Try to convince them
		name = tgp_movement_events.0160.a
		duel = {
			skill = diplomacy
			target = scope:rival
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
				}
				modifier = {
					scope:rival = { has_trait = greedy }
					add = 25
				}
				modifier = {
					scope:rival = { gold <= medium_gold_value }
					add = 10
				}
				desc = tgp_movement_events.0100.a.success
				send_interface_toast = {
					title = tgp_movement_events.0100.a.success
					left_icon = scope:rival
					tgp_movement_events_0160_scheme_blocking_effect = yes
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
				}
				desc = tgp_movement_events.0100.a.failure
				send_interface_toast = {
					title = tgp_movement_events.0100.a.failure
					left_icon = scope:rival

				}
			}
		}
		stress_impact = {
			ambitious = medium_stress_impact_loss
			deceitful = major_stress_impact_gain
			honest = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = ambitious
					has_trait = deceitful
				}
				factor = 2
			}
			modifier = {
				has_trait = honest
				factor = 0
			}
		}
	}

	option = { # Pay them money lol
		name = tgp_movement_events.0160.b
		pay_short_term_gold = {
			target = scope:rival
			gold = medium_gold_value
		}
		tgp_movement_events_0160_scheme_blocking_effect = yes
		stress_impact = {
			honest = medium_stress_impact_loss
			deceitful = major_stress_impact_gain
			greedy = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = honest
				factor = 2
			}
			modifier = {
				OR = {
					gold <= major_gold_value
					has_trait = greedy
					has_trait = deceitful
				}
				factor = 0
			}
		}
	}

	option = { # I'm good
		name = tgp_movement_events.0160.c
		add_intrigue_lifestyle_xp = minor_lifestyle_xp
		stress_impact = {
			ambitious = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = ambitious
				factor = 0
			}
		}
	}
}
