﻿DI_personality_trait_randomizer_effect = {
    random_list = {
        10 = { add_trait = lustful }
        10 = { add_trait = chaste }
        10 = { add_trait = gluttonous }
        10 = { add_trait = temperate }
        10 = { add_trait = greedy }
        10 = { add_trait = generous }
        10 = { add_trait = lazy }
        10 = { add_trait = diligent }
        10 = { add_trait = wrathful }
        10 = { add_trait = calm }
        10 = { add_trait = patient }
        10 = { add_trait = impatient }
    }
    random_list = {
        10 = { add_trait = arrogant }
        10 = { add_trait = humble }
        10 = { add_trait = authoritative }
        10 = { add_trait = honorable }
        10 = { add_trait = ruthless }
        10 = { add_trait = deceitful }
        10 = { add_trait = honest }
        10 = { add_trait = craven }
        10 = { add_trait = brave }
        10 = { add_trait = shy }
        10 = { add_trait = gregarious }
        10 = { add_trait = ambitious }
        10 = { add_trait = content }
        10 = { add_trait = arbitrary }
    }
    random_list = {
        10 = { add_trait = just }
        10 = { add_trait = cynical }
        10 = { add_trait = zealous }
        10 = { add_trait = paranoid }
        10 = { add_trait = trusting }
        10 = { add_trait = compassionate }
        10 = { add_trait = rude }
        10 = { add_trait = callous }
        10 = { add_trait = sadistic }
        10 = { add_trait = stubborn }
        10 = { add_trait = fickle }
        10 = { add_trait = vengeful }
        10 = { add_trait = forgiving }
    }
}

DI_clear_personality_traits_effect = {
    if = { limit = { has_trait = lustful } remove_trait = lustful }
    if = { limit = { has_trait = chaste } remove_trait = chaste }
    if = { limit = { has_trait = gluttonous } remove_trait = gluttonous }
    if = { limit = { has_trait = temperate } remove_trait = temperate }
    if = { limit = { has_trait = greedy } remove_trait = greedy }
    if = { limit = { has_trait = generous } remove_trait = generous }
    if = { limit = { has_trait = lazy } remove_trait = lazy }
    if = { limit = { has_trait = diligent } remove_trait = diligent }
    if = { limit = { has_trait = wrathful } remove_trait = wrathful }
    if = { limit = { has_trait = calm } remove_trait = calm }
    if = { limit = { has_trait = patient } remove_trait = patient }
    if = { limit = { has_trait = impatient } remove_trait = impatient }
    if = { limit = { has_trait = arrogant } remove_trait = arrogant }
    if = { limit = { has_trait = humble } remove_trait = humble }
    if = { limit = { has_trait = deceitful } remove_trait = deceitful }
    if = { limit = { has_trait = honest } remove_trait = honest }
    if = { limit = { has_trait = craven } remove_trait = craven }
    if = { limit = { has_trait = brave } remove_trait = brave }
    if = { limit = { has_trait = shy } remove_trait = shy }
    if = { limit = { has_trait = gregarious } remove_trait = gregarious }
    if = { limit = { has_trait = ambitious } remove_trait = ambitious }
    if = { limit = { has_trait = content } remove_trait = content }
    if = { limit = { has_trait = arbitrary } remove_trait = arbitrary }
    if = { limit = { has_trait = just } remove_trait = just }
    if = { limit = { has_trait = cynical } remove_trait = cynical }
    if = { limit = { has_trait = zealous } remove_trait = zealous }
    if = { limit = { has_trait = paranoid } remove_trait = paranoid }
    if = { limit = { has_trait = trusting } remove_trait = trusting }
    if = { limit = { has_trait = compassionate } remove_trait = compassionate }
    if = { limit = { has_trait = callous } remove_trait = callous }
    if = { limit = { has_trait = sadistic } remove_trait = sadistic }
    if = { limit = { has_trait = stubborn } remove_trait = stubborn }
    if = { limit = { has_trait = fickle } remove_trait = fickle }
    if = { limit = { has_trait = vengeful } remove_trait = vengeful }
    if = { limit = { has_trait = forgiving } remove_trait = forgiving }
    if = { limit = { has_trait = honorable } remove_trait = honorable }
    if = { limit = { has_trait = ruthless } remove_trait = ruthless }
    if = { limit = { has_trait = authoritative } remove_trait = authoritative }
    if = { limit = { has_trait = rude } remove_trait = rude }
}

DI_set_weight_0 = {
    change_current_weight = 200
    change_current_weight = -100
}

DI_add_commander_traits_effect = {
    add_trait = logistician
    add_trait = military_engineer
    add_trait = aggressive_attacker
    add_trait = unyielding_defender
    add_trait = forder
    add_trait = flexible_leader
    add_trait = desert_warrior
    add_trait = jungle_stalker
    add_trait = reaver
    add_trait = reckless
    add_trait = holy_warrior
    add_trait = open_terrain_expert
    add_trait = rough_terrain_expert
    add_trait = forest_fighter
    add_trait = cautious_leader
    add_trait = organizer
    if = { limit = { has_trait = logistician } add_trait_xp = { trait = logistician value = 100 } }
    if = { limit = { has_trait = military_engineer } add_trait_xp = { trait = military_engineer value = 100 } }
    if = { limit = { has_trait = aggressive_attacker } add_trait_xp = { trait = aggressive_attacker value = 100 } }
    if = { limit = { has_trait = unyielding_defender } add_trait_xp = { trait = unyielding_defender value = 100 } }
    if = { limit = { has_trait = forder } add_trait_xp = { trait = forder value = 100 } }
    if = { limit = { has_trait = flexible_leader } add_trait_xp = { trait = flexible_leader value = 100 } }
    if = { limit = { has_trait = desert_warrior } add_trait_xp = { trait = desert_warrior value = 100 } }
    if = { limit = { has_trait = jungle_stalker } add_trait_xp = { trait = jungle_stalker value = 100 } }
    if = { limit = { has_trait = reaver } add_trait_xp = { trait = reaver value = 100 } }
    if = { limit = { has_trait = reckless } add_trait_xp = { trait = reckless value = 100 } }
    if = { limit = { has_trait = holy_warrior } add_trait_xp = { trait = holy_warrior value = 100 } }
    if = { limit = { has_trait = open_terrain_expert } add_trait_xp = { trait = open_terrain_expert value = 100 } }
    if = { limit = { has_trait = rough_terrain_expert } add_trait_xp = { trait = rough_terrain_expert value = 100 } }
    if = { limit = { has_trait = forest_fighter } add_trait_xp = { trait = forest_fighter value = 100 } }
    if = { limit = { has_trait = cautious_leader } add_trait_xp = { trait = cautious_leader value = 100 } }
    if = { limit = { has_trait = organizer } add_trait_xp = { trait = organizer value = 100 } }
    # adding trait xp to newly added commander traits so they can progress right away #
    # effect add_trait_xp = {trait = organizer value=100}}`
}

DI_remove_commander_traits_effect = {
    if = { limit = { has_trait = logistician } remove_trait = logistician }
    if = { limit = { has_trait = military_engineer } remove_trait = military_engineer }
    if = { limit = { has_trait = aggressive_attacker } remove_trait = aggressive_attacker }
    if = { limit = { has_trait = unyielding_defender } remove_trait = unyielding_defender }
    if = { limit = { has_trait = forder } remove_trait = forder }
    if = { limit = { has_trait = flexible_leader } remove_trait = flexible_leader }
    if = { limit = { has_trait = desert_warrior } remove_trait = desert_warrior }
    if = { limit = { has_trait = jungle_stalker } remove_trait = jungle_stalker }
    if = { limit = { has_trait = reaver } remove_trait = reaver }
    if = { limit = { has_trait = reckless } remove_trait = reckless }
    if = { limit = { has_trait = holy_warrior } remove_trait = holy_warrior }
    if = { limit = { has_trait = open_terrain_expert } remove_trait = open_terrain_expert }
    if = { limit = { has_trait = rough_terrain_expert } remove_trait = rough_terrain_expert }
    if = { limit = { has_trait = forest_fighter } remove_trait = forest_fighter }
    if = { limit = { has_trait = cautious_leader } remove_trait = cautious_leader }
    if = { limit = { has_trait = organizer } remove_trait = organizer }
}

DI_lifestyle_martial_present_effect = {
    if = { limit = { NOT = { has_perk = bellum_justum_perk } } add_perk = bellum_justum_perk }
    if = { limit = { NOT = { has_perk = parthian_tactics_perk } } add_perk = parthian_tactics_perk }
    if = { limit = { NOT = { has_perk = envelopment_perk } } add_perk = envelopment_perk }
    if = { limit = { NOT = { has_perk = organized_retreat_perk } } add_perk = organized_retreat_perk }
    if = { limit = { NOT = { has_perk = hit_and_run_perk } } add_perk = hit_and_run_perk }
    if = { limit = { NOT = { has_perk = engineered_for_destruction_perk } } add_perk = engineered_for_destruction_perk }
    if = { limit = { NOT = { has_perk = living_off_the_land_perk } } add_perk = living_off_the_land_perk }
    if = { limit = { NOT = { has_perk = sappers_perk } } add_perk = sappers_perk }
    if = { limit = { NOT = { has_perk = strategist_perk } } add_perk = strategist_perk }
    if = { limit = { NOT = { has_perk = serve_the_crown_perk } } add_perk = serve_the_crown_perk }
    if = { limit = { NOT = { has_perk = a_mans_home_perk } } add_perk = a_mans_home_perk }
    if = { limit = { NOT = { has_perk = enduring_hardships_perk } } add_perk = enduring_hardships_perk }
    if = { limit = { NOT = { has_perk = prepared_conscription_perk } } add_perk = prepared_conscription_perk }
    if = { limit = { NOT = { has_perk = strict_organization_perk } } add_perk = strict_organization_perk }
    if = { limit = { NOT = { has_perk = hard_rule_perk } } add_perk = hard_rule_perk }
    if = { limit = { NOT = { has_perk = soldiers_of_lesser_fortune_perk } } add_perk = soldiers_of_lesser_fortune_perk }
    if = { limit = { NOT = { has_perk = absolute_control_perk } } add_perk = absolute_control_perk }
    if = { limit = { NOT = { has_perk = overseer_perk } } add_perk = overseer_perk }
    if = { limit = { NOT = { has_perk = stalwart_leader_perk } } add_perk = stalwart_leader_perk }
    if = { limit = { NOT = { has_perk = courtship_perk } } add_perk = courtship_perk }
    if = { limit = { NOT = { has_perk = promising_prospects_perk } } add_perk = promising_prospects_perk }
    if = { limit = { NOT = { has_perk = loyalty_and_respect_perk } } add_perk = loyalty_and_respect_perk }
    if = { limit = { NOT = { has_perk = chivalric_dominance_perk } } add_perk = chivalric_dominance_perk }
    if = { limit = { NOT = { has_perk = never_back_down_perk } } add_perk = never_back_down_perk }
    if = { limit = { NOT = { has_perk = kingsguard_perk } } add_perk = kingsguard_perk }
    if = { limit = { NOT = { has_perk = peacemaker_perk } } add_perk = peacemaker_perk }
    if = { limit = { NOT = { has_perk = gallant_perk } } add_perk = gallant_perk }
    add_character_modifier = {
        modifier = no_lifestyle_martial
        days = -1
    }
}

DI_lifestyle_diplomacy_present_effect = {
    if = { limit = { NOT = { has_perk = thoughtful_perk } } add_perk = thoughtful_perk }
    if = { limit = { NOT = { has_perk = ducal_conquest_perk } } add_perk = ducal_conquest_perk }
    if = { limit = { NOT = { has_perk = forced_vassalage_perk } } add_perk = forced_vassalage_perk }
    if = { limit = { NOT = { has_perk = adaptive_traditions_perk } } add_perk = adaptive_traditions_perk }
    if = { limit = { NOT = { has_perk = flexible_truces_perk } } add_perk = flexible_truces_perk }
    if = { limit = { NOT = { has_perk = defensive_negotiations_perk } } add_perk = defensive_negotiations_perk }
    if = { limit = { NOT = { has_perk = embassies_perk } } add_perk = embassies_perk }
    if = { limit = { NOT = { has_perk = accomplished_forger_perk } } add_perk = accomplished_forger_perk }
    if = { limit = { NOT = { has_perk = diplomat_perk } } add_perk = diplomat_perk }
    if = { limit = { NOT = { has_perk = benevolent_intent_perk } } add_perk = benevolent_intent_perk }
    if = { limit = { NOT = { has_perk = inspiring_rule_perk } } add_perk = inspiring_rule_perk }
    if = { limit = { NOT = { has_perk = firm_hand_perk } } add_perk = firm_hand_perk }
    if = { limit = { NOT = { has_perk = praetorian_guard_perk } } add_perk = praetorian_guard_perk }
    if = { limit = { NOT = { has_perk = true_ruler_perk } } add_perk = true_ruler_perk }
    if = { limit = { NOT = { has_perk = writing_history_perk } } add_perk = writing_history_perk }
    if = { limit = { NOT = { has_perk = a_life_of_glory_perk } } add_perk = a_life_of_glory_perk }
    if = { limit = { NOT = { has_perk = dignitas_perk } } add_perk = dignitas_perk }
    if = { limit = { NOT = { has_perk = august_perk } } add_perk = august_perk }
    if = { limit = { NOT = { has_perk = befriend_perk } } add_perk = befriend_perk }
    if = { limit = { NOT = { has_perk = confidants_perk } } add_perk = confidants_perk }
    if = { limit = { NOT = { has_perk = flatterer_perk } } add_perk = flatterer_perk }
    if = { limit = { NOT = { has_perk = groomed_to_rule_perk } } add_perk = groomed_to_rule_perk }
    if = { limit = { NOT = { has_perk = familial_familiar_perk } } add_perk = familial_familiar_perk }
    if = { limit = { NOT = { has_perk = thicker_than_water_perk } } add_perk = thicker_than_water_perk }
    if = { limit = { NOT = { has_perk = friendly_counsel_perk } } add_perk = friendly_counsel_perk }
    if = { limit = { NOT = { has_perk = sound_foundations_perk } } add_perk = sound_foundations_perk }
    if = { limit = { NOT = { has_perk = family_man_perk } } add_perk = family_man_perk }
    add_character_modifier = {
        modifier = no_lifestyle_diplomacy
        days = -1
    }
}

DI_lifestyle_stewardship_present_effect = {
    if = { limit = { NOT = { has_perk = golden_obligations_perk } } add_perk = golden_obligations_perk }
    if = { limit = { NOT = { has_perk = heregeld_perk } } add_perk = heregeld_perk }
    if = { limit = { NOT = { has_perk = detailed_ledgers_perk } } add_perk = detailed_ledgers_perk }
    if = { limit = { NOT = { has_perk = war_profiteer_perk } } add_perk = war_profiteer_perk }
    if = { limit = { NOT = { has_perk = fearful_troops_perk } } add_perk = fearful_troops_perk }
    if = { limit = { NOT = { has_perk = it_is_my_domain_perk } } add_perk = it_is_my_domain_perk }
    if = { limit = { NOT = { has_perk = golden_aplomb_perk } } add_perk = golden_aplomb_perk }
    if = { limit = { NOT = { has_perk = at_any_cost_perk } } add_perk = at_any_cost_perk }
    if = { limit = { NOT = { has_perk = avaricious_perk } } add_perk = avaricious_perk }
    if = { limit = { NOT = { has_perk = tax_man_perk } } add_perk = tax_man_perk }
    if = { limit = { NOT = { has_perk = defensive_measures_perk } } add_perk = defensive_measures_perk }
    if = { limit = { NOT = { has_perk = organized_muster_rolls_perk } } add_perk = organized_muster_rolls_perk }
    if = { limit = { NOT = { has_perk = cutting_corners_perk } } add_perk = cutting_corners_perk }
    if = { limit = { NOT = { has_perk = professional_workforce_perk } } add_perk = professional_workforce_perk }
    if = { limit = { NOT = { has_perk = centralization_perk } } add_perk = centralization_perk }
    if = { limit = { NOT = { has_perk = popular_figurehead_perk } } add_perk = popular_figurehead_perk }
    if = { limit = { NOT = { has_perk = divided_attention_perk } } add_perk = divided_attention_perk }
    if = { limit = { NOT = { has_perk = architect_perk } } add_perk = architect_perk }
    if = { limit = { NOT = { has_perk = meritocracy_perk } } add_perk = meritocracy_perk }
    if = { limit = { NOT = { has_perk = chains_of_loyalty_perk } } add_perk = chains_of_loyalty_perk }
    if = { limit = { NOT = { has_perk = likable_perk } } add_perk = likable_perk }
    if = { limit = { NOT = { has_perk = positions_of_power_perk } } add_perk = positions_of_power_perk }
    if = { limit = { NOT = { has_perk = large_levies_perk } } add_perk = large_levies_perk }
    if = { limit = { NOT = { has_perk = soon_forgiven_perk } } add_perk = soon_forgiven_perk }
    if = { limit = { NOT = { has_perk = toe_the_line_perk } } add_perk = toe_the_line_perk }
    if = { limit = { NOT = { has_perk = honored_to_serve_perk } } add_perk = honored_to_serve_perk }
    if = { limit = { NOT = { has_perk = administrator_perk } } add_perk = administrator_perk }
    add_character_modifier = {
        modifier = no_lifestyle_stewardship
        days = -1
    }
}

DI_lifestyle_intrigue_present_effect = {
    if = { limit = { NOT = { has_perk = truth_is_relative_perk } } add_perk = truth_is_relative_perk }
    if = { limit = { NOT = { has_perk = digging_for_dirt_perk } } add_perk = digging_for_dirt_perk }
    if = { limit = { NOT = { has_perk = kidnapper_perk } } add_perk = kidnapper_perk }
    if = { limit = { NOT = { has_perk = court_of_shadows_perk } } add_perk = court_of_shadows_perk }
    if = { limit = { NOT = { has_perk = prepared_for_anything_perk } } add_perk = prepared_for_anything_perk }
    if = { limit = { NOT = { has_perk = swift_execution_perk } } add_perk = swift_execution_perk }
    if = { limit = { NOT = { has_perk = a_job_done_right_perk } } add_perk = a_job_done_right_perk }
    if = { limit = { NOT = { has_perk = twice_schemed_perk } } add_perk = twice_schemed_perk }
    if = { limit = { NOT = { has_perk = schemer_perk } } add_perk = schemer_perk }
    if = { limit = { NOT = { has_perk = like_weed_in_a_garden_perk } } add_perk = like_weed_in_a_garden_perk }
    if = { limit = { NOT = { has_perk = unshackled_lust_perk } } add_perk = unshackled_lust_perk }
    if = { limit = { NOT = { has_perk = subtle_desire_perk } } add_perk = subtle_desire_perk }
    if = { limit = { NOT = { has_perk = mortal_adoration_perk } } add_perk = mortal_adoration_perk }
    if = { limit = { NOT = { has_perk = enticing_opportunity_perk } } add_perk = enticing_opportunity_perk }
    if = { limit = { NOT = { has_perk = home_advantage_perk } } add_perk = home_advantage_perk }
    if = { limit = { NOT = { has_perk = graceful_recovery_perk } } add_perk = graceful_recovery_perk }
    if = { limit = { NOT = { has_perk = smooth_operator_perk } } add_perk = smooth_operator_perk }
    if = { limit = { NOT = { has_perk = seducer_perk } } add_perk = seducer_perk }
    if = { limit = { NOT = { has_perk = dark_insights_perk } } add_perk = dark_insights_perk }
    if = { limit = { NOT = { has_perk = divine_retribution_perk } } add_perk = divine_retribution_perk }
    if = { limit = { NOT = { has_perk = dreadful_perk } } add_perk = dreadful_perk }
    if = { limit = { NOT = { has_perk = thriving_in_chaos_perk } } add_perk = thriving_in_chaos_perk }
    if = { limit = { NOT = { has_perk = malice_implicit_perk } } add_perk = malice_implicit_perk }
    if = { limit = { NOT = { has_perk = fear_tax_perk } } add_perk = fear_tax_perk }
    if = { limit = { NOT = { has_perk = forever_infamous_perk } } add_perk = forever_infamous_perk }
    if = { limit = { NOT = { has_perk = prison_feudal_complex_perk } } add_perk = prison_feudal_complex_perk }
    if = { limit = { NOT = { has_perk = torturer_perk } } add_perk = torturer_perk }
    if = { limit = { NOT = { has_perk = master_of_masses_perk } } add_perk = master_of_masses_perk }
    if = { limit = { NOT = { has_perk = instructed_spies_perk } } add_perk = instructed_spies_perk }
    if = { limit = { NOT = { has_perk = little_birds_perk } } add_perk = little_birds_perk }
    if = { limit = { NOT = { has_perk = convincing_perk } } add_perk = convincing_perk }
    if = { limit = { NOT = { has_perk = innocent_children_perk } } add_perk = innocent_children_perk }
    if = { limit = { NOT = { has_perk = charismatic_perk } } add_perk = charismatic_perk }
    if = { limit = { NOT = { has_perk = omerta_perk } } add_perk = omerta_perk }
    if = { limit = { NOT = { has_perk = sleeper_cells_perk } } add_perk = sleeper_cells_perk }
    if = { limit = { NOT = { has_perk = spider_perk } } add_perk = spider_perk }
    add_character_modifier = {
        modifier = no_lifestyle_intrigue
        days = -1
    }
}

DI_lifestyle_learning_present_effect = {
    if = { limit = { NOT = { has_perk = anatomical_studies_perk } } add_perk = anatomical_studies_perk }
    if = { limit = { NOT = { has_perk = carefree_perk } } add_perk = carefree_perk }
    if = { limit = { NOT = { has_perk = mental_resilience_perk } } add_perk = mental_resilience_perk }
    if = { limit = { NOT = { has_perk = restraint_perk } } add_perk = restraint_perk }
    if = { limit = { NOT = { has_perk = know_thyself_perk } } add_perk = know_thyself_perk }
    if = { limit = { NOT = { has_perk = wash_your_hands_perk } } add_perk = wash_your_hands_perk }
    if = { limit = { NOT = { has_perk = iron_constitution_perk } } add_perk = iron_constitution_perk }
    if = { limit = { NOT = { has_perk = healthy_perk } } add_perk = healthy_perk }
    if = { limit = { NOT = { has_perk = whole_of_body_perk } } add_perk = whole_of_body_perk }
    if = { limit = { NOT = { has_perk = pedagogy_perk } } add_perk = pedagogy_perk }
    if = { limit = { NOT = { has_perk = open_minded_perk } } add_perk = open_minded_perk }
    if = { limit = { NOT = { has_perk = apostate_perk } } add_perk = apostate_perk }
    if = { limit = { NOT = { has_perk = scientific_perk } } add_perk = scientific_perk }
    if = { limit = { NOT = { has_perk = planned_cultivation_perk } } add_perk = planned_cultivation_perk }
    if = { limit = { NOT = { has_perk = scholarly_circles_perk } } add_perk = scholarly_circles_perk }
    if = { limit = { NOT = { has_perk = learn_on_the_job_perk } } add_perk = learn_on_the_job_perk }
    if = { limit = { NOT = { has_perk = sanctioned_loopholes_perk } } add_perk = sanctioned_loopholes_perk }
    if = { limit = { NOT = { has_perk = scholar_perk } } add_perk = scholar_perk }
    if = { limit = { NOT = { has_perk = faithful_perk } } add_perk = faithful_perk }
    if = { limit = { NOT = { has_perk = zealous_proselytizer_perk } } add_perk = zealous_proselytizer_perk }
    if = { limit = { NOT = { has_perk = religious_icon_perk } } add_perk = religious_icon_perk }
    if = { limit = { NOT = { has_perk = prophet_perk } } add_perk = prophet_perk }
    if = { limit = { NOT = { has_perk = clerical_justifications_perk } } add_perk = clerical_justifications_perk }
    if = { limit = { NOT = { has_perk = church_and_state_perk } } add_perk = church_and_state_perk }
    if = { limit = { NOT = { has_perk = radiant_perk } } add_perk = radiant_perk }
    if = { limit = { NOT = { has_perk = defender_of_the_faith_perk } } add_perk = defender_of_the_faith_perk }
    if = { limit = { NOT = { has_perk = theologian_perk } } add_perk = theologian_perk }
    add_character_modifier = {
        modifier = no_lifestyle_learning
        days = -1
    }
}

DI_lifestyle_wandering_present_effect = {
    if = { limit = { NOT = { has_perk = mustering_the_troops_perk } } add_perk = mustering_the_troops_perk }
    if = { limit = { NOT = { has_perk = know_your_land_know_your_people_perk } } add_perk = know_your_land_know_your_people_perk }
    if = { limit = { NOT = { has_perk = no_stone_unturned_perk } } add_perk = no_stone_unturned_perk }
    if = { limit = { NOT = { has_perk = travel_logs_perk } } add_perk = travel_logs_perk }
    if = { limit = { NOT = { has_perk = local_inspection_perk } } add_perk = local_inspection_perk }
    if = { limit = { NOT = { has_perk = local_arbitration_perk } } add_perk = local_arbitration_perk }
    if = { limit = { NOT = { has_perk = realm_charts_perk } } add_perk = realm_charts_perk }
    if = { limit = { NOT = { has_perk = personal_touch_perk } } add_perk = personal_touch_perk }
    if = { limit = { NOT = { has_perk = surveyor_perk } } add_perk = surveyor_perk }
    if = { limit = { NOT = { has_perk = well_prepared_perk } } add_perk = well_prepared_perk }
    if = { limit = { NOT = { has_perk = far_and_wide_perk } } add_perk = far_and_wide_perk }
    if = { limit = { NOT = { has_perk = just_one_more_hill_perk } } add_perk = just_one_more_hill_perk }
    if = { limit = { NOT = { has_perk = roaming_perk } } add_perk = roaming_perk }
    if = { limit = { NOT = { has_perk = of_the_people_perk } } add_perk = of_the_people_perk }
    if = { limit = { NOT = { has_perk = local_hero_perk } } add_perk = local_hero_perk }
    if = { limit = { NOT = { has_perk = travel_companion_perk } } add_perk = travel_companion_perk }
    if = { limit = { NOT = { has_perk = the_home_away_from_home_perk } } add_perk = the_home_away_from_home_perk }
    if = { limit = { NOT = { has_perk = wayfarer_perk } } add_perk = wayfarer_perk }
    if = { limit = { NOT = { has_perk = power_at_home_perk } } add_perk = power_at_home_perk }
    if = { limit = { NOT = { has_perk = mercenary_contacts_perk } } add_perk = mercenary_contacts_perk }
    if = { limit = { NOT = { has_perk = journey_planner_perk } } add_perk = journey_planner_perk }
    if = { limit = { NOT = { has_perk = finally_there_perk } } add_perk = finally_there_perk }
    if = { limit = { NOT = { has_perk = journey_perk } } add_perk = journey_perk }
    if = { limit = { NOT = { has_perk = souvenirs_aplenty_perk } } add_perk = souvenirs_aplenty_perk }
    if = { limit = { NOT = { has_perk = gracious_host_impeccable_guest_perk } } add_perk = gracious_host_impeccable_guest_perk }
    if = { limit = { NOT = { has_perk = been_there_done_that_perk } } add_perk = been_there_done_that_perk }
    if = { limit = { NOT = { has_perk = voyager_perk } } add_perk = voyager_perk }
    add_character_modifier = {
        modifier = no_lifestyle_wandering
        days = -1
    }
}

DI_lifestyle_martial_present_no_effect = {
    if = { limit = { has_perk = bellum_justum_perk } remove_perk = bellum_justum_perk }
    if = { limit = { has_perk = parthian_tactics_perk } remove_perk = parthian_tactics_perk }
    if = { limit = { has_perk = envelopment_perk } remove_perk = envelopment_perk }
    if = { limit = { has_perk = organized_retreat_perk } remove_perk = organized_retreat_perk }
    if = { limit = { has_perk = hit_and_run_perk } remove_perk = hit_and_run_perk }
    if = { limit = { has_perk = engineered_for_destruction_perk } remove_perk = engineered_for_destruction_perk }
    if = { limit = { has_perk = living_off_the_land_perk } remove_perk = living_off_the_land_perk }
    if = { limit = { has_perk = sappers_perk } remove_perk = sappers_perk }
    if = { limit = { has_perk = strategist_perk } remove_perk = strategist_perk }
    if = { limit = { has_perk = serve_the_crown_perk } remove_perk = serve_the_crown_perk }
    if = { limit = { has_perk = a_mans_home_perk } remove_perk = a_mans_home_perk }
    if = { limit = { has_perk = enduring_hardships_perk } remove_perk = enduring_hardships_perk }
    if = { limit = { has_perk = prepared_conscription_perk } remove_perk = prepared_conscription_perk }
    if = { limit = { has_perk = strict_organization_perk } remove_perk = strict_organization_perk }
    if = { limit = { has_perk = hard_rule_perk } remove_perk = hard_rule_perk }
    if = { limit = { has_perk = soldiers_of_lesser_fortune_perk } remove_perk = soldiers_of_lesser_fortune_perk }
    if = { limit = { has_perk = absolute_control_perk } remove_perk = absolute_control_perk }
    if = { limit = { has_perk = overseer_perk } remove_perk = overseer_perk }
    if = { limit = { has_perk = stalwart_leader_perk } remove_perk = stalwart_leader_perk }
    if = { limit = { has_perk = courtship_perk } remove_perk = courtship_perk }
    if = { limit = { has_perk = promising_prospects_perk } remove_perk = promising_prospects_perk }
    if = { limit = { has_perk = loyalty_and_respect_perk } remove_perk = loyalty_and_respect_perk }
    if = { limit = { has_perk = chivalric_dominance_perk } remove_perk = chivalric_dominance_perk }
    if = { limit = { has_perk = never_back_down_perk } remove_perk = never_back_down_perk }
    if = { limit = { has_perk = kingsguard_perk } remove_perk = kingsguard_perk }
    if = { limit = { has_perk = peacemaker_perk } remove_perk = peacemaker_perk }
    if = { limit = { has_perk = gallant_perk } remove_perk = gallant_perk }
    remove_trait = strategist
    remove_trait = overseer
    remove_trait = gallant
    remove_character_modifier = no_lifestyle_martial
}


DI_lifestyle_diplomacy_present_no_effect = {
    if = { limit = { has_perk = thoughtful_perk } remove_perk = thoughtful_perk }
    if = { limit = { has_perk = ducal_conquest_perk } remove_perk = ducal_conquest_perk }
    if = { limit = { has_perk = forced_vassalage_perk } remove_perk = forced_vassalage_perk }
    if = { limit = { has_perk = adaptive_traditions_perk } remove_perk = adaptive_traditions_perk }
    if = { limit = { has_perk = flexible_truces_perk } remove_perk = flexible_truces_perk }
    if = { limit = { has_perk = defensive_negotiations_perk } remove_perk = defensive_negotiations_perk }
    if = { limit = { has_perk = embassies_perk } remove_perk = embassies_perk }
    if = { limit = { has_perk = accomplished_forger_perk } remove_perk = accomplished_forger_perk }
    if = { limit = { has_perk = diplomat_perk } remove_perk = diplomat_perk }
    if = { limit = { has_perk = benevolent_intent_perk } remove_perk = benevolent_intent_perk }
    if = { limit = { has_perk = inspiring_rule_perk } remove_perk = inspiring_rule_perk }
    if = { limit = { has_perk = firm_hand_perk } remove_perk = firm_hand_perk }
    if = { limit = { has_perk = praetorian_guard_perk } remove_perk = praetorian_guard_perk }
    if = { limit = { has_perk = true_ruler_perk } remove_perk = true_ruler_perk }
    if = { limit = { has_perk = writing_history_perk } remove_perk = writing_history_perk }
    if = { limit = { has_perk = a_life_of_glory_perk } remove_perk = a_life_of_glory_perk }
    if = { limit = { has_perk = dignitas_perk } remove_perk = dignitas_perk }
    if = { limit = { has_perk = august_perk } remove_perk = august_perk }
    if = { limit = { has_perk = befriend_perk } remove_perk = befriend_perk }
    if = { limit = { has_perk = confidants_perk } remove_perk = confidants_perk }
    if = { limit = { has_perk = flatterer_perk } remove_perk = flatterer_perk }
    if = { limit = { has_perk = groomed_to_rule_perk } remove_perk = groomed_to_rule_perk }
    if = { limit = { has_perk = familial_familiar_perk } remove_perk = familial_familiar_perk }
    if = { limit = { has_perk = thicker_than_water_perk } remove_perk = thicker_than_water_perk }
    if = { limit = { has_perk = friendly_counsel_perk } remove_perk = friendly_counsel_perk }
    if = { limit = { has_perk = sound_foundations_perk } remove_perk = sound_foundations_perk }
    if = { limit = { has_perk = family_man_perk } remove_perk = family_man_perk }
    remove_trait = diplomat
    remove_trait = family_first
    remove_trait = august
    remove_character_modifier = no_lifestyle_diplomacy
}

DI_lifestyle_stewardship_present_no_effect = {
    if = { limit = { has_perk = golden_obligations_perk } remove_perk = golden_obligations_perk }
    if = { limit = { has_perk = heregeld_perk } remove_perk = heregeld_perk }
    if = { limit = { has_perk = detailed_ledgers_perk } remove_perk = detailed_ledgers_perk }
    if = { limit = { has_perk = war_profiteer_perk } remove_perk = war_profiteer_perk }
    if = { limit = { has_perk = fearful_troops_perk } remove_perk = fearful_troops_perk }
    if = { limit = { has_perk = it_is_my_domain_perk } remove_perk = it_is_my_domain_perk }
    if = { limit = { has_perk = golden_aplomb_perk } remove_perk = golden_aplomb_perk }
    if = { limit = { has_perk = at_any_cost_perk } remove_perk = at_any_cost_perk }
    if = { limit = { has_perk = avaricious_perk } remove_perk = avaricious_perk }
    if = { limit = { has_perk = tax_man_perk } remove_perk = tax_man_perk }
    if = { limit = { has_perk = defensive_measures_perk } remove_perk = defensive_measures_perk }
    if = { limit = { has_perk = organized_muster_rolls_perk } remove_perk = organized_muster_rolls_perk }
    if = { limit = { has_perk = cutting_corners_perk } remove_perk = cutting_corners_perk }
    if = { limit = { has_perk = professional_workforce_perk } remove_perk = professional_workforce_perk }
    if = { limit = { has_perk = centralization_perk } remove_perk = centralization_perk }
    if = { limit = { has_perk = popular_figurehead_perk } remove_perk = popular_figurehead_perk }
    if = { limit = { has_perk = divided_attention_perk } remove_perk = divided_attention_perk }
    if = { limit = { has_perk = architect_perk } remove_perk = architect_perk }
    if = { limit = { has_perk = meritocracy_perk } remove_perk = meritocracy_perk }
    if = { limit = { has_perk = chains_of_loyalty_perk } remove_perk = chains_of_loyalty_perk }
    if = { limit = { has_perk = likable_perk } remove_perk = likable_perk }
    if = { limit = { has_perk = positions_of_power_perk } remove_perk = positions_of_power_perk }
    if = { limit = { has_perk = large_levies_perk } remove_perk = large_levies_perk }
    if = { limit = { has_perk = soon_forgiven_perk } remove_perk = soon_forgiven_perk }
    if = { limit = { has_perk = toe_the_line_perk } remove_perk = toe_the_line_perk }
    if = { limit = { has_perk = honored_to_serve_perk } remove_perk = honored_to_serve_perk }
    if = { limit = { has_perk = administrator_perk } remove_perk = administrator_perk }
    remove_trait = architect
    remove_trait = administrator
    remove_trait = avaricious
    remove_character_modifier = no_lifestyle_stewardship
}

DI_lifestyle_intrigue_present_no_effect = {
    if = { limit = { has_perk = truth_is_relative_perk } remove_perk = truth_is_relative_perk }
    if = { limit = { has_perk = digging_for_dirt_perk } remove_perk = digging_for_dirt_perk }
    if = { limit = { has_perk = kidnapper_perk } remove_perk = kidnapper_perk }
    if = { limit = { has_perk = court_of_shadows_perk } remove_perk = court_of_shadows_perk }
    if = { limit = { has_perk = prepared_for_anything_perk } remove_perk = prepared_for_anything_perk }
    if = { limit = { has_perk = swift_execution_perk } remove_perk = swift_execution_perk }
    if = { limit = { has_perk = a_job_done_right_perk } remove_perk = a_job_done_right_perk }
    if = { limit = { has_perk = twice_schemed_perk } remove_perk = twice_schemed_perk }
    if = { limit = { has_perk = schemer_perk } remove_perk = schemer_perk }
    if = { limit = { has_perk = like_weed_in_a_garden_perk } remove_perk = like_weed_in_a_garden_perk }
    if = { limit = { has_perk = unshackled_lust_perk } remove_perk = unshackled_lust_perk }
    if = { limit = { has_perk = subtle_desire_perk } remove_perk = subtle_desire_perk }
    if = { limit = { has_perk = mortal_adoration_perk } remove_perk = mortal_adoration_perk }
    if = { limit = { has_perk = enticing_opportunity_perk } remove_perk = enticing_opportunity_perk }
    if = { limit = { has_perk = home_advantage_perk } remove_perk = home_advantage_perk }
    if = { limit = { has_perk = graceful_recovery_perk } remove_perk = graceful_recovery_perk }
    if = { limit = { has_perk = smooth_operator_perk } remove_perk = smooth_operator_perk }
    if = { limit = { has_perk = seducer_perk } remove_perk = seducer_perk }
    if = { limit = { has_perk = dark_insights_perk } remove_perk = dark_insights_perk }
    if = { limit = { has_perk = divine_retribution_perk } remove_perk = divine_retribution_perk }
    if = { limit = { has_perk = dreadful_perk } remove_perk = dreadful_perk }
    if = { limit = { has_perk = thriving_in_chaos_perk } remove_perk = thriving_in_chaos_perk }
    if = { limit = { has_perk = malice_implicit_perk } remove_perk = malice_implicit_perk }
    if = { limit = { has_perk = fear_tax_perk } remove_perk = fear_tax_perk }
    if = { limit = { has_perk = forever_infamous_perk } remove_perk = forever_infamous_perk }
    if = { limit = { has_perk = prison_feudal_complex_perk } remove_perk = prison_feudal_complex_perk }
    if = { limit = { has_perk = torturer_perk } remove_perk = torturer_perk }
    if = { limit = { has_perk = master_of_masses_perk } remove_perk = master_of_masses_perk }
    if = { limit = { has_perk = instructed_spies_perk } remove_perk = instructed_spies_perk }
    if = { limit = { has_perk = little_birds_perk } remove_perk = little_birds_perk }
    if = { limit = { has_perk = convincing_perk } remove_perk = convincing_perk }
    if = { limit = { has_perk = innocent_children_perk } remove_perk = innocent_children_perk }
    if = { limit = { has_perk = charismatic_perk } remove_perk = charismatic_perk }
    if = { limit = { has_perk = omerta_perk } remove_perk = omerta_perk }
    if = { limit = { has_perk = sleeper_cells_perk } remove_perk = sleeper_cells_perk }
    if = { limit = { has_perk = spider_perk } remove_perk = spider_perk }
    remove_trait = schemer
    remove_trait = seducer
    remove_trait = torturer
    remove_character_modifier = no_lifestyle_intrigue
}

DI_lifestyle_learning_present_no_effect = {
    if = { limit = { has_perk = anatomical_studies_perk } remove_perk = anatomical_studies_perk }
    if = { limit = { has_perk = carefree_perk } remove_perk = carefree_perk }
    if = { limit = { has_perk = mental_resilience_perk } remove_perk = mental_resilience_perk }
    if = { limit = { has_perk = restraint_perk } remove_perk = restraint_perk }
    if = { limit = { has_perk = know_thyself_perk } remove_perk = know_thyself_perk }
    if = { limit = { has_perk = wash_your_hands_perk } remove_perk = wash_your_hands_perk }
    if = { limit = { has_perk = iron_constitution_perk } remove_perk = iron_constitution_perk }
    if = { limit = { has_perk = healthy_perk } remove_perk = healthy_perk }
    if = { limit = { has_perk = whole_of_body_perk } remove_perk = whole_of_body_perk }
    if = { limit = { has_perk = pedagogy_perk } remove_perk = pedagogy_perk }
    if = { limit = { has_perk = open_minded_perk } remove_perk = open_minded_perk }
    if = { limit = { has_perk = apostate_perk } remove_perk = apostate_perk }
    if = { limit = { has_perk = scientific_perk } remove_perk = scientific_perk }
    if = { limit = { has_perk = planned_cultivation_perk } remove_perk = planned_cultivation_perk }
    if = { limit = { has_perk = scholarly_circles_perk } remove_perk = scholarly_circles_perk }
    if = { limit = { has_perk = learn_on_the_job_perk } remove_perk = learn_on_the_job_perk }
    if = { limit = { has_perk = sanctioned_loopholes_perk } remove_perk = sanctioned_loopholes_perk }
    if = { limit = { has_perk = scholar_perk } remove_perk = scholar_perk }
    if = { limit = { has_perk = faithful_perk } remove_perk = faithful_perk }
    if = { limit = { has_perk = zealous_proselytizer_perk } remove_perk = zealous_proselytizer_perk }
    if = { limit = { has_perk = religious_icon_perk } remove_perk = religious_icon_perk }
    if = { limit = { has_perk = prophet_perk } remove_perk = prophet_perk }
    if = { limit = { has_perk = clerical_justifications_perk } remove_perk = clerical_justifications_perk }
    if = { limit = { has_perk = church_and_state_perk } remove_perk = church_and_state_perk }
    if = { limit = { has_perk = radiant_perk } remove_perk = radiant_perk }
    if = { limit = { has_perk = defender_of_the_faith_perk } remove_perk = defender_of_the_faith_perk }
    if = { limit = { has_perk = theologian_perk } remove_perk = theologian_perk }
    remove_trait = whole_of_body
    remove_trait = scholar
    remove_trait = theologian
    remove_character_modifier = no_lifestyle_learning
}

DI_lifestyle_wandering_present_no_effect = {
    if = { limit = { has_perk = mustering_the_troops_perk } remove_perk = mustering_the_troops_perk }
    if = { limit = { has_perk = know_your_land_know_your_people_perk } remove_perk = know_your_land_know_your_people_perk }
    if = { limit = { has_perk = no_stone_unturned_perk } remove_perk = no_stone_unturned_perk }
    if = { limit = { has_perk = travel_logs_perk } remove_perk = travel_logs_perk }
    if = { limit = { has_perk = local_inspection_perk } remove_perk = local_inspection_perk }
    if = { limit = { has_perk = local_arbitration_perk } remove_perk = local_arbitration_perk }
    if = { limit = { has_perk = realm_charts_perk } remove_perk = realm_charts_perk }
    if = { limit = { has_perk = personal_touch_perk } remove_perk = personal_touch_perk }
    if = { limit = { has_perk = surveyor_perk } remove_perk = surveyor_perk }
    if = { limit = { has_perk = well_prepared_perk } remove_perk = well_prepared_perk }
    if = { limit = { has_perk = far_and_wide_perk } remove_perk = far_and_wide_perk }
    if = { limit = { has_perk = just_one_more_hill_perk } remove_perk = just_one_more_hill_perk }
    if = { limit = { has_perk = roaming_perk } remove_perk = roaming_perk }
    if = { limit = { has_perk = of_the_people_perk } remove_perk = of_the_people_perk }
    if = { limit = { has_perk = local_hero_perk } remove_perk = local_hero_perk }
    if = { limit = { has_perk = travel_companion_perk } remove_perk = travel_companion_perk }
    if = { limit = { has_perk = the_home_away_from_home_perk } remove_perk = the_home_away_from_home_perk }
    if = { limit = { has_perk = wayfarer_perk } remove_perk = wayfarer_perk }
    if = { limit = { has_perk = power_at_home_perk } remove_perk = power_at_home_perk }
    if = { limit = { has_perk = mercenary_contacts_perk } remove_perk = mercenary_contacts_perk }
    if = { limit = { has_perk = journey_planner_perk } remove_perk = journey_planner_perk }
    if = { limit = { has_perk = finally_there_perk } remove_perk = finally_there_perk }
    if = { limit = { has_perk = journey_perk } remove_perk = journey_perk }
    if = { limit = { has_perk = souvenirs_aplenty_perk } remove_perk = souvenirs_aplenty_perk }
    if = { limit = { has_perk = gracious_host_impeccable_guest_perk } remove_perk = gracious_host_impeccable_guest_perk }
    if = { limit = { has_perk = been_there_done_that_perk } remove_perk = been_there_done_that_perk }
    if = { limit = { has_perk = voyager_perk } remove_perk = voyager_perk }
    remove_trait = lifestyle_surveyor
    remove_trait = lifestyle_wayfarer
    remove_trait = lifestyle_voyager
    remove_character_modifier = no_lifestyle_wandering
}

DI_eliminated_health_problem_effect = {
    if = { limit = { has_trait = drunkard } remove_trait = drunkard }
    if = { limit = { has_trait = depressed_1 } remove_trait = depressed_1 }
    if = { limit = { has_trait = depressed_genetic } remove_trait = depressed_genetic }
    if = { limit = { has_trait = lunatic_1 } remove_trait = lunatic_1 }
    if = { limit = { has_trait = lunatic_genetic } remove_trait = lunatic_genetic }
    if = { limit = { has_trait = possessed_1 } remove_trait = possessed_1 }
    if = { limit = { has_trait = possessed_genetic } remove_trait = possessed_genetic }
    if = { limit = { has_trait = ill } remove_trait = ill }
    if = { limit = { has_trait = pneumonic } remove_trait = pneumonic }
    if = { limit = { has_trait = great_pox } remove_trait = great_pox }
    if = { limit = { has_trait = early_great_pox } remove_trait = early_great_pox }
    if = { limit = { has_trait = lovers_pox } remove_trait = lovers_pox }
    if = { limit = { has_trait = leper } remove_trait = leper }
    if = { limit = { has_trait = wounded_1 } remove_trait = wounded_1 }
    if = { limit = { has_trait = wounded_2 } remove_trait = wounded_2 }
    if = { limit = { has_trait = wounded_3 } remove_trait = wounded_3 }
    if = { limit = { has_trait = maimed } remove_trait = maimed }
    if = { limit = { has_trait = one_eyed } remove_trait = one_eyed }
    if = { limit = { has_trait = one_legged } remove_trait = one_legged }
    if = { limit = { has_trait = disfigured } remove_trait = disfigured }
    if = { limit = { has_trait = infirm } remove_trait = infirm }
    if = { limit = { has_trait = incapable } remove_trait = incapable }
    if = { limit = { has_trait = gout_ridden } remove_trait = gout_ridden }
    if = { limit = { has_trait = consumption } remove_trait = consumption }
    if = { limit = { has_trait = cancer } remove_trait = cancer }
    if = { limit = { has_trait = typhus } remove_trait = typhus }
    if = { limit = { has_trait = bubonic_plague } remove_trait = bubonic_plague }
    if = { limit = { has_trait = smallpox } remove_trait = smallpox }
    if = { limit = { has_trait = sickly } remove_trait = sickly }
    if = { limit = { has_trait = scarred } remove_trait = scarred }
    if = { limit = { has_trait = eunuch_1 } remove_trait = eunuch_1 }
    if = { limit = { has_trait = beardless_eunuch } remove_trait = beardless_eunuch }
    if = { limit = { has_trait = blind } remove_trait = blind }
    if = { limit = { has_trait = clubfooted } remove_trait = clubfooted }
    if = { limit = { has_trait = hunchbacked } remove_trait = hunchbacked }
    if = { limit = { has_trait = lisping } remove_trait = lisping }
    if = { limit = { has_trait = stuttering } remove_trait = stuttering }
    if = { limit = { has_trait = dwarf } remove_trait = dwarf }
    if = { limit = { has_trait = giant } remove_trait = giant }
    if = { limit = { has_trait = inbred } remove_trait = inbred }
    if = { limit = { has_trait = weak } remove_trait = weak }
    if = { limit = { has_trait = dull } remove_trait = dull }
    if = { limit = { has_trait = impotent } remove_trait = impotent }
    if = { limit = { has_trait = spindly } remove_trait = spindly }
    if = { limit = { has_trait = scaly } remove_trait = scaly }
    if = { limit = { has_trait = wheezing } remove_trait = wheezing }
    if = { limit = { has_trait = bleeder } remove_trait = bleeder }
    if = { limit = { has_trait = infertile } remove_trait = infertile }

    hidden_effect = {
        if = {
            limit = {
                has_character_flag = will_get_scar
            }
            remove_character_flag = will_get_scar
        }
        if = {
            limit = {
                has_character_modifier = infected_wound_modifier
            }
            remove_character_modifier = infected_wound_modifier
        }

        if = { limit = { has_character_flag = had_event_harm_0002 } remove_character_flag = had_event_harm_0002 }
        if = { limit = { has_character_flag = had_event_harm_0003 } remove_character_flag = had_event_harm_0003 }
        if = { limit = { has_character_flag = had_event_harm_0501 } remove_character_flag = had_event_harm_0501 }
        if = { limit = { has_character_flag = had_event_harm_0502 } remove_character_flag = had_event_harm_0502 }
        if = { limit = { has_character_flag = had_event_harm_0511 } remove_character_flag = had_event_harm_0511 }
        if = { limit = { has_character_flag = had_event_harm_0512 } remove_character_flag = had_event_harm_0512 }
        if = { limit = { has_character_flag = had_event_harm_0521 } remove_character_flag = had_event_harm_0521 }
        if = { limit = { has_character_flag = had_event_harm_0522 } remove_character_flag = had_event_harm_0522 }
        if = { limit = { has_character_flag = had_event_harm_0531 } remove_character_flag = had_event_harm_0531 }
        if = { limit = { has_character_flag = had_event_harm_0532 } remove_character_flag = had_event_harm_0532 }
        if = { limit = { has_character_flag = had_event_harm_0541 } remove_character_flag = had_event_harm_0541 }
        if = { limit = { has_character_flag = had_event_harm_0542 } remove_character_flag = had_event_harm_0542 }
        if = { limit = { has_character_flag = had_event_harm_0551 } remove_character_flag = had_event_harm_0551 }
        if = { limit = { has_character_flag = had_event_harm_0552 } remove_character_flag = had_event_harm_0552 }
        if = { limit = { has_character_flag = had_event_harm_0561 } remove_character_flag = had_event_harm_0561 }
        if = { limit = { has_character_flag = had_event_harm_0562 } remove_character_flag = had_event_harm_0562 }
        if = { limit = { has_character_flag = had_event_harm_0571 } remove_character_flag = had_event_harm_0571 }
        if = { limit = { has_character_flag = had_event_harm_0572 } remove_character_flag = had_event_harm_0572 }
        if = { limit = { has_character_flag = had_event_harm_0581 } remove_character_flag = had_event_harm_0581 }
        if = { limit = { has_character_flag = had_event_harm_0582 } remove_character_flag = had_event_harm_0582 }
        if = { limit = { has_character_flag = had_event_harm_0591 } remove_character_flag = had_event_harm_0591 }
        if = { limit = { has_character_flag = had_event_harm_0592 } remove_character_flag = had_event_harm_0592 }
        if = { limit = { has_character_flag = had_event_harm_0601 } remove_character_flag = had_event_harm_0601 }
        if = { limit = { has_character_flag = had_event_harm_0602 } remove_character_flag = had_event_harm_0602 }
        if = { limit = { has_character_flag = had_event_harm_0611 } remove_character_flag = had_event_harm_0611 }
        if = { limit = { has_character_flag = had_event_harm_0612 } remove_character_flag = had_event_harm_0612 }
        if = { limit = { has_character_flag = had_event_harm_0621 } remove_character_flag = had_event_harm_0621 }
        if = { limit = { has_character_flag = had_event_harm_0622 } remove_character_flag = had_event_harm_0622 }
        if = { limit = { has_character_flag = had_event_harm_0631 } remove_character_flag = had_event_harm_0631 }
        if = { limit = { has_character_flag = had_event_harm_0632 } remove_character_flag = had_event_harm_0632 }
        if = { limit = { has_character_flag = had_event_harm_0641 } remove_character_flag = had_event_harm_0641 }
        if = { limit = { has_character_flag = had_event_harm_0642 } remove_character_flag = had_event_harm_0642 }
        if = { limit = { has_character_flag = had_event_harm_1001 } remove_character_flag = had_event_harm_1001 }
        if = { limit = { has_character_flag = had_event_harm_1002 } remove_character_flag = had_event_harm_1002 }
        if = { limit = { has_character_flag = had_event_harm_1011 } remove_character_flag = had_event_harm_1011 }
        if = { limit = { has_character_flag = had_event_harm_1012 } remove_character_flag = had_event_harm_1012 }
        if = { limit = { has_character_flag = had_event_harm_1021 } remove_character_flag = had_event_harm_1021 }
        if = { limit = { has_character_flag = had_event_harm_1022 } remove_character_flag = had_event_harm_1022 }
        if = { limit = { has_character_flag = had_event_harm_1031 } remove_character_flag = had_event_harm_1031 }
        if = { limit = { has_character_flag = had_event_harm_1032 } remove_character_flag = had_event_harm_1032 }
        if = { limit = { has_character_flag = had_event_harm_1041 } remove_character_flag = had_event_harm_1041 }
        if = { limit = { has_character_flag = had_event_harm_1042 } remove_character_flag = had_event_harm_1042 }
        if = { limit = { has_character_flag = had_event_harm_1051 } remove_character_flag = had_event_harm_1051 }
        if = { limit = { has_character_flag = had_event_harm_1052 } remove_character_flag = had_event_harm_1052 }
        if = { limit = { has_character_flag = had_event_harm_1061 } remove_character_flag = had_event_harm_1061 }
        if = { limit = { has_character_flag = had_event_harm_1062 } remove_character_flag = had_event_harm_1062 }
        if = { limit = { has_character_flag = had_event_harm_1071 } remove_character_flag = had_event_harm_1071 }
        if = { limit = { has_character_flag = had_event_harm_1072 } remove_character_flag = had_event_harm_1072 }
        if = { limit = { has_character_flag = had_event_harm_1081 } remove_character_flag = had_event_harm_1081 }
        if = { limit = { has_character_flag = had_event_harm_1082 } remove_character_flag = had_event_harm_1082 }
        if = { limit = { has_character_flag = had_event_harm_1091 } remove_character_flag = had_event_harm_1091 }
        if = { limit = { has_character_flag = had_event_harm_1092 } remove_character_flag = had_event_harm_1092 }
        if = { limit = { has_character_flag = had_event_harm_1101 } remove_character_flag = had_event_harm_1101 }
        if = { limit = { has_character_flag = had_event_harm_1102 } remove_character_flag = had_event_harm_1102 }
        if = { limit = { has_character_flag = had_event_harm_1111 } remove_character_flag = had_event_harm_1111 }
        if = { limit = { has_character_flag = had_event_harm_1112 } remove_character_flag = had_event_harm_1112 }
        remove_all_character_modifier_instances = infected_wound_modifier
        remove_all_character_modifier_instances = gangrene_modifier
        remove_all_character_modifier_instances = rejected_from_marriage_bed_modifier
        remove_all_character_modifier_instances = safe_disease_treatment_failure_modifier
        remove_all_character_modifier_instances = risky_disease_treatment_failure_modifier
        remove_all_character_modifier_instances = safe_wound_treatment_failure_modifier
        remove_all_character_modifier_instances = risky_wound_treatment_failure_modifier
        remove_all_character_modifier_instances = chastised_physician_modifier
        remove_all_character_modifier_instances = exhausted_modifier
        remove_all_character_modifier_instances = low_social_energy_modifier
        remove_all_character_modifier_instances = lunatic_made_of_glass_modifier
        remove_all_character_modifier_instances = lunatic_bat_ravings_modifier
        remove_all_character_modifier_instances = wounds_quickly_tended_to_modifier
        remove_all_character_modifier_instances = drank_water_modifier
        remove_all_character_modifier_instances = almost_drowned_modifier
        remove_all_character_modifier_instances = malnourished_modifier
        remove_all_character_modifier_instances = obese_modifier
        remove_all_character_modifier_instances = gaining_weight_modifier
        remove_all_character_modifier_instances = losing_weight_modifier
        remove_all_character_modifier_instances = travel_choke_on_a_bone_modifier
        remove_all_character_modifier_instances = travel_sore_muscles_modifier
        remove_all_character_modifier_instances = travel_rich_dining_modifier
        remove_all_character_modifier_instances = travel_mild_frostbite_modifier
        remove_all_character_modifier_instances = travel_severe_frostbite_modifier
        remove_all_character_modifier_instances = travel_ate_poisonous_plant_modifier
        remove_all_character_modifier_instances = travel_touched_poisonous_plant_modifier
        remove_all_character_modifier_instances = drained_by_mosquitoes_modifier
        remove_all_character_modifier_instances = emaciated_modifier
        remove_all_character_modifier_instances = travel_stealing_food_modifier
    }
}

DI_remove_health_conflict_effect = {
    if = { limit = { has_trait = beauty_bad_1 } remove_trait = beauty_bad_1 }
    if = { limit = { has_trait = beauty_bad_2 } remove_trait = beauty_bad_2 }
    if = { limit = { has_trait = beauty_bad_3 } remove_trait = beauty_bad_3 }
    if = { limit = { has_trait = beauty_good_1 } remove_trait = beauty_good_1 }
    if = { limit = { has_trait = beauty_good_2 } remove_trait = beauty_good_2 }
    if = { limit = { has_trait = intellect_bad_1 } remove_trait = intellect_bad_1 }
    if = { limit = { has_trait = intellect_bad_2 } remove_trait = intellect_bad_2 }
    if = { limit = { has_trait = intellect_bad_3 } remove_trait = intellect_bad_3 }
    if = { limit = { has_trait = intellect_good_1 } remove_trait = intellect_good_1 }
    if = { limit = { has_trait = intellect_good_2 } remove_trait = intellect_good_2 }
    if = { limit = { has_trait = physique_bad_1 } remove_trait = physique_bad_1 }
    if = { limit = { has_trait = physique_bad_2 } remove_trait = physique_bad_2 }
    if = { limit = { has_trait = physique_bad_3 } remove_trait = physique_bad_3 }
    if = { limit = { has_trait = physique_good_1 } remove_trait = physique_good_1 }
    if = { limit = { has_trait = physique_good_2 } remove_trait = physique_good_2 }
    if = { limit = { has_trait = clubfooted } remove_trait = clubfooted }
    if = { limit = { has_trait = hunchbacked } remove_trait = hunchbacked }
    if = { limit = { has_trait = lisping } remove_trait = lisping }
    if = { limit = { has_trait = stuttering } remove_trait = stuttering }
    if = { limit = { has_trait = dwarf } remove_trait = dwarf }
    if = { limit = { has_trait = giant } remove_trait = giant }
    if = { limit = { has_trait = inbred } remove_trait = inbred }
    if = { limit = { has_trait = weak } remove_trait = weak }
    if = { limit = { has_trait = dull } remove_trait = dull }
    if = { limit = { has_trait = impotent } remove_trait = impotent }
    if = { limit = { has_trait = spindly } remove_trait = spindly }
    if = { limit = { has_trait = scaly } remove_trait = scaly }
    if = { limit = { has_trait = wheezing } remove_trait = wheezing }
    if = { limit = { has_trait = bleeder } remove_trait = bleeder }
    if = { limit = { has_trait = infertile } remove_trait = infertile }
}

#remove health conflicts other than worst traits (for bad genes present only)
DI_remove_health_conflict_forbadgene_effect = {
    if = { limit = { has_trait = beauty_bad_1 } remove_trait = beauty_bad_1 }
    if = { limit = { has_trait = beauty_bad_2 } remove_trait = beauty_bad_2 }
    if = { limit = { has_trait = beauty_good_1 } remove_trait = beauty_good_1 }
    if = { limit = { has_trait = beauty_good_2 } remove_trait = beauty_good_2 }
    if = { limit = { has_trait = intellect_bad_1 } remove_trait = intellect_bad_1 }
    if = { limit = { has_trait = intellect_bad_2 } remove_trait = intellect_bad_2 }
    if = { limit = { has_trait = intellect_good_1 } remove_trait = intellect_good_1 }
    if = { limit = { has_trait = intellect_good_2 } remove_trait = intellect_good_2 }
    if = { limit = { has_trait = physique_bad_1 } remove_trait = physique_bad_1 }
    if = { limit = { has_trait = physique_bad_2 } remove_trait = physique_bad_2 }
    if = { limit = { has_trait = physique_good_1 } remove_trait = physique_good_1 }
    if = { limit = { has_trait = physique_good_2 } remove_trait = physique_good_2 }
}

#add best education traits
DI_add_education_traits_effect = {
    if = { limit = { NOT = { has_trait = education_learning_5 } } add_trait = education_learning_5 }
    if = { limit = { NOT = { has_trait = education_intrigue_5 } } add_trait = education_intrigue_5 }
    if = { limit = { NOT = { has_trait = education_diplomacy_5 } } add_trait = education_diplomacy_5 }
    if = { limit = { NOT = { has_trait = education_stewardship_5 } } add_trait = education_stewardship_5 }
    if = { limit = { NOT = { has_trait = education_martial_5 } } add_trait = education_martial_5 }
}

#remove all Education traits
DI_remove_education_traits_effect = {
    if = { limit = { has_trait = education_learning_1 } remove_trait = education_learning_1 }
    if = { limit = { has_trait = education_learning_2 } remove_trait = education_learning_2 }
    if = { limit = { has_trait = education_learning_3 } remove_trait = education_learning_3 }
    if = { limit = { has_trait = education_learning_4 } remove_trait = education_learning_4 }
    if = { limit = { has_trait = education_learning_5 } remove_trait = education_learning_5 }
    if = { limit = { has_trait = education_intrigue_1 } remove_trait = education_intrigue_1 }
    if = { limit = { has_trait = education_intrigue_2 } remove_trait = education_intrigue_2 }
    if = { limit = { has_trait = education_intrigue_3 } remove_trait = education_intrigue_3 }
    if = { limit = { has_trait = education_intrigue_4 } remove_trait = education_intrigue_4 }
    if = { limit = { has_trait = education_intrigue_5 } remove_trait = education_intrigue_5 }
    if = { limit = { has_trait = education_diplomacy_1 } remove_trait = education_diplomacy_1 }
    if = { limit = { has_trait = education_diplomacy_2 } remove_trait = education_diplomacy_2 }
    if = { limit = { has_trait = education_diplomacy_3 } remove_trait = education_diplomacy_3 }
    if = { limit = { has_trait = education_diplomacy_4 } remove_trait = education_diplomacy_4 }
    if = { limit = { has_trait = education_diplomacy_5 } remove_trait = education_diplomacy_5 }
    if = { limit = { has_trait = education_stewardship_1 } remove_trait = education_stewardship_1 }
    if = { limit = { has_trait = education_stewardship_2 } remove_trait = education_stewardship_2 }
    if = { limit = { has_trait = education_stewardship_3 } remove_trait = education_stewardship_3 }
    if = { limit = { has_trait = education_stewardship_4 } remove_trait = education_stewardship_4 }
    if = { limit = { has_trait = education_stewardship_5 } remove_trait = education_stewardship_5 }
    if = { limit = { has_trait = education_martial_1 } remove_trait = education_martial_1 }
    if = { limit = { has_trait = education_martial_2 } remove_trait = education_martial_2 }
    if = { limit = { has_trait = education_martial_3 } remove_trait = education_martial_3 }
    if = { limit = { has_trait = education_martial_4 } remove_trait = education_martial_4 }
    if = { limit = { has_trait = education_martial_5 } remove_trait = education_martial_5 }
}

#boost education traits to best level
DI_boost_education_traits_effect = {
    if = { limit = { has_trait = education_learning_1 } remove_trait = education_learning_1 add_trait = education_learning_5 }
    if = { limit = { has_trait = education_learning_2 } remove_trait = education_learning_2 add_trait = education_learning_5 }
    if = { limit = { has_trait = education_learning_3 } remove_trait = education_learning_3 add_trait = education_learning_5 }
    if = { limit = { has_trait = education_learning_4 } remove_trait = education_learning_4 add_trait = education_learning_5 }
    if = { limit = { has_trait = education_intrigue_1 } remove_trait = education_intrigue_1 add_trait = education_intrigue_5 }
    if = { limit = { has_trait = education_intrigue_2 } remove_trait = education_intrigue_2 add_trait = education_intrigue_5 }
    if = { limit = { has_trait = education_intrigue_3 } remove_trait = education_intrigue_3 add_trait = education_intrigue_5 }
    if = { limit = { has_trait = education_intrigue_4 } remove_trait = education_intrigue_4 add_trait = education_intrigue_5 }
    if = { limit = { has_trait = education_diplomacy_1 } remove_trait = education_diplomacy_1 add_trait = education_diplomacy_5 }
    if = { limit = { has_trait = education_diplomacy_2 } remove_trait = education_diplomacy_2 add_trait = education_diplomacy_5 }
    if = { limit = { has_trait = education_diplomacy_3 } remove_trait = education_diplomacy_3 add_trait = education_diplomacy_5 }
    if = { limit = { has_trait = education_diplomacy_4 } remove_trait = education_diplomacy_4 add_trait = education_diplomacy_5 }
    if = { limit = { has_trait = education_stewardship_1 } remove_trait = education_stewardship_1 add_trait = education_stewardship_5 }
    if = { limit = { has_trait = education_stewardship_2 } remove_trait = education_stewardship_2 add_trait = education_stewardship_5 }
    if = { limit = { has_trait = education_stewardship_3 } remove_trait = education_stewardship_3 add_trait = education_stewardship_5 }
    if = { limit = { has_trait = education_stewardship_4 } remove_trait = education_stewardship_4 add_trait = education_stewardship_5 }
    if = { limit = { has_trait = education_martial_1 } remove_trait = education_martial_1 add_trait = education_martial_5 }
    if = { limit = { has_trait = education_martial_2 } remove_trait = education_martial_2 add_trait = education_martial_5 }
    if = { limit = { has_trait = education_martial_3 } remove_trait = education_martial_3 add_trait = education_martial_5 }
    if = { limit = { has_trait = education_martial_4 } remove_trait = education_martial_4 add_trait = education_martial_5 }
}


# add auxillary traits fitting for education
DI_boost_education_extra_traits_effect = {
    if = {
        limit = {
            OR = {
                has_trait = education_learning_1
                has_trait = education_learning_2
                has_trait = education_learning_3
                has_trait = education_learning_4
                has_trait = education_learning_5
            }
        }
        add_trait = lifestyle_herbalist
        add_trait = lifestyle_mystic
    }
    if = {
        limit = {
            OR = {
                has_trait = education_intrigue_1
                has_trait = education_intrigue_2
                has_trait = education_intrigue_3
                has_trait = education_intrigue_4
                has_trait = education_intrigue_5
            }
        }
        add_trait = lifestyle_herbalist
        add_trait = lifestyle_mystic
        add_trait = lifestyle_blademaster
    }
    if = {
        limit = {
            OR = {
                has_trait = education_diplomacy_1
                has_trait = education_diplomacy_2
                has_trait = education_diplomacy_3
                has_trait = education_diplomacy_4
                has_trait = education_diplomacy_5
            }
        }
        add_trait = lifestyle_reveler
        add_trait = lifestyle_poet
    }
    if = {
        limit = {
            OR = {
                has_trait = education_stewardship_1
                has_trait = education_stewardship_2
                has_trait = education_stewardship_3
                has_trait = education_stewardship_4
                has_trait = education_stewardship_5
            }
        }
        add_trait = lifestyle_gardener
        add_trait = lifestyle_poet
    }
    if = {
        limit = {
            OR = {
                has_trait = education_martial_1
                has_trait = education_martial_2
                has_trait = education_martial_3
                has_trait = education_martial_4
                has_trait = education_martial_5
            }
        }
        add_trait = lifestyle_blademaster
        add_trait = lifestyle_hunter
        add_trait = education_martial_prowess_4
    }
    if = { limit = { has_trait = education_martial_prowess_1 } remove_trait = education_martial_prowess_1 add_trait = education_martial_prowess_4 }
    if = { limit = { has_trait = education_martial_prowess_2 } remove_trait = education_martial_prowess_2 add_trait = education_martial_prowess_4 }
    if = { limit = { has_trait = education_martial_prowess_3 } remove_trait = education_martial_prowess_3 add_trait = education_martial_prowess_4 }
    if = { limit = { has_trait = lifestyle_blademaster } add_trait_xp = { trait = lifestyle_blademaster value = 100 } }
    if = { limit = { has_trait = lifestyle_mystic } add_trait_xp = { trait = lifestyle_mystic value = 100 } }
    if = { limit = { has_trait = lifestyle_hunter } add_trait_xp = { trait = lifestyle_hunter track = Venator value = 100 } }
    if = { limit = { has_trait = lifestyle_hunter } add_trait_xp = { trait = lifestyle_hunter track = Falconer value = 100 } }
    if = { limit = { has_trait = lifestyle_reveler } add_trait_xp = { trait = lifestyle_reveler value = 100 } }
}