﻿agotma_claimant_interaction = {
	icon = icon_agotma_claimant
	category = interaction_category_friendly
	desc = agotma_claimant_interaction_desc
	interface_priority = 100
	scheme = agotma_claimant

	send_name = START_SCHEME
	ignores_pending_interaction_block = yes

	ai_targets = {
		ai_recipients = liege
		ai_recipients = dynasty
		ai_recipients = family
		ai_recipients = neighboring_rulers
	}

	ai_frequency = 12


	is_shown = {
		trigger_if = {
			limit = { has_game_rule = agotma_action_restriction_enabled }
			scope:actor.intrigue >= 20
		}
		scope:recipient.dynasty.dynast ?= {
			is_landed = yes
			highest_held_title_tier > tier_barony
		}
		scope:actor = {
			is_dynast = no
			NOT = {
				has_trait = incapable
			}
			is_lowborn = no
			NOT = {
				has_character_modifier = agotma_claimant_final_modifier
				has_claim_on = scope:recipient.dynasty.dynast.primary_title
			}
		}
		scope:actor.father ?= {
			NOT = { has_claim_on = scope:recipient.dynasty.dynast.primary_title }
		}
		scope:actor.mother ?= {
			NOT = { has_claim_on = scope:recipient.dynasty.dynast.primary_title }
		}
		scope:recipient = {
			is_dynast = yes
			is_landed = yes
			highest_held_title_tier > tier_county
			NOT = { is_parent_of = scope:actor }
			dynasty = scope:actor.dynasty
		}
		OR = {
			AND = {
				scope:actor = { is_ai = yes }
				has_game_rule = agotma_dynastic_claimant_enabled
			}
			scope:actor = { is_ai = no }
		}
		OR = {
			AND = {
				scope:actor = { is_ai = yes }
				scope:recipient.top_liege.primary_title = { NOT = { has_variable = agotma_claimant_started } }
			}
			scope:actor = { is_ai = no }
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			is_adult = yes
			is_at_home = yes
		}
	}

	cost = {
		# Nothing
	}

	auto_accept = yes

	on_accept = {
		scope:actor = {
			start_scheme = {
				type = agotma_claimant
				target_character = scope:recipient
			}
		}
	}

	ai_potential = {
		has_game_rule = agotma_dynastic_claimant_enabled
		is_adult = yes
		is_dynast = no
		NOT = {
			has_trait = incapable
		}
		is_lowborn = no
		NOT = {
			has_character_modifier = agotma_claimant_final_modifier
			#has_claim_on = scope:recipient.dynasty.dynast.primary_title
		}
	}

	ai_will_do = {
		base = 0

		opinion_modifier = {
			opinion_target = scope:recipient
			multiplier = -2
		}

		ai_value_modifier = {
			ai_boldness = 0.75
			ai_rationality = -0.25
			ai_greed = 0.75
			ai_honor = -0.25
		}

		modifier = {
			factor = 1.1
			scope:actor = {
				has_trait = education_martial_3
			}
		}

		modifier = {
			factor = 1.2
			scope:actor = {
				has_trait = education_martial_4
			}
		}

		modifier = {
			factor = 1.3
			scope:actor = {
				has_trait = education_martial_5
			}
		}

		modifier = {
			factor = 1.1
			scope:actor = {
				has_trait = strategist
			}
		}

		modifier = {
			factor = 1.1
			scope:actor = {
				has_trait = gallant
			}
		}

		modifier = {
			factor = 1.1
			scope:actor = {
				has_trait = patient
			}
		}

		modifier = {
			factor = 1.2
			scope:actor = {
				has_trait = scholar
			}
		}

		modifier = {
			add = 10
			scope:actor = {
				has_trait = deceitful
			}
		}

		modifier = {
			factor = 1.1
			scope:actor = {
				has_trait = diligent
			}
		}

		modifier = {
			factor = 2
			scope:actor = {
				learning >= 15
			}
		}

		modifier = {
			factor = 2
			scope:actor = {
				intrigue >= 30
			}
		}

		modifier = {
			factor = 0.8
			NOT = { scope:actor.culture = scope:recipient.culture }
		}

		modifier = {
			factor = 1.1
			scope:actor.location = scope:recipient.location
		}

		modifier = {
			factor = 1.1
			scope:actor = {
				prestige_level >= 2
			}
		}

		modifier = {
			factor = 1.2
			scope:actor = {
				highest_held_title_tier >= tier_county
			}
		}

		modifier = {
			factor = 1.2
			scope:recipient = {
				dynasty.dynasty_prestige_level >= 8
			}
		}

		modifier = {
			factor = 1.1
			scope:recipient = {
				dynasty.dynasty_prestige_level <= 7
				dynasty.dynasty_prestige_level > 5
			}
		}

		modifier = {
			factor = 0.9
			scope:recipient = {
				dynasty.dynasty_prestige_level <= 5
			}
		}

		modifier = {
			factor = 25
			scope:actor = {
				highest_held_title_tier >= tier_kingdom
			}
		}

	}

	on_decline = {
		# N/A
	}
}