# Author(s): Angriest Bird, Mkemper, Crocomoth # calculate_expected_spending zeroes and rebuilds the expected_* vars, so it is their only # writer and folds the offsets below in itself. Nothing here may write them. recalculate_law_desires = { focus_on_laws_due_to_economic_despair = yes # will increase next month, just in case increase_spending_if_possible = yes ai_reduce_spending_on_deficit = yes } focus_on_laws_due_to_economic_despair = { if = { limit = { NOT = { has_country_flag = AI_economic_downspiral } OR = { has_idea = depression has_idea = recession ai_has_major_economic_problems = yes ai_has_moderate_economic_problems = yes } } set_country_flag = AI_economic_downspiral clear_law_desire_offsets = yes if = { limit = { is_debug = yes } log = "[GetDateText]: [ROOT.GetName]: DEBUG: AI Scripted Trigger: focus_on_laws_due_to_economic_despair fired" } } else_if = { limit = { has_country_flag = AI_economic_downspiral OR = { ai_has_acceptable_deficit = yes NOT = { OR = { has_idea = depression has_idea = recession } } } } if = { limit = { is_debug = yes } log = "[GetDateText]: [ROOT.GetName]: DEBUG: AI Scripted Trigger: focus_on_laws_due_to_economic_despair removed" } clr_country_flag = AI_economic_downspiral } if = { limit = { check_variable = { corporate_tax_rate > 30 } } clear_law_desire_offsets = yes } } # Defence is deliberately left alone: it is driven by security pressure, not by what the # treasury can spare. clear_law_desire_offsets = { set_variable = { bureau_desire_offset = 0 } set_variable = { education_desire_offset = 0 } set_variable = { health_desire_offset = 0 } set_variable = { police_desire_offset = 0 } set_variable = { social_desire_offset = 0 } } increase_spending_if_possible = { if = { # if we are good on taxes and not increased spending already limit = { check_variable = { treasury_rate > 0 } check_variable = { corporate_tax_rate < 20 } check_variable = { population_tax_rate < 25 } has_bureau_idea_law_desired = yes has_education_law_desired = yes has_health_law_desired = yes has_police_idea_law_desired = yes has_social_law_desired = yes } set_temp_variable = { desire_change = 1 } random_list = { 10 = { change_expected_bureaucracy_spending = yes } 10 = { change_expected_education_spending = yes } 10 = { change_expected_health_spending = yes } 10 = { change_expected_police_spending = yes } 10 = { change_expected_social_spending = yes } } } } change_expected_bureaucracy_spending = { add_to_variable = { bureau_desire_offset = desire_change } clamp_variable = { var = bureau_desire_offset min = -1 max = 4 } } change_expected_education_spending = { add_to_variable = { education_desire_offset = desire_change } clamp_variable = { var = education_desire_offset min = -1 max = 4 } } change_expected_police_spending = { add_to_variable = { police_desire_offset = desire_change } clamp_variable = { var = police_desire_offset min = -1 max = 4 } } change_expected_health_spending = { add_to_variable = { health_desire_offset = desire_change } clamp_variable = { var = health_desire_offset min = -1 max = 5 } } change_expected_social_spending = { add_to_variable = { social_desire_offset = desire_change } clamp_variable = { var = social_desire_offset min = -1 max = 5 } } change_expected_defense_spending = { add_to_variable = { defence_desire_offset = desire_change } clamp_variable = { var = defence_desire_offset min = -1 max = 5 } } ai_reduce_spending_on_deficit = { if = { limit = { is_ai = yes } # STEP 1: Trim any category above its expected level when running a high deficit # Applies in peacetime only — wartime spending is handled by war multipliers if = { limit = { has_war = no ai_has_high_deficit = yes } # Reduce civilian categories first (welfare, health, education, police, admin) if = { limit = { check_variable = { social_law > 1 } check_variable = { social_law > expected_welfare_spending } } decrease_social_spending = yes } if = { limit = { check_variable = { police_law > 1 } check_variable = { police_law > expected_police_spending } } decrease_policing_budget = yes } if = { limit = { check_variable = { education_law > 1 } check_variable = { education_law > expected_edu_spending } } decrease_education_budget = yes } if = { limit = { check_variable = { health_law > 1 } check_variable = { health_law > expected_health_spending } } decrease_healthcare_budget = yes } if = { limit = { check_variable = { bureau_law > 1 } check_variable = { bureau_law > expected_adm_spending } } decrease_centralization = yes } # Military cut LAST: only reduce if above expected level if = { limit = { check_variable = { military_law > 1 } check_variable = { military_law > expected_military_sp } } decrease_military_spending = yes } } # STEP 2: Emergency austerity during MAJOR crisis (interest >12% + rate < -9) # Applies even during wartime — if the economy is collapsing, cuts must happen # Cut one civilian category per month (the highest one), military only if civilians are all at minimum if = { limit = { ai_has_major_economic_problems = yes } # Try civilian categories first — pick the highest non-minimum one if = { limit = { check_variable = { social_law > 1 } check_variable = { social_law > police_law } check_variable = { social_law > education_law } } decrease_social_spending = yes } else_if = { limit = { check_variable = { health_law > 1 } check_variable = { health_law > police_law } check_variable = { health_law > education_law } } decrease_healthcare_budget = yes } else_if = { limit = { check_variable = { education_law > 1 } } decrease_education_budget = yes } else_if = { limit = { check_variable = { police_law > 1 } } decrease_policing_budget = yes } else_if = { limit = { check_variable = { bureau_law > 1 } } decrease_centralization = yes } # Military LAST: only cut if all civilian categories are at minimum (level 1) else_if = { limit = { check_variable = { military_law > 1 } check_variable = { social_law < 2 } check_variable = { health_law < 2 } check_variable = { education_law < 2 } check_variable = { police_law < 2 } check_variable = { bureau_law < 2 } } decrease_military_spending = yes } } } }