﻿namespace = enfp_court
# "Courtly Sensibilities" a courtly vassal is ticked off you have a bastard child 
enfp_court.0001 = {
    type = court_event
    title = enfp_court.0001.t
    desc  = enfp_court.0001.desc
    theme = court
    cooldown = { years = 50 }

    court_scene = {
        button_position_character = scope:angrycourtly
        court_event_force_open = yes
        show_timeout_info = no
        should_pause_time = yes
        roles = {
            scope:angrycourtly = {
                group = petitioners_group
                animation = anger
            }
            scope:bastardkid = {
                group = petitioners_group
                animation = rage
            }
        }
    }

    widget = {
        gui = "event_window_widget_event_chain_progress"
        container = "custom_widgets_container"
        controller = event_chain_progress
    }

    trigger = {
        is_adult = yes
		has_royal_court = yes
        

        any_child = {
            has_trait = bastard
            is_courtier_of = root
            is_ai = yes
            NOT = {
                has_trait = devoted
                has_relation_rival = root

            }
        }

        any_vassal = {
            has_vassal_stance = courtly
            is_ai = yes
            age > 13
			faith = {
				OR = {
					has_doctrine_parameter = bastards_legitimize
					has_doctrine_parameter = bastards_always
				}
			}
        }
    }

    weight_multiplier = {
        base = 1
    }

    immediate = {
        hold_court_queue_next_event_effect = yes

        random_child = {
            limit = {
                has_trait = bastard
                is_courtier_of = root
            }
            save_scope_as = bastardkid
        }

        random_vassal = {
            limit = {
                has_vassal_stance = courtly
                age > 13
            }
            save_scope_as = angrycourtly
        }

        every_vassal = {
            limit = {
                has_vassal_stance = courtly
            }
            add_opinion = {
                target = root
                modifier = angry_opinion
                opinion = -25
            }
        }

        
    }

    option = {
        name = enfp_court.0001.a # Banish bastard
        scope:bastardkid = {
            banish = yes
            set_relation_rival = { 
                target = root
                reason = enfp_court.0001.a.banish
            }

        }
        add_prestige = major_prestige_gain
		if = {
			limit = { has_government = administrative_government }
			change_influence = major_influence_gain
		}
		else = {
			add_legitimacy = major_legitimacy_gain
		}
        change_current_court_grandeur = medium_court_grandeur_gain
        stress_impact = {
            compassionate = major_stress_impact_gain
			just = major_stress_impact_gain
            
        }
        ai_chance = {
            base = 20
            modifier = { add = 30 has_trait = zealous }
            modifier = { add = 10 has_trait = callous }
            modifier = { add = -30 has_trait = compassionate }
        }
    }

    option = {
        name = enfp_court.0001.b # Side with bastard
		flavor = enfp_court.0001.b.flavor
        
        every_vassal = {
            limit = { has_vassal_stance = courtly }
            add_opinion = {
                target = root
                modifier = angry_opinion
                opinion = -25
            }
        }
        change_current_court_grandeur = minor_court_grandeur_loss
        stress_impact = {
            just = minor_stress_impact_loss
            brave = minor_stress_impact_loss
            stubborn = minor_stress_impact_gain
        }
        ai_chance = {
            base = 10
            modifier = { add = 30 has_trait = compassionate }
            modifier = { add = 20 has_trait = brave }
            modifier = { add = -20 has_trait = callous }
        }
    }

    option = {
        name = enfp_court.0001.c # Legitimize them
        flavor = enfp_court.0001.b.flavor
        add_tyranny = medium_tyranny_gain
        if = {
			limit = { has_government = administrative_government }
			change_influence = medium_influence_loss
		}
		else = {
			add_legitimacy = medium_legitimacy_gain
        }

        scope:bastardkid = {
            remove_trait = bastard
            add_trait = legitimized_bastard
            add_opinion = {
                target = root
                modifier = grateful_opinion
                opinion = 50
            }
        }
        change_current_court_grandeur = medium_court_grandeur_gain
        stress_impact = {
            arrogant = minor_stress_impact_gain
            zealous = minor_stress_impact_gain
            just = medium_stress_impact_loss
        }
        ai_chance = {
            base = 15
            modifier = { add = 25 has_trait = just }
            modifier = { add = -25 has_trait = zealous }
            modifier = { add = -10 has_trait = arrogant }
        }
    }

    option = {
        name = enfp_court.0001.d # Kill bastard if you are sadistic or insane
		trait = lunatic_1
		trait = sadistic
        add_internal_flag = dangerous
        trigger = {
			OR = {
            has_trait = sadistic
			has_trait = lunatic_1
			}
        }
        scope:bastardkid = {
            death = {
                death_reason = death_execution
                killer = root
            }
        }

        add_trait = kinslayer_3

        murder_opinion_effect = {
			VICTIM = scope:bastardkid
			MURDERER = root
		}
        
        change_current_court_grandeur = major_court_grandeur_loss
		
		add_tyranny = major_tyranny_gain
        add_dread = major_dread_gain
        
		stress_impact = {
            sadistic = major_stress_impact_loss
            compassionate = major_stress_impact_gain
            just = major_stress_impact_gain
        }
        ai_chance = {
            base = 5
            modifier = { add = 40 has_trait = sadistic }
            modifier = { add = -50 has_trait = compassionate }
			modifier = { add = 40 has_trait = lunatic }
        }
    }

    option = {
        name = enfp_court.0001.e # Banish vassal, nice try buddy
        scope:angrycourtly = {
            banish = yes
        }
        add_prestige = major_prestige_gain
        
		add_tyranny = massive_tyranny_gain
		
		scope:bastardkid = {
			add_opinion = {
                target = root
                modifier = grateful_opinion
                opinion = 50
            }
		}
        change_current_court_grandeur = minor_court_grandeur_gain
		if = {
			limit = { has_government = administrative_government }
			change_influence = major_influence_loss
		}
		else = {
			add_legitimacy = major_legitimacy_loss
		}
        stress_impact = {
            arbitrary = minor_stress_impact_loss
            just = medium_stress_impact_gain
            vengeful = minor_stress_impact_loss
        }
        
        ai_chance = {
            base = 10
            modifier = { add = 50 has_trait = vengeful }
            modifier = { add = -30 has_trait = just }
            modifier = { add = 15 has_trait = arbitrary }
        }
    }

    after = {
        scope:angrycourtly = {
            clear_court_event_participation = yes
        }
        scope:bastardkid = {
            clear_court_event_participation = yes
        }
        hold_court_queue_post_event_effect = yes
    }
}
