﻿########################################
# Regula Character Interactions (Misc) #
######################################################
# This file has the interactions that we can do as the Magister
# "Misc" interactions are those that dont quite fit into the other categories right now.
##
# Regula Misc Interactions
## regula_prisoner_interaction - Visit a female prisoner in your dungeon for shenanigans
## regula_take_orba_interaction - Turn an orba back into a Paelex
## regula_change_marriage_bed_status - Either remove or return someone to your marriage bed (fertility modifier)
## regula_interrogate_heretic_interaction - Visit a heretical prisoner in order to interrogate them to find info on other heresy members.
######################################################

# Visit Prisoner
regula_prisoner_interaction = {
	category = interaction_category_prison
	common_interaction = yes
	interface_priority = 25

	desc = regula_prisoner_interaction_desc

	is_shown = {
		scope:recipient = {
			is_male = no
			is_imprisoned_by = scope:actor
			age >= 16
		}
		scope:actor = {
			has_trait = magister_trait_group
		}
	}

	auto_accept = yes

	on_accept = {
		scope:recipient = {
			custom_tooltip = {
				text = regula_prisoner_interaction_tooltip
			}
		}
		scope:actor = {
			trigger_event = {
				id = regula_prisoner_event.1000
			}
		}
	}

	ai_will_do = {
		base = 0
	}
}

# Take Orba
regula_take_orba_interaction = {
	category = interaction_category_religion
	common_interaction = no
	desc = regula_take_orba_interaction_desc
	interface_priority = 150

	is_shown = {
		scope:actor = {
			has_trait = magister_trait_group
		}
		scope:recipient = {
			is_ai = yes
			has_trait = orba
			NOT = { scope:recipient = scope:actor }
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			custom_description = {
				text = magister_trait_2_required_trigger
				has_trait_rank = {
					trait = magister_trait_group
					rank >= 2
				}
			}
		}
		scope:recipient = {
			is_imprisoned = no #Will make alternate event for this.
			OR = {
				is_concubine = no
				is_consort_of = scope:actor
			}
		}
	}

	auto_accept = yes

	on_accept = {
		scope:recipient = {
			remove_trait = orba
			remove_all_character_modifier_instances = regula_orba_health_loss
			regula_add_paelex_trait_effect = yes
		}
		scope:actor = {
			if = {
				limit = {
					scope:recipient = {
						highest_held_title_tier >= tier_county
					}
				}
				marry = scope:recipient
			}
			else = {
				make_concubine = scope:recipient
			}
		}
	}
	ai_will_do = {
		base = 0
	}
}

# Remove from Marriage bed
# In this context, "Remove" means gaining the rejected from marriage bed modifier
# While "Add" means removing the marriage bed modifier
regula_change_marriage_bed_status = {
	category = interaction_category_friendly
	common_interaction = no
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:recipient = { has_character_modifier = rejected_from_marriage_bed_modifier }
				}
				desc = regula_change_marriage_bed_status_desc_remove
			}
			desc = regula_change_marriage_bed_status_desc_add
		}
	}
	icon = icon_personal
	interface_priority = 70

	is_shown = {
		scope:recipient = {
			is_consort_of = scope:actor
		}
	}

	is_valid_showing_failures_only = {
		scope:recipient = {
			is_visibly_fertile = yes
		}
	}

	cost = {
		prestige = {
			value = 100
		}
	}

	on_accept = {

		# Tooltip of what happens
		show_as_tooltip = {
			if = {
				limit = {
					scope:recipient = { has_character_modifier = rejected_from_marriage_bed_modifier }
				}
				scope:recipient = {
					remove_character_modifier = rejected_from_marriage_bed_modifier
				}
			}
			else = {
				scope:recipient = {
					add_character_modifier = rejected_from_marriage_bed_modifier
				}
			}
		}

		# Trigger letter effect
		scope:actor = {
			trigger_event = {
				id = regula_interaction_event.0003
			}
		}
	}

	auto_accept = yes

	ai_will_do = {
		base = 0
	}
}

# Interrogate Heretic
regula_interrogate_heretic_interaction = {
	category = interaction_category_prison
	common_interaction = yes
	icon = torture_interaction

	desc = regula_interrogate_heretic_interaction_desc

	is_shown = {
		scope:recipient = {
			is_imprisoned_by = scope:actor
		}
		scope:actor = {
			has_trait = magister_trait_group
			has_opinion_modifier = {
				target = scope:recipient
				modifier = regula_heresy_conspirator_opinion
			}
			any_owned_story = {
				story_type = story_regula_heresy
				regula_heresy_story_in_secret_state_trigger = yes
				is_target_in_variable_list = { 
					name = regula_heresy_all_conspirators
					target = scope:recipient
				}
			}
		}
	}

	auto_accept = yes

	cooldown_against_recipient = { years = 1 }

	on_accept = {
		scope:recipient = {
			custom_tooltip = {
				text = regula_interrogate_heretic_interaction_tooltip
			}
		}
		scope:actor = {
			trigger_event = {
				id = regula_interrogate_heretic_event.0001
			}
		}
	}

	ai_will_do = {
		base = 0
	}
}
