﻿namespace = feast_tsagaan_sar_events

### 0001 - 0099 - Gift Events
##  0001 - Host: Determine who's gifting or no
##  0002 - Guest: Choose what to gift
##  0003 - Guest: Choose how much to gift
##  0004 - Guest: Choose which artifact to gift
##  0010 - Host: Gift Recap

### 0100 - 0199 - Guest Events
##  0100 - Your gift was unaccounted for
##  0101 - Someone has a cool Horse

### 0200 - 0299 - Guest & Host Events
### 0200 - You're invited to gamble
### 0210 - Someone gives you herding tips
### 0220 - You decide to forgive a rival (or not)
### 0230 - Someone is throatsinging
### 0240 - You perform throatsinging
### 0250 - Someone starts a horse race
### 0251 - Horse Race (follow up)
### 0252 - Horse Race (follow up 2)
### 0253 - Horse Race Outcome
### 0260 - Someone is dressed very well
### 0270 - Drinking contest
### 0280 - You ask an elder for wisdom
### 0290 - The court astrologer / wise guy talks about the current year

### 0300 - 0399 - Host Events
### 0300 - Someone is cleaning the yurts
### 0310 - You overhear a guest brag about not giving you a gift
### 0320 - You choose to distribute gifts to the elders

scripted_trigger in_tsaagan_sar_trigger = {
    involved_activity = {
        has_activity_option = {
            category = special_type
            option = feast_type_tsagaan_sar
        }
    }
}
# Determine who will gift
feast_tsagaan_sar_events.0001 = {
    type = activity_event

    title = feast_tsagaan_sar_events.0001.t
    desc = feast_tsagaan_sar_events.0001.desc
    theme = feast_activity

    left_portrait = {
        character = root
        animation = personality_honorable
    }

    immediate = {
        save_scope_as = host
        involved_activity = {
            every_attending_character = {
                limit = {
                    is_adult = yes
                    NOT = { this = root }
                }
                save_scope_as = possible_gifter
                # Will they gift, though?
                if = {
                    limit = {
                        mpo_tsagaan_sar_gift_likely_value >= 75
                    }
                    set_variable = {
                        name = tsagaan_sar_gift
                        value = flag:will_gift
                    }
					add_to_list = gifters_list
                }
                else_if = {
                    limit = {
                        mpo_tsagaan_sar_gift_likely_value <= 25
                    }
                    set_variable = {
                        name = tsagaan_sar_gift
                        value = flag:no_gift
                    }
                }
                else = {
                    set_variable = {
                        name = tsagaan_sar_gift
                        value = flag:no_gift
                    }
                    random = {
                        chance = mpo_tsagaan_sar_gift_likely_value
                        set_variable = {
                            name = tsagaan_sar_gift
                            value = flag:will_gift
                        }
						add_to_list = gifters_list
                    }
                }
            }
        }
		if = {
			limit = { list_size:gifters_list > 0 }
			save_scope_value_as = {
				name = gifters_list_size
				value = list_size:gifters_list
			}
		}
        set_variable = {
            name = feast_herd_total
            value = 0
        }
        set_variable = {
            name = feast_gold_total
            value = 0
        }
        set_variable = {
            name = feast_prestige_total
            value = 0
        }
        set_variable = {
            name = feast_piety_total
            value = 0
        }
    }

    # Riches
    option = {
        name = feast_tsagaan_sar_events.0001.a
        trigger = { list_size:gifters_list >= 1 }
        # Will appreciate gold gifts more
        set_variable = {
            name = tsagaan_sar_gift_pref
            value = flag:gold
        }
        custom_tooltip = feast_tsagaan_sar_events.0001.a_tt

        ai_chance = {
            base = 100
            ai_value_modifier = {
                ai_greed = 1
            }
        }
    }

    # Stuff
    option = {
        name = feast_tsagaan_sar_events.0001.b
        trigger = { list_size:gifters_list >= 1 }
        set_variable = {
            name = tsagaan_sar_gift_pref
            value = flag:artifact
        }
        custom_tooltip = feast_tsagaan_sar_events.0001.b_tt

        ai_chance = {
            base = 100
            ai_value_modifier = {
                ai_greed = 1
            }
        }
    }

    # People
    option = {
        name = feast_tsagaan_sar_events.0001.c
        trigger = { list_size:gifters_list >= 1 }
        set_variable = {
            name = tsagaan_sar_gift_pref
            value = flag:hook
        }
        custom_tooltip = feast_tsagaan_sar_events.0001.c_tt

        ai_chance = {
            base = 100
            ai_value_modifier = {
                ai_sociability = 1
            }
        }
    }

    # Faith
    option = {
        name = feast_tsagaan_sar_events.0001.d
        trigger = { list_size:gifters_list >= 1 }
        set_variable = {
            name = tsagaan_sar_gift_pref
            value = flag:piety
        }
        custom_tooltip = feast_tsagaan_sar_events.0001.d_tt

        ai_chance = {
            base = 100
            ai_value_modifier = {
                ai_zeal = 1
            }
        }
    }

    # Food!
    option = {
        name = feast_tsagaan_sar_events.0001.e
        trigger = { has_trait = gluttonous }
        add_stress = minor_stress_loss
    }

    option = {
        name = feast_tsagaan_sar_events.0001.f
		trigger = { list_size:gifters_list < 1 }
        add_stress = minor_stress_loss
    }

    after = { # Prepare your gift!
        if = {
            limit = {
                mpo_tsagaan_sar_guest_gifters >= 1 
            }
            involved_activity = {
                every_attending_character = {
                    limit = {
                        NOT = { this = involved_activity.var:host_var }
                        OR = {
                            var:tsagaan_sar_gift ?= flag:will_gift
                            is_ai = no
                        }
                    }
                    trigger_event = {
                        id = feast_tsagaan_sar_events.0002
                    }
                }
            }
            custom_tooltip = feast_tsagaan_sar_events.0001_tt
        }
        else = {
            custom_tooltip = feast_tsagaan_sar_events.0001_none
        }
    }
}

scripted_trigger more_likely_to_give_important_gift_trigger = {
    exists = involved_activity.var:host_var
    OR = {
    	is_tributary_of = involved_activity.var:host_var
		is_obedient_to = involved_activity.var:host_var
        is_vassal_or_below_of = involved_activity.var:host_var
        is_any_family_relation_or_spouse_trigger = { CHARACTER = involved_activity.var:host_var }
        has_important_relationship_with_character_trigger = { CHARACTER = involved_activity.var:host_var }
    }
}

scripted_trigger more_likely_to_give_decent_gift_trigger = {
    exists = involved_activity.var:host_var
    OR = {
        is_liege_or_above_of = involved_activity.var:host_var
        is_councillor_of = involved_activity.var:host_var
        is_extended_family_of = involved_activity.var:host_var
        AND = {
            is_courtier_of = involved_activity.var:host_var
            has_any_court_position = yes
        }
    }
}

scripted_trigger more_likely_to_give_ok_gift_trigger = {
    exists = involved_activity.var:host_var
    NOR = {
        more_likely_to_give_decent_gift_trigger = yes
        more_likely_to_give_important_gift_trigger = yes
    }
}

scripted_effect add_to_gift_pool_effect = {
    save_scope_as = recipient
    $GIVER$ = { save_scope_as = giver }


    scope:giver = {
        if = {
            limit = {
                NOT = { has_variable = tsagaan_sar_gift_amount }
            }
            set_variable = {
                name = tsagaan_sar_gift_amount
                value = flag:$AMOUNT$
            }
        }
    }

    # send_interface_message = {
    #     type = event_generic_neutral
    switch = {
        trigger = $TYPE$
        flag:herd = {
            change_variable = {
                name = feast_herd_total
                add = $AMOUNT$_herd_value
            }
            scope:giver = { pay_herd = { target = scope:recipient value = domicile.$AMOUNT$_herd_value } }
        }
        flag:gold = {
            change_variable = {
                name = feast_gold_total
                add = $AMOUNT$_gold_value
            }
            scope:giver = { pay_short_term_gold = { target = scope:recipient gold = $AMOUNT$_gold_value } }
        }
        flag:prestige = {
            change_variable = {
                name = feast_prestige_total
                add = $AMOUNT$_prestige_gain
            }
            scope:giver = {
                add_prestige = $AMOUNT$_prestige_loss
                scope:recipient = { add_prestige = $AMOUNT$_prestige_gain }
            }
        }
        flag:piety = {
            change_variable = {
                name = feast_piety_total
                add = $AMOUNT$_piety_gain
            }
            scope:giver = {
                add_piety = $AMOUNT$_piety_loss
                scope:recipient = { add_piety = $AMOUNT$_piety_gain }
            }
        }
    }
    #}
}


scripted_effect gift_received_notif = {
    hidden_effect = {
        random_list = {
            $CHANCE_1$ = {
                modifier = {
                    add = 25
                    involved_activity.var:host_var = { var:tsagaan_sar_gift_pref = flag:$TYPE$ }
                }
                send_interface_message = {
                    title = tsagaan_sar_gift_received
                    right_icon = involved_activity.var:host_var
                    type = event_generic_neutral
                    involved_activity.var:host_var = {
                        add_opinion = {
                            target = root
                            modifier = grateful_opinion
                            opinion = 15
                        }
                    }
                }
            }
            $CHANCE_2$ = {
                send_interface_message = {
                    title = tsagaan_sar_gift_received
                    right_icon = involved_activity.var:host_var
                    type = event_generic_neutral
                    involved_activity.var:host_var = {
                        add_opinion = {
                            target = root
                            modifier = grateful_opinion
                            opinion = 5
                        }
                    }
                }
            }
        }
    }
}
# Choose what you will give!
feast_tsagaan_sar_events.0002 = {
    type = activity_event

    title = feast_tsagaan_sar_events.0002.t
    desc = {
        first_valid = {
            triggered_desc = {
                trigger = {
                    has_character_flag = already_chose_gift
                }
                desc = feast_tsagaan_sar_events.0002.desc_again
            }
            desc = feast_tsagaan_sar_events.0002.desc
        }
    }
    theme = feast_activity

    left_portrait = {
        character = root
        animation = stress
    }

    lower_center_portrait = involved_activity.var:host_var

    ### DEFAULT OPTIONS ###
    # Nothing lol
    option = {
        name = {
            text = {
                random_valid = {
                    triggered_desc = {
                        trigger = {
                            has_trait = arrogant
                        }
                        desc = feast_tsagaan_sar_events.0002.nothing_arrogant
                    }
                    triggered_desc = {
                        trigger = {
                            has_trait = fickle
                        }
                        desc = feast_tsagaan_sar_events.0002.nothing_fickle
                    }
                    desc = feast_tsagaan_sar_events.0002.nothing
                }
            }
        }
        trigger = {
            NOT = { has_character_flag = cant_no_gift }
        }
        set_variable = {
            name = tsagaan_sar_gift
            value = flag:no_gift
        }
        if = {
            limit = {
                has_variable = tsagaan_sar_gift_item
            }
            remove_variable = tsagaan_sar_gift_item
        }

        ai_chance = {
            base = 0
        }
    }

    # Herd
    option = {
        name = {
            text = {
                random_valid = {
                    desc = feast_tsagaan_sar_events.0002.herd_1
                    desc = feast_tsagaan_sar_events.0002.herd_2
                    desc = feast_tsagaan_sar_events.0002.herd_3
                    triggered_desc = {
                        trigger = {
                            var:tsagaan_sar_gift_item ?= flag:herd
                        }
                        desc = feast_tsagaan_sar_events.0002.herd_4
                    }
                }
            }
        }
        trigger = {
            domicile ?= { herd >= twenty_percent_herd_value }
            involved_activity.var:host_var = {
                domicile ?= { herd < max_herd }
            }
            NOT = { var:tsagaan_sar_gift_item ?= flag:herd }
        }
        set_variable = {
            name = tsagaan_sar_gift_item
            value = flag:herd
        }
        custom_tooltip = feast_tsagaan_sar_events.0002.herd_tt
        trigger_event = feast_tsagaan_sar_events.0003

        ai_chance = {
            base = 125

            ai_value_modifier = {
                ai_greed = -1
            }
            modifier = {
                factor = 2.5
                OR = {
                    more_likely_to_give_important_gift_trigger = yes
                    more_likely_to_give_decent_gift_trigger = yes
                }
            }
            modifier = {
                factor = 2
                more_likely_to_give_ok_gift_trigger = yes
            }
            modifier = {
                factor = 0.75
                domicile ?= { herd >= twenty_percent_herd_value }
            }
            modifier = {
                factor = 1.25
                domicile ?= { herd >= sixty_percent_herd_value }
            }
            modifier = {
                factor = 1.5
                domicile ?= { herd >= eighty_percent_herd_value }
            }
        }
    }

    # Gold
    option = {
        name = {
            text = {
                random_valid = {
                    desc = feast_tsagaan_sar_events.0002.gold_1
                    desc = feast_tsagaan_sar_events.0002.gold_2
                    desc = feast_tsagaan_sar_events.0002.gold_3
                }
            }
        }
        trigger = {
            short_term_gold >= miniscule_gold_value
            NOT = { var:tsagaan_sar_gift_item ?= flag:gold }
        }
        custom_tooltip = feast_tsagaan_sar_events.0002.gold_tt
        set_variable = {
            name = tsagaan_sar_gift_item
            value = flag:gold
        }
        trigger_event = feast_tsagaan_sar_events.0003

        ai_chance = {
            base = 100

            ai_value_modifier = {
                ai_greed = -1
            }
            modifier = {
                factor = 2.5
                OR = {
                    more_likely_to_give_important_gift_trigger = yes
                    more_likely_to_give_decent_gift_trigger = yes
                }
            }
            modifier = {
                add = 25
                involved_activity.var:host_var = { var:tsagaan_sar_gift_pref = flag:gold }
            }
            modifier = {
                factor = 2
                more_likely_to_give_ok_gift_trigger = yes
            }
            modifier = {
                factor = 0.75
                short_term_gold >= miniscule_gold_value
            }
            modifier = {
                factor = 1.25
                short_term_gold >= major_gold_value
            }
            modifier = {
                factor = 1.5
                short_term_gold >= massive_gold_value
            }
        }
    }

    ## OTHER OPTIONS ##

    # Artifact
    option = {
        name = feast_tsagaan_sar_events.0002.artifact
        trigger = {
            has_eligible_artifact_trigger = yes
            NOT = { var:tsagaan_sar_gift_item ?= flag:artifact }
        }
        custom_tooltip = feast_tsagaan_sar_events.0002.artifact_tt
        set_variable = {
            name = tsagaan_sar_gift_item
            value = flag:artifact
        }
        trigger_event = feast_tsagaan_sar_events.0004

        ai_chance = {
            base = 50

            modifier = {
                factor = 2
                more_likely_to_give_important_gift_trigger = yes
            }
            modifier = {
                factor = 1.5
                more_likely_to_give_decent_gift_trigger = yes
            }
            modifier = {
                factor = 1.5
                any_artifact = { artifact_owner = root is_equipped = no }
            }
            modifier = {
                add = 10
                involved_activity.var:host_var = { var:tsagaan_sar_gift_pref = flag:artifact }
            }
        }
    }

    # Loyalty
    option = {
        name = feast_tsagaan_sar_events.0002.loyalty
        trigger = {
            involved_activity.var:host_var = { NOT = { has_hook = root } }
        }
        set_variable = {
            name = tsagaan_sar_gift_item
            value = flag:hook
        }
        involved_activity.var:host_var = {
            send_interface_message = {
                title = tsagaan_sar_gift_title
                right_icon = root
                type = event_generic_neutral
                involved_activity.var:host_var = {
                    add_hook_no_toast = {
                        target = root
                        type = loyalty_hook
                        years = 1
                    }
                }
            }
        }

        gift_received_notif = {
            TYPE = hook
            CHANCE_1 = 50
            CHANCE_2 = 50
        }

        stress_impact = {
            paranoid = minor_stress_impact_gain
        }

        ai_chance = {
            base = 10
            modifier = {
                add = 5
                involved_activity.var:host_var = { var:tsagaan_sar_gift_pref = flag:hook }
            }
        }
    }

    # Prestige
    option = {
        name = feast_tsagaan_sar_events.0002.prestige
        trigger = {
            prestige >= miniscule_prestige_gain
            NOT = { var:tsagaan_sar_gift_item ?= flag:prestige }
        }
        custom_tooltip = feast_tsagaan_sar_events.0002.prestige_tt
        set_variable = {
            name = tsagaan_sar_gift_item
            value = flag:prestige
        }
        trigger_event = feast_tsagaan_sar_events.0003

        ai_chance = {
            base = 35
            modifier = {
                factor = 2
                more_likely_to_give_ok_gift_trigger = yes
            }
            modifier = {
                factor = 0.75
                prestige >= minor_prestige_value
            }
            modifier = {
                factor = 1.25
                prestige >= major_prestige_value
            }
            modifier = {
                factor = 1.5
                prestige >= massive_prestige_value
            }
        }
    }

    # Blessing
    option = {
        name = feast_tsagaan_sar_events.0002.blessing
        trigger = {
            piety >= miniscule_piety_value
            involved_activity.var:host_var.faith = root.faith
            NOT = { var:tsagaan_sar_gift_item ?= flag:piety }
        }
        custom_tooltip = feast_tsagaan_sar_events.0002.blessing_tt
        set_variable = {
            name = tsagaan_sar_gift_item
            value = flag:piety
        }
        trigger_event = feast_tsagaan_sar_events.0003

        ai_chance = {
            base = 15
            ai_value_modifier = {
                ai_zeal = 1
            }
            modifier = {
                factor = 2
                more_likely_to_give_ok_gift_trigger = yes
            }
            modifier = {
                factor = 0.75
                piety >= miniscule_piety_value
            }
            modifier = {
                factor = 1.25
                piety >= major_piety_value
            }
            modifier = {
                factor = 1.5
                piety >= massive_piety_value
            }
        }
    }
}

# Giving something numerical (Herd, Gold, Piety, Prestige)
feast_tsagaan_sar_events.0003 = {
    type = activity_event

    title = feast_tsagaan_sar_events.0002.t
    desc = {
        first_valid = {
            triggered_desc = {
                trigger = {
                    var:tsagaan_sar_gift_item ?= flag:herd
                }
                desc = feast_tsagaan_sar_events.0003.herd
            }
            triggered_desc = {
                trigger = {
                    var:tsagaan_sar_gift_item ?= flag:gold
                }
                desc = feast_tsagaan_sar_events.0003.gold
            }
            triggered_desc = {
                trigger = {
                    var:tsagaan_sar_gift_item ?= flag:piety
                }
                desc = feast_tsagaan_sar_events.0003.piety
            }
            triggered_desc = {
                trigger = {
                    var:tsagaan_sar_gift_item ?= flag:prestige
                }
                desc = feast_tsagaan_sar_events.0003.prestige
            }
        }
    }
    theme = feast_activity

    left_portrait = {
        character = root
        animation = thinking
    }

    lower_center_portrait = involved_activity.var:host_var

    # Major
    option = {
        name = {
            text = {
                random_valid = {
                    triggered_desc = {
                        trigger = {
                            var:tsagaan_sar_gift_item ?= flag:herd
                        }
                        desc = feast_tsagaan_sar_events.0003.major.herd
                    }
                    triggered_desc = {
                        trigger = {
                            var:tsagaan_sar_gift_item ?= flag:gold
                        }
                        desc = feast_tsagaan_sar_events.0003.major.gold
                    }
                    triggered_desc = {
                        trigger = {
                            var:tsagaan_sar_gift_item ?= flag:prestige
                        }
                        desc = feast_tsagaan_sar_events.0003.major.prestige
                    }
                    triggered_desc = {
                        trigger = {
                            var:tsagaan_sar_gift_item ?= flag:piety
                        }
                        desc = feast_tsagaan_sar_events.0003.major.piety
                    }
                }
            }
        }
        trigger = {
            OR = {
                AND = {
                    var:tsagaan_sar_gift_item ?= flag:herd
                    domicile ?= { herd >= medium_herd_value }
                }
                AND = {
                    var:tsagaan_sar_gift_item ?= flag:gold
                    short_term_gold >= medium_gold_value
                }
                AND = {
                    var:tsagaan_sar_gift_item ?= flag:prestige
                    prestige >= medium_prestige_value
                }
                AND = {
                    var:tsagaan_sar_gift_item ?= flag:piety
                    piety >= medium_piety_value
                }
            }
        }
        switch = {
            trigger = var:tsagaan_sar_gift_item
            flag:herd = {
                involved_activity.var:host_var = {
                    add_to_gift_pool_effect = {
                        GIVER = root
                        TYPE = flag:herd
                        AMOUNT = medium
                    }
                }
                gift_received_notif = {
                    TYPE = herd
                    CHANCE_1 = 70
                    CHANCE_2 = 30
                }
            }

            flag:gold = {
                involved_activity.var:host_var = {
                    add_to_gift_pool_effect = {
                        GIVER = root
                        TYPE = flag:gold
                        AMOUNT = medium
                    }
                }
                gift_received_notif = {
                    TYPE = gold
                    CHANCE_1 = 70
                    CHANCE_2 = 30
                }
            }

            flag:prestige = {
                involved_activity.var:host_var = {
                    add_to_gift_pool_effect = {
                        GIVER = root
                        TYPE = flag:prestige
                        AMOUNT = medium
                    }
                }
                gift_received_notif = {
                    TYPE = prestige
                    CHANCE_1 = 70
                    CHANCE_2 = 30
                }
            }
            flag:piety = {
                involved_activity.var:host_var = {
                    add_to_gift_pool_effect = {
                        GIVER = root
                        TYPE = flag:piety
                        AMOUNT = medium
                    }

                }
                gift_received_notif = {
                    TYPE = piety
                    CHANCE_1 = 70
                    CHANCE_2 = 30
                }
            }
        }


        ai_chance = {
            base = 100
            modifier = {
                factor = 1.25
                more_likely_to_give_important_gift_trigger = yes
            }
        }
    }

    # Medium
    option = {
        name = {
            text = {
                random_valid = {
                    triggered_desc = {
                        trigger = {
                            var:tsagaan_sar_gift_item ?= flag:herd
                        }
                        desc = feast_tsagaan_sar_events.0003.medium.herd
                    }
                    triggered_desc = {
                        trigger = {
                            var:tsagaan_sar_gift_item ?= flag:herd
                        }
                        desc = feast_tsagaan_sar_events.0003.medium.herd_2
                    }
                    triggered_desc = {
                        trigger = {
                            var:tsagaan_sar_gift_item ?= flag:gold
                        }
                        desc = feast_tsagaan_sar_events.0003.medium.gold
                    }
                    triggered_desc = {
                        trigger = {
                            var:tsagaan_sar_gift_item ?= flag:gold
                        }
                        desc = feast_tsagaan_sar_events.0003.medium.gold_2
                    }
                    triggered_desc = {
                        trigger = {
                            var:tsagaan_sar_gift_item ?= flag:prestige
                        }
                        desc = feast_tsagaan_sar_events.0003.medium.prestige
                    }
                    triggered_desc = {
                        trigger = {
                            var:tsagaan_sar_gift_item ?= flag:piety
                        }
                        desc = feast_tsagaan_sar_events.0003.medium.piety
                    }
                }
            }
        }
        trigger = {
            OR = {
                AND = {
                    var:tsagaan_sar_gift_item ?= flag:herd
                    domicile ?= { herd >= minor_herd_value }
                }
                AND = {
                    var:tsagaan_sar_gift_item ?= flag:gold
                    short_term_gold >= minor_gold_value
                }
                AND = {
                    var:tsagaan_sar_gift_item ?= flag:prestige
                    prestige >= minor_prestige_value
                }
                AND = {
                    var:tsagaan_sar_gift_item ?= flag:piety
                    piety >= minor_piety_value
                }
            }
        }
        switch = {
            trigger = var:tsagaan_sar_gift_item
            flag:herd = {
                involved_activity.var:host_var = {
                    add_to_gift_pool_effect = {
                        GIVER = root
                        TYPE = flag:herd
                        AMOUNT = minor
                    }

                }
                gift_received_notif = {
                    TYPE = herd
                    CHANCE_1 = 60
                    CHANCE_2 = 40
                }
            }
            flag:gold = {
                involved_activity.var:host_var = {
                    add_to_gift_pool_effect = {
                        GIVER = root
                        TYPE = flag:gold
                        AMOUNT = minor
                    }

                }
                gift_received_notif = {
                    TYPE = gold
                    CHANCE_1 = 60
                    CHANCE_2 = 40
                }
            }
            flag:prestige = {
                involved_activity.var:host_var = {
                    add_to_gift_pool_effect = {
                        GIVER = root
                        TYPE = flag:prestige
                        AMOUNT = minor
                    }

                }
                gift_received_notif = {
                    TYPE = prestige
                    CHANCE_1 = 60
                    CHANCE_2 = 40
                }
            }
            flag:piety = {
                involved_activity.var:host_var = {
                    add_to_gift_pool_effect = {
                        GIVER = root
                        TYPE = flag:piety
                        AMOUNT = minor
                    }

                }
                gift_received_notif = {
                    TYPE = piety
                    CHANCE_1 = 60
                    CHANCE_2 = 40
                }
            }
        }
        ai_chance = {
            base = 100
            modifier = {
                factor = 1.5
                more_likely_to_give_decent_gift_trigger = yes
            }
        }
    }

    # Minor
    option = {
        name = {
            text = {
                random_valid = {
                    triggered_desc = {
                        trigger = {
                            var:tsagaan_sar_gift_item ?= flag:herd
                        }
                        desc = feast_tsagaan_sar_events.0003.minor.herd
                    }
                    triggered_desc = {
                        trigger = {
                            var:tsagaan_sar_gift_item ?= flag:herd
                        }
                        desc = feast_tsagaan_sar_events.0003.minor.herd_2
                    }
                    triggered_desc = {
                        trigger = {
                            var:tsagaan_sar_gift_item ?= flag:gold
                        }
                        desc = feast_tsagaan_sar_events.0003.minor.gold
                    }
                    triggered_desc = {
                        trigger = {
                            var:tsagaan_sar_gift_item ?= flag:gold
                        }
                        desc = feast_tsagaan_sar_events.0003.minor.gold_2
                    }
                    triggered_desc = {
                        trigger = {
                            var:tsagaan_sar_gift_item ?= flag:prestige
                        }
                        desc = feast_tsagaan_sar_events.0003.minor.prestige
                    }
                    triggered_desc = {
                        trigger = {
                            var:tsagaan_sar_gift_item ?= flag:piety
                        }
                        desc = feast_tsagaan_sar_events.0003.minor.piety
                    }
                }
            }
        }
        switch = {
            trigger = var:tsagaan_sar_gift_item
            flag:herd = {
                involved_activity.var:host_var = {
                    add_to_gift_pool_effect = {
                        GIVER = root
                        TYPE = flag:herd
                        AMOUNT = miniscule
                    }

                }
                gift_received_notif = {
                    TYPE = herd
                    CHANCE_1 = 50
                    CHANCE_2 = 50
                }
            }
            flag:gold = {
                involved_activity.var:host_var = {
                    add_to_gift_pool_effect = {
                        GIVER = root
                        TYPE = flag:gold
                        AMOUNT = miniscule
                    }

                }
                gift_received_notif = {
                    TYPE = gold
                    CHANCE_1 = 50
                    CHANCE_2 = 50
                }
            }
            flag:prestige = {
                involved_activity.var:host_var = {
                    add_to_gift_pool_effect = {
                        GIVER = root
                        TYPE = flag:prestige
                        AMOUNT = miniscule
                    }

                }
                gift_received_notif = {
                    TYPE = prestige
                    CHANCE_1 = 50
                    CHANCE_2 = 50
                }
            }
            flag:piety = {
                involved_activity.var:host_var = {
                    add_to_gift_pool_effect = {
                        GIVER = root
                        TYPE = flag:piety
                        AMOUNT = miniscule
                    }

                }
                gift_received_notif = {
                    TYPE = piety
                    CHANCE_1 = 50
                    CHANCE_2 = 50
                }
            }
        }

        ai_chance = {
            base = 100
            modifier = {
                factor = 2
                more_likely_to_give_ok_gift_trigger = yes
            }
        }
    }

    # Nevermind actually
    option = {
        name = feast_tsagaan_sar_events.0002.choose
        custom_tooltip = feast_tsagaan_sar_events.0002.choose_tt
        trigger = {
            NOT = { has_character_flag = already_chose_gift }
        }
        add_character_flag = {
            flag = already_chose_gift
            days = 2
        }
        trigger_event = {
            id = feast_tsagaan_sar_events.0002
        }

        ai_chance = {
            base = 10
        }
    }

    option = {
        name = feast_tsagaan_sar_events.0002.none
        trigger = {
            NOT = { has_character_flag = cant_no_gift }
        }
        set_variable = {
            name = tsagaan_sar_gift
            value = flag:no_gift
        }
        if = {
            limit = {
                has_variable = tsagaan_sar_gift_item
            }
            remove_variable = tsagaan_sar_gift_item
        }
        ai_chance = {
            base = 1
        }
    }
}

# Gifting an artifact
feast_tsagaan_sar_events.0004 = {
    type = activity_event

    title = feast_tsagaan_sar_events.0002.t
    desc = feast_tsagaan_sar_events.0004.desc
    theme = feast_activity

    left_portrait = {
        character = root
        animation = thinking
    }

    artifact = {
        trigger = { exists = scope:artifact_1 }
        target = scope:artifact_1
        position = lower_left_portrait
    }
    artifact = {
        trigger = { exists = scope:artifact_2 }
        target = scope:artifact_2
        position = lower_center_portrait
    }
    artifact = {
        trigger = { exists = scope:artifact_3 }
        target = scope:artifact_3
        position = lower_right_portrait
    }

    immediate = {
        every_character_artifact = {
            limit = {
                NOR = {
                    has_variable = banner_house
                    has_variable = banner_dynasty
                    has_variable = 1025_treasure_map
                }
            }
            add_to_list = list_of_potential_artifacts_to_gift
        }
        ordered_in_list = { # Try and give away the worst one first
            list = list_of_potential_artifacts_to_gift
            max = 3
            check_range_bounds = no
            order_by = {
                value = 1
                add = {
                    value = {
                        add = artifact_durability
                        multiply = -1
                    }
                }
                add = {
                    value = {
                        add = artifact_age
                        multiply = -1
                    }
                }
                if = {
                    limit = {
                        is_equipped = no
                    }
                    add = 15
                }
                if = {
                    limit = {
                        rarity = common
                    }
                    add = 15
                }
                if = {
                    limit = {
                        rarity = masterwork
                    }
                    add = 10
                }
                if = {
                    limit = {
                        rarity = famed
                    }
                    add = 5
                }
                if = {
                    limit = {
                        NOT = { creator = root }
                    }
                    add = 10
                }
            }
            if = {
                limit = {
                    NOT = { exists = scope:artifact_1 }
                }
                save_scope_as = artifact_1
            }
            else_if = {
                limit = {
                    NOT = { exists = scope:artifact_2 }
                }
                save_scope_as = artifact_2
            }
            else_if = {
                limit = {
                    NOT = { exists = scope:artifact_3 }
                }
                save_scope_as = artifact_3
            }
        }
    }

    # Gift artifact 1
    option = {
        name = feast_tsagaan_sar_events.0004.a
        set_variable = {
            name = tsagaan_sar_gift_amount
            value = scope:artifact_1
        }
        involved_activity.var:host_var = {
            send_interface_message = {
                title = tsagaan_sar_gift_title
                right_icon = root
                type = event_generic_neutral
                scope:artifact_1 = {
                    set_owner = involved_activity.var:host_var
                }
            }
        }

        gift_received_notif = {
            TYPE = artifact
            CHANCE_1 = 50
            CHANCE_2 = 50
        }

        ai_chance = {
            base = 50
            modifier = {
                factor = 0.5
                scope:artifact_1 = { is_equipped = yes }
            }
        }
    }
    # Gift artifact 2
    option = {
        name = feast_tsagaan_sar_events.0004.b
        trigger = { exists = scope:artifact_2 }
        set_variable = {
            name = tsagaan_sar_gift_amount
            value = scope:artifact_2
        }

        involved_activity.var:host_var = {
            send_interface_message = {
                title = tsagaan_sar_gift_title
                right_icon = root
                type = event_generic_neutral
                scope:artifact_2 = {
                    set_owner = involved_activity.var:host_var
                }
            }
        }

        gift_received_notif = {
            TYPE = artifact
            CHANCE_1 = 50
            CHANCE_2 = 50
        }

        ai_chance = {
            base = 50
            modifier = {
                factor = 0.5
                scope:artifact_2 = { is_equipped = yes }
            }
        }
    }
    # Gift artifact 3
    option = {
        name = feast_tsagaan_sar_events.0004.c
        trigger = { exists = scope:artifact_3 }
        set_variable = {
            name = tsagaan_sar_gift_amount
            value = scope:artifact_3
        }

        involved_activity.var:host_var = {
            send_interface_message = {
                title = tsagaan_sar_gift_title
                right_icon = root
                type = event_generic_neutral
                scope:artifact_3 = {
                    set_owner = involved_activity.var:host_var
                }
            }
        }

        gift_received_notif = {
            TYPE = artifact
            CHANCE_1 = 50
            CHANCE_2 = 50
        }

        ai_chance = {
            base = 50
            modifier = {
                factor = 0.5
                scope:artifact_3 = { is_equipped = yes }
            }
        }
    }

    # Nevermind actually
    option = {
        name = feast_tsagaan_sar_events.0002.choose
        custom_tooltip = feast_tsagaan_sar_events.0002.choose_tt
        trigger = {
            NOT = { has_character_flag = already_chose_gift }
        }
        add_character_flag = {
            flag = already_chose_gift
            days = 2
        }
        trigger_event = {
            id = feast_tsagaan_sar_events.0002
        }

        ai_chance = {
            base = 10
        }
    }
}

scripted_trigger is_eligible_gift_collector = {
    NOR = {
        this = root
        this = involved_activity.var:host_var
    }
    is_adult = yes
    is_courtier_of = involved_activity.var:host_var
}

feast_tsagaan_sar_events.0010 = {
    type = activity_event

    title = feast_tsagaan_sar_events.0010.t
    desc = feast_tsagaan_sar_events.0010.desc
    theme = feast_activity

    left_portrait = {
        character = root
        animation = personality_honorable
    }

    right_portrait = {
        character = scope:gift_collector
        animation = personality_honorable
    }

    trigger = {
        NOT = { mpo_tsagaan_sar_guest_gifters = 0 }
    }

    immediate = {
        involved_activity = {
            random_attending_character = {
                limit =  { is_courtier_of = root }
                save_scope_as = gift_collector
            }
        }
    }

    # Bring out the gifts!
    option = {
        name = feast_tsagaan_sar_events.0010.a
        custom_tooltip = feast_tsagaan_sar_events.0010.a_tt
        remove_variable = tsagaan_sar_gift_pref
        remove_variable = feast_gold_total
        remove_variable = feast_prestige_total
        remove_variable = feast_piety_total
        remove_variable = feast_herd_total
        involved_activity = {
            every_attending_character = {
                limit = {
                    has_variable = tsagaan_sar_gift
                }
                remove_variable = tsagaan_sar_gift
                remove_variable = tsagaan_sar_gift_item
                remove_variable = tsagaan_sar_gift_amount
            }
        }
    }
}

# Your gift was unaccounted for
feast_tsagaan_sar_events.0100 = {
    type = activity_event

    title = feast_tsagaan_sar_events.0100.t
    desc = feast_tsagaan_sar_events.0100.desc
    theme = feast_activity

    left_portrait = {
        character = root
        animation = shock
    }

    right_portrait = {
        character = scope:gift_collector
        animation = storyteller
    }

    trigger = {
        exists = var:tsagaan_sar_gift_item
        NOR = {
            var:tsagaan_sar_gift_item ?= flag:hook
        }
        involved_activity = {
            has_activity_option = {
                category = special_type
                option = feast_type_tsagaan_sar
            }
            any_attending_character = {
                is_eligible_gift_collector = yes
            }
        }
    }

    cooldown = { years = 20 }

    immediate = {
        involved_activity = {
            var:host_var = { save_scope_as = host }
            random_attending_character = {
                limit =  { is_eligible_gift_collector = yes }
                save_scope_as = gift_collector
            }
        }
    }

    # Gift something else
    option = {
        name = feast_tsagaan_sar_events.0100.a
        stress_impact = {
            generous = medium_stress_impact_loss
            greedy = medium_stress_impact_gain
        }

        add_character_flag = {
            flag = already_chose_gift
            days = 2
        }
        trigger_event = {
            id = feast_tsagaan_sar_events.0002
        }

        ai_chance = {
            base = 75
            ai_value_modifier = {
                ai_greed = 0.5
            }
            opinion_modifier = {
                who = root
                opinion_target = involved_activity.var:host_var
                multiplier = 0.5
            }
        }
    }

    # Gift a portion of old gift
    option = {
        name = feast_tsagaan_sar_events.0100.b
        trigger = {
            OR = {
                var:tsagaan_sar_gift_item = flag:herd
                var:tsagaan_sar_gift_item = flag:gold
                var:tsagaan_sar_gift_item = flag:piety
                var:tsagaan_sar_gift_item = flag:prestige
            }
        }

        switch = {
            trigger = var:tsagaan_sar_gift_item
            flag:herd = {
                involved_activity.var:host_var = {
                    add_to_gift_pool_effect = {
                        GIVER = root
                        TYPE = flag:herd
                        AMOUNT = miniscule
                    }
                }
            }
            flag:gold = {
                involved_activity.var:host_var = {
                    add_to_gift_pool_effect = {
                        GIVER = root
                        TYPE = flag:gold
                        AMOUNT = miniscule
                    }
                }
            }
            flag:prestige = {
                involved_activity.var:host_var = {
                    add_to_gift_pool_effect = {
                        GIVER = root
                        TYPE = flag:prestige
                        AMOUNT = miniscule
                    }
                }
            }
            flag:piety = {
                involved_activity.var:host_var = {
                    add_to_gift_pool_effect = {
                        GIVER = root
                        TYPE = flag:piety
                        AMOUNT = miniscule
                    }
                }
            }
        }

        stress_impact = {
            generous = minor_stress_impact_loss
            greedy = minor_stress_impact_gain
        }

        ai_chance = {
            base = 100
            ai_value_modifier = {
                ai_greed = 0.1
            }
            opinion_modifier = {
                who = root
                opinion_target = involved_activity.var:host_var
                multiplier = 0.5
            }
        }
    }

    # Oh well!
    option = {
        name = {
            text = {
                first_valid = {
                    triggered_desc = {
                        trigger = {
                            has_trait = paranoid
                        }
                        desc = feast_tsagaan_sar_events.0100.c_paranoid
                    }
                    desc = feast_tsagaan_sar_events.0100.c
                }
            }
        }
        stress_impact = {
            base = minor_stress_impact_gain
            greedy = minor_stress_impact_loss
        }

        ai_chance = {
            base = 50
            ai_value_modifier = {
                ai_greed = 1
            }
            opinion_modifier = {
                who = root
                opinion_target = involved_activity.var:host_var
                multiplier = -1
            }
            modifier = {
                factor = 1.5
                has_trait = lazy
            }
        }
    }
}

scripted_trigger is_eligible_target_ts_0101 = {
    NOR = {
        this = root
        this = involved_activity.var:host_var
    }
    is_adult = yes
    domicile ?= { herd > miniscule_herd_value }
}

# Someone has a cool horse
feast_tsagaan_sar_events.0101 = {
    type = activity_event

    title = feast_tsagaan_sar_events.0101.t
    desc = feast_tsagaan_sar_events.0101.desc
    theme = feast_activity

    left_portrait = {
        character = root
        animation = admiration
    }

    right_portrait = {
        character = scope:horse_haver
        animation = jockey_idle
        camera = camera_event_horse_right
    }

    trigger = {
        in_tsaagan_sar_trigger = yes
        government_has_flag = government_is_nomadic
        is_landed = yes
        involved_activity = {
            any_attending_character = {
                is_eligible_target_ts_0101 = yes
            }
        }
    }

    cooldown = { years = 10 }

    immediate = {
        involved_activity = {
            var:host_var = { save_scope_as = host }
            random_attending_character = {
                limit = { is_eligible_target_ts_0101 = yes }
                save_scope_as = horse_haver
            }
        }
    }

    # Ride horse
    option = {
        name = feast_tsagaan_sar_events.0101.a

        add_stress = medium_stress_loss

        ai_chance = {
            base = 75
            modifier = {
                factor = 2
                has_activity_intent = reduce_stress_intent
            }
        }
    }

    # Can i buy please
    option = {
        name = feast_tsagaan_sar_events.0101.b
        trigger = {
            short_term_gold >= medium_gold_value
        }
        show_as_unavailable = { always = yes }
        duel = {
            desc = feast_tsagaan_sar_events.0101.b.duel
            skill = stewardship
            target = scope:horse_haver
            60 = {
                desc = feast_tsagaan_sar_events.0101.b.success
                compare_modifier = {
                    value = scope:duel_value
                    multiplier = 3.5
                }
                modifier = {
                    add = 15
                    scope:horse_haver = { has_trait = greedy }
                }
                send_interface_toast = {
                    title = feast_tsagaan_sar_events.0101.b.success
                    type = event_toast_effect_good
                    left_icon = root
                    right_icon = scope:horse_haver
                    pay_short_term_gold = { target = scope:horse_haver gold = medium_gold_value }
                    scope:horse_haver = { pay_herd = { target = root value = domicile.miniscule_herd_value } }
                    add_character_modifier = {
                        modifier = mpo_horse_ride_modifier
                        years = 3
                    }
                    stress_impact = {
                        greedy = minor_stress_impact_gain
                        generous = minor_stress_impact_loss
                        improvident = minor_stress_impact_loss
                    }
                }
            }
            40 = {
                desc = feast_tsagaan_sar_events.0101.b.failure
                compare_modifier = {
                    value = scope:duel_value
                    multiplier = -3.5
                }
                send_interface_toast = {
                    title = feast_tsagaan_sar_events.0101.b.failure
                    type = event_toast_effect_neutral
                    left_icon = root
                    right_icon = scope:horse_haver
                }
            }
        }
        ai_chance = {
            base = 100
            ai_value_modifier = {
                ai_greed = -1
                ai_energy = 1
            }
        }
    }

    # Steal horse
    option = {
        name = feast_tsagaan_sar_events.0101.c
        duel = {
            desc = feast_tsagaan_sar_events.0101.c.duel
            skill = prowess
            target = scope:horse_haver
            50 = {
                desc = feast_tsagaan_sar_events.0101.c.success
                compare_modifier = {
                    value = scope:duel_value
                    multiplier = 3.5
                }
                send_interface_toast = {
                    title = feast_tsagaan_sar_events.0101.c.success
                    type = event_toast_effect_good
                    left_icon = root
                    right_icon = scope:horse_haver
                    scope:horse_haver = {
                        progress_towards_rival_effect = {
                            REASON = rival_stole_my_horse
                            CHARACTER = root
                            OPINION = -25
                        }
                        pay_herd = { target = root value = domicile.miniscule_herd_value }
                    }
                    add_character_modifier = {
                        modifier = mpo_horse_ride_modifier
                        years = 3
                    }

                }
                if = {
                    limit = {
                        has_activity_intent = banquet_mischief_intent
                    }
                    complete_activity_intent = yes
                }
            }
            50 = {
                desc = feast_tsagaan_sar_events.0101.c.failure
                compare_modifier = {
                    value = scope:duel_value
                    multiplier = -3.5
                }
                send_interface_toast = {
                    title = feast_tsagaan_sar_events.0101.c.failure
                    type = event_toast_effect_bad
                    left_icon = root
                    right_icon = scope:horse_haver
                    add_prestige = miniscule_prestige_loss
                    random = {
                        chance = 10
                        increase_wounds_effect = { REASON = horse_riding_accident }
                    }
                }
            }
        }
        if = {
            limit = {
                NOT = { has_trait = greedy }
            }
            random = {
                chance = 5
                add_trait = greedy
            }
        }
        stress_impact = {
            base = minor_stress_impact_loss
            callous = medium_stress_impact_loss
            sadistic = major_stress_impact_loss
            greedy = major_stress_impact_loss
            content = minor_stress_impact_gain
            just = medium_stress_impact_gain
            compassionate = medium_stress_impact_gain
            arbitrary = minor_stress_impact_loss
        }
        ai_chance = {
            base = 100
            ai_value_modifier = {
                ai_greed = -0.5
                ai_compassion = -1
            }
            modifier = {
                factor = 1.5
                has_activity_intent = banquet_mischief_intent
            }
            modifier = {
                factor = 0
                OR = {
                    has_trait = compassionate
                    has_trait = content
                }
            }
        }
    }
}

scripted_trigger is_eligible_target_ts_0200 = {
    is_adult = yes
    gold >= major_gold_value
}

# You're invited to gamble
feast_tsagaan_sar_events.0200 = {
    type = activity_event

    title = feast_tsagaan_sar_events.0200.t
    desc = feast_tsagaan_sar_events.0200.desc
    theme = feast_activity

    left_portrait = {
        character = root
        triggered_animation = {
            trigger = { has_trait = content }
            animation = eyeroll
        }
        animation = throne_room_conversation_3
    }

    right_portrait = {
        character = scope:gambler
        animation = betting
    }

    trigger = {
        in_tsaagan_sar_trigger = yes
        involved_activity = {
            any_attending_character = {
                is_eligible_target_ts_0200 = yes
                NOT = { this = root }
            }
        }
        is_eligible_target_ts_0200 = yes
    }

    cooldown = { years = 10 }

    immediate = {
        involved_activity = {
            random_attending_character = {
                limit = {
                    is_eligible_target_ts_0200 = yes
                    NOT = { this = root }
                }
                weight = {
                    base = 5
                    modifier = {
                        add = 20
                        has_trait = improvident
                    }
                    modifier = {
                        add = 10
                        has_trait = greedy
                    }
                    modifier = {
                        add = 5
                        has_trait = gregarious
                    }
                    modifier = {
                        add = 5
                        has_trait = brave
                    }
                    modifier = {
                        add = 15
                        has_activity_intent = befriend_attendee_intent
                        intent_target ?= root
                    }
                    modifier = {
                        add = 15
                        root = {
                            has_activity_intent = befriend_attendee_intent
                            intent_target ?= prev
                        }
                    }
                }
                save_scope_as = gambler
            }
        }
    }

    # Put a lot of gold down
    option = {
        name = feast_tsagaan_sar_events.0200.a

        custom_tooltip = feast_tsagaan_sar_events.0200.a_tt

        random_list = {
            50 = {
                show_chance = no
                desc = feast_tsagaan_sar_events.0200_win
                send_interface_toast = {
                    title = feast_tsagaan_sar_events.0200_win
                    type = event_toast_effect_good
                    left_icon = root
                    right_icon = scope:gambler
                    scope:gambler = { pay_short_term_gold = { target = root gold = medium_gold_value } }
                }
            }
            50 = {
                show_chance = no
                desc = feast_tsagaan_sar_events.0200_lose
                send_interface_toast = {
                    title = feast_tsagaan_sar_events.0200_lose
                    type = event_toast_effect_bad
                    left_icon = root
                    right_icon = scope:gambler
                    pay_short_term_gold = { target = scope:gambler gold = medium_gold_value }
                }
            }
        }

        progress_towards_friend_effect = {
            REASON = friend_played_party_games
            CHARACTER = scope:gambler
            OPINION = 20
        }

        if = {
            limit = {
                has_activity_intent = befriend_attendee_intent
                intent_target ?= scope:gambler
            }
            complete_activity_intent = yes
        }

        stress_impact = {
            temperate = medium_stress_impact_gain
            improvident = medium_stress_impact_loss
        }

        ai_chance = {
            base = 25
            ai_value_modifier = {
                ai_greed = 0.5
                ai_energy = 0.5
            }
        }
    }

    # Medium gold
    option = {
        name = feast_tsagaan_sar_events.0200.b

        custom_tooltip = feast_tsagaan_sar_events.0200.b_tt

        random_list = {
            50 = {
                show_chance = no
                desc = feast_tsagaan_sar_events.0200_win
                send_interface_toast = {
                    title = feast_tsagaan_sar_events.0200_win
                    type = event_toast_effect_good
                    left_icon = root
                    right_icon = scope:gambler
                    scope:gambler = { pay_short_term_gold = { target = root gold = minor_gold_value } }
                }
            }
            50 = {
                show_chance = no
                desc = feast_tsagaan_sar_events.0200_lose
                send_interface_toast = {
                    title = feast_tsagaan_sar_events.0200_lose
                    type = event_toast_effect_bad
                    left_icon = root
                    right_icon = scope:gambler
                    pay_short_term_gold = { target = scope:gambler gold = minor_gold_value }
                }
            }
        }

        progress_towards_friend_effect = {
            REASON = friend_played_party_games
            CHARACTER = scope:gambler
            OPINION = 15
        }

        if = {
            limit = {
                has_activity_intent = befriend_attendee_intent
                intent_target ?= scope:gambler
            }
            complete_activity_intent = yes
        }

        stress_impact = {
            temperate = minor_stress_impact_gain
            improvident = minor_stress_impact_loss
        }

        ai_chance = {
            base = 50
            ai_value_modifier = {
                ai_greed = 0.5
                ai_energy = 0.5
            }
        }
    }

    # A little bit of gold
    option = {
        name = feast_tsagaan_sar_events.0200.c

        custom_tooltip = feast_tsagaan_sar_events.0200.c_tt

        random_list = {
            50 = {
                show_chance = no
                desc = feast_tsagaan_sar_events.0200_win
                send_interface_toast = {
                    title = feast_tsagaan_sar_events.0200_win
                    type = event_toast_effect_good
                    left_icon = root
                    right_icon = scope:gambler
                    scope:gambler = { pay_short_term_gold = { target = root gold = tiny_gold_value } }
                }
            }
            50 = {
                show_chance = no
                desc = feast_tsagaan_sar_events.0200_lose
                send_interface_toast = {
                    title = feast_tsagaan_sar_events.0200_lose
                    type = event_toast_effect_bad
                    left_icon = root
                    right_icon = scope:gambler
                    pay_short_term_gold = { target = scope:gambler gold = tiny_gold_value }
                }
            }
        }

        progress_towards_friend_effect = {
            REASON = friend_played_party_games
            CHARACTER = scope:gambler
            OPINION = 10
        }

        if = {
            limit = {
                has_activity_intent = befriend_attendee_intent
                intent_target ?= scope:gambler
            }
            complete_activity_intent = yes
        }

        stress_impact = {
            temperate = miniscule_stress_impact_gain
            improvident = miniscule_stress_impact_loss
        }

        ai_chance = {
            base = 75
            ai_value_modifier = {
                ai_greed = 0.5
                ai_energy = 0.5
            }
        }
    }

    # Wtf no
    option = {
        name = {
            text = {
                first_valid = {
                    triggered_desc = {
                        trigger = {
                            OR = {
                                has_trait = content
                                has_trait = temperate
                            }
                        }
                        desc = feast_tsagaan_sar_events.0200.d_content
                    }
                    desc = feast_tsagaan_sar_events.0200.d
                }
            }
        }

        scope:gambler = {
            add_opinion = {
                target = root
                modifier = disappointed_opinion
                opinion = -10
            }
        }

        ai_chance = {
            base = 100
            modifier = {
                factor = 1.5
                OR = {
                    has_trait = content
                    has_trait = temperate
                }
            }
        }
    }
}

scripted_trigger is_eligible_target_ts_0201 = {
    is_adult = yes
    OR = {
        government_has_flag = government_is_herder
        AND = {
           domicile ?= { herd >= eighty_percent_herd_value }
           government_has_flag = government_is_nomadic
        }
    }
    NOT = { this = root }
}

# Someone gives you tips on how to herd
feast_tsagaan_sar_events.0210 = {
    type = activity_event
    title = feast_tsagaan_sar_events.0210.t
    desc = feast_tsagaan_sar_events.0210.desc
    theme = feast_activity

    left_portrait = {
        character = root
        animation = personality_content
    }

    right_portrait = {
        character = scope:herder
        animation = storyteller
    }

    trigger = {
        in_tsaagan_sar_trigger = yes
        involved_activity = {
            any_attending_character = {
                is_eligible_target_ts_0201 = yes
            }
        }
    }

    cooldown = { years = 15 }

    immediate = {
        involved_activity = {
            random_attending_character = {
                limit = { is_eligible_target_ts_0201 = yes }
                save_scope_as = herder
            }
        }
    }

    # Get more
    option = {
        name = feast_tsagaan_sar_events.0210.a
        custom_tooltip = feast_tsagaan_sar_events.0210.tt
        trigger = { prestige >= minor_prestige_value }
        show_as_unavailable = { always = yes }

        add_prestige = minor_prestige_loss

        scope:herder = {
            add_prestige = minor_prestige_gain
        }

        add_character_modifier = {
            modifier = mpo_big_herd_modifier
            years = 5
        }

        ai_chance = {
            base = 50
        }
    }

    # Get better
    option = {
        name = feast_tsagaan_sar_events.0210.b
        custom_tooltip = feast_tsagaan_sar_events.0210.tt
        trigger = { prestige >= minor_prestige_value }
        show_as_unavailable = { always = yes }

        add_prestige = minor_prestige_loss

        scope:herder = {
            add_prestige = minor_prestige_gain
        }

        add_character_modifier = {
            modifier = mpo_efficent_herd_modifier
            years = 5
        }

        ai_chance = {
            base = 50
        }
    }

    # I'll keep doing what I was doing
    option = {
        name = feast_tsagaan_sar_events.0210.c

        stress_impact = {
            arrogant = medium_stress_impact_loss
        }

        ai_chance = {
            base = 10
            modifier = {
                factor = 10
                has_trait = arrogant
            }
        }
    }
}

scripted_trigger is_eligible_target_ts_0202 = {
    OR = {
        has_relation_rival = root
        has_relation_nemesis = root
    }
    NOT = { has_trait = vengeful }
    is_ai = yes
}

# You decide to settle a rivalry
feast_tsagaan_sar_events.0220 = {
    type = activity_event

    title = feast_tsagaan_sar_events.0220.t
    desc = feast_tsagaan_sar_events.0220.desc
    theme = feast_activity

    left_portrait = {
        character = root
        triggered_animation = {
            trigger = {
                has_trait = forgiving
            }
            animation = personality_forgiving
        }
        animation = worry
    }

    right_portrait = {
        character = scope:old_rival
        animation = personality_irrational
    }

    trigger = {
        in_tsaagan_sar_trigger = yes
        involved_activity = {
            any_attending_character = {
                is_eligible_target_ts_0202 = yes
            }
        }
    }

    cooldown = { years = 5 }

    immediate = {
        involved_activity = {
            random_attending_character = {
                limit = { is_eligible_target_ts_0202 = yes }
                save_scope_as = old_rival
            }
        }
    }

    # Decide to settle your differences
    option = {
        name = feast_tsagaan_sar_events.0220.a

        remove_relation_rival = scope:old_rival

        stress_impact = {
            forgiving = medium_stress_impact_loss
            vengeful = medium_stress_impact_gain
        }

        ai_chance = {
            base = 50
            ai_value_modifier = {
                ai_vengefulness = -1
            }
        }
    }

    # Become lovers
    option = {
        name = feast_tsagaan_sar_events.0220.b
        trigger = {
            OR = {
                has_trait = lustful
                has_trait = rakish
                has_relation_potential_lover = scope:old_rival
            }
            can_set_relation_lover_trigger = { CHARACTER = scope:old_rival }
        }
        flavor = feast_tsagaan_sar_events.0220.b_flavor

        remove_relation_rival = scope:old_rival

        random_list = {
            50 = {
                modifier = {
                    add = 10
                    has_relation_potential_lover = scope:old_rival
                }
                modifier = {
                    add = 15
                    scope:old_rival = {
                        OR = {
                            has_trait = lustful
                            has_trait = rakish
                        }
                    }
                }
                show_chance = no
                desc = feast_tsagaan_sar_events.0220_win
                send_interface_toast = {
                    title = feast_tsagaan_sar_events.0220_win
                    type = event_toast_effect_good
                    left_icon = root
                    right_icon = scope:old_rival
                    had_sex_with_effect = {
                        CHARACTER = scope:old_rival
                        PREGNANCY_CHANCE = pregnancy_chance
                    }
                    if = {
                        limit = {
                            has_relation_potential_lover = scope:old_rival
                        }
                        set_relation_lover = scope:old_rival
                    }
                    else = {
                        set_relation_potential_lover = scope:old_rival
                    }
                }
            }
            50 = {
                modifier = {
                    add = 10
                    scope:old_rival = { has_trait = chaste }
                }
                show_chance = no
                desc = feast_tsagaan_sar_events.0220_lose
                send_interface_toast = {
                    title = feast_tsagaan_sar_events.0220_lose
                    type = event_toast_effect_bad
                    left_icon = root
                    right_icon = scope:old_rival
                    scope:old_rival = {
                        add_opinion = {
                            target = root
                            modifier = disgusted_opinion
                            opinion = -10
                        }
                    }
                }
            }
        }

        stress_impact = {
            lustful = medium_stress_impact_loss
            chaste = medium_stress_impact_gain
            forgiving = medium_stress_impact_loss
            vengeful = medium_stress_impact_gain
        }


        ai_chance = {
            base = 50
        }
    }

    # Become friends
    option = {
        name = feast_tsagaan_sar_events.0220.c
        trigger = {
            OR = {
                has_trait = gregarious
                has_trait = compassionate
                has_trait = forgiving
            }
        }

        remove_relation_rival = scope:old_rival
        scope:old_rival = {
            add_opinion = {
                target = root
                modifier = grateful_opinion
                opinion = 10
            }
        }

        if = {
            limit = {
                has_relation_potential_friend = scope:old_rival
            }
            set_relation_friend = {
                target = scope:old_rival
                reason = friend_feast_rivalry
            }
        }
        else = {
            set_relation_potential_friend = scope:old_rival
        }

        stress_impact = {
            forgiving = medium_stress_impact_loss
            vengeful = medium_stress_impact_gain
        }

        ai_chance = {
            base = 50
            ai_value_modifier = {
                ai_compassion = 1
            }
        }
    }

    # Nope
    option = {
        name = {
            text = {
                first_valid = {
                    triggered_desc = {
                        trigger = {
                            has_trait = vengeful
                        }
                        desc = feast_tsagaan_sar_events.0220.d_vengeful
                    }
                    desc = feast_tsagaan_sar_events.0220.d
                }
            }
        }

        scope:old_rival = {
            add_opinion = {
                target = root
                modifier = disappointed_opinion
                opinion = -15
            }
        }

        stress_impact = {
            forgiving = minor_stress_impact_gain
            vengeful = minor_stress_impact_loss
        }

        ai_chance = {
            base = 50
        }
    }
}

# Someone is throat singing
feast_tsagaan_sar_events.0230 = {
    type = activity_event

    title = feast_tsagaan_sar_events.0230.t
    desc = {
        desc = feast_tsagaan_sar_events.0230.desc_intro
        first_valid = {
            triggered_desc = {
                trigger = {
                    scope:throat_singer = { var:throatsinging_style ?= flag:sygyt }
                }
                desc = feast_tsagaan_sar_events.0230.desc_sygyt
            }
            triggered_desc = {
                trigger = {
                    scope:throat_singer = { var:throatsinging_style ?= flag:hoomei }
                }
                desc = feast_tsagaan_sar_events.0230.desc_hoomei
            }
            triggered_desc = {
                trigger = {
                    scope:throat_singer = { var:throatsinging_style ?= flag:kargyraa }
                }
                desc = feast_tsagaan_sar_events.0230.desc_kargyraa
            }
        }
        desc = feast_tsagaan_sar_events.0230.desc_outro
    }
    theme = feast_activity

    left_portrait = {
        character = root
        animation = admiration
    }

    center_portrait = {
        character = scope:observer
        animation = happiness
    }

    right_portrait = {
        character = scope:throat_singer
        animation = storyteller
    }

    trigger = {
        always = no
        #in_tsaagan_sar_trigger = yes
        #involved_activity = {
        #    any_attending_character = {
        #        NOT = { this = root }
        #        culture = {
        #            OR = {
        #                has_cultural_pillar = heritage_mongolic
        #                has_cultural_pillar = heritage_turkic
        #            }
        #        }
        #        count >= 3
        #    }
        #}
    }

    cooldown = { years = 5 }

    immediate = {
        involved_activity = {
            random_attending_character = {
                limit = {
                    NOT = { this = root }
                    #culture = {
                    #    OR = {
                    #        has_cultural_pillar = heritage_mongolic
                    #        has_cultural_pillar = heritage_turkic
                    #    }
                    #}
                    is_ai = yes
                }
                weight = {
                    base = 5
                    modifier = {
                        add = 10
                        has_trait = poet
                    }
                    modifier = {
                        add = 10
                        has_trait = journaller
                    }
                    modifier = {
                        add = 20
                        has_trait_xp = {
                            trait = tourney_participant
                            track = wit
                            value >= 1
                        }
                    }
                    modifier = {
                        add = 100
                        has_variable = throatsinging_style
                    }
                    modifier = {
                        add = -5
                        is_female = yes
                    }
                }
                if = {
                    limit = {
                        has_variable = throatsinging_style
                    }
                    change_variable = {
                        name = throatsinging_practice
                        add = 1
                    }
                }
                else = {
                    set_throatsinging_style_effect = yes
                }
                save_scope_as = throat_singer
            }
            random_attending_character = {
                limit = {
                    NOR = {
                        this = root
                        this = scope:throat_singer
                    }
                    #culture = {
                    #    OR = {
                    #        has_cultural_pillar = heritage_mongolic
                    #        has_cultural_pillar = heritage_turkic
                    #    }
                    #}
                }
                save_scope_as = observer
            }
        }
    }


    # Sounds good
    option = {
        name = feast_tsagaan_sar_events.0230.a

        pay_short_term_gold = { target = scope:throat_singer gold = tiny_gold_value }

        scope:throat_singer = {
            add_opinion = {
                target = root
                modifier = grateful_opinion
                opinion = 15
            }
        }

        stress_impact = {
            generous = minor_stress_impact_gain
            greedy = minor_stress_impact_gain
        }

        ai_chance = {
            base = 50
            ai_value_modifier = {
                ai_greed = -1
            }
        }
    }

    # Boo!
    option = {
        name = feast_tsagaan_sar_events.0230.b
        custom_tooltip = feast_tsagaan_sar_events.0230.b_tt

        scope:throat_singer = {
            progress_towards_rival_effect = {
                REASON = rival_throat_singing
                CHARACTER = root
                OPINION = -25
            }
        }

        scope:observer = {
            add_opinion = {
                target = root
                modifier = disappointed_opinion
                opinion = -5
            }
        }

        stress_impact = {
            arrogant = medium_stress_impact_loss
            callous = minor_stress_impact_loss
            sadistic = minor_stress_impact_loss
            compassionate = minor_stress_impact_gain
        }

        if = {
            limit = {
                has_activity_intent = banquet_mischief_intent
            }
            complete_activity_intent = yes
        }

        ai_chance = {
            base = 50
            ai_value_modifier = {
                ai_compassion = -1
            }
            modifier = {
                factor = 1.5
                has_trait = arrogant
            }
            modifier = {
                factor = 1.5
                has_activity_intent = banquet_mischief_intent
            }
        }
    }

    # Join in
    option = {
        name = feast_tsagaan_sar_events.0230.c
        trigger = { has_variable = throatsinging_style }

        if = {
            limit = {
                has_relation_potential_friend = scope:throat_singer
            }
            set_relation_friend = {
                target = scope:throat_singer
                reason = friend_throat_singing
            }
        }
        else = {
            set_relation_potential_friend = scope:throat_singer
        }

        if = {
            limit = {
                has_activity_intent = befriend_attendee_intent
                intent_target ?= scope:throat_singer
            }
            complete_activity_intent = yes
        }

        change_variable = {
            name = throatsinging_practice
            add = 1
        }

        add_character_modifier = {
            modifier = mpo_throatsinging_duet_modifier
            years = 3
        }

        ai_chance = {
            base = 50
            modifier = {
                factor = 1.5
                has_trait = gregarious
            }
            modifier = {
                factor = 2
                has_activity_intent = befriend_attendee_intent
                intent_target ?= scope:throat_singer
            }
        }
    }

    # I should learn this
    option = {
        name = feast_tsagaan_sar_events.0230.d
        trigger = { NOT = { has_variable = throatsinging_style } }

        duel = {
            skill = learning
            value = low_skill_rating
            50 = {
                desc = feast_tsagaan_sar_events.0230.d.duel
                modifier = {
                    add = 10
                    has_trait = poet
                }
                modifier = {
                    add = 10
                    has_trait = tourney_participant
                }
                modifier = {
                    add = 10
                    has_trait = ambitious
                }
                compare_modifier = {
                    value = scope:duel_value
                    multiplier = 3.5
                }
                send_interface_toast = {
                    title = feast_tsagaan_sar_events.0230.d.success
                    type = event_toast_effect_good
                    left_icon = root
                    custom_tooltip = feast_tsagaan_sar_events.0230.d_tt
                    add_prestige = miniscule_prestige_gain
                    add_character_modifier = {
                        modifier = mpo_throatsinging_great_practice_modifier
                        years = 3
                    }
                }
                if = {
                    limit = {
                        NOT = { has_trait = tourney_participant }
                    }
                    add_trait = tourney_participant
                }
                add_trait_xp = {
                    trait = tourney_participant
                    track = wit
                    value = 5
                }
                set_variable = {
                    name = throatsinging_style
                    value = scope:throat_singer.var:throatsinging_style
                }
                set_variable = {
                    name = throatsinging_practice
                    value = 1
                }
            }
            50 = {
                desc = feast_tsagaan_sar_events.0230.d.failure
                compare_modifier = {
                    value = scope:duel_value
                    multiplier = -3.5
                }
                send_interface_toast = {
                    title = feast_tsagaan_sar_events.0230.d.failure
                    type = event_toast_effect_neutral
                    left_icon = root
                    set_variable = {
                        name = throatsinging_practice
                        value = 1
                    }
                    add_character_modifier = {
                        modifier = mpo_throatsinging_practice_modifier
                        years = 3
                    }
                }
            }
        }

        ai_chance = {
            base = 50
            modifier = {
                factor = 1.5
                has_trait = ambitious
            }
        }
    }
}

scripted_effect throatsinging_0240_effect = {
    random_list = {
        desc = feast_tsagaan_sar_events.0240.duel_new
        40 = {
            show_chance = no
            desc = feast_tsagaan_sar_events.0240.success
            modifier = {
                var:throatsinging_practice = 4
                add = 30
            }
            modifier = {
                var:throatsinging_practice = 3
                add = 20
            }
            modifier = {
                var:throatsinging_practice = 2
                add = 10
            }
            send_interface_toast = {
                title = feast_tsagaan_sar_events.0240.success
                type = event_toast_effect_good
                left_icon = root
                right_icon = scope:audience
                add_character_modifier = {
                    modifier = mpo_throatsinging_great_performance_modifier
                    years = 3
                }
                switch = {
                    trigger = flag:$STYLE$
                    flag:sygyt = {
                        custom_tooltip = feast_tsagaan_sar_events.0240.success_sygyt_tt
                    }
                    flag:hoomei = {
                        custom_tooltip = feast_tsagaan_sar_events.0240.success_hoomei_tt
                    }
                    flag:kargyraa = {
                        custom_tooltip = feast_tsagaan_sar_events.0240.success_kargyraa_tt
                    }
                }
                scope:audience = {
                    add_opinion = {
                        target = root
                        modifier = impressed_opinion
                        opinion = 15
                    }
                }
                set_variable = {
                    name = throatsinging_practice
                    value = 1
                }
            }
        }
        60 = {
            show_chance = no
            desc = feast_tsagaan_sar_events.0240.ok
            send_interface_toast = {
                title = feast_tsagaan_sar_events.0240.ok
                type = event_toast_effect_neutral
                left_icon = root
                right_icon = scope:audience
                add_character_modifier = {
                    modifier = mpo_throatsinging_good_performance_modifier
                    years = 3
                }
                scope:audience = {
                    add_opinion = {
                        target = root
                        modifier = impressed_opinion
                        opinion = 10
                    }
                }
                change_variable = {
                    name = throatsinging_practice
                    add = 1
                }
            }
        }
    }

}

# You attempt throat singing
feast_tsagaan_sar_events.0240 = {
    type = activity_event

    title = feast_tsagaan_sar_events.0240.t
    desc = feast_tsagaan_sar_events.0240.desc

    theme = feast_activity

    left_portrait = {
        character = root
        triggered_animation = {
            trigger = {
                OR = {
                    has_trait = shy
                    has_trait = craven
                }
            }
            animation = stress
        }
        animation = storyteller
    }
    right_portrait = {
        character = scope:audience
        animation = admiration
    }

    trigger = {
        in_tsaagan_sar_trigger = yes
        has_variable = throatsinging_style
        involved_activity = {
            any_attending_character = {
                NOT = { this = root }
            }
        }
    }

    cooldown = { years = 5 }

    immediate = {
        involved_activity = {
            random_attending_character = {
                limit = {
                    NOT = { this = root }
                }
                weight = {
                    base = 5
                    modifier = {
                        add = 20
                        has_any_good_relationship_with_character_trigger = { CHARACTER = root }
                    }
                }
                save_scope_as = audience
            }
        }
    }


    # Perform normal style
    option = {
        name = feast_tsagaan_sar_events.0240.a
        random_list = {
            desc = feast_tsagaan_sar_events.0240.duel
            50 = {
                show_chance = no
                desc = feast_tsagaan_sar_events.0240.success
                modifier = {
                    var:throatsinging_practice = 4
                    add = 30
                }
                modifier = {
                    var:throatsinging_practice = 3
                    add = 20
                }
                modifier = {
                    var:throatsinging_practice = 2
                    add = 10
                }
                send_interface_toast = {
                    title = feast_tsagaan_sar_events.0240.success
                    type = event_toast_effect_good
                    left_icon = root
                    right_icon = scope:audience
                    add_character_modifier = {
                        modifier = mpo_throatsinging_great_performance_modifier
                        years = 3
                    }
                    if = {
                        limit = {
                            NOT = { has_trait = tourney_participant }
                        }
                        add_trait = tourney_participant
                    }
                    add_trait_xp = {
                        trait = tourney_participant
                        track = wit
                        value = 5
                    }
                    scope:audience = {
                        add_opinion = {
                            target = root
                            modifier = impressed_opinion
                            opinion = 15
                        }
                    }
                }
            }
            50 = {
                show_chance = no
                desc = feast_tsagaan_sar_events.0240.ok
                send_interface_toast = {
                    title = feast_tsagaan_sar_events.0240.ok
                    type = event_toast_effect_neutral
                    left_icon = root
                    right_icon = scope:audience
                    add_character_modifier = {
                        modifier = mpo_throatsinging_good_performance_modifier
                        years = 3
                    }
                    scope:audience = {
                        add_opinion = {
                            target = root
                            modifier = impressed_opinion
                            opinion = 10
                        }
                    }
                }
            }
        }
        change_variable = {
            name = throatsinging_practice
            add = 1
        }

        if = {
            limit = {
                has_relation_potential_friend = scope:audience
            }
            set_relation_friend = {
                target = scope:audience
                reason = friend_throat_singing
            }
        }
        else = {
            set_relation_potential_friend = scope:audience
        }

        if = {
            limit = {
                has_activity_intent = befriend_attendee_intent
                intent_target ?= scope:audience
            }
            complete_activity_intent = yes
        }

        stress_impact = {
            shy = minor_stress_impact_gain
            craven = minor_stress_impact_gain
            gregarious = minor_stress_impact_loss
        }

        ai_chance = {
            base = 100
            modifier = {
                factor = 0.5
                has_trait = shy
            }
        }
    }

    # Try out Sygyt
    option = {
        name = feast_tsagaan_sar_events.0240.sygyt
        trigger = { NOT = { var:throatsinging_style ?= flag:sygyt } }

        throatsinging_0240_effect = { STYLE = sygyt }

        ai_chance = {
            base = 100
            modifier = {
                factor = 0.25
                has_trait = ambitious
            }
            modifier = {
                factor = 0.25
                has_trait = shy
            }
        }
    }

    # Try out Hoomei
    option = {
        name = feast_tsagaan_sar_events.0240.hoomei
        trigger = { NOT = { var:throatsinging_style ?= flag:hoomei } }

        throatsinging_0240_effect = { STYLE = hoomei }

        ai_chance = {
            base = 100
            modifier = {
                factor = 0.25
                has_trait = ambitious
            }
            modifier = {
                factor = 0.25
                has_trait = shy
            }
        }
    }

    # Try out Kargyraa
    option = {
        name = feast_tsagaan_sar_events.0240.kargyraa
        trigger = { NOT = { var:throatsinging_style ?= flag:kargyraa } }

        throatsinging_0240_effect = { STYLE = kargyraa }

        ai_chance = {
            base = 100
            modifier = {
                factor = 0.25
                has_trait = ambitious
            }
            modifier = {
                factor = 0.25
                has_trait = shy
            }
        }
    }

    # No
    option = {
        name = {
            text = {
                first_valid = {
                    triggered_desc = {
                        trigger = {
                            OR = {
                                has_trait = shy
                                has_trait = craven
                            }
                        }
                        desc = feast_tsagaan_sar_events.0240.d_shy
                    }
                    desc = feast_tsagaan_sar_events.0240.d
                }
            }
        }

        scope:audience = {
            add_opinion = {
                target = root
                modifier = disappointed_opinion
                opinion = -10
            }
        }

        stress_impact = {
            shy = minor_stress_impact_loss
            craven = minor_stress_impact_loss
        }

        ai_chance = {
            base = 50
        }
    }
}

scripted_trigger is_eligible_target_ts_0250 = {
    NOR = {
        this = root
        has_character_flag = knocked_horse_race
    }
    OR = {
        prowess >= decent_skill_rating
        martial >= decent_skill_rating
    }
    is_adult = yes
    is_incapable = no

}

feast_tsagaan_sar_events.0250 = {
    type = activity_event

    title = feast_tsagaan_sar_events.0250.t
    desc = feast_tsagaan_sar_events.0250.desc

    theme = feast_activity

    left_portrait = {
        character = root
        animation = personality_honorable
    }

    center_portrait = {
        character = scope:horse_rider_1
        animation = jockey_idle
        camera = camera_event_horse_right
    }

    right_portrait = {
        character = scope:horse_rider_2
        animation = jockey_idle
        camera = camera_event_horse_right
    }

    trigger = {
        in_tsaagan_sar_trigger = yes
        involved_activity = {
            any_attending_character = {
                is_eligible_target_ts_0250 = yes
                count >= 2
            }
        }
    }

    cooldown = { years = 10 }

    immediate = {
        involved_activity = {
            ordered_attending_character = {
                limit = { is_eligible_target_ts_0250 = yes }
                order_by = {
                    value = martial
                    add = prowess
                    add = intrigue
                    if = {
                        limit = {
                            has_trait = tourney_participant
                        }
                        add = 5
                    }
                    if = {
                        limit = {
                            has_trait = lifestyle_hunter
                        }
                        add = 10
                    }
                    if = {
                        limit = {
                            has_trait_xp = {
                                trait = tourney_participant
                                track = horse
                                value >= 1
                            }
                        }
                        add = 10
                    }
                }
                max = 2
                check_range_bounds = no

                if = {
                    limit = {
                        NOT = { exists = scope:horse_rider_1 }
                    }
                    save_scope_as = horse_rider_1
                }
                else = {
                    save_scope_as = horse_rider_2
                }
            }
        }
    }

    weight_multiplier = {
        base = 5
        modifier = {
            add = 1
            number_of_knights < max_number_of_knights
        }
    }

    # Bet on option 1
    option = {
        name = feast_tsagaan_sar_events.0250.a
        trigger = { short_term_gold >= tiny_gold_value }

        custom_tooltip = feast_tsagaan_sar_events.0250.a_tt

        remove_short_term_gold = tiny_gold_value

        add_character_flag = {
            flag = horse_race_bet_1
            days = 5
        }

        stress_impact = {
            improvident = minor_stress_impact_loss
        }

        ai_chance = {
            base = 100
            ai_value_modifier = {
                ai_greed = -0.5
                ai_energy = 1
            }
        }
    }

    # Bet on option 2
    option = {
        name = feast_tsagaan_sar_events.0250.b
        trigger = { short_term_gold >= tiny_gold_value }

        custom_tooltip = feast_tsagaan_sar_events.0250.b_tt

        add_character_flag = {
            flag = horse_race_bet_2
            days = 5
        }

        remove_short_term_gold = tiny_gold_value

        stress_impact = {
            improvident = minor_stress_impact_loss
        }

        ai_chance = {
            base = 100
            ai_value_modifier = {
                ai_greed = -0.5
                ai_energy = 1
            }
        }
    }

    # Join in yourself
    option = {
        name = feast_tsagaan_sar_events.0250.c
        trigger = { prowess >= low_skill_rating }
        show_as_unavailable = { always = yes }

        add_character_flag = {
            flag = in_horse_race
            days = 5
        }

        custom_tooltip = feast_tsagaan_sar_events.0250.c_tt

        stress_impact = {
            ambitious = minor_stress_impact_loss
            arrogant = minor_stress_impact_loss
            craven = minor_stress_impact_gain
        }

        ai_chance = {
            base = 100
            ai_value_modifier = {
                ai_energy = 2
            }
            modifier = {
                factor = 1.5
                OR = {
                    has_trait = ambitious
                    has_trait = brave
                    has_trait = arrogant
                }
            }
        }
    }

    # Watch
    option = {
        name = feast_tsagaan_sar_events.0250.d

        ai_chance = {
            base = 100
            ai_value_modifier = {
                ai_energy = -0.5
            }
        }
    }

    after = {
        custom_tooltip = {
            text = feast_tsagaan_sar_events.0250.after_tt
            trigger_event = {
                id = feast_tsagaan_sar_events.0251
            }
        }
    }
}

# Horse race event 1
feast_tsagaan_sar_events.0251 = {
    type = activity_event

    title = feast_tsagaan_sar_events.0250.t
    desc = {
        desc = feast_tsagaan_sar_events.0251.desc_intro
        first_valid = {
            triggered_desc = {
                trigger = {
                    has_character_flag = in_horse_race
                }
                desc = feast_tsagaan_sar_events.0251.desc_race
            }
            desc = feast_tsagaan_sar_events.0251.desc_watch
        }
    }

    theme = feast_activity

    left_portrait = {
        character = root
        triggered_animation = {
            trigger = {
                has_character_flag = in_horse_race
            }
            animation = jockey_gallop
        }
        camera = camera_event_horse_left
        animation = jockey_walk
    }

    center_portrait = {
        character = scope:horse_rider_1
        animation = jockey_gallop
        camera = camera_event_horse_right
    }

    right_portrait = {
        character = scope:horse_rider_2
        animation = jockey_gallop
        camera = camera_event_horse_right
    }

    # Ok
    option = {
        name = feast_tsagaan_sar_events.0251.a
        trigger = { NOT = { has_character_flag = in_horse_race } }

        add_stress = minor_stress_impact_loss
    }

    # Bump the first rider
    option = {
        name = feast_tsagaan_sar_events.0251.b
        trigger = { has_character_flag = in_horse_race }

        duel = {
            desc = feast_tsagaan_sar_events.0251.b.duel
            skills = { martial prowess }
            target = scope:horse_rider_1
            70 = {
                desc = feast_tsagaan_sar_events.0251.success
                modifier = {
                    add = 10
                    scope:horse_rider_1 = { has_trait = wounded }
                }
                modifier = {
                    add = 10
                    OR = {
                        has_trait = sadistic
                        has_trait = callous
                    }
                }
                modifier = {
                    add = 10
                    has_trait = lifestyle_hunter
                }
                modifier = {
                    add = 5
                    has_trait_xp = {
                        trait = tourney_participant
                        track = horse
                        value >= 50
                    }
                }
                modifier = {
                    add = 5
                    has_trait_xp = {
                        trait = tourney_participant
                        track = horse
                        value >= 1
                    }
                }
                compare_modifier = {
                    value = scope:duel_value
                    multiplier = 3.5
                }
                send_interface_toast = {
                    title = feast_tsagaan_sar_events.0251.success
                    type = event_toast_effect_good
                    left_icon = root
                    right_icon = scope:horse_rider_1
                    custom_tooltip = feast_tsagaan_sar_events.0251.b_tt
                    scope:horse_rider_2 = { save_scope_as = final_opponent }
                    scope:horse_rider_1 = {
                        progress_towards_rival_effect = {
                            REASON = rival_cheated_horse_race
                            CHARACTER = root
                            OPINION = -15
                        }
                        random = {
                            chance = 10
                            increase_wounds_effect = { REASON = horse_riding_accident }
                        }
                    }
                    stress_impact = {
                        compassionate = minor_stress_impact_gain
                        callous = minor_stress_impact_loss
                        sadistic = minor_stress_impact_loss
                        arbitrary = minor_stress_impact_loss
                    }
                }
            }
            30 = {
                desc = feast_tsagaan_sar_events.0251.failure
                compare_modifier = {
                    value = scope:duel_value
                    multiplier = -3.5
                }
                send_interface_toast = {
                    title = feast_tsagaan_sar_events.0251.failure
                    type = event_toast_effect_bad
                    left_icon = root
                    right_icon = scope:horse_rider_1
                    add_character_flag = {
                        flag = knocked_horse_race
                        days = 5
                    }
                    custom_tooltip = feast_tsagaan_sar_events.0251.lose
                    random = {
                        chance = 10
                        increase_wounds_effect = { REASON = horse_riding_accident }
                    }
                }
            }
        }


        ai_chance = {
            base = 100
            ai_value_modifier = {
                ai_compassion = -1
            }
            modifier = {
                factor = 0.5
                has_trait = just
            }
        }
    }

    # Bump the second rider
    option = {
        name = feast_tsagaan_sar_events.0251.c
        trigger = { has_character_flag = in_horse_race }

        duel = {
            desc = feast_tsagaan_sar_events.0251.c.duel
            skills = { martial prowess }
            target = scope:horse_rider_2
            70 = {
                desc = feast_tsagaan_sar_events.0251.success
                modifier = {
                    add = 10
                    scope:horse_rider_2 = { has_trait = wounded }
                }
                modifier = {
                    add = 10
                    OR = {
                        has_trait = sadistic
                        has_trait = callous
                    }
                }
                modifier = {
                    add = 10
                    has_trait = lifestyle_hunter
                }
                modifier = {
                    add = 5
                    has_trait_xp = {
                        trait = tourney_participant
                        track = horse
                        value >= 50
                    }
                }
                modifier = {
                    add = 5
                    has_trait_xp = {
                        trait = tourney_participant
                        track = horse
                        value >= 1
                    }
                }
                compare_modifier = {
                    value = scope:duel_value
                    multiplier = 3.5
                }
                send_interface_toast = {
                    title = feast_tsagaan_sar_events.0251.success
                    type = event_toast_effect_good
                    left_icon = root
                    right_icon = scope:horse_rider_2
                    custom_tooltip = feast_tsagaan_sar_events.0251.c_tt
                    scope:horse_rider_1 = { save_scope_as = final_opponent }
                    scope:horse_rider_2 = {
                        progress_towards_rival_effect = {
                            REASON = rival_cheated_horse_race
                            CHARACTER = root
                            OPINION = -15
                        }
                        random = {
                            chance = 10
                            increase_wounds_effect = { REASON = horse_riding_accident }
                        }
                    }
                    stress_impact = {
                        compassionate = minor_stress_impact_gain
                        callous = minor_stress_impact_loss
                        sadistic = minor_stress_impact_loss
                        arbitrary = minor_stress_impact_loss
                    }
                }
            }
            30 = {
                desc = feast_tsagaan_sar_events.0251.failure
                compare_modifier = {
                    value = scope:duel_value
                    multiplier = -3.5
                }
                send_interface_toast = {
                    title = feast_tsagaan_sar_events.0251.failure
                    type = event_toast_effect_bad
                    left_icon = root
                    right_icon = scope:horse_rider_2
                    add_character_flag = {
                        flag = knocked_horse_race
                        days = 5
                    }
                    custom_tooltip = feast_tsagaan_sar_events.0251.lose
                    random = {
                        chance = 10
                        increase_wounds_effect = { REASON = horse_riding_accident }
                    }
                }
            }
        }

        ai_chance = {
            base = 100
            ai_value_modifier = {
                ai_compassion = -1
            }
            modifier = {
                factor = 0.5
                has_trait = just
            }
        }
    }

    # Keep going
    option = {
        name = feast_tsagaan_sar_events.0251.d
        trigger = { has_character_flag = in_horse_race }

        random_list = {
            50 = {
                modifier = {
                    add = 10
                    scope:horse_rider_1 = { has_trait = wounded }
                }
                modifier = {
                    add = 5
                    scope:horse_rider_1 = {
                        has_trait_xp = {
                            trait = tourney_participant
                            track = horse
                            value >= 1
                        }
                    }
                }
                show_chance = no
                desc = feast_tsagaan_sar_events.0251.d.knocked_out_1
                send_interface_toast = {
                    title = feast_tsagaan_sar_events.0251.d_title
                    type = event_toast_effect_neutral
                    left_icon = scope:horse_rider_2
                    right_icon = scope:horse_rider_1
                    scope:horse_rider_2 = { save_scope_as = final_opponent }
                    custom_tooltip = feast_tsagaan_sar_events.0251.b_tt
                }
            }
            50 = {
                modifier = {
                    add = 10
                    scope:horse_rider_2 = { has_trait = wounded }
                }
                modifier = {
                    add = 5
                    scope:horse_rider_2 = {
                        has_trait_xp = {
                            trait = tourney_participant
                            track = horse
                            value >= 1
                        }
                    }
                }
                show_chance = no
                desc = feast_tsagaan_sar_events.0251.d.knocked_out_2
                send_interface_toast = {
                    title = feast_tsagaan_sar_events.0251.d_title
                    type = event_toast_effect_neutral
                    left_icon = scope:horse_rider_1
                    right_icon = scope:horse_rider_2
                    scope:horse_rider_1 = { save_scope_as = final_opponent }
                    custom_tooltip = feast_tsagaan_sar_events.0251.c_tt
                }
            }
            30 = {
                modifier = {
                    add = 10
                    has_trait = wounded
                }
                modifier = {
                    add = 5
                    scope:horse_rider_2 = {
                        has_trait_xp = {
                            trait = tourney_participant
                            track = horse
                            value >= 1
                        }
                    }
                }
                modifier = {
                    add = 5
                    scope:horse_rider_1 = {
                        has_trait_xp = {
                            trait = tourney_participant
                            track = horse
                            value >= 1
                        }
                    }
                }
                show_chance = no
                desc = feast_tsagaan_sar_events.0251.d.knocked_out_3
                send_interface_toast = {
                    title = feast_tsagaan_sar_events.0251.d_title
                    type = event_toast_effect_neutral
                    left_icon = scope:horse_rider_1
                    right_icon = scope:horse_rider_2
                    add_character_flag = {
                        flag = knocked_horse_race
                        days = 5
                    }
                    custom_tooltip = feast_tsagaan_sar_events.0251.lose
                }
            }
        }

        ai_chance = {
            base = 100
        }
    }

    after = {
        custom_tooltip = {
            text = feast_tsagaan_sar_events.0251.after_tt
            trigger_event = {
                id = feast_tsagaan_sar_events.0252
            }
        }
    }
}
# Horse race event 2
feast_tsagaan_sar_events.0252 = {
    type = activity_event

    title = feast_tsagaan_sar_events.0250.t
    desc = {
        first_valid = {
            triggered_desc = {
                trigger = {
                    NOT = { has_character_flag = in_horse_race }
                }
                desc = feast_tsagaan_sar_events.0252.desc_watch
            }
            triggered_desc = {
                trigger = {
                    has_character_flag = knocked_horse_race
                }
                desc = feast_tsagaan_sar_events.0252.desc_knocked
            }
            triggered_desc = {
                trigger = {
                    scope:horse_rider_1 = { has_character_flag = knocked_horse_race }
                }
                desc = feast_tsagaan_sar_events.0252.desc_knocked_1
            }
            triggered_desc = {
                trigger = {
                    scope:horse_rider_2 = { has_character_flag = knocked_horse_race }
                }
                desc = feast_tsagaan_sar_events.0252.desc_knocked_2
            }
        }

    }

    theme = feast_activity

    left_portrait = {
        character = root
        triggered_animation = {
            trigger = {
                has_character_flag = in_horse_race
                NOT = { has_character_flag = knocked_horse_race }
            }
            animation = jockey_gallop
        }
        camera = camera_event_horse_left
        animation = jockey_walk
    }

    center_portrait = {
        character = scope:horse_rider_1
        triggered_animation = {
            trigger = {
                OR = {
                    NOT = { root =  { has_character_flag = in_horse_race } }
                    AND = {
                        root = { has_character_flag = in_horse_race }
                        NOT = { has_character_flag = knocked_horse_race }
                    }
                }
            }
            animation = jockey_gallop
        }
        animation = jockey_walk
        camera = camera_event_horse_right
    }

    right_portrait = {
        character = scope:horse_rider_2
        triggered_animation = {
            trigger = {
                OR = {
                    NOT = { root =  { has_character_flag = in_horse_race } }
                    AND = {
                        root = { has_character_flag = in_horse_race }
                        NOT = { has_character_flag = knocked_horse_race }
                    }
                }
            }
            animation = jockey_gallop
        }
        animation = jockey_walk
        camera = camera_event_horse_right
    }

    # Cheat
    option = {
        name = feast_tsagaan_sar_events.0252.a
        trigger = { has_character_flag = in_horse_race NOT = { has_character_flag = knocked_horse_race } }
        duel = {
            desc = feast_tsagaan_sar_events.0252.a.duel
            skills = { intrigue prowess }
            target = scope:final_opponent
            50 = {
                desc = feast_tsagaan_sar_events.0252.success
                compare_modifier = {
                    value = scope:duel_value
                    multiplier = 3.5
                }
                send_interface_toast = {
                    title = feast_tsagaan_sar_events.0252.success
                    type = event_toast_effect_good
                    left_icon = root
                    right_icon = scope:final_opponent
                    add_character_flag = {
                        flag = horse_race_cheat
                        days = 1
                    }
                    scope:final_opponent = {
                        progress_towards_rival_effect = {
                            REASON = rival_cheated_horse_race
                            CHARACTER = root
                            OPINION = -15
                        }
                    }
                    stress_impact = {
                        just = minor_stress_impact_gain
                        arbitrary = minor_stress_impact_loss
                    }
                }
            }
            50 = {
                desc = feast_tsagaan_sar_events.0252.failure
                compare_modifier = {
                    value = scope:duel_value
                    multiplier = -3.5
                }
                send_interface_toast = {
                    title = feast_tsagaan_sar_events.0252.failure
                    type = event_toast_effect_bad
                    left_icon = root
                    right_icon = scope:final_opponent
                }
            }
        }

        ai_chance = {
            base = 100
            ai_value_modifier = {
                ai_compassion = -1
            }
            modifier = {
                factor = 0.5
                has_trait = just
            }
        }
    }

    # Ok
    option = {
        name = feast_tsagaan_sar_events.0252.b
        trigger = { NOT = { has_character_flag = in_horse_race } }
    }

    # Just keep riding
    option = {
        name = feast_tsagaan_sar_events.0252.c
        trigger = { has_character_flag = in_horse_race }

        ai_chance = {
            base = 100
        }
    }

    after = {
        # Determine Winner
        hidden_effect = {
            random_list = {
                10 = { # Player
                    trigger = {
                        has_character_flag = in_horse_race
                        NOT = { has_character_flag = knocked_horse_race }
                        exists = scope:final_opponent
                    }
                    modifier = {
                        add = 10
                        has_character_flag = horse_race_cheat
                    }
                    save_scope_as = rider_winner
                    scope:final_opponent = { save_scope_as = rider_loser }
                }
                10 = {
                    trigger = {
                        scope:horse_rider_1 = { NOT = { has_character_flag = knocked_horse_race } }
                    }
                    scope:horse_rider_1 = { save_scope_as = rider_winner }
                    if = {
                        limit = {
                            has_character_flag = in_horse_race
                            NOT = { has_character_flag = knocked_horse_race }
                        }
                        save_scope_as = rider_loser
                    }
                    else = {
                        scope:horse_rider_2 = { save_scope_as = rider_loser }
                    }
                }
                10 = {
                    trigger = {
                        scope:horse_rider_2 = { NOT = { has_character_flag = knocked_horse_race } }
                    }
                    scope:horse_rider_2 = { save_scope_as = rider_winner }
                    if = {
                        limit = {
                            has_character_flag = in_horse_race
                            NOT = { has_character_flag = knocked_horse_race }
                        }
                        save_scope_as = rider_loser
                    }
                    else = {
                        scope:horse_rider_1 = { save_scope_as = rider_loser }
                    }
                }
            }
        }
        custom_tooltip = {
            text = feast_tsagaan_sar_events.0252.after_tt
            trigger_event = {
                id = feast_tsagaan_sar_events.0253
            }
        }
    }
}
# Horse race event 3
feast_tsagaan_sar_events.0253 = {
    type = activity_event

    title = feast_tsagaan_sar_events.0250.t
    desc = {
        first_valid = {
            triggered_desc = {
                trigger = {
                    root = scope:rider_winner
                    has_character_flag = in_horse_race
                }
                desc = feast_tsagaan_sar_events.0253.desc_won
            }
            triggered_desc = {
                trigger = {
                    has_character_flag = in_horse_race
                    NOR = { 
                        has_character_flag = knocked_horse_race
                        root = scope:rider_winner  
                    }
                }
                desc = feast_tsagaan_sar_events.0253.desc_lost
            }
            desc = feast_tsagaan_sar_events.0253.desc_watch
        }
    }

    immediate = {
        # Outcome of bet
        if = {
            limit = {
                has_character_flag = horse_race_bet_1
                scope:rider_winner = scope:horse_rider_1
            }
            alternative_limit = {
                has_character_flag = horse_race_bet_2
                scope:rider_winner = scope:horse_rider_2
            }
            custom_tooltip = feast_tsagaan_sar_events.0253.bet_tt
            add_short_term_gold = tiny_gold_value_double
        }
    }

    theme = feast_activity

    left_portrait = {
        character = scope:rider_winner
        camera = camera_event_horse_left
        animation = jockey_victory
    }

    right_portrait = {
        character = scope:rider_loser
        camera = camera_event_horse_right
        animation = jockey_walk
    }

    # Okay
    option = {
        name = feast_tsagaan_sar_events.0253.a
        trigger = { NOT = { has_character_flag = in_horse_race } }
        ai_chance = {
            base = 100
        }
    }

    option = {
        name = feast_tsagaan_sar_events.0253.winner
        trigger = { scope:rider_winner = root }
        ai_chance = {
            base = 100
        }
    }

    # Good game
    option = {
        name = feast_tsagaan_sar_events.0253.b
        trigger = { has_character_flag = in_horse_race NOR = { has_trait = arrogant scope:rider_winner = root } }
        add_opinion = {
            target = scope:rider_winner
            modifier = impressed_opinion
            opinion = 10
        }
        ai_chance = {
            base = 100
        }
    }

    # Whatever
    option = {
        name = feast_tsagaan_sar_events.0253.c
        trigger = { has_character_flag = in_horse_race NOT = { scope:rider_winner = root } }
        ai_chance = {
            base = 100
        }
    }

    # Possible recruitment
    option = {
        name = feast_tsagaan_sar_events.0253.d
        trigger = {
            NOR = { 
                scope:rider_winner = { is_courtier_of = root }
                scope:rider_winner = { is_knight_of = root }
                scope:rider_winner = { is_councillor_of = root }
                scope:rider_winner = { is_vassal_of = root }
            }
            can_recruit_character_to_court_trigger = {
                RECRUITER = root
                RECRUITEE = scope:rider_winner
            }
            scope:rider_winner = { is_ai = yes is_courtier = yes }
            is_ruler = yes
        }

        if = {
            limit = {
                exists = scope:rider_winner.liege
            }
            scope:rider_winner.liege = {
                add_opinion = {
                    target = root
                    modifier = stole_my_courtier_opinion
                    opinion = -15
                }
            }
        }

        scope:rider_winner = {
            add_to_court_and_entourage_effect = yes
        }

        stress_impact = {
            arrogant = minor_stress_impact_gain
        }

        ai_chance = {
            base = 100
            modifier = {
                factor = 0
                has_trait = arrogant
                scope:rider_loser = root
            }
        }
    }

    after = {
        scope:rider_winner = {
            add_prestige = minor_prestige_gain
            add_stress = minor_stress_impact_loss
            if = {
                limit = {
                    NOT = { has_trait = tourney_participant }
                }
                add_trait = tourney_participant
            }
            add_trait_xp = {
                trait = tourney_participant
                track = horse
                value = 3
            }
        }
    }
}

scripted_trigger is_eligible_target_ts_0260 = {
    NOT = {
        this = root
    }
    is_adult = yes
    is_ai = yes
}

# Someone is dressed very well
feast_tsagaan_sar_events.0260 = {
    type = activity_event

    title = feast_tsagaan_sar_events.0260.t
    desc = feast_tsagaan_sar_events.0260.desc

    theme = feast_activity

    left_portrait = {
        character = root
        animation = admiration
    }

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

    trigger = {
        in_tsaagan_sar_trigger = yes
        involved_activity = {
            any_attending_character = {
                is_eligible_target_ts_0260 = yes
            }
        }
    }

    cooldown = { years = 10 }

    immediate = {
        involved_activity = {
            random_attending_character = {
                limit = { is_eligible_target_ts_0260 = yes }
                weight = {
                    base = 1
                    modifier = {
                        add = 5
                        has_trait = beauty_good
                    }
                }
                save_scope_as = drip_haver
            }
        }
    }

    # Give a friendly compliment
    option = {
        name = feast_tsagaan_sar_events.0260.a

        if = {
            limit = {
                can_set_relation_friend_trigger = { CHARACTER = scope:drip_haver }
                has_relation_potential_friend = scope:drip_haver
            }
            set_relation_friend = {
                target = scope:drip_haver
                reason = friend_tsagaan_sar_compliment
            }
        }
        else_if = {
            limit = {
                can_set_relation_potential_friend_trigger = { CHARACTER = scope:drip_haver }
            }
            set_relation_potential_friend = scope:drip_haver
        }

        scope:drip_haver = {
            add_opinion = {
                target = root
                modifier = flattered_opinion
                opinion = 15
            }
        }

        stress_impact = {
            shy = minor_stress_impact_gain
            arrogant = minor_stress_impact_gain
            gregarious = minor_stress_impact_loss
            compassionate = minor_stress_impact_loss
        }

        if = {
            limit = {
                has_activity_intent = befriend_attendee_intent
                intent_target ?= scope:drip_haver
            }
            complete_activity_intent = yes
        }

        ai_chance = {
            base = 75
            ai_value_modifier = {
                ai_compassion = 1
                ai_sociability = 0.5
            }
            modifier = {
                factor = 0.5
                has_trait = arrogant
            }
            modifier = {
                factor = 1.5
                has_trait = gregarious
            }
            modifier = {
                factor = 1.5
                has_activity_intent = befriend_attendee_intent
                intent_target ?= scope:drip_haver
            }
        }
    }

    # ok
    option = {
        name = {
            text = {
                first_valid = {
                    triggered_desc = {
                        trigger = {
                            has_trait = shy
                        }
                        desc = feast_tsagaan_sar_events.0260.b_shy
                    }
                    desc = feast_tsagaan_sar_events.0260.b
                }
            }
        }

        add_character_modifier = {
            modifier = mpo_appreciate_fashion_modifier
            years = 2
        }

        stress_impact = {
            shy = minor_stress_impact_loss
        }

        ai_chance = {
            base = 75
            ai_value_modifier = {
                ai_sociability = -1
            }
        }
    }
}

# Drinking contest
feast_tsagaan_sar_events.0270 = {
    type = activity_event

    title = feast_tsagaan_sar_events.0270.t
    desc = feast_tsagaan_sar_events.0270.desc

    theme = feast_activity

    left_portrait = {
        character = root
        animation = toast_goblet
    }

    right_portrait = {
        character = scope:drinker
        animation = drink_goblet
    }

    trigger = {
        in_tsaagan_sar_trigger = yes
        involved_activity = {
            any_attending_character = {
                NOR = { this = root has_trait = temperate }
                is_adult = yes
            }
        }
    }

    cooldown = { years = 5 }

    immediate = {
        involved_activity = {
            random_attending_character = {
                limit = {
                    NOR = { this = root has_trait = temperate }
                    is_adult = yes
                }
                weight = {
                    base = 1
                    modifier = {
                        add = 5
                        has_trait = drunkard
                    }
                    modifier = {
                        add = 20
                        has_any_good_relationship_with_character_trigger = { CHARACTER = root }
                    }
                }
                save_scope_as = drinker
            }
        }
    }

    # Ok sure
    option = {
        name = feast_tsagaan_sar_events.0270.a

        random_list = {
            40 = {
                modifier = {
                    add = 10
                    has_trait = drunkard
                }
                desc = feast_tsagaan_sar_events.0270.win
                send_interface_toast = {
                    title = feast_tsagaan_sar_events.0270.win
                    type = event_toast_effect_good
                    left_icon = root
                    right_icon = scope:drinker
                    add_prestige = minor_prestige_gain
                    scope:drinker = {
                        add_opinion = {
                            target = root
                            modifier = impressed_opinion
                            opinion = 15
                        }
                    }
                }
            }
            20 = {
                desc = feast_tsagaan_sar_events.0270.win_price
                send_interface_toast = {
                    title = feast_tsagaan_sar_events.0270.win_price
                    type = event_toast_effect_good
                    left_icon = root
                    right_icon = scope:drinker
                    add_prestige = miniscule_prestige_gain
                    add_character_modifier = {
                        modifier = mpo_queasy_modifier
                        months = 6
                    }
                    scope:drinker = {
                        add_opinion = {
                            target = root
                            modifier = impressed_opinion
                            opinion = 10
                        }
                    }
                }
            }
            39 = {
                modifier = {
                    add = 10
                    scope:drinker = { has_trait = drunkard }
                }
                desc = feast_tsagaan_sar_events.0270.lose
                send_interface_toast = {
                    title = feast_tsagaan_sar_events.0270.lose
                    type = event_toast_effect_neutral
                    left_icon = root
                    right_icon = scope:drinker
                    scope:drinker = { add_prestige = miniscule_prestige_gain }
                }
            }
            1 = {
                desc = feast_tsagaan_sar_events.0270.win_price
                modifier = {
                    add = 1
                    has_trait = drunkard
                }
                death = { death_reason = death_drinking_passive }
            }
        }
        random = {
            chance = 5
            add_trait = drunkard
        }
        if = {
            limit = {
                can_set_relation_friend_trigger = { CHARACTER = scope:drinker }
            }
            set_relation_friend = {
                target = scope:drinker
                reason = friend_drinking_buddies
            }
        }

        stress_impact = {
            drunkard = medium_stress_impact_loss
            gregarious = minor_stress_impact_loss
            temperate = minor_stress_impact_gain
        }

        if = {
            limit = {
                has_activity_intent = befriend_attendee_intent
                intent_target ?= scope:drinker
            }
            complete_activity_intent = yes
        }

        ai_chance = {
            base = 75
            ai_value_modifier = {
                ai_sociability = 1
            }
            modifier = {
                factor = 1.5
                OR = {
                    has_trait = gregarious
                    has_trait = drunkard
                    has_trait = gluttonous
                }
            }
            modifier = {
                factor = 1.5
                has_activity_intent = befriend_attendee_intent
                intent_target ?= scope:drinker
            }
        }
    }

    # No
    option = {
        name = {
            text = {
                triggered_desc = {
                    trigger = {
                        has_trait = paranoid
                    }
                    desc = feast_tsagaan_sar_events.0270.b_paranoid
                }
                desc = feast_tsagaan_sar_events.0270.b
            }
        }

        scope:drinker = {
            add_opinion = {
                target = root
                modifier = disappointed_opinion
                opinion = -10
            }
        }

        stress_impact = {
            base = minor_stress_impact_loss
            temperate = minor_stress_impact_loss
            paranoid = minor_stress_impact_loss
        }

        ai_chance = {
            base = 50
            ai_value_modifier = {
                ai_sociability = -1
            }
            modifier = {
                factor = 1.5
                has_trait = paranoid
            }
            modifier = {
                factor = 2
                has_trait = temperate
            }
        }
    }
}

# You ask an elder for wisdom
feast_tsagaan_sar_events.0280 = {
    type = activity_event

    title = feast_tsagaan_sar_events.0280.t
    desc = feast_tsagaan_sar_events.0280.desc

    theme = feast_activity

    left_portrait = {
        character = root
        animation = personality_compassionate
    }

    right_portrait = {
        character = scope:elder
        animation = personality_forgiving
    }

    trigger = {
        in_tsaagan_sar_trigger = yes
        age <= 40
        involved_activity = {
            any_attending_character = {
                NOT = { this = root }
                age >= 55
            }
        }
    }

    cooldown = { years = 5 }

    immediate = {
        involved_activity = {
            random_attending_character = {
                limit = {
                    NOT = { this = root }
                    age >= 55
                }
                save_scope_as = elder
            }
        }
    }

    # Tell me about my family
    option = {
        name = feast_tsagaan_sar_events.0280.a

        random_list = {
            50 = { # Grow your family
                modifier = {
                    add = -10
                    age >= 35
                }
                show_chance = no
                desc = feast_tsagaan_sar_events.0280.a_grow
                send_interface_toast = {
                    title = feast_tsagaan_sar_events.0280.a_grow
                    type = event_toast_effect_good
                    left_icon = root
                    right_icon = scope:elder
                    add_character_modifier = {
                        modifier = mpo_elder_family_grow_modifier
                        years = 2
                    }
                }
            }
            50 = { # Strengthen your family
                show_chance = no
                desc = feast_tsagaan_sar_events.0280.a_strength
                send_interface_toast = {
                    title = feast_tsagaan_sar_events.0280.a_strength
                    type = event_toast_effect_good
                    left_icon = root
                    right_icon = scope:elder
                    add_character_modifier = {
                        modifier = mpo_elder_family_strength_modifier
                        years = 2
                    }
                }
            }
        }

        ai_chance = {
            base = 100
        }
    }
    # Tell me about my armies
    option = {
        name = feast_tsagaan_sar_events.0280.b

        random_list = {
            50 = { # Focus on defending
                show_chance = no
                desc = feast_tsagaan_sar_events.0280.b_defense
                send_interface_toast = {
                    title = feast_tsagaan_sar_events.0280.b_defense
                    type = event_toast_effect_good
                    left_icon = root
                    right_icon = scope:elder
                    add_character_modifier = {
                        modifier = mpo_elder_war_defense_modifier
                        years = 2
                    }
                }
            }
            50 = { # Focus on conquering
                show_chance = no
                desc = feast_tsagaan_sar_events.0280.b_attack
                send_interface_toast = {
                    title = feast_tsagaan_sar_events.0280.b_attack
                    type = event_toast_effect_good
                    left_icon = root
                    right_icon = scope:elder
                    add_character_modifier = {
                        modifier = mpo_elder_war_attack_modifier
                        years = 2
                    }
                }
            }
        }

        ai_chance = {
            base = 100
        }
    }
    # Tell me about my peoples
    option = {
        name = feast_tsagaan_sar_events.0280.c

        random_list = {
            50 = { # migrate them
                show_chance = no
                desc = feast_tsagaan_sar_events.0280.c_migrate
                send_interface_toast = {
                    title = feast_tsagaan_sar_events.0280.c_migrate
                    type = event_toast_effect_good
                    left_icon = root
                    right_icon = scope:elder
                    add_character_modifier = {
                        modifier = mpo_elder_flock_migrate_modifier
                        years = 2
                    }
                }
            }
            50 = { # Tend to them
                show_chance = no
                desc = feast_tsagaan_sar_events.0280.c_tend
                send_interface_toast = {
                    title = feast_tsagaan_sar_events.0280.c_tend
                    type = event_toast_effect_good
                    left_icon = root
                    right_icon = scope:elder
                    add_character_modifier = {
                        modifier = mpo_elder_flock_tend_modifier
                        years = 2
                    }
                }
            }
        }

        ai_chance = {
            base = 100
        }
    }

    option = {
        name = feast_tsagaan_sar_events.0280.d

        stress_impact = {
            base = minor_stress_impact_loss
            humble = minor_stress_impact_loss
        }

        scope:elder = {
            add_opinion = {
                target = root
                modifier = flattered_opinion
                opinion = 15
            }
        }

        ai_chance = {
            base = 50
        }
    }

}

# Wise guy boon
feast_tsagaan_sar_events.0290 = {
    type = activity_event

    title = feast_tsagaan_sar_events.0290.t
    desc = feast_tsagaan_sar_events.0290.desc

    theme = feast_activity

    left_portrait = {
        character = root
        animation = ecstasy
    }

    right_portrait = {
        character = scope:wise_guy
        animation = toast_goblet
    }

    trigger = {
        in_tsaagan_sar_trigger = yes
        #faith.religion = religion:tengrism_religion #TODO_CD_AT - maybe allow it for all steppe religions? and religions that have a lunisolar calendar?
        involved_activity = {
            any_attending_character = {
                NOT = {
                    this = root
                }
                is_adult = yes
                is_ai = yes
                #faith.religion = religion:tengrism_religion 
            }
        }
    }

    immediate = {
        involved_activity = {
            ordered_attending_character = {
                limit = {
                    NOT = {
                        this = root
                    }
                    is_adult = yes
                    is_ai = yes
                    #faith.religion = religion:tengrism_religion  
                }
                order_by = {
                    value = learning
                    if = {
                        limit = {
                            has_trait = intellect_good
                        }
                        add = 10
                    }
                    if = {
                        limit = {
                            has_court_position = court_astrologer_court_position
                        }
                        add = 100
                    }
                    if = {
                        limit = {
                            has_trait = lifestyle_mystic
                        }
                        add = 10
                    }
                }
                save_scope_as = wise_guy
            }
        }
        switch = {
            trigger = mpo_zodiac_calculation_value
            0 = {
                add_character_modifier = { modifier = mpo_lunar_new_year_monkey_modifier years = 1 }
            }
            1 = {
                add_character_modifier = { modifier = mpo_lunar_new_year_rooster_modifier years = 1 }
            }
            2 = {
                add_character_modifier = { modifier = mpo_lunar_new_year_dog_modifier years = 1 }
            }
            3 = {
                add_character_modifier = { modifier = mpo_lunar_new_year_pig_modifier years = 1 }
            }
            4 = {
                add_character_modifier = { modifier = mpo_lunar_new_year_rat_modifier years = 1 }
            }
            5 = {
                add_character_modifier = { modifier = mpo_lunar_new_year_ox_modifier years = 1 }
            }
            6 = {
                add_character_modifier = { modifier = mpo_lunar_new_year_tiger_modifier years = 1 }
            }
            7 = {
                add_character_modifier = { modifier = mpo_lunar_new_year_rabbit_modifier years = 1 }
            }
            8 = {
                add_character_modifier = { modifier = mpo_lunar_new_year_dragon_modifier years = 1 }
            }
            9 = {
                add_character_modifier = { modifier = mpo_lunar_new_year_snake_modifier years = 1 }
            }
            10 = {
                add_character_modifier = { modifier = mpo_lunar_new_year_horse_modifier years = 1 }
            }
            11 = {
                add_character_modifier = { modifier = mpo_lunar_new_year_sheep_modifier years = 1 }
            }
        }
    }

    # Ok yay
    option = {
        name = feast_tsagaan_sar_events.0290.a
        add_stress = minor_stress_loss
    }

    option = {
        name = feast_tsagaan_sar_events.0290.b
        trigger = {
            can_appoint_char_to_court_position = {
			    CHAR = scope:wise_guy
				COURT_POS = court_astrologer_court_position
			}
        }
        court_position_grant_effect = { POS = court_astrologer CANDIDATE = scope:wise_guy EMPLOYER = root }
    }
}

scripted_trigger is_eligible_target_ts_0300 = {
    NOT = {
        this = root
    }
    is_lowborn = yes
    is_adult = yes
}

# Someone's cleaning up
feast_tsagaan_sar_events.0300 = {
    type = activity_event

    title = feast_tsagaan_sar_events.0300.t
    desc = feast_tsagaan_sar_events.0300.desc

    theme = feast_activity

    left_portrait = {
        character = root
        animation = disbelief
    }

    right_portrait = {
        character = scope:cleaner
        animation = worry
    }

    trigger = {
        in_tsaagan_sar_trigger = yes
        involved_activity = {
            any_attending_character = {
                is_eligible_target_ts_0300 = yes 
            }
        }
    }

    immediate = {
        involved_activity = {
            random_attending_character = {
                limit = {
                    is_eligible_target_ts_0300 = yes
                }
                weight = {
                    base = 5
                    modifier = {
                        add = 5
                        is_female = yes
                    }
                }
                save_scope_as = cleaner
            }
        }
    }


    # Thank them with some gold
    option = {
        name = feast_tsagaan_sar_events.0300.a
        custom_tooltip = feast_tsagaan_sar_events.0300.a_tt

        pay_short_term_gold = {
            gold = tiny_gold_value
            target = scope:cleaner
        }

        stress_impact = {
            compassionate = minor_stress_impact_loss
            generous = medium_stress_impact_loss
            greedy = minor_stress_impact_gain
        }

        scope:cleaner = {
            add_opinion = {
                target = root
                modifier = grateful_opinion
                opinion = 15
            }
        }

        ai_chance = {
            base = 150
            ai_value_modifier = {
                ai_compassion = 1
                ai_greed = -1
                ai_sociability = 1.5
            }
        }
    }

    # Spill stuff on the floor that they have to clean up
    option = {
        name = feast_tsagaan_sar_events.0300.b
        custom_tooltip = feast_tsagaan_sar_events.0300.b_tt

        stress_impact = {
            sadistic = minor_stress_impact_loss
            callous = medium_stress_impact_loss
            compassionate = minor_stress_impact_gain
        }

        if = {
            limit = {
                has_activity_intent = banquet_mischief_intent
            }
            complete_activity_intent = yes
        }

        scope:cleaner = {
            add_opinion = {
                target = root
                modifier = annoyed_opinion
                opinion = -15
            }
        }

        ai_chance = {
            base = 50
            ai_value_modifier = {
                ai_compassion = -1
            }
        }
    }

    # Nothing
    option = {
        name = feast_tsagaan_sar_events.0300.c
    }
}

# Someone brags about not getting you a gift
feast_tsagaan_sar_events.0310 = {
    type = activity_event

    title = feast_tsagaan_sar_events.0310.t
    desc = feast_tsagaan_sar_events.0310.desc

    theme = feast_activity

    right_portrait = {
        character = scope:bragger
        animation = personality_bold
    }

    center_portrait = {
        character = scope:bragger_friend
        animation = worry
    }

    left_portrait = {
        character = root
        animation = scheme
    }

    trigger = {
        in_tsaagan_sar_trigger = yes
        involved_activity = {
            any_attending_character = {
                var:tsagaan_sar_gift ?= flag:no_gift
                can_gift_anything_trigger = yes
                is_ai = yes
            }
        }
    }

    immediate = {
        involved_activity = {
            random_attending_character = {
                limit = {
                    var:tsagaan_sar_gift ?= flag:no_gift
                    can_gift_anything_trigger = yes
                    is_ai = yes
                }
                weight = {
                    base = 1
                    modifier = {
                        add = 10
                        is_vassal_of = root
                    }
                }
                save_scope_as = bragger
            }
        }
        involved_activity = {
            random_attending_character = {
                limit = {
                    NOR = {
                        this = root
                        this = scope:bragger
                    }
                }
                save_scope_as = bragger_friend
            }
        }
    }

    # Kick them out of your court
    option = {
        name = feast_tsagaan_sar_events.0310.a
        trigger = {
            scope:bragger = {
                OR = {
                    is_courtier_of = root
                    is_pool_guest_of = root
                }
            }
        }

        scope:bragger = {
            select_and_move_to_pool_effect = yes

            add_opinion = {
                modifier = kicked_me_from_court
                target = root
            }
        }

        stress_impact = {
            compassionate = minor_stress_impact_gain
            callous = minor_stress_impact_loss
            sadistic = minor_stress_impact_loss
            gregarious = minor_stress_impact_gain
        }

        ai_chance = {
            base = 100
            ai_value_modifier = {
                ai_compassion = -1
            }
        }
    }

    # Force into giving a tribute
    option = {
        name = feast_tsagaan_sar_events.0310.b
        duel = {
            desc = feast_tsagaan_sar_events.0310.b.duel
            skill = intrigue
            target = scope:bragger
            60 = {
                desc = feast_tsagaan_sar_events.0310.b.success
                compare_modifier = {
                    value = scope:duel_value
                    multiplier = 3.5
                }
                send_interface_toast = {
                    title = feast_tsagaan_sar_events.0310.b.success
                    type = event_toast_effect_good
                    left_icon = root
                    right_icon = scope:bragger
                    scope:bragger = { add_character_flag = cant_no_gift }
                    stress_impact = {
                        vengeful = medium_stress_impact_loss
                    }
                    scope:bragger = {
                        add_prestige = minor_prestige_loss
                        trigger_event = feast_tsagaan_sar_events.0002
                    }
                }
            }
            40 = {
                desc = feast_tsagaan_sar_events.0310.b.failure
                compare_modifier = {
                    value = scope:duel_value
                    multiplier = -3.5
                }
                send_interface_toast = {
                    title = feast_tsagaan_sar_events.0310.b.failure
                    type = event_toast_effect_neutral
                    left_icon = root
                    right_icon = scope:bragger
                    scope:bragger = { remove_from_activity = involved_activity }
                }
            }
        }

        stress_impact = {
            forgiving = minor_stress_impact_gain
            craven = minor_stress_impact_gain
            vengeful = minor_stress_impact_loss
        }

        ai_chance = {
            base = 100
            ai_value_modifier = {
                ai_vengefulness = 1
                ai_greed = 0.5
            }
        }
    }

    # Just ignore him
    option = {
        name = feast_tsagaan_sar_events.0310.c

        stress_impact = {
            forgiving = minor_stress_impact_loss
            craven = minor_stress_impact_loss
            lazy = minor_stress_impact_loss
            vengeful = minor_stress_impact_gain
        }

        ai_chance = {
            base = 100
            ai_value_modifier = {
                ai_vengefulness = -1
            }
        }
    }
}

# Gifting to elders
feast_tsagaan_sar_events.0320 = {
    type = activity_event

    title = feast_tsagaan_sar_events.0320.t
    desc = feast_tsagaan_sar_events.0320.desc

    theme = feast_activity

    left_portrait = {
        character = root
        animation = personality_honorable
    }

    trigger = {
        in_tsaagan_sar_trigger = yes
        short_term_gold >= minor_gold_value
        involved_activity = {
            any_attending_character = {
                age >= 50
                count >= 2
            }
        }
    }

    option = {
        name = feast_tsagaan_sar_events.0320.a

        remove_short_term_gold = minor_gold_value

        add_piety = minor_piety_gain

        custom_tooltip = {
            text = feast_tsagaan_sar_events.0320.a_tt
            involved_activity = {
                every_attending_character = {
                    limit = { age >= 50 }
                    add_opinion = {
                        target = root
                        modifier = grateful_opinion
                        opinion = 10
                    }
                }
            }
        }
        stress_impact = {
            generous = minor_stress_impact_loss
            greedy = minor_stress_impact_gain
            compassionate = minor_stress_impact_loss
        }

        ai_chance = {
            base = 100
            ai_value_modifier = {
                ai_honor = 1.5
            }
            modifier = {
                factor = 1.5
                OR = {
                    has_trait = generous
                    has_trait = improvident
                }
            }
        }
    }

    option = {
        name = feast_tsagaan_sar_events.0320.b

        stress_impact = {
            lazy = minor_stress_impact_loss
        }

        ai_chance = {
            base = 100
            ai_value_modifier = {
                ai_greed = 1
                ai_honor = 0.5
            }
        }
    }
}
