#Interactions relating to factions

force_join_faction_interaction = {
	category = interaction_category_vassal
	special_interaction = force_join_faction
	desc = force_join_faction_interaction_desc
	icon = scroll_scales

	force_notification = yes
	greeting = positive
	notification_text = FORCE_JOIN_FACTION_NOTIFICATION

	is_shown = {
		scope:actor = {
			is_a_faction_member = yes
			liege = scope:recipient.liege
			NOR = {
				joined_faction = scope:recipient.joined_faction
				scope:recipient = scope:actor.liege
			}
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			trigger_if = {
				limit = { has_government = administrative_government }
				custom_tooltip = {
					text = force_join_faction_admin_requirement_desc
					OR = {
						has_strong_usable_hook = scope:recipient
						AND = {
							influence >= { value = scope:actor.monumental_influence_value multiply = 2 }
							scope:recipient ?= {
								NOT = { opinion = { target = scope:actor value <= -50 } }
								NOT = { opinion = { target = scope:recipient.liege value >= 50 } }
							}
						}
					}
				}
			}
			trigger_else = {
				has_strong_usable_hook = scope:recipient # Make sure to update the NFaction::POTENTIAL_FORCE_JOIN_HOOK_TYPE define if you change the type of hook used here
			}
			NOT = { is_at_war_with = scope:recipient }
		}
		scope:recipient = {
			trigger_if = {
				limit = { is_a_faction_member = yes }
				joined_faction.faction_leader = { is_ai = yes }
			}
			is_forced_into_faction = no	
			can_join_faction = scope:actor.joined_faction	
		}
		custom_description = {
			text = barons_joining_independence_factions
			NAND = {
				scope:actor.joined_faction = { faction_is_type = independence_faction }
				scope:recipient.highest_held_title_tier = tier_barony
			}
		}
	}
	
	on_accept = {
		scope:actor = {
			send_interface_message = {
				type = event_faction_neutral
				title = force_join_faction_interaction_notification
				right_icon = scope:recipient
				if = {
					limit = { scope:hook = yes }
					use_hook = scope:recipient
				}
				else_if = {
					limit = { scope:influence = yes }
					change_influence = {
						value = monumental_influence_value
						multiply = -2
					}
				}
				scope:recipient = {
					join_faction_forced = {
						faction = scope:actor.joined_faction
						forced_by = scope:actor
						years = 10
					}
				}
			}
		}

		# If we're a clan this interaction affects unity
		add_clan_unity_interaction_effect = {
			CHARACTER = scope:actor
			TARGET = scope:recipient
			VALUE = medium_unity_loss
			DESC = clan_unity_forced_faction_joinage.desc
			REVERSE_NON_HOUSE_TARGET = no
		}
	}

	auto_accept = yes

	#Use hook
	send_option = {
		is_valid = {
			exists = scope:recipient
			scope:actor ?= { has_strong_usable_hook = scope:recipient }
		}
		flag = hook	
		localization = GENERIC_SPEND_A_HOOK
	}

	#Spend influence
	send_option = {
		is_shown = {
			scope:actor = { has_government = administrative_government }
			scope:actor.top_liege ?= { has_government = administrative_government }
		}
		is_valid = { # Convincing someone with influence is not available if they hate you or love the liege
			scope:actor ?= { influence >= { value = scope:actor.monumental_influence_value multiply = 2 } }
			scope:recipient ?= {
				NOT = { opinion = { target = scope:actor value <= -50 } }
				NOT = { opinion = { target = scope:recipient.liege value >= 50 } }
			}
		}
		flag = influence	
		localization = SPEND_INFLUENCE
	}

	send_options_exclusive = yes
	
	# AI
	ai_targets = {
		ai_recipients = peer_vassals
	}
	ai_frequency = 12
	
	ai_potential = {
		is_independent_ruler = no
		is_a_faction_member = yes
		
		# Only force others to join a faction if you joined by your own free will
		is_forced_into_faction = no
	}
	
	ai_will_do = {
		base = 100
		
		# Don't steal players' factions' members
		modifier = {
			factor = 0
			scope:recipient = {
				is_a_faction_member = yes
				joined_faction = {
					faction_leader = {
						is_ai = no
					}
				}
			}
		}
	}
}
