﻿concubine_on_accept_effect = {
	scope:recipient = {
		if = {
			limit = {
				has_trait = devoted
			}
			remove_trait = devoted
		}
		# 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.0040
		if = {
			# Victim is angry for being forced into concubinage.
			limit = {
				OR = {
					has_trait = celibate
					is_imprisoned = yes
				}
			}
			release_from_prison = yes
			add_opinion = {
				target = scope:actor
				modifier = forced_me_concubine_marriage_opinion
			}

			# Family members of victim are also angry that you've forced them into concubinage.
			every_close_family_member = {
				if = {
					limit = { 
						this != scope:actor # Don't hate yourself.
					}
					add_opinion = {
						target = scope:actor
						modifier = forced_family_concubine_marriage_opinion
					}
					hidden_effect = {
						send_interface_message = {
							type = msg_family_became_concubine
							title = msg_close_family_member_taken_as_concubine_title
							right_icon = scope:actor
							left_icon = scope:secondary_actor
							show_as_tooltip = { scope:actor = { make_concubine = scope:secondary_actor } }
						}
					}

					# Family members are even *more* angry if they don't believe in concubines/polyamory (different from polygamy). Also if they don't accept same-sex relationships
					if = {
						limit = { 
							OR = {
								NOT = { faith = { has_doctrine = doctrine_concubines } }
								NOT = { faith = { has_doctrine = tenet_polyamory } }
								AND = {
									allowed_to_marry_same_sex_trigger = no
									scope:recipient = { sex_same_as = scope:secondary_actor }
								}
							}
						}
						add_opinion = {
							target = scope:actor
							modifier = relative_in_blasphemous_union_opinion
						}
					}
				}
			}	

			# Not up to them anymore...
			if = {
				limit = { has_trait = celibate }
				remove_trait = celibate
			}			
					
			# Spouses, if any exist, are also furious.
			if = {
				limit = {
					is_married = yes
				}
				every_spouse = {
					show_as_tooltip = {
						add_opinion = {
							target = scope:actor
							modifier = forced_spouse_concubine_marriage_opinion
						}
						divorce = scope:recipient # no additional opinion hit, no scripted effect
					}
					trigger_event = marriage_interaction.0041
				}
			}
					
			# Stealing concubines pisses the former concubinist off.
			if = {
				limit = {
					is_concubine = yes
				}
				this.concubinist = {
					show_as_tooltip = {
						add_opinion = {
							target = scope:secondary_actor
							modifier = stole_concubine_opinion
						}
						remove_concubine = scope:recipient # no additional opinion hit, no scripted effect
					}
					trigger_event = marriage_interaction.0041
				}
			}

			# Break any betrothals which may exist (without additional opinion penalties).
			if = {
				limit = { exists = betrothed }
				betrothed = { trigger_event = marriage_interaction.0041 }
				break_betrothal = betrothed
			}

			# Having concubines means they're now no longer yours.
			if = {
				limit = { number_of_concubines > 0	}
				every_concubine = {
					scope:recipient = {
						remove_concubine = prev
					}
				}
			}
		}
	}

	# Send us a notification about what we just did.
	scope:secondary_actor = {
		hidden_effect = {
			send_interface_toast = {
				type = event_toast_effect_neutral
				title = msg_concubine_taken_title
				right_icon = scope:recipient
				make_concubine = scope:recipient
			}
		}
	}
}