﻿
convert_to_witchcraft_interaction = {
	icon = icon_scheme_convert_to_witchcraft
	category = interaction_category_friendly

	interface_priority = 90
	scheme = convert_to_witchcraft

	send_name = START_SCHEME

	desc = convert_to_witchcraft_interaction_desc

	is_shown = {
		scope:actor = {
			can_start_scheme = {
				type = convert_to_witchcraft
				target_character = scope:recipient
			}
		}
		NOT = { scope:actor = scope:recipient }
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			NOT = { is_at_war_with = scope:recipient }
			can_start_scheme = {
				type = convert_to_witchcraft
				target_character = scope:recipient
			}
		}
		custom_description = {
			text = has_a_witch_secret_known_by_character
			subject = scope:recipient
			object = scope:actor
			scope:recipient = { #If they are a secret witch I must not know about it
				trigger_if = {
					limit = {
						any_secret = {
							secret_type = secret_witch
						}
					}
					any_secret = {
						secret_type = secret_witch
						NOT = {  any_secret_knower = { this = scope:actor } }
					}
				}
			}
		}
	}

	on_accept = {
		scope:actor = {
			send_interface_toast = {
				type = event_toast_effect_good
				title = convert_to_witchcraft_interaction_notification

				left_icon = scope:actor					
				right_icon = scope:recipient

				begin_scheme_basic_effect = {
					SCHEME_TYPE = convert_to_witchcraft
					TARGET_TYPE = target_character
					TARGET_SCOPE = scope:recipient
				}
			}
		}
	}

	auto_accept = yes

	#AI will do
	
	ai_potential = {
		is_witch_trigger = yes
	}
	
	ai_target_quick_trigger = {
		adult = yes
	}

	ai_targets = {
		ai_recipients = family
		max = 5
	}
	ai_targets = {
		ai_recipients = guests
		ai_recipients = courtiers
		ai_recipients = liege
		ai_recipients = vassals
		chance = 0.2
	}
	
	ai_frequency = 72


	ai_will_do = {
		base = -45
		
		# Do I like recipient & are they trustworthy
		opinion_modifier = {
			who = scope:actor
			opinion_target = scope:recipient
			multiplier = 0.5
		}
		compatibility_modifier = {
			who = scope:actor
			compatibility_target = scope:recipient
			multiplier = 0.2
		}
		opinion_modifier = {
			who = scope:recipient
			opinion_target = scope:actor
			multiplier = 0.5
		}
		ai_value_modifier = {
			who = scope:recipient
			ai_honor = 0.2
			ai_compassion = 0.1
			ai_rationality = 0.2
			ai_greed = 0.2
			ai_sociability = 0.1
		}
		ai_value_modifier = {
			trigger = { trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = scope:recipient.faith TRAIT = witch GENDER_CHARACTER = scope:actor } }
			ai_zeal = -0.5
			max = 20
		}

		# Are they important (to me)
		modifier = {
			add = {
				value = scope:recipient.highest_held_title_tier
				subtract = scope:actor.highest_held_title_tier
				multiply = 10
			}
		}
		modifier = {
			OR = {
				is_close_family_of = scope:recipient
				is_consort_of = scope:recipient
				has_relation_lover = scope:recipient
				has_relation_friend = scope:recipient
			}
			add = 20
		}
		modifier = {
			OR = {
				has_relation_best_friend = scope:recipient
				has_relation_soulmate = scope:recipient
			}
			add = 30
		}
		modifier = {
			exists = house
			exists = scope:recipient.house
			house = scope:recipient.house
			add = 10
		}

		# Do I want to spread the word
		ai_value_modifier = {
			ai_sociability = 0.2
			ai_compassion = 0.1
			ai_boldness = 0.4
			min = -20
		}
	}
}

reveal_as_witch_interaction = {
	category = interaction_category_friendly
	icon = icon_scheme_convert_to_witchcraft

	interface_priority = 100

	desc = reveal_as_witch_interaction_desc
	notification_text = witch.2900.desc

	is_shown = {
		scope:actor = {
			is_adult = yes
			any_secret = {
				secret_type = secret_witch
				NOT = { is_known_by = scope:recipient }
			}
			knows_about_character_being_witch_trigger = { CHARACTER = scope:recipient }
		}
		scope:actor.faith = scope:recipient.faith
		scope:recipient = {
			is_adult = yes
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			NOT = { is_at_war_with = scope:recipient }
		}
	}

	on_accept = {
		scope:actor = {
			#Secret reveals.
			random_secret = {
				limit = {
					secret_type = secret_witch
					NOT = { is_known_by = scope:recipient }
				}
				save_scope_as = witch_secret
				reveal_to = scope:recipient
			}
			#Send a reply.
			trigger_event = witch.2901
			#Opinion effects.
			reverse_add_opinion = {
				target = scope:recipient
				modifier = trust_opinion
				opinion = 20
			}
			hidden_effect = {
				if = {
					limit = {
						can_set_relation_potential_friend_trigger = { CHARACTER = scope:recipient }
					}
					set_relation_potential_friend = scope:recipient
				}
			}
		}

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

	auto_accept = yes
	force_notification = yes

	#AI will do
	
	ai_potential = {
		always = yes
	}
	
	ai_target_quick_trigger = {
		adult = yes
	}

	ai_targets = {
		ai_recipients = liege
		ai_recipients = known_secrets
	}
	ai_targets = {
		ai_recipients = vassals
		ai_recipients = peer_vassals
		chance = 0.2
	}
	ai_frequency = 144


	ai_will_do = {
		base = -45

		# Do I like recipient & are they trustworthy
		opinion_modifier = {
			who = scope:actor
			opinion_target = scope:recipient
			multiplier = 0.5
		}
		compatibility_modifier = {
			who = scope:actor
			compatibility_target = scope:recipient
			multiplier = 0.2
		}
		opinion_modifier = {
			who = scope:recipient
			opinion_target = scope:actor
			multiplier = 0.5
		}
		ai_value_modifier = {
			who = scope:recipient
			ai_honor = 0.2
			ai_compassion = 0.1
		}

		# Are they important
		modifier = {
			add = {
				value = scope:recipient.highest_held_title_tier
				subtract = scope:actor.highest_held_title_tier
				multiply = 10
				max = 30
			}
		}

		#Do I want to tell anyone
		ai_value_modifier = {
			ai_sociability = 0.2
			ai_compassion = 0.1
			min = -20
		}

		modifier = {
			has_trait = paranoid
			add = -40
		}
	}
}
