code:
ie_consensual_sex_scene_orgasm_warning_giving = {
	type = character

	random_valid = yes

	# Straight / Gay / Futa

	text = {
		trigger = {
			OR = {
				carn_gender_can_impregnate_trigger = yes
				scope:second = { carn_gender_can_impregnate_trigger = yes }
			}
		}
		localization_key = ie_consensual_sex_scene.orgasm_male.warning_1_giving
	}

	text = {
		trigger = {
			OR = {
				carn_gender_can_impregnate_trigger = yes
				scope:second = { carn_gender_can_impregnate_trigger = yes }
			}
		}
		localization_key = ie_consensual_sex_scene.orgasm_male.warning_2_giving
	}

	text = {
		trigger = {
			OR = {
				carn_gender_can_impregnate_trigger = yes
				scope:second = { carn_gender_can_impregnate_trigger = yes }
			}
		}
		localization_key = ie_consensual_sex_scene.orgasm_male.warning_3_giving
	}

	# Lesbian

	text = {
		trigger = {
			carn_gender_can_impregnate_trigger = no
			scope:second = { carn_gender_can_impregnate_trigger = no }
		}
		localization_key = ie_consensual_sex_scene.orgasm_female.warning_1_giving
	}

	text = {
		trigger = {
			carn_gender_can_impregnate_trigger = no
			scope:second = { carn_gender_can_impregnate_trigger = no }
		}
		localization_key = ie_consensual_sex_scene.orgasm_female.warning_2_giving
	}

	text = {
		trigger = {
			carn_gender_can_impregnate_trigger = no
			scope:second = { carn_gender_can_impregnate_trigger = no }
		}
		localization_key = ie_consensual_sex_scene.orgasm_female.warning_3_giving
	}
}

ie_consensual_sex_scene_orgasm_warning_receiving = {
	type = character

	random_valid = yes

	# Straight / Gay / Futa

	text = {
		trigger = {
			OR = {
				carn_gender_can_impregnate_trigger = yes
				scope:second = { carn_gender_can_impregnate_trigger = yes }
			}
		}
		localization_key = ie_consensual_sex_scene.orgasm_male.warning_1_receiving
	}

	text = {
		trigger = {
			OR = {
				carn_gender_can_impregnate_trigger = yes
				scope:second = { carn_gender_can_impregnate_trigger = yes }
			}
		}
		localization_key = ie_consensual_sex_scene.orgasm_male.warning_2_receiving
	}

	text = {
		trigger = {
			OR = {
				carn_gender_can_impregnate_trigger = yes
				scope:second = { carn_gender_can_impregnate_trigger = yes }
			}
		}
		localization_key = ie_consensual_sex_scene.orgasm_male.warning_3_receiving
	}

	# Lesbian

	text = {
		trigger = {
			carn_gender_can_impregnate_trigger = no
			scope:second = { carn_gender_can_impregnate_trigger = no }
		}
		localization_key = ie_consensual_sex_scene.orgasm_female.warning_1_receiving
	}

	text = {
		trigger = {
			carn_gender_can_impregnate_trigger = no
			scope:second = { carn_gender_can_impregnate_trigger = no }
		}
		localization_key = ie_consensual_sex_scene.orgasm_female.warning_2_receiving
	}

	text = {
		trigger = {
			carn_gender_can_impregnate_trigger = no
			scope:second = { carn_gender_can_impregnate_trigger = no }
		}
		localization_key = ie_consensual_sex_scene.orgasm_female.warning_3_receiving
	}
}

ie_consensual_sex_scene_orgasm_inside_giving = {
	type = character

	random_valid = yes

	# Straight / Gay / Futa

	text = {
		trigger = {
			OR = {
				carn_gender_can_impregnate_trigger = yes
				scope:second = { carn_gender_can_impregnate_trigger = yes }
			}
		}
		localization_key = ie_consensual_sex_scene.orgasm_male.inside_1_giving
	}

	text = {
		trigger = {
			OR = {
				carn_gender_can_impregnate_trigger = yes
				scope:second = { carn_gender_can_impregnate_trigger = yes }
			}
		}
		localization_key = ie_consensual_sex_scene.orgasm_male.inside_2_giving
	}

	text = {
		trigger = {
			OR = {
				carn_gender_can_impregnate_trigger = yes
				scope:second = { carn_gender_can_impregnate_trigger = yes }
			}
		}
		localization_key = ie_consensual_sex_scene.orgasm_male.inside_3_giving
	}

	# Lesbian

	text = {
		trigger = {
			carn_gender_can_impregnate_trigger = no
			scope:second = { carn_gender_can_impregnate_trigger = no }
		}
		localization_key = ie_consensual_sex_scene.orgasm_female.1_giving
	}

	text = {
		trigger = {
			carn_gender_can_impregnate_trigger = no
			scope:second = { carn_gender_can_impregnate_trigger = no }
		}
		localization_key = ie_consensual_sex_scene.orgasm_female.2_giving
	}

	text = {
		trigger = {
			carn_gender_can_impregnate_trigger = no
			scope:second = { carn_gender_can_impregnate_trigger = no }
		}
		localization_key = ie_consensual_sex_scene.orgasm_female.3_giving
	}
}

ie_consensual_sex_scene_orgasm_inside_receiving = {
	type = character

	random_valid = yes

	# Straight / Gay / Futa

	text = {
		trigger = {
			OR = {
				carn_gender_can_impregnate_trigger = yes
				scope:second = { carn_gender_can_impregnate_trigger = yes }
			}
		}
		localization_key = ie_consensual_sex_scene.orgasm_male.inside_1_receiving
	}

	text = {
		trigger = {
			OR = {
				carn_gender_can_impregnate_trigger = yes
				scope:second = { carn_gender_can_impregnate_trigger = yes }
			}
		}
		localization_key = ie_consensual_sex_scene.orgasm_male.inside_2_receiving
	}

	text = {
		trigger = {
			OR = {
				carn_gender_can_impregnate_trigger = yes
				scope:second = { carn_gender_can_impregnate_trigger = yes }
			}
		}
		localization_key = ie_consensual_sex_scene.orgasm_male.inside_3_receiving
	}

	# Lesbian

	text = {
		trigger = {
			carn_gender_can_impregnate_trigger = no
			scope:second = { carn_gender_can_impregnate_trigger = no }
		}
		localization_key = ie_consensual_sex_scene.orgasm_female.1_receiving
	}

	text = {
		trigger = {
			carn_gender_can_impregnate_trigger = no
			scope:second = { carn_gender_can_impregnate_trigger = no }
		}
		localization_key = ie_consensual_sex_scene.orgasm_female.2_receiving
	}

	text = {
		trigger = {
			carn_gender_can_impregnate_trigger = no
			scope:second = { carn_gender_can_impregnate_trigger = no }
		}
		localization_key = ie_consensual_sex_scene.orgasm_female.3_receiving
	}
}

ie_consensual_sex_scene_orgasm_inside_aftermath_giving = {
	type = character

	random_valid = yes

	# Straight / Gay / Futa

	text = {
		trigger = {
			OR = {
				carn_gender_can_impregnate_trigger = yes
				scope:second = { carn_gender_can_impregnate_trigger = yes }
			}
		}
		localization_key = ie_consensual_sex_scene.orgasm_male.inside_aftermath_1_giving
	}

	text = {
		trigger = {
			OR = {
				carn_gender_can_impregnate_trigger = yes
				scope:second = { carn_gender_can_impregnate_trigger = yes }
			}
		}
		localization_key = ie_consensual_sex_scene.orgasm_male.inside_aftermath_2_giving
	}

	text = {
		trigger = {
			OR = {
				carn_gender_can_impregnate_trigger = yes
				scope:second = { carn_gender_can_impregnate_trigger = yes }
			}
		}
		localization_key = ie_consensual_sex_scene.orgasm_male.inside_aftermath_3_giving
	}

	# Lesbian

	text = {
		trigger = {
			carn_gender_can_impregnate_trigger = no
			scope:second = { carn_gender_can_impregnate_trigger = no }
		}
		localization_key = ie_consensual_sex_scene.orgasm_female.aftermath_1_giving
	}

	text = {
		trigger = {
			carn_gender_can_impregnate_trigger = no
			scope:second = { carn_gender_can_impregnate_trigger = no }
		}
		localization_key = ie_consensual_sex_scene.orgasm_female.aftermath_2_giving
	}

	text = {
		trigger = {
			carn_gender_can_impregnate_trigger = no
			scope:second = { carn_gender_can_impregnate_trigger = no }
		}
		localization_key = ie_consensual_sex_scene.orgasm_female.aftermath_3_giving
	}
}

ie_consensual_sex_scene_orgasm_inside_aftermath_receiving = {
	type = character

	random_valid = yes

	# Straight / Gay / Futa

	text = {
		trigger = {
			OR = {
				carn_gender_can_impregnate_trigger = yes
				scope:second = { carn_gender_can_impregnate_trigger = yes }
			}
		}
		localization_key = ie_consensual_sex_scene.orgasm_male.inside_aftermath_1_receiving
	}

	text = {
		trigger = {
			OR = {
				carn_gender_can_impregnate_trigger = yes
				scope:second = { carn_gender_can_impregnate_trigger = yes }
			}
		}
		localization_key = ie_consensual_sex_scene.orgasm_male.inside_aftermath_2_receiving
	}

	text = {
		trigger = {
			OR = {
				carn_gender_can_impregnate_trigger = yes
				scope:second = { carn_gender_can_impregnate_trigger = yes }
			}
		}
		localization_key = ie_consensual_sex_scene.orgasm_male.inside_aftermath_3_receiving
	}

	# Lesbian

	text = {
		trigger = {
			carn_gender_can_impregnate_trigger = no
			scope:second = { carn_gender_can_impregnate_trigger = no }
		}
		localization_key = ie_consensual_sex_scene.orgasm_female.aftermath_1_receiving
	}

	text = {
		trigger = {
			carn_gender_can_impregnate_trigger = no
			scope:second = { carn_gender_can_impregnate_trigger = no }
		}
		localization_key = ie_consensual_sex_scene.orgasm_female.aftermath_2_receiving
	}

	text = {
		trigger = {
			carn_gender_can_impregnate_trigger = no
			scope:second = { carn_gender_can_impregnate_trigger = no }
		}
		localization_key = ie_consensual_sex_scene.orgasm_female.aftermath_3_receiving
	}
}


code:
ie_consensual_sex_scene_missionary_part_1_giving = {
	type = character

	random_valid = yes

	text = {
		localization_key = ie_consensual_sex_scene.missionary.first_1_giving
	}

	text = {
		localization_key = ie_consensual_sex_scene.missionary.first_2_giving
	}

	text = {
		localization_key = ie_consensual_sex_scene.missionary.first_3_giving
	}

	text = {
		trigger = {
			has_trait = lustful
		}
		weight_multiplier = { base = 10 }
		localization_key = ie_consensual_sex_scene.missionary.first_lustful_giving
	}
}

ie_consensual_sex_scene_missionary_part_1_receiving = {
	type = character

	random_valid = yes

	text = {
		localization_key = ie_consensual_sex_scene.missionary.first_1_receiving
	}

	text = {
		localization_key = ie_consensual_sex_scene.missionary.first_2_receiving
	}

	text = {
		localization_key = ie_consensual_sex_scene.missionary.first_3_receiving
	}

	text = {
		trigger = {
			scope:second = { has_trait = lustful }
		}
		weight_multiplier = { base = 10 }
		localization_key = ie_consensual_sex_scene.missionary.first_lustful_receiving
	}
}

ie_consensual_sex_scene_missionary_part_2_giving = {
	type = character

	random_valid = yes

	text = {
		localization_key = ie_consensual_sex_scene.missionary.second_1_giving
	}

	text = {
		localization_key = ie_consensual_sex_scene.missionary.second_2_giving
	}

	text = {
		trigger = {
			OR = {
				carn_gender_can_impregnate_trigger = yes
				scope:second = { carn_gender_can_impregnate_trigger = yes }
			}
		}
		localization_key = ie_consensual_sex_scene.missionary.second_3_giving
	}

	text = {
		trigger = {
			carn_gender_can_impregnate_trigger = no
			scope:second = { carn_gender_can_impregnate_trigger = no }
		}
		localization_key = ie_consensual_sex_scene.missionary.second_3_giving_fem
	}

	text = {
		localization_key = ie_consensual_sex_scene.missionary.second_4_giving
	}
}

ie_consensual_sex_scene_missionary_part_2_receiving = {
	type = character

	random_valid = yes

	text = {
		localization_key = ie_consensual_sex_scene.missionary.second_1_receiving
	}

	text = {
		localization_key = ie_consensual_sex_scene.missionary.second_2_receiving
	}

	text = {
		trigger = {
			OR = {
				carn_gender_can_impregnate_trigger = yes
				scope:second = { carn_gender_can_impregnate_trigger = yes }
			}
		}
		localization_key = ie_consensual_sex_scene.missionary.second_3_receiving
	}

	text = {
		trigger = {
			carn_gender_can_impregnate_trigger = no
			scope:second = { carn_gender_can_impregnate_trigger = no }
		}
		localization_key = ie_consensual_sex_scene.missionary.second_3_receiving_fem
	}

	text = {
		localization_key = ie_consensual_sex_scene.missionary.second_4_receiving
	}
}

ie_consensual_sex_scene_missionary_part_3_giving = {
	type = character

	random_valid = yes

	text = {
		localization_key = ie_consensual_sex_scene.missionary.third_1_giving
	}

	text = {
		localization_key = ie_consensual_sex_scene.missionary.third_2_giving
	}

	text = {
		localization_key = ie_consensual_sex_scene.missionary.third_3_giving
	}
}

ie_consensual_sex_scene_missionary_part_3_receiving = {
	type = character

	random_valid = yes

	text = {
		localization_key = ie_consensual_sex_scene.missionary.third_1_receiving
	}

	text = {
		localization_key = ie_consensual_sex_scene.missionary.third_2_receiving
	}

	text = {
		localization_key = ie_consensual_sex_scene.missionary.third_3_receiving
	}
}

ie_consensual_sex_scene_missionary_part_4_giving = {
	type = character

	random_valid = yes

	text = {
		localization_key = ie_consensual_sex_scene.missionary.escalation_1_giving
	}

	text = {
		localization_key = ie_consensual_sex_scene.missionary.escalation_2_giving
	}

	text = {
		localization_key = ie_consensual_sex_scene.missionary.escalation_3_giving
	}

	text = {
		localization_key = ie_consensual_sex_scene.missionary.escalation_4_giving
	}
}

ie_consensual_sex_scene_missionary_part_4_receiving = {
	type = character

	random_valid = yes

	text = {
		localization_key = ie_consensual_sex_scene.missionary.escalation_1_receiving
	}

	text = {
		localization_key = ie_consensual_sex_scene.missionary.escalation_2_receiving
	}

	text = {
		localization_key = ie_consensual_sex_scene.missionary.escalation_3_receiving
	}

	text = {
		localization_key = ie_consensual_sex_scene.missionary.escalation_4_receiving
	}
}

license: unknown


code:
CulturalGiant = {
	type = character

	text = { # Jewish
		trigger = {
			OR = {
				faith = { religion_tag = judaism_religion }
				culture = { has_cultural_pillar = heritage_israelite }
			}
		}
		localization_key = ie_cultural_giant_nephilim
	}

	text = { # Arabic
		trigger = { culture = { has_cultural_pillar = heritage_arabic } }
		localization_key = ie_cultural_giant_jabbar
	}

	text = { # Brythonic
		trigger = { culture = { has_cultural_pillar = heritage_brythonic } }
		localization_key = ie_cultural_giant_cawr
	}

	text = { # Goidelic
		trigger = { culture = { has_cultural_pillar = heritage_goidelic } }
		localization_key = ie_cultural_giant_fomorian
	}

	text = { # Iberian
		trigger = { culture = { has_cultural_pillar = heritage_iberian } }
		localization_key = ie_cultural_giant_jentil
	}

	text = { # South Slavic
		trigger = { culture = { has_cultural_pillar = heritage_south_slavic } }
		localization_key = ie_cultural_giant_ispolin
	}

	text = { # Byzantine
		trigger = { culture = { has_cultural_pillar = heritage_byzantine } }
		localization_key = ie_cultural_giant_gigant
	}

	text = { # Indo-Aryan
		trigger = { culture = { has_cultural_pillar = heritage_indo_aryan } }
		localization_key = ie_cultural_giant_daitya
	}

	text = { # North Germanic / Scandinavian
		trigger = { culture = { has_cultural_pillar = heritage_north_germanic } }
		localization_key = ie_cultural_giant_jotunn
	}

	text = { # Dutch
		trigger = {
			OR = {
				culture = culture:frisian
				culture = culture:dutch
			}
		}
		localization_key = ie_cultural_giant_reus
	}

	text = { # Generic
		localization_key = ie_cultural_giant_giant
		fallback = yes
	}
}


code:
GenitalsInteraction = {
	type = character

	text = {
		trigger = {
			is_giving_partner_trigger = {
				PARTNER = scope:second
			}
		}
		localization_key = genitals_interaction_giving
	}

	text = {
		localization_key = genitals_interaction_receiving
	}
}

GenitalsInteractionWithName = {
	type = character

	text = {
		trigger = {
			is_giving_partner_trigger = {
				PARTNER = scope:second
			}
		}
		localization_key = genitals_interaction_giving
	}

	text = {
		localization_key = genitals_interaction_receiving_with_name
	}
}

# Example:
# "I [ROOT.Char.Custom2('GenitalsInteractionGiving', SCOPE.sC('second'))]."
GenitalsInteractionGiving = {
	type = character

	random_valid = yes

	text = {
		localization_key = genitals_interaction_penetrate_giving
	}

	text = {
		localization_key = genitals_interaction_enter_giving
	}

	text = {
		localization_key = genitals_interaction_push_giving
	}

	text = {
		localization_key = genitals_interaction_shove_giving
	}

	text = {
		localization_key = genitals_interaction_thrust_giving
	}

	text = {
		localization_key = genitals_interaction_plunge_giving
	}

	text = {
		localization_key = genitals_interaction_take_giving
	}

	text = {
		localization_key = genitals_interaction_fuck_giving
	}
}

# Example:
# "[second.GetSheHe|U] [ROOT.Char.Custom2('GenitalsInteractionReceiving', SCOPE.sC('second'))]."
GenitalsInteractionReceiving = {
	type = character

	random_valid = yes

	text = {
		localization_key = genitals_interaction_penetrate_receiving
	}

	text = {
		localization_key = genitals_interaction_enter_receiving
	}

	text = {
		localization_key = genitals_interaction_push_receiving
	}

	text = {
		localization_key = genitals_interaction_shove_receiving
	}

	text = {
		localization_key = genitals_interaction_thrust_receiving
	}

	text = {
		localization_key = genitals_interaction_plunge_receiving
	}

	text = {
		localization_key = genitals_interaction_take_receiving
	}

	text = {
		localization_key = genitals_interaction_fuck_receiving
	}
}


code:
breasts_chest = {
	type = character

	text = {
		trigger = { is_female = yes }
		localization_key = breasts
	}

	text = {
		trigger = { is_female = no }
		localization_key = chest
	}
}


code:
ie_host_orgy_decision = {
	picture = "gfx/interface/illustrations/decisions/decision_misc.dds"
	ai_check_interval = 60

	cost = {
		gold = {
			add = standard_activity_cost
			multiply = 1.25
		}
	}

	cooldown = { days = standard_orgy_cooldown_time }

	desc = ie_host_orgy_decision_desc
	selection_tooltip = ie_host_orgy_decision_tooltip

	is_shown = {
		always = no # Broken in CK1.11
		is_landed = yes
		highest_held_title_tier > tier_barony
		OR = {
			has_game_rule = ie_masked_orgy_player_and_ai
			has_game_rule = ie_masked_orgy_player_only
		}
	}

	is_valid_showing_failures_only = {
		is_available_adult = yes
	}

	effect = {
		capital_province = {
			spawn_activity = {
				type = ie_activity_orgy
				owner = root
			}
		}
	}

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 0
		has_game_rule = ie_masked_orgy_player_and_ai
		modifier = {
			add = 50
			short_term_gold > 300
			has_trait = lustful
		}
	}
}


code:
lustful_act_piety_impact_effect = {
	first = I_LUSTFUL_PIETY_IMPACT_GAIN
	first_neg = I_LUSTFUL_PIETY_IMPACT_LOSS
	third = THEY_LUSTFUL_PIETY_IMPACT_GAIN
	third_neg = THEY_LUSTFUL_PIETY_IMPACT_LOSS
	first_past = I_PAST_LUSTFUL_PIETY_IMPACT_GAIN
	first_neg_past = I_PAST_LUSTFUL_PIETY_IMPACT_LOSS
	third_past = THEY_PAST_LUSTFUL_PIETY_IMPACT_GAIN
	third_neg_past = THEY_PAST_LUSTFUL_PIETY_IMPACT_LOSS
	global = LUSTFUL_PIETY_IMPACT_GAIN
	global_neg = LUSTFUL_PIETY_IMPACT_LOSS
	global_past = PAST_LUSTFUL_PIETY_IMPACT_GAIN
	global_neg_past = PAST_LUSTFUL_PIETY_IMPACT_LOSS
}


code:
ie_cave = {
	background = {
		reference = "gfx/interface/illustrations/event_scenes/cave.dds"
		environment = "environment_event_tavern"
		ambience = "event:/SFX/Events/Backgrounds/corner_of_tavern"
	}
}

### BEDCHAMBER ###
### Fix for original ###
bedchamber = {
	background = {
		reference = "gfx/interface/illustrations/event_scenes/bedchamber.dds"
		environment = "environment_event_bedchamber"
		ambience = "event:/SFX/Events/Backgrounds/sittingroom_fireplace"
	}
}


code:
### Fix for original ###
seduction = {
	icon = {
		reference = "gfx/interface/icons/event_types/type_seduction.dds"
	}
	sound = {
		reference = "event:/SFX/Events/Themes/sfx_event_theme_type_seduction"
	}
	background = {
		reference = bedchamber
	}
}

seduce_scheme = {
	icon = {
		reference = "gfx/interface/icons/event_types/type_seduction.dds"
	}
	sound = {
		reference = "event:/SFX/Events/Themes/sfx_event_theme_type_seduction"
	}
	background = {
		reference = bedchamber
	}
}


code:
#ie_masked_orgy = {
#	default = ie_masked_orgy_player_and_ai
#	ie_masked_orgy_player_and_ai = { flag = GG_can_change_rule }
#	ie_masked_orgy_player_only = { flag = GG_can_change_rule }
#	ie_masked_orgy_disabled = { flag = GG_can_change_rule }
#}


code:
stimulated_modifier = {
	icon = fertility_positive
	fertility = 0.1
}

shy_in_bed_modifier = {
	icon = fertility_negative
	fertility = -0.1
}

slept_in_modifier = {
	icon = fertility_negative
	fertility = -0.1
}

early_bird_modifier = {
	icon = stewardship_positive
	stewardship = 2
}


code:
feast_default_event_selection = { #Picks out the event for a participant in a default feast
	random_events = {
		5 = ie_feast.1000
	}
}

feast_default_host_event_selection = { #Picks out the event for the host of a default feast
	random_events = {
		5 = ie_feast.1000
	}
}


code:
# For reference: Vanilla events have weight 100-200, and 2600 in total.
hunt_random_pulse = {
	random_events = {
		100 = ie_hunt.0001 # Quite the Catch. Some restrictions, but not moreso than vanilla events.
	}
}


code:
ie_orgy_event_selection = {
	trigger = {
		exists = scope:activity
	}
	random_events = {
		100 = ie_orgy.2000 # Random orgy event
		100 = ie_orgy.2001 # Revelation
	}
	fallback = ie_orgy_fallback
}

ie_orgy_fallback = {
	events = {
		ie_orgy.0001 # Try to end orgy if no relevant event was found
	}
}


code:
ie_carnal_court_sex_scenes_on_actions = {
	random_events = {
		100 = ie_carnal_court_sex_scene.0001
		100 = ie_carnal_court_sex_scene.0002
		100 = ie_carnal_court_sex_scene.0003
		100 = ie_carnal_court_sex_scene.0004
		100 = ie_carnal_court_sex_scene.0005
		100 = ie_carnal_court_sex_scene.0006
		100 = ie_carnal_court_sex_scene.0007
		100 = ie_carnal_court_sex_scene.0008
		100 = ie_carnal_court_sex_scene.0009
		100 = ie_carnal_court_sex_scene.0010
		100 = ie_carnal_court_sex_scene.0011
		100 = ie_carnal_court_sex_scene.0012
		100 = ie_carnal_court_sex_scene.0013
	}
}


code:
carn_sex_scene = {
	random_events = {
		300 = ie_consensual_sex_scene.0001 # 3 times as likely as the default Carnalitas scene
	}
}


code:
on_yearly_events = {
	random_events = {
		chance_to_happen = 25
		100 = ie_yearly.1000 # Late Night Visitor
		100 = ie_yearly.1010 # Dreaming Big
	}
}

on_16th_birthday = {
	events = {
		delay = { days = { 7 21 } }
		ie_coming_of_age.0001
	}
}


code:
friendship_ongoing = {
	# For reference: vanilla friendship events have weights 10-300, total 1200
	random_events = {
		10 = ie_friendship.0001 # Sharing everything. "Might become lover" event has weight 10, and this a bit more extreme. However, it also has harsher requirements.
	}
}


code:
sway_ongoing = {

	# For reference: vanilla events have weights 1-2, and 10 in total
    random_events = {
        10 = ie_sway_ongoing.0001 #Brave event. Chance needs to make up for our harsh restrictions, and it's usually <0.5 vanilla sway event per sway attempt anyway.
         5 = ie_sway_ongoing.0010 #Shy event. Can trigger both if you or the target is shy.
         5 = ie_sway_ongoing.0013 #Lazy event (you are lazy).
         5 = ie_sway_ongoing.0014 #Lazy event (spouse is lazy).
    }
}


code:
# For reference: Vanilla events have weight 50, and about 300 in total (400 if you also have a cat)
ongoing_dog_events = {
	random_events = {
		250 = ie_pet_animal.0001 # "A girl's best friend". 5x chance because of highly restricted trigger conditions.
	}
}


code:
######################
# ORGY STUFF
######################
standard_orgy_cooldown_time = 1825
min_default_orgy_events = 2
max_default_orgy_events = 3
chance_of_extra_orgy_events = 25

orgy_initial_event_delay = 3
min_orgy_event_spacing = 7
max_orgy_event_spacing = 14

max_orgy_duration = {
	value = max_orgy_event_spacing
	multiply = {
		value = max_default_orgy_events
		subtract = 1 # The first one starts quickly, as specified by orgy_initial_event_delay
	}
	add = orgy_initial_event_delay
	add = 1 # To be sure no values get set on the last tick
}


code:
ie_seductive_character_template = {
	age = { 18 35 }
	faith = root.faith
	culture = root.culture
	gender_female_chance = root_attraction_based_female_chance
	dynasty = none
	random_traits = no
	random_traits_list = {
		count = 1
		beauty_good_1 = {}
		beauty_good_2 = {}
		beauty_good_3 = {}
		seducer = { weight = { base = 2 } }
	}
	trait = lustful
	random_traits_list = {
		count = 2
		lunatic_1 = {}
		possessed_1 = {}
		beauty_good_1 = {}
		temperate = {
			trigger = {
				root.faith = {
					OR = {
						trait_is_sin = temperate
						NOT = { trait_is_virtue = temperate }
					}
				}
			}
		}
		greedy = {
			trigger = {
				root.faith = {
					OR = {
						trait_is_sin = greedy
						NOT = { trait_is_virtue = greedy }
					}
				}
			}
		}
		generous = {
			trigger = {
				root.faith = {
					OR = {
						trait_is_sin = generous
						NOT = { trait_is_virtue = generous }
					}
				}
			}
		}
		wrathful = {
			trigger = {
				root.faith = {
					OR = {
						trait_is_sin = wrathful
						NOT = { trait_is_virtue = wrathful }
					}
				}
			}
		}
		calm = {
			trigger = {
				root.faith = {
					OR = {
						trait_is_sin = calm
						NOT = { trait_is_virtue = calm }
					}
				}
			}
		}
		patient = {
			trigger = {
				root.faith = {
					OR = {
						trait_is_sin = patient
						NOT = { trait_is_virtue = patient }
					}
				}
			}
		}
		impatient = {
			trigger = {
				root.faith = {
					OR = {
						trait_is_sin = impatient
						NOT = { trait_is_virtue = impatient }
					}
				}
			}
		}
		arrogant = {
			trigger = {
				root.faith = {
					OR = {
						trait_is_sin = arrogant
						NOT = { trait_is_virtue = arrogant }
					}
				}
			}
		}
		deceitful = {
			trigger = {
				root.faith = {
					OR = {
						trait_is_sin = deceitful
						NOT = { trait_is_virtue = deceitful }
					}
				}
			}
		}
		brave = {
			trigger = {
				root.faith = {
					OR = {
						trait_is_sin = brave
						NOT = { trait_is_virtue = brave }
					}
				}
			}
		}
		ambitious = {
			trigger = {
				root.faith = {
					OR = {
						trait_is_sin = ambitious
						NOT = { trait_is_virtue = ambitious }
					}
				}
			}
		}
		arbitrary = {
			trigger = {
				root.faith = {
					OR = {
						trait_is_sin = arbitrary
						NOT = { trait_is_virtue = arbitrary }
					}
				}
			}
		}
		just = {
			trigger = {
				root.faith = {
					OR = {
						trait_is_sin = just
						NOT = { trait_is_virtue = just }
					}
				}
			}
		}
		paranoid = {
			trigger = {
				root.faith = {
					OR = {
						trait_is_sin = paranoid
						NOT = { trait_is_virtue = paranoid }
					}
				}
			}
		}
		callous = {
			trigger = {
				root.faith = {
					OR = {
						trait_is_sin = callous
						NOT = { trait_is_virtue = callous }
					}
				}
			}
		}
		sadistic = {
			trigger = {
				root.faith = {
					OR = {
						trait_is_sin = sadistic
						NOT = { trait_is_virtue = sadistic }
					}
				}
			}
		}
		stubborn = {
			trigger = {
				root.faith = {
					OR = {
						trait_is_sin = stubborn
						NOT = { trait_is_virtue = stubborn }
					}
				}
			}
		}
		fickle = {
			trigger = {
				root.faith = {
					OR = {
						trait_is_sin = fickle
						NOT = { trait_is_virtue = fickle }
					}
				}
			}
		}
		vengeful = {
			trigger = {
				root.faith = {
					OR = {
						trait_is_sin = vengeful
						NOT = { trait_is_virtue = vengeful }
					}
				}
			}
		}
	}
	random_traits_list = {
		count = 1
		education_intrigue_1  = {}
		education_intrigue_2  = {}
		education_intrigue_3  = {}
		education_intrigue_4  = {}
	}
	intrigue = {
		min_template_decent_skill
		max_template_decent_skill
	}
	after_creation = {
		# Make sure they don't have any of these traits
		remove_trait = shy
		remove_trait = chaste

		random_list = {
			40 = {}
			10 = {
				trigger = { trait_is_shunned_or_criminal_in_my_or_lieges_faith_trigger = { TRAIT = deviant GENDER_CHARACTER = root } }
				add_secret = { type = secret_deviant }
			}
			10 = {
				trigger = { NOT = { trait_is_shunned_or_criminal_in_my_or_lieges_faith_trigger = { TRAIT = deviant GENDER_CHARACTER = root } } }
				add_trait = deviant
			}
			10 = {
				trigger = { trait_is_shunned_or_criminal_in_my_or_lieges_faith_trigger = { TRAIT = witch GENDER_CHARACTER = root } }
				add_secret = { type = secret_witch }
			}
			10 = {
				trigger = { NOT = { trait_is_shunned_or_criminal_in_my_or_lieges_faith_trigger = { TRAIT = witch GENDER_CHARACTER = root } } }
				add_trait = witch
			}
		}
		random_list = {
			20 = {}
			20 = { add_trait = fecund }
			20 = {
				trigger = { is_female = yes }
				carn_add_tits_big_2_effect = yes
			}
			20 = {
				trigger = { is_female = yes }
				carn_add_tits_big_2_effect = yes
			}
			20 = {
				trigger = { is_female = yes }
				carn_add_tits_big_3_effect = yes
			}
			20 = {
				trigger = { is_male = yes }
				carn_add_dick_big_1_effect = yes
			}
			20 = {
				trigger = { is_male = yes }
				carn_add_dick_big_2_effect = yes
			}
			20 = {
				trigger = { is_male = yes }
				carn_add_dick_big_3_effect = yes
			}
		}
	}
}

ie_ugly_giant_template = {
	age = { 25 50 }
	faith = root.faith
	culture = root.culture
	gender_female_chance = root_attraction_based_female_chance
	dynasty = none

	trait = giant

	random_traits = yes

	random_traits_list = {
		physique_good_2 = {}
		physique_good_3 = {}
	}

	random_traits_list = {
		count = 1
		beauty_bad_2 = {}
		beauty_bad_3 = {}
	}

	random_traits_list = {
		count = 1
		lustful = {}
		fecund = {}
	}

	random_traits_list = {
		count = 1
		education_martial_1  = {}
		education_stewardship_1  = {}
		education_diplomacy_1  = {}
		education_intrigue_1  = {}
		education_learning_1  = {}
	}

	martial = {
		min_template_low_skill
		max_template_low_skill
	}
	stewardship = {
		min_template_low_skill
		max_template_low_skill
	}
	diplomacy = {
		min_template_low_skill
		max_template_low_skill
	}
	intrigue = {
		min_template_low_skill
		max_template_low_skill
	}
	learning = {
		min_template_low_skill
		max_template_low_skill
	}
	prowess = {
		min_template_decent_skill
		max_template_decent_skill
	}

	after_creation = {
		random_list = {
			50 = {
				trigger = { is_female = yes }
				carn_add_tits_big_2_effect = yes
			}
			50 = {
				trigger = { is_female = yes }
				carn_add_tits_big_3_effect = yes
			}
			50 = {
				trigger = { is_male = yes }
				carn_add_dick_big_2_effect = yes
			}
			50 = {
				trigger = { is_male = yes }
				carn_add_dick_big_3_effect = yes
			}
		}
	}
}


code:
# Gives a message "you lost/gained piety because lustful is sin/virtue"
# MUST be used with positive values for lustful as virtue, and negative for lustful as sin - there is no "you only lost/gained x piety"
lustful_act_piety_impact_effect = {
	if = {
		limit = {
			OR = {
				AND = {
					faith = { trait_is_sin = lustful }
					$IMPACT$ < 0
				}
				AND = {
					faith = { trait_is_virtue = lustful }
					$IMPACT$ > 0
				}
			}
		}
		hidden_effect = {
			add_piety = $IMPACT$
		}
		custom_description = {
			text = lustful_act_piety_impact_effect
			value = $IMPACT$
		}
	}
}


code:
ie_orgy_attire_effect = {
	carn_undress_character_effect = yes
	add_trait = ie_masked
}

ie_orgy_attire_remove_effect = {
	carn_dress_character_effect = yes
	remove_trait = ie_masked
}

ie_orgy_end_effect = {
	stress_impact = {
		base = medium_stress_loss
		lustful = medium_stress_impact_loss
		rakish = medium_stress_impact_loss
		gregarious = minor_stress_impact_loss
		shy = minor_stress_impact_gain
	}
}

ie_orgy_concluded_my_events_effect = {
	save_temporary_scope_as = finished_participant
	scope:activity = {
		add_to_variable_list = {
			name = finished_participants
			target = scope:finished_participant
		}
	}
}

ie_orgy_fire_random_event_effect = {
	trigger_event = {
		on_action = ie_orgy_event_selection
		days = { min_orgy_event_spacing max_orgy_event_spacing }
	}
}

ie_orgy_wrap_up_or_fire_random_event_effect = {
	if = {
		limit = {
			NOT = { exists = local_var:num_of_orgy_events }
		}
		set_local_variable = {
			name = num_of_orgy_events
			value = 1
		}
		ie_orgy_fire_random_event_effect = yes
	}
	else = {
		change_local_variable = {
			name = num_of_orgy_events
			add = 1
		}
		if = {
			limit = { # Check the number of events fired
				local_var:num_of_orgy_events < max_default_orgy_events
			}
			# If below the max number check whether to fire more
			if = {
				limit = {
					local_var:num_of_orgy_events >= min_default_orgy_events
				}
				random_list = {
					0 = {
						modifier = { add = chance_of_extra_orgy_events }
						ie_orgy_fire_random_event_effect = yes
					}
					100 = {
						modifier = {
							add = {
								subtract = chance_of_extra_orgy_events
							}
						}
						ie_orgy_concluded_my_events_effect = yes
					}
				}
			}
			else = {
				ie_orgy_fire_random_event_effect = yes
			}
		}
		else = {
			ie_orgy_concluded_my_events_effect = yes
		}
	}
}

#############
# Sometimes there just isn't any guest our character is interested in, then we
# need to hire a professional.
#############
ie_orgy_generate_prostitute_effect = {
	debug_log_scopes = yes
	create_character = {
		location = scope:activity.activity_location
		faith = scope:activity.activity_location.county.faith
		culture = scope:activity.activity_location.county.culture
		template = ie_seductive_character_template
		dynasty = none
		save_temporary_scope_as = prostitute
	}
	scope:prostitute = {
		set_sexuality = bisexual
	}

	scope:prostitute = {
		if = {
			limit = {
				OR = {
					has_game_rule = carn_prostitution_content_any_gender
					AND = {
						is_male = yes
						has_game_rule = carn_prostitution_content_male_only
					}
					AND = {
						is_female = yes
						has_game_rule = carn_prostitution_content_female_only
					}
				}
			}
			carn_start_working_as_prostitute_effect = yes
		}
		if = {
			limit = {
				root = { is_attracted_to_gender_of = scope:prostitute }
				NOT = { is_attracted_to_gender_of = root }
			}
			random_list = {
				75 = {
					set_sexuality = bisexual
				}
				25 = {
					if = {
						limit = {
							sex_same_as = root
						}
						set_sexuality = homosexual
					}
					else = {
						set_sexuality = heterosexual
					}
				}
			}
		}
		ie_orgy_attire_effect = yes
	}
}


code:
# Brave event chain starting at 0001
sway_ongoing_0001_failure_effect = {
	$OTHER$ = { save_scope_as = sex_partner }

	send_interface_toast = {
		title = ie_sway_ongoing.0003.a_failure

		# Faith is ok with that
		if = {
			limit = {
				faith = { trait_is_virtue = lustful }
			}
			custom_tooltip = ie_sway_ongoing.0003.a_lustful_is_virtue
		}
		# Faith hates it!
		else_if = {
			limit = {
				faith = { trait_is_sin = lustful }
			}
			lustful_act_piety_impact_effect = {
				IMPACT = major_piety_loss
			}
		}
		# Faith is undecided (probably against)
		else = {
			add_piety = medium_piety_loss
		}
	}
	# Might expose adultery secret

	if = {
		# Only show chance if something can be exposed
		limit = {
			OR = {
				relation_with_character_is_incestuous_in_my_or_lieges_faith_trigger = { CHARACTER = scope:sex_partner }
				relation_with_character_is_sodomy_in_my_or_lieges_faith_trigger = { CHARACTER = scope:sex_partner}
				has_relation_lover = scope:sex_target
			}
		}
		random = {
			chance = 50
			extramarital_sex_exposure_consequences_with_target_effect = { TARGET = scope:sex_partner SPOUSE_EVENT = no }
		}
	}

}


code:
ie_can_join_orgy = {
	is_available_for_activity_trigger = yes
	OR = {
		any_secret = { secret_type = secret_deviant }
		any_secret = { secret_type = secret_lover }
		any_secret = { secret_type = secret_witch }
		has_trait = deviant
		has_trait = lustful
		has_trait = rakish
		has_trait = adulterer
		has_trait = fornicator
	}
	NOT = {
		any_in_list = {
			list = potential_guests
			this = prev
		}
	}
}


code:
is_negative_opinion = {
	has_personality_malicious_trigger = yes
	opinion = {
		target = scope:second
		value < -25
	}
}

is_negative_reverse_opinion = {
	scope:second = { has_personality_malicious_trigger = yes }
	reverse_opinion = {
		target = scope:second
		value < -25
	}
}


code:
is_giving_partner_trigger = {
	OR = {
		AND = { # Straight sex
			carn_gender_can_impregnate_trigger = yes
			$PARTNER$ = { carn_gender_can_impregnate_trigger = no }
		}
		AND = { # Lesbian sex, player always giver
			carn_gender_can_impregnate_trigger = no
			$PARTNER$ = { carn_gender_can_impregnate_trigger = no }
			is_ai = no
		}
		AND = { # Gay/Futa sex, player always giver
			carn_gender_can_impregnate_trigger = yes
			$PARTNER$ = { carn_gender_can_impregnate_trigger = yes }
			is_ai = no
		}
	}
}

is_receiving_partner_trigger = {
	OR = {
		AND = { # Straight sex
			carn_gender_can_impregnate_trigger = no
			$PARTNER$ = { carn_gender_can_impregnate_trigger = yes }
		}
		AND = { # Lesbian sex, AI always receiver
			carn_gender_can_impregnate_trigger = no
			$PARTNER$ = { carn_gender_can_impregnate_trigger = no }
			is_ai = yes
		}
		AND = { # Gay/Futa sex, AI always receiver
			carn_gender_can_impregnate_trigger = yes
			$PARTNER$ = { carn_gender_can_impregnate_trigger = yes }
			is_ai = yes
		}
	}
}


code:
ie_masked = {
	index = 111

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					NOT = { exists = this }
				}
				desc = trait_ie_masked_desc
			}
			desc = trait_ie_masked_character_desc
		}
	}
}


code:
ie_character_is_already_naked = {
	first_not = I_AM_ALREADY_NAKED
	third_not = THEY_ARE_ALREADY_NAKED
}


code:
version="0.4.0"
tags={
	"Character Interactions"
	"Events"
}
name="Intimate Encounters"
supported_version="1.11.*"


code:
namespace = ie_feast

scripted_effect ie_feast_1000_outcome_effect = {
	stress_impact = {
		deviant = minor_stress_loss
		lustful = minor_stress_loss
		seducer = minor_stress_loss
	}

	send_interface_toast = {
		title = ie_feast.1000.t
		left_icon = scope:stranger

		add_courtier = scope:stranger
		set_relation_lover = scope:stranger
	}
}

scripted_effect ie_feast_1000_outcome_random_effect = {
	stress_impact = {
		deviant = minor_stress_loss
		lustful = minor_stress_loss
		seducer = minor_stress_loss
	}

	random_list = {
		90 = {

		}
		10 = {
			send_interface_toast = {
				title = ie_feast.1000.t
				left_icon = scope:stranger

				add_courtier = scope:stranger
			}
		}
	}
}

# The Morning After
ie_feast.1000 = {
	type = character_event
	title = ie_feast.1000.t
	desc = ie_feast.1000.desc

	theme = feast_activity
	override_background = {
		event_background = bedchamber
	}

	left_portrait = {
		character = root
		animation = personality_compassionate
	}

	trigger = {
		is_ai = no
		is_capable_adult = yes # ...but children cannot attend feasts anyway.
		is_healthy = yes
		NOR = {
			exists = local_var:ie_had_1000
			has_trait = shy
			has_trait = chaste
			has_sexuality = asexual
			has_game_rule = carn_content_consent_always
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 2
			has_trait = drunkard
		}
	}

	immediate = {
		set_local_variable = {
			name = ie_had_1000
			value = yes
		}
	}

	option = {
		name = ie_feast.1000.a
		trigger_event = ie_feast.1001
	}
}

ie_feast.1001 = {
	type = character_event
	title = ie_feast.1000.t
	desc = ie_feast.1001.desc

	theme = feast_activity
	override_background = {
		event_background = bedchamber
	}

	left_portrait = {
		character = scope:stranger
		animation = flirtation_left
	}

	immediate = {
		hidden_effect = {
			# Generate character
			create_character = {
				location = scope:activity.activity_location
				faith = scope:activity.activity_location.county.faith
				culture = scope:activity.activity_location.county.culture
				gender_female_chance = root_attraction_based_female_chance
				template = ie_seductive_character_template
				dynasty = none
				save_scope_as = stranger
			}

			scope:stranger = {
				carn_undress_character_effect = yes
			}
			random_list = {
				50 = {
					trigger = {
						OR = {
							AND = {
								scope:stranger = { is_female = yes }
								root = { is_male = yes }
							}
							AND = {
								scope:stranger = { is_male = yes }
								root = { is_female = yes }
							}
						}
					}
					scope:stranger = { set_sexuality = heterosexual }
				}
				50 = {
					trigger = {
						OR = {
							AND = {
								scope:stranger = { is_male = yes }
								root = { is_male = yes }
							}
							AND = {
								scope:stranger = { is_female = yes }
								root = { is_female = yes }
							}
						}
					}
					scope:stranger = { set_sexuality = homosexual }
				}
				50 = { scope:stranger = { set_sexuality = bisexual } }
			}
		}
	}

	option = {
		name = {
			text = {
				desc = ie_feast.1001.a
				triggered_desc = {
					trigger = {
						OR = {
							any_consort = {
								count >= 1
							}
							any_relation = {
								type = lover
								count >= 1
							}
						}
					}
					desc = ie_feast.1001.a.spouse
				}
			}
		}

		custom_tooltip = ie_feast.1001.a.tt

		add_piety = medium_piety_gain

		stress_impact = {
			deviant = medium_stress_gain
			lustful = medium_stress_gain
			seducer = medium_stress_gain
		}

		stress_impact = {
			chaste = minor_stress_loss
			content = minor_stress_loss
			lazy = minor_stress_loss
			humble = minor_stress_loss
			temperate = minor_stress_loss
			zealous = minor_stress_loss
		}
	}

	option = {
		name = ie_feast.1001.b

		show_as_tooltip = {
			carn_had_sex_with_effect = {
				CHARACTER_1 = root
				CHARACTER_2 = scope:stranger
				C1_PREGNANCY_CHANCE = pregnancy_chance
				C2_PREGNANCY_CHANCE = pregnancy_chance
				STRESS_EFFECTS = yes
				DRAMA = yes
			}

			ie_feast_1000_outcome_random_effect = yes
		}

		hidden_effect = {
			set_local_variable = {
				name = ie_feast_1001_randomize_outcome
				value = yes
			}

			trigger_event = {
				id = ie_feast.1010
				days = 1
			}
		}
	}

	option = {
		name = ie_feast.1001.c

		show_as_tooltip = {
			carn_had_sex_with_effect = {
				CHARACTER_1 = root
				CHARACTER_2 = scope:stranger
				C1_PREGNANCY_CHANCE = pregnancy_chance
				C2_PREGNANCY_CHANCE = pregnancy_chance
				STRESS_EFFECTS = yes
				DRAMA = yes
			}

			ie_feast_1000_outcome_effect = yes
		}

		hidden_effect = {
			set_local_variable = {
				name = ie_feast_1001_randomize_outcome
				value = no
			}

			trigger_event = {
				id = ie_feast.1010
				days = 1
			}
		}
	}

	after = {
		scope:stranger = {
			carn_dress_character_effect = yes
		}
	}
}

ie_feast.1010 = {
	# This is a maintenance necessary to fix characters being dressed during the sex scene
	hidden = yes

	immediate = {
		hidden_effect = {
			carn_sex_scene_request_consensual = yes

			carn_sex_scene_effect = {
				PLAYER = root
				TARGET = scope:stranger
				STRESS_EFFECTS = yes
				DRAMA = yes
			}

			if = {
				limit = { local_var:ie_feast_1001_randomize_outcome = yes }
				ie_feast_1000_outcome_random_effect = yes
			}
			else = {
				ie_feast_1000_outcome_effect = yes
			}
		}
	}
}


code:
namespace = ie_hunt

scripted_trigger ie_hunt_0001_lesbian_selection = {
	NOT = { is_spouse_of = root }
	is_alive = yes
	is_female = yes
	is_available_healthy_ai_adult = yes # Ironically, those that are selected as "real" participants for the hunt probably won't be available. Oh well.
	this.age <= 50
	OR = { # Logically, should be AND, but I'm afraid of restricting the target pool a bit too much.
		might_cheat_on_every_partner_trigger = yes
		has_sexuality = bisexual
		has_sexuality = homosexual
	}
}

# We don't use potential_hunt_participants, it's a bit too restrictive to find two lesbians by chance.
scripted_effect ie_hunt_0001_find_lesbians = {
	every_vassal_or_below = {
		every_spouse = {
			add_to_temporary_list = potential_hunt_participants_custom
		}
		add_to_temporary_list = potential_hunt_participants_custom
	}
	every_in_list  = {
		list = potential_hunt_participants_custom
		limit = { ie_hunt_0001_lesbian_selection = yes }
		add_to_temporary_list = lesbians
	}
	random_in_list = {
		list = lesbians
		weight = {
			base = 1
			modifier = {
				might_cheat_on_every_partner_trigger = yes
				factor = 3
			}
			modifier = {
				OR = {
					has_sexuality = bisexual
					has_sexuality = homosexual
				}
				factor = 5
			}
		}
		save_scope_as = lesbian_1
	}
	# Find a partner fitting for the first one
	random_in_list = {
		list = lesbians
		limit = {
			NOT = { this = scope:lesbian_1 }
		}
		weight = {
			base = 100

			# Add opinion to and from target
			opinion_modifier = {
				opinion_target = scope:lesbian_1
				multiplier = 0.5
			}
			opinion_modifier = {
				who = scope:lesbian_1
				opinion_target = this
				multiplier = 0.5
			}
			# Age difference penalty
			modifier = {
				add = {
					value = age
					subtract = scope:lesbian_1.age
					multiply = -2
					min = 0
				}
			}
			modifier = {
				add = {
					value = scope:lesbian_1.age
					subtract = age
					multiply = 2
					min = 0
				}
			}

			modifier = {
				might_cheat_on_every_partner_trigger = yes
				factor = 3
			}
			modifier = {
				OR = {
					has_sexuality = bisexual
					has_sexuality = homosexual
				}
				factor = 5
			}
			modifier = {
				OR = {
					has_relation_lover = scope:lesbian_1
					has_relation_soulmate = scope:lesbian_1
				}
				factor = 10
			}
		}
		save_scope_as = lesbian_2
	}

}

# "Quite the Catch"
ie_hunt.0001 = {
	type = character_event
	title = ie_hunt.0001.t
	desc = {
		desc = ie_hunt.0001.desc
		triggered_desc = {
			trigger = {
				is_attracted_to_gender_of = scope:lesbian_1
			}
			desc = ie_hunt.0001.desc.optional
		}

	}
	theme = hunt_activity
	left_portrait = {
		character = scope:lesbian_1
		animation = flirtation_left

	}
	right_portrait = {
		character = scope:lesbian_2
		animation = flirtation
	}

	trigger = {
		is_ai = no
		is_capable_adult = yes # ...but children cannot go hunting anyway
		is_healthy = yes
		OR = {
			# This is a bit ridiculous, but I don't know a more elegant solution to check multiple or custom lists at the same time.
			# Luckily I need to find only 2 characters in total from 2 "lists" and not 4 characters in 3 lists...
			any_vassal_or_below = {
				count > 1
				any_spouse = {
					ie_hunt_0001_lesbian_selection = yes
				}
			}
			any_vassal_or_below = {
				count > 1
				ie_hunt_0001_lesbian_selection = yes
			}
			AND = {
				any_vassal_or_below = {
					count = 1
					any_spouse = {
						ie_hunt_0001_lesbian_selection = yes
					}
				}
				any_vassal_or_below = {
					count = 1
					ie_hunt_0001_lesbian_selection = yes
				}
			}
		}
	}

	immediate = {
		ie_hunt_0001_find_lesbians = yes

		if = {
			limit = {
				is_attracted_to_gender_of = scope:lesbian_1
			}
			caf_add_arousal = { VALUE = caf_medium_arousal_gain }
		}

		hidden_effect = {
			scope:lesbian_1 = { set_relation_lover = scope:lesbian_2 }
		}
		scope:lesbian_1 = {
			random_secret = {
				limit = {
					secret_type = secret_lover
					secret_target = scope:lesbian_2
				}
				reveal_to = root
			}
			add_character_flag = single_combat_stripped_to_waist
		}
		scope:lesbian_2 = {
			add_character_flag = wearing_cbo_panties
		}
	}

	option = { # Offer to join
		name = ie_hunt.0001.a
		custom_tooltip = ie_hunt.0001.a.tt

		if = {
			limit = {
				OR = {
					scope:lesbian_1 = { is_attracted_to_gender_of = root }
					scope:lesbian_2 = { is_attracted_to_gender_of = root }
				}
				# The more they like you, the less hot you have to be (1:1 ratio)
				scope:lesbian_1 = {
					opinion = {
						target = root
						value >= {
							value = root.attraction
							multiply = -1
						}
					}
				}
				scope:lesbian_2 = {
					opinion = {
						target = root
						value >= {
							value = root.attraction
							multiply = -1
						}
					}
				}
			}
			trigger_event = {
				id = ie_hunt.0003 # Ok!
				days = { 1 3 }
			}
		}
		else_if = {
			limit = {
				OR = {
					NOR = {
						scope:lesbian_1 = { is_attracted_to_gender_of = root }
						scope:lesbian_2 = { is_attracted_to_gender_of = root }
					}
					AND = {
						scope:lesbian_1 = {
							opinion = {
								target = root
								value < low_negative_opinion
							}
						}
						scope:lesbian_2 = {
							opinion = {
								target = root
								value < low_negative_opinion
							}
						}
					}
				}
				NOR = {
					scope:lesbian_1 = {
						has_dread_level_towards = {
							target = root
							level >= 1
						}
					}
					scope:lesbian_2 = {
						has_dread_level_towards = {
							target = root
							level >= 1
						}
					}
				}
			}
			trigger_event = {
				id = ie_hunt.0002 # Never!
				days = { 1 3 }
			}
		}
		else = {
			trigger_event = {
				id = ie_hunt.0004 # Run!
				days = { 1 3 }
			}
		}

		stress_impact = {
			chaste = medium_stress_impact_gain
			shy = medium_stress_impact_gain
		}
	}

	option = { # Leave
		name = ie_hunt.0001.b
		custom_tooltip = ie_hunt.0001.b.tt

		trigger_event = {
			id = hunt.9001 #To complete the activity
			days = { 14 20 }
		}

		stress_impact = {
			lustful = medium_stress_impact_gain
			shy = medium_stress_impact_loss
		}
	}

	option = { # Expose secrets
		name = ie_hunt.0001.c

		trigger = {
			OR = {
				scope:lesbian_1 = { relation_with_character_is_sodomy_in_my_or_lieges_faith_trigger = { CHARACTER = scope:lesbian_2 } }
				scope:lesbian_1 = { relation_with_character_is_incestuous_in_my_or_lieges_faith_trigger = { CHARACTER = scope:lesbian_2 } }
				scope:lesbian_1 = {
					AND = {
						is_married = yes
						trait_is_shunned_or_criminal_in_my_or_lieges_faith_trigger = { TRAIT = adulterer GENDER_CHARACTER = scope:lesbian_1 }
					}
				}
				scope:lesbian_2 = { relation_with_character_is_sodomy_in_my_or_lieges_faith_trigger = { CHARACTER = scope:lesbian_1 } }
				scope:lesbian_2 = { relation_with_character_is_incestuous_in_my_or_lieges_faith_trigger = { CHARACTER = scope:lesbian_1 } }
				scope:lesbian_2 = {
					AND = {
						is_married = yes
						trait_is_shunned_or_criminal_in_my_or_lieges_faith_trigger = { TRAIT = adulterer GENDER_CHARACTER = scope:lesbian_2 }
					}
				}
			}
		}

		scope:lesbian_1 = {
			extramarital_sex_attempt_exposure_consequences_with_target_effect = {
				TARGET = scope:lesbian_2
				SPOUSE_EVENT = yes
			}
		}
		scope:lesbian_2 = {
			extramarital_sex_attempt_exposure_consequences_with_target_effect = {
				TARGET = scope:lesbian_1
				SPOUSE_EVENT = yes
			}
		}

		trigger_event = {
			id = hunt.9001 #To complete the activity
			days = { 14 20 }
		}

		stress_impact = {
			lustful = medium_stress_impact_gain
			zealous = medium_stress_impact_loss
			generous = medium_stress_impact_gain
			compassionate = major_stress_impact_gain
		}
	}
	after = {
		scope:lesbian_1 = {
			remove_character_flag = single_combat_stripped_to_waist
		}
		scope:lesbian_2 = {
			remove_character_flag = wearing_cbo_panties
		}
	}
}

# "Quite the Catch" (cont.)
ie_hunt.0002 = {
	type = character_event
	title = ie_hunt.0001.t
	desc = ie_hunt.0002.desc
	theme = hunt_activity
	left_portrait = {
		character = scope:lesbian_1
		animation = flirtation_left
	}
	right_portrait = {
		character = scope:lesbian_2
		animation = flirtation
	}

	immediate = {
		add_stress = minor_stress_gain

		change_variable = {
			name = hunt_outcome
			add = -1
		}
	}

	option = { # Expose secrets
		name = ie_hunt.0002.a

		trigger = {
			OR = {
				scope:lesbian_1 = { relation_with_character_is_sodomy_in_my_or_lieges_faith_trigger = { CHARACTER = scope:lesbian_2 } }
				scope:lesbian_1 = { relation_with_character_is_incestuous_in_my_or_lieges_faith_trigger = { CHARACTER = scope:lesbian_2 } }
				scope:lesbian_1 = {
					AND = {
						is_married = yes
						trait_is_shunned_or_criminal_in_my_or_lieges_faith_trigger = { TRAIT = adulterer GENDER_CHARACTER = scope:lesbian_1 }
					}
				}
				scope:lesbian_2 = { relation_with_character_is_sodomy_in_my_or_lieges_faith_trigger = { CHARACTER = scope:lesbian_1 } }
				scope:lesbian_2 = { relation_with_character_is_incestuous_in_my_or_lieges_faith_trigger = { CHARACTER = scope:lesbian_1 } }
				scope:lesbian_2 = {
					AND = {
						is_married = yes
						trait_is_shunned_or_criminal_in_my_or_lieges_faith_trigger = { TRAIT = adulterer GENDER_CHARACTER = scope:lesbian_2 }
					}
				}
			}
		}

		scope:lesbian_1 = {
			extramarital_sex_attempt_exposure_consequences_with_target_effect = {
				TARGET = scope:lesbian_2
				SPOUSE_EVENT = yes
			}
		}
		scope:lesbian_2 = {
			extramarital_sex_attempt_exposure_consequences_with_target_effect = {
				TARGET = scope:lesbian_1
				SPOUSE_EVENT = yes
			}
		}

		trigger_event = {
			id = hunt.9001 #To complete the activity
			days = { 14 20 }
		}

		stress_impact = {
			zealous = medium_stress_impact_loss
			compassionate = major_stress_impact_gain
			calm = major_stress_impact_gain
		}
	}

	option = { # Leave them be
		name = ie_hunt.0002.b

		trigger_event = {
			id = hunt.9001 #To complete the activity
			days = { 14 20 }
		}

		stress_impact = {
			vengeful = major_stress_impact_gain
			wrathful = major_stress_impact_gain
		}
	}
}

# "Quite the Catch" (cont.)
ie_hunt.0003 = {
	type = character_event
	title = ie_hunt.0001.t
	desc = ie_hunt.0003.desc
	theme = hunt_activity
	left_portrait = {
		character = scope:lesbian_1
		animation = flirtation_left
	}
	right_portrait = {
		character = scope:lesbian_2
		animation = flirtation
	}

	immediate = {
		scope:lesbian_1 = { carn_undress_character_effect = yes }
		scope:lesbian_2 = { carn_undress_character_effect = yes }
		if = {
			limit = {
				scope:lesbian_1 = { is_attracted_to_gender_of = root }
			}
			carn_had_sex_with_effect = {
				CHARACTER_1 = root
				CHARACTER_2 = scope:lesbian_1
				C1_PREGNANCY_CHANCE = pregnancy_chance
				C2_PREGNANCY_CHANCE = pregnancy_chance
				STRESS_EFFECTS = yes
				DRAMA = yes
			}
		}
		if = {
			limit = {
				scope:lesbian_2 = { is_attracted_to_gender_of = root }
			}
			carn_had_sex_with_effect = {
				CHARACTER_1 = root
				CHARACTER_2 = scope:lesbian_2
				C1_PREGNANCY_CHANCE = pregnancy_chance
				C2_PREGNANCY_CHANCE = pregnancy_chance
				STRESS_EFFECTS = yes
				DRAMA = yes
			}
		}
		change_variable = {
			name = hunt_outcome
			add = 3
		}
	}

	option = { # Make it a regular thing
		name = ie_hunt.0003.a
		if = {
			limit = {
				scope:lesbian_1 = { is_attracted_to_gender_of = root }
			}
			set_relation_lover = scope:lesbian_1
		}
		if = {
			limit = {
				scope:lesbian_2 = { is_attracted_to_gender_of = root }
			}
			set_relation_lover = scope:lesbian_2
		}
	}

	option = { # One-time distraction
		name = ie_hunt.0003.b
	}

	after = {
		scope:lesbian_1 = { carn_dress_character_effect = yes }
		scope:lesbian_2 = { carn_dress_character_effect = yes }
		trigger_event = {
			id = hunt.9001 #To complete the activity
			days = { 14 20 }
		}
	}
}

# "Quite the Catch" (cont.)
ie_hunt.0004 = {
	type = character_event
	title = ie_hunt.0001.t
	desc = ie_hunt.0004.desc
	theme = hunt_activity

	option = { # One-time distraction
		name = ie_hunt.0004.a
	}

	after = {
		trigger_event = {
			id = hunt.9001 #To complete the activity
			days = { 14 20 }
		}
	}
}


code:
#######################
# 0001 - Ending event
# 1001-1005 - Functionality events
# 2000+ - Regular events triggered by on_actions
# 9999 - Fallback event for when no other events trigger

namespace = ie_orgy

scripted_trigger ie_orgy_end_events_participant_trigger = {
	NOT = { this = scope:host }
	is_alive = yes
	is_imprisoned = no
}

# Ending event
ie_orgy.0001 = {
	type = character_event
	hidden = yes

	trigger = {
		exists = scope:activity
	}

	immediate = {
		if = {
			limit = {
				OR = {
					# Everyone has wrapped up their events
					scope:activity = {
						# debug_log_details = checking_participants
						any_participant = {
							count = all
							trigger_if = {
								limit = {
									is_alive = yes
									is_imprisoned = no
								}
								save_temporary_scope_as = participant_check
								scope:activity = {
									is_target_in_variable_list = {
										name = finished_participants
										target = scope:participant_check
									}
								}
							}
							trigger_else = { always = yes }
						}
					}
					# There exists a special exception
					exists = scope:activity.var:end__now
					# Has attempted to wrap up the feast already
					AND = {
						trigger_if = {
							limit = {
								exists = scope:activity.var:attempted_to_end_orgy
							}
							scope:activity.var:attempted_to_end_orgy > 2
						}
						trigger_else = {
							always = no
						}
					}
				}
			}
			scope:activity = {
				activity_owner = {
					save_scope_as = host
				}
				every_participant = {
					limit = { ie_orgy_end_events_participant_trigger = yes }
					trigger_event = ie_orgy.1004
				}
				activity_owner = {
					trigger_event = ie_orgy.1003
				}
			}
		}
		if = {
			limit = { NOT = { exists = scope:activity.var:attempted_to_end_orgy } }
			scope:activity = {
				set_variable = {
					name = attempted_to_end_orgy
					value = 1
				}
			}
		}
		else = {
			scope:activity = {
				change_variable = {
					name = attempted_to_end_orgy
					add = 1
				}
			}
		}
		trigger_event = {
			id = ie_orgy.0001
			days = 20
		}
	}
}

# Invite prostitute
ie_orgy.0002 = {
	type = character_event
	hidden = yes

	trigger = {
		exists = scope:activity

		scope:activity = {
			NOT = {
				any_participant = {
					NOT = { this = root }
					is_attracted_to_gender_of = root
					root = {
						is_attracted_to_gender_of = prev
					}
				}
			}
		}
	}

	immediate = {
		ie_orgy_generate_prostitute_effect = yes
		scope:activity = {
			hidden_effect = { invite_character_to_activity = scope:prostitute }
			accept_invitation_for_character = scope:prostitute
		}
	}
}

# Invitation letter
ie_orgy.1001 = {
	type = letter_event
	opening = ie_orgy.1001.t
	desc = ie_orgy.1001.desc
	sender = {
		character = scope:host
		hide_info = yes
	}

	immediate = {
		scope:activity.activity_owner = { save_scope_as = host }
	}

  	#Yes!
	option = {
		name = ie_orgy.1001.a

		play_music_cue = "mx_cue_seduction"
		scope:activity = {
			accept_invitation_for_character = prev
		}
		ai_chance = {
			base = 100
			modifier = {
				add = 25
				has_trait = lustful
			}
			modifier = {
				add = 25
				has_trait = rakish
			}
		}
	}

	#No...
	option = {
		name = ie_orgy.1001.b

		scope:activity = {
			decline_invitation_for_character = prev
		}
		ai_chance = {
			base = 10
			modifier = {
				add = 25
				has_trait = chaste
			}
			modifier = {
				add = 50
				has_trait = celibate
			}
			ai_value_modifier = {
				ai_zeal = 1.5
			}
		}
	}
}

# No guests came :(
ie_orgy.1002 = {
	type = character_event
	title = ie_orgy.1002.t
	desc = ie_orgy.1002.desc
	theme = seduction
	left_portrait = {
		character = root
		animation = sadness
	}

	option = {
		name = ie_orgy.1002.a

		scope:activity = {
			complete_activity = yes
		}
	}
}

# End for host
ie_orgy.1003 = {
	type = character_event
	title = ie_orgy.1003.t
	desc = {
		desc = ie_orgy.1003.start.desc
		desc = ie_orgy.1003.end.desc
	}
	theme = seduction
	left_portrait = {
		character = root
		animation = ecstasy
	}

	trigger = { exists = scope:activity }

	option = {
		name = ie_orgy.1003.a

		scope:activity = {
			complete_activity = yes
		}

		ie_orgy_end_effect = yes
	}
}

# End for guest
ie_orgy.1004 = {
	type = character_event
	title = ie_orgy.1003.t
	desc = {
		desc = ie_orgy.1004.start.desc
		desc = ie_orgy.1003.end.desc
	}
	theme = seduction
	left_portrait = {
		character = root
		animation = ecstasy
	}

	option = {
		name = ie_orgy.1003.a
		custom_tooltip = ie_orgy.1004.tt
		ie_orgy_end_effect = yes
	}
}

#######################
# Random orgy event
# by Ernie Collins
# 2000
#######################
ie_orgy.2000 = {
	type = character_event
	title = ie_orgy.2000.t
	desc = {
		desc = ie_orgy.2000.desc
		triggered_desc = {
			trigger = {
				scope:orgy_character = scope:activity.activity_owner
			}
			desc = ie_orgy.2000.desc.host
		}
		triggered_desc = {
			trigger = {
				exists = scope:orgy_character2
			}
			desc = ie_orgy.2000.desc.threesome
		}
	}
	theme = seduction
	left_portrait = {
		character = scope:orgy_character
		animation = flirtation_left
		hide_info = yes
	}
	right_portrait = {
		character = scope:orgy_character2
		animation = ecstasy
		hide_info = yes
	}

	trigger = {
		NOR = {
			exists = local_var:had_2000
			has_character_flag = block_orgy_events
		}
		scope:activity = {
			any_participant = {
				NOR = {
					this = root
					has_character_flag = block_orgy_events
				}
				root = {
					is_attracted_to_gender_of = prev
				}
			}
		}
	}

	immediate = {
		set_local_variable = {
			name = had_2000
			value = yes
		}

		scope:activity = {
			random_participant = {
				limit = {
					NOR = {
						this = root
						has_character_flag = block_orgy_events
					}
					root = {
						is_attracted_to_gender_of = prev
					}
				}
				save_scope_as = orgy_character
			}
			if = {
				limit = { any_participant = { count > 1 } }
				random_participant = {
					limit = {
						NOR = {
							this = root
							this = scope:orgy_character
						}
					}
					save_scope_as = orgy_character2
				}
			}
		}

		hidden_effect = {
			carn_had_sex_with_effect = {
				CHARACTER_1 = root
				CHARACTER_2 = scope:orgy_character
				C1_PREGNANCY_CHANCE = pregnancy_chance
				C2_PREGNANCY_CHANCE = pregnancy_chance
				STRESS_EFFECTS = yes
				DRAMA = no # We'll handle secrets ourselves
			}
			# Only give the secret to Root, because AI will fire these events as well and have the same/other characters present
			give_homosexual_secret_or_nothing_with_target_effect = { CHARACTER = scope:orgy_character }

			if = {
				limit = { exists = scope:orgy_character2 }

				carn_had_sex_with_effect = {
					CHARACTER_1 = root
					CHARACTER_2 = scope:orgy_character2
					C1_PREGNANCY_CHANCE = pregnancy_chance
					C2_PREGNANCY_CHANCE = pregnancy_chance
					STRESS_EFFECTS = yes
					DRAMA = no # We'll handle secrets ourselves
				}
				give_homosexual_secret_or_nothing_with_target_effect = { CHARACTER = scope:orgy_character2 }

				carn_had_sex_with_effect = {
					CHARACTER_1 = scope:orgy_character
					CHARACTER_2 = scope:orgy_character2
					C1_PREGNANCY_CHANCE = pregnancy_chance
					C2_PREGNANCY_CHANCE = pregnancy_chance
					STRESS_EFFECTS = yes
					DRAMA = no # We'll handle secrets ourselves
				}
			}
		}
	}

	option = {
		name = ie_orgy.2000.a
		custom_tooltip = ie_orgy.2000.tt
	}

	after = {
		hidden_effect = {
			ie_orgy_wrap_up_or_fire_random_event_effect = yes
		}
	}
}

#######################
# Revelation during the orgy
# by Ernie Collins
# 2001-2012
#######################
ie_orgy.2001 = {
	type = character_event
	title = ie_orgy.2001.t
	desc =  ie_orgy.2001.desc

	theme = seduction
	left_portrait = {
		character = scope:orgy_character
		animation = flirtation_left
		hide_info = yes
	}

	trigger = {
		NOR = {
			exists = local_var:had_2001
			has_character_flag = block_orgy_events
		}
		scope:activity = {
			any_participant = {
				NOT = { this = root }
				is_attracted_to_gender_of = root
				root = {
					is_attracted_to_gender_of = prev
				}
			}
		}
		carn_gender_can_impregnate_trigger = yes
	}

	immediate = {
		set_local_variable = {
			name = had_2001
			value = yes
		}

		save_scope_as = orgy_character_rev

		scope:activity = {
			random_participant = {
				limit = {
					NOT = { this = root }
					root = {
						is_attracted_to_gender_of = prev
					}
				}
				save_scope_as = orgy_character
			}
		}

		scope:orgy_character = {
			add_character_flag = block_orgy_events
		}
	}

	option = {
		name = ie_orgy.2001.a
		scope:orgy_character = {
			trigger_event = ie_orgy.2011
		}
	}
}

# The choice
ie_orgy.2002 = {
	type = character_event
	title = ie_orgy.2001.t
	desc =  ie_orgy.2002.desc

	theme = seduction
	left_portrait = {
		character = scope:orgy_character
		animation = flirtation_left
		hide_info = yes
	}

	option = {
		name = ie_orgy.2002.a
		trigger_event = ie_orgy.2003

		stress_impact = {
			curious = medium_stress_impact_gain
			deceitful = minor_stress_impact_gain
			paranoid = major_stress_impact_gain
			stubborn = medium_stress_impact_gain
		}
		stress_impact = {
			compassionate = minor_stress_impact_loss
			content = minor_stress_impact_loss
			craven = minor_stress_impact_loss
			shy = medium_stress_impact_loss
			trusting = medium_stress_impact_loss
		}
	}

	option = {
		name = ie_orgy.2002.b
		custom_tooltip = ie_orgy.2002.b.tt
		trigger_event = ie_orgy.2004

		stress_impact = {
			compassionate = medium_stress_impact_gain
			content = medium_stress_impact_gain
			craven = medium_stress_impact_gain
			honest = minor_stress_impact_gain
			humble = minor_stress_impact_gain
			shy = major_stress_impact_gain
			trusting = major_stress_impact_gain
		}
		stress_impact = {
			arrogant = minor_stress_impact_loss
			callous = minor_stress_impact_loss
			curious = medium_stress_impact_loss
			deceitful = medium_stress_impact_loss
			greedy = minor_stress_impact_loss
			paranoid = major_stress_impact_loss
			stubborn = medium_stress_impact_loss
		}
	}
}

# Privacy respected
ie_orgy.2003 = {
	type = character_event
	title = ie_orgy.2001.t
	desc =  ie_orgy.2003.desc

	theme = seduction
	left_portrait = {
		character = scope:orgy_character
		animation = ecstasy
		hide_info = yes
	}

	immediate = {
		hidden_effect = {
			carn_had_sex_with_effect = {
				CHARACTER_1 = root
				CHARACTER_2 = scope:orgy_character
				C1_PREGNANCY_CHANCE = pregnancy_chance
				C2_PREGNANCY_CHANCE = pregnancy_chance
				STRESS_EFFECTS = yes
				DRAMA = no # We'll handle secrets ourselves
			}
			give_homosexual_secret_or_nothing_with_target_effect = { CHARACTER = scope:orgy_character }
		}
		show_as_tooltip = {
			stress_impact = {
				lustful = minor_stress_impact_loss
				rakish = minor_stress_impact_loss
			}
		}
	}

	option = {
		name = ie_orgy.2003.a
		custom_tooltip = ie_orgy.2003.a.tt
		scope:orgy_character = {
			set_local_variable = {
				name = ie_revelation_outcome
				value = flag:masked
			}
			trigger_event = ie_orgy.2012
		}
	}

	after = {
		hidden_effect = {
			ie_orgy_wrap_up_or_fire_random_event_effect = yes
		}
	}
}

# Revelation
ie_orgy.2004 = {
	type = character_event
	title = ie_orgy.2001.t
	desc =  ie_orgy.2004.desc

	theme = seduction
	left_portrait = {
		character = scope:orgy_character
		animation = ecstasy
		hide_info = no # Just to make it explicit
	}

	immediate = {
		hidden_effect = {
			scope:orgy_character = {
				remove_trait = ie_masked
				give_deviant_secret_or_trait_effect = yes
			}
		}

		scope:orgy_character = {
			random_secret = {
				limit = {
					secret_type = secret_deviant
					NOT = { is_known_by = root }
				}
				reveal_to = root
			}
		}
	}

	option = {
		name = ie_orgy.2004.a
		custom_tooltip = ie_orgy.2004.a.tt

		hidden_effect = {
			carn_had_sex_with_effect = {
				CHARACTER_1 = root
				CHARACTER_2 = scope:orgy_character
				C1_PREGNANCY_CHANCE = pregnancy_chance
				C2_PREGNANCY_CHANCE = pregnancy_chance
				STRESS_EFFECTS = yes
				DRAMA = no # We'll handle secrets ourselves
			}
		}

		give_incest_secret_or_nothing_with_target_effect = { CHARACTER = scope:orgy_character }
		give_homosexual_secret_or_nothing_with_target_effect = { CHARACTER = scope:orgy_character }

		stress_impact = {
			chaste = medium_stress_impact_gain
		}
		stress_impact = {
			arrogant = minor_stress_impact_loss
			deviant = major_stress_impact_loss
			lustful = medium_stress_impact_loss
			rakish = medium_stress_impact_loss
			seducer = minor_stress_impact_loss
		}

		scope:orgy_character = {
			set_local_variable = {
				name = ie_revelation_outcome
				value = flag:unmasked_continued
			}
			trigger_event = ie_orgy.2012
		}

	}

	option = {
		name = ie_orgy.2004.b
		custom_tooltip = ie_orgy.2004.b.tt

		stress_impact = {
			deviant = medium_stress_impact_gain
			lustful = medium_stress_impact_gain
			rakish = medium_stress_impact_gain
			seducer = medium_stress_impact_gain
		}
		stress_impact = {
			chaste = medium_stress_impact_loss
			craven = medium_stress_impact_loss
			zealous = medium_stress_impact_loss
		}

		scope:orgy_character = {
			set_local_variable = {
				name = ie_revelation_outcome
				value = flag:unmasked_stopped
			}
			trigger_event = ie_orgy.2012
		}
	}
}

# For the other character
ie_orgy.2011 = {
	type = character_event
	title = ie_orgy.2001.t
	desc =  ie_orgy.2011.desc

	theme = seduction
	left_portrait = {
		character = scope:orgy_character_rev
		animation = flirtation_left
		hide_info = yes
	}

	trigger = {
		exists = scope:orgy_character_rev
	}

	option = {
		name = ie_orgy.2011.a
		scope:orgy_character_rev = {
			trigger_event = ie_orgy.2002
		}
	}
}

ie_orgy.2012 = {
	type = character_event
	title = ie_orgy.2001.t
	desc =  {
		desc = ie_orgy.2012.desc
		first_valid = {
			triggered_desc = {
				trigger = { local_var:ie_revelation_outcome = flag:masked }
				desc = ie_orgy.2012.desc.masked
			}
			desc = ie_orgy.2012.desc.unmasked
		}
		triggered_desc = {
			trigger = { local_var:ie_revelation_outcome = flag:unmasked_continued }
			desc = ie_orgy.2012.desc.unmasked.continue
		}
		triggered_desc = {
			trigger = { local_var:ie_revelation_outcome = flag:unmasked_stopped }
			desc = ie_orgy.2012.desc.unmasked.stop
		}
	}

	theme = seduction
	left_portrait = {
		character = scope:orgy_character_rev
		triggered_animation = {
			trigger = { local_var:ie_revelation_outcome = flag:unmasked_stopped }
			animation = shock
		}
		animation = ecstasy
		hide_info = yes
	}

	trigger = {
		exists = scope:orgy_character_rev
		exists = local_var:ie_revelation_outcome
	}

	immediate = {
		if = {
			limit = {
				OR = {
					local_var:ie_revelation_outcome = flag:masked
					local_var:ie_revelation_outcome = flag:unmasked_continued
				}
			}
			show_as_tooltip = {
				stress_impact = {
					lustful = minor_stress_impact_loss
					rakish = minor_stress_impact_loss
				}
			}
		}
	}

	option = {
		trigger = { local_var:ie_revelation_outcome = flag:masked }
		name = ie_orgy.2012.a
	}

	option = {
		trigger = { NOT = { local_var:ie_revelation_outcome = flag:masked } }
		name = ie_orgy.2012.b
	}

	after = {
		hidden_effect = {
			remove_character_flag = block_orgy_events
			if = {
				limit = { NOT = { has_trait = ie_masked } }
				add_trait = ie_masked
			}
		}
		scope:orgy_character_rev = {
			ie_orgy_wrap_up_or_fire_random_event_effect = yes
		}
	}
}


code:
namespace = ie_coming_of_age

ie_coming_of_age.0001 = {
	type = character_event
	hidden = yes

	trigger = {
		is_ai = yes
		is_female = yes
		exists = root.father
		exists = root.mother
		is_attracted_to_gender_of = root.father
		OR = {
			sexually_liberal_trigger = yes
			has_trait = incestuous
			has_trait = witch
			AND = {
				root.father = {
					has_trait = beauty_good
				}
				NOT = { has_trait = chaste }
			}
		}
		NOR = {
			secret_disputed_heritage_is_valid_trigger = {
				TARGET = root
			}
			has_trait = incapable
		}
		root.father = {
			relation_with_character_is_incestuous_in_my_faith_trigger = {
				CHARACTER = prev.mother
			}
		}
	}

	immediate = {
		save_scope_as = child_who_has_come_of_age

		scope:child_who_has_come_of_age.father = {
			trigger_event = ie_coming_of_age.1001
		}
	}
}

# Parent tells child of child's incestuous conception
ie_coming_of_age.1001 = {
	type = character_event
	title = ie_coming_of_age.1001.t
	desc = ie_coming_of_age.1001.desc

	theme = education
	left_portrait = {
		character = scope:child_who_has_come_of_age
		animation = worry
	}

	trigger = {
		is_ai = no # The AI has enough incest as is
	}

	option = {
		name = ie_coming_of_age.1001.a
	}

	option = {
		name = ie_coming_of_age.1001.b
		trigger_event = ie_coming_of_age.1002

		show_as_tooltip = {
			carn_had_sex_with_effect = {
				CHARACTER_1 = root
				CHARACTER_2 = scope:child_who_has_come_of_age
				C1_PREGNANCY_CHANCE = pregnancy_chance
				C2_PREGNANCY_CHANCE = pregnancy_chance
				STRESS_EFFECTS = yes
				DRAMA = yes
			}
		}

		stress_impact = {
			zealous = major_stress_impact_gain
		}
		stress_impact = {
			lustful = major_stress_impact_loss
		}
	}

}

ie_coming_of_age.1002 = {
	type = character_event
	title = ie_coming_of_age.1001.t
	desc = ie_coming_of_age.1002.desc

	theme = education
	left_portrait = {
		character = scope:child_who_has_come_of_age
		animation = flirtation_left
	}

	immediate = {
		scope:child_who_has_come_of_age = {
			carn_undress_character_effect = yes
		}
	}

	option = {
		name = ie_coming_of_age.1002.a
		set_variable = {
			name = sex_location
			value = flag:chair
		}
	}

	option = {
		name = ie_coming_of_age.1002.b
		set_variable = {
			name = sex_location
			value = flag:floor
		}
	}

	option = {
		name = ie_coming_of_age.1002.c
		set_variable = {
			name = sex_location
			value = flag:desk
		}
	}

	option = {
		name = ie_coming_of_age.1002.d
		set_variable = {
			name = sex_location
			value = flag:wall
		}
	}

	after = {
		trigger_event = ie_coming_of_age.1003
	}
}

ie_coming_of_age.1003 = {
	type = character_event
	title = ie_coming_of_age.1001.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { var:sex_location = flag:chair }
				desc = ie_coming_of_age.1003.desc.1.chair
			}
			triggered_desc = {
				trigger = { var:sex_location = flag:floor }
				desc = ie_coming_of_age.1003.desc.1.floor
			}
			triggered_desc = {
				trigger = { var:sex_location = flag:desk }
				desc = ie_coming_of_age.1003.desc.1.desk
			}
			triggered_desc = {
				trigger = { var:sex_location = flag:wall }
				desc = ie_coming_of_age.1003.desc.1.wall
			}
		}
		desc = ie_coming_of_age.1003.desc.1
		first_valid = {
			triggered_desc = {
				trigger = { var:sex_location = flag:chair }
				desc = ie_coming_of_age.1003.desc.2.chair
			}
			triggered_desc = {
				trigger = { var:sex_location = flag:floor }
				desc = ie_coming_of_age.1003.desc.2.floor
			}
			triggered_desc = {
				trigger = { var:sex_location = flag:desk }
				desc = ie_coming_of_age.1003.desc.2.desk
			}
			triggered_desc = {
				trigger = { var:sex_location = flag:wall }
				desc = ie_coming_of_age.1003.desc.2.wall
			}
		}
		desc = ie_coming_of_age.1003.desc.2
	}

	theme = education
	left_portrait = {
		character = scope:child_who_has_come_of_age
		animation = ecstasy
	}

	immediate = {
		scope:child_who_has_come_of_age = {
			carn_undress_character_effect = yes
		}
	}

	option = {
		name = ie_coming_of_age.1003.a
		set_variable = {
			name = cum_inside
			value = yes
		}
	}

	option = {
		name = ie_coming_of_age.1003.b
	}

	after = {
		trigger_event = ie_coming_of_age.1004
	}
}

ie_coming_of_age.1004 = {
	type = character_event
	title = ie_coming_of_age.1001.t
	desc = {
		desc = ie_coming_of_age.1004.desc.1
		first_valid = {
			triggered_desc = {
				trigger = { exists = var:cum_inside }
				desc = ie_coming_of_age.1004.desc.1.inside
			}
			desc = ie_coming_of_age.1004.desc.1.outside
		}
		desc = ie_coming_of_age.1004.desc.2
	}

	theme = education
	left_portrait = {
		character = scope:child_who_has_come_of_age
		animation = ecstasy
	}

	immediate = {
		scope:child_who_has_come_of_age = {
			carn_undress_character_effect = yes
		}

		hidden_effect = {
			if = {
				limit = { exists = var:cum_inside }
				carn_had_sex_with_effect = {
					CHARACTER_1 = root
					CHARACTER_2 = scope:child_who_has_come_of_age
					C1_PREGNANCY_CHANCE = pregnancy_chance
					C2_PREGNANCY_CHANCE = pregnancy_chance
					STRESS_EFFECTS = yes
					DRAMA = yes
				}
			}
			else = {
				carn_had_sex_with_effect = {
					CHARACTER_1 = root
					CHARACTER_2 = scope:child_who_has_come_of_age
					C1_PREGNANCY_CHANCE = 0
					C2_PREGNANCY_CHANCE = 0
					STRESS_EFFECTS = yes
					DRAMA = yes
				}
			}
		}

	}

	option = {
		name = ie_coming_of_age.1004.a
		set_relation_lover = scope:child_who_has_come_of_age
	}

	option = {
		name = ie_coming_of_age.1004.b

		random_list = {
			10 = {
				modifier = {
					add = 80
					sexually_liberal_trigger = yes
				}
				show_chance = no
				reverse_add_opinion = {
					target = scope:child_who_has_come_of_age
					modifier = pleased_opinion
					opinion = 20
				}
				desc = ie_coming_of_age.1004.b.positive_outcome
			}
			10 = {
				modifier = {
					add = 80
					sexually_liberal_trigger = no
				}
				show_chance = no
				reverse_add_opinion = {
					target = scope:child_who_has_come_of_age
					modifier = disappointed_opinion
					opinion = -20
				}
				desc = ie_coming_of_age.1004.b.negative_outcome
			}
		}
	}

	after = {
		scope:child_who_has_come_of_age = {
			carn_dress_character_effect = yes
		}
		if = {
			limit = { exists = var:cum_inside }
			remove_variable = cum_inside
		}
	}
}


code:
namespace = ie_friendship

# Sharing everything
# Code by Siudhne, writing by Ernie Collens
scripted_trigger ie_friendship_0001_sharing_everything_trigger_wife = {
	is_available_healthy_ai_adult = yes
	NOT = { is_spouse_of = root } # For polyamorous societies
	sexually_liberal_trigger = yes
	is_attracted_to_gender_of = root
	is_female = yes
}

scripted_trigger ie_friendship_0001_sharing_everything_trigger = {
	is_available_healthy_ai_adult = yes
	NOT = { is_spouse_of = root } # For polyamorous societies
	is_male = yes
	any_spouse = { ie_friendship_0001_sharing_everything_trigger_wife = yes }
}

ie_friendship.0001 = {
	type = character_event
	title = ie_friendship.0001.t
	desc = ie_friendship.0001.desc
	theme = friend_relation
	left_portrait = {
		character = scope:friend_with_wife
		animation = happiness
	}
	right_portrait = {
		character = scope:wife_of_friend
		animation = love
	}

	trigger = {
		is_available_healthy_adult = yes
		any_relation = {
			type = friend
			ie_friendship_0001_sharing_everything_trigger = yes
		}
		NOT = { has_character_flag = ie_had_sharing_everything_event }
	}

	immediate = {
		add_character_flag = {
			flag = ie_had_sharing_everything_event
			years = 10
		}
		random_relation = {
			type = friend
			limit = {
				ie_friendship_0001_sharing_everything_trigger = yes
			}
			save_scope_as = friend_with_wife
		}
		scope:friend_with_wife = {
			random_spouse = {
				limit = { ie_friendship_0001_sharing_everything_trigger_wife = yes }
				save_scope_as = wife_of_friend
			}
		}
		scope:wife_of_friend = { carn_undress_character_effect = yes }
	}

	# Agree
	option = {
		name = ie_friendship.0001.a
		custom_tooltip = ie_friendship.0001.a.tt

		# Carnalitas framework sex scene
		carn_sex_scene_request_consensual = yes
		carn_sex_scene_effect = {
			PLAYER = root
			TARGET = scope:wife_of_friend
			STRESS_EFFECTS = yes
			DRAMA = yes
		}

		reverse_add_opinion = {
			target = scope:wife_of_friend
			opinion = 40
			modifier = romance_opinion
		}
	}

	# Threesome
	option = {
		name = ie_friendship.0001.b
		custom_tooltip = ie_friendship.0001.b.tt

		trigger_event = {
			id = ie_friendship.0002
			days = { 1 3 }
		}
	}

	# Rebuke
	option = {
		name = ie_friendship.0001.c
		custom_tooltip = ie_friendship.0001.c.tt

		add_piety = minor_piety_gain
		stress_impact = {
			deviant = minor_stress_impact_gain
			seducer = minor_stress_impact_gain
			lustful = medium_stress_impact_gain
			chaste = miniscule_stress_impact_loss
			celibate = miniscule_stress_impact_loss
		}
	}

	after = {
		scope:friend_with_wife = { carn_dress_character_effect = yes }
	}
}

ie_friendship.0002 = {
	type = character_event
	title = ie_friendship.0001.t
	desc = ie_friendship.0002.desc
	theme = friend_relation
	left_portrait = {
		character = scope:friend_with_wife
		animation = love
	}
	right_portrait = {
		character = scope:wife_of_friend
		animation = ecstasy
	}

	immediate = {
		scope:wife_of_friend = { carn_undress_character_effect = yes }
		scope:friend_with_wife = { carn_undress_character_effect = yes }
	}

	# Become lovers
	option = {
		name = ie_friendship.0002.a
		set_relation_lover = scope:wife_of_friend
	}

	# Become friends
	option = {
		name = ie_friendship.0002.b
		set_relation_friend = scope:wife_of_friend
		remove_character_flag = ie_had_sharing_everything_event
	}

	after = {
		scope:friend_with_wife = { carn_dress_character_effect = yes	}
		scope:wife_of_friend = { carn_dress_character_effect = yes }
	}
}