﻿fabricate_hook_interaction = {
	icon = icon_scheme_fabricate_hook
	category = interaction_category_hostile

	auto_accept = yes
	ignores_pending_interaction_block = yes

	scheme = fabricate_hook

	desc = dlm_forge_hook_interaction_desc
	
	is_shown = {
		scope:actor = {
			OR = {
				has_perk = truth_is_relative_perk
				dlm_has_criminal_network_landmark = yes
				AND = {
					has_trait = vengeful
					has_relation_rival = scope:recipient
				}
				AND = {
					any_character_struggle = {
						involvement = involved
						has_struggle_phase_parameter = unlocks_fabricate_hooks_for_all
						is_secondary_character_involvement_either_trigger = {
							CHAR = scope:recipient
						}
					}
				}
				AND = {
					government_has_flag = government_is_clan
					is_in_same_clan_as_trigger = { CHARACTER = scope:recipient }
					house = { has_house_unity_stage = competitive }	
				}	
			}
		}
		scope:recipient != scope:actor
	}

	is_valid = {
		NOT = { scope:actor = { has_hook = scope:recipient } }
		OR = {
			scope:actor = {
				OR = {
					has_perk = truth_is_relative_perk
					dlm_has_criminal_network_landmark = yes
					AND = {
						has_trait = vengeful
						has_relation_rival = scope:recipient
					}
					AND = {
						any_character_struggle = {
							involvement = involved
							has_struggle_phase_parameter = unlocks_fabricate_hooks_for_all
							is_secondary_character_involvement_either_trigger = {
								CHAR = scope:recipient
							}
						}
					}
					AND = {
						government_has_flag = government_is_clan
						is_in_same_clan_as_trigger = { CHARACTER = scope:recipient }
						house = { has_house_unity_stage = competitive }	
					}	
				}
			}
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			is_physically_able_adult = yes
			can_start_scheme = {
				target_character = scope:recipient
				type = fabricate_hook
			}
		}
	}

	options_heading = schemes.t.agent_packages
	send_options_exclusive = yes
	send_option = {
		flag = agent_focus_balance
		current_description = fabricate_hook_interaction.tt.agent_focus_balance
	}
	send_option = {
		flag = agent_focus_success
		current_description = fabricate_hook_interaction.tt.agent_focus_success
	}
	send_option = {
		flag = agent_focus_speed
		current_description = fabricate_hook_interaction.tt.agent_focus_speed
	}
	send_option = {
		flag = agent_focus_secrecy
		current_description = fabricate_hook_interaction.tt.agent_focus_secrecy
	}

	on_accept = {
		scope:actor = {
			stress_impact = {
				just = medium_stress_impact_gain
				honest = medium_stress_impact_gain
				compassionate = minor_stress_impact_gain
			}
			send_interface_toast = {
				type = event_toast_effect_good
				title = fabricate_hook_interaction_toast
				left_icon = scope:actor
				right_icon = scope:recipient

				if = {
					limit = { scope:agent_focus_success ?= yes }
					begin_scheme_with_agents_effect = {
						SCHEME_TYPE = fabricate_hook
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:recipient
						AGENT_1 = agent_outcast
						AGENT_2 = agent_diplomat
						AGENT_3 = agent_thief
						AGENT_4 = agent_infiltrator
						AGENT_5 = agent_lookout
					}
				}
				else_if = {
					limit = { scope:agent_focus_speed ?= yes }
					begin_scheme_with_agents_effect = {
						SCHEME_TYPE = fabricate_hook
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:recipient
						AGENT_1 = agent_infiltrator
						AGENT_2 = agent_footpad
						AGENT_3 = agent_socialite
						AGENT_4 = agent_outcast
						AGENT_5 = agent_lookout
					}
				}
				else_if = {
					limit = { scope:agent_focus_secrecy ?= yes }
					begin_scheme_with_agents_effect = {
						SCHEME_TYPE = fabricate_hook
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:recipient
						AGENT_1 = agent_lookout
						AGENT_2 = agent_decoy
						AGENT_3 = agent_justiciar
						AGENT_4 = agent_outcast
						AGENT_5 = agent_footpad
					}
				}
				else = {
					begin_scheme_with_agents_effect = {
						SCHEME_TYPE = fabricate_hook
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:recipient
						AGENT_1 = agent_outcast
						AGENT_2 = agent_thief
						AGENT_3 = agent_infiltrator
						AGENT_4 = agent_footpad
						AGENT_5 = agent_lookout
					}
				}
			}
		}
	}

	ai_targets = {
		ai_recipients = liege
		ai_recipients = vassals
	}

	ai_targets = {
		ai_recipients = neighboring_rulers
		ai_recipients = peer_vassals
		max = 10
	}
	
	ai_targets = {
		ai_recipients = courtiers
		max = 5
	}

	ai_potential = {
		OR = {
			has_perk = truth_is_relative_perk
			dlm_has_criminal_network_landmark = yes
			AND = {
				has_trait = vengeful
				has_relation_rival = scope:recipient
			}
			AND = {
				government_has_flag = government_is_clan
				is_in_same_clan_as_trigger = { CHARACTER = scope:recipient }
				house = { has_house_unity_stage = competitive }
			}
		}
	}
}
