carn_sex_interaction = {
    category = interaction_category_friendly
    
    desc = carn_sex_interaction_desc
    interface_priority = 40
    use_diplomatic_range = no

    is_shown = {
        NOR = {
            has_game_rule = carn_sex_interaction_disabled
            scope:actor = scope:recipient
        }
        scope:actor = {
            is_adult = yes
            NOR = {
                has_trait_with_flag = carn_block_send_sex_interaction
                has_character_flag = carn_block_send_sex_interaction
                has_opinion_modifier = {
                    target = scope:recipient
                    modifier = carn_block_sex_interaction_to_opinion
                }
            }
        }
        scope:recipient = {
            is_adult = yes
            NOR = {
                has_trait_with_flag = carn_block_receive_sex_interaction
                has_character_flag = carn_block_receive_sex_interaction
                has_opinion_modifier = {
                    target = scope:actor
                    modifier = carn_block_sex_interaction_from_opinion
                }
            }
        }
        OR = {
            scope:actor = {
                carn_relationship_allows_free_sex_trigger = {
                    PARTNER = scope:recipient
                }
            }
            scope:recipient = {
                carn_is_working_as_prostitute_trigger = yes
            }
        }
    }

	cooldown = { months = carn_sex_interaction_cooldown }

    is_valid_showing_failures_only = {
        scope:actor = {
            carn_can_have_sex_trigger = yes
        }
        scope:recipient = {
            carn_can_have_sex_trigger = yes
        }
            
        # if this is a paid transaction, actor needs the gold
        trigger_if = {
            limit = {
                scope:recipient = {
                    carn_is_working_as_prostitute_trigger = yes
                }
                NOT = {
                    scope:actor = {
                        carn_relationship_allows_free_sex_trigger = {
                            PARTNER = scope:recipient
                        }
                    }
                }
            }
            scope:actor.gold >= scope:recipient.carn_prostitute_sex_interaction_price_value
        }
    }

	on_accept = {
		scope:actor = {

			if = {
				limit = {
					NOT = { has_character_flag = carn_sex_interaction_effect_cd }
				}

				show_as_tooltip = {
					carn_had_sex_with_effect_v2 = {
						PARTNER = scope:recipient
					}

					if = {
						limit = {
							dynasty = { has_dynasty_perk = martial_arts_legacy_3 }
						}

						scope:recipient = {
							save_scope_as = carn_sex_partner_scope
						}

						dual_cultivation_effect = yes
					}
				}

				### STRESS ###
				if = {
					limit = {
						is_attracted_to_gender_of = scope:recipient
					}
					stress_impact = {
						base = minor_stress_impact_loss
						chaste = activity_stress_gain_impact
					}
				}
				else = {
					custom_tooltip = carn_sex_interaction_not_attracted_to_warning_tt
					stress_impact = {
						base = major_stress_impact_gain
					}
				}

				add_character_flag = {
					flag = carn_sex_interaction_effect_cd
					months = carn_sex_interaction_cooldown_base
				}
			}
			else = {
				custom_tooltip = carn_sex_interaction_effect_cd_tt
			}

			hidden_effect = {

				carn_sex_scene_effect_v2 = {
					PARTNER = scope:recipient
				}

				if = {
					limit = {
						dynasty = { has_dynasty_perk = martial_arts_legacy_3 }
					}

					scope:recipient = {
						save_scope_as = carn_sex_partner_scope
					}

					dual_cultivation_effect = yes
				}
			}
		}
	}

    auto_accept = yes
}