namespace = prisoner

################################################
# Force prisoner to relinquish claims decision
################################################
# Jailer - Force prisoner to relinquish claims
character_event = {
	id = prisoner.1
	desc = EVTDESCprisoner.1
	picture = GFX_evt_torture
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTAprisoner.1
	}
}
# Prisoner - Forced to relinquish claims
character_event = {
	id = prisoner.2
	desc = EVTDESCprisoner.2
	picture = GFX_evt_torture
	
	hide_from = yes
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTAprisoner.2
	}
}

################################################
# Visit prisoner decision
################################################
# Prisoner - Visited
character_event = {
	id = prisoner.3
	desc = EVTDESCprisoner.3
	picture = GFX_evt_lovers
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTAprisoner.3
		hidden_tooltip = {
			host = { character_event = { id = prisoner.4 } }
		}
	}
}
# Jailer - Visit prisoner
character_event = {
	id = prisoner.4
	desc = EVTDESCprisoner.4
	picture = GFX_evt_lovers
	
	hide_from = yes
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTAprisoner.4
		if = {
			limit = {
				is_female = no
				FROM = { is_pregnant = no }
				fertility = 0.5
				FROM = { fertility = 0.5 }
			}
			random = {
				chance = 100
				FROM = {
					impregnate = ROOT
					# impregnate_cuckoo = ROOT
					set_character_flag = prison_rape
				}
			}
		}
	}
}
# Prisoner - Pregnant (on_pregnancy)
character_event = {
	id = prisoner.5
	desc = EVTDESCprisoner.5
	picture = GFX_evt_pregnancy
	
	is_triggered_only = yes
	
	trigger = {
		NOT = { culture = wilderness}
		NOT = { trait = pregnant }
		has_character_flag = prison_rape
	}
	
	option = {
		name = OK
		add_trait = pregnant
		piety = -50
		prestige = -50
		if = {
			limit = {
				prisoner = yes
				father_of_unborn = {
					is_alive = yes
					ROOT = {
						host = { character = PREVPREV }
					}
				}
			}
			father_of_unborn = { character_event = { id = prisoner.6 } }
		}
		if = {
			limit = {
				prisoner = no
				OR = {
					is_married = yes
					is_consort = yes
				}
			}
			spouse = { character_event = { id = prisoner.7 } }
			consort = { character_event = { id = prisoner.7 } }
		}
	}
}
# Jailer - Notification if still prisoner
character_event = {
	id = prisoner.6
	desc = EVTDESCprisoner.6
	picture = GFX_evt_pregnancy
	
	is_triggered_only = yes 
	
	option = {
		name = OK
	}
}
# Spouse or consort - Notification if not prisoner
character_event = {
	id = prisoner.7
	desc = EVTDESCprisoner.7
	picture = GFX_evt_pregnancy
	
	is_triggered_only = yes 
	
	option = {
		name = OK
	}
}
# Child - Is born (on_birth)
character_event = {
	id = prisoner.8
	desc = EVTDESCprisoner.8
	picture = GFX_evt_birth
	
	is_triggered_only = yes
	
	trigger = {
		NOT = { culture = wilderness}
		was_conceived_a_bastard = yes
		mother = { has_character_flag = prison_rape }
	}
	
	option = {
		name = "OK"
		trigger = {
			mother = {
				prisoner = yes
				host = {
					ROOT = {
						father = {
							is_alive = yes
							character = PREVPREV
						}
					}
				}
			}
		}
		father = { character_event = { id = prisoner.9 days = 1 } }
	}
	option = {
		name = "OK"
		trigger = {
			mother = {
				prisoner = no
				is_married = yes
			}
		}
		mother = { spouse = { character_event = { id = prisoner.10 days = 1 } } }
	}
	option = {
		name = "OK"
		trigger = {
			mother = {
				prisoner = no
				is_consort = yes
			}
		}
		mother = { consort = { character_event = { id = prisoner.10 days = 1 } } }
	}
	option = {
		name = "OK"
		trigger = {
			mother = {
				OR ={ 
					prisoner = yes
					OR = {
						is_consort = no
						is_married = no
					}
				}
			}
		}
		mother = { character_event = { id = prisoner.10 days = 1 } }
	}
	
}
# Jailor - Reacts to the bastard birth
character_event = {
	id = prisoner.9
	desc = EVTDESCprisoner.9
	picture = GFX_evt_birth
	
	is_triggered_only = yes
	
	option = { # Legitimize the child
		name = EVTOPTAprisoner.9
		FROM = {
			character_event = { id = prisoner.11 tooltip = EVTTOOLTIPprisoner.11 }
			mother = {
				spouse = {
					if = {
						limit = { NOT = { character = ROOT} }
						character_event = { id = prisoner.13 tooltip = EVTTOOLTIP1prisoner.13 }
					}
				}
				consort = {
					if = {
						limit = { NOT = { character = ROOT} }
						character_event = { id = prisoner.13 tooltip = EVTTOOLTIP2prisoner.13 }
					}
				}
			}
		}
		any_child = {
			limit = {
				NOT = { character = FROM }
				dynasty = ROOT
				NOT = { trait = bastard }
			}
			opinion = { who = ROOT modifier = legitimized_bastard months = 12 }
		}
	}
	option = { # Acknowledge the child
		name = EVTOPTBprisoner.9
		FROM = {
			character_event = { id = prisoner.14 tooltip = EVTTOOLTIPprisoner.14 }
			mother = {
				any_spouse = {
					limit = { NOT = { character = ROOT} }
					character_event = { id = prisoner.13 tooltip = EVTTOOLTIP1prisoner.13 }
				}
				any_consort = {
					limit = { NOT = { character = ROOT} }
					character_event = { id = prisoner.13 tooltip = EVTTOOLTIP2prisoner.13 }
				}
			}
		}
	}
	option = { # Denounce the child
		name = EVTOPTCprisoner.9
		FROM = {
			character_event = { id = prisoner.16 tooltip = EVTTOOLTIPprisoner.16 }
			mother = {
				any_spouse = {
					limit = { NOT = { character = ROOT} }
					character_event = { id = prisoner.13 tooltip = EVTTOOLTIP1prisoner.13 }
				}
				any_consort = {
					limit = { NOT = { character = ROOT} }
					character_event = { id = prisoner.13 tooltip = EVTTOOLTIP2prisoner.13 }
				}
			}
		}
	}
}
# Spouse, consort or prisoner - Reacts to the bastard birth
character_event = {
	id = prisoner.10
	desc = EVTDESCprisoner.10
	picture = GFX_evt_birth
	
	is_triggered_only = yes
	
	option = { # Legitimize the child
		name = EVTOPTAprisoner.9
		FROM = {
			character_event = { id = prisoner.11 tooltip = EVTTOOLTIPprisoner.11 }
			mother = {
				spouse = {
					if = {
						limit = { NOT = { character = ROOT} }
						character_event = { id = prisoner.13 tooltip = EVTTOOLTIP1prisoner.13 }
					}
				}
				consort = {
					if = {
						limit = { NOT = { character = ROOT} }
						character_event = { id = prisoner.13 tooltip = EVTTOOLTIP2prisoner.13 }
					}
				}
			}
		}
		any_child = {
			limit = {
				NOT = { character = FROM }
				dynasty = ROOT
				NOT = { trait = bastard }
			}
			opinion = { who = ROOT modifier = legitimized_bastard months = 12 }
		}
	}
	option = { # Acknowledge the child
		name = EVTOPTBprisoner.9
		FROM = {
			character_event = { id = prisoner.14 tooltip = EVTTOOLTIPprisoner.14 }
			mother = {
				any_spouse = {
					limit = { NOT = { character = ROOT} }
					character_event = { id = prisoner.13 tooltip = EVTTOOLTIP1prisoner.13 }
				}
				any_consort = {
					limit = { NOT = { character = ROOT} }
					character_event = { id = prisoner.13 tooltip = EVTTOOLTIP2prisoner.13 }
				}
			}
		}
	}
	option = { # Denounce the child
		name = EVTOPTCprisoner.9
		FROM = {
			character_event = { id = prisoner.16 tooltip = EVTTOOLTIPprisoner.16 }
			mother = {
				any_spouse = {
					limit = { NOT = { character = ROOT} }
					character_event = { id = prisoner.13 tooltip = EVTTOOLTIP1prisoner.13 }
				}
				any_consort = {
					limit = { NOT = { character = ROOT} }
					character_event = { id = prisoner.13 tooltip = EVTTOOLTIP2prisoner.13 }
				}
			}
		}
	}
}
# Child - Legitimized
character_event = {
	id = prisoner.11
	desc = EVTDESC302
	picture = GFX_evt_birth
	
	is_triggered_only = yes 
	
	option = {
		name = OK
		dynasty = FROM
		remove_trait = bastard
		add_trait = legit_bastard
		if = {
			limit = { father = { NOT = { character = FROM } } }
			father = { ROOT = { set_real_father = PREV } }
			set_father = FROM
		}
		FROM = {
			ROOT ={
				father = {
					if = {
						limit = { character = PREVPREV }
						spouse = { character_event = { id = prisoner.12 tooltip = EVTTOOLTIPprisoner.12 } }
					}
				}
			}
		}
	}
}
# Jailor's wife - Enraged
character_event = {
	id = prisoner.12
	desc = EVTDESCprisoner.12
	picture = GFX_evt_quarrel
	
	is_triggered_only = yes 

	option = {
		name = EVTOPTAprisoner.12
		spouse = { reverse_opinion = { who = ROOT modifier = legitimized_bastard years = 20 } }
	}
}
# Spouse or consort - Pissed off
character_event = {
	id = prisoner.13
	desc = EVTDESCprisoner.13
	picture = GFX_evt_quarrel
	
	is_triggered_only = yes 
	
	option = {
		name = EVTOPTAprisoner.13
		opinion = { who = FROM modifier = opinion_cuckolded years = 10 }
	}
}
# Child - Acknowledged
character_event = {
	id = prisoner.14
	desc = EVTDESC306
	picture = GFX_evt_birth
	
	is_triggered_only = yes 
	
	option = {
		name = OK
		dynasty = FROM
		add_trait = bastard
		if = {
			limit = { father = { NOT = { character = FROM } } }
			father = { ROOT = { set_real_father = PREV } }
			set_father = FROM
		}
		FROM = {
			ROOT ={
				father = {
					if = {
						limit = { character = PREVPREV }
						spouse = { character_event = { id = prisoner.15 tooltip = EVTTOOLTIPprisoner.15 } }
					}
				}
			}
		}
	}
}
# Jailor's wife - Angered
character_event = {
	id = prisoner.15
	desc = EVTDESCprisoner.15
	picture = GFX_evt_quarrel
	
	is_triggered_only = yes 
	
	option = {
		name = EVTOPTAprisoner.15
		spouse = { reverse_opinion = { who = ROOT modifier = acknowledged_bastard years = 20 } }
	}
}
# The child is denounced
character_event = {
	id = prisoner.16
	desc = EVTDESC309
	picture = GFX_evt_birth
	
	is_triggered_only = yes 
	
	option = {
		name = OK
		dynasty = mother_bastard
		father = { ROOT = { set_real_father = PREV } }
		set_father = 0
	}
}

################################################
# Prisoner managment
################################################
# Mass release
character_event = {
	id = prisoner.20
	desc = EVTDESCprisoner.20
	picture = GFX_evt_into_the_dungeon
	
	is_triggered_only = yes 
	
	option = { # Unlanded
		name = EVTOPTAprisoner.20
		trigger = {
			any_courtier = {
				prisoner = yes
				is_landed = no
			}
		}
		any_courtier = {
			limit = {
				prisoner = yes
				is_landed = no
			}
			hidden_tooltip = {
				opinion = { who = ROOT modifier = opinion_merciful months = 60 }
				if = {
					limit = {
						liege = { character = ROOT }
						is_landed = yes
					}
					ROOT = {
						any_vassal = {
							limit = { NOT = { has_opinion_modifier = { who = ROOT modifier = opinion_released_prisoner } } }
							opinion = { modifier = opinion_released_prisoner who = ROOT months = 30 }
						}
					}
				}
			}
			imprison = no
		}
	}
	option = { # Below my tier
		name = EVTOPTBprisoner.20
		trigger = {
			any_courtier = {
				prisoner = yes
				is_landed = yes
				lower_tier_than = ROOT
			}
		}
		any_courtier = {
			limit = {
				prisoner = yes
				is_landed = yes
				lower_tier_than = ROOT
			}
			hidden_tooltip = {
				opinion = { who = ROOT modifier = opinion_merciful months = 60 }
				if = {
					limit = {
						liege = { character = ROOT }
						is_landed = yes
					}
					ROOT = {
						any_vassal = {
							limit = { NOT = { has_opinion_modifier = { who = ROOT modifier = opinion_released_prisoner } } }
							opinion = { modifier = opinion_released_prisoner who = ROOT months = 30 }
						}
					}
				}
			}
			imprison = no
		}
	}
	option = { # Above my tier
		name = EVTOPTCprisoner.20
		trigger = {
			any_courtier = {
				prisoner = yes
				is_landed = yes
				OR = {
					higher_tier_than = ROOT
					tier = ROOT
				}
			}
		}
		any_courtier = {
			limit = {
				prisoner = yes
				is_landed = yes
				OR = {
					higher_tier_than = ROOT
					tier = ROOT
				}
			}
			hidden_tooltip = {
				opinion = { who = ROOT modifier = opinion_merciful months = 60 }
				if = {
					limit = {
						liege = { character = ROOT }
						is_landed = yes
					}
					ROOT = {
						any_vassal = {
							limit = { NOT = { has_opinion_modifier = { who = ROOT modifier = opinion_released_prisoner } } }
							opinion = { modifier = opinion_released_prisoner who = ROOT months = 30 }
						}
					}
				}
			}
			imprison = no
		}
	}
	option = { # Cancel
		name = EVTOPTDprisoner.20
	}
}
# Mass execute
character_event = {
	id = prisoner.21
	desc = EVTDESCprisoner.21
	picture = GFX_evt_into_the_dungeon
	
	is_triggered_only = yes 
	
	option = { # Unlanded
		name = EVTOPTAprisoner.21
		trigger = {
			any_courtier = {
				prisoner = yes
				is_landed = no
			}
		}
		if = {
			limit = {
				any_courtier = {
					prisoner = yes
					is_landed = no
					dynasty = ROOT
				}
			}
			add_trait = kinslayer
		}
		any_courtier = {
			limit = {
				prisoner = yes
				is_landed = no
			}
			hidden_tooltip = {
				top_liege = {
					opinion = { who = ROOT modifier = opinion_tyrant months = 120 }
					any_realm_character = { opinion = { who = ROOT modifier = opinion_tyrant months = 120 } }
				}
				ROOT = { piety = -20 }
			}
			death = { death_reason = death_execution killer = ROOT }
		}
	}
	option = { # Below my tier
		name = EVTOPTBprisoner.21
		trigger = {
			any_courtier = {
				prisoner = yes
				is_landed = yes
				lower_tier_than = ROOT
			}
		}
		if = {
			limit = {
				any_courtier = {
					prisoner = yes
					is_landed = yes
					lower_tier_than = ROOT
					dynasty = ROOT
				}
			}
			add_trait = kinslayer
		}
		any_courtier = {
			limit = {
				prisoner = yes
				is_landed = yes
				lower_tier_than = ROOT
			}
			hidden_tooltip = {
				top_liege = {
					opinion = { who = ROOT modifier = opinion_tyrant months = 120 }
					any_realm_character = { opinion = { who = ROOT modifier = opinion_tyrant months = 120 } }
				}
				ROOT = { piety = -20 }
			}
			death = { death_reason = death_execution killer = ROOT }
		}
	}
	option = { # Above my tier
		name = EVTOPTCprisoner.21
		trigger = {
			any_courtier = {
				prisoner = yes
				is_landed = yes
				OR = {
					higher_tier_than = ROOT
					tier = ROOT
				}
			}
		}
		if = {
			limit = {
				any_courtier = {
					prisoner = yes
					is_landed = yes
					OR = {
						higher_tier_than = ROOT
						tier = ROOT
					}
					dynasty = ROOT
				}
			}
			add_trait = kinslayer
		}
		any_courtier = {
			limit = {
				prisoner = yes
				is_landed = yes
				OR = {
					higher_tier_than = ROOT
					tier = ROOT
				}
			}
			hidden_tooltip = {
				top_liege = {
					opinion = { who = ROOT modifier = opinion_tyrant months = 120 }
					any_realm_character = { opinion = { who = ROOT modifier = opinion_tyrant months = 120 } }
				}
				ROOT = { piety = -20 }
			}
			death = { death_reason = death_execution killer = ROOT }
		}
	}
	option = { # Cancel
		name = EVTOPTDprisoner.21
	}
}
