
debug_change_opinion_interaction = {
	category = interaction_debug_main
	use_diplomatic_range = no
	ignores_pending_interaction_block = yes
	icon = debug_good

	is_shown = {
		debug_only = yes
		NOT = { scope:recipient = scope:actor }
	}

	send_option = {
		flag = love
		localization = debug_make_love_me_interaction
	}
	send_option = {
		flag = like
		localization = debug_make_like_me_interaction
	}
	send_option = {
		flag = dislike
		localization = debug_make_dislike_me_interaction
	}
	send_option = {
		flag = hate
		localization = debug_make_hate_me_interaction
	}
	on_accept = {
		scope:recipient = {
			switch = {
				trigger = yes
				scope:love = {
					add_opinion = {
						modifier = love_opinion
						target = scope:actor
						opinion = 200
					}
				}
				scope:like = {
					add_opinion = {
						modifier = friendliness_opinion
						target = scope:actor
						opinion = 100
					}
				}
				scope:dislike = {
					add_opinion = {
						modifier = angry_opinion
						target = scope:actor
						opinion = -100
					}
				}
				scope:hate = {
					add_opinion = {
						modifier = hate_opinion
						target = scope:actor
						opinion = -200
					}
				}
			}
		}
	}
	auto_accept = yes
}

make_lover_interaction = {
	category = interaction_debug_main

	use_diplomatic_range = no
	ignores_pending_interaction_block = yes

	is_shown = {
		debug_only = yes
		NOT = { scope:recipient = scope:actor }
		NOT = {
			scope:actor = {
				has_relation_lover = scope:recipient
			}
		}
		always = no # superseded by set_relation_interaction
	}

	auto_accept = yes

	on_accept = {
		scope:actor = {
			set_relation_lover = { reason = test_lover_desc target = scope:recipient }
		}
	}
}

make_soulmate_interaction = {
	category = interaction_debug_main

	use_diplomatic_range = no
	ignores_pending_interaction_block = yes

	is_shown = {
		debug_only = yes
		NOT = { scope:recipient = scope:actor }
		scope:actor = { has_relation_lover = scope:recipient }
		NOT = {
			scope:actor = {
				has_relation_soulmate = scope:recipient
			}
		}
		always = no # superseded by set_relation_interaction
	}

	auto_accept = yes

	on_accept = {
		scope:actor = {
			set_relation_soulmate = { reason = test_soulmate_desc copy_reason = lover target = scope:actor }
		}
	}
}

make_rival_interaction = {
	category = interaction_debug_main

	use_diplomatic_range = no
	ignores_pending_interaction_block = yes

	is_shown = {
		debug_only = yes
		NOT = { scope:recipient = scope:actor }
		NOT = {
			scope:actor = {
				any_relation = {
				type = rival
					this = scope:recipient
				}
			}
		}
		always = no # superseded by set_relation_interaction
	}

	auto_accept = yes

	on_accept = {
		scope:actor = {
			set_relation_rival = {
				target = scope:recipient
				reason = rival_debug
			}
		}
	}
}

make_nemesis_interaction = {
	category = interaction_debug_main

	use_diplomatic_range = no
	ignores_pending_interaction_block = yes

	is_shown = {
		debug_only = yes
		NOT = { scope:recipient = scope:actor }
		scope:actor = { has_relation_rival = scope:recipient }
		NOT = {
			scope:actor = {
				has_relation_nemesis = scope:recipient
			}
		}
		always = no # superseded by set_relation_interaction
	}

	auto_accept = yes

	on_accept = {
		scope:actor = {
			set_relation_nemesis = {
				reason = test_nemesis_desc
				copy_reason = rival
				target = scope:recipient
			}
		}
	}
}

remove_rival_interaction = {
	category = interaction_debug_main

	use_diplomatic_range = no
	ignores_pending_interaction_block = yes

	is_shown = {
		debug_only = yes
		NOT = { scope:recipient = scope:actor }
		scope:actor = {
			has_relation_rival = scope:recipient
		}
		always = no # superseded by set_relation_interaction
	}

	auto_accept = yes

	on_accept = {
		scope:actor = {
			remove_relation_rival = scope:recipient
		}
	}
}

make_friend_interaction = {
	category = interaction_debug_main

	use_diplomatic_range = no
	ignores_pending_interaction_block = yes

	is_shown = {
		debug_only = yes
		NOT = { scope:recipient = scope:actor }
		NOT = {
			scope:actor = {
				any_relation = {
				type = friend
					this = scope:recipient
				}
			}
		}
		always = no # superseded by set_relation_interaction
	}

	auto_accept = yes

	on_accept = {
		scope:actor = {
			set_relation_friend = { reason = test_friend_desc target = scope:recipient }
		}
	}
}


learn_secrets_interaction = {
	category = interaction_debug_main

	use_diplomatic_range = no
	ignores_pending_interaction_block = yes
	common_interaction = yes
	icon = icon_discovered_scheme
	interface_priority = -3

	is_shown = {
		debug_only = yes

		scope:recipient = {
			any_secret = {
				NOT = {
					is_known_by = scope:actor
				}
			}
		}
	}
	on_accept = {
		scope:recipient = {
			every_secret = {
				reveal_to = scope:actor
			}
		}
	}

	auto_accept = yes
}

make_dynasty_house_head_interaction = {
	category = interaction_debug_main
	use_diplomatic_range = no
	ignores_pending_interaction_block = yes

	icon = icon_dynasty

	is_shown = {
		debug_only = yes
		scope:recipient = {
			exists = scope:recipient.house
			NOT = { scope:recipient.house.house_head = scope:recipient }
		}
	}

	auto_accept = yes

	on_accept = {
		debug_log_scopes = yes
		scope:recipient.house = {
			set_house_head = scope:recipient
		}
	}
}

take_title_interaction = {
	category = interaction_debug_main
	use_diplomatic_range = no
	ignores_pending_interaction_block = yes

	target_type = title
	target_filter = recipient_domain_titles

	icon = debug_take_title

	is_shown = {
		debug_only = yes
		scope:recipient = { is_landed_or_landless_administrative = yes }
		NOT = { scope:recipient = scope:actor }
	}

	can_be_picked_title = {
		trigger_if = {
			limit = {
				scope:landless_title = yes
			}
			scope:target = {
				is_landless_type_title = yes
				is_noble_family_title = no
			}
		}
		trigger_else = {
			scope:target = { is_landless_type_title = no }
		}
	}

	send_option = {
		flag = title_only
		localization = take_title_interaction
	}
	send_option = {
		flag = title_and_vassals
		localization = take_title_and_vassals_interaction
	}
	send_option = {
		flag = landless_title
		localization = take_landless_title_interaction
	}

	auto_accept = yes

	on_accept = {
		create_title_and_vassal_change = {
			type = conquest
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:target = {
			switch = {
				trigger = yes
				scope:title_only = {
					change_title_holder = {
						holder = scope:actor
						change = scope:change
					}
				}
				scope:title_and_vassals = {
					change_title_holder_include_vassals = {
						holder = scope:actor
						change = scope:change
					}
				}
				scope:landless_title = {
					change_title_holder = {
						holder = scope:actor
						change = scope:change
					}
				}
			}
		}
		resolve_title_and_vassal_change = scope:change
	}
}

take_domain_interaction = {
	category = interaction_debug_main

	use_diplomatic_range = no
	ignores_pending_interaction_block = yes

	is_shown = {
		debug_only = yes
		scope:recipient = { is_landed_or_landless_administrative = yes }
		NOT = {
			scope:recipient = scope:actor
		}
		always = no
	}

	auto_accept = yes

	on_accept = {
		create_title_and_vassal_change = {
			type = conquest
			save_scope_as = change
		}
		scope:recipient = {
			every_held_title = {
				limit = {
					is_landless_type_title = no
				}
				change_title_holder_include_vassals = {
					holder = scope:actor
					change = scope:change
				}
			}
		}
		resolve_title_and_vassal_change = scope:change
	}
}

take_realm_interaction = {
	category = interaction_debug_main
	common_interaction = yes

	use_diplomatic_range = no
	ignores_pending_interaction_block = yes

	icon = grant_titles_interaction

	is_shown = {
		debug_only = yes
		scope:recipient = { is_landed_or_landless_administrative = yes }
		NOT = {
			scope:recipient = scope:actor
		}
	}

	auto_accept = yes

	send_option = {
		flag = domain
		localization = take_domain_interaction
	}
	send_option = {
		flag = realm
		localization = take_realm_interaction
	}
	send_option = {
		is_valid = {
			scope:actor.highest_held_title_tier < scope:recipient.liege.highest_held_title_tier
			scope:recipient = { is_independent_ruler = no }
		}
		flag = domain_as_vassal
		localization = take_domain_as_vassal_interaction
	}
	send_option = {
		is_valid = {
			scope:actor.highest_held_title_tier < scope:recipient.liege.highest_held_title_tier
			scope:recipient = { is_independent_ruler = no }
		}
		flag = realm_as_vassal
		localization = take_realm_as_vassal_interaction
	}

	on_accept = {
		scope:recipient.liege = { save_scope_as = new_liege }
		if = {
			limit = {
				OR = {
					scope:realm = yes
					scope:realm_as_vassal = yes
				}
			}
			create_title_and_vassal_change = {
				type = conquest
				save_scope_as = change
			}
			scope:recipient = {
				every_sub_realm_title = {
					limit = {
						tier >= tier_county
						is_noble_family_title = no
						is_landless_type_title = no
						NOT = { holder ?= scope:actor }
					}
					change_title_holder_include_vassals = {
						holder = scope:actor
						change = scope:change
						take_baronies = no
					}
				}
			}
			resolve_title_and_vassal_change = scope:change
		}
		else_if = {
			limit = {
				OR = {
					scope:domain = yes
					scope:domain_as_vassal = yes
				}
			}
			create_title_and_vassal_change = {
				type = conquest
				save_scope_as = change
			}
			scope:recipient = {
				every_held_title = {
					limit = {
						tier >= tier_county
						is_noble_family_title = no
						is_landless_type_title = no
					}
					change_title_holder_include_vassals = {
						holder = scope:actor
						change = scope:change
						take_baronies = no
					}
				}
			}
			resolve_title_and_vassal_change = scope:change
		}
		if = {
			limit = {
				OR = {
					scope:realm_as_vassal = yes
					scope:domain_as_vassal = yes
				}
			}
			create_title_and_vassal_change = {
				type = conquest
				save_scope_as = change
			}
			scope:actor = {
				change_liege = {
					liege = scope:new_liege
					change = scope:change
				}
			}
			resolve_title_and_vassal_change = scope:change
		}
	}
}

take_vassal_interaction = {
	category = interaction_debug_main
	use_diplomatic_range = no
	ignores_pending_interaction_block = yes

	icon = icon_liege

	is_shown = {
		debug_only = yes
		scope:recipient = {
			NOT = { is_vassal_of = scope:actor }
			highest_held_title_tier >= tier_county
			highest_held_title_tier < scope:actor.highest_held_title_tier
		}
		NOT = { scope:recipient = scope:actor }
		scope:actor = { has_any_landed_title_trigger = yes }
	}

	auto_accept = yes

	on_accept = {
		create_title_and_vassal_change = {
			type = conquest
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:recipient = {
			change_liege = {
				liege = scope:actor
				change = scope:change
			}
		}
		resolve_title_and_vassal_change = scope:change
	}
}

make_independent_interaction = {
	category = interaction_debug_main
	use_diplomatic_range = no
	ignores_pending_interaction_block = yes

	icon = independence

	is_shown = {
		debug_only = yes
		scope:recipient = {
			is_independent_ruler = no
			highest_held_title_tier >= tier_county
		}
	}

	auto_accept = yes

	on_accept = {
		create_title_and_vassal_change = {
			type = conquest
			save_scope_as = change
		}
		scope:recipient = {
			becomes_independent = { change = scope:change }
		}
		resolve_title_and_vassal_change = scope:change
	}
}

start_pregnancy_interaction = {
	category = interaction_debug_main

	use_diplomatic_range = no
	ignores_pending_interaction_block = yes
	icon = pregnant

	is_shown = {
		debug_only = yes
		scope:recipient = { is_adult = yes }
		scope:actor = { is_adult = yes }
		scope:recipient = { is_pregnant = no }
		scope:actor = { is_pregnant = no }

		OR = {
			AND = {
				scope:recipient = { is_female = yes }
				scope:actor = { is_male = yes }
			}
			AND = {
				scope:recipient = { is_male = yes }
				scope:actor = { is_female = yes }
			}
		}
	}

	on_accept = {
		scope:actor = { trigger_event = debug.0002 }
	}

	auto_accept = yes
}

get_claim_interaction = {
	category = interaction_debug_main
	use_diplomatic_range = no
	ignores_pending_interaction_block = yes
	icon = vassal_claim_liege_title_interaction

	target_type = title
	target_filter = recipient_domain_titles

	is_shown = {
		debug_only = yes
		scope:recipient = { is_landed_or_landless_administrative = yes }
		NOT = { scope:recipient = scope:actor }
	}

	can_be_picked_title = {
		scope:target = {
			is_noble_family_title = no
			is_landless_type_title = no
		}
		trigger_if = {
			limit = {
				scope:actor = { has_claim_on = scope:target }
			}
			scope:pressed = yes
			scope:actor = { has_weak_claim_on = scope:target }
		}
	}

	send_option = {
		flag = pressed
		localization = add_pressed_claim_interaction
	}
	send_option = {
		flag = unpressed
		localization = add_unpressed_claim_interaction
	}

	auto_accept = yes

	on_accept = {
		scope:actor = {
			switch = {
				trigger = yes
				scope:pressed = { add_pressed_claim = scope:target }
				scope:unpressed = { add_unpressed_claim = scope:target }
			}
		}
	}
}

claim_all_interaction = {
	category = interaction_debug_main
	use_diplomatic_range = no
	ignores_pending_interaction_block = yes
	icon = icon_claim_pressed

	is_shown = {
		debug_only = yes
		scope:recipient = { is_landed_or_landless_administrative = yes }
		NOT = { scope:recipient = scope:actor }
	}

	send_option = {
		flag = pressed
		localization = add_pressed_claim_interaction
	}
	send_option = {
		flag = unpressed
		localization = add_unpressed_claim_interaction
	}

	auto_accept = yes

	on_accept = {
		scope:recipient = {
			every_held_title = {
				limit = {
					is_landless_type_title = no
					is_noble_family_title = no
					trigger_if = {
						limit = {
							scope:actor = { has_claim_on = scope:target }
						}
						scope:pressed = yes
						scope:actor = { has_weak_claim_on = scope:target }
					}
					tier >= tier_county
				}
				save_temporary_scope_as = title_temp
				scope:actor = {
					switch = {
						trigger = yes
						scope:pressed = { add_pressed_claim = scope:title_temp }
						scope:unpressed = { add_unpressed_claim = scope:title_temp }
					}
				}
			}
		}
	}
}

get_claim_on_all_creatable_interaction = {
	category = interaction_debug_main
	icon = icon_claim_pressed

	use_diplomatic_range = no
	ignores_pending_interaction_block = yes

	is_shown = {
		debug_only = yes
		scope:recipient = scope:actor
	}

	auto_accept = yes

	on_accept = {
		scope:actor = {
			every_alert_creatable_title =
			{
				scope:actor = {
					add_pressed_claim = prev
				}
			}
		}
	}
}

test_dynasty_prestige_interaction = {
	category = interaction_debug_main

	use_diplomatic_range = no
	ignores_pending_interaction_block = yes

	is_shown = {
		debug_only = yes
		scope:recipient = scope:actor
		always = no
	}

	auto_accept = yes

	on_accept = {
		scope:actor.dynasty = {
			add_dynasty_prestige_level = 1
			add_dynasty_prestige = 1000
		}
	}
}

debug_start_era_of_great_holy_wars_interaction = {
	category = interaction_debug_main
	icon = religious

	use_diplomatic_range = no
	ignores_pending_interaction_block = yes
	interface_priority = -100

	is_shown = {
		debug_only = yes
	}

	send_option = {
		flag = crusade
		localization = debug_start_era_of_crusades_interaction
		is_valid = {
			NOT = { exists = faith:catholic.religion.var:variable_ghw_unlocked }
		}
	}
	send_option = {
		flag = jihad
		localization = debug_start_era_of_jihads_interaction
		is_valid = {
			NOT = { exists = faith:ashari.religion.var:variable_ghw_unlocked }
		}
	}

	send_option = {
		flag = ghw_natural
		localization = debug_launch_natural_crusade_interaction
		is_valid = {
			scope:recipient.faith = {
				NOR = {
					exists = great_holy_war
					exists = var:variable_ghw_cooldown
					exists = religion.var:variable_first_ghw_cooldown # Do not event spam after Crusades have been just unlocked.
				}
				exists = religion.var:variable_ghw_unlocked #Activated by event for every religion.
			}
		}
	}

	send_option = {
		flag = ghw
		localization = debug_start_great_holy_war_interaction
		is_valid = {
			NOT = { scope:recipient.faith = scope:actor.faith }
			scope:actor.faith = {
				NOR = {
					exists = great_holy_war
					exists = var:variable_ghw_cooldown
					exists = religion.var:variable_first_ghw_cooldown # Do not event spam after Crusades have been just unlocked.
				}
				exists = religion.var:variable_ghw_unlocked #Activated by event for every religion.
			}
		}
	}

	auto_accept = yes

	on_accept = {
		hidden_effect = {
			switch = {
				trigger = yes
				scope:crusade = {
					faith:catholic = { save_scope_as = awakening_faith }
				}
				scope:jihad = {
					faith:ashari = { save_scope_as = awakening_faith }
				}
				scope:ghw_natural = {
					hidden_effect = {
						scope:recipient.faith = {
							change_fervor = {
								value = 200
								desc = test_interaction_fervor_gain
							}
							trigger_event = great_holy_war.0001
						}
					}
				}
				scope:ghw = {
					scope:actor.faith = {
						start_great_holy_war = {
							target_character = scope:recipient
							target_title = scope:recipient.primary_title
							delay = 30
						}
					}
				}
			}
			scope:awakening_faith ?= {
				change_fervor = {
					value = 200
					desc = test_interaction_fervor_gain
				}
				if = {
					limit = { exists = religious_head }
					religious_head = { save_scope_as = ghw_first_sponsor }
				}
				else = {
					random_theocratic_ruler = {
						limit = { faith = root }
						save_scope_as = ghw_first_sponsor
					}
				}
				if = { # Fallback
					limit = {
						NOT = { exists = scope:ghw_first_sponsor }
					}
					random_ruler = {
						limit = { faith = root }
						save_scope_as = ghw_first_sponsor
					}
				}
				religion = {
					set_variable = {
						name = variable_ghw_unlocked # Crusades
						value = yes
					}
				}
				every_player = { trigger_event = great_holy_war.0011 } # Flavor fluff for various Faiths.
			}
		}
	}
}

debug_change_council_task_interaction = {
	category = interaction_debug_main

	use_diplomatic_range = no
	ignores_pending_interaction_block = yes

	is_valid_showing_failures_only = {
		scope:actor = {
			cp:councillor_spymaster = {
				NOT = { councillor_task_target = scope:recipient }
			}
		}
	}

	is_shown = {
		debug_only = yes
		exists = scope:actor.cp:councillor_spymaster.councillor_task_target
		always = no
	}

	auto_accept = yes

	on_accept = {
		scope:actor = {
			cp:councillor_spymaster = {
				set_council_task = {
					task_type = task_find_secrets
					target = scope:recipient
				}
			}
		}
	}
}

debug_trigger_localization_testing_interaction = {
	category = interaction_debug_main

	use_diplomatic_range = no
	ignores_pending_interaction_block = yes

	is_valid_showing_failures_only = {

	}

	is_valid = {
		scope:actor.father = scope:actor.father
		scope:actor.father.killer = scope:actor
		scope:actor.capital_county.holder = scope:actor
		scope:actor.capital_county.faith = scope:actor.faith
		scope:actor.faith.religion = faith:catholic.religion
		scope:actor.capital_county.kingdom = title:k_england
		scope:recipient.liege = scope:actor


	}

	is_shown = {
		always = no # This interaction has no purpose beyond debugging trigger localization. As such, it can be disabled unless somebody is actively working on that.
		debug_only = yes
	}

	auto_accept = yes

	on_accept = {
		add_gold = 100
	}
}

# DEBUG INTERACTION!
create_betrothal_interaction = {
	category = interaction_debug_main

	is_shown = {
		debug_only = yes
		scope:actor = {
			is_married = no
			is_betrothed = no
			allowed_to_marry_character_gender_trigger = { CHARACTER = scope:recipient }
			OR = {
				is_adult = no
				scope:recipient = { is_adult = no }
			}
			scope:recipient = {
				is_married = no
				is_betrothed = no
			}
		}
	}


	on_accept = {
		scope:actor = {
			create_betrothal = scope:recipient
		}
	}

	ai_accept = {
		base = 70
		modifier = {
			add = 100
			scope:recipient = {
				opinion = { target = scope:actor value >= 0 }
			}
		}
	}
}

set_relation_interaction = {
	category = interaction_debug_main
	use_diplomatic_range = no
	ignores_pending_interaction_block = yes

	is_shown = {
		debug_only = yes
		NOT = { scope:recipient = scope:actor }
		always = no # deprecated
	}

	on_accept = {
		scope:actor = { trigger_event = debug.350 }
	}

	auto_accept = yes
}

designate_diarch_interaction = {
	category = interaction_debug_main

	use_diplomatic_range = no
	ignores_pending_interaction_block = yes
	icon = icon_dismiss_entrenched_regency

	is_shown = {
		debug_only = yes
		NOT = {
			scope:actor = scope:recipient
		}
	}
	on_accept = {
		scope:actor = {
			designate_diarch = scope:recipient
		}
	}

	auto_accept = yes
}

start_diarchy_interaction = {
	icon = icon_entrench_regency
	category = interaction_debug_main

	use_diplomatic_range = no
	ignores_pending_interaction_block = yes

	is_shown = {
		debug_only = yes
		scope:recipient = {
			basic_eligible_for_diarchy_trigger = yes
			has_active_diarchy = no
		}
	}
	on_accept = {
		scope:recipient = { start_diarchy = regency }
	}

	auto_accept = yes
}

end_diarchy_interaction = {
	category = interaction_debug_main
	icon = "icon_dismiss_entrenched_regency"
	use_diplomatic_range = no
	ignores_pending_interaction_block = yes

	is_shown = {
		debug_only = yes
		scope:recipient = { has_active_diarchy = yes }
	}
	on_accept = {
		scope:recipient = { end_diarchy = yes }
	}

	auto_accept = yes
}

test_cooldown_category_10_days = {
	category = interaction_debug_main

	use_diplomatic_range = no
	ignores_pending_interaction_block = yes

	category_cooldown = { days = 10 }

	is_shown = {
		debug_only = yes
		always = no # Comment out this line to test
	}

	auto_accept = yes
	on_accept = {}
}


test_cooldown_category_against_30_days = {
	category = interaction_debug_main

	use_diplomatic_range = no
	ignores_pending_interaction_block = yes

	category_cooldown_against_recipient = { days = 30 }

	is_shown = {
		debug_only = yes
		always = no # Comment out this line to test
	}

	auto_accept = yes
	on_accept = {}
}

take_hostage_interaction = {
	category = interaction_debug_main
	icon = icon_hostage

	use_diplomatic_range = no
	ignores_pending_interaction_block = yes

	is_shown = {
		debug_only = yes
		NOT = {
			scope:actor = scope:recipient
		}
		scope:recipient = {
			is_ruler = no
			is_hostage = no
		}
	}

	on_accept = {
		scope:actor = {
			take_hostage = scope:recipient
		}
	}

	auto_accept = yes
}

release_hostage_interaction = {
	category = interaction_debug_main

	use_diplomatic_range = no
	ignores_pending_interaction_block = yes

	is_shown = {
		debug_only = yes
		NOT = {
			scope:actor = scope:recipient
		}
		scope:recipient = {
			is_hostage = yes
		}
	}

	on_accept = {
		scope:recipient = {
			return_hostage = yes
		}
	}

	auto_accept = yes
}
