
# Mil gui shit

GGR_decrease_militarist_loyalty_small = {
    set_temp_variable = { loyalty_change = 5 }
	GGR_decrease_militarist_loyalty = yes
}
GGR_decrease_militarist_loyalty = {
    if = {
        limit = {
            NOT = { has_variable = loyalty_change }
        }
        set_temp_variable = { loyalty_change = 10 }
    }
	subtract_from_variable = { GER_Militarist_Loyalty = loyalty_change }
    
    set_temp_variable = { loyalty_hawkishness_change = GER_Militarist_Hawkishness }
    divide_temp_variable = { loyalty_hawkishness_change = 100 }
    multiply_temp_variable = { loyalty_hawkishness_change = loyalty_change }

    set_temp_variable = { rounder = loyalty_hawkishness_change }
    add_to_temp_variable = { rounder = 0.5 }

    # what lack of round_temp_variable does to a mf
    set_temp_variable_to_random = { 
        var = loyalty_hawkishness_change

        min = rounder
        max = rounder
        integer = yes
    }


    subtract_from_variable = { GER_Militarist_Loyalty = loyalty_hawkishness_change }

	custom_effect_tooltip = GER_GOR_Militarists_loyalty_decrease
	clamp_variable = { var = GER_Militarist_Loyalty min = 0 max = 100 }
    calculate_militarist_variables = yes
}
GGR_decrease_militarist_loyalty_large = {
    set_temp_variable = { loyalty_change = 15 }
	GGR_decrease_militarist_loyalty = yes
}

GGR_increase_militarist_loyalty_small = {
    set_temp_variable = { loyalty_change = 5 }
    GGR_increase_militarist_loyalty = yes
}
GGR_increase_militarist_loyalty = {
    if = {
        limit = {
            NOT = { has_variable = loyalty_change }
        }
        set_temp_variable = { loyalty_change = 10 }
    }
	custom_effect_tooltip = GER_GOR_Militarists_loyalty_increase
	add_to_variable = { GER_Militarist_Loyalty = loyalty_change }
	clamp_variable = { var = GER_Militarist_Loyalty min = 0 max = 100 }
    calculate_militarist_variables = yes
}
GGR_increase_militarist_loyalty_large = {
    set_temp_variable = { loyalty_change = 15 }
    GGR_increase_militarist_loyalty = yes
}

GGR_decrease_militarist_power_small = {
    set_temp_variable = { power_change = 5 }
    GGR_decrease_militarist_power = yes
}
GGR_decrease_militarist_power = {
    if = {
        limit = {
            NOT = { has_variable = power_change }
        }
        set_temp_variable = { power_change = 10 }
    }
	custom_effect_tooltip = GER_GOR_Militarists_power_decrease
	subtract_from_variable = { GER_Militarist_Power = power_change }
	clamp_variable = { var = GER_Militarist_Power min = 0 max = 100 }
    calculate_militarist_variables = yes
}
GGR_decrease_militarist_power_large = {
    set_temp_variable = { power_change = 15 }
    GGR_decrease_militarist_power = yes
}

GGR_increase_militarist_power_small = {
    set_temp_variable = { power_change = 5 }
    GGR_increase_militarist_power = yes
}
GGR_increase_militarist_power = {
    if = {
        limit = {
            NOT = { has_variable = power_change }
        }
        set_temp_variable = { power_change = 10 }
    }
	custom_effect_tooltip = GER_GOR_Militarists_power_increase
	add_to_variable = { GER_Militarist_Power = power_change }
	clamp_variable = { var = GER_Militarist_Power min = 0 max = 100 }
    calculate_militarist_variables = yes
}
GGR_increase_militarist_power_large = {
    set_temp_variable = { power_change = 15 }
    GGR_increase_militarist_power = yes
}

GGR_decrease_militarist_hawkishness_small = {
    set_temp_variable = { hawkishness_change = 5 }
    GGR_decrease_militarist_hawkishness = yes
}
GGR_decrease_militarist_hawkishness = {
    if = {
        limit = {
            NOT = { has_variable = hawkishness_change }
        }
        set_temp_variable = { hawkishness_change = 10 }
    }
	custom_effect_tooltip = GER_GOR_Militarists_hawkishness_decrease
	subtract_from_variable = { GER_Militarist_Hawkishness = hawkishness_change }
	clamp_variable = { var = GER_Militarist_Hawkishness min = 0 max = 100 }
    calculate_militarist_variables = yes
}
GGR_decrease_militarist_hawkishness_large = {
    set_temp_variable = { hawkishness_change = 15 }
    GGR_decrease_militarist_hawkishness = yes
}

GGR_increase_militarist_hawkishness_small = {
    set_temp_variable = { hawkishness_change = 5 }
    GGR_increase_militarist_hawkishness = yes
}
GGR_increase_militarist_hawkishness = {
    if = {
        limit = {
            NOT = { has_variable = hawkishness_change }
        }
        set_temp_variable = { hawkishness_change = 10 }
    }
	custom_effect_tooltip = GER_GOR_Militarists_hawkishness_increase
	add_to_variable = { GER_Militarist_Hawkishness = hawkishness_change }
	clamp_variable = { var = GER_Militarist_Hawkishness min = 0 max = 100 }
    calculate_militarist_variables = yes
}
GGR_increase_militarist_hawkishness_large = {
    set_temp_variable = { hawkishness_change = 15 }
    GGR_increase_militarist_hawkishness = yes
}

simulate_militarists_pleasing = {    
    set_temp_variable = { difference = GER_Militarist_Power }
    divide_temp_variable = { difference = 100 }
    multiply_temp_variable = { difference = GER_Militarist_Hawkishness }
    subtract_from_temp_variable = { difference = GER_Militarist_Loyalty }
    round_temp_variable = differnece

    if = {
        limit = { 
            check_variable = { difference < 0 }
        }
        multiply_temp_variable = { difference = -1 }
    }
    
    set_temp_variable = { required_loyalty = GER_Militarist_Loyalty }
    add_to_temp_variable = { required_loyalty = required_difference }
    subtract_from_temp_variable = { required_loyalty = difference }

    log = "Power - [?GER_Militarist_Power], Hawkishness - [?GER_Militarist_Hawkishness], Loyalty - [?GER_Militarist_Loyalty]"
    log = "Required difference - [?required_difference], differnece - [?difference], required loyalty - [?required_loyalty]"
}

GGR_initialize_militarist_mechanic = {
    set_country_flag = gui_alert_visible_2
    set_country_flag = country_has_gui

    add_ideas = GGR_the_militarists_dummy
    hidden_effect = { add_dynamic_modifier = { modifier = GGR_the_militarists } }
    
    calculate_militarist_variables = yes
}

calculate_militarist_variables = {
    set_variable = { GGR_militarists_hawkishness_1 = GER_Militarist_Hawkishness }
    divide_variable = { GGR_militarists_hawkishness_1 = 100 }

    set_variable = { GGR_militarists_hawkishness_1_2 = GGR_militarists_hawkishness_1 }
    divide_variable = { GGR_militarists_hawkishness_1_2 = 2 }
    
    set_variable = { GGR_militarists_hawkishness_1_4 = GGR_militarists_hawkishness_1_2 }
    divide_variable = { GGR_militarists_hawkishness_1_4 = 2 }
    set_variable = { GGR_militarists_hawkishness_1_4_neg = GGR_militarists_hawkishness_1_4 }
    multiply_variable = { GGR_militarists_hawkishness_1_4_neg = -1 }
    set_variable = { GGR_militarists_hawkishness_1_8_neg = GGR_militarists_hawkishness_1_4_neg }
    multiply_variable = { GGR_militarists_hawkishness_1_8_neg = 0.5 }



    set_variable = { GGR_militarists_power_1_2 = GER_Militarist_Power }
    divide_variable = { GGR_militarists_power_1_2 = 200 }
    set_variable = { GGR_militarists_power_1_2_neg = GGR_militarists_power_1_2 }
    multiply_variable = { GGR_militarists_power_1_2_neg = -1 }

    set_variable = { GGR_militarists_power_1_4 = GGR_militarists_power_1_2 }
    divide_variable = { GGR_militarists_power_1_4 = 2 }
    set_variable = { GGR_militarists_power_1_4_neg = GGR_militarists_power_1_4 }
    multiply_variable = { GGR_militarists_power_1_4_neg = -1 }



    set_variable = { GGR_militarists_loyalty_1 = GER_Militarist_loyalty }
    divide_variable = { GGR_militarists_loyalty_1 = 100 }
    
    set_variable = { GGR_militarists_loyalty_50_1 = GER_Militarist_loyalty }
    subtract_from_variable = { GGR_militarists_loyalty_50_1 = 50 }
    divide_variable = { GGR_militarists_loyalty_50_1 = 100 }

    set_variable = { GGR_militarists_loyalty_1_2 = GGR_militarists_loyalty_1 }
    divide_variable = { GGR_militarists_loyalty_1_2 = 2 }
    
    set_variable = { GGR_militarists_loyalty_9_10 = GGR_militarists_loyalty_1 }
    multiply_variable = { GGR_militarists_loyalty_3_4 = 0.9 }

    if = {
        limit = {
            has_country_flag = GGR_radicals_appear
        }
        set_variable = { national_socialism_2_drift_var = 2.5 }
        set_temp_variable = { national_socialism_2_drift_var_red = 2.5 }
        multiply_temp_variable = { national_socialism_2_drift_var_red = GGR_militarists_loyalty_1 }
        subtract_from_variable = { national_socialism_2_drift_var = national_socialism_2_drift_var_red }
        set_variable = { national_socialism_1_drift_var = 10 }
        set_temp_variable = { national_socialism_1_drift_var_red = 10 }
        multiply_temp_variable = { national_socialism_1_drift_var_red = GGR_militarists_loyalty_9_10 }
        subtract_from_variable = { national_socialism_1_drift_var = national_socialism_1_drift_var_red }
    }
    else = {
        set_variable = { national_socialism_2_drift_var = 5 }
        set_temp_variable = { national_socialism_2_drift_var_red = 5 }
        multiply_temp_variable = { national_socialism_2_drift_var_red = GGR_militarists_loyalty_1 }
        subtract_from_variable = { national_socialism_2_drift_var = national_socialism_2_drift_var_red }
    }

    if = {
        limit = {
            has_completed_focus = GER_GOR_war_plan_C_new
        }
        multiply_variable = { national_socialism_2_drift_var = 0 }
    }
    else_if = {
        limit = {
            has_country_flag = GGR_schorner_loses_popularity
        }
        add_to_variable = { national_socialism_2_drift_var = national_socialism_2_drift_var_red }
        multiply_variable = { national_socialism_2_drift_var = -1 }
        multiply_variable = { national_socialism_1_drift_var = 2 }
    }

    divide_variable = { national_socialism_1_drift_var = 100 }
    divide_variable = { national_socialism_2_drift_var = 100 }
}