#######################################
# Order of the Sacred Magdalene
# Brothel / Sacred Prostitution Events
#
# TARGET ARCHITECTURE
#
# The House decisions establish their required
# state before the visible service chains begin.
#
# ggsm_work_whore:
#   ROOT = female worker
#   ggsm.700 selects and saves
#   event_target:ggsm_brothel_client
#
# ggsm_visit_brothel:
#   ROOT = male visitor
#   event_target:ggsm_whore = selected female worker
#
# The Visit route consumes a target selected by
# its decision. The Work route deliberately selects
# its client inside ggsm.700, restoring the older
# known-good House entry architecture.
#######################################

namespace = ggsm

#######################################
# HOUSE STATE MODEL
#
#   Live encounter mutex. Set while a sister
#   has an active customer and cleared only
#   when that encounter reaches a terminal exit.
#
# ggsm_house_rest
#   Timed 30-day character modifier used for
#   balance. CK2 expires it automatically.
#
# The old ggsm_whored / ggsm.714 delayed-event
# cooldown system is retired in this event file.
#######################################


#######################################
# WORK IN A HOUSE OF MERCY
#
# Four-screen sequence:
#
# INSIDE:
# 700 -> 701 -> 702 -> 703
#
# OUTSIDE:
# 700 -> 710 -> 711 -> 712
#
# Cell and yard work keep ROOT on the sister.
# The one saved client is handed only to hidden
# work-response events 745 / 746. The separate
# male Visit route continues to use 722 / 724.
#######################################

long_character_event = {
	id = ggsm.700
	desc = ggsm.700.desc
	picture = GFX_event_nada1
	border = GFX_event_long_frame_religion
	is_triggered_only = yes

	immediate = {
		# Select and save the client inside the opening event.
		# This restores the old known-good House work entry:
		# a broad global Catholic male pool with no separate
		# diplomatic-range gate between the decision and .700.
		random_character = {
			limit = {
				is_female = no
				is_adult = yes
				ai = yes
				religion = catholic
				prisoner = no
				is_within_diplo_range = ROOT

				NOT = { character = ROOT }
				NOT = { spouse = { character = ROOT } }
				NOT = { is_lover = ROOT }
				NOT = { trait = chaste }
				NOT = { trait = celibate }
				NOT = { trait = incapable }
			}

			save_event_target_as = ggsm_brothel_client
		}

		hidden_tooltip = {
			# Preserve the existing weak-character illness risk.
			if = {
				limit = { trait = weak }
				random = {
					chance = 1
					add_trait = ill
				}
			}
		}
	}

	option = {
		name = ggsm.700.inside

		long_character_event = {
			id = ggsm.701
		}
	}

	option = {
		name = ggsm.700.outside

		long_character_event = {
			id = ggsm.710
		}
	}
}


long_character_event = {
	id = ggsm.701
	desc = ggsm.701.desc
	picture = GFX_event_nada1
	border = GFX_event_long_frame_religion
	is_triggered_only = yes

	trigger = {
		event_target:ggsm_brothel_client = {
			is_alive = yes
		}
	}

	option = {
		name = ggsm.continue

		long_character_event = {
			id = ggsm.702
		}
	}
}


long_character_event = {
	id = ggsm.702
	desc = ggsm.702.desc
	picture = GFX_event_nada1
	border = GFX_event_long_frame_religion
	is_triggered_only = yes

	trigger = {
		event_target:ggsm_brothel_client = {
			is_alive = yes
		}
	}

	option = {
		name = ggsm.continue

		long_character_event = {
			id = ggsm.703
		}
	}
}


long_character_event = {
	id = ggsm.703
	desc = ggsm.703.desc
	picture = GFX_event_nada1
	border = GFX_event_long_frame_religion
	is_triggered_only = yes

	trigger = {
		event_target:ggsm_brothel_client = {
			is_alive = yes
		}
	}

	#######################################
	# PUT HIM OUT
	#######################################
	option = {
		name = ggsm.703.reject

		# Encounter ends here. House Rest expires naturally.
	}

	#######################################
	# SHE WANTS HIM TO FINISH INSIDE
	#######################################
	option = {
		name = ggsm.703.inside

		set_variable = { which = local_pay value = 0 }

		if = { limit = { check_variable = { which = wealth_temp value = 3 } }  set_variable = { which = local_pay value = 2 } }
		if = { limit = { check_variable = { which = wealth_temp value = 5 } }  set_variable = { which = local_pay value = 3 } }
		if = { limit = { check_variable = { which = wealth_temp value = 7 } }  set_variable = { which = local_pay value = 4 } }
		if = { limit = { check_variable = { which = wealth_temp value = 9 } }  set_variable = { which = local_pay value = 5 } }
		if = { limit = { check_variable = { which = wealth_temp value = 11 } } set_variable = { which = local_pay value = 6 } }
		if = { limit = { check_variable = { which = wealth_temp value = 13 } } set_variable = { which = local_pay value = 7 } }
		if = { limit = { check_variable = { which = wealth_temp value = 15 } } set_variable = { which = local_pay value = 8 } }

		if = {
			limit = { tier = EMPEROR }
			multiply_variable = { which = local_pay value = 12 }
		}
		if = {
			limit = { tier = KING }
			multiply_variable = { which = local_pay value = 8 }
		}
		if = {
			limit = { tier = DUKE }
			multiply_variable = { which = local_pay value = 5 }
		}
		if = {
			limit = { tier = COUNT }
			multiply_variable = { which = local_pay value = 3 }
		}

		wealth = local_pay

		# Hand the one saved AI client to the hidden work resolver.
		# The visible Serve sequence never becomes his event.
		event_target:ggsm_brothel_client = {
			character_event = { id = ggsm.745 }
		}
	}

	#######################################
	# SHE WANTS HIM TO FINISH OUTSIDE
	#######################################
	option = {
		name = ggsm.703.outside

		set_variable = { which = local_pay value = 0 }

		if = { limit = { check_variable = { which = wealth_temp value = 3 } }  set_variable = { which = local_pay value = 1 } }
		if = { limit = { check_variable = { which = wealth_temp value = 5 } }  set_variable = { which = local_pay value = 2 } }
		if = { limit = { check_variable = { which = wealth_temp value = 7 } }  set_variable = { which = local_pay value = 3 } }
		if = { limit = { check_variable = { which = wealth_temp value = 9 } }  set_variable = { which = local_pay value = 4 } }
		if = { limit = { check_variable = { which = wealth_temp value = 11 } } set_variable = { which = local_pay value = 5 } }
		if = { limit = { check_variable = { which = wealth_temp value = 13 } } set_variable = { which = local_pay value = 6 } }
		if = { limit = { check_variable = { which = wealth_temp value = 15 } } set_variable = { which = local_pay value = 7 } }

		if = {
			limit = { tier = EMPEROR }
			multiply_variable = { which = local_pay value = 10 }
		}
		if = {
			limit = { tier = KING }
			multiply_variable = { which = local_pay value = 6 }
		}
		if = {
			limit = { tier = DUKE }
			multiply_variable = { which = local_pay value = 4 }
		}
		if = {
			limit = { tier = COUNT }
			multiply_variable = { which = local_pay value = 2 }
		}

		wealth = local_pay

		# Hand the one saved AI client to the hidden work resolver.
		# The visible Serve sequence never becomes his event.
		event_target:ggsm_brothel_client = {
			character_event = { id = ggsm.746 }
		}
	}
}


#######################################
# OUTSIDE ROUTE
#######################################

long_character_event = {
	id = ggsm.710
	desc = ggsm.710.desc
	picture = GFX_event_nada1
	border = GFX_event_long_frame_religion
	is_triggered_only = yes

	trigger = {
		event_target:ggsm_brothel_client = {
			is_alive = yes
		}
	}

	option = {
		name = ggsm.continue

		long_character_event = {
			id = ggsm.711
		}
	}
}


long_character_event = {
	id = ggsm.711
	desc = ggsm.711.desc
	picture = GFX_event_nada1
	border = GFX_event_long_frame_religion
	is_triggered_only = yes

	trigger = {
		event_target:ggsm_brothel_client = {
			is_alive = yes
		}
	}

	option = {
		name = ggsm.continue

		long_character_event = {
			id = ggsm.712
		}
	}
}


long_character_event = {
	id = ggsm.712
	desc = ggsm.712.desc
	picture = GFX_event_nada1
	border = GFX_event_long_frame_religion
	is_triggered_only = yes

	trigger = {
		event_target:ggsm_brothel_client = {
			is_alive = yes
		}
	}

	#######################################
	# END THE YARD SERVICE
	#######################################
	option = {
		name = ggsm.712.reject

		# Encounter ends here. House Rest expires naturally.
	}

	#######################################
	# SHE WANTS HIM TO FINISH INSIDE
	#######################################
	option = {
		name = ggsm.712.inside

		set_variable = { which = local_pay value = 0 }

		if = { limit = { check_variable = { which = wealth_temp value = 3 } }  set_variable = { which = local_pay value = 1 } }
		if = { limit = { check_variable = { which = wealth_temp value = 5 } }  set_variable = { which = local_pay value = 2 } }
		if = { limit = { check_variable = { which = wealth_temp value = 7 } }  set_variable = { which = local_pay value = 3 } }
		if = { limit = { check_variable = { which = wealth_temp value = 9 } }  set_variable = { which = local_pay value = 4 } }
		if = { limit = { check_variable = { which = wealth_temp value = 11 } } set_variable = { which = local_pay value = 5 } }
		if = { limit = { check_variable = { which = wealth_temp value = 13 } } set_variable = { which = local_pay value = 6 } }
		if = { limit = { check_variable = { which = wealth_temp value = 15 } } set_variable = { which = local_pay value = 7 } }

		if = {
			limit = { tier = EMPEROR }
			multiply_variable = { which = local_pay value = 10 }
		}
		if = {
			limit = { tier = KING }
			multiply_variable = { which = local_pay value = 6 }
		}
		if = {
			limit = { tier = DUKE }
			multiply_variable = { which = local_pay value = 4 }
		}
		if = {
			limit = { tier = COUNT }
			multiply_variable = { which = local_pay value = 2 }
		}

		wealth = local_pay

		event_target:ggsm_brothel_client = {
			character_event = { id = ggsm.745 }
		}
	}

	#######################################
	# SHE WANTS HIM TO FINISH OUTSIDE
	#######################################
	option = {
		name = ggsm.712.outside

		set_variable = { which = local_pay value = 0 }

		if = { limit = { check_variable = { which = wealth_temp value = 3 } }  set_variable = { which = local_pay value = 1 } }
		if = { limit = { check_variable = { which = wealth_temp value = 5 } }  set_variable = { which = local_pay value = 2 } }
		if = { limit = { check_variable = { which = wealth_temp value = 7 } }  set_variable = { which = local_pay value = 3 } }
		if = { limit = { check_variable = { which = wealth_temp value = 9 } }  set_variable = { which = local_pay value = 4 } }
		if = { limit = { check_variable = { which = wealth_temp value = 11 } } set_variable = { which = local_pay value = 5 } }
		if = { limit = { check_variable = { which = wealth_temp value = 13 } } set_variable = { which = local_pay value = 6 } }
		if = { limit = { check_variable = { which = wealth_temp value = 15 } } set_variable = { which = local_pay value = 7 } }

		if = {
			limit = { tier = EMPEROR }
			multiply_variable = { which = local_pay value = 10 }
		}
		if = {
			limit = { tier = KING }
			multiply_variable = { which = local_pay value = 6 }
		}
		if = {
			limit = { tier = DUKE }
			multiply_variable = { which = local_pay value = 4 }
		}
		if = {
			limit = { tier = COUNT }
			multiply_variable = { which = local_pay value = 2 }
		}

		wealth = local_pay

		event_target:ggsm_brothel_client = {
			character_event = { id = ggsm.746 }
		}
	}
}


#######################################
# SERVE IN THE HOUSE: HIDDEN RESPONSE
# SHE ORDERED HIM TO FINISH INSIDE
#
# ROOT = the ONE AI Catholic male saved by ggsm.700
# FROM = the working sister
#
# This event belongs only to ggsm_work_whore.
# It is hidden so the player never receives the
# selected man's response buttons.
#######################################

character_event = {
	id = ggsm.745
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		ai = yes
		is_alive = yes
		is_female = no
		FROM = {
			is_alive = yes
			is_female = yes
		}
	}

	immediate = {
		random_list = {

			###################################
			# OBEY: FINISH INSIDE
			###################################
			80 = {
				modifier = { factor = 1.5 trait = just }
				modifier = { factor = 1.25 trait = kind }
				modifier = { factor = 1.25 trait = humble }
				modifier = { factor = 1.25 trait = temperate }

				FROM = {
					long_character_event = { id = ggsm.726 }
				}
			}

			###################################
			# DISOBEY: PULL OUT
			###################################
			15 = {
				modifier = { factor = 2 trait = arbitrary }
				modifier = { factor = 1.75 trait = wroth }
				modifier = { factor = 1.5 trait = proud }
				modifier = { factor = 1.5 trait = cruel }
				modifier = { factor = 1.25 trait = lustful }
				modifier = { factor = 0.5 trait = just }
				modifier = { factor = 0.5 trait = kind }
				modifier = { factor = 0.5 trait = humble }

				# Same punishment as ggsm.723, applied here invisibly.
				if = {
					limit = { FROM = { higher_tier_than = ROOT } }
					imprison = FROM
				}

				if = {
					limit = { NOT = { FROM = { higher_tier_than = ROOT } } }
					excommunicate = yes
				}

				if = {
					limit = { higher_tier_than = FROM }

					if = {
						limit = {
							OR = {
								AND = { tier = COUNT FROM = { tier = BARON } }
								AND = { tier = DUKE FROM = { tier = COUNT } }
								AND = { tier = KING FROM = { tier = DUKE } }
								AND = { tier = EMPEROR FROM = { tier = KING } }
							}
						}
						add_character_modifier = { name = ggsm_magdalene_scandal_1 duration = 1825 }
					}

					if = {
						limit = {
							OR = {
								AND = { tier = DUKE FROM = { tier = BARON } }
								AND = { tier = KING FROM = { tier = COUNT } }
								AND = { tier = EMPEROR FROM = { tier = DUKE } }
							}
						}
						add_character_modifier = { name = ggsm_magdalene_scandal_2 duration = 1825 }
					}

					if = {
						limit = {
							OR = {
								AND = { tier = KING FROM = { tier = BARON } }
								AND = { tier = EMPEROR FROM = { tier = COUNT } }
							}
						}
						add_character_modifier = { name = ggsm_magdalene_scandal_3 duration = 1825 }
					}

					if = {
						limit = { tier = EMPEROR FROM = { tier = BARON } }
						add_character_modifier = { name = ggsm_magdalene_scandal_4 duration = 1825 }
					}
				}

				FROM = {
					long_character_event = { id = ggsm.730 }
				}
			}

			###################################
			# STOP
			###################################
			5 = {
				modifier = { factor = 2 trait = shy }
				modifier = { factor = 1.5 trait = temperate }

				FROM = {
					long_character_event = { id = ggsm.727 }
				}
			}
		}
	}
}


#######################################
# SERVE IN THE HOUSE: HIDDEN RESPONSE
# SHE ORDERED HIM TO FINISH OUTSIDE
#
# ROOT = the ONE AI Catholic male saved by ggsm.700
# FROM = the working sister
#
# This event belongs only to ggsm_work_whore.
# It is hidden so the player never receives the
# selected man's response buttons.
#######################################

character_event = {
	id = ggsm.746
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		ai = yes
		is_alive = yes
		is_female = no
		FROM = {
			is_alive = yes
			is_female = yes
		}
	}

	immediate = {
		random_list = {

			###################################
			# OBEY: PULL OUT
			###################################
			80 = {
				modifier = { factor = 1.5 trait = just }
				modifier = { factor = 1.25 trait = kind }
				modifier = { factor = 1.25 trait = humble }
				modifier = { factor = 1.25 trait = temperate }

				FROM = {
					long_character_event = { id = ggsm.728 }
				}
			}

			###################################
			# DISOBEY: FINISH INSIDE
			###################################
			15 = {
				modifier = { factor = 2 trait = arbitrary }
				modifier = { factor = 1.75 trait = wroth }
				modifier = { factor = 1.5 trait = proud }
				modifier = { factor = 1.5 trait = cruel }
				modifier = { factor = 1.25 trait = lustful }
				modifier = { factor = 0.5 trait = just }
				modifier = { factor = 0.5 trait = kind }
				modifier = { factor = 0.5 trait = humble }

				# Same punishment as ggsm.725, applied here invisibly.
				if = {
					limit = { FROM = { higher_tier_than = ROOT } }
					imprison = FROM
				}

				if = {
					limit = { NOT = { FROM = { higher_tier_than = ROOT } } }
					excommunicate = yes
				}

				if = {
					limit = { higher_tier_than = FROM }

					if = {
						limit = {
							OR = {
								AND = { tier = COUNT FROM = { tier = BARON } }
								AND = { tier = DUKE FROM = { tier = COUNT } }
								AND = { tier = KING FROM = { tier = DUKE } }
								AND = { tier = EMPEROR FROM = { tier = KING } }
							}
						}
						add_character_modifier = { name = ggsm_magdalene_scandal_1 duration = 1825 }
					}

					if = {
						limit = {
							OR = {
								AND = { tier = DUKE FROM = { tier = BARON } }
								AND = { tier = KING FROM = { tier = COUNT } }
								AND = { tier = EMPEROR FROM = { tier = DUKE } }
							}
						}
						add_character_modifier = { name = ggsm_magdalene_scandal_2 duration = 1825 }
					}

					if = {
						limit = {
							OR = {
								AND = { tier = KING FROM = { tier = BARON } }
								AND = { tier = EMPEROR FROM = { tier = COUNT } }
							}
						}
						add_character_modifier = { name = ggsm_magdalene_scandal_3 duration = 1825 }
					}

					if = {
						limit = { tier = EMPEROR FROM = { tier = BARON } }
						add_character_modifier = { name = ggsm_magdalene_scandal_4 duration = 1825 }
					}
				}

				FROM = {
					long_character_event = { id = ggsm.731 }
				}
			}

			###################################
			# STOP
			###################################
			5 = {
				modifier = { factor = 2 trait = shy }
				modifier = { factor = 1.5 trait = temperate }

				FROM = {
					long_character_event = { id = ggsm.729 }
				}
			}
		}
	}
}


#######################################
# RETIRED: ggsm.714
#
# The old cooldown system scheduled ggsm.714
# to clear ggsm_whored after thirty days.
#
# The House now uses ggsm_house_rest, a timed
# character modifier whose expiration CK2 owns.
#
# ggsm.714 intentionally has no live definition.
#######################################


#######################################
# VISIT A HOUSE OF MERCY AS A MALE
#
# The decision has already selected and
# saved event_target:ggsm_whore before
# this visible event is fired.
#
# SERVICE HANDOFF:
#
# 720 ROOT = male visitor
#     event_target:ggsm_whore = sister
#
# The Visit decision reserves the sister with
# before this visible chain begins.
#
# The chain then remains on the male for four
# continuation screens:
#
#     720 -> 732 -> 733 -> 734 -> 735
#
# 735 sends 721 to the sister.
#
# 721 ROOT = sister
#     FROM = male visitor
#
# She makes the inside/outside ending choice.
#
# Wants inside:  721 -> FROM -> 722
# Wants outside: 721 -> FROM -> 724
#
# 722 / 724 ROOT = male visitor
#           FROM = sister
#
# Sister-side terminal results 726-731
#######################################

long_character_event = {
	id = ggsm.720
	desc = ggsm.720.desc
	picture = GFX_event_nada7
	border = GFX_event_long_frame_religion
	is_triggered_only = yes

	trigger = {
		event_target:ggsm_whore = {
			is_alive = yes
			NOT = { trait = incapable }
		}
	}

	option = {
		# Pay for the sister's service.
		# The Visit decision already reserved her and
		# applied the thirty-day ggsm_house_rest modifier.
		name = ggsm.720.a
		wealth = -5

		event_target:ggsm_whore = {
			wealth = 5
		}

		# Stay on the male for the service sequence.
		long_character_event = {
			id = ggsm.732
		}
	}

	option = {
		# Leave without buying service.
		#
		# ggsm_house_rest remains until its thirty-day
		# modifier duration expires naturally.
		name = ggsm.720.d

		event_target:ggsm_whore = {
		}
	}
}


#######################################
# MALE VISITOR SERVICE SEQUENCE
#
# ROOT = male visitor
# event_target:ggsm_whore = sister
#
# These four events are continuation-only.
# Localization supplies the male perspective.
# No service choice is made here.
#######################################

long_character_event = {
	id = ggsm.732
	desc = ggsm.732.desc
	picture = GFX_event_nada7
	border = GFX_event_long_frame_religion
	is_triggered_only = yes

	trigger = {
		event_target:ggsm_whore = {
			is_alive = yes
			NOT = { trait = incapable }
		}
	}

	option = {
		name = ggsm.continue

		long_character_event = {
			id = ggsm.733
		}
	}
}


long_character_event = {
	id = ggsm.733
	desc = ggsm.733.desc
	picture = GFX_event_nada7
	border = GFX_event_long_frame_religion
	is_triggered_only = yes

	trigger = {
		event_target:ggsm_whore = {
			is_alive = yes
			NOT = { trait = incapable }
		}
	}

	option = {
		name = ggsm.continue

		long_character_event = {
			id = ggsm.734
		}
	}
}


long_character_event = {
	id = ggsm.734
	desc = ggsm.734.desc
	picture = GFX_event_nada7
	border = GFX_event_long_frame_religion
	is_triggered_only = yes

	trigger = {
		event_target:ggsm_whore = {
			is_alive = yes
			NOT = { trait = incapable }
		}
	}

	option = {
		name = ggsm.continue

		long_character_event = {
			id = ggsm.735
		}
	}
}


long_character_event = {
	id = ggsm.735
	desc = ggsm.735.desc
	picture = GFX_event_nada7
	border = GFX_event_long_frame_religion
	is_triggered_only = yes

	trigger = {
		event_target:ggsm_whore = {
			is_alive = yes
			NOT = { trait = incapable }
		}
	}

	option = {
		name = ggsm.continue

		# The service sequence is complete.
		# ROOT becomes the sister and FROM the male.
		event_target:ggsm_whore = {
			long_character_event = {
				id = ggsm.721
			}
		}
	}
}

#######################################
# THE SISTER STATES HER WISH
#
# ROOT = sister
# FROM = male visitor
#
# This is deliberately a real event on
# the woman. A player-controlled sister
# chooses for herself. An AI sister makes
# the same choice through ai_chance.
#######################################

long_character_event = {
	id = ggsm.721
	desc = ggsm.721.desc
	picture = GFX_event_nada7
	border = GFX_event_long_frame_religion
	is_triggered_only = yes

	trigger = {

		FROM = {
			is_alive = yes
			is_adult = yes
			is_female = no
		}
	}

	option = {
		# She wants him to finish inside.
		name = ggsm.721.a

		# Send the event back to the male.
		# ROOT becomes him and FROM becomes her.
		FROM = {
			long_character_event = { id = ggsm.722 }
		}

		ai_chance = {
			factor = 50
		}
	}

	option = {
		# She wants him to pull out.
		name = ggsm.721.b

		# Send the event back to the male.
		# ROOT becomes him and FROM becomes her.
		FROM = {
			long_character_event = { id = ggsm.724 }
		}

		ai_chance = {
			factor = 50
		}
	}
}


#######################################
# SHE WANTS HIM TO FINISH INSIDE
#
# ROOT = male
# FROM = sister
#
# SHARED HOUSE RULE:
# Work chain and male-visitor chain both arrive
# here. The divine office has no conception hook;
# only obedience to the sister's stated ending
# is adjudicated by these events.
#######################################

long_character_event = {
	id = ggsm.722
	desc = ggsm.722.inside.desc
	picture = GFX_event_nada7
	border = GFX_event_long_frame_religion
	is_triggered_only = yes

	trigger = {
		FROM = {
			is_alive = yes
			is_female = yes
		}
	}

	#######################################
	# OBEY: FINISH INSIDE
	#
	# This is a divine office of the Order.
	# The House does not roll pregnancy or
	# call Nada / WoL conception hooks.
	#######################################
	option = {
		name = ggsm.722.inside

		# Tell the sister that he obeyed.
		FROM = {
			long_character_event = { id = ggsm.726 }
		}

		ai_chance = {
			factor = 80

			modifier = {
				factor = 1.5
				trait = just
			}

			modifier = {
				factor = 1.25
				trait = kind
			}

			modifier = {
				factor = 1.25
				trait = humble
			}

			modifier = {
				factor = 1.25
				trait = temperate
			}
		}
	}

	#######################################
	# DISOBEY: PULL OUT
	#######################################
	option = {
		name = ggsm.722.outside

		# Visible punishment retains FROM = sister.
		repeat_event = { id = ggsm.723 }

		ai_chance = {
			factor = 15

			modifier = {
				factor = 2
				trait = arbitrary
			}

			modifier = {
				factor = 1.75
				trait = wroth
			}

			modifier = {
				factor = 1.5
				trait = proud
			}

			modifier = {
				factor = 1.5
				trait = cruel
			}

			modifier = {
				factor = 1.25
				trait = lustful
			}

			modifier = {
				factor = 0.5
				trait = just
			}

			modifier = {
				factor = 0.5
				trait = kind
			}

			modifier = {
				factor = 0.5
				trait = humble
			}
		}
	}

	#######################################
	# STOP
	#######################################
	option = {
		name = ggsm.722.stop

		# He does not violate her instruction.
		FROM = {
			long_character_event = { id = ggsm.727 }
		}

		ai_chance = {
			factor = 5

			modifier = {
				factor = 2
				trait = shy
			}

			modifier = {
				factor = 1.5
				trait = temperate
			}
		}
	}
}


#######################################
# VISIBLE PUNISHMENT
# HE PULLED OUT AFTER SHE ORDERED INSIDE
#
# ROOT = offending male
# FROM = wronged sister
#######################################

long_character_event = {
	id = ggsm.723
	desc = ggsm.723.desc
	picture = GFX_event_nada7
	border = GFX_event_long_frame_religion
	is_triggered_only = yes

	trigger = {
		FROM = {
			is_alive = yes
			is_female = yes
		}
	}

	immediate = {

		# She outranks him: secular treason.
		if = {
			limit = {
				FROM = {
					higher_tier_than = ROOT
				}
			}

			imprison = FROM
		}

		# Equal rank or he outranks her:
		# ecclesiastical punishment.
		if = {
			limit = {
				NOT = {
					FROM = {
						higher_tier_than = ROOT
					}
				}
			}

			excommunicate = yes
		}

		# If he outranks her, add public scandal
		# scaled by the landed-title difference.
		if = {
			limit = {
				higher_tier_than = FROM
			}

			# One tier.
			if = {
				limit = {
					OR = {
						AND = {
							tier = COUNT
							FROM = { tier = BARON }
						}
						AND = {
							tier = DUKE
							FROM = { tier = COUNT }
						}
						AND = {
							tier = KING
							FROM = { tier = DUKE }
						}
						AND = {
							tier = EMPEROR
							FROM = { tier = KING }
						}
					}
				}
				add_character_modifier = {
					name = ggsm_magdalene_scandal_1
					duration = 1825
				}
			}

			# Two tiers.
			if = {
				limit = {
					OR = {
						AND = {
							tier = DUKE
							FROM = { tier = BARON }
						}
						AND = {
							tier = KING
							FROM = { tier = COUNT }
						}
						AND = {
							tier = EMPEROR
							FROM = { tier = DUKE }
						}
					}
				}
				add_character_modifier = {
					name = ggsm_magdalene_scandal_2
					duration = 1825
				}
			}

			# Three tiers.
			if = {
				limit = {
					OR = {
						AND = {
							tier = KING
							FROM = { tier = BARON }
						}
						AND = {
							tier = EMPEROR
							FROM = { tier = COUNT }
						}
					}
				}
				add_character_modifier = {
					name = ggsm_magdalene_scandal_3
					duration = 1825
				}
			}

			# Four tiers.
			if = {
				limit = {
					tier = EMPEROR
					FROM = { tier = BARON }
				}
				add_character_modifier = {
					name = ggsm_magdalene_scandal_4
					duration = 1825
				}
			}
		}
	}

	option = {
		name = ggsm.723.a

		# The punishment has already landed in immediate.
		# Give the offending man his own result notice first.
		repeat_event = { id = ggsm.737 }
	}
}


#######################################
# SHE WANTS HIM TO FINISH OUTSIDE
#
# ROOT = male
# FROM = sister
#######################################

long_character_event = {
	id = ggsm.724
	desc = ggsm.722.outside.desc
	picture = GFX_event_nada7
	border = GFX_event_long_frame_religion
	is_triggered_only = yes

	trigger = {
		FROM = {
			is_alive = yes
			is_female = yes
		}
	}

	#######################################
	# OBEY: PULL OUT
	#
	# No conception hook exists in the House.
	# This is the clean completion she ordered.
	#######################################
	option = {
		name = ggsm.722.outside

		# Tell the sister that he obeyed.
		FROM = {
			long_character_event = { id = ggsm.728 }
		}

		ai_chance = {
			factor = 80

			modifier = {
				factor = 1.5
				trait = just
			}

			modifier = {
				factor = 1.25
				trait = kind
			}

			modifier = {
				factor = 1.25
				trait = humble
			}

			modifier = {
				factor = 1.25
				trait = temperate
			}
		}
	}

	#######################################
	# DISOBEY: FINISH INSIDE
	#
	# Still no pregnancy hook. The offense is
	# violation of the sister's stated order,
	# handled by the House / Church punishment.
	#######################################
	option = {
		name = ggsm.722.inside

		repeat_event = { id = ggsm.725 }

		ai_chance = {
			factor = 15

			modifier = {
				factor = 2
				trait = arbitrary
			}

			modifier = {
				factor = 1.75
				trait = wroth
			}

			modifier = {
				factor = 1.5
				trait = proud
			}

			modifier = {
				factor = 1.5
				trait = cruel
			}

			modifier = {
				factor = 1.25
				trait = lustful
			}

			modifier = {
				factor = 0.5
				trait = just
			}

			modifier = {
				factor = 0.5
				trait = kind
			}

			modifier = {
				factor = 0.5
				trait = humble
			}
		}
	}

	#######################################
	# STOP
	#######################################
	option = {
		name = ggsm.722.stop

		FROM = {
			long_character_event = { id = ggsm.729 }
		}

		ai_chance = {
			factor = 5

			modifier = {
				factor = 2
				trait = shy
			}

			modifier = {
				factor = 1.5
				trait = temperate
			}
		}
	}
}


#######################################
# VISIBLE PUNISHMENT
# HE FINISHED INSIDE AFTER SHE ORDERED OUTSIDE
#
# ROOT = offending male
# FROM = wronged sister
#######################################

long_character_event = {
	id = ggsm.725
	desc = ggsm.725.desc
	picture = GFX_event_nada7
	border = GFX_event_long_frame_religion
	is_triggered_only = yes

	trigger = {
		FROM = {
			is_alive = yes
			is_female = yes
		}
	}

	immediate = {

		# She outranks him: secular treason.
		if = {
			limit = {
				FROM = {
					higher_tier_than = ROOT
				}
			}

			imprison = FROM
		}

		# Equal rank or he outranks her:
		# ecclesiastical punishment.
		if = {
			limit = {
				NOT = {
					FROM = {
						higher_tier_than = ROOT
					}
				}
			}

			excommunicate = yes
		}

		# If he outranks her, add public scandal
		# scaled by the landed-title difference.
		if = {
			limit = {
				higher_tier_than = FROM
			}

			# One tier.
			if = {
				limit = {
					OR = {
						AND = {
							tier = COUNT
							FROM = { tier = BARON }
						}
						AND = {
							tier = DUKE
							FROM = { tier = COUNT }
						}
						AND = {
							tier = KING
							FROM = { tier = DUKE }
						}
						AND = {
							tier = EMPEROR
							FROM = { tier = KING }
						}
					}
				}
				add_character_modifier = {
					name = ggsm_magdalene_scandal_1
					duration = 1825
				}
			}

			# Two tiers.
			if = {
				limit = {
					OR = {
						AND = {
							tier = DUKE
							FROM = { tier = BARON }
						}
						AND = {
							tier = KING
							FROM = { tier = COUNT }
						}
						AND = {
							tier = EMPEROR
							FROM = { tier = DUKE }
						}
					}
				}
				add_character_modifier = {
					name = ggsm_magdalene_scandal_2
					duration = 1825
				}
			}

			# Three tiers.
			if = {
				limit = {
					OR = {
						AND = {
							tier = KING
							FROM = { tier = BARON }
						}
						AND = {
							tier = EMPEROR
							FROM = { tier = COUNT }
						}
					}
				}
				add_character_modifier = {
					name = ggsm_magdalene_scandal_3
					duration = 1825
				}
			}

			# Four tiers.
			if = {
				limit = {
					tier = EMPEROR
					FROM = { tier = BARON }
				}
				add_character_modifier = {
					name = ggsm_magdalene_scandal_4
					duration = 1825
				}
			}
		}
	}

	option = {
		name = ggsm.725.a

		# The punishment has already landed in immediate.
		# Give the offending man his own result notice first.
		repeat_event = { id = ggsm.738 }
	}
}




#######################################
# MALE RESULT: SHE ORDERED INSIDE
# HE PULLED OUT AND WAS PUNISHED
#
# ROOT = offending male
# FROM = wronged sister
#
# Punishment was already applied by .723.
# This screen tells the man what actually
# happened to him, then hands off to .730.
#######################################

long_character_event = {
	id = ggsm.737
	picture = GFX_event_nada7
	border = GFX_event_long_frame_religion
	is_triggered_only = yes

	desc = {
		trigger = {
			prisoner = yes
		}
		text = ggsm.737.imprisoned.desc
	}

	desc = {
		trigger = {
			prisoner = no
			trait = excommunicated
		}
		text = ggsm.737.excommunicated.desc
	}

	desc = {
		trigger = {
			prisoner = no
			NOT = { trait = excommunicated }
		}
		text = ggsm.737.desc
	}

	option = {
		name = ggsm.737.a

		FROM = {
			long_character_event = { id = ggsm.730 }
		}
	}
}


#######################################
# MALE RESULT: SHE ORDERED OUTSIDE
# HE FINISHED INSIDE AND WAS PUNISHED
#
# ROOT = offending male
# FROM = wronged sister
#
# Punishment was already applied by .725.
# This screen tells the man what actually
# happened to him, then hands off to .731.
#######################################

long_character_event = {
	id = ggsm.738
	picture = GFX_event_nada7
	border = GFX_event_long_frame_religion
	is_triggered_only = yes

	desc = {
		trigger = {
			prisoner = yes
		}
		text = ggsm.738.imprisoned.desc
	}

	desc = {
		trigger = {
			prisoner = no
			trait = excommunicated
		}
		text = ggsm.738.excommunicated.desc
	}

	desc = {
		trigger = {
			prisoner = no
			NOT = { trait = excommunicated }
		}
		text = ggsm.738.desc
	}

	option = {
		name = ggsm.738.a

		FROM = {
			long_character_event = { id = ggsm.731 }
		}
	}
}

#######################################
# SISTER RESULT: SHE ORDERED INSIDE
# HE OBEYED
#
# ROOT = sister
# FROM = male
#######################################

long_character_event = {
	id = ggsm.726
	desc = ggsm.726.desc
	picture = GFX_event_nada7
	border = GFX_event_long_frame_religion
	is_triggered_only = yes


	option = {
		name = ggsm.726.a
	}
}


#######################################
# SISTER RESULT: SHE ORDERED INSIDE
# HE STOPPED
#
# ROOT = sister
# FROM = male
#######################################

long_character_event = {
	id = ggsm.727
	desc = ggsm.727.desc
	picture = GFX_event_nada7
	border = GFX_event_long_frame_religion
	is_triggered_only = yes


	option = {
		name = ggsm.727.a
	}
}


#######################################
# SISTER RESULT: SHE ORDERED OUTSIDE
# HE OBEYED
#
# ROOT = sister
# FROM = male
#######################################

long_character_event = {
	id = ggsm.728
	desc = ggsm.728.desc
	picture = GFX_event_nada7
	border = GFX_event_long_frame_religion
	is_triggered_only = yes


	option = {
		name = ggsm.728.a
	}
}


#######################################
# SISTER RESULT: SHE ORDERED OUTSIDE
# HE STOPPED
#
# ROOT = sister
# FROM = male
#######################################

long_character_event = {
	id = ggsm.729
	desc = ggsm.729.desc
	picture = GFX_event_nada7
	border = GFX_event_long_frame_religion
	is_triggered_only = yes


	option = {
		name = ggsm.729.a
	}
}


#######################################
# SISTER RESULT: SHE ORDERED INSIDE
# HE DISOBEYED AND WAS PUNISHED
#
# ROOT = sister
# FROM = offending male
#######################################

long_character_event = {
	id = ggsm.730
	desc = ggsm.730.desc
	picture = GFX_event_nada7
	border = GFX_event_long_frame_religion
	is_triggered_only = yes


	option = {
		name = ggsm.730.a

		# Preserve ROOT = sister and FROM = offending male.
		repeat_event = { id = ggsm.736 }
	}
}


#######################################
# SISTER RESULT: SHE ORDERED OUTSIDE
# HE DISOBEYED AND WAS PUNISHED
#
# ROOT = sister
# FROM = offending male
#######################################

long_character_event = {
	id = ggsm.731
	desc = ggsm.731.desc
	picture = GFX_event_nada7
	border = GFX_event_long_frame_religion
	is_triggered_only = yes


	option = {
		name = ggsm.731.a

		# Preserve ROOT = sister and FROM = offending male.
		repeat_event = { id = ggsm.736 }
	}
}



#######################################
# PUNISHMENT RESULT NOTIFICATION
#
# ROOT = wronged sister
# FROM = offending male
#
# Called with repeat_event from ggsm.730
# or ggsm.731 so ROOT and FROM are kept.
#######################################

long_character_event = {
	id = ggsm.736
	picture = GFX_event_nada7
	border = GFX_event_long_frame_religion
	is_triggered_only = yes

	desc = {
		trigger = {
			FROM = {
				prisoner = yes
			}
		}
		text = ggsm.736.imprisoned.desc
	}

	desc = {
		trigger = {
			FROM = {
				prisoner = no
				trait = excommunicated
			}
		}
		text = ggsm.736.excommunicated.desc
	}

	desc = {
		trigger = {
			FROM = {
				prisoner = no
				NOT = { trait = excommunicated }
			}
		}
		text = ggsm.736.desc
	}

	option = {
		name = ggsm.736.a
	}
}

#######################################
# LOCALIZATION
#
# Intentionally not rewritten here.
#
# New keys required:
#
# Male result after .723:
# ggsm.737.imprisoned.desc
# ggsm.737.excommunicated.desc
# ggsm.737.desc
# ggsm.737.a
#
# Male result after .725:
# ggsm.738.imprisoned.desc
# ggsm.738.excommunicated.desc
# ggsm.738.desc
# ggsm.738.a
#
# Sister punishment result:
# ggsm.736.imprisoned.desc
# ggsm.736.excommunicated.desc
# ggsm.736.desc
# ggsm.736.a
#######################################
