﻿nht_swordsmanship_tutelage_interaction = {
	category = interaction_category_friendly
	common_interaction = yes
	icon = nht_swordsmanship_tutelage

	send_name = SEND_NHT_START_TRAINING

	desc = nht_swordsmanship_tutelage_interaction_desc	

	cooldown_against_recipient = { years = 3 }
	
	populate_actor_list = {
		scope:actor = {
			if = {
				limit = {
					is_physically_able_adult = yes
					is_imprisoned = no
					NOT = { has_trait = incapable }
				}
				add_to_list = characters
			}
		}
	}

	populate_recipient_list = {
		scope:recipient = {
			if = {
				limit = {
					is_physically_able_adult = no
					is_imprisoned = no
					NOT = { has_trait = incapable }
				}
				add_to_list = characters
			}
		}	
		scope:actor = {	
			every_child = {
				limit = {
					is_child_of = scope:actor
					age >= 7
					is_physically_able_adult = no
					is_imprisoned = no
					NOT = { has_trait = incapable }
					trigger_if = { # Has to be male or have right doctrine
						limit = {
							scope:actor = {	
								NOR = { 
									faith = { has_doctrine = doctrine_gender_equal } 
									culture = { has_cultural_parameter = has_access_to_shieldmaidens }
									culture = { has_cultural_parameter = martial_custom_equal_combatant }
								}
							}
						}
						is_male = yes
					}
				}
				add_to_list = characters
			}
			every_relation = {
				type = ward
				limit = {
					age >= 7
					is_physically_able_adult = no
					is_imprisoned = no
					NOT = { has_trait = incapable }
				}
				add_to_list = characters
			}
		}
	}
	
	greeting = positive	
	prompt = NHT_SELECT_CHILD_TO_TRAIN
	
	is_shown = {
		scope:actor = { 
			OR = {
				has_perk = nht_swordsmanship_teaching_perk
				has_game_rule = nht_swordsmanship_tutelage_interaction_no_requi
			}
			OR = {
				is_ruler = yes 
				is_ai = no
			}
		}
		scope:recipient = {
			age >= 7
			is_adult = no
			OR = {
				has_relation_guardian = scope:actor
				is_child_of = scope:actor
			}
		}
	}

	is_valid_showing_failures_only = {
		scope:recipient = {
			NOR = { 
				is_in_the_same_court_as = scope:actor
				has_trait = incapable
			}
			is_imprisoned = no
		}	
		scope:actor = {
			is_imprisoned = no
			NOT = {
				is_at_war_with = scope:recipient
			}
		}	
	}

	can_be_picked = {
		is_at_home = yes
	}
	
	on_accept = {	
		scope:recipient = {
			custom_tooltip = nht_might_gain_prowess_interaction.recipient.notification
			save_scope_as = nht_recipient_combat
		}
		hidden_effect = {
			scope:actor = {
				trigger_event = {
					id = nht_more_lyfestyle_event.0001
					days = { 1 3 }
				}
				save_scope_as = nht_actor_combat
			}
		}		
	}

	auto_accept = yes
	
	ai_will_do = {
		base = 100
	}
}

nht_train_with_knight_interaction = {
	category = interaction_category_friendly
	common_interaction = yes
	icon = nht_knight_training

	send_name = SEND_NHT_REQUEST_TRAINING

	desc = nht_train_with_knight_interaction_desc	

	cooldown_against_recipient = { years = 5 }
	
	populate_actor_list = {
		scope:actor = {
			if = {
				limit = {
					is_physically_able_adult = yes
					is_imprisoned = no
					NOT = { has_trait = incapable }
				}
				add_to_list = characters
			}
		}
	}

	populate_recipient_list = {
		scope:recipient = {
			if = {
				limit = {
					is_knight = yes
					is_imprisoned = no
					NOT = { has_trait = incapable }
				}
				add_to_list = characters
			}
		}	
		scope:actor = {	
			every_knight = {
				limit = {
					is_imprisoned = no
				}
				add_to_list = characters
			}
		}
	}
	
	greeting = positive	
	prompt = NHT_SELECT_CHILD_TO_TRAIN
	
	is_shown = {
		scope:actor = { 
			has_perk = nht_half_grip_perk
			OR = {
				has_perk = nht_half_grip_perk
				has_game_rule = nht_train_with_knight_interaction_no_requi
			}
			OR = {
				is_ruler = yes 
				is_ai = no
			}
		}
		scope:recipient = {
			is_knight = yes
			is_imprisoned = no
			NOT = { has_trait = incapable }
		}
	}

	can_send = {
		scope:actor = {
			custom_description = {
				text = "character_interactions_hostile_actions_disabled_delay"
				NOT = { has_character_flag = flag_trade_actions_disabled_delay }
			}
		}
	}

	on_send = {
		scope:actor = {
			add_character_flag = {
				flag = flag_trade_actions_disabled_delay
				days = 10
			}
		}
	}
	
	is_valid_showing_failures_only = {
		scope:recipient = {
			NOR = { 
				is_in_the_same_court_as = scope:actor
				has_trait = incapable
			}
			is_imprisoned = no
		}	
		scope:actor = {
			is_imprisoned = no
		}
		
		scope:actor = {
		custom_description = {
			text = "has_nht_already_trained_recently"
			scope:actor = {
				NOT = { has_character_flag = flag_nht_has_trained_disabled_action }
			}	
		}
		}
		
	}

	can_be_picked = {
		is_at_home = yes
	}

	# Hooks can be used to force this through.
	## Don't force-force this on/for the player (so no pain but less benefits), but AI regard weak hooks as compulsory from/for other AI.
	send_options_exclusive = no
	send_option = {
		is_valid = {
			scope:actor = { has_usable_hook = scope:recipient }
		}
		flag = hook
		localization = SCHEME_HOOK
	}
	should_use_extra_icon = {
		scope:actor = { has_usable_hook = scope:recipient }
	}
	extra_icon = "gfx/interface/icons/character_interactions/hook_icon.dds"

	on_auto_accept = {
		scope:actor = {
			custom_tooltip = nht_might_gain_permanent_prowess_interaction.actor.notification
		}				
		scope:recipient = {
			custom_tooltip = nht_might_gain_prowess_interaction.recipient.notification
		}
		hidden_effect = {
			scope:actor = {
				trigger_event = {
					id = nht_more_lyfestyle_event.0004
					days = { 1 3 }
				}
				add_character_flag = {
					flag = flag_nht_has_trained_disabled_action
					years = 5
				}
			}
		}
	}
	
	on_accept = {
		scope:actor = {
			custom_tooltip = nht_might_gain_permanent_prowess_interaction.actor.notification
		}				
		scope:recipient = {
			custom_tooltip = nht_might_gain_prowess_interaction.recipient.notification
		}
		hidden_effect = {
			scope:actor = {
				trigger_event = {
					id = nht_more_lyfestyle_event.0004
					days = { 1 3 }
				}
				add_character_flag = {
					flag = flag_nht_has_trained_disabled_action
					years = 5
				}
			}
		}		
	}
	
	on_decline = {
	}

	# AI
	## Standard Acceptance stuff
	ai_accept = {
		# AI should accept by default
		base = 50
		
		modifier = {
			trigger = {
				always = scope:hook
			}
			add = 100
			desc = SCHEME_WEAK_HOOK_USED
		}
		# Weight up for opinion.
		opinion_modifier = {
			who = scope:recipient
			opinion_target = scope:actor
			multiplier = 1
			desc = AI_OPINION_REASON
		}

		# Traits thingy
		modifier = {
			add = -20
			scope:recipient = {
				has_trait = craven
			}
			desc = INTERACTION_NHT_CRAVEN
		}
		modifier = {
			add = 20
			scope:recipient = {
				has_trait = brave
			}
			desc = INTERACTION_NHT_BRAVE
		}
		modifier = {
			add = -20
			scope:recipient = {
				has_trait = paranoid
			}
			desc = INTERACTION_NHT_PARANOID
		}
		modifier = {
			add = -10
			scope:recipient = {
				has_trait = arbitrary
			}
			desc = INTERACTION_NHT_ARBITRARY
		}
		modifier = {
			add = 10
			scope:recipient = {
				has_trait = trusting
			}
			desc = INTERACTION_NHT_TRUSTING
		}
		modifier = {
			add = 10
			scope:recipient = {
				has_trait = just
			}
			desc = INTERACTION_NHT_JUST
		}
		# Rivalry
		modifier = { # Say no to friend
			add = 100
			scope:recipient = {
				has_relation_friend = scope:actor
				NOT = { has_relation_best_friend = scope:actor }
			}
			desc = "WE_ARE_FRIENDS"
		}
		modifier = { # Say yes to bestie BFF
			add = 300
			scope:recipient = {
				has_relation_best_friend = scope:actor
			}
			desc = "WE_ARE_BEST_FRIENDS"
		}
		# Rivalry
		modifier = { # Say no to rivals
			add = -100
			scope:recipient = {
				has_relation_rival = scope:actor
				NOT = { has_relation_nemesis = scope:actor }
			}
			desc = "ACTOR_RIVAL_TO_ME_REASON"
		}
		modifier = { # Say no to nemesis
			add = -300
			scope:recipient = {
				has_relation_nemesis = scope:actor
			}
			desc = "ACTOR_NEMESIS_TO_ME_REASON"
		}
		modifier = {
			desc = AI_DYNASTY_PRESTIGE_REASON
			scope:actor = { has_dynasty = yes }
			scope:actor.dynasty != scope:recipient.dynasty
			scope:actor.dynasty = { dynasty_prestige_level >= 2 }
			add = {
				value = 10
				if = {
					limit = {
						scope:actor.dynasty = { dynasty_prestige_level >= 3 }
					}
					add = 5
				}
				if = {
					limit = {
						scope:actor.dynasty = { dynasty_prestige_level >= 4 }
					}
					add = 5
				}
				if = {
					limit = {
						scope:actor.dynasty = { dynasty_prestige_level >= 5 }
					}
					add = 5
				}
				if = {
					limit = {
						scope:actor.dynasty = { dynasty_prestige_level >= 6 }
					}
					add = 5
				}
				if = {
					limit = {
						scope:actor.dynasty = { dynasty_prestige_level >= 7 }
					}
					add = 5
				}
				if = {
					limit = {
						scope:actor.dynasty = { dynasty_prestige_level >= 8 }
					}
					add = 5
				}
				if = {
					limit = {
						scope:actor.dynasty = { dynasty_prestige_level >= 9 }
					}
					add = 5
				}
				if = {
					limit = {
						scope:actor.dynasty = { dynasty_prestige_level >= 10 }
					}
					add = 5
				}
			}
		}		
		modifier = { #Faith compatibility
			scope:recipient.faith = {
				faith_hostility_level = {
					target = scope:actor.faith
					value > faith_fully_accepted_level
				}
			}
			NOT = {
				scope:recipient.ai_zeal <= -50
			}
			add = {
				value = -20
				if = {
					limit = {
						scope:recipient.faith = {
							faith_hostility_level = {
								target = scope:actor.faith
								value >= faith_astray_level
							}
						}
					}
					subtract = 20
				}
				if = {
					limit = {
						scope:recipient.faith = {
							faith_hostility_level = {
								target = scope:actor.faith
								value >= faith_hostile_level
							}
						}
					}
					subtract = 40
				}
				if = {
					limit = {
						scope:recipient.faith = {
							faith_hostility_level = {
								target = scope:actor.faith
								value >= faith_evil_level
							}
						}
					}
					subtract = 60
				}
				if = {
					limit = {
						scope:recipient.ai_zeal <= -25
					}
					divide = 2
				}
			}
			desc = MARRY_DIFFERENT_FAITH_REASON
		}
		#Actor has claims on recipient's titles.
		modifier = {
			scope:actor = {
				any_claim = {
					holder = scope:recipient
				}
			}
			add = -25
			desc = IS_CLAIMANT_TO_RECIPIENT_TITLES
		}
		modifier = {
			scope:recipient = {
				NOT = {
					any_claim = {
						holder = scope:actor
					}
				}
			}
			scope:recipient.house = scope:actor.house
			add = 15
			desc = IS_SAME_HOUSE_REASON
		}
		modifier = {
			scope:recipient = {
				has_opinion_modifier = {
					target = scope:actor
					modifier = declared_war
				}
			}
			add = -100
			desc = DECLARED_WAR_REASON
		}
		# Feud
		modifier = {
			add = -25
			scope:recipient = {
				house_has_feud_relation_with_trigger = { TARGET = scope:actor }
			}
			desc = MARRY_FAMILY_FEUD_REASON
		}		
	}	
	
	ai_will_do = {
		base = 100

		# Weight up for opinion.
		opinion_modifier = {
			who = scope:recipient
			opinion_target = scope:actor
			multiplier = 1
			desc = AI_OPINION_REASON
		}

		# Traits thingy
		modifier = {
			add = -20
			scope:recipient = {
				has_trait = craven
			}
		}
		modifier = {
			add = 20
			scope:recipient = {
				has_trait = brave
			}
		}
		modifier = {
			add = -20
			scope:recipient = {
				has_trait = paranoid
			}
		}
		modifier = {
			add = -10
			scope:recipient = {
				has_trait = arbitrary
			}
		}
		modifier = {
			add = 10
			scope:recipient = {
				has_trait = trusting
			}
		}
		modifier = {
			add = 10
			scope:recipient = {
				has_trait = just
			}
		}
		# Rivalry
		modifier = { # Say no to friend
			add = 100
			scope:recipient = {
				has_relation_friend = scope:actor
				NOT = { has_relation_best_friend = scope:actor }
			}
		}
		modifier = { # Say yes to bestie BFF
			add = 300
			scope:recipient = {
				has_relation_best_friend = scope:actor
			}
		}
		# Rivalry
		modifier = { # Say no to rivals
			add = -100
			scope:recipient = {
				has_relation_rival = scope:actor
				NOT = { has_relation_nemesis = scope:actor }
			}
		}
		modifier = { # Say no to nemesis
			add = -300
			scope:recipient = {
				has_relation_nemesis = scope:actor
			}
		}
	}
}