﻿domcom_cuck_evidence_trigger = {
    # Run from the prospective cuck. Requires scope:actor.
    # v2.5.1: attraction or a Lover/Soulmate relation alone is no longer enough for the public Cucked
    # state. There must be recorded sex evidence or parentage proving the relationship was consummated.
    is_alive = yes
    age >= 18
    NOT = { is_consort_of = scope:actor }
    OR = {
        NOT = { has_variable = domcom_cuck_patron }
        var:domcom_cuck_patron = scope:actor
    }
    OR = {
        # Dominion/Carnalitas direct-sex bridges record this immediately after actual intimacy.
        domcom_has_full_sex_evidence_from_actor_trigger = yes

        # A child by the prospective Patron is independently conclusive evidence even if an older save
        # predates the sex-evidence registry.
        any_consort = {
            is_alive = yes
            age >= 18
            NOT = { is_consort_of = scope:actor }
            any_child = {
                OR = {
                    father ?= scope:actor
                    mother ?= scope:actor
                    real_father ?= scope:actor
                }
            }
        }
        any_relation = {
            type = soulmate
            is_alive = yes
            age >= 18
            NOT = { is_consort_of = scope:actor }
            any_child = {
                OR = {
                    father ?= scope:actor
                    mother ?= scope:actor
                    real_father ?= scope:actor
                }
            }
        }
    }
}

# Parameterized version used by autonomous AI code where the challenger is a saved scope rather than the
# interaction's built-in scope:actor. Run from the prospective cuck.
domcom_has_qualifying_cuck_evidence_from_patron_trigger = {
    is_alive = yes
    age >= 18
    NOT = { is_consort_of = $PATRON$ }
    OR = {
        any_in_list = {
            variable = domcom_sex_evidence_patrons
            this = $PATRON$
        }
        any_consort = {
            is_alive = yes
            age >= 18
            NOT = { is_consort_of = $PATRON$ }
            any_child = {
                OR = {
                    father ?= $PATRON$
                    mother ?= $PATRON$
                    real_father ?= $PATRON$
                }
            }
        }
        any_relation = {
            type = soulmate
            is_alive = yes
            age >= 18
            NOT = { is_consort_of = $PATRON$ }
            any_child = {
                OR = {
                    father ?= $PATRON$
                    mother ?= $PATRON$
                    real_father ?= $PATRON$
                }
            }
        }
    }
}

domcom_is_owned_by_actor_trigger = {
    has_character_flag = domcom_owned_cuck
    has_variable = domcom_patron
    var:domcom_patron = scope:actor
}


# 1.4 compatibility: Final Collapse must distinguish ordinary secular holdings from
# special identity/institutional titles introduced by later CK3 systems. Run from a title.
domcom_collapse_transferable_title_trigger = {
    NOT = { tier = tier_barony }
    is_landless_type_title = no
    is_noble_family_title = no
    is_nomad_title = no
    is_head_of_faith = no
    NOT = { exists = var:ceremonial_title }
}

# Run from a character. These are personal ruler/domicile identities that Take Everything may
# extinguish, rather than illegally granting them to an unrelated Patron.
domcom_has_collapsible_special_title_trigger = {
    OR = {
        is_landless_adventurer = yes
        any_held_title = { is_noble_family_title = yes }
        any_held_title = { is_nomad_title = yes }
    }
}

# Rulers whose political existence is represented by a domicile/family title can be CK3 vassals while
# is_landed = no. Use this where Dominion means "political vassal", not literally a landed holder.
domcom_is_political_vassal_ruler_trigger = {
    OR = {
        is_landed = yes
        any_held_title = { is_noble_family_title = yes }
        any_held_title = { is_nomad_title = yes }
    }
}

# Run from a character after seizure. Protected religious/ceremonial offices intentionally do not
# count as a failed confiscation; CK3 itself treats those as institutional rather than ordinary property.
domcom_has_unresolved_collapse_property_trigger = {
    OR = {
        domcom_has_collapsible_special_title_trigger = yes
        any_held_title = { domcom_collapse_transferable_title_trigger = yes }
    }
}

domcom_is_eligible_communion_admirer_trigger = {
    # Run from the candidate with scope:actor = patron.
    is_alive = yes
    age >= 18
    NOT = { this = scope:actor }
    NOT = { is_close_or_extended_family_of = scope:actor }
    NOT = { has_character_flag = domcom_communion_admirer_registered }
    scope:actor = { is_attracted_to_gender_of = prev }
    is_attracted_to_gender_of = scope:actor
}

# Strategic Prospect filter. The player asked to be interrupted only for people who matter to a
# dynastic/map-painting campaign: strong congenital stock or a meaningful landed succession route.
# Two separate positive congenital lines at any tier qualify (Quick + Hale, for example); a single
# tier-II/III line or Pure-Blooded is valuable enough to qualify by itself.
domcom_has_strategic_genetics_trigger = {
    OR = {
        has_trait = intellect_good_2
        has_trait = intellect_good_3
        has_trait = beauty_good_2
        has_trait = beauty_good_3
        has_trait = physique_good_2
        has_trait = physique_good_3
        has_trait = pure_blooded

        AND = {
            OR = { has_trait = intellect_good_1 has_trait = intellect_good_2 has_trait = intellect_good_3 }
            OR = { has_trait = beauty_good_1 has_trait = beauty_good_2 has_trait = beauty_good_3 }
        }
        AND = {
            OR = { has_trait = intellect_good_1 has_trait = intellect_good_2 has_trait = intellect_good_3 }
            OR = { has_trait = physique_good_1 has_trait = physique_good_2 has_trait = physique_good_3 }
        }
        AND = {
            OR = { has_trait = beauty_good_1 has_trait = beauty_good_2 has_trait = beauty_good_3 }
            OR = { has_trait = physique_good_1 has_trait = physique_good_2 has_trait = physique_good_3 }
        }
        AND = {
            has_trait = fecund
            OR = {
                has_trait = intellect_good_1 has_trait = intellect_good_2 has_trait = intellect_good_3
                has_trait = beauty_good_1 has_trait = beauty_good_2 has_trait = beauty_good_3
                has_trait = physique_good_1 has_trait = physique_good_2 has_trait = physique_good_3
            }
        }
    }
}

# Notification-quality prospects are deliberately stricter than the Ledger itself. Every successful
# prospect remains available in Dynastic Prospects, but a title alone no longer creates an alert.
# Purely political alerts begin at King-tier (or the spouse of a King-tier ruler), where a blood/abdication
# route is substantial enough to justify interrupting the player's attention. Counts and Dukes stay silent
# unless their congenital quality independently makes them noteworthy.
domcom_is_strategic_prospect_trigger = {
    OR = {
        domcom_has_strategic_genetics_trigger = yes
        highest_held_title_tier >= tier_kingdom
        any_spouse = { is_alive = yes highest_held_title_tier >= tier_kingdom }
    }
}

domcom_can_publicly_humiliate_through_recipient_trigger = {
    # Run from the prospective adult partner, with scope:actor = patron.
    is_alive = yes
    age >= 18
    NOT = { this = scope:actor }
    scope:actor = { is_attracted_to_gender_of = prev }
    is_attracted_to_gender_of = scope:actor
    OR = {
        is_consort_of = scope:actor
        has_relation_crush = scope:actor
        has_relation_lover = scope:actor
        has_relation_soulmate = scope:actor
    }
    OR = {
        any_spouse = { domcom_can_attempt_embarrass_owned_trigger = { PATRON = scope:actor } }
        any_close_or_extended_family_member = { domcom_can_attempt_embarrass_owned_trigger = { PATRON = scope:actor } }
    }
}

# A single Owned subject may only face one embarrassment attempt every four months and no more than
# six successful public humiliations from the same Patron. The Patron pointer allows a future conqueror
# to start a fresh record rather than inheriting somebody else's cap.
domcom_can_attempt_embarrass_owned_trigger = {
    is_alive = yes
    age >= 18
    has_character_flag = domcom_owned_cuck
    has_variable = domcom_patron
    var:domcom_patron = $PATRON$
    NOT = { has_character_flag = domcom_embarrass_attempt_cooldown }
    OR = {
        NOT = { has_variable = domcom_embarrass_counter_patron }
        NOT = { var:domcom_embarrass_counter_patron = $PATRON$ }
        NOT = { has_variable = domcom_embarrass_successes }
        var:domcom_embarrass_successes < 6
    }
    OR = {
        any_spouse = {
            is_alive = yes age >= 18
            $PATRON$ = { is_attracted_to_gender_of = prev }
            is_attracted_to_gender_of = $PATRON$
            OR = { has_relation_crush = $PATRON$ has_relation_lover = $PATRON$ has_relation_soulmate = $PATRON$ }
        }
        any_close_or_extended_family_member = {
            is_alive = yes age >= 18
            has_variable = domcom_crush_source
            var:domcom_crush_source = root
            $PATRON$ = { is_attracted_to_gender_of = prev }
            is_attracted_to_gender_of = $PATRON$
            OR = { has_relation_crush = $PATRON$ has_relation_lover = $PATRON$ has_relation_soulmate = $PATRON$ }
        }
    }
}

domcom_can_demand_abdication_for_blood_trigger = {
    is_alive = yes
    is_landed = yes
    has_character_flag = domcom_owned_cuck
    has_variable = domcom_patron
    var:domcom_patron = $PATRON$
    NOT = { has_character_flag = domcom_blood_abdication_immunity }
    NOT = { has_character_flag = domcom_blood_abdication_pending }
    OR = {
        AND = {
            has_variable = domcom_blood_successor
            var:domcom_blood_successor = {
                is_alive = yes
                any_parent = { this = $PATRON$ }
                trigger_if = {
                    limit = { exists = $PATRON$.house }
                    house = $PATRON$.house
                }
            }
        }
        AND = {
            exists = primary_heir
            primary_heir = {
                is_alive = yes
                any_parent = { this = $PATRON$ }
                trigger_if = {
                    limit = { exists = $PATRON$.house }
                    house = $PATRON$.house
                }
            }
        }
    }
}

domcom_ai_is_enabled_trigger = {
    OR = {
        has_game_rule = domcom_ai_all
        AND = {
            has_game_rule = domcom_ai_notable
            OR = {
                highest_held_title_tier >= tier_kingdom
                has_trait = seducer
                has_trait = lustful
                has_trait = ambitious
                has_trait = arrogant
                has_trait = sadistic
            }
        }
    }
}

# Run from the prospective hegemon.
domcom_can_summon_imperial_tribute_trigger = {
    is_alive = yes
    age >= 18
    is_landed = yes
    is_imprisoned = no
    any_vassal = { is_alive = yes domcom_is_political_vassal_ruler_trigger = yes }
    NOT = { has_character_flag = domcom_tribute_season_active }
    NOT = { has_character_flag = domcom_tribute_cooldown }
    OR = {
        highest_held_title_tier >= tier_empire
        AND = {
            highest_held_title_tier = tier_kingdom
            is_independent_ruler = yes
        }
    }
}

# Run from a vassal with scope:domcom_tribute_patron saved.
domcom_has_household_tribute_candidate_trigger = {
    OR = {
        AND = {
            age >= 18
            is_alive = yes
            scope:domcom_tribute_patron = { is_attracted_to_gender_of = prev }
            is_attracted_to_gender_of = scope:domcom_tribute_patron
        }
        any_spouse = {
            is_alive = yes age >= 18
            scope:domcom_tribute_patron = { is_attracted_to_gender_of = prev }
            is_attracted_to_gender_of = scope:domcom_tribute_patron
        }
        any_child = {
            is_alive = yes age >= 18
            scope:domcom_tribute_patron = { is_attracted_to_gender_of = prev }
            is_attracted_to_gender_of = scope:domcom_tribute_patron
        }
    }
}

domcom_ui_roster_filter_trigger = {
    OR = {
        scope:domcom_ui_patron = { NOT = { exists = var:domcom_ui_filter_mode } }
        scope:domcom_ui_patron = { var:domcom_ui_filter_mode = flag:all }
        AND = { scope:domcom_ui_patron = { var:domcom_ui_filter_mode = flag:landed } is_landed = yes }
        AND = { scope:domcom_ui_patron = { var:domcom_ui_filter_mode = flag:dukeplus } highest_held_title_tier >= tier_duchy }
        AND = { scope:domcom_ui_patron = { var:domcom_ui_filter_mode = flag:kingplus } highest_held_title_tier >= tier_kingdom }
    }
}


# Run from a prospective target. A numbered Slave creates a permanent access point for the Patron's
# dynasty against that character and their close/extended family.
domcom_slave_network_target_trigger = {
    $PATRON$ = { exists = dynasty }
    OR = {
        AND = {
            has_character_flag = domcom_dynasty_slave
            has_variable = domcom_pet_patron
            var:domcom_pet_patron = {
                dynasty = $PATRON$.dynasty
            }
        }
        any_close_or_extended_family_member = {
            is_alive = yes
            has_character_flag = domcom_dynasty_slave
            has_variable = domcom_pet_patron
            var:domcom_pet_patron = {
                dynasty = $PATRON$.dynasty
            }
        }
    }
}

domcom_general_alpha_target_trigger = {
    is_alive = yes
    is_imprisoned = no
    NOT = { this = scope:actor }
    sex_same_as = scope:actor
    scope:actor = {
        is_alive = yes
        is_imprisoned = no
    }
}

# Run from a prospective rival with scope:actor = challenger. True if the target is already publicly
# Cucked by the actor OR the actor has created qualifying cuck evidence that has not yet been formally
# registered.
domcom_is_cuck_target_of_actor_trigger = {
    OR = {
        AND = {
            has_character_flag = domcom_cucked
            has_variable = domcom_cuck_patron
            var:domcom_cuck_patron = scope:actor
        }
        domcom_cuck_evidence_trigger = yes
    }
}

domcom_tantalize_target_trigger = {
    is_alive = yes
    age >= 18
    is_imprisoned = no
    NOT = { this = scope:actor }
    scope:actor = {
        is_alive = yes
        age >= 18
        is_imprisoned = no
        is_attracted_to_gender_of = prev
    }
    is_attracted_to_gender_of = scope:actor

    # A successful household defense protects this specific spouse/concubine from all AI Dominion
    # courtship for one year. Human-directed interactions are not blocked by the protection.
    NOT = {
        AND = {
            has_character_flag = domcom_household_guarded
            scope:actor = { is_ai = yes }
        }
    }

    NOR = {
        has_relation_lover = scope:actor
        has_relation_soulmate = scope:actor
    }

    # Devotion is patron-specific. A character already being worked on by this patron can be Tantalized
    # again; an established Pet cannot.
    OR = {
        NOT = { has_variable = domcom_obedience_patron }
        var:domcom_obedience_patron = scope:actor
    }
    NOT = {
        AND = {
            has_character_flag = domcom_pet
            has_variable = domcom_pet_patron
            var:domcom_pet_patron = scope:actor
        }
    }
}

domcom_needs_profile_init_trigger = {
    is_alive = yes
    age >= 18
    OR = {
        # Male adult who has never been measured.
        AND = {
            domcom_should_express_endowment_trigger = yes
            NOT = { has_variable = domcom_length_tenths }
        }
        # Measured under an older version but never synced to a visible trait.
        AND = {
            domcom_should_express_endowment_trigger = yes
            has_variable = domcom_length_tenths
            has_variable = domcom_girth_tenths
            NOT = { has_variable = domcom_endowment_category }
        }
        # Attracted to men but missing any part of the permanent Endowment preference profile.
        AND = {
            is_attracted_to_men = yes
            OR = {
                NOT = { has_variable = domcom_size_preference_primary }
                NOT = { has_variable = domcom_pref_length_tenths }
                NOT = { has_variable = domcom_pref_girth_tenths }
            }
        }
        # Adult women missing any part of the permanent Breast Profile.
        AND = {
            is_female = yes
            OR = {
                NOT = { has_variable = domcom_underbust_tenths }
                NOT = { has_variable = domcom_bust_tenths }
                NOT = { has_variable = domcom_breast_fullness_tenths }
                NOT = { has_variable = domcom_breast_category }
            }
        }
        # Anyone attracted to women can carry an independent breast-size preference profile.
        AND = {
            is_attracted_to_women = yes
            OR = {
                NOT = { has_variable = domcom_pref_underbust_tenths }
                NOT = { has_variable = domcom_pref_breast_fullness_tenths }
            }
        }
    }
}


domcom_is_spawn_of_cuck_trigger = {
    OR = {
        AND = { exists = mother mother = { has_character_flag = domcom_cucked } }
        AND = { exists = real_father real_father = { has_character_flag = domcom_cucked } }
        AND = {
            NOT = { exists = real_father }
            exists = father
            father = { has_character_flag = domcom_cucked }
        }
    }
}

domcom_deserves_cucked_nickname_trigger = {
    has_character_flag = domcom_cucked
    NOT = { has_nickname = nick_domcom_the_cucked }
}

domcom_intimacy_partner_trigger = {
    is_alive = yes
    age >= 18
    NOT = {
        AND = {
            has_character_flag = domcom_household_guarded
            scope:actor = { is_ai = yes }
        }
    }
    OR = {
        # A lawful spouse/concubine/consort is directly eligible.
        is_consort_of = scope:actor
        AND = {
            OR = {
                has_relation_crush = scope:actor
                has_relation_lover = scope:actor
                has_relation_soulmate = scope:actor
            }
            scope:actor = { is_attracted_to_gender_of = prev }
            is_attracted_to_gender_of = scope:actor
        }
    }
}


# Run from a county title. PARTNER is the prospective spouse/patron.
domcom_county_in_partner_subrealm_trigger = {
    exists = holder
    holder = {
        OR = {
            this = $PARTNER$
            is_vassal_or_below_of = $PARTNER$
        }
    }
}

# Run from the crowned ruler. The capital must be in, or no more than five county-border steps from, any
# county held inside PARTNER's sub-realm.
domcom_crowned_union_proximity_trigger = {
    exists = capital_county
    capital_county = {
        OR = {
            domcom_county_in_partner_subrealm_trigger = { PARTNER = $PARTNER$ }
            any_neighboring_county = {
                OR = {
                    domcom_county_in_partner_subrealm_trigger = { PARTNER = $PARTNER$ }
                    any_neighboring_county = {
                        OR = {
                            domcom_county_in_partner_subrealm_trigger = { PARTNER = $PARTNER$ }
                            any_neighboring_county = {
                                OR = {
                                    domcom_county_in_partner_subrealm_trigger = { PARTNER = $PARTNER$ }
                                    any_neighboring_county = {
                                        OR = {
                                            domcom_county_in_partner_subrealm_trigger = { PARTNER = $PARTNER$ }
                                            any_neighboring_county = {
                                                domcom_county_in_partner_subrealm_trigger = { PARTNER = $PARTNER$ }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

# Baseline pair eligibility for the direct interaction and autonomous AI offer. The current character is
# the crowned ruler; PARTNER is the prospective spouse.
domcom_crowned_union_pair_trigger = {
    is_alive = yes
    age >= 18
    is_female = yes
    is_landed = yes
    highest_held_title_tier >= tier_kingdom
    is_married = yes
    is_imprisoned = no
    NOT = { is_close_or_extended_family_of = $PARTNER$ }
    NOT = { any_spouse = { this = $PARTNER$ } }
    NOT = { has_trait = celibate }
    allowed_to_marry_character_gender_trigger = { CHARACTER = $PARTNER$ }
    $PARTNER$ = {
        is_alive = yes
        age >= 18
        is_imprisoned = no
        can_marry_trigger = yes
        allowed_to_marry_character_gender_trigger = { CHARACTER = prev }
    }
    domcom_crowned_union_proximity_trigger = { PARTNER = $PARTNER$ }
}

# Pet-level direct control: the player has already fully won her over.
domcom_crowned_union_pet_trigger = {
    domcom_crowned_union_pair_trigger = { PARTNER = $PARTNER$ }
    has_character_flag = domcom_pet
    has_variable = domcom_pet_patron
    var:domcom_pet_patron = $PARTNER$
}

# Personality gate for a Queen/Empress who independently decides to act on attraction.
# Stable/content/chaste personalities do not generate proposals.
domcom_crowned_heart_actor_trigger = {
    is_ai = yes
    NOT = { has_trait = celibate }
    NOR = {
        has_trait = chaste
        has_trait = content
        has_trait = humble
    }
    OR = {
        has_trait = lustful
        has_trait = ambitious
        has_trait = deceitful
        has_trait = arbitrary
        has_trait = brave
        has_trait = arrogant
        has_trait = wrathful
        has_trait = gregarious
        has_trait = fickle
        has_trait = eccentric
    }
}

domcom_is_unacknowledged_blood_trigger = {
    is_alive = yes
    exists = scope:domcom_ui_patron
    real_father ?= scope:domcom_ui_patron
    NOT = { father ?= scope:domcom_ui_patron }
    NOT = { has_character_flag = domcom_blood_acknowledged_child }
}

# Tantalized roster filter (issue 5). Sex is read from the character, so anyone CK3 records as neither
# male nor female still appears under "All".
domcom_tantalize_filter_trigger = {
    OR = {
        NOT = { exists = scope:domcom_ui_patron.var:domcom_ui_tantalize_filter }
        scope:domcom_ui_patron.var:domcom_ui_tantalize_filter = flag:all
        AND = { scope:domcom_ui_patron.var:domcom_ui_tantalize_filter = flag:women is_female = yes }
        AND = { scope:domcom_ui_patron.var:domcom_ui_tantalize_filter = flag:men   is_male = yes }
        AND = { scope:domcom_ui_patron.var:domcom_ui_tantalize_filter = flag:pets  has_character_flag = domcom_pet }
    }
}

domcom_alpha_budget_available_trigger = {
    OR = {
        has_game_rule = domcom_alpha_budget_off
        NOT = { has_variable = domcom_alpha_budget_used }
        var:domcom_alpha_budget_used < domcom_alpha_budget_cap_value
    }
}


# The recipient's spouse has been taken by the actor.
domcom_spouse_taken_by_actor_trigger = {
    any_spouse = {
        is_alive = yes
        # Plural-marriage compatibility: a spouse who is also lawfully married/consorted to the actor
        # is not evidence that the recipient has been cuckolded by that actor.
        NOT = { is_consort_of = scope:actor }
        OR = {
            has_relation_lover = scope:actor
            has_relation_soulmate = scope:actor
            any_in_list = {
                variable = domcom_betrayal_evidence_patrons
                this = scope:actor
            }
            any_child = {
                OR = {
                    father ?= scope:actor
                    real_father ?= scope:actor
                }
            }
        }
    }
}

# The recipient's spouse has been faced down by the actor in an Alpha Check.
domcom_spouse_dominated_by_actor_trigger = {
    any_spouse = {
        is_alive = yes
        has_character_flag = domcom_dominated
        has_variable = domcom_dominance_patron
        var:domcom_dominance_patron = scope:actor
    }
}

# 2.6.13 — Invite-to-Bed household submission gate.
# Run from the lover's spouse/cuck. At terminal Cuck XP, a cuck who is actually tied to the acting
# Patron no longer confronts or imprisons that Patron or their lover merely because the encounter was
# public. A 1000-XP cuck belonging to somebody else does not grant this protection.
domcom_intimacy_cuckold_submitted_to_patron_trigger = {
    has_variable = domcom_cuck_xp
    var:domcom_cuck_xp >= 1000
    OR = {
        AND = { has_variable = domcom_cuck_patron var:domcom_cuck_patron = $PATRON$ }
        AND = { has_variable = domcom_cuck_origin_patron var:domcom_cuck_origin_patron = $PATRON$ }
        AND = { has_variable = domcom_patron var:domcom_patron = $PATRON$ }
        any_in_list = { variable = domcom_cuck_patrons this = $PATRON$ }
    }
}



# 2.6.57 — journal-state helper. Run from a Dominion subject and pass the prospective Patron.
# The lover journal suppressor uses this in both directions so temporary vanilla Lover churn does not
# masquerade as a real relationship ending while a persistent Dominion bond still has live state.
domcom_has_active_dominion_to_patron_trigger = {
    OR = {
        AND = {
            has_variable = domcom_cuck_xp
            var:domcom_cuck_xp > 0
            OR = {
                AND = { has_variable = domcom_cuck_patron var:domcom_cuck_patron = $PATRON$ }
                AND = { has_variable = domcom_cuck_origin_patron var:domcom_cuck_origin_patron = $PATRON$ }
                AND = { has_variable = domcom_patron var:domcom_patron = $PATRON$ }
                any_in_list = { variable = domcom_cuck_patrons this = $PATRON$ }
            }
        }
        AND = {
            has_variable = domcom_obedience
            var:domcom_obedience > 0
            has_variable = domcom_obedience_patron
            var:domcom_obedience_patron = $PATRON$
        }
        AND = {
            has_character_flag = domcom_pet
            has_variable = domcom_pet_patron
            var:domcom_pet_patron = $PATRON$
        }
        AND = {
            has_character_flag = domcom_communion_intimate_bound
            has_variable = domcom_communion_intimate_patron
            var:domcom_communion_intimate_patron = $PATRON$
        }
    }
}


# v2.6.67 performance: monthly Patron upkeep should not wake every AI ruler in the world.
# These are cheap local-state checks only: existing Dominion registries, cult state, or an
# actual Lover/Soulmate relation that can progress Devotion. Human players remain ungated.
domcom_ai_monthly_patron_relevant_trigger = {
    OR = {
        has_variable_list = domcom_owned_registry
        has_variable_list = domcom_cucked_registry
        has_variable_list = domcom_crush_candidates
        has_variable_list = domcom_intimate_registry
        has_variable_list = domcom_lick_cult_adherents
        AND = { has_variable = domcom_cult_strength var:domcom_cult_strength > 0 }
        AND = { has_variable = domcom_cult_retinue_pending var:domcom_cult_retinue_pending = 1 }
        any_relation = { type = lover is_alive = yes age >= 18 }
        any_relation = { type = soulmate is_alive = yes age >= 18 }
    }
}
