#be aware that the actual granting of the title happens in code!
grant_titles_interaction = {

	category = interaction_category_vassal
	common_interaction = yes

	desc = grant_titles_interaction_desc

	special_interaction = grant_titles_interaction
	interface = grant_titles
	target_type = title
	target_filter = actor_domain_titles
	interface_priority = 60

	# actor character giving the titles
	# recipient character receiving the titles

	is_shown = {
		scope:actor != scope:recipient
		scope:actor = {
			NOT = {
				government_has_flag = government_is_landless_adventurer
			}
		}
		scope:recipient = {
			OR = {
				target_is_liege_or_above = scope:actor
				is_pool_guest_of = scope:actor
				AND = {
					scope:actor.faith.religious_head = scope:recipient
					top_liege = this
				}
			}
		}
		trigger_if = {
			limit = {
				scope:actor = { government_allows = administrative }
			}
			scope:recipient = { NOT = { government_allows = administrative } }
		}
		trigger_if = {
			limit = {
				scope:actor = { government_has_flag = government_is_nomadic NOT = { government_has_flag = government_allows_nomad_domicile_titles }}
			}
			scope:recipient = { NOT = { government_has_flag = government_is_true_herder } }
		}
	}

	is_valid_showing_failures_only = {
		scope:recipient = {
			custom_tooltip = {
				text = can_be_granted_titles_interaction_tt
				OR = {
					can_be_granted_titles_by = { RULER = scope:actor }
					can_be_granted_theocratic_titles_by = { RULER = scope:actor }
					AND = {
						is_diarch_of_target = scope:actor
						scope:actor = { has_diarchy_active_parameter = diarchy_is_co_rulership }
					}
				}
			}
			NOT = { is_at_war_with = scope:actor }
			NOT = { has_trait = devoted } # Monks are disinherited, and should not have land granted to them
			bp2_valid_for_standard_interactions_trigger = yes
			trigger_if = {
				limit = { is_ruler = no }
				is_imprisoned = no
			}
			# DON'T TAKE OTHER PLAYERS' ACCLAIMED KNIGHTS
			custom_description = {
				text = grant_title_stealing_acclaimed_knight
				subject = scope:recipient
				NOR = {
					AND = {
						is_acclaimed = yes
						liege ?= {
							is_ai = no
							this != scope:actor
						}
					}
					AND = {
						is_acclaimed = yes
						scope:actor = { is_ai = yes }
					}
				}
			}
			# Gallivanters won't accept additional responsibilities.
			NOT = { has_trait = gallivanter }
			# TGP JAPAN
			tgp_japan_grant_titles_restriction_trigger = {
				GRANTER = scope:actor
				GRANTEE = scope:recipient
			}
		}
		custom_description = {
			text = is_not_theocratic_court_chaplain
			subject = scope:recipient
			NAND = {
				scope:actor.faith = {
					has_doctrine = doctrine_theocracy_temporal
				}
				scope:recipient = {
					faith = {
						has_doctrine = doctrine_theocracy_temporal
					}
					has_council_position = councillor_court_chaplain
				}
				scope:actor.faith.religious_head != scope:recipient
			}
		}
		scope:actor = {
			any_held_title = {
				count > 1
			}
		}
	}

	can_send = {
		trigger_if = {
			limit = {
				scope:actor = {
					highest_held_title_tier >= tier_kingdom
					has_diarchy_active_parameter = primeminister_requires_duchy
					diarch = scope:recipient
				}
			}
			custom_tooltip = {
				text = primeminister_requires_duchy.tt.blocked_grant
				any_in_list = {
					list = target_titles
					tier >= tier_duchy
				}
			}
		}
	}

	can_be_picked_title = {
		scope:target = {
			is_leased_out = no

			trigger_if = {
				limit = { is_noble_family_title = yes }
				custom_tooltip = {
					text = GRANT_TITLES_ITEM_CANT_GIVE_NOBLE_FAMILY
					always = no
				}
			}

			trigger_if = {
				limit = {
					scope:actor = {
						NOT = {
							has_government = nomad_government
						}
					}
					title_province = {
						OR = {
							has_holding_type = nomad_holding
							has_holding_type = herder_holding
						}
					}
					scope:recipient = {
						is_ruler = no
					}
				}
				custom_tooltip = {
					text = GRANT_TITLES_ITEM_CANT_GIVE_NOMADIC_TITLES_TO_NON_NOMADS_TITLE
					always = no
				}
			}

			trigger_if = {
				limit = { is_nomad_title = yes }
				custom_tooltip = {
					text = GRANT_TITLES_ITEM_CANT_GIVE_NOMAD_TITLE
					always = no
				}
			}

			trigger_if = {
				limit = {
					is_head_of_faith = yes
					scope:recipient.faith.religious_head != scope:actor.faith.religious_head
				}
				custom_tooltip = {
					text = GRANT_TITLES_ITEM_CANT_HEAD_OF_FAITH_TO_INFIDEL
					scope:recipient.faith.religious_head = scope:actor.faith.religious_head
				}
			}

			trigger_if = {
				limit = {
					scope:recipient = scope:actor.player_heir
					scope:actor = { has_partition_succession_realm_law_trigger = yes }
				}
				custom_description = {
					text = partition_primary_heir_unfair
					subject = scope:recipient
					current_heir = scope:recipient
				}
			}
			trigger_if = {
				limit = { scope:target = title:k_fashion }
				NOT = { scope:target = title:k_fashion }
			}
			custom_tooltip = {
				text = cannot_grant_ceremonial_title
				NOT = { exists = var:ceremonial_title }
			}
		}

		custom_description = {
			text = grant_titles_interaction_can_only_give_diarch_de_jure_liege_to_diarch
			subject = scope:actor.diarch
			NAND = {
				# Only applies if we have an active diarchy.
				scope:actor = { has_active_diarchy = yes }
				# Now, prevent us from giving away our diarch's land to invalidate them...
				scope:target = {
					any_dejure_vassal_title_holder = { this = scope:actor.diarch }
					# ... _unless_ we're giving it _to_ the diarch.
					scope:recipient != scope:actor.diarch
					# Plus we only care if the title is below our tier.
					tier < scope:actor.highest_held_title_tier
				}
			}
		}

		custom_description = {
			text = grant_titles_interaction_children_not_allowed_temple
			subject = scope:recipient
			NOR = {
				AND = {
					scope:recipient = {
						is_adult = no
					}
					scope:target = {
						tier = tier_barony
						title_province = { has_building_with_flag = temple }
					}
				}
				AND = {
					scope:recipient = {
						is_adult = no
					}
					scope:target = {
						tier = tier_county

						title_province = {
							is_county_capital = yes
							has_building_with_flag = temple
						}
					}
				}
			}
		}

		custom_description = {
			text = grant_titles_interaction_title_being_wagered
			NOT = {
				scope:target = { has_variable = wagered_county }
			}
		}
	}

	auto_accept = yes

	on_auto_accept = {
		scope:recipient = {
			trigger_event = char_interaction.0110
		}
	}

	on_accept = {
		if = {
			limit = {
				scope:actor = {
					government_has_flag = government_is_nomadic
					vassal_limit_available <= 0
					is_independent_ruler = yes
					scope:recipient = {
						NOT = { is_vassal_of = scope:actor }
					}
				}
			}
			custom_tooltip = grant_title_nomad_and_at_vassal_limit
		}
		scope:recipient = {
			add_character_flag = {
				flag = domicile_culture_and_faith_check
				days = 1
			}
		}
		if = {
			limit = {
				scope:recipient = {
					is_acclaimed = yes
					liege = {
						this = scope:actor
					}
				}
				scope:target = {
					tier > tier_barony
				}
			}
			custom_tooltip = grant_title_landing_acclaimed_knight_warning
		}
		scope:recipient = {
			if = {
				limit = {
					top_liege = this
					save_temporary_scope_as = recipient_is_independent
				}
			}
			if = {
				limit = {
					NOT = {
						has_relation_friend = scope:actor
					}
				}
				if = {
					# then verify the right struggle phase
					limit = {
						is_diff_faith_or_culture_trigger = {
							CHAR = scope:actor
							STATUS = involved
						}
						any_character_struggle = {
							involvement = involved
							has_struggle_phase_parameter = struggle_grant_titles_diff_faith_culture_to_leads_to_friendship
						}
					}
					progress_towards_friend_effect = {
						REASON = friend_granted_title
						CHARACTER = scope:actor
						OPINION = 0
					}
				}
			}
		}

		if = {
			limit = {
				OR = {
					any_in_list = {
						list = target_titles
						tier = tier_county
						culture = scope:recipient.culture
						NOR = {
							culture = scope:actor.culture
							recent_history = {
								type = granted
								years = 10
							}
						}
					}
					any_in_list = {
						list = target_titles
						tier >= tier_duchy
						title_capital_county = {
							culture != scope:actor.culture
							culture = scope:recipient.culture
						}
						NOT = {
							recent_history = {
								type = granted
								years = 10
							}
						}
					}
				}
			}
			scope:recipient.culture = {
				change_cultural_acceptance = {
					target = scope:actor.culture
					value = grant_title_cultural_acceptance_impact
					desc = cultural_acceptance_gain_granted_title
				}
			}
		}
		if = {
			limit = {
				any_in_list = {
					list = target_titles
					tier = tier_county
				}
				scope:actor.culture = { has_cultural_parameter = grants_to_lowborns_bonuses }
				scope:recipient = {
					is_lowborn = yes
				}
			}
			every_in_list = {
				list = target_titles
				limit = { tier = tier_county }
				change_county_control = 30
			}
			scope:recipient = {
				add_trait = peasant_leader
			}
		}
		if = {
			limit = {
				any_in_list = {
					list = target_titles
					tier >= tier_county
				}
				scope:actor.culture = { has_cultural_parameter = landing_house_members_give_prestige }
				exists = scope:actor.house
				exists = scope:recipient.house
				scope:actor.house = scope:recipient.house
			}
			scope:actor = {
				add_prestige = {
					value = 0
					every_in_list = {
						list = target_titles
						limit = { tier = tier_empire }
						add = massive_prestige_gain
					}
					every_in_list = {
						list = target_titles
						limit = { tier = tier_kingdom }
						add = major_prestige_gain
					}
					every_in_list = {
						list = target_titles
						limit = { tier = tier_duchy }
						add = medium_prestige_gain
					}
					every_in_list = {
						list = target_titles
						limit = { tier = tier_county }
						add = minor_prestige_gain
					}
				}
			}
		}
		if = {
			limit = {
				any_in_list = {
					list = target_titles
					tier >= tier_county
				}
				scope:actor.culture = { has_cultural_parameter = landing_house_members_gives_renown }
				exists = scope:actor.house
				exists = scope:recipient.house
				scope:actor.house = scope:recipient.house
			}
			scope:actor.dynasty = {
				add_dynasty_prestige = {
					value = 0
					every_in_list = {
						list = target_titles
						limit = { tier = tier_empire }
						add = scope:actor.dynasty.massive_dynasty_prestige_gain
					}
					every_in_list = {
						list = target_titles
						limit = { tier = tier_kingdom }
						add = scope:actor.dynasty.major_dynasty_prestige_gain
					}
					every_in_list = {
						list = target_titles
						limit = { tier = tier_duchy }
						add = scope:actor.dynasty.medium_dynasty_prestige_gain
					}
					every_in_list = {
						list = target_titles
						limit = { tier = tier_county }
						add = scope:actor.dynasty.minor_dynasty_prestige_gain
					}
				}
			}
		}

		# Iterate over all given titles
		#  - Add opinion modifiers
		#  - Collect titles that discontent reduction can later be derived from
		every_in_list = {
			list = target_titles
			save_temporary_scope_as = this_title
			if = {
				limit = {
					exists = scope:landed_title
				}
				scope:recipient = {
					if = {
						limit = {
							scope:this_title.tier = tier_barony
						}

						hidden_effect = {
							add_opinion = {
								target = scope:actor
								modifier = received_title_barony
							}
						}

						scope:this_title = { add_to_temporary_list = titles_to_grant }
					}

					else_if = {
						limit = {
							scope:this_title.tier = tier_county
						}

						hidden_effect = {
							add_opinion = {
								target = scope:actor
								modifier = received_title_county
							}
							if = {
								limit = {
									is_lowborn = yes
								}
								scope:actor = {
									if = {
										limit = {
											is_ai = no
										}
										every_vassal = {
											vassal_stance = courtly
											add_opinion = {
												target = scope:actor
												modifier = courtly_lowborn_grant_opinion
												opinion = -5
											}
										}
									}
									else = { # Can't really stop the AI from landing lowborns, so throttle it a bit so that great conquerors don't annihilate their opinion
										random = {
											chance = 25
											every_vassal = {
												vassal_stance = courtly
												add_opinion = {
													target = scope:actor
													modifier = courtly_lowborn_grant_opinion
													opinion = -5
												}
											}
										}
									}
								}
							}
						}

						scope:this_title = { add_to_temporary_list = titles_to_grant }
					}

					else_if = {
						limit = {
							scope:this_title.tier = tier_duchy
						}

						hidden_effect = {
							add_opinion = {
								target = scope:actor
								modifier = received_title_duchy
							}
							if = {
								limit = {
									is_lowborn = yes
								}
								scope:actor = {
									every_vassal = {
										vassal_stance = courtly
										add_opinion = {
											target = scope:actor
											modifier = courtly_lowborn_grant_opinion
											opinion = -20
										}
									}
								}
							}
						}

						scope:this_title = { add_to_temporary_list = titles_to_grant }
					}

					else_if = {
						limit = {
							scope:this_title.tier = tier_kingdom
						}

						hidden_effect = {
							add_opinion = {
								target = scope:actor
								modifier = received_title_kingdom
							}
							if = {
								limit = {
									is_lowborn = yes
								}
								scope:actor = {
									every_vassal = {
										vassal_stance = courtly
										add_opinion = {
											target = scope:actor
											modifier = courtly_lowborn_grant_opinion
											opinion = -50
										}
									}
								}
							}
						}

						scope:this_title = { add_to_temporary_list = titles_to_grant }
					}

					else_if = {
						limit = {
							scope:this_title.tier = tier_empire
						}

						hidden_effect = {
							add_opinion = {
								target = scope:actor
								modifier = received_title_empire
							}
							if = {
								limit = {
									is_lowborn = yes
								}
								scope:actor = {
									every_vassal = {
										vassal_stance = courtly
										add_opinion = {
											target = scope:actor
											modifier = courtly_lowborn_grant_opinion
											opinion = -5
										}
									}
								}
							}
							if = {
								limit = {
									is_a_faction_member = yes
								}
								add_joined_faction_discontent = -60
							}
						}

						scope:this_title = { add_to_temporary_list = titles_to_grant }
					}
				}

				#Promised a vassal this title they had a claim on (vassal.2901)
				if = {
					limit = {
						scope:actor = {
							exists = var:was_promised_title
							var:was_promised_title = scope:recipient
						}
					}
					if = {
						limit = {
							scope:recipient = {
								exists = var:promised_title
							}
							scope:landed_title = scope:recipient.var:promised_title
						}
						scope:actor = {
							trigger_event = {
								id = vassal.2910
								days = { 7 14 }
							}
						}
					}
				}
			}
			if = {
				limit = {
					scope:recipient = {
						has_trait = bastard
					}
				}
				custom_tooltip = grant_title_to_bastard_dynasty_warning
			}
		} # every_in_list


		# The accumulated discontent reduction of the recipient
		scope:recipient = {
			if = {
				limit = {
					is_a_faction_member = yes
				}
				add_joined_faction_discontent = grant_title_opinion_sum_discontent_calc
			}
		}

		# Viziers may be booted from their job.
		scope:actor = {
			if = {
				limit = {
					# Assuming this is relevant at all.
					diarch ?= scope:recipient
					# And that scope:actor can do without a supervisor atm.
					can_leave_diarchy_trigger = yes
					# Aaaaand that their diarchy supports this type of thing.
					OR = {
						has_diarchy_parameter = primeminister_requires_county
						has_diarchy_parameter = primeminister_requires_duchy
					}
				}
				# Is this a duchy?
				if = {
					limit = {
						any_in_list = {
							list = target_titles
							tier >= tier_duchy
						}
					}
					custom_tooltip = grant_titles_interaction.tt.primeminister_title_grant.duchy_sufficient
					end_diarchy = yes
				}
				# Is this a county?
				else_if = {
					limit = {
						any_in_list = {
							list = target_titles
							tier = tier_county
						}
					}
					# Is that insufficient?
					if = {
						limit = { has_diarchy_active_parameter = primeminister_requires_duchy }
						custom_tooltip = grant_titles_interaction.tt.primeminister_title_grant.county_insufficient
					}
					# Is that sufficient?
					else = {
						custom_tooltip = grant_titles_interaction.tt.primeminister_title_grant.county_sufficient
						end_diarchy = yes
					}
				}
				# Is this a barony?
				else_if = {
					limit = {
						any_in_list = {
							list = target_titles
							count = all
							tier = tier_barony
						}
					}
					custom_tooltip = grant_titles_interaction.tt.primeminister_title_grant.barony_doesnt_end
				}
			}
		}

		if = {
			limit = {
				any_in_list = {
					list = target_titles
					tier = tier_empire
				}
			}
			custom_tooltip = grant_title_modifier_stack_empires
		}
		if = {
			limit = {
				any_in_list = {
					list = target_titles
					tier = tier_kingdom
				}
			}
			custom_tooltip = grant_title_modifier_stack_kingdoms
		}
		if = {
			limit = {
				any_in_list = {
					list = titles_to_grant
					tier = tier_duchy
				}
			}
			custom_tooltip = grant_title_modifier_stack_duchies
		}
		if = {
			limit = {
				any_in_list = {
					list = titles_to_grant
					tier = tier_county
				}
			}
			custom_tooltip = grant_title_modifier_stack_counties
		}
		if = {
			limit = {
				any_in_list = {
					list = titles_to_grant
					tier = tier_barony
				}
			}
			custom_tooltip = grant_title_modifier_stack_baronies
		}
		if = {
			limit = {
				trigger_if = {
					limit = { scope:actor = { is_ai = yes } }
					scope:actor = {
						any_vassal = {
							vassal_stance = courtly
						}
					}
				}
				scope:recipient = {
					is_lowborn = yes
				}
				any_in_list = {
					list = titles_to_grant
					tier >= tier_county
				}
			}
			custom_tooltip = grant_title_modifier_courtly_lowborn_grant_penalty
		}
		if = {
			limit = {
				scope:recipient = { is_a_faction_member = yes }
			}
			custom_tooltip = grant_title_modifier_stack_discontent
		}

		# Jealousy check
		if = {
			limit = {
				any_in_list = {
					list = titles_to_grant
					any_claimant = { grant_title_rivalry_trigger = yes }
				}
			}
			hidden_effect = {
				random = {
					chance = 25
					ordered_in_list = {
						list = titles_to_grant
						limit = {
							any_claimant = { grant_title_rivalry_trigger = yes }
						}
						order_by = tier
						save_scope_as = claim_title
						ordered_claimant = {
							limit = { grant_title_rivalry_trigger = yes }
							order_by = primary_title.tier
							save_scope_as = claim_vassal
							if = {
								limit = {
									scope:recipient = { is_lowborn = yes }
								}
								scope:recipient = { save_scope_as = lowborn_scope }
							}
							else_if = {
								limit = {
									scope:recipient = { has_claim_on = scope:claim_title }
								}
								scope:recipient = { save_scope_as = claimant_scope }
							}
							scope:actor = {
								trigger_event = {
									id = bp1_yearly.8070
									days = 5
								}
							}
						}
					}
				}
			}
		}

		#Stress impact
		scope:actor = {
			if = {
				limit = {
					any_in_list = {
						list = target_titles
						trigger_if = {
							limit = { tier = tier_barony }
							title_province.barony = {
								has_wrong_holding_type = no
							}
						}
						count >= 1
					}
				}

				# Generous characters enjoy giving away titles
				if = {
					limit = {
						has_trait = generous
					}
					add_stress = generous_title_grant_value
				}

				# Gnostics lose stress for giving away titles.
				if = {
					limit = {
						scope:actor = {
							faith = {
								has_doctrine_parameter = granting_titles_gives_stress
							}
						}
					}
					scope:actor = {
						add_stress = {
							value = 0

							# Base stress value scaled on title tier.
							every_in_list = {
								list = target_titles

								add = {
									value = 0

									if = {
										limit = { this.tier = tier_county }
										add = minor_stress_loss # 10 base
									}
									else_if = {
										limit = { this.tier = tier_duchy }
										add = {
											value = medium_stress_loss
											multiply = 1.25 # 25 base
										}
									}
									else_if = {
										limit = { this.tier = tier_kingdom }
										add = {
											value = major_stress_loss
											multiply = 2 # 80 base
										}
									}
									else_if = {
										limit = { this.tier = tier_empire }
										add = {
											value = monumental_stress_loss
											multiply = 2 # 200 base
										}
									}

									# Lose more stress for giving away titles of your primary tier; lose less stress for giving away titles far below your primary in tier.
									multiply = {
										value = this.tier
										add = 1
										divide = scope:actor.primary_title.tier
									}

									# Round to the nearest multiple of 5.
									divide = 5
									round = yes
									multiply = 5

									# For a Duke, this will be x1.25 for Duchies (-30) and x1 for Counties(-10)
									# For a King, this will be x1.25 for a Kingdom (-100), x1 for a Duchy (-25) and x0.75 for Counties(-10)
									# For an Emperor, this will be x1.25 for an Empire(-200), x1 for a Kingdom(-80), x0.75 for a Duchy(-20) and x0.4 for a Counties (-5)
								}
							}
						}
					}
				}

				# Greedy & ambitious ruler gain stress for giving away titles if they would normally be able to keep them.
				if = {
					limit = {
						# Pre-filter
						OR = {
							has_trait = greedy
							has_trait = ambitious
						}
						domain_size <= domain_limit # Not over my domain limit
						any_in_list = {
							list = target_titles
							tier <= tier_county # At least 1 selected title counts toward domain limit
						}

						# Special exemption for lieges who are over their held duchy limit, which are giving away that duchy (and associated counties) specifically
						trigger_if = {
							limit = {
								has_too_many_held_duchies_trigger = yes
							}
							NOT = {
								# Granting at least 1 duchy
								any_in_list = {
									list = target_titles
									title_counts_towards_too_many_duchies_trigger = yes
									save_temporary_scope_as = granted_duchy

									# All counties being granted are De Jure part of the duchy that is being granted
									any_in_list = {
										list = target_titles
										count = all
										trigger_if = {
											limit = { tier = tier_county}
											de_jure_liege = scope:granted_duchy
										}
									}
								}
							}
						}
					}
					# Actual stress gain effects
					if = {
						limit = {
							domain_size = domain_limit
						}
						stress_impact = {
							greedy = minor_stress_impact_gain
							ambitious = minor_stress_impact_gain
						}
					}
					else_if = {
						limit = {
							domain_size < domain_limit
						}
						stress_impact = {
							greedy = medium_stress_impact_gain
							ambitious = medium_stress_impact_gain
						}
					}
				}
			}

			# Maintenance for runestones
			if = {
				limit = {
					# Use expanded version if we have FP1.
					has_fp1_dlc_trigger = yes
					fp1_remove_stele_new_holder_trigger = {
						TITLE = scope:target
						PREVIOUS_HOLDER = scope:actor
						NEW_HOLDER = scope:recipient
					}
				}
				# Actually removed in fp1_other_decisions.0113
				custom_tooltip = runestone_grant_title_warning
			}
			else_if = {
				limit = {
					scope:target = {
						exists = var:ancestor_to_bury
						has_county_modifier = county_raised_runestone_modifier
					}
					NOT = { scope:recipient.dynasty = var:ancestor_to_bury.dynasty } #We only have to change something if the new holder is of a different dynasty
				}
				# Actually removed in religious_decision.0312
				custom_tooltip = runestone_grant_title_warning
			}

			if = {
				limit = {
					exists = scope:actor.dynasty
					scope:actor.dynasty = {
						has_dynasty_perk = ep1_culture_legacy_3
					}
					scope:recipient = {
						is_playable_character = no
						culture != scope:actor.culture
						any_in_list = {
							list = target_titles
							OR = {
								tier = tier_county
								tier = tier_barony
							}
							culture = scope:recipient.culture
						}
					}
				}
				scope:actor = {
					if = {
						limit = {
							can_add_hook = {
								target = scope:recipient
								type = favor_hook
							}
						}
						add_hook = {
							type = favor_hook
							target = scope:recipient
						}
					}
				}
			}

			#Feedback for actor
			hidden_effect = {
				if = {
					limit = {
						government_has_flag = government_is_nomadic
						vassal_limit_available <= 0
						is_independent_ruler = yes
						scope:recipient = {
							NOT = { is_vassal_of = scope:actor }
						}
					}
					send_interface_toast = {
						type = event_toast_effect_neutral
						title = grant_titles_interaction_notification

						left_icon = scope:actor
						right_icon = scope:recipient

						custom_tooltip = grant_titles_interaction_notification_effect_7
					}
				}
				else_if = {
					limit = {
						any_in_list = {
							list = target_titles
							count = 1
							NOT = { tier = scope:actor.highest_held_title_tier }
						}
						NOT = { exists = scope:recipient_is_independent }
						scope:recipient = {
							any_held_title = {
								title_tier > barony
								NOT = {
									is_in_list = target_titles
								}
							}
						}
					}
					random_in_list = {
						list = target_titles
						save_temporary_scope_as = loc_title
					}
					send_interface_toast = {
						type = event_toast_effect_neutral
						title = grant_titles_interaction_notification

						left_icon = scope:actor
						right_icon = scope:recipient

						custom_tooltip = grant_titles_interaction_notification_effect_2
						if = {
							limit = {
								exists = dynasty
								is_diff_faith_or_culture_trigger = {
									CHAR = scope:recipient
									STATUS = involved
								}
								any_character_struggle = {
									involvement = involved
									has_struggle_phase_parameter = struggle_grant_titles_diff_faith_culture_gives_prestige

								}
							}
							dynasty = {
								add_dynasty_prestige = minor_dynasty_prestige_gain
							}

						}
					}
				}
				else_if = {
					limit = {
						any_in_list = {
							list = target_titles
							count > 1
							NOT = { tier = scope:actor.highest_held_title_tier }
						}
						NOT = { exists = scope:recipient_is_independent }
						scope:recipient = {
							any_held_title = {
								title_tier > barony
								NOT = {
									is_in_list = target_titles
								}
							}
						}
					}
					random_in_list = {
						list = target_titles
						save_temporary_scope_as = loc_title
					}
					send_interface_toast = {
						type = event_toast_effect_neutral
						title = grant_titles_interaction_notification

						left_icon = scope:actor
						right_icon = scope:recipient

						custom_tooltip = grant_titles_interaction_notification_effect_3
					}
				}
				else_if = {
					limit = {
						exists = scope:recipient_is_independent
					}

					random_in_list = {
						list = target_titles
						save_temporary_scope_as = loc_title
					}
					send_interface_toast = {
						type = event_toast_effect_neutral
						title = grant_titles_interaction_notification

						left_icon = scope:actor
						right_icon = scope:recipient

						custom_tooltip = grant_titles_interaction_notification_effect_6
					}
				}
				else_if = {
					limit = {
						scope:recipient = {
							any_in_list = { #Became independent from you, but still have the same liege
								list = target_titles
								tier = scope:actor.highest_held_title_tier
							}
							top_liege = scope:actor.top_liege
						}
					}
					send_interface_toast = {
						type = event_toast_effect_neutral
						title = grant_titles_interaction_notification

						left_icon = scope:actor
						right_icon = scope:recipient

						custom_tooltip = grant_titles_interaction_notification_effect_5
					}
				}
				else_if = {
					limit = {
						scope:recipient = {
							any_in_list = { #Became independent
								list = target_titles
								tier = scope:actor.highest_held_title_tier
							}
						}
					}
					send_interface_toast = {
						type = event_toast_effect_neutral
						title = grant_titles_interaction_notification

						left_icon = scope:actor
						right_icon = scope:recipient

						custom_tooltip = grant_titles_interaction_notification_effect_4
					}
				}
				else = {
					send_interface_toast = {
						type = event_toast_effect_neutral
						title = grant_titles_interaction_notification

						left_icon = scope:actor
						right_icon = scope:recipient

						custom_tooltip = grant_titles_interaction_notification_effect
					}
				}
			}
		}

		hidden_effect = {
			# Struggle Catalyst
			if = {
				limit = {
					scope:actor = {
						is_diff_faith_or_culture_trigger = {
							CHAR = scope:recipient
							STATUS = involved
						}
						any_character_struggle = {
							involvement = involved
							activate_struggle_catalyst_secondary_character_involvement_involved_trigger = {
								CATALYST = catalyst_grant_privilege_to_diff_faith_culture_vassal
								CHAR = scope:recipient
							}
						}
					}
				}
				scope:actor = {
					every_character_struggle = {
						involvement = involved
						limit = {
							activate_struggle_catalyst_secondary_character_involvement_involved_trigger = {
								CATALYST = catalyst_grant_privilege_to_diff_faith_culture_vassal
								CHAR = scope:recipient
							}
						}
						activate_struggle_catalyst = {
							catalyst = catalyst_grant_privilege_to_diff_faith_culture_vassal
							character = scope:actor
						}
					}
				}
			}
		}

		# Achievements.
		scope:actor = {
			if = {
				limit = {
					has_variable_list = candidate_a_knights_tale_achievement
					is_target_in_variable_list = {
						name = candidate_a_knights_tale_achievement
						target = scope:recipient
					}
				}
				set_global_variable = {
					name = finished_a_knights_tale_achievement
					value = yes
				}
			}
		}
	}
}

#This interaction is referenced in code! If it's renamed you have to ping a coder
grant_title_to_new_random_character_interaction = {
	hidden = yes
	auto_accept = yes
	special_interaction = grant_titles_interaction
	use_diplomatic_range = no

	is_valid_showing_failures_only = {
		scope:actor = {
			this != scope:recipient
			any_held_title = {
				count > 1
			}
		}
	}
}

#be aware that the actual granting of the title happens in code!
grant_governorship_interaction = {
	icon = grant_governorship
	category = interaction_category_vassal
	common_interaction = yes

	desc = grant_governorship_interaction_desc

	special_interaction = grant_governorship_interaction
	interface = grant_titles
	target_type = title
	target_filter = actor_domain_titles
	interface_priority = 60

	# actor character giving the titles
	# recipient character receiving the titles

	is_shown = {
		scope:actor != scope:recipient
		scope:recipient = {
			OR = {
				target_is_liege_or_above = scope:actor
				is_pool_guest_of = scope:actor
			}
		}
		scope:actor = {
			government_allows = administrative
			highest_held_title_tier >= tier_county
		}

		trigger_if = {
			limit = {
				scope:actor = { is_ai = yes }
			}
			scope:recipient = {
				NOT = { any_parent = { is_ai = no } }
			}
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			custom_tooltip = {
				text = grant_governorship_interaction_no_title_tt
				any_held_title = {
					tier >= tier_county
					is_noble_family_title = no
					is_landless_type_title = no
					NOR = {
						this = scope:actor.capital_county
						this = scope:actor.primary_title
					}
				}
			}
		}
		scope:recipient = {
			is_adult = yes
			NOT = { is_at_war_with = scope:actor }
			bp2_valid_for_standard_interactions_trigger = yes
			trigger_if = {
				limit = { is_ruler = no }
				is_imprisoned = no
			}
			government_allows = administrative
			# Only the preferred gender can be appointed unless they hold titles already
			trigger_if = {
				limit = {
					scope:actor = {
						OR = {
							has_realm_law = male_only_law
							has_realm_law = male_preference_law
						}
					}
					is_landed = no
				}
				custom_tooltip = {
					text = recipient_cannot_be_appointed_gender_laws_tt
					is_female = no
				}
			}
			trigger_if = {
				limit = {
					scope:actor = {
						OR = {
							has_realm_law = female_only_law
							has_realm_law = female_preference_law
						}
					}
					is_landed = no
				}
				custom_tooltip = {
					text = recipient_cannot_be_appointed_gender_laws_tt
					is_female = yes
				}
			}
			# DON'T TAKE OTHER PLAYERS' ACCLAIMED KNIGHTS
			custom_description = {
				text = grant_title_stealing_acclaimed_knight
				subject = scope:recipient
				NOR = {
					AND = {
						is_acclaimed = yes
						liege ?= {
							is_ai = no
							this != scope:actor
						}
					}
					AND = {
						is_acclaimed = yes
						scope:actor = { is_ai = yes }
					}
				}
			}
			is_clergy = no
			# Gallivanters won't accept additional responsibilities.
			NOT = { has_trait = gallivanter }
			# TGP JAPAN
			tgp_japan_grant_titles_restriction_trigger = {
				GRANTER = scope:actor
				GRANTEE = scope:recipient
			}
			# Cannot be a minister
			custom_tooltip = {
				text = recipient_is_a_minister_desc
				tgp_is_any_minister = no
			}
		}
	}

	can_send = {
		scope:recipient = {
			custom_tooltip = {
				text = promote_candidate_interaction_existing_holder_tt
				this != scope:target.holder
			}

			trigger_if = { # Governors can only be appointed to certain titles
				limit = {
					is_governor = yes
					scope:target = { is_noble_family_title = no } # For tooltip reasons, so we don't show more than necessary
				}
				custom_tooltip = { # Only one province of highest rank
					text = only_one_province_of_highest_rank_tt
					NAND = {
						highest_held_title_tier = scope:target.tier
						scope:target.tier >= tier_duchy
						scope:target = { # We make an exception if recipient controls at least one de jure county
							any_de_jure_county = {
								count < 1
								OR = {
									holder = scope:recipient
									holder = { is_vassal_or_below_of = scope:recipient }
								}
							}
						}
					}
				}
				custom_tooltip = {
					text = admin_must_be_de_jure_or_neighboring
					any_held_title = {
						OR = {
							# The target title is part of your de jure structure
							is_de_jure_liege_or_above_target = scope:target
							target_is_de_jure_liege_or_above = scope:target
							# Or is a neighboring county which de jure duchy is not part of your realm
							AND = {
								NOT = { tier = tier_barony }
								any_title_to_title_neighboring_county = { this = scope:target }
								scope:target = {
									tier = tier_county
									duchy = {
										OR = {
											NOT = { exists = holder }
											holder = {
												NOR = {
													is_vassal_or_below_of = scope:actor
													this = scope:actor
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
			trigger_if = { # If recipient is landless and only have a family title, target title must be a duchy or above
				limit = {
					is_landless_ruler = yes
					any_held_title = { is_noble_family_title = yes }
					scope:target.tier < min_appointment_tier
				}
				primary_title.tier <= scope:target.tier
			}
			trigger_if = { # If recipient is a count, they can get only get counties within the same duchy
				limit = {
					highest_held_title_tier = tier_county
					main_administrative_tier > tier_county
					is_landed = yes
					scope:target.tier = tier_county
				}
				custom_tooltip = {
					text = admin_count_grant_only_counties
					any_held_title = { duchy = scope:target.duchy }
				}
			}
			tgp_is_ceremonial_liege_trigger = no
		}
	}

	can_be_picked_title = {
		scope:target = {
			is_leased_out = no

			scope:recipient = {
				trigger_if = { # Governors can only be appointed to certain titles
					limit = {
						is_governor = yes
						scope:target = { is_noble_family_title = no } # For tooltip reasons, so we don't show more than necessary
					}
					custom_tooltip = { # Only one province of highest rank
						text = only_one_province_of_highest_rank_tt
						NAND = {
							highest_held_title_tier = scope:target.tier
							scope:target.tier >= main_administrative_tier
							trigger_if = {
								limit = {
									scope:target.tier >= tier_duchy
								}
								scope:target = { # We make an exception if recipient controls at least one de jure county
									any_de_jure_county = {
										count < 1
										OR = {
											holder = scope:recipient
											holder = { is_vassal_or_below_of = scope:recipient }
										}
									}
								}
							}
						}
					}
					custom_tooltip = {
						text = admin_must_be_de_jure_or_neighboring
						any_held_title = {
							OR = {
								# The target title is part of your de jure structure
								is_de_jure_liege_or_above_target = scope:target
								target_is_de_jure_liege_or_above = scope:target
								# Or is a neighboring county which de jure duchy is not part of your realm
								AND = {
									any_title_to_title_neighboring_county = { this = scope:target }
									scope:target = {
										tier = tier_county
										duchy = {
											OR = {
												NOT = { exists = holder }
												holder = {
													NOR = {
														is_vassal_or_below_of = scope:actor
														this = scope:actor
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
				trigger_if = { # If recipient is landless and only have a family title, target title must be a duchy or above
					limit = {
						is_landless_ruler = yes
						any_held_title = { is_noble_family_title = yes }
						scope:target.tier < min_appointment_tier
					}
					primary_title.tier <= scope:target.tier
				}
				trigger_if = { # If recipient is a count, they can get only get counties within the same duchy
					limit = {
						highest_held_title_tier = tier_county
						main_administrative_tier > tier_county
						is_landed = yes
						scope:target.tier = tier_county
					}
					custom_tooltip = {
						text = admin_count_grant_only_counties
						any_held_title = { duchy = scope:target.duchy }
					}
				}
				tgp_is_ceremonial_liege_trigger = no
			}

			custom_tooltip = {
				text = GRANT_TITLES_ITEM_CANT_GIVE_ADMIN_PRIMARY
				this != scope:actor.capital_province.duchy
			}

			trigger_if = {
				limit = { is_noble_family_title = yes }
				custom_tooltip = {
					text = GRANT_TITLES_ITEM_CANT_GIVE_NOBLE_FAMILY
					always = no
				}
			}
			trigger_if = {
				limit = { exists = var:ceremonial_title }
				custom_tooltip = {
					text = GRANT_TITLES_ITEM_CANT_GIVE_CEREMONIAL_TITLE
					always = no
				}
			}

			trigger_if = {
				limit = {
					list_size:target_titles > 0
				}
				custom_tooltip = {
					text = GRANT_TITLES_ITEM_ADMIN_CANT_GIVE_MORE_THAN_ONE
					any_in_list = {
						list = target_titles
						scope:target ?= this
					}
				}
			}

			trigger_if = {
				limit = { scope:target = title:k_fashion }
				NOT = { scope:target = title:k_fashion }
			}
		}

		custom_description = {
			text = grant_titles_interaction_can_only_give_diarch_de_jure_liege_to_diarch
			subject = scope:actor.diarch
			NAND = {
				# Only applies if we have an active diarchy.
				scope:actor = { has_active_diarchy = yes }
				# Now, prevent us from giving away our diarch's land to invalidate them...
				scope:target = {
					any_dejure_vassal_title_holder = { this = scope:actor.diarch }
					# ... _unless_ we're giving it _to_ the diarch.
					scope:recipient != scope:actor.diarch
					# Plus we only care if the title is below our tier.
					tier < scope:actor.highest_held_title_tier
				}
			}
		}

		custom_description = {
			text = grant_titles_interaction_title_being_wagered
			NOT = {
				scope:target = { has_variable = wagered_county }
			}
		}
	}

	auto_accept = yes

	on_auto_accept = {
		scope:recipient = {
			trigger_event = {
				id = char_interaction.0111
				delayed = yes #this has to be delayed in case you grant it to someone that doesn't have an estate yet, for the change_government effect to work and generate the estate
			}
		}
	}

	on_accept = {
		if = {
			limit = {
				scope:recipient = {
					is_acclaimed = yes
					liege = {
						this = scope:actor
					}
				}
			}
			custom_tooltip = grant_title_landing_acclaimed_knight_warning
		}

		if = {
			limit = {
				any_in_list = {
					list = target_titles
					tier >= tier_duchy
					title_capital_county = {
						culture != scope:actor.culture
						culture = scope:recipient.culture
					}
					NOT = {
						recent_history = {
							type = granted
							years = 10
						}
					}
				}
			}
			scope:recipient.culture = {
				change_cultural_acceptance = {
					target = scope:actor.culture
					value = grant_title_cultural_acceptance_impact
					desc = cultural_acceptance_gain_granted_title
				}
			}
		}
		if = {
			limit = {
				any_in_list = {
					list = target_titles
					tier >= tier_county
				}
				scope:actor.culture = { has_cultural_parameter = landing_house_members_give_prestige }
				exists = scope:actor.house
				exists = scope:recipient.house
				scope:actor.house = scope:recipient.house
			}
			scope:actor = {
				add_prestige = {
					value = 0
					every_in_list = {
						list = target_titles
						limit = { tier = tier_empire }
						add = massive_prestige_gain
					}
					every_in_list = {
						list = target_titles
						limit = { tier = tier_kingdom }
						add = major_prestige_gain
					}
					every_in_list = {
						list = target_titles
						limit = { tier = tier_duchy }
						add = medium_prestige_gain
					}
				}
			}
		}
		if = {
			limit = {
				any_in_list = {
					list = target_titles
					tier >= tier_county
				}
				scope:actor.culture = { has_cultural_parameter = landing_house_members_gives_renown }
				exists = scope:actor.house
				exists = scope:recipient.house
				scope:actor.house = scope:recipient.house
			}
			scope:actor.dynasty = {
				add_dynasty_prestige = {
					value = 0
					every_in_list = {
						list = target_titles
						limit = { tier = tier_kingdom }
						add = scope:actor.dynasty.major_dynasty_prestige_gain
					}
					every_in_list = {
						list = target_titles
						limit = { tier = tier_duchy }
						add = scope:actor.dynasty.medium_dynasty_prestige_gain
					}
				}
			}
		}

		# Iterate over all given titles
		#  - Add opinion modifiers
		#  - Collect titles that discontent reduction can later be derived from
		every_in_list = {
			list = target_titles
			save_temporary_scope_as = this_title
			if = {
				limit = {
					exists = scope:landed_title
				}
				scope:recipient = {
					# Add opinion based on title tier
					if = {
						limit = {
							scope:this_title.tier = tier_county
							scope:actor = { min_appointment_tier = tier_county }
						}

						hidden_effect = {
							add_opinion = {
								target = scope:actor
								modifier = received_title_county
							}
						}

						scope:this_title = { add_to_temporary_list = titles_to_grant }
					}
					
					else_if = {
						limit = {
							scope:this_title.tier = tier_duchy
						}

						hidden_effect = {
							add_opinion = {
								target = scope:actor
								modifier = received_title_duchy
							}
							if = {
								limit = {
									is_lowborn = yes
								}
								scope:actor = {
									every_vassal = {
										vassal_stance = courtly
										add_opinion = {
											target = scope:actor
											modifier = courtly_lowborn_grant_opinion
											opinion = -10	#less than usual because admin realms are more tolerant of bureaucratic "new" nobility
										}
									}
								}
							}
						}

						scope:this_title = { add_to_temporary_list = titles_to_grant }
					}

					else_if = {
						limit = {
							scope:this_title.tier = tier_kingdom
						}

						hidden_effect = {
							add_opinion = {
								target = scope:actor
								modifier = received_title_kingdom
							}
							if = {
								limit = {
									is_lowborn = yes
								}
								scope:actor = {
									every_vassal = {
										vassal_stance = courtly
										add_opinion = {
											target = scope:actor
											modifier = courtly_lowborn_grant_opinion
											opinion = -30	#less than usual because admin realms are more tolerant of bureaucratic "new" nobility
										}
									}
								}
							}
						}

						scope:this_title = { add_to_temporary_list = titles_to_grant }
					}

					else_if = {
						limit = {
							scope:this_title.tier = tier_empire
						}

						hidden_effect = {
							add_opinion = {
								target = scope:actor
								modifier = received_title_empire
							}
							if = {
								limit = {
									is_lowborn = yes
								}
								scope:actor = {
									every_vassal = {
										vassal_stance = courtly
										add_opinion = {
											target = scope:actor
											modifier = courtly_lowborn_grant_opinion
											opinion = -30	#less than usual because admin realms are more tolerant of bureaucratic "new" nobility
										}
									}
								}
							}
						}

						scope:this_title = { add_to_temporary_list = titles_to_grant }
					}
				}

				#Promised a vassal this title they had a claim on (vassal.2901)
				if = {
					limit = {
						scope:actor = {
							exists = var:was_promised_title
							var:was_promised_title = scope:recipient
						}
					}
					if = {
						limit = {
							scope:recipient = {
								exists = var:promised_title
							}
							scope:landed_title = scope:recipient.var:promised_title
						}
						scope:actor = {
							trigger_event = {
								id = vassal.2910
								days = { 7 14 }
							}
						}
					}
				}
			}
			if = {
				limit = {
					scope:recipient = {
						has_trait = bastard
					}
				}
				custom_tooltip = grant_title_to_bastard_dynasty_warning
			}
		} # every_in_list

		# The accumulated discontent reduction of the recipient
		scope:recipient = {
			if = {
				limit = {
					is_a_faction_member = yes
				}
				add_joined_faction_discontent = grant_title_opinion_sum_discontent_calc
			}
		}

		# Show stacked opinion gain
		if = {
			limit = {
				any_in_list = {
					list = target_titles
					tier = tier_empire
				}
			}
			custom_tooltip = grant_title_modifier_stack_empires
		}
		if = {
			limit = {
				any_in_list = {
					list = target_titles
					tier = tier_kingdom
				}
			}
			custom_tooltip = grant_title_modifier_stack_kingdoms
		}
		if = {
			limit = {
				any_in_list = {
					list = titles_to_grant
					tier = tier_duchy
				}
			}
			custom_tooltip = grant_title_modifier_stack_duchies
		}
		if = {
			limit = {
				any_in_list = {
					list = titles_to_grant
					tier = tier_county
					scope:actor = { min_appointment_tier = tier_county }
				}
			}
			custom_tooltip = grant_title_modifier_stack_counties
		}
		
		if = {
			limit = {
				trigger_if = {
					limit = { scope:actor = { is_ai = yes } }
					scope:actor = {
						any_vassal = {
							vassal_stance = courtly
						}
					}
				}
				scope:recipient = {
					is_lowborn = yes
				}
				any_in_list = {
					list = titles_to_grant
					tier >= tier_county
				}
			}
			custom_tooltip = grant_title_modifier_courtly_lowborn_grant_penalty
		}
		if = {
			limit = {
				scope:recipient = { is_a_faction_member = yes }
			}
			custom_tooltip = grant_title_modifier_stack_discontent
		}

		# Jealousy check
		if = {
			limit = {
				any_in_list = {
					list = titles_to_grant
					any_claimant = { grant_title_rivalry_trigger = yes }
				}
			}
			hidden_effect = {
				random = {
					chance = 25
					ordered_in_list = {
						list = titles_to_grant
						limit = {
							any_claimant = { grant_title_rivalry_trigger = yes }
						}
						order_by = tier
						save_scope_as = claim_title
						ordered_claimant = {
							limit = { grant_title_rivalry_trigger = yes }
							order_by = primary_title.tier
							save_scope_as = claim_vassal
							if = {
								limit = {
									scope:recipient = { is_lowborn = yes }
								}
								scope:recipient = { save_scope_as = lowborn_scope }
							}
							else_if = {
								limit = {
									scope:recipient = { has_claim_on = scope:claim_title }
								}
								scope:recipient = { save_scope_as = claimant_scope }
							}
							scope:actor = {
								trigger_event = {
									id = bp1_yearly.8070
									days = 5
								}
							}
						}
					}
				}
			}
		}

		scope:actor = {
			# Maintenance for runestones
			if = {
				limit = {
					# Use expanded version if we have FP1.
					has_fp1_dlc_trigger = yes
					fp1_remove_stele_new_holder_trigger = {
						TITLE = scope:target
						PREVIOUS_HOLDER = scope:actor
						NEW_HOLDER = scope:recipient
					}
				}
				# Actually removed in fp1_other_decisions.0113
				custom_tooltip = runestone_grant_title_warning
			}
			else_if = {
				limit = {
					scope:target = {
						exists = var:ancestor_to_bury
						has_county_modifier = county_raised_runestone_modifier
					}
					NOT = { scope:recipient.dynasty = var:ancestor_to_bury.dynasty } #We only have to change something if the new holder is of a different dynasty
				}
				# Actually removed in religious_decision.0312
				custom_tooltip = runestone_grant_title_warning
			}

			if = {
				limit = {
					dynasty ?= { has_dynasty_perk = ep1_culture_legacy_3 }
					scope:recipient = {
						is_playable_character = no
						culture != scope:actor.culture
						any_in_list = {
							list = target_titles
							OR = {
								tier = tier_county
								tier = tier_barony
							}
							culture = scope:recipient.culture
						}
					}
				}
				if = {
					limit = {
						can_add_hook = {
							target = scope:recipient
							type = favor_hook
						}
					}
					add_hook = {
						type = favor_hook
						target = scope:recipient
					}
				}
			}

			#Feedback for actor
			hidden_effect = {
				if = {
					limit = {
						NOT = { exists = scope:recipient_is_independent }
						scope:recipient = {
							any_held_title = {
								title_tier > barony
								NOT = { is_in_list = target_titles }
							}
						}
					}
					set_variable = {
						name = lower_count
						value = {
							value = -1
							every_in_list = {
								list = target_titles
								limit = {
									NOT = { tier = scope:actor.highest_held_title_tier }
								}
								add = 1
							}
						}
					}
					save_scope_value_as = {
						name = equal_count
						value = {
							value = 0
							every_in_list = {
								list = target_titles
								limit = { tier = scope:actor.highest_held_title_tier }
								add = 1
							}
						}
					}
					ordered_in_list = {
						list = target_titles
						order_by = tier
						save_temporary_scope_as = loc_title
					}
					send_interface_toast = {
						type = event_toast_effect_neutral
						title = grant_governorship_interaction_notification
						left_icon = scope:recipient
						right_icon = scope:loc_title
						if = {
							limit = { scope:actor.var:lower_count ?= 0 }
							custom_tooltip = grant_governorship_interaction_notification_effect_2
						}
						else_if = {
							limit = {
								exists = scope:actor.var:lower_count
								scope:actor.var:lower_count > 1
							}
							custom_tooltip = grant_governorship_interaction_notification_effect_3
						}
						else_if = {
							limit = { scope:actor.var:lower_count ?= 1 }
							custom_tooltip = grant_governorship_interaction_notification_effect_4
						}
						else_if = {
							limit = {
								scope:equal_count >= 1
								scope:recipient.top_liege ?= scope:actor.top_liege
							}
							custom_tooltip = grant_titles_interaction_notification_effect_5
						}
						else = { custom_tooltip = grant_titles_interaction_notification_effect }
						if = {
							limit = {
								exists = dynasty
								is_diff_faith_or_culture_trigger = {
									CHAR = scope:recipient
									STATUS = involved
								}
								any_character_struggle = {
									involvement = involved
									has_struggle_phase_parameter = struggle_grant_titles_diff_faith_culture_gives_prestige
								}
							}
							dynasty = { add_dynasty_prestige = minor_dynasty_prestige_gain }
						}
						remove_variable = lower_count
					}
				}
			}
		}

		hidden_effect = {
			# Struggle Catalyst
			if = {
				limit = {
					scope:actor = {
						is_diff_faith_or_culture_trigger = {
							CHAR = scope:recipient
							STATUS = involved
						}
						any_character_struggle = {
							involvement = involved
							activate_struggle_catalyst_secondary_character_involvement_involved_trigger = {
								CATALYST = catalyst_grant_privilege_to_diff_faith_culture_vassal
								CHAR = scope:recipient
							}
						}
					}
				}
				scope:actor = {
					every_character_struggle = {
						involvement = involved
						limit = {
							activate_struggle_catalyst_secondary_character_involvement_involved_trigger = {
								CATALYST = catalyst_grant_privilege_to_diff_faith_culture_vassal
								CHAR = scope:recipient
							}
						}
						activate_struggle_catalyst = {
							catalyst = catalyst_grant_privilege_to_diff_faith_culture_vassal
							character = scope:actor
						}
					}
				}
			}
		}

		# Achievements.
		scope:actor = {
			if = {
				limit = {
					has_variable_list = candidate_a_knights_tale_achievement
					is_target_in_variable_list = {
						name = candidate_a_knights_tale_achievement
						target = scope:recipient
					}
				}
				set_global_variable = {
					name = finished_a_knights_tale_achievement
					value = yes
				}
			}
		}
		# TGP Catalyst - triggered in on_title_gain
		if = {
			limit = {
				title:h_china.holder ?= scope:actor
				any_in_list = {
					list = target_titles
					OR = {
						AND = {
							tier = tier_empire
							scope:recipient.merit_level < 7
						}
						AND = {
							tier = tier_kingdom
							scope:recipient.merit_level < 5
						}
						AND = {
							tier = tier_duchy
							scope:recipient.merit_level < 3
						}
						AND = {
							tier = tier_county
							scope:recipient.merit_level < 1
						}
					}
				}
			}
			show_as_tooltip = {
				situation:dynastic_cycle ?= {
					if = {
						limit = {
							situation_top_has_catalyst = catalyst_hegemon_appointing_low_merit_governor
							title:h_china.holder = scope:actor
						}
						trigger_situation_catalyst = {
							catalyst = catalyst_hegemon_appointing_low_merit_governor
							character =  scope:recipient
						}
					}
				}
			}
		}
	}
}
