﻿fmp_interaction_effect = {
	scope:recipient = {
		# Hegemony tier
		if = {
			limit = {
				OR = {
					AND = {
						is_imprisoned = yes
						is_married = yes
						any_spouse = {
							AND = {
								is_ruler = yes
								highest_held_title_tier = tier_hegemony
							}
						}
					}
					AND = {
						is_imprisoned = yes
						is_concubine = yes
						this.concubinist = {
							is_ruler = yes
							highest_held_title_tier = tier_hegemony
						}
					}
				}
			}
			scope:actor = {
				add_character_modifier = {
					modifier = concubine_royal_monthly_hegemony
					years = 5
				}
				add_prestige = 500
			}
		}

		# Empire tier
		if = {
			limit = {
				OR = {
					AND = {
						is_imprisoned = yes
						is_married = yes
						any_spouse = {
							AND = {
								is_ruler = yes
								highest_held_title_tier = tier_empire
							}
						}
					}
					AND = {
						is_imprisoned = yes
						is_concubine = yes
						this.concubinist = {
							is_ruler = yes
							highest_held_title_tier = tier_empire
						}
					}
				}
			}
			scope:actor = {
				add_character_modifier = {
					modifier = concubine_royal_monthly_empire
					years = 5
				}
				add_prestige = 400
			}
		}

		# Kingdom tier
		if = {
			limit = {
				OR = {
					AND = {
						is_imprisoned = yes
						is_married = yes
						any_spouse = {
							AND = {
								is_ruler = yes
								highest_held_title_tier = tier_kingdom
							}
						}
					}
					AND = {
						is_imprisoned = yes
						is_concubine = yes
						this.concubinist = {
							is_ruler = yes
							highest_held_title_tier = tier_kingdom
						}
					}
				}
			}
			scope:actor = {
				add_character_modifier = {
					modifier = concubine_royal_monthly_kingdom
					years = 5
				}
				add_prestige = 300
			}
		}

		# Duchy tier
		if = {
			limit = {
				OR = {
					AND = {
						is_imprisoned = yes
						is_married = yes
						any_spouse = {
							AND = {
								is_ruler = yes
								highest_held_title_tier = tier_duchy
							}
						}
					}
					AND = {
						is_imprisoned = yes
						is_concubine = yes
						this.concubinist = {
							is_ruler = yes
							highest_held_title_tier = tier_duchy
						}
					}
				}
			}
			scope:actor = {
				add_character_modifier = {
					modifier = concubine_royal_monthly_duchy
					years = 5
				}
				add_prestige = 200
			}
		}

		# County tier
		if = {
			limit = {
				OR = {
					AND = {
						is_imprisoned = yes
						is_married = yes
						any_spouse = {
							AND = {
								is_ruler = yes
								highest_held_title_tier = tier_county
							}
						}
					}
					AND = {
						is_imprisoned = yes
						is_concubine = yes
						this.concubinist = {
							is_ruler = yes
							highest_held_title_tier = tier_county
						}
					}
				}
			}
			scope:actor = {
				add_character_modifier = {
					modifier = concubine_royal_monthly_county
					years = 5
				}
				add_prestige = 100
			}
		}
		trigger_event = marriage_interaction.0010
		if = {
			limit = {
				is_imprisoned = yes
			}
			release_from_prison = yes
			if = {
				limit = {
					NOR = {
						has_relation_lover = scope:actor
						has_relation_soulmate = scope:actor
						is_courtier_of = scope:actor
					}
				}
				add_opinion = {
					target = scope:actor
					modifier = demanded_recruitment
				}
			}
			if = {
				limit = {
					is_married = yes
				}
				every_spouse = {
					#trigger_event = marriage_interaction.0041
					divorce = scope:recipient # no opinion hit, no scripted effect
					add_opinion = {
						target = scope:recipient
						modifier =  fmp_rightful_spouse_opinion
					}
					progress_towards_rival_effect = { CHARACTER = scope:actor }
					if = {
						limit = { scope:recipient = { is_female = yes } }
						add_opinion = {
							target = scope:actor
							modifier =  fmp_stole_my_wife_opinion
						}
					}
					else = {
						add_opinion = {
							target = scope:actor
							modifier = fmp_stole_my_husband_opinion
						}
					}
				}
			}
			if = {
				limit = { exists = betrothed }
				#trigger_event = marriage_interaction.0041 # opinion event
				break_betrothal = betrothed
			}
		}
	}
	scope:secondary_actor = {
		if = {
			limit = { is_female = yes }
			marry_matrilineal = scope:secondary_recipient
		}
		else = {
			marry = scope:secondary_recipient
		}
	}

	###MANAGEMENT SCRIPT FOR VARIOUS EVENTS/CONTENT###

	#If your spouse councillor had boosted the chance of marriage, remove modifier
	if = {
		limit = {
			scope:secondary_actor = {
				has_character_modifier = heir_easier_to_marry_off_modifier
			}
			scope:actor = { player_heir = scope:secondary_actor }
		}
		scope:secondary_actor = {
			remove_character_modifier = heir_easier_to_marry_off_modifier
		}
	}
	if = {
		limit = {
			scope:secondary_actor = {
				is_child_of = scope:actor
				has_character_modifier = child_easier_to_marry_off_modifier
			}
		}
		scope:secondary_actor = {
			remove_character_modifier = child_easier_to_marry_off_modifier
		}
	}
}
