code:
carn_enslaved_close_family_opinion = {
	opinion = -50
	years = 30
	decaying = yes
}

carn_enslaved_close_family_crime_opinion = {
	opinion = -50
	imprisonment_reason = yes
	execute_reason = yes
	banish_reason = yes
}

carn_enslaved_dynasty_member_opinion = {
	opinion = -20
	years = 20
	decaying = yes
}

carn_enslaved_close_relation_opinion = {
	opinion = -30
	years = 25
	decaying = yes
}

carn_enslaved_my_countryman_opinion = {
	opinion = -25
	years = 20
	decaying = yes
}

carn_enslaved_guest_opinion = {
	opinion = -5
	years = 10
	decaying = yes
}

carn_enslaved_me_opinion = {
	opinion = -80
	years = 50
	decaying = yes
}

carn_enslaved_me_crime_opinion = {
	opinion = -80
	imprisonment_reason = yes
	execute_reason = yes
	banish_reason = yes
}

carn_freed_me_from_slavery_opinion = {
	opinion = 50
	years = 50
	decaying = yes
}

carn_stole_my_slave_opinion = {
	opinion = -10
	years = 10
	decaying = yes
}

# For modders, this opinion makes the character auto accept enslave interactions from the opinion target
carn_wants_to_be_your_slave_opinion = {
	opinion = 10
}

carn_forced_me_into_prostitution_opinion = {
	opinion = -50
	years = 30
	decaying = yes
}

# used for pregnancy logic, to prevent pregnancies from ex-slaves or ex-owners being treated as bastard pregnancies
carn_former_slave_or_slave_owner_opinion = {
	opinion = -5
	months = 9
}


code:
carn_refused_manumission_demand_opinion = {
	opinion = -15
	years = 10
}

carn_illegal_refused_manumission_demand_opinion = {
	opinion = -15
	years = 10
	imprisonment_reason = yes
}

carn_demanded_manumission_opinion = {
	opinion = -20
	monthly_change = 0.1
	decaying = yes
}

repo_name: Synthael/carnalitas

license: mit


code:
carn_doctrine_same_slavery = {
	group = "crimes"

	is_available_on_create = {
		NOT = { has_game_rule = carn_slavery_content_disabled }
	}

	carn_doctrine_same_slavery_crime = {
		piety_cost = {
			value = faith_doctrine_cost_mid
			if = {
				limit = { has_doctrine = carn_doctrine_same_slavery_crime }
				multiply = 0
			}
			else_if = {
				limit = { has_doctrine = carn_doctrine_same_slavery_accepted }
				multiply = faith_changed_doctrine_cost_mult_two_step
			}
		}
		parameters = {
			same_slavery_illegal = yes
		}
	}
	carn_doctrine_same_slavery_shunned = {
		piety_cost = {
			value = faith_doctrine_cost_mid
			if = {
				limit = { has_doctrine = carn_doctrine_same_slavery_shunned }
				multiply = 0
			}
		}
		parameters = {
			same_slavery_shunned = yes
		}
	}
	carn_doctrine_same_slavery_accepted = {
		piety_cost = {
			value = faith_doctrine_cost_mid
			if = {
				limit = { has_doctrine = carn_doctrine_same_slavery_accepted }
				multiply = 0
			}
			else_if = {
				limit = { has_doctrine = carn_doctrine_same_slavery_crime }
				multiply = faith_changed_doctrine_cost_mult_two_step
			}
		}
		parameters = {
			same_slavery_accepted = yes
		}
	}
}

carn_doctrine_other_slavery = {
	group = "crimes"

	is_available_on_create = {
		NOT = { has_game_rule = carn_slavery_content_disabled }
	}

	carn_doctrine_other_slavery_crime = {
		piety_cost = {
			value = faith_doctrine_cost_mid
			if = {
				limit = { has_doctrine = carn_doctrine_other_slavery_crime }
				multiply = 0
			}
			else_if = {
				limit = { has_doctrine = carn_doctrine_other_slavery_accepted }
				multiply = faith_changed_doctrine_cost_mult_two_step
			}
		}
		parameters = {
			other_slavery_illegal = yes
		}
	}
	carn_doctrine_other_slavery_shunned = {
		piety_cost = {
			value = faith_doctrine_cost_mid
			if = {
				limit = { has_doctrine = carn_doctrine_other_slavery_shunned }
				multiply = 0
			}
		}
		parameters = {
			other_slavery_shunned = yes
		}
	}
	carn_doctrine_other_slavery_accepted = {
		piety_cost = {
			value = faith_doctrine_cost_mid
			if = {
				limit = { has_doctrine = carn_doctrine_other_slavery_accepted }
				multiply = 0
			}
			else_if = {
				limit = { has_doctrine = carn_doctrine_other_slavery_crime }
				multiply = faith_changed_doctrine_cost_mult_two_step
			}
		}
		parameters = {
			other_slavery_accepted = yes
		}
	}
}

carn_doctrine_prostitution = {
	group = "crimes"

	is_available_on_create = {
		NOT = { has_game_rule = carn_prostitution_content_disabled }
	}

	carn_doctrine_prostitution_crime = {
		piety_cost = {
			value = faith_doctrine_cost_mid
			if = {
				limit = { has_doctrine = carn_doctrine_prostitution_crime }
				multiply = 0
			}
			else_if = {
				limit = { has_doctrine = carn_doctrine_prostitution_accepted }
				multiply = faith_changed_doctrine_cost_mult_two_step
			}
		}
		parameters = {
			carn_prostitution_illegal = yes
		}
	}
	carn_doctrine_prostitution_shunned = {
		piety_cost = {
			value = faith_doctrine_cost_mid
			if = {
				limit = { has_doctrine = carn_doctrine_prostitution_shunned }
				multiply = 0
			}
		}
		parameters = {
			carn_prostitution_shunned = yes
		}
	}
	carn_doctrine_prostitution_accepted = {
		piety_cost = {
			value = faith_doctrine_cost_mid
			if = {
				limit = { has_doctrine = carn_doctrine_prostitution_accepted }
				multiply = 0
			}
			else_if = {
				limit = { has_doctrine = carn_doctrine_prostitution_crime }
				multiply = faith_changed_doctrine_cost_mult_two_step
			}
		}
		parameters = {
			carn_prostitution_accepted = yes
		}
	}
}

carn_dummy_doctrine = {
	group = "special"

	is_available_on_create = {
		always = no
	}

	carn_we_need_this_to_define_parameters_otherwise_error_log_complains = {
		parameters = {
			naked_males_active = no
			naked_females_active = no
			naked_malepriest_active = no
			naked_malepriests_active = no
			naked_femalepriest_active = no
			naked_femalepriests_active = no
		}
	}
}


code:
abduct = {
	# Basic Setup
	skill = intrigue
	desc = "abduct_desc_general"
	success_desc = "ABDUCT_SUCCESS_DESC"
	discovery_desc = "ABDUCT_DISCOVERY_DESC"
	icon = icon_scheme_abduct
	illustration = "gfx/interface/illustrations/event_scenes/corridor.dds"
	category = hostile
	target_type = character
	is_secret = yes
	maximum_breaches = 5
	cooldown = { years = 10 }

	# Parameters
	speed_per_skill_point = t2_spsp_owner_value
	speed_per_target_skill_point = t2_spsp_target_value
	base_progress_goal = t2_base_phase_length_value
	maximum_secrecy = 85
	base_maximum_success = t2_base_max_success_value
	phases_per_agent_charge = 1
	success_chance_growth_per_skill_point = t2_scgpsp_value

	# Core Triggers
	allow = {
		OR = {
			has_perk = kidnapper_perk # Scheme unlocked by the Kidnapper Perk
			domicile ?= { has_domicile_parameter = camp_unlocks_abduct_scheme }
			AND = {
				any_character_struggle = {
					involvement = involved
					has_struggle_phase_parameter = unlocks_abduct_for_all
					is_secondary_character_involvement_involved_trigger = {
						CHAR = scope:target
					}
				}
			}
		}

		is_adult = yes
		is_playable_character = yes
		is_imprisoned = no
	}
	valid = {
		is_playable_character = yes
		is_ruler = yes
		is_incapable = no
		custom_description = { #If they're your kid you need special traits to do it
			text = abduct_own_children_block
			object = scope:target

			trigger_if = {
				limit = {
					is_parent_of = scope:target
				}
				has_trait_with_flag = can_murder_own_children
			}
		}
		scope:target = {
			is_imprisoned = no
			is_hostage = no
			exists = location
			in_diplomatic_range = scope:owner
		}
		# Special AI exceptions
		NOT = {
			scope:owner = {
				is_ai = yes
				has_opinion_modifier = {
					target = scope:target
					modifier = repentant_opinion
				}
			}
		}
	}

	# Agents
	agent_leave_threshold = -25
	agent_join_chance = {
		base = 0

		ai_agent_join_chance_basic_suite_modifier = yes
		ai_agent_join_chance_hostile_grievous_modifier = yes
	}
	agent_groups_owner_perspective = { courtiers guests scripted_relations }
	agent_groups_target_character_perspective = { courtiers vassals }
	valid_agent = { is_valid_agent_standard_trigger = yes }

	odds_prediction = {
		add = hostile_scheme_base_odds_prediction_target_is_char_value
		add = odds_skill_contribution_intrigue_value
		add = agent_groups_owner_perspective_value
		add = agent_groups_target_character_perspective_value
		add = odds_abduct_scheme_misc_value
		min = 0
	}

	# Base Chances
	base_success_chance = {
		base = 0
		scheme_type_skill_success_chance_modifier = { SKILL = INTRIGUE }

		hostile_scheme_base_chance_modifier = yes

		# Countermeasures.
		apply_calculated_scheme_success_chance_adjustments_modifier = yes

		# You found their escape tunnel
		modifier = {
			add = 100
			desc = "SCHEME_DISCOVERED_ESCAPE_TUNNEL"
			scope:owner = {
				exists = var:discovered_escape_tunnel_of
				var:discovered_escape_tunnel_of = scope:target
			}
		}

		# Spiritual Head of Faith
		modifier = {
			add = -50
			desc = "SCHEME_VS_SPIRITUAL_HOF"
			scope:target = {
				faith = scope:owner.faith
				faith = {
					has_doctrine = doctrine_spiritual_head
				}
				faith = {
					exists = religious_head
					religious_head = {
			 			this = scope:target
			 		}
				}
			}
		}

		# Sponsored Inspiration
		modifier = {
			add = -25
			desc = target_has_sponsored_inspiration
			scope:target = {
				exists = inspiration
				inspiration = { exists = inspiration_sponsor }
			}
		}

		# Family Feud
		house_feud_hostile_scheme_success_modifier = yes

		# Various penalties
		first_valid = {
			modifier = { # Foreign Rulers are very hard to kidnap
				add = -75
				desc = "sway_foreign_target"
				scope:target = {
					is_ruler = yes
					NOT = {
						scope:target.top_liege = scope:owner.top_liege
					}
				}
			}
			modifier = { # Foreign subjects less so
				add = -40
				desc = "sway_foreign_target"
				scope:target = {
					is_foreign_court_or_pool_guest = no
					NOT = {
						scope:target.top_liege = scope:owner.top_liege
					}
				}
			}
			modifier = { # Rulers are harder to kidnap
				add = -50
				desc = "FABRICATE_HOOK_RULER_TARGET"
				scope:target = {
					is_ruler = yes
					scope:target.top_liege = scope:owner.top_liege
				}
			}
		}

		# At War
		first_valid = {
			modifier = {
				add = -200
				desc = "SCHEME_AT_WAR"
				scope:target = {
					is_at_war_with = scope:owner
				}
			}
			modifier = {
				add = -150
				scope:target = {
					is_playable_character = no
					exists = liege
					liege = {
						is_at_war_with = scope:owner
					}
				}
				desc = "SCHEME_AT_WAR_WITH_LIEGE"
			}
			modifier = {
				add = -100
				scope:target = {
					is_playable_character = yes
					exists = liege
					liege = {
						is_at_war_with = scope:owner
					}
				}
				desc = "SCHEME_AT_WAR_WITH_LIEGE"
			}
		}

		# Diarchs are better at schemes within their liege's realm
		diarch_scheming_within_realm_bonus_modifier = yes

		# You have a secret tunnel yourself
		modifier = {
			add = 25
			desc = "SCHEME_SECRET_DOMICILE_TUNNEL"
			scope:owner = {
				exists = var:ep3_secret_tunnels_var
			}
		}

		# Tailor
		modifier = {
			add = 10
			scope:owner = {
				has_character_modifier = tournament_tailor_mixup_scheme_modifier
				exists = var:tailor_mixup_house
				exists = scope:target.house
				var:tailor_mixup_house = scope:target.house
			}
			desc = "tournament_tailor_mixup_scheme_modifier_value"
		}
	}
	base_secrecy = {
		add = secrecy_base_value
		add = countermeasure_apply_secrecy_maluses_value
	}

	# On Actions
	on_start = {
		set_variable = {
			name = apply_countermeasures
			value = flag:calculating
		}
		add_scheme_starting_opportunities_intrigue_effect = yes
		# Fallback agents — a balanced config if you start the scheme from script.
		if = {
			limit = {
				scheme_owner = {
					NOT = { has_variable = agents_added }
				}
			}
			add_agent_slot = agent_thug
			add_agent_slot = agent_thug
			add_agent_slot = agent_muscle
			add_agent_slot = agent_footpad
			add_agent_slot = agent_lookout
		}
	}
	on_phase_completed = {
		suppress_scheme_follow_up_event_till_input_given_effect = yes
		abduct_scheme_prep_effect = yes
		cap_schemes_and_fire_reminders_effect = yes
	}
	on_hud_click  = { abduct_scheme_prep_effect = yes }
	on_semiyearly = {
		if = {
			limit = {
				scheme_owner = { is_ai = yes }
			}
			abduct_scheme_prep_effect = yes
		}
	}
	on_monthly = {
		hostile_scheme_monthly_discovery_chance_effect = yes

		if = {
			limit = {
				NOT = { exists = scope:discovery_event_happening }
			}
			scheme_owner = {
				trigger_event = {
					on_action = abduct_ongoing
					days = { 1 30 }
				}
			}
		}
	}
	on_invalidated = {
		scheme_target_character = {
			save_scope_as = target
		}
		scheme_owner = {
			save_scope_as = owner
		}
		if = {
			limit = {
				scope:target = { is_alive = no }
			}
			scope:owner = {
				send_interface_toast = {
					title = abduct_scheme_invalidated_title
					left_icon = scope:target
					custom_description_no_bullet = {
						object = scope:target
						text = scheme_target_died
					}
				}
			}
		}
		else_if = {
			limit = {
				scope:target = {
					is_imprisoned = yes
					imprisoner = scope:owner
				}
				scope:owner = {
					NOT = { has_character_flag = is_in_event_abduct_outcome_0001 } #You probably abducted them
				}
			}
			scope:owner = {
				send_interface_message = {
					title = abduct_scheme_invalidated_title
					type = abduct_invalidated_i_imprisoned_message
					desc = abduct_scheme_i_imprisoned_them_message
					left_icon = scope:target
				}
			}
		}
		else_if = {
			limit = {
				scope:target = {
					is_imprisoned = yes
					NOT = { imprisoner = scope:owner }
				}
			}
			scope:target.imprisoner = {
				save_scope_as = other_imprisoner
			}
			scope:owner = {
				send_interface_toast = {
					title = abduct_scheme_invalidated_title
					left_icon = scope:target
					right_icon = scope:other_imprisoner
					custom_description_no_bullet = {
						subject = scope:other_imprisoner
						object = scope:target
						text = scheme_target_imprisoned_by_other
					}
				}
			}
		}
		else_if = {
			limit = {
				scope:target = {
					NOT = { in_diplomatic_range = scope:owner }
				}
			}
			scope:owner = {
				send_interface_toast = {
					title = abduct_scheme_invalidated_title
					left_icon = scope:target
					custom_description_no_bullet = {
						object = scope:target
						text = scheme_target_not_in_diplomatic_range
					}
				}
			}
		}
	}
}


code:
abduct = {
	# Basic Setup
	skill = intrigue
	desc = "abduct_desc_general"
	success_desc = "ABDUCT_SUCCESS_DESC"
	discovery_desc = "ABDUCT_DISCOVERY_DESC"
	icon = icon_scheme_abduct
	illustration = "gfx/interface/illustrations/event_scenes/corridor.dds"
	category = hostile
	target_type = character
	is_secret = yes
	maximum_breaches = 5
	cooldown = { years = 10 }

	# Parameters
	speed_per_skill_point = t2_spsp_owner_value
	speed_per_target_skill_point = t2_spsp_target_value
	base_progress_goal = t2_base_phase_length_value
	maximum_secrecy = 85
	base_maximum_success = t2_base_max_success_value
	phases_per_agent_charge = 1
	success_chance_growth_per_skill_point = t2_scgpsp_value

	# Core Triggers
	allow = {
		OR = {
			has_perk = kidnapper_perk # Scheme unlocked by the Kidnapper Perk
			domicile ?= { has_domicile_parameter = camp_unlocks_abduct_scheme }
			AND = {
				any_character_struggle = {
					involvement = involved
					has_struggle_phase_parameter = unlocks_abduct_for_all
					is_secondary_character_involvement_involved_trigger = {
						CHAR = scope:target
					}
				}
			}
			has_character_flag = can_use_abduct_scheme
			has_trait_with_flag = can_use_abduct_scheme
		}

		is_adult = yes
		is_playable_character = yes
		is_imprisoned = no
	}
	valid = {
		is_playable_character = yes
		is_ruler = yes
		is_incapable = no
		custom_description = { #If they're your kid you need special traits to do it
			text = abduct_own_children_block
			object = scope:target

			trigger_if = {
				limit = {
					is_parent_of = scope:target
				}
				has_trait_with_flag = can_murder_own_children
			}
		}
		scope:target = {
			is_imprisoned = no
			is_hostage = no
			exists = location
			in_diplomatic_range = scope:owner
		}
		# Special AI exceptions
		NOT = {
			scope:owner = {
				is_ai = yes
				has_opinion_modifier = {
					target = scope:target
					modifier = repentant_opinion
				}
			}
		}
	}

	# Agents
	agent_leave_threshold = -25
	agent_join_chance = {
		base = 0

		ai_agent_join_chance_basic_suite_modifier = yes
		ai_agent_join_chance_hostile_grievous_modifier = yes
	}
	agent_groups_owner_perspective = { courtiers guests scripted_relations }
	agent_groups_target_character_perspective = { courtiers vassals }
	valid_agent = { is_valid_agent_standard_trigger = yes }

	odds_prediction = {
		add = hostile_scheme_base_odds_prediction_target_is_char_value
		add = odds_skill_contribution_intrigue_value
		add = agent_groups_owner_perspective_value
		add = agent_groups_target_character_perspective_value
		add = odds_abduct_scheme_misc_value
		min = 0
	}

	# Base Chances
	base_success_chance = {
		base = 0
		scheme_type_skill_success_chance_modifier = { SKILL = INTRIGUE }

		hostile_scheme_base_chance_modifier = yes

		# Countermeasures.
		apply_calculated_scheme_success_chance_adjustments_modifier = yes

		# You found their escape tunnel
		modifier = {
			add = 100
			desc = "SCHEME_DISCOVERED_ESCAPE_TUNNEL"
			scope:owner = {
				exists = var:discovered_escape_tunnel_of
				var:discovered_escape_tunnel_of = scope:target
			}
		}

		# Spiritual Head of Faith
		modifier = {
			add = -50
			desc = "SCHEME_VS_SPIRITUAL_HOF"
			scope:target = {
				faith = scope:owner.faith
				faith = {
					has_doctrine = doctrine_spiritual_head
				}
				faith = {
					exists = religious_head
					religious_head = {
			 			this = scope:target
			 		}
				}
			}
		}

		# Sponsored Inspiration
		modifier = {
			add = -25
			desc = target_has_sponsored_inspiration
			scope:target = {
				exists = inspiration
				inspiration = { exists = inspiration_sponsor }
			}
		}

		# Family Feud
		house_feud_hostile_scheme_success_modifier = yes

		# Various penalties
		first_valid = {
			modifier = { # Foreign Rulers are very hard to kidnap
				add = -75
				desc = "sway_foreign_target"
				scope:target = {
					is_ruler = yes
					NOT = {
						scope:target.top_liege = scope:owner.top_liege
					}
				}
			}
			modifier = { # Foreign subjects less so
				add = -40
				desc = "sway_foreign_target"
				scope:target = {
					is_foreign_court_or_pool_guest = no
					NOT = {
						scope:target.top_liege = scope:owner.top_liege
					}
				}
			}
			modifier = { # Rulers are harder to kidnap
				add = -50
				desc = "FABRICATE_HOOK_RULER_TARGET"
				scope:target = {
					is_ruler = yes
					scope:target.top_liege = scope:owner.top_liege
				}
			}
		}

		# At War
		first_valid = {
			modifier = {
				add = -200
				desc = "SCHEME_AT_WAR"
				scope:target = {
					is_at_war_with = scope:owner
				}
			}
			modifier = {
				add = -150
				scope:target = {
					is_playable_character = no
					exists = liege
					liege = {
						is_at_war_with = scope:owner
					}
				}
				desc = "SCHEME_AT_WAR_WITH_LIEGE"
			}
			modifier = {
				add = -100
				scope:target = {
					is_playable_character = yes
					exists = liege
					liege = {
						is_at_war_with = scope:owner
					}
				}
				desc = "SCHEME_AT_WAR_WITH_LIEGE"
			}
		}

		# Diarchs are better at schemes within their liege's realm
		diarch_scheming_within_realm_bonus_modifier = yes

		# You have a secret tunnel yourself
		modifier = {
			add = 25
			desc = "SCHEME_SECRET_DOMICILE_TUNNEL"
			scope:owner = {
				exists = var:ep3_secret_tunnels_var
			}
		}

		# Tailor
		modifier = {
			add = 10
			scope:owner = {
				has_character_modifier = tournament_tailor_mixup_scheme_modifier
				exists = var:tailor_mixup_house
				exists = scope:target.house
				var:tailor_mixup_house = scope:target.house
			}
			desc = "tournament_tailor_mixup_scheme_modifier_value"
		}
	}
	base_secrecy = {
		add = secrecy_base_value
		add = countermeasure_apply_secrecy_maluses_value
	}

	# On Actions
	on_start = {
		set_variable = {
			name = apply_countermeasures
			value = flag:calculating
		}
		add_scheme_starting_opportunities_intrigue_effect = yes
		# Fallback agents — a balanced config if you start the scheme from script.
		if = {
			limit = {
				scheme_owner = {
					NOT = { has_variable = agents_added }
				}
			}
			add_agent_slot = agent_thug
			add_agent_slot = agent_thug
			add_agent_slot = agent_muscle
			add_agent_slot = agent_footpad
			add_agent_slot = agent_lookout
		}
	}
	on_phase_completed = {
		suppress_scheme_follow_up_event_till_input_given_effect = yes
		abduct_scheme_prep_effect = yes
		cap_schemes_and_fire_reminders_effect = yes
	}
	on_hud_click  = { abduct_scheme_prep_effect = yes }
	on_semiyearly = {
		if = {
			limit = {
				scheme_owner = { is_ai = yes }
			}
			abduct_scheme_prep_effect = yes
		}
	}
	on_monthly = {
		hostile_scheme_monthly_discovery_chance_effect = yes

		if = {
			limit = {
				NOT = { exists = scope:discovery_event_happening }
			}
			scheme_owner = {
				trigger_event = {
					on_action = abduct_ongoing
					days = { 1 30 }
				}
			}
		}
	}
	on_invalidated = {
		scheme_target_character = {
			save_scope_as = target
		}
		scheme_owner = {
			save_scope_as = owner
		}
		if = {
			limit = {
				scope:target = { is_alive = no }
			}
			scope:owner = {
				send_interface_toast = {
					title = abduct_scheme_invalidated_title
					left_icon = scope:target
					custom_description_no_bullet = {
						object = scope:target
						text = scheme_target_died
					}
				}
			}
		}
		else_if = {
			limit = {
				scope:target = {
					is_imprisoned = yes
					imprisoner = scope:owner
				}
				scope:owner = {
					NOT = { has_character_flag = is_in_event_abduct_outcome_0001 } #You probably abducted them
				}
			}
			scope:owner = {
				send_interface_message = {
					title = abduct_scheme_invalidated_title
					type = abduct_invalidated_i_imprisoned_message
					desc = abduct_scheme_i_imprisoned_them_message
					left_icon = scope:target
				}
			}
		}
		else_if = {
			limit = {
				scope:target = {
					is_imprisoned = yes
					NOT = { imprisoner = scope:owner }
				}
			}
			scope:target.imprisoner = {
				save_scope_as = other_imprisoner
			}
			scope:owner = {
				send_interface_toast = {
					title = abduct_scheme_invalidated_title
					left_icon = scope:target
					right_icon = scope:other_imprisoner
					custom_description_no_bullet = {
						subject = scope:other_imprisoner
						object = scope:target
						text = scheme_target_imprisoned_by_other
					}
				}
			}
		}
		else_if = {
			limit = {
				scope:target = {
					NOT = { in_diplomatic_range = scope:owner }
				}
			}
			scope:owner = {
				send_interface_toast = {
					title = abduct_scheme_invalidated_title
					left_icon = scope:target
					custom_description_no_bullet = {
						object = scope:target
						text = scheme_target_not_in_diplomatic_range
					}
				}
			}
		}
	}
}


code:
# used in carn_had_sex_with_effect
carn_birth_control_pregnancy_chance_multiplier = 0.1


code:
carn_dick_size_value = {
	value = 0
	if = {
		limit = { carn_has_dick_big_1_trigger = yes }
		add = 1
	}
	else_if = {
		limit = { carn_has_dick_big_2_trigger = yes }
		add = 2
	}
	else_if = {
		limit = { carn_has_dick_big_3_trigger = yes }
		add = 3
	}
	else_if = {
		limit = { carn_has_dick_small_1_trigger = yes }
		add = -1
	}
	else_if = {
		limit = { carn_has_dick_small_2_trigger = yes }
		add = -2
	}
	else_if = {
		limit = { carn_has_dick_small_3_trigger = yes }
		add = -3
	}
}

carn_tits_size_value = {
	value = 0
	if = {
		limit = { carn_has_tits_big_1_trigger = yes }
		add = 1
	}
	else_if = {
		limit = { carn_has_tits_big_2_trigger = yes }
		add = 2
	}
	else_if = {
		limit = { carn_has_tits_big_3_trigger = yes }
		add = 3
	}
	else_if = {
		limit = { carn_has_tits_small_1_trigger = yes }
		add = -1
	}
	else_if = {
		limit = { carn_has_tits_small_2_trigger = yes }
		add = -2
	}
	else_if = {
		limit = { carn_has_tits_small_3_trigger = yes }
		add = -3
	}
}


code:
carn_futa_very_rare_chance = 0.1
carn_futa_rare_chance = 0.5
carn_futa_uncommon_chance = 2.5
carn_futa_common_chance = 10
carn_futa_very_common_chance = 25


code:
carn_on_pregnancy_milk_production_increase = 100
carn_on_pregnancy_milk_production_cap = 300
carn_yearly_milk_production_change = -20
carn_lactation_age_cutoff = 45

#############################################################
# Very Low milk production
#############################################################
# after a lot of coaxing, a few droplets come out

carn_very_low_milk_production_amount = 1

#############################################################
# Low milk production
#############################################################
# after some coaxing, a thin stream of milk comes out

carn_low_milk_production_amount = 40

#############################################################
# Average milk production
#############################################################
# after some coaxing, a regular flow of milk comes out
# your breasts get sore and leak milk if you don't milk them
# this is the default human level of lactation following pregnancy

carn_average_milk_production_amount = 80

#############################################################
# High milk production
#############################################################
# your breasts are sensitive and prone to let down milk, and get swollen if you don't milk them
# this is the realistic maximum for humans irl

carn_high_milk_production_amount = 200

#############################################################
# Very High milk production
#############################################################
# superhuman levels of milk production
# milk is constantly oozing from your breasts, you need to be milked regularly
# this is how the average "hucow" is depicted

carn_very_high_milk_production_amount = 500

#############################################################
# Extreme milk production
#############################################################
# milk is constantly running from your breasts, it's hard to have a normal life
# you're basically a pair of milk factories attached to a girl

carn_extreme_milk_production_amount = 1000


code:
carn_prostitution_age_cutoff = 45

carn_prostitute_sex_interaction_price_value = {
	value = 15
	if = {
		limit = {
			has_trait_xp = {
				trait = lifestyle_prostitute
				value >= 100
			}
		}
		multiply = 5
	}
	else_if = {
		limit = {
			has_trait_xp = {
				trait = lifestyle_prostitute
				value >= 50
			}
		}
		multiply = 2
	}
}


code:
carn_sex_interaction_cooldown_base = {
	value = 12
}

carn_sex_interaction_cooldown = {
	value = carn_sex_interaction_cooldown_base
	if = {
		limit = { has_game_rule = carn_sex_interaction_no_cd }
		multiply = 0
	}
}


code:
# requires scope:mother and scope:father to be provided
# not using any of the spouse,concubine, secondary spouse fertility multiplier as define in base game
# as those are to calculate monthly pregnancy,using in a manual one does not seems right.
carn_sex_pregnancy_chance = {
	# get base fertility multiplier
	value = 0
	if = {
		limit = {
			NOR = {
				scope:mother.fertility < 0.1
				scope:father.fertility < 0.1
			}
		}
		# Use carn_pregnancy_chance if available on the mother for backward compatibility
		if = {
			limit = { exists = scope:mother.var:carn_pregnancy_chance }
			add = scope:mother.var:carn_pregnancy_chance
		}
		else = {
			add = {
				value = scope:mother.fertility
			}
			add = {
				value = scope:father.fertility
			}
			#Scaling to a avg of 30 if both got 0.5 fertility
			multiply = 30
		}
	}
}


code:
carn_slave_prostitution_income_value = {
	value = 0
	if = {
		limit = {
			has_trait_xp = {
				trait = lifestyle_prostitute
				value >= 100
			}
		}
		add = 12 # 2 multiplied by 6 months
	}
	else_if = {
		limit = {
			has_trait_xp = {
				trait = lifestyle_prostitute
				value >= 50
			}
		}
		add = 6 # 1 multiplied by 6 months
	}
	else_if = {
		limit = {
			has_trait = lifestyle_prostitute
		}
		add = 3 # 0.5 multiplied by 6 months
	}
}

carn_max_slave_prostitutes_per_owner = 10


code:
carn_slave_price_value = {
	value = 1

	# congenital traits
	if = {
		limit = { has_trait = beauty_good_1 }
		add = 1
	}
	if = {
		limit = { has_trait = beauty_good_2 }
		add = 2
	}
	if = {
		limit = { has_trait = beauty_good_3 }
		add = 3
	}
	if = {
		limit = { has_trait = beauty_bad_1 }
		add = -1
	}
	if = {
		limit = { has_trait = beauty_bad_2 }
		add = -2
	}
	if = {
		limit = { has_trait = beauty_bad_3 }
		add = -3
	}
	if = {
		limit = { has_trait = physique_good_1 }
		add = 1
	}
	if = {
		limit = { has_trait = physique_good_2 }
		add = 2
	}
	if = {
		limit = { has_trait = physique_good_3 }
		add = 3
	}
	if = {
		limit = { has_trait = physique_bad_1 }
		add = -1
	}
	if = {
		limit = { has_trait = physique_bad_2 }
		add = -2
	}
	if = {
		limit = { has_trait = physique_bad_3 }
		add = -3
	}
	if = {
		limit = { has_trait = intellect_good_1 }
		add = 1
	}
	if = {
		limit = { has_trait = intellect_good_2 }
		add = 2
	}
	if = {
		limit = { has_trait = intellect_good_3 }
		add = 3
	}
	if = {
		limit = { has_trait = intellect_bad_1 }
		add = -1
	}
	if = {
		limit = { has_trait = intellect_bad_2 }
		add = -2
	}
	if = {
		limit = { has_trait = intellect_bad_3 }
		add = -3
	}
	if = {
		limit = { has_trait = pure_blooded }
		add = 3
	}
	if = {
		limit = { has_trait = clubfooted }
		add = -1
	}
	if = {
		limit = { has_trait = hunchbacked }
		add = -1
	}
	if = {
		limit = { has_trait = lisping }
		add = -1
	}
	if = {
		limit = { has_trait = stuttering }
		add = -1
	}
	if = {
		limit = { has_trait = inbred }
		add = -5
	}
	if = {
		limit = { has_trait = spindly }
		add = -1
	}
	if = {
		limit = { has_trait = scaly }
		add = -1
	}
	if = {
		limit = { has_trait = wheezing }
		add = -1
	}
	if = {
		limit = { has_trait = bleeder }
		add = -1
	}
	if = {
		limit = { has_trait = depressed_1 }
		add = -3
	}
	if = {
		limit = { has_trait = depressed_genetic }
		add = -3
	}
	if = {
		limit = { has_trait = lunatic_1 }
		add = -5
	}
	if = {
		limit = { has_trait = lunatic_genetic }
		add = -5
	}
	if = {
		limit = { has_trait = possessed_1 }
		add = -5
	}
	if = {
		limit = { has_trait = possessed_genetic }
		add = -5
	}
	if = {
		limit = {
			has_trait = fecund
			is_visibly_fertile = yes
		}
		add = 1
	}
	if = {
		limit = {
			has_trait = infertile
			is_visibly_fertile = yes
		}
		add = -1
	}

	# personality traits
	if = {
		limit = { has_trait = diligent }
		add = 1
	}
	if = {
		limit = { has_trait = humble }
		add = 1
	}
	if = {
		limit = { has_trait = content }
		add = 1
	}
	if = {
		limit = { has_trait = lazy }
		add = -1
	}
	if = {
		limit = { has_trait = arrogant }
		add = -1
	}
	if = {
		limit = { has_trait = ambitious }
		add = -1
	}

	# stress traits
	if = {
		limit = { has_trait = drunkard }
		add = -3
	}
	if = {
		limit = { has_trait = hashishiyah }
		add = -3
	}
	if = {
		limit = { has_trait = rakish }
		add = -3
	}
	if = {
		limit = { has_trait = irritable }
		add = -1
	}
	if = {
		limit = { has_trait = contrite }
		add = -1
	}
	if = {
		limit = { has_trait = athletic }
		add = 1
	}

	# other traits
	if = {
		limit = { has_trait = strong }
		add = 1
	}
	if = {
		limit = { has_trait = shrewd }
		add = 1
	}
	if = { # historically, eunuchs were worth more (they don't fuck your wife)
		limit = { is_eunuch_trigger = yes }
		add = 1
	}
	if = {
		limit = { has_trait = weak }
		add = -1
	}
	if = {
		limit = { has_trait = dull }
		add = -1
	}
	if = {
		limit = {
			is_female = yes # sexism against impotent women
			has_trait = impotent
			is_visibly_fertile = yes
		}
		add = -1
	}
	if = {
		limit = {
			OR = {
				has_trait = sayyid
				has_trait = blood_of_prophet
			}
		}
		add = 1
	}
	if = {
		limit = { # famous slaves get top shelf prices
			OR = {
				has_trait = faith_warrior
				has_trait = berserker
				has_trait = varangian
				has_trait = viking
				has_trait = reincarnation
			}
		}
		add = 3
	}
	if = {
		limit = { has_treatable_disease_trigger = yes }
		add = -5
	}
	if = {
		limit = { has_contagious_disease_trigger = yes }
		add = -1000 # don't touch this with a ten foot pole
	}
	if = {
		limit = { has_wounds_trigger = yes }
		add = -5
	}
	if = {
		limit = { has_trait = maimed }
		add = -5
	}
	if = {
		limit = { has_trait = disfigured }
		add = -5
	}
	if = {
		limit = { has_trait = blind }
		add = -5
	}
	if = {
		limit = { is_incapable = yes }
		add = -1000 # what's the point of buying an incapable slave?
	}
	if = {
		limit = { has_trait = sickly }
		add = -1000 # kid might die on you
	}

	# very young children and elderly are worth less
	if = {
		limit = {
			is_immortal = no
			OR = {
				effective_age < 6
				effective_age >= 50
			}
		}
		multiply = 0.5
	}

	# highborn slaves are worth more
	if = {
		limit = { is_lowborn = no }
		multiply = 2
	}

	# female slaves are worth 3x (historically attested)
	if = {
		limit = {
			is_female = yes
			is_visibly_fertile = yes
		}
		multiply = 3
	}

	# enslaving the saoshyant!!!
	if = {
		limit = {
			OR = {
				has_trait = saoshyant
				has_trait = savior
				has_trait = augustus
				has_trait = chakravarti
				has_trait = greatest_of_khans
				has_trait = paragon
			}
		}
		multiply = 2
		add = 100
	}
	if = {
		limit = {
			OR = {
				has_trait = saoshyant_descendant
				has_trait = divine_blood
				has_trait = saint
				has_trait = born_in_the_purple
				has_trait = consecrated_blood
			}
		}
		multiply = 2
	}

	# claims (unaffected by age and gender considerations)
	every_claim = {
		if = {
			limit = { tier = tier_barony }
			add = 10
		}
		else_if = {
			limit = { tier = tier_county }
			add = 30
		}
		else_if = {
			limit = { tier = tier_duchy }
			add = 120
		}
		else_if = {
			limit = { tier = tier_kingdom }
			add = 600
		}
		else_if = {
			limit = { tier = tier_empire }
			add = 3000
		}
	}

	# skills (unaffected by age and gender considerations)
	if = {
		limit = { highest_skill = diplomacy }
		add = {
			add = diplomacy
			add = -10
			min = 0
		}
	}
	else_if = {
		limit = { highest_skill = martial }
		add = {
			add = martial
			add = -10
			min = 0
		}
	}
	else_if = {
		limit = { highest_skill = stewardship }
		add = {
			add = stewardship
			add = -10
			min = 0
		}
	}
	else_if = {
		limit = { highest_skill = intrigue }
		add = {
			add = intrigue
			add = -10
			min = 0
		}
	}
	else_if = {
		limit = { highest_skill = learning }
		add = {
			add = learning
			add = -10
			min = 0
		}
	}
	if = {
		limit = { prowess > 10 }
		add = prowess
		add = -10
	}

	# all slaves have a value of at least one ducat, even if they're crap
	min = 1
}

# used in localization for carn_buy_slave_effect
carn_scope_recipient_carn_slave_price_value = {
	value = scope:recipient.carn_slave_price_value
}
carn_scope_buyer_current_gold_value = {
	value = scope:buyer.current_gold_value
}
carn_scope_slave_price_value = {
	value = scope:slave_price
}


code:
demand_free_illegal_slaves_likelihood_calculation = {
	# Keep conversion's learning difference; who knows the law better?
	add = demand_conversion_learning_difference

	# Removed fervor calc, but would like to put something like it
	# More likely to accept if faith fervor is high? I.E. this will look bad if I say no?

	# Opinion impacts
	if = {
		limit = {
			opinion = {
				target = scope:actor
				value < medium_negative_opinion
			}
		}
		add = -50
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:actor
				value < neutral_opinion
			}
		}
		add = -25
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:actor
				value >= medium_positive_opinion
			}
		}
		add = 50
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:actor
				value > neutral_opinion
			}
		}
		add = 25
	}

	# Trait Impacts
	# Less likely to accept if requestor is former slave
	if = {
		limit = {
			scope:actor = { has_trait = former_slave }
		}
		add = -15
	}
	# Less likely to accept if zealous and different faith than requestor
	if = {
		limit = {
      AND = {
        has_trait = zealous
        NOT = { faith = scope:actor.faith }
      }
		}
		add = -50
	}

	# Refusing is always a crime, so add a flat "jail is scary" mod
	add = 50

	# Dread Impact
	if = {
		limit = {
			scope:recipient = {
				has_dread_level_towards = {
					target = scope:actor
					level = 1
				}
			}
		}
		add = 10
	}
	if = {
		limit = {
			scope:recipient = {
				has_dread_level_towards = {
					target = scope:actor
					level = 2
				}
			}
		}
		add = 20
	}

	max = 100
}


code:
# carn_start_custom_pregnancy_effect (requires `PREGNANCY_TYPE`, `DAYS_UNTIL_NEXT_STAGE`, `CAN_BE_ABORTED`)
# carn_setup_delayed_custom_pregnancy_stage_change (requires `DAYS`)
# carn_end_custom_pregnancy_effect

# carn_start_custom_pregnancy_effect
# requires:
# PREGNANCY_TYPE (arbitary string),
# DAYS_UNTIL_NEXT_STAGE (integer),
# CAN_BE_ABORTED (yes/no)
carn_start_custom_pregnancy_effect = {
	save_scope_value_as = {
		name = new_pregnancy_type
		value = flag:$PREGNANCY_TYPE$
	}
	if = {
		limit = {
			carn_has_any_custom_pregnancy_trigger = yes
			carn_custom_pregnancy_can_be_aborted_trigger = no
		}
		trigger_event = {
			on_action = carn_on_custom_pregnancy_failed_to_replace_custom_pregnancy
		}
	}
	else_if = {
		limit = {
			carn_normal_pregnancy_can_be_aborted_trigger = no
		}
		trigger_event = {
			on_action = carn_on_custom_pregnancy_failed_to_replace_normal_pregnancy
		}
	}
	else = {
		if = {
			limit = {
				carn_has_any_custom_pregnancy_trigger = yes
			}
			trigger_event = {
				on_action = carn_on_custom_pregnancy_replace_custom_pregnancy
			}
			carn_end_custom_pregnancy_effect = yes
		}
		set_variable = {
			name = carn_custom_pregnancy
			value = flag:$PREGNANCY_TYPE$
		}
		set_variable = {
			name = carn_custom_pregnancy_stage
			value = 0
		}
		if = {
			limit = {
				$CAN_BE_ABORTED$ = no
			}
			add_character_flag = carn_block_aborting_next_custom_pregnancy
		}
		if = {
			limit = {
				is_pregnant = yes
			}
			if = {
				limit = {
					carn_has_absolute_birth_control_trigger = yes
				}
				trigger_event = {
					id = carn_absolute_birth_control.0001
				}
			}
			else = {
				trigger_event = {
					on_action = carn_on_custom_pregnancy_replace_normal_pregnancy
				}
				end_pregnancy = yes
			}
		}
		trigger_event = {
			on_action = carn_on_start_custom_pregnancy
		}
		trigger_event = {
			id = carn_custom_pregnancy.0001
			days = $DAYS_UNTIL_NEXT_STAGE$
		}
	}
}

# carn_setup_delayed_custom_pregnancy_stage_change
# requires DAYS (integer)
carn_setup_delayed_custom_pregnancy_stage_change = {
	trigger_event = {
		id = carn_custom_pregnancy.0001
		days = $DAYS$
	}
}

# carn_end_custom_pregnancy_effect
carn_end_custom_pregnancy_effect = {
	trigger_event = {
		on_action = carn_on_end_custom_pregnancy
	}
	remove_variable = carn_custom_pregnancy
	remove_variable = carn_custom_pregnancy_stage
	remove_character_flag = carn_block_aborting_next_custom_pregnancy
}


code:
#
# carn_seed_dt_traits_effect
# carn_flip_ruler_designed_dt_traits_to_game_rule_effect
# carn_make_all_dt_traits_inactive_effect
# carn_activate_gender_specific_dt_traits_effect
#
# carn_remove_dick_trait_effect
# carn_remove_tits_trait_effect
#
# carn_increase_dick_size_one_step_effect
# carn_decrease_dick_size_one_step_effect
# carn_increase_tits_size_one_step_effect
# carn_decrease_tits_size_one_step_effect
#
# carn_add_dick_small_1_effect
# carn_add_dick_small_2_effect
# carn_add_dick_small_3_effect
# carn_add_dick_big_1_effect
# carn_add_dick_big_2_effect
# carn_add_dick_big_3_effect
# carn_add_dick_small_1_effect
# carn_add_tits_small_2_effect
# carn_add_tits_small_3_effect
# carn_add_tits_big_1_effect
# carn_add_tits_big_2_effect
# carn_add_tits_big_3_effect
#
# carn_add_inactive_dick_small_1_effect
# carn_add_inactive_dick_small_2_effect
# carn_add_inactive_dick_small_3_effect
# carn_add_inactive_dick_big_1_effect
# carn_add_inactive_dick_big_2_effect
# carn_add_inactive_dick_big_3_effect
# carn_add_inactive_dick_small_1_effect
# carn_add_inactive_tits_small_2_effect
# carn_add_inactive_tits_small_3_effect
# carn_add_inactive_tits_big_1_effect
# carn_add_inactive_tits_big_2_effect
# carn_add_inactive_tits_big_3_effect
#

# randomly seed inactive dick and tits traits, regardless of age or gender
carn_seed_dt_traits_effect = {
	if = {
		limit = { has_character_flag = carn_seed_dick_small_1 }
		carn_add_dick_small_1_effect = yes
	}
	else_if = {
		limit = { has_character_flag = carn_seed_dick_small_2 }
		carn_add_dick_small_2_effect = yes
	}
	else_if = {
		limit = { has_character_flag = carn_seed_dick_small_3 }
		carn_add_dick_small_3_effect = yes
	}
	else_if = {
		limit = { has_character_flag = carn_seed_dick_big_1 }
		carn_add_dick_big_1_effect = yes
	}
	else_if = {
		limit = { has_character_flag = carn_seed_dick_big_2 }
		carn_add_dick_big_2_effect = yes
	}
	else_if = {
		limit = { has_character_flag = carn_seed_dick_big_3 }
		carn_add_dick_big_3_effect = yes
	}
	else_if = {
		limit = {
			carn_has_any_dick_gene_trigger = no
		}
		random_list = {
			820 = {
				# nothing
			}
			50 = {
				carn_add_inactive_dick_small_1_effect = yes
			}
			25 = {
				carn_add_inactive_dick_small_2_effect = yes
			}
			15 = {
				carn_add_inactive_dick_small_3_effect = yes
			}
			50 = {
				carn_add_inactive_dick_big_1_effect = yes
			}
			25 = {
				carn_add_inactive_dick_big_2_effect = yes
			}
			15 = {
				carn_add_inactive_dick_big_3_effect = yes
			}
		}
	}
	if = {
		limit = { has_character_flag = carn_seed_tits_small_1 }
		carn_add_tits_small_1_effect = yes
	}
	else_if = {
		limit = { has_character_flag = carn_seed_tits_small_2 }
		carn_add_tits_small_2_effect = yes
	}
	else_if = {
		limit = { has_character_flag = carn_seed_tits_small_3 }
		carn_add_tits_small_3_effect = yes
	}
	else_if = {
		limit = { has_character_flag = carn_seed_tits_big_1 }
		carn_add_tits_big_1_effect = yes
	}
	else_if = {
		limit = { has_character_flag = carn_seed_tits_big_2 }
		carn_add_tits_big_2_effect = yes
	}
	else_if = {
		limit = { has_character_flag = carn_seed_tits_big_3 }
		carn_add_tits_big_3_effect = yes
	}
	else_if = {
		limit = {
			carn_has_any_tits_gene_trigger = no
		}
		random_list = {
			820 = {
				# nothing
			}
			50 = {
				carn_add_inactive_tits_small_1_effect = yes
			}
			25 = {
				carn_add_inactive_tits_small_2_effect = yes
			}
			15 = {
				carn_add_inactive_tits_small_3_effect = yes
			}
			50 = {
				carn_add_inactive_tits_big_1_effect = yes
			}
			25 = {
				carn_add_inactive_tits_big_2_effect = yes
			}
			15 = {
				carn_add_inactive_tits_big_3_effect = yes
			}
		}
	}
	add_character_flag = carn_dt_traits_seeded
}

carn_flip_ruler_designed_dt_traits_to_game_rule_effect = {
	if = {
		limit = { has_game_rule = carn_dt_dick_small_bad }
		if = {
			limit = { has_trait = dick_small_good_1 }
			remove_trait = dick_small_good_1
			add_trait = dick_small_bad_1
		}
		else_if = {
			limit = { has_trait = dick_small_good_2 }
			remove_trait = dick_small_good_2
			add_trait = dick_small_bad_2
		}
		if = {
			limit = { has_trait = dick_small_good_3 }
			remove_trait = dick_small_good_3
			add_trait = dick_small_bad_3
		}
	}
	if = {
		limit = { has_game_rule = carn_dt_dick_big_bad }
		if = {
			limit = { has_trait = dick_big_good_1 }
			remove_trait = dick_big_good_1
			add_trait = dick_big_bad_1
		}
		else_if = {
			limit = { has_trait = dick_big_good_2 }
			remove_trait = dick_big_good_2
			add_trait = dick_big_bad_2
		}
		if = {
			limit = { has_trait = dick_big_good_3 }
			remove_trait = dick_big_good_3
			add_trait = dick_big_bad_3
		}
	}
	if = {
		limit = { has_game_rule = carn_dt_tits_small_bad }
		if = {
			limit = { has_trait = tits_small_good_1 }
			remove_trait = tits_small_good_1
			add_trait = tits_small_bad_1
		}
		else_if = {
			limit = { has_trait = tits_small_good_2 }
			remove_trait = tits_small_good_2
			add_trait = tits_small_bad_2
		}
		if = {
			limit = { has_trait = tits_small_good_3 }
			remove_trait = tits_small_good_3
			add_trait = tits_small_bad_3
		}
	}
	if = {
		limit = { has_game_rule = carn_dt_tits_big_bad }
		if = {
			limit = { has_trait = tits_big_good_1 }
			remove_trait = tits_big_good_1
			add_trait = tits_big_bad_1
		}
		else_if = {
			limit = { has_trait = tits_big_good_2 }
			remove_trait = tits_big_good_2
			add_trait = tits_big_bad_2
		}
		if = {
			limit = { has_trait = tits_big_good_3 }
			remove_trait = tits_big_good_3
			add_trait = tits_big_bad_3
		}
	}
}

# makes all dt traits inactive for children
carn_make_all_dt_traits_inactive_effect = {
	if = {
		limit = { has_trait = dick_small_good_1 }
		make_trait_inactive = dick_small_good_1
	}
	else_if = {
		limit = { has_trait = dick_small_good_2 }
		make_trait_inactive = dick_small_good_2
	}
	else_if = {
		limit = { has_trait = dick_small_good_3 }
		make_trait_inactive = dick_small_good_3
	}
	else_if = {
		limit = { has_trait = dick_small_bad_1 }
		make_trait_inactive = dick_small_bad_1
	}
	else_if = {
		limit = { has_trait = dick_small_bad_2 }
		make_trait_inactive = dick_small_bad_2
	}
	else_if = {
		limit = { has_trait = dick_small_bad_3 }
		make_trait_inactive = dick_small_bad_3
	}
	else_if = {
		limit = { has_trait = dick_big_good_1 }
		make_trait_inactive = dick_big_good_1
	}
	else_if = {
		limit = { has_trait = dick_big_good_2 }
		make_trait_inactive = dick_big_good_2
	}
	else_if = {
		limit = { has_trait = dick_big_good_3 }
		make_trait_inactive = dick_big_good_3
	}
	else_if = {
		limit = { has_trait = dick_big_bad_1 }
		make_trait_inactive = dick_big_bad_1
	}
	else_if = {
		limit = { has_trait = dick_big_bad_2 }
		make_trait_inactive = dick_big_bad_2
	}
	else_if = {
		limit = { has_trait = dick_big_bad_3 }
		make_trait_inactive = dick_big_bad_3
	}
	if = {
		limit = { has_trait = tits_small_good_1 }
		make_trait_inactive = tits_small_good_1
	}
	else_if = {
		limit = { has_trait = tits_small_good_2 }
		make_trait_inactive = tits_small_good_2
	}
	else_if = {
		limit = { has_trait = tits_small_good_3 }
		make_trait_inactive = tits_small_good_3
	}
	else_if = {
		limit = { has_trait = tits_small_bad_1 }
		make_trait_inactive = tits_small_bad_1
	}
	else_if = {
		limit = { has_trait = tits_small_bad_2 }
		make_trait_inactive = tits_small_bad_2
	}
	else_if = {
		limit = { has_trait = tits_small_bad_3 }
		make_trait_inactive = tits_small_bad_3
	}
	else_if = {
		limit = { has_trait = tits_big_good_1 }
		make_trait_inactive = tits_big_good_1
	}
	else_if = {
		limit = { has_trait = tits_big_good_2 }
		make_trait_inactive = tits_big_good_2
	}
	else_if = {
		limit = { has_trait = tits_big_good_3 }
		make_trait_inactive = tits_big_good_3
	}
	else_if = {
		limit = { has_trait = tits_big_bad_1 }
		make_trait_inactive = tits_big_bad_1
	}
	else_if = {
		limit = { has_trait = tits_big_bad_2 }
		make_trait_inactive = tits_big_bad_2
	}
	else_if = {
		limit = { has_trait = tits_big_bad_3 }
		make_trait_inactive = tits_big_bad_3
	}
}

# selectively enables dt traits based on character's gender
carn_activate_gender_specific_dt_traits_effect = {

	# dick
	if = {
		limit = { carn_should_have_dick_trigger = yes }
		if = {
			limit = { has_inactive_trait = dick_small_good_1 }
			make_trait_active = dick_small_good_1
		}
		else_if = {
			limit = { has_inactive_trait = dick_small_good_2 }
			make_trait_active = dick_small_good_2
		}
		else_if = {
			limit = { has_inactive_trait = dick_small_good_3 }
			make_trait_active = dick_small_good_3
		}
		else_if = {
			limit = { has_inactive_trait = dick_small_bad_1 }
			make_trait_active = dick_small_bad_1
		}
		else_if = {
			limit = { has_inactive_trait = dick_small_bad_2 }
			make_trait_active = dick_small_bad_2
		}
		else_if = {
			limit = { has_inactive_trait = dick_small_bad_3 }
			make_trait_active = dick_small_bad_3
		}
		else_if = {
			limit = { has_inactive_trait = dick_big_good_1 }
			make_trait_active = dick_big_good_1
		}
		else_if = {
			limit = { has_inactive_trait = dick_big_good_2 }
			make_trait_active = dick_big_good_2
		}
		else_if = {
			limit = { has_inactive_trait = dick_big_good_3 }
			make_trait_active = dick_big_good_3
		}
		else_if = {
			limit = { has_inactive_trait = dick_big_bad_1 }
			make_trait_active = dick_big_bad_1
		}
		else_if = {
			limit = { has_inactive_trait = dick_big_bad_2 }
			make_trait_active = dick_big_bad_2
		}
		else_if = {
			limit = { has_inactive_trait = dick_big_bad_3 }
			make_trait_active = dick_big_bad_3
		}
	}

	# tits
	if = {
		limit = { carn_should_have_tits_trigger = yes }
		if = {
			limit = { has_inactive_trait = tits_small_good_1 }
			make_trait_active = tits_small_good_1
		}
		else_if = {
			limit = { has_inactive_trait = tits_small_good_2 }
			make_trait_active = tits_small_good_2
		}
		else_if = {
			limit = { has_inactive_trait = tits_small_good_3 }
			make_trait_active = tits_small_good_3
		}
		else_if = {
			limit = { has_inactive_trait = tits_small_bad_1 }
			make_trait_active = tits_small_bad_1
		}
		else_if = {
			limit = { has_inactive_trait = tits_small_bad_2 }
			make_trait_active = tits_small_bad_2
		}
		else_if = {
			limit = { has_inactive_trait = tits_small_bad_3 }
			make_trait_active = tits_small_bad_3
		}
		else_if = {
			limit = { has_inactive_trait = tits_big_good_1 }
			make_trait_active = tits_big_good_1
		}
		else_if = {
			limit = { has_inactive_trait = tits_big_good_2 }
			make_trait_active = tits_big_good_2
		}
		else_if = {
			limit = { has_inactive_trait = tits_big_good_3 }
			make_trait_active = tits_big_good_3
		}
		else_if = {
			limit = { has_inactive_trait = tits_big_bad_1 }
			make_trait_active = tits_big_bad_1
		}
		else_if = {
			limit = { has_inactive_trait = tits_big_bad_2 }
			make_trait_active = tits_big_bad_2
		}
		else_if = {
			limit = { has_inactive_trait = tits_big_bad_3 }
			make_trait_active = tits_big_bad_3
		}
	}
}

carn_remove_dick_trait_effect = {
	remove_trait = dick_small_good_1
	remove_trait = dick_small_good_2
	remove_trait = dick_small_good_3
	remove_trait = dick_small_bad_1
	remove_trait = dick_small_bad_2
	remove_trait = dick_small_bad_3
	remove_trait = dick_big_good_1
	remove_trait = dick_big_good_2
	remove_trait = dick_big_good_3
	remove_trait = dick_big_bad_1
	remove_trait = dick_big_bad_2
	remove_trait = dick_big_bad_3
}

carn_remove_tits_trait_effect = {
	remove_trait = tits_small_good_1
	remove_trait = tits_small_good_2
	remove_trait = tits_small_good_3
	remove_trait = tits_small_bad_1
	remove_trait = tits_small_bad_2
	remove_trait = tits_small_bad_3
	remove_trait = tits_big_good_1
	remove_trait = tits_big_good_2
	remove_trait = tits_big_good_3
	remove_trait = tits_big_bad_1
	remove_trait = tits_big_bad_2
	remove_trait = tits_big_bad_3
}

carn_increase_dick_size_one_step_effect = {
	if = {
		limit = {
			has_game_rule = carn_dt_enabled
			is_adult = yes
			carn_should_have_dick_trigger = yes
		}
		if = {
			limit = { carn_has_dick_big_2_trigger = yes }
			carn_remove_dick_trait_effect = yes
			carn_add_dick_big_3_effect = yes
		}
		else_if = {
			limit = { carn_has_dick_big_1_trigger = yes }
			carn_remove_dick_trait_effect = yes
			carn_add_dick_big_2_effect = yes
		}
		else_if = {
			limit = { carn_has_dick_small_3_trigger = yes }
			carn_remove_dick_trait_effect = yes
			carn_add_dick_small_2_effect = yes
		}
		else_if = {
			limit = { carn_has_dick_small_2_trigger = yes }
			carn_remove_dick_trait_effect = yes
			carn_add_dick_small_1_effect = yes
		}
		else_if = {
			limit = { carn_has_dick_small_1_trigger = yes }
			carn_remove_dick_trait_effect = yes
		}
		else = {
			carn_add_dick_big_1_effect = yes
		}
	}
}

carn_decrease_dick_size_one_step_effect = {
	if = {
		limit = {
			has_game_rule = carn_dt_enabled
			is_adult = yes
			carn_should_have_dick_trigger = yes
		}
		if = {
			limit = { carn_has_dick_small_2_trigger = yes }
			carn_remove_dick_trait_effect = yes
			carn_add_dick_small_3_effect = yes
		}
		else_if = {
			limit = { carn_has_dick_small_1_trigger = yes }
			carn_remove_dick_trait_effect = yes
			carn_add_dick_small_2_effect = yes
		}
		else_if = {
			limit = { carn_has_dick_big_3_trigger = yes }
			carn_remove_dick_trait_effect = yes
			carn_add_dick_big_2_effect = yes
		}
		else_if = {
			limit = { carn_has_dick_big_2_trigger = yes }
			carn_remove_dick_trait_effect = yes
			carn_add_dick_big_1_effect = yes
		}
		else_if = {
			limit = { carn_has_dick_big_1_trigger = yes }
			carn_remove_dick_trait_effect = yes
		}
		else = {
			carn_add_dick_small_1_effect = yes
		}
	}
}

carn_increase_tits_size_one_step_effect = {
	if = {
		limit = {
			has_game_rule = carn_dt_enabled
			is_adult = yes
			carn_should_have_tits_trigger = yes
		}
		if = {
			limit = { carn_has_tits_big_2_trigger = yes }
			carn_remove_tits_trait_effect = yes
			carn_add_tits_big_3_effect = yes
		}
		else_if = {
			limit = { carn_has_tits_big_1_trigger = yes }
			carn_remove_tits_trait_effect = yes
			carn_add_tits_big_2_effect = yes
		}
		else_if = {
			limit = { carn_has_tits_small_3_trigger = yes }
			carn_remove_tits_trait_effect = yes
			carn_add_tits_small_2_effect = yes
		}
		else_if = {
			limit = { carn_has_tits_small_2_trigger = yes }
			carn_remove_tits_trait_effect = yes
			carn_add_tits_small_1_effect = yes
		}
		else_if = {
			limit = { carn_has_tits_small_1_trigger = yes }
			carn_remove_tits_trait_effect = yes
		}
		else = {
			carn_add_tits_big_1_effect = yes
		}
	}
}

carn_decrease_tits_size_one_step_effect = {
	if = {
		limit = {
			has_game_rule = carn_dt_enabled
			is_adult = yes
			carn_should_have_tits_trigger = yes
		}
		if = {
			limit = { carn_has_tits_small_2_trigger = yes }
			carn_remove_tits_trait_effect = yes
			carn_add_tits_small_3_effect = yes
		}
		else_if = {
			limit = { carn_has_tits_small_1_trigger = yes }
			carn_remove_tits_trait_effect = yes
			carn_add_tits_small_2_effect = yes
		}
		else_if = {
			limit = { carn_has_tits_big_3_trigger = yes }
			carn_remove_tits_trait_effect = yes
			carn_add_tits_big_2_effect = yes
		}
		else_if = {
			limit = { carn_has_tits_big_2_trigger = yes }
			carn_remove_tits_trait_effect = yes
			carn_add_tits_big_1_effect = yes
		}
		else_if = {
			limit = { carn_has_tits_big_1_trigger = yes }
			carn_remove_tits_trait_effect = yes
		}
		else = {
			carn_add_tits_small_1_effect = yes
		}
	}
}

#
# this series of scripted effects adds the appropriate dick/tit traits depending on active game rules
#

carn_add_dick_small_1_effect = {
	if = {
		limit = { has_game_rule = carn_dt_enabled }
		if = {
			limit = { has_game_rule = carn_dt_dick_small_good }
			add_trait = dick_small_good_1
			if = {
				limit = { is_adult = no }
				make_trait_inactive = dick_small_good_1
			}
		}
		else = {
			add_trait = dick_small_bad_1
			if = {
				limit = { is_adult = no }
				make_trait_inactive = dick_small_bad_1
			}
		}
	}
	add_character_flag = carn_dt_traits_seeded
}

carn_add_dick_small_2_effect = {
	if = {
		limit = { has_game_rule = carn_dt_enabled }
		if = {
			limit = { has_game_rule = carn_dt_dick_small_good }
			add_trait = dick_small_good_2
			if = {
				limit = { is_adult = no }
				make_trait_inactive = dick_small_good_2
			}
		}
		else = {
			add_trait = dick_small_bad_2
			if = {
				limit = { is_adult = no }
				make_trait_inactive = dick_small_bad_2
			}
		}
	}
	add_character_flag = carn_dt_traits_seeded
}

carn_add_dick_small_3_effect = {
	if = {
		limit = { has_game_rule = carn_dt_enabled }
		if = {
			limit = { has_game_rule = carn_dt_dick_small_good }
			add_trait = dick_small_good_3
			if = {
				limit = { is_adult = no }
				make_trait_inactive = dick_small_good_3
			}
		}
		else = {
			add_trait = dick_small_bad_3
			if = {
				limit = { is_adult = no }
				make_trait_inactive = dick_small_bad_3
			}
		}
	}
	add_character_flag = carn_dt_traits_seeded
}

carn_add_dick_big_1_effect = {
	if = {
		limit = { has_game_rule = carn_dt_enabled }
		if = {
			limit = { has_game_rule = carn_dt_dick_big_good }
			add_trait = dick_big_good_1
			if = {
				limit = { is_adult = no }
				make_trait_inactive = dick_big_good_1
			}
		}
		else = {
			add_trait = dick_big_bad_1
			if = {
				limit = { is_adult = no }
				make_trait_inactive = dick_big_bad_1
			}
		}
	}
	add_character_flag = carn_dt_traits_seeded
}

carn_add_dick_big_2_effect = {
	if = {
		limit = { has_game_rule = carn_dt_enabled }
		if = {
			limit = { has_game_rule = carn_dt_dick_big_good }
			add_trait = dick_big_good_2
			if = {
				limit = { is_adult = no }
				make_trait_inactive = dick_big_good_2
			}
		}
		else = {
			add_trait = dick_big_bad_2
			if = {
				limit = { is_adult = no }
				make_trait_inactive = dick_big_bad_2
			}
		}
	}
	add_character_flag = carn_dt_traits_seeded
}

carn_add_dick_big_3_effect = {
	if = {
		limit = { has_game_rule = carn_dt_enabled }
		if = {
			limit = { has_game_rule = carn_dt_dick_big_good }
			add_trait = dick_big_good_3
			if = {
				limit = { is_adult = no }
				make_trait_inactive = dick_big_good_3
			}
		}
		else = {
			add_trait = dick_big_bad_3
			if = {
				limit = { is_adult = no }
				make_trait_inactive = dick_big_bad_3
			}
		}
	}
	add_character_flag = carn_dt_traits_seeded
}

carn_add_tits_small_1_effect = {
	if = {
		limit = { has_game_rule = carn_dt_enabled }
		if = {
			limit = { has_game_rule = carn_dt_tits_small_good }
			add_trait = tits_small_good_1
			if = {
				limit = { is_adult = no }
				make_trait_inactive = tits_small_good_1
			}
		}
		else = {
			add_trait = tits_small_bad_1
			if = {
				limit = { is_adult = no }
				make_trait_inactive = tits_small_bad_1
			}
		}
	}
	add_character_flag = carn_dt_traits_seeded
}

carn_add_tits_small_2_effect = {
	if = {
		limit = { has_game_rule = carn_dt_enabled }
		if = {
			limit = { has_game_rule = carn_dt_tits_small_good }
			add_trait = tits_small_good_2
			if = {
				limit = { is_adult = no }
				make_trait_inactive = tits_small_good_2
			}
		}
		else = {
			add_trait = tits_small_bad_2
			if = {
				limit = { is_adult = no }
				make_trait_inactive = tits_small_bad_2
			}
		}
	}
	add_character_flag = carn_dt_traits_seeded
}

carn_add_tits_small_3_effect = {
	if = {
		limit = { has_game_rule = carn_dt_enabled }
		if = {
			limit = { has_game_rule = carn_dt_tits_small_good }
			add_trait = tits_small_good_3
			if = {
				limit = { is_adult = no }
				make_trait_inactive = tits_small_good_3
			}
		}
		else = {
			add_trait = tits_small_bad_3
			if = {
				limit = { is_adult = no }
				make_trait_inactive = tits_small_bad_3
			}
		}
	}
	add_character_flag = carn_dt_traits_seeded
}

carn_add_tits_big_1_effect = {
	if = {
		limit = { has_game_rule = carn_dt_enabled }
		if = {
			limit = { has_game_rule = carn_dt_tits_big_good }
			add_trait = tits_big_good_1
			if = {
				limit = { is_adult = no }
				make_trait_inactive = tits_big_good_1
			}
		}
		else = {
			add_trait = tits_big_bad_1
			if = {
				limit = { is_adult = no }
				make_trait_inactive = tits_big_bad_1
			}
		}
	}
	add_character_flag = carn_dt_traits_seeded
}

carn_add_tits_big_2_effect = {
	if = {
		limit = { has_game_rule = carn_dt_enabled }
		if = {
			limit = { has_game_rule = carn_dt_tits_big_good }
			add_trait = tits_big_good_2
			if = {
				limit = { is_adult = no }
				make_trait_inactive = tits_big_good_2
			}
		}
		else = {
			add_trait = tits_big_bad_2
			if = {
				limit = { is_adult = no }
				make_trait_inactive = tits_big_bad_2
			}
		}
	}
	add_character_flag = carn_dt_traits_seeded
}

carn_add_tits_big_3_effect = {
	if = {
		limit = { has_game_rule = carn_dt_enabled }
		if = {
			limit = { has_game_rule = carn_dt_tits_big_good }
			add_trait = tits_big_good_3
			if = {
				limit = { is_adult = no }
				make_trait_inactive = tits_big_good_3
			}
		}
		else = {
			add_trait = tits_big_bad_3
			if = {
				limit = { is_adult = no }
				make_trait_inactive = tits_big_bad_3
			}
		}
	}
	add_character_flag = carn_dt_traits_seeded
}

carn_add_inactive_dick_small_1_effect = {
	if = {
		limit = { has_game_rule = carn_dt_dick_small_good }
		add_trait = dick_small_good_1
		make_trait_inactive = dick_small_good_1
	}
	else = {
		add_trait = dick_small_bad_1
		make_trait_inactive = dick_small_bad_1
	}
}

carn_add_inactive_dick_small_2_effect = {
	if = {
		limit = { has_game_rule = carn_dt_dick_small_good }
		add_trait = dick_small_good_2
		make_trait_inactive = dick_small_good_2
	}
	else = {
		add_trait = dick_small_bad_2
		make_trait_inactive = dick_small_bad_2
	}
}

carn_add_inactive_dick_small_3_effect = {
	if = {
		limit = { has_game_rule = carn_dt_dick_small_good }
		add_trait = dick_small_good_3
		make_trait_inactive = dick_small_good_3
	}
	else = {
		add_trait = dick_small_bad_3
		make_trait_inactive = dick_small_bad_3
	}
}

carn_add_inactive_dick_big_1_effect = {
	if = {
		limit = { has_game_rule = carn_dt_dick_big_good }
		add_trait = dick_big_good_1
		make_trait_inactive = dick_big_good_1
	}
	else = {
		add_trait = dick_big_bad_1
		make_trait_inactive = dick_big_bad_1
	}
}

carn_add_inactive_dick_big_2_effect = {
	if = {
		limit = { has_game_rule = carn_dt_dick_big_good }
		add_trait = dick_big_good_2
		make_trait_inactive = dick_big_good_2
	}
	else = {
		add_trait = dick_big_bad_2
		make_trait_inactive = dick_big_bad_2
	}
}

carn_add_inactive_dick_big_3_effect = {
	if = {
		limit = { has_game_rule = carn_dt_dick_big_good }
		add_trait = dick_big_good_3
		make_trait_inactive = dick_big_good_3
	}
	else = {
		add_trait = dick_big_bad_3
		make_trait_inactive = dick_big_bad_3
	}
}

carn_add_inactive_tits_small_1_effect = {
	if = {
		limit = { has_game_rule = carn_dt_tits_small_good }
		add_trait = tits_small_good_1
		make_trait_inactive = tits_small_good_1
	}
	else = {
		add_trait = tits_small_bad_1
		make_trait_inactive = tits_small_bad_1
	}
}

carn_add_inactive_tits_small_2_effect = {
	if = {
		limit = { has_game_rule = carn_dt_tits_small_good }
		add_trait = tits_small_good_2
		make_trait_inactive = tits_small_good_2
	}
	else = {
		add_trait = tits_small_bad_2
		make_trait_inactive = tits_small_bad_2
	}
}

carn_add_inactive_tits_small_3_effect = {
	if = {
		limit = { has_game_rule = carn_dt_tits_small_good }
		add_trait = tits_small_good_3
		make_trait_inactive = tits_small_good_3
	}
	else = {
		add_trait = tits_small_bad_3
		make_trait_inactive = tits_small_bad_3
	}
}

carn_add_inactive_tits_big_1_effect = {
	if = {
		limit = { has_game_rule = carn_dt_tits_big_good }
		add_trait = tits_big_good_1
		make_trait_inactive = tits_big_good_1
	}
	else = {
		add_trait = tits_big_bad_1
		make_trait_inactive = tits_big_bad_1
	}
}

carn_add_inactive_tits_big_2_effect = {
	if = {
		limit = { has_game_rule = carn_dt_tits_big_good }
		add_trait = tits_big_good_2
		make_trait_inactive = tits_big_good_2
	}
	else = {
		add_trait = tits_big_bad_2
		make_trait_inactive = tits_big_bad_2
	}
}

carn_add_inactive_tits_big_3_effect = {
	if = {
		limit = { has_game_rule = carn_dt_tits_big_good }
		add_trait = tits_big_good_3
		make_trait_inactive = tits_big_good_3
	}
	else = {
		add_trait = tits_big_bad_3
		make_trait_inactive = tits_big_bad_3
	}
}


code:
# carn_add_random_fetish_effect
# carn_add_fetish_effect (requires `FETISH`, a fetish flag)
# carn_remove_all_fetishes_effect
# carn_remove_fetish_effect (requires `FETISH`, a fetish flag)
# carn_give_deviant_secret_or_trait_if_has_any_fetish_effect
# carn_remove_deviant_secret_or_trait_if_has_no_fetishes_effect

carn_add_random_fetish_effect = {
	if = {
		limit = { has_game_rule = carn_fetishes_enabled }

		custom_description = {
			text = carn_add_random_fetish_effect
			trigger_event = {
				on_action = carn_on_new_random_fetish
			}
			add_character_flag = carn_fetishes_seeded
		}
	}
}

carn_add_fetish_effect = {
	save_scope_value_as = {
		name = carn_new_fetish
		value = flag:$FETISH$
	}
	if = {
		limit = {
			# fetishes must be enabled in game rules
			has_game_rule = carn_fetishes_enabled
			NOR = {
				# doesn't already have the fetish
				carn_has_fetish_trigger = {
					FETISH = $FETISH$
				}
				# fetish isn't blocked by game rules
				AND = {
					scope:carn_new_fetish = flag:anal
					NOT = { has_game_rule = carn_content_anal_enabled }
				}
				AND = {
					OR = {
						scope:carn_new_fetish = flag:sadism
						scope:carn_new_fetish = flag:masochism
					}
					NOT = { has_game_rule = carn_content_painful_enabled }
				}
				AND = {
					scope:carn_new_fetish = flag:bestiality
					NOT = { has_game_rule = carn_content_bestiality_enabled }
				}
				AND = {
					scope:carn_new_fetish = flag:watersports
					NOT = { has_game_rule = carn_content_watersports_enabled }
				}
				AND = {
					scope:carn_new_fetish = flag:scat
					NOT = { has_game_rule = carn_content_scat_enabled }
				}
				AND = {
					scope:carn_new_fetish = flag:gore
					NOT = { has_game_rule = carn_content_gore_enabled }
				}
				AND = {
					OR = {
						scope:carn_new_fetish = flag:raping
						scope:carn_new_fetish = flag:being_raped
					}
					NOT = { has_game_rule = carn_content_consent_noncon }
				}
			}
		}
		send_interface_message = {
			type = event_generic_neutral
			title = carn_msg_fetish_gained
			right_icon = this
			custom_description = {
				text = carn_add_fetish_$FETISH$_effect
				add_to_variable_list = {
					name = carn_active_fetishes
					target = scope:carn_new_fetish
				}
				trigger_event = {
					on_action = carn_on_gain_fetish
				}
				add_character_flag = carn_fetishes_seeded
			}
		}
	}
}

carn_remove_all_fetishes_effect = {
	custom_description = {
		text = carn_remove_all_fetishes_effect
		clear_variable_list = carn_active_fetishes
		trigger_event = {
			on_action = carn_on_lose_fetish
		}
	}
}

carn_remove_fetish_effect = {
	if = {
		limit = {
			carn_has_fetish_trigger = {
				fetish = $FETISH$
			}
		}
		custom_description = {
			text = carn_remove_fetish_effect
			remove_list_variable = {
				name = carn_active_fetishes
				target = flag:$FETISH$
			}
			trigger_event = {
				on_action = carn_on_lose_fetish
			}
		}
	}
}

carn_give_deviant_secret_or_trait_if_has_any_fetish_effect = {
	if = {
		limit = {
			carn_has_any_fetish_trigger = yes
		}
		carn_give_deviant_secret_or_trait_no_fetish_effect = yes
	}
}

carn_remove_deviant_secret_or_trait_if_has_no_fetishes_effect = {
	if = {
		limit = {
			carn_has_any_fetish_trigger = no
		}
		remove_trait = deviant
		every_secret = {
			limit = {
				secret_type = secret_deviant
			}
			remove_secret = yes
		}
	}
}

carn_fetish_tooltip_effect = {
	switch = {
		trigger = $FETISH$
		flag:anal = {
			custom_tooltip = carn_fetish_gui_anal
		}
		flag:sadism = {
			custom_tooltip = carn_fetish_gui_sadism
		}
		flag:masochism = {
			custom_tooltip = carn_fetish_gui_masochism
		}
		flag:bestiality = {
			custom_tooltip = carn_fetish_gui_bestiality
		}
		flag:watersports = {
			custom_tooltip = carn_fetish_gui_watersports
		}
		flag:scat = {
			custom_tooltip = carn_fetish_gui_scat
		}
		flag:gore = {
			custom_tooltip = carn_fetish_gui_gore
		}
		flag:foot_play = {
			custom_tooltip = carn_fetish_gui_foot_play
		}
		flag:bondage = {
			custom_tooltip = carn_fetish_gui_bondage
		}
		flag:domination = {
			custom_tooltip = carn_fetish_gui_domination
		}
		flag:submission = {
			custom_tooltip = carn_fetish_gui_submission
		}
		flag:raping = {
			custom_tooltip = carn_fetish_gui_raping
		}
		flag:being_raped = {
			custom_tooltip = carn_fetish_gui_being_raped
		}
		flag:lactation = {
			custom_tooltip = carn_fetish_gui_lactation
		}
		fallback = {
			custom_tooltip = carn_fetish_gui_unknown
		}
	}
}


code:
# carn_seed_futa_trait_effect
# carn_flip_ruler_designed_futa_trait_to_game_rule_effect
# carn_add_futa_effect
# carn_remove_futa_effect
# carn_add_futa_transformation_effect
# carn_remove_futa_transformation_effect

# seed futa trait based on selected game rules
carn_seed_futa_trait_effect = {
	add_character_flag = carn_futa_trait_seeded
	if = {
		limit = { has_character_flag = carn_seed_futa }
		carn_add_futa_effect = yes
	}
	else = {
		if = {
			limit = {
				has_trait = futa_genetic
				is_male = yes
			}
			make_trait_inactive = futa_genetic
		}
		else_if = {
			limit = {
				carn_is_futa_trigger = no
				NOT = { has_inactive_trait = futa_genetic }
			}
			random = {
				chance = 0
				modifier = {
					add = carn_futa_very_rare_chance
					has_game_rule = carn_futa_content_very_rare
				}
				modifier = {
					add = carn_futa_rare_chance
					has_game_rule = carn_futa_content_rare
				}
				modifier = {
					add = carn_futa_uncommon_chance
					has_game_rule = carn_futa_content_uncommon
				}
				modifier = {
					add = carn_futa_common_chance
					has_game_rule = carn_futa_content_common
				}
				modifier = {
					add = carn_futa_very_common_chance
					has_game_rule = carn_futa_content_very_common
				}
				modifier = {
					add = 100
					has_game_rule = carn_futa_content_always
				}
				if = {
					limit = {
						has_game_rule = carn_futa_trait_inheritance_disabled
					}
					if = {
						limit = { is_female = yes }
						add_trait = futa
					}
				}
				else = {
					add_trait = futa_genetic
					if = {
						limit = { is_male = yes }
						make_trait_inactive = futa_genetic
					}
				}
			}
		}
	}
}

carn_flip_ruler_designed_futa_trait_to_game_rule_effect = {
	if = {
		limit = {
			has_game_rule = carn_futa_trait_inheritance_enabled
			has_trait = futa
		}
		remove_trait = futa
		add_trait = futa_genetic
	}
}

# adds either futa or futa_genetic depending on game rule
carn_add_futa_effect = {
	if = {
		limit = {
			NOT = { has_game_rule = carn_futa_content_disabled }
			is_female = yes
			carn_is_futa_trigger = no
		}
		if = {
			limit = { has_game_rule = carn_futa_trait_inheritance_enabled }
			add_trait = futa_genetic
		}
		else = {
			add_trait = futa
		}
		carn_activate_gender_specific_dt_traits_effect = yes
	}
}

# removes all futa traits
carn_remove_futa_effect = {
	remove_trait = futa_genetic
	remove_trait = futa
	hidden_effect = {
		carn_make_all_dt_traits_inactive_effect = yes
		carn_activate_gender_specific_dt_traits_effect = yes
	}
}

# adds non-inheritable futa trait if the character doesn't have futa gene, or activates inactive futa_genetic trait if the character has it
carn_add_futa_transformation_effect = {
	if = {
		limit = {
			NOT = { has_game_rule = carn_futa_content_disabled }
			is_female = yes
			carn_is_futa_trigger = no
		}
		if = {
			limit = { has_inactive_trait = futa_genetic }
			make_trait_active = futa_genetic
		}
		else = {
			add_trait = futa
		}
		carn_activate_gender_specific_dt_traits_effect = yes
	}
}

# removes non-inheritable futa trait, or deactivates futa_genetic trait if the character has it
carn_remove_futa_transformation_effect = {
	if = {
		limit = {
			NOT = { has_game_rule = carn_futa_content_disabled }
			carn_is_futa_trigger = yes
		}
		if = {
			limit = { has_trait = futa_genetic }
			make_trait_inactive = futa_genetic
		}
		else = {
			remove_trait = futa
		}
		hidden_effect = {
			carn_make_all_dt_traits_inactive_effect = yes
			carn_activate_gender_specific_dt_traits_effect = yes
		}
	}
}


code:
#not using nested loop as even one new fetish gives rise to too many combination and not half of them will ever be used
#you can see the pattern in which this is written.
#order of the fetishs is the way the appear in effect and trigger list, first comes first.
#please follow the same parttern, it will be easier for other to follow
carn_had_sex_memory_effect = {
	#giving_player vaginal cum_inside consensual
	if = {
		limit = {
			carn_sex_scene_character_is_giving_player_trigger = yes
			carn_sex_scene_is_vaginal_trigger = yes
			carn_sex_scene_is_cum_inside_trigger = yes
			carn_sex_scene_is_consensual_trigger = yes
		}
		create_character_memory = {
			type = had_sex_giving_player_vaginal_cum_inside_consensual
			participants = {
				sex_partner = scope:carn_sex_partner
			}
		}
		scope:carn_sex_partner = {
			create_character_memory = {
				type = had_sex_receiving_player_vaginal_cum_inside_consensual
				participants = {
					sex_partner = scope:carn_sex_player
				}
			}
		}
	}
	#giving_player vaginal cum_outside consensual
	else_if = {
		limit = {
			carn_sex_scene_character_is_giving_player_trigger = yes
			carn_sex_scene_is_vaginal_trigger = yes
			carn_sex_scene_is_cum_outside_trigger = yes
			carn_sex_scene_is_consensual_trigger = yes
		}
		create_character_memory = {
			type = had_sex_giving_player_vaginal_cum_outside_consensual
			participants = {
				sex_partner = scope:carn_sex_partner
			}
		}
		scope:carn_sex_partner = {
			create_character_memory = {
				type = had_sex_receiving_player_vaginal_cum_outside_consensual
				participants = {
					sex_partner = scope:carn_sex_player
				}
			}
		}
	}
	#giving_player anal consensual
	else_if = {
		limit = {
			carn_sex_scene_character_is_giving_player_trigger = yes
			carn_sex_scene_is_anal_trigger = yes
			carn_sex_scene_is_consensual_trigger = yes
		}
		create_character_memory = {
			type = had_sex_giving_player_anal_consensual
			participants = {
				sex_partner = scope:carn_sex_partner
			}
		}
		scope:carn_sex_partner = {
			create_character_memory = {
				type = had_sex_receiving_player_anal_consensual
				participants = {
					sex_partner = scope:carn_sex_player
				}
			}
		}
	}
	#giving_player oral consensual
	else_if = {
		limit = {
			carn_sex_scene_character_is_giving_player_trigger = yes
			carn_sex_scene_is_oral_trigger = yes
			carn_sex_scene_is_consensual_trigger = yes
		}
		create_character_memory = {
			type = had_sex_giving_player_oral_consensual
			participants = {
				sex_partner = scope:carn_sex_partner
			}
		}
		scope:carn_sex_partner = {
			create_character_memory = {
				type = had_sex_receiving_player_oral_consensual
				participants = {
					sex_partner = scope:carn_sex_player
				}
			}
		}
	}
	#giving_player dom vaginal cum_inside noncon
	else_if = {
		limit = {
			#dom player is always in charge so no need to check 1st trigger , writting is just for the sake of pattern
			#carn_sex_scene_character_is_giving_player_trigger = yes
			carn_sex_scene_character_is_dom_player_trigger = yes
			carn_sex_scene_is_vaginal_trigger = yes
			carn_sex_scene_is_cum_inside_trigger = yes
			carn_sex_scene_is_noncon_trigger = yes
		}
		create_character_memory = {
			type = had_sex_giving_player_dom_vaginal_cum_inside_noncon
			participants = {
				sex_partner = scope:carn_sex_partner
			}
		}
		scope:carn_sex_partner = {
			create_character_memory = {
				type = had_sex_receiving_player_sub_vaginal_cum_inside_noncon
				participants = {
					sex_partner = scope:carn_sex_player
				}
			}
		}
	}
	#giving_player dom vaginal cum_outside noncon
	else_if = {
		limit = {
			#carn_sex_scene_character_is_giving_player_trigger = yes
			carn_sex_scene_character_is_dom_player_trigger = yes
			carn_sex_scene_is_vaginal_trigger = yes
			carn_sex_scene_is_cum_outside_trigger = yes
			carn_sex_scene_is_noncon_trigger = yes
		}
		create_character_memory = {
			type = had_sex_giving_player_dom_vaginal_cum_outside_noncon
			participants = {
				sex_partner = scope:carn_sex_partner
			}
		}
		scope:carn_sex_partner = {
			create_character_memory = {
				type = had_sex_receiving_player_sub_vaginal_cum_outside_noncon
				participants = {
					sex_partner = scope:carn_sex_player
				}
			}
		}
	}
	#giving_player dom anal noncon
	else_if = {
		limit = {
			#carn_sex_scene_character_is_giving_player_trigger = yes
			carn_sex_scene_character_is_dom_player_trigger = yes
			carn_sex_scene_is_anal_trigger = yes
			carn_sex_scene_is_noncon_trigger = yes
		}
		create_character_memory = {
			type = had_sex_giving_player_dom_anal_noncon
			participants = {
				sex_partner = scope:carn_sex_partner
			}
		}
		scope:carn_sex_partner = {
			create_character_memory = {
				type = had_sex_receiving_player_sub_anal_noncon
				participants = {
					sex_partner = scope:carn_sex_player
				}
			}
		}
	}
	#giving_player dom oral noncon
	else_if = {
		limit = {
			#carn_sex_scene_character_is_giving_player_trigger = yes
			carn_sex_scene_character_is_dom_player_trigger = yes
			carn_sex_scene_is_oral_trigger = yes
			carn_sex_scene_is_noncon_trigger = yes
		}
		create_character_memory = {
			type = had_sex_giving_player_dom_oral_noncon
			participants = {
				sex_partner = scope:carn_sex_partner
			}
		}
		scope:carn_sex_partner = {
			create_character_memory = {
				type = had_sex_receiving_player_sub_oral_noncon
				participants = {
					sex_partner = scope:carn_sex_player
				}
			}
		}
	}
	#giving_player dom vaginal cum_inside dubcon
	else_if = {
		limit = {
			#carn_sex_scene_character_is_giving_player_trigger = yes
			carn_sex_scene_character_is_dom_player_trigger = yes
			carn_sex_scene_is_vaginal_trigger = yes
			carn_sex_scene_is_cum_inside_trigger = yes
			carn_sex_scene_is_dubcon_trigger = yes
		}
		create_character_memory = {
			type = had_sex_giving_player_dom_vaginal_cum_inside_dubcon
			participants = {
				sex_partner = scope:carn_sex_partner
			}
		}
		scope:carn_sex_partner = {
			create_character_memory = {
				type = had_sex_receiving_player_sub_vaginal_cum_inside_dubcon
				participants = {
					sex_partner = scope:carn_sex_player
				}
			}
		}
	}
	#giving_player dom vaginal cum_outside dubcon
	else_if = {
		limit = {
			#carn_sex_scene_character_is_giving_player_trigger = yes
			carn_sex_scene_character_is_dom_player_trigger = yes
			carn_sex_scene_is_vaginal_trigger = yes
			carn_sex_scene_is_cum_outside_trigger = yes
			carn_sex_scene_is_dubcon_trigger = yes
		}
		create_character_memory = {
			type = had_sex_giving_player_dom_vaginal_cum_outside_dubcon
			participants = {
				sex_partner = scope:carn_sex_partner
			}
		}
		scope:carn_sex_partner = {
			create_character_memory = {
				type = had_sex_receiving_player_sub_vaginal_cum_outside_dubcon
				participants = {
					sex_partner = scope:carn_sex_player
				}
			}
		}
	}
	#giving_player dom anal dubcon
	else_if = {
		limit = {
			#carn_sex_scene_character_is_giving_player_trigger = yes
			carn_sex_scene_character_is_dom_player_trigger = yes
			carn_sex_scene_is_anal_trigger = yes
			carn_sex_scene_is_dubcon_trigger = yes
		}
		create_character_memory = {
			type = had_sex_giving_player_dom_anal_dubcon
			participants = {
				sex_partner = scope:carn_sex_partner
			}
		}
		scope:carn_sex_partner = {
			create_character_memory = {
				type = had_sex_receiving_player_sub_anal_dubcon
				participants = {
					sex_partner = scope:carn_sex_player
				}
			}
		}
	}
	#giving_player dom oral dubcon
	else_if = {
		limit = {
			#carn_sex_scene_character_is_giving_player_trigger = yes
			carn_sex_scene_character_is_dom_player_trigger = yes
			carn_sex_scene_is_oral_trigger = yes
			carn_sex_scene_is_dubcon_trigger = yes
		}
		create_character_memory = {
			type = had_sex_giving_player_dom_oral_dubcon
			participants = {
				sex_partner = scope:carn_sex_partner
			}
		}
		scope:carn_sex_partner = {
			create_character_memory = {
				type = had_sex_receiving_player_sub_oral_dubcon
				participants = {
					sex_partner = scope:carn_sex_player
				}
			}
		}
	}
	#receiving_player sub vaginal cum_inside noncon
	else_if = {
		limit = {
			#carn_sex_scene_character_is_receiving_player_trigger = yes
			carn_sex_scene_character_is_sub_player_trigger = yes
			carn_sex_scene_is_vaginal_trigger = yes
			carn_sex_scene_is_cum_inside_trigger = yes
			carn_sex_scene_is_noncon_trigger = yes
		}
		create_character_memory = {
			type = had_sex_receiving_player_sub_vaginal_cum_inside_noncon
			participants = {
				sex_partner = scope:carn_sex_partner
			}
		}
		scope:carn_sex_partner = {
			create_character_memory = {
				type = had_sex_giving_player_dom_vaginal_cum_inside_noncon
				participants = {
					sex_partner = scope:carn_sex_player
				}
			}
		}
	}
	#receiving_player sub vaginal cum_outside noncon
	else_if = {
		limit = {
			#carn_sex_scene_character_is_receiving_player_trigger = yes
			carn_sex_scene_character_is_sub_player_trigger = yes
			carn_sex_scene_is_vaginal_trigger = yes
			carn_sex_scene_is_cum_outside_trigger = yes
			carn_sex_scene_is_noncon_trigger = yes
		}
		create_character_memory = {
			type = had_sex_receiving_player_sub_vaginal_cum_outside_noncon
			participants = {
				sex_partner = scope:carn_sex_partner
			}
		}
		scope:carn_sex_partner = {
			create_character_memory = {
				type = had_sex_giving_player_dom_vaginal_cum_outside_noncon
				participants = {
					sex_partner = scope:carn_sex_player
				}
			}
		}
	}
	#receiving_player sub anal noncon
	else_if = {
		limit = {
			#carn_sex_scene_character_is_receiving_player_trigger = yes
			carn_sex_scene_character_is_sub_player_trigger = yes
			carn_sex_scene_is_anal_trigger = yes
			carn_sex_scene_is_noncon_trigger = yes
		}
		create_character_memory = {
			type = had_sex_receiving_player_sub_anal_noncon
			participants = {
				sex_partner = scope:carn_sex_partner
			}
		}
		scope:carn_sex_partner = {
			create_character_memory = {
				type = had_sex_giving_player_dom_anal_noncon
				participants = {
					sex_partner = scope:carn_sex_player
				}
			}
		}
	}
	#receiving_player sub oral noncon
	else_if = {
		limit = {
			#carn_sex_scene_character_is_receiving_player_trigger = yes
			carn_sex_scene_character_is_sub_player_trigger = yes
			carn_sex_scene_is_oral_trigger = yes
			carn_sex_scene_is_noncon_trigger = yes
		}
		create_character_memory = {
			type = had_sex_receiving_player_sub_oral_noncon
			participants = {
				sex_partner = scope:carn_sex_partner
			}
		}
		scope:carn_sex_partner = {
			create_character_memory = {
				type = had_sex_giving_player_dom_oral_noncon
				participants = {
					sex_partner = scope:carn_sex_player
				}
			}
		}
	}
	#Fallback
	else = {
		create_character_memory = {
			type = had_sex
			participants = {
				sex_partner = scope:carn_sex_partner
			}
		}
		scope:carn_sex_partner = {
			create_character_memory = {
				type = had_sex
				participants = {
					sex_partner = scope:carn_sex_player
				}
			}
		}
	}
}


code:
# better version of had_sex_with_effect
#
# scope:carn_sex_player: the character doing the laying with.
# scope:carn_sex_partner: the character getting laid.
# set the following effect on scope, effect is being called on for following
# carn_sex_scene_no_pregnancy_effect = yes for no prenancy check, default is to check
# carn_sex_scene_no_stress_effect = yes for no stress check, default is to check
# carn_sex_scene_no_drama_effect = yes for no drama check, default is to check
# carn_sex_scene_no_memory_effect = yes for no memory check, default is to check
# carn_sex_scene_no_std_effect = yes for no std check, default is to check
#
# sends scope:carn_sex_player and scope:carn_sex_partner to carn_on_sex on action event triggered by scope:carn_sex_player
#
# sends scope:father and scope:mother to carn_on_pregnancy on action event triggered by scope:mother
#

carn_had_sex_with_effect_v2 = {
	save_scope_as = carn_sex_player
	$PARTNER$ = {save_scope_as = carn_sex_partner}

	# Save additional scopes for backward compatibility
	save_scope_as = carn_sex_char_1
	save_scope_as = had_sex_root_character
	$PARTNER$ = {
		save_scope_as = carn_sex_char_2
		save_scope_as = had_sex_with_effect_partner
	}

	if = {
		limit = { this = scope:carn_sex_player }
		custom_tooltip = carn_had_sex_with_effect.first_person.tt
	}
	else_if = {
		limit = { this = scope:carn_sex_partner }
		custom_tooltip = carn_had_sex_with_effect.second_person.tt
	}
	else = {
		custom_tooltip = carn_had_sex_with_effect.third_person.tt
	}

	#Pregnancy
	if = {
		limit = {
			NOT = {carn_sex_scene_no_pregnancy_trigger = yes}
		}
		if = {
			limit = {
				scope:carn_sex_player = {carn_gender_can_impregnate_trigger = yes}
				scope:carn_sex_partner = {is_female = yes}
			}
			carn_check_pregnancy_effect = {
				FATHER = scope:carn_sex_player
				MOTHER = scope:carn_sex_partner
			}
		}
		if = {
			limit = {
				scope:carn_sex_player = {is_female = yes}
				scope:carn_sex_partner = {carn_gender_can_impregnate_trigger = yes}
			}
			carn_check_pregnancy_effect = {
				FATHER = scope:carn_sex_partner
				MOTHER = scope:carn_sex_player
			}
		}
	}

	#Stress
	if = {
		limit = {
			NOT = {carn_sex_scene_no_stress_trigger = yes}
		}
		if = {
			limit = { NOT = { has_character_flag = no_sex_stress_loss}}
			stress_impact = {
				lustful = minor_stress_impact_loss
				rakish = minor_stress_impact_loss
			}
			scope:carn_sex_partner = {
				hidden_effect = {
					stress_impact = {
						lustful = minor_stress_impact_loss
						rakish = minor_stress_impact_loss
					}
				}
			}
		}
	}

	#Drama
	hidden_effect = {
		if = {
			limit = {
				NOT = {carn_sex_scene_no_drama_trigger = yes}
			}
			if = {
				limit = {
					carn_gender_can_impregnate_trigger = yes
					NOT = { has_character_flag = had_story_cycle_peasant_affair }
					is_ruler = yes
					scope:carn_sex_partner = {
						is_lowborn = yes
						is_playable_character = no
						is_courtier = no
					}
					NOT = {
						any_scheme = {
							scheme_target_character = scope:carn_sex_partner
						}
					}
				}
				set_variable = {
					name = story_peasant_affair_target
					value = scope:carn_sex_partner
				}
				scope:carn_sex_partner = {
					if = {
						limit = {
							is_female = yes
							is_pregnant = no
							fertility >= 0.1
							is_visibly_fertile = yes
						}
						random = {
							#setting it to default game setting of 30
							chance = pregnancy_chance
							add_character_flag = {
								flag = peasant_is_pregnant
								days = 560
							}
						}
					}
				}
				create_story = story_peasant_affair
			}
			if = {
				limit = {
					is_female = yes
					NOT = { has_character_flag = had_story_cycle_peasant_affair }
					is_ruler = yes
					scope:carn_sex_partner = {
						is_lowborn = yes
						is_playable_character = no
						is_courtier = no
					}
					NOT = {
						any_scheme = {
							scheme_target_character = scope:carn_sex_partner
						}
					}
				}
				set_variable = {
					name = story_peasant_affair_target
					value = scope:carn_sex_partner
				}
				create_story = story_peasant_affair
			}

			#Adultery suspicion
			if = {
				limit = {
					OR = {
						is_married = yes
						is_concubine = yes
					}
					NOT = { any_consort = { this = scope:carn_sex_partner } }
				}
				set_variable = {
					name = had_recent_sex_with
					value = scope:carn_sex_partner
					days = 1000
				}
				random = {
					chance = 50 #This should be quite high as there is a chance that adultery.0001 "fails" i.e. spouse doesn't realize
					every_relation = {
						type = soulmate
						limit = {
							NOT = { this = scope:carn_sex_partner } #Soulmates should not grow suspicous of adulterous affairs after sleeping with their lover
						}
						add_to_temporary_list = partners_1
					}
					every_consort = {
						add_to_temporary_list = partners_1
					}
					random_in_list = {
						list = partners_1
						limit = { is_ai = no }
						alternative_limit = { always = yes }
						trigger_event = {
							id = adultery.0001
							days = { 14 365 }
						}
					}
				}
			}
			scope:carn_sex_partner = {
				if = {
					limit = {
						OR = {
							is_married = yes
							is_concubine = yes
						}
						NOT = { any_consort = { this = scope:carn_sex_player }}
					}
					set_variable = {
						name = had_recent_sex_with
						value = scope:carn_sex_player
						days = 1000
					}
					random = {
						chance = 50 #This should be quite high as there is a chance that adultery.0001 "fails" i.e. spouse doesn't realize
						every_relation = {
							type = soulmate
							limit = {
								NOT = { this = scope:carn_sex_player } #Soulmates should not grow suspicous of adulterous affairs after sleeping with their lover
							}
							add_to_temporary_list = partners_2
						}
						every_consort = {
							add_to_temporary_list = partners_2
						}
						random_in_list = {
							list = partners_2
							limit = { is_ai = no }
							alternative_limit = { always = yes }
							trigger_event = {
								id = adultery.0001
								days = { 14 365 }
							}
						}
					}
				}
			}
		}
	}

	hidden_effect = {
		#Memory
		if = {
			limit = {
				NOT = {carn_sex_scene_no_memory_trigger = yes}
			}
			#Created a seprate file as it is too big
			carn_had_sex_memory_effect = yes
		}

		#Incestuous Relations
		give_incest_secret_or_nothing_with_target_effect = { CHARACTER = scope:carn_sex_partner }
		scope:carn_sex_partner = { give_incest_secret_or_nothing_with_target_effect = { CHARACTER = scope:carn_sex_player } }

		#Homosexuality
		give_homosexual_secret_or_nothing_with_target_effect = { CHARACTER = scope:carn_sex_partner }
		scope:carn_sex_partner = { give_homosexual_secret_or_nothing_with_target_effect = { CHARACTER = scope:carn_sex_player } }

		# hook into new on_action
		trigger_event = {
			on_action = carn_on_sex_v2
		}

		# Trigger carn_on_sex for both partners for backward compatibility
		trigger_event = {
			on_action = carn_on_sex
		}
		scope:carn_sex_partner = {
			# Change carn_sex_partner to be carn_sex_player for backward compatibility
			scope:carn_sex_player = { save_scope_as = carn_sex_partner }
			trigger_event = {
				on_action = carn_on_sex
			}
			# Restore carn_sex_partner
			save_scope_as = carn_sex_partner
		}

		#STD transmission
		if = {
			limit = { carn_sex_scene_no_std_trigger = no }
			risk_of_std_from_effect = { PARTNER = scope:carn_sex_partner }
			scope:carn_sex_partner = { risk_of_std_from_effect = { PARTNER = scope:carn_sex_player }}
		}

	}

	#Violet Poet trait
	if = {
		limit = {
			scope:had_sex_root_character = {
				has_trait = violet_poet
			}
		}
		scope:had_sex_root_character = {
			add_trait_xp = {
				trait = violet_poet
				value = {
					integer_range = {
						min = 5
						max = 10
					}
				}
			}
		}
	}
	if = {
		limit = {
			scope:had_sex_with_effect_partner = {
				has_trait = violet_poet
			}
		}
		scope:had_sex_with_effect_partner = {
			add_trait_xp = {
				trait = violet_poet
				value = {
					integer_range = {
						min = 5
						max = 10
					}
				}
			}
		}
	}
}

carn_check_pregnancy_effect = {
	$FATHER$ = {save_scope_as = father}
	$MOTHER$ = {save_scope_as = mother}

	hidden_effect = {
		# Save additional scope values for backward compatibility
		save_scope_value_as = { name = carn_sex_char_1_could_be_impregnated value = no }
		save_scope_value_as = { name = carn_sex_char_2_could_be_impregnated value = no }
		save_scope_value_as = { name = carn_sex_char_1_impregnated value = no }
		save_scope_value_as = { name = carn_sex_char_2_impregnated value = no }

		scope:mother = {
			add_to_variable_list = {
				name = potential_father_variable_list
				target = scope:father
			}
			if = {
				limit = {
					age >= define:NChildbirth|MIN_FEMALE_REPRODUCTION_AGE
					age <= define:NChildbirth|MAX_FEMALE_REPRODUCTION_AGE
					is_pregnant = no
				}

				# Save additional scope values for backward compatibility
				if = {
					limit = {
						carn_sex_pregnancy_chance > 0
						OR = {
							carn_sex_scene_is_vaginal_trigger = yes
							scope:father = { carn_sex_scene_is_vaginal_trigger = yes}
						}
						NOT = { scope:father = {is_eunuch_trigger = yes } }
					}
					if = {
						limit = { this = scope:carn_sex_player }
						save_scope_value_as = { name = carn_sex_char_1_could_be_impregnated value = yes }
					}
					else = {
						save_scope_value_as = { name = carn_sex_char_2_could_be_impregnated value = yes }
					}
				}

				random = {
					chance = 0
					modifier = { add = carn_sex_pregnancy_chance }
					modifier = {
						factor = 0.2
						OR = {
							carn_sex_scene_is_vaginal_trigger = yes
							scope:father = {carn_sex_scene_is_vaginal_trigger = yes}
						}
						NOT = { carn_sex_scene_is_cum_inside_trigger = yes }
						scope:father = {NOT = { carn_sex_scene_is_cum_inside_trigger = yes }}
					}
					modifier = {
						factor = 0
						NOT = {carn_sex_scene_is_vaginal_trigger = yes}
						scope:father = {NOT = {carn_sex_scene_is_vaginal_trigger = yes}}
					}
					modifier = {
						factor = 0
						scope:father = {is_eunuch_trigger = yes}
					}
					modifier = {
						factor = carn_birth_control_pregnancy_chance_multiplier
						OR = {
							scope:father = { has_character_modifier = carn_using_birth_control_modifier }
							has_character_modifier = carn_using_birth_control_modifier
						}
					}

					# Save additional scope values for backward compatibility
					if = {
						limit = { this = scope:carn_sex_player }
						save_scope_value_as = { name = carn_sex_char_1_impregnated value = yes }
					}
					else = {
						save_scope_value_as = { name = carn_sex_char_2_impregnated value = yes }
					}

					make_pregnant = {
						father = scope:father
					}
					# hook into new on_action
					trigger_event = {
						on_action = carn_on_pregnancy
					}
				}
			}
		}
	}
}