@ucr_small = 20
@ucr_big = 35
@oun_small = 16
@oun_big = 30
@vlnt_small = 10
@vlnt_big = 20

UKR_recalc_parliament_icon_frames = { ### Always use this after adding value to the variable, updates the GFX 
	
	set_temp_variable = { parliament_temp = ukrainian_parliament_support } ### Assigns the currrent parliament support to a temporary variable
	divide_temp_variable = { parliament_temp = ukrainian_parliament_total } ### Divides the current support by the max value
	multiply_temp_variable = { parliament_temp = 10 } ### Set it to 10, 1 less than the max because the first frame of the GFX has 0 green seats
	add_to_temp_variable = { parliament_temp = 1 } ### Adding 1 to the variable in order to make all frames accessable
	if = {
		limit = { check_variable = { parliament_temp > 0 } }
		clamp_temp_variable = {
			var = parliament_temp
			min = 1
			max = 11
		}
	}
	else = {
		set_temp_variable = { parliament_temp = 1 }
	}
	set_variable = { UKR_current_parliament_icon_frame = parliament_temp } ### Sets the current frame number to the one caluclated
	UKR_parliament_support_majority = yes ### Runs script further down
}


UKR_parliament_support_add5 = { ### Use this when adding 1-5 support
	custom_effect_tooltip = UKR_parliament_support_add5_tt ### Custom tooltip
	set_temp_variable = { temp_factor = random } ### Generates a random value between 0 and 1
	multiply_temp_variable = { temp_factor = 5 } ### Multiplies the value by 5 to get a value between 0 and 10
	clamp_temp_variable = { var = temp_factor max = 5 min = 1 } ### Is used to cap the variable, currently set that it can be at most 5 and at least 1
	add_to_variable = { ukrainian_parliament_support = temp_factor } ### Increases the support by the value generated
	round_variable = ukrainian_parliament_support ### Rounds the support to the nearest int
	clamp_variable = { var = ukrainian_parliament_support max = ukrainian_parliament_total min = 0 } ### Clamps the support value so it can't exceed the maximum
	UKR_recalc_parliament_icon_frames = yes
}

UKR_parliament_support_add10 = { ### Use this when adding 6-10 support
	custom_effect_tooltip = UKR_parliament_support_add10_tt ### Custom tooltip
	set_temp_variable = { temp_factor = random } ### Generates a random value between 0 and 1
	multiply_temp_variable = { temp_factor = 10 } ### Multiplies the value by 10 to get a value between 0 and 10
	clamp_temp_variable = { var = temp_factor max = 10 min = 5 } ### Is used to cap the variable, currently set that it can be at most 10 and at least 1
	add_to_variable = { ukrainian_parliament_support  = temp_factor } ### Increases the support by the value generated
	round_variable = ukrainian_parliament_support ### Rounds the support to the nearest int
	clamp_variable = { var = ukrainian_parliament_support max = ukrainian_parliament_total min = 0 } ### Clamps the support value so it can't exceed the maximum
	UKR_recalc_parliament_icon_frames = yes
}

UKR_rada_small_opposition = {
	custom_effect_tooltip = ukr_rada_small_opposition_tt
	set_temp_variable = { temp_factor = random }
	multiply_temp_variable = { temp_factor = -5 }
	add_to_variable = { ukrainian_parliament_support = temp_factor }
	round_variable = ukrainian_parliament_support
	clamp_variable = { var = ukrainian_parliament_support max = ukrainian_parliament_total min = 0 }
	UKR_recalc_parliament_icon_frames = yes
}

UKR_rada_big_opposition = {
	custom_effect_tooltip = ukr_rada_big_opposition_tt
	set_temp_variable = { temp_factor = random }
	multiply_temp_variable = { temp_factor = -10 }
	clamp_temp_variable = { var = temp_factor max = -5 min = -10 }
	add_to_variable = { ukrainian_parliament_support = temp_factor }
	round_variable = ukrainian_parliament_support
	clamp_variable = { var = ukrainian_parliament_support max = ukrainian_parliament_total min = 0 }
	UKR_recalc_parliament_icon_frames = yes
}

UKR_rada_small_support = {
	custom_effect_tooltip = ukr_rada_small_support_tt
	set_temp_variable = { temp_factor = random }
	multiply_temp_variable = { temp_factor = 5 }
	add_to_variable = { ukrainian_parliament_support = temp_factor }
	round_variable = ukrainian_parliament_support
	clamp_variable = { var = ukrainian_parliament_support max = ukrainian_parliament_total min = 0 }
	UKR_recalc_parliament_icon_frames = yes
}

UKR_parliament_support_majority = { ### calculated bonuses from support in parliament
	if = {
		limit = { 
			check_variable = { ukrainian_parliament_support > 49 } 
			check_variable = { ukrainian_parliament_support < 70 }
		}
		#set_country_flag = ukrainian_parliament_support_majority
		set_variable = { ukr_sr_stability = 0.03 }
		set_variable = { ukr_sr_polit_power = 0.05 }
		set_variable = { ukr_sr_democratic = 0 }
	}
	if = {
		limit = { 
			check_variable = { ukrainian_parliament_support > 69 } 
			check_variable = { ukrainian_parliament_support < 90 } 
		}
		set_variable = { ukr_sr_stability = 0.05 }
		set_variable = { ukr_sr_polit_power = 0.10 }
		set_variable = { ukr_sr_democratic = -0.02 }
	}
	if = {
		limit = { 
			check_variable = { ukrainian_parliament_support > 89 } 
		}
		set_variable = { ukr_sr_stability = 0.07 }
		set_variable = { ukr_sr_polit_power = 0.15 }
		set_variable = { ukr_sr_democratic = -0.03 }
	}
	if = {
		limit = { 
			check_variable = { ukrainian_parliament_support < 50 }
			check_variable = { ukrainian_parliament_support > 33 }
		}
		set_variable = { ukr_sr_stability = 0 }
		set_variable = { ukr_sr_polit_power = 0 }
		set_variable = { ukr_sr_democratic = 0.05 }
	}
	if = {
		limit = { 
			check_variable = { ukrainian_parliament_support < 34 }
		}
		set_variable = { ukr_sr_stability = -0.05 }
		set_variable = { ukr_sr_polit_power = -0.10 }
	}
}

UKR_recruting_of_yakov_blyumkin = {
	create_operative_leader = {
		name = "Yakov Blyumkin"
		GFX = GFX_Portrait_Yakov_Blyumkin
		traits = { operative_commando operative_escape_artist }
		bypass_recruitment = no
		available_to_spy_master = yes
		nationalities = { SOV ISR }
	}
	clr_country_flag = UKR_arrival_of_yakov_blyumkin_flag
}
# Cossack republic factions
ucr_support_of_unionists_small = {
	custom_effect_tooltip = ucr_support_of_unionists_small_tt
	add_to_variable = { var_ucr_support_of_unionists = @ucr_small }
	if = {
        limit = { 
        	check_variable = { var_ucr_support_of_unionists > 100 } 
        }
        set_variable = { var_ucr_support_of_unionists = 100 }
    }
	ucr_recalc_bonuses_for_unionists = yes
}
ucr_support_of_unionists_big = {
	custom_effect_tooltip = ucr_support_of_unionists_big_tt
	add_to_variable = { var_ucr_support_of_unionists = @ucr_big }
	if = {
        limit = { 
        	check_variable = { var_ucr_support_of_unionists > 100 } 
        }
        set_variable = { var_ucr_support_of_unionists = 100 }
    }
	ucr_recalc_bonuses_for_unionists = yes
}
ucr_opposition_of_unionists_small = {
	custom_effect_tooltip = ucr_opposition_of_unionists_small_tt
	subtract_from_variable = { var_ucr_support_of_unionists = @ucr_small }
	if = {
        limit = { 
        	check_variable = { var_ucr_support_of_unionists < 0 } 
        }
        set_variable = { var_ucr_support_of_unionists = 0 }
    }
	ucr_recalc_bonuses_for_unionists = yes
}
ucr_opposition_of_unionists_big = {
	custom_effect_tooltip = ucr_opposition_of_unionists_big_tt
	subtract_from_variable = { var_ucr_support_of_unionists = @ucr_big }
	if = {
        limit = { 
        	check_variable = { var_ucr_support_of_unionists < 0 } 
        }
        set_variable = { var_ucr_support_of_unionists = 0 }
    }
	ucr_recalc_bonuses_for_unionists = yes
}
ucr_support_of_guards_small = {
	custom_effect_tooltip = ucr_support_of_guards_small_tt
	add_to_variable = { var_ucr_support_of_guards_of_order = @ucr_small }
	if = {
        limit = { 
        	check_variable = { var_ucr_support_of_guards_of_order > 100 } 
        }
        set_variable = { var_ucr_support_of_guards_of_order = 100 }
    }
	ucr_recalc_bonuses_for_guards_of_order = yes
}
ucr_support_of_guards_big = {
	custom_effect_tooltip = ucr_support_of_guards_big_tt
	add_to_variable = { var_ucr_support_of_guards_of_order = @ucr_big }
	if = {
        limit = { 
        	check_variable = { var_ucr_support_of_guards_of_order > 100 } 
        }
        set_variable = { var_ucr_support_of_guards_of_order = 100 }
    }
	ucr_recalc_bonuses_for_guards_of_order = yes
}
ucr_opposition_of_guards_small = {
	custom_effect_tooltip = ucr_opposition_of_guards_small_tt
	subtract_from_variable = { var_ucr_support_of_guards_of_order = @ucr_small }
	if = {
        limit = { 
        	check_variable = { var_ucr_support_of_guards_of_order < 0 } 
        }
        set_variable = { var_ucr_support_of_guards_of_order = 0 }
    }
	ucr_recalc_bonuses_for_guards_of_order = yes
}
ucr_opposition_of_guards_big = {
	custom_effect_tooltip = ucr_opposition_of_guards_big_tt
	subtract_from_variable = { var_ucr_support_of_guards_of_order = @ucr_big }
	if = {
        limit = { 
        	check_variable = { var_ucr_support_of_guards_of_order < 0 } 
        }
        set_variable = { var_ucr_support_of_guards_of_order = 0 }
    }
	ucr_recalc_bonuses_for_guards_of_order = yes
}
ucr_support_of_right_small = {
	custom_effect_tooltip = ucr_support_of_right_small_tt
	add_to_variable = { var_ucr_support_of_right_wing = @ucr_small }
	if = {
        limit = { 
        	check_variable = { var_ucr_support_of_right_wing > 100 } 
        }
        set_variable = { var_ucr_support_of_right_wing = 100 }
    }
	ucr_recalc_bonuses_for_right_wing = yes
}
ucr_support_of_right_big = {
	custom_effect_tooltip = ucr_support_of_right_big_tt
	add_to_variable = { var_ucr_support_of_right_wing = @ucr_big }
	if = {
        limit = { 
        	check_variable = { var_ucr_support_of_right_wing > 100 } 
        }
        set_variable = { var_ucr_support_of_right_wing = 100 }
    }
	ucr_recalc_bonuses_for_right_wing = yes
}
ucr_opposition_of_right_small = {
	custom_effect_tooltip = ucr_opposition_of_right_small_tt
	subtract_from_variable = { var_ucr_support_of_right_wing = @ucr_small }
	if = {
        limit = { 
        	check_variable = { var_ucr_support_of_right_wing < 0 } 
        }
        set_variable = { var_ucr_support_of_right_wing = 0 }
    }
	ucr_recalc_bonuses_for_right_wing = yes
}
ucr_opposition_of_right_big = {
	custom_effect_tooltip = ucr_opposition_of_right_big_tt
	subtract_from_variable = { var_ucr_support_of_right_wing = @ucr_big }
	if = {
        limit = { 
        	check_variable = { var_ucr_support_of_right_wing < 0 } 
        }
        set_variable = { var_ucr_support_of_right_wing = 0 }
    }
	ucr_recalc_bonuses_for_right_wing = yes
}
ucr_support_of_black_small = {
	custom_effect_tooltip = ucr_support_of_black_small_tt
	add_to_variable = { var_ucr_support_of_black_rada = @ucr_small }
	if = {
        limit = { 
        	check_variable = { var_ucr_support_of_black_rada > 100 } 
        }
        set_variable = { var_ucr_support_of_black_rada = 100 }
    }
	ucr_recalc_bonuses_for_black_rada = yes
}
ucr_support_of_black_big = {
	custom_effect_tooltip = ucr_support_of_black_big_tt
	add_to_variable = { var_ucr_support_of_black_rada = @ucr_big }
	if = {
        limit = { 
        	check_variable = { var_ucr_support_of_black_rada > 100 } 
        }
        set_variable = { var_ucr_support_of_black_rada = 100 }
    }
	ucr_recalc_bonuses_for_black_rada = yes
}
ucr_opposition_of_black_small = {
	custom_effect_tooltip = ucr_opposition_of_black_small_tt
	subtract_from_variable = { var_ucr_support_of_black_rada = @ucr_small }
	if = {
        limit = { 
        	check_variable = { var_ucr_support_of_black_rada < 0 } 
        }
        set_variable = { var_ucr_support_of_black_rada = 0 }
    }
	ucr_recalc_bonuses_for_black_rada = yes
}
ucr_opposition_of_black_big = {
	custom_effect_tooltip = ucr_opposition_of_black_big_tt
	subtract_from_variable = { var_ucr_support_of_black_rada = @ucr_big }
	if = {
        limit = { 
        	check_variable = { var_ucr_support_of_black_rada < 0 } 
        }
        set_variable = { var_ucr_support_of_black_rada = 0 }
    }
	ucr_recalc_bonuses_for_black_rada = yes
}
ucr_support_of_unionists_full = {
	custom_effect_tooltip = ucr_support_of_unionists_full_tt
	set_variable = { var_ucr_support_of_unionists = 100 }
	ucr_recalc_bonuses_for_unionists = yes
}
ucr_opposition_of_unionists_full = {
	custom_effect_tooltip = ucr_opposition_of_unionists_full_tt
	set_variable = { var_ucr_support_of_unionists = 0 }
	ucr_recalc_bonuses_for_unionists = yes
}
ucr_support_of_guards_full = {
	custom_effect_tooltip = ucr_support_of_guards_full_tt
	set_variable = { var_ucr_support_of_guards_of_order = 100 }
	ucr_recalc_bonuses_for_guards_of_order = yes
}
ucr_opposition_of_guards_full = {
	custom_effect_tooltip = ucr_opposition_of_guards_full_tt
	set_variable = { var_ucr_support_of_guards_of_order = 0 }
	ucr_recalc_bonuses_for_guards_of_order = yes
}
ucr_support_of_right_full = {
	custom_effect_tooltip = ucr_support_of_right_full_tt
	set_variable = { var_ucr_support_of_right_wing = 100 }
	ucr_recalc_bonuses_for_right_wing = yes
}
ucr_opposition_of_right_full = {
	custom_effect_tooltip = ucr_opposition_of_right_full_tt
	set_variable = { var_ucr_support_of_right_wing = 0 }
	ucr_recalc_bonuses_for_right_wing = yes
}
ucr_support_of_black_full = {
	custom_effect_tooltip = ucr_support_of_black_full_tt
	set_variable = { var_ucr_support_of_black_rada = 100 }
	ucr_recalc_bonuses_for_black_rada = yes
}
ucr_opposition_of_black_full = {
	custom_effect_tooltip = ucr_opposition_of_black_full_tt
	set_variable = { var_ucr_support_of_black_rada = 0 }
	ucr_recalc_bonuses_for_black_rada = yes
}
ucr_recalc_bonuses_for_unionists = {
	if = {
		limit = { check_variable = { var_ucr_support_of_unionists > 79 } }
		set_variable = { ucr_unionists_polit_power = 0.08 }
		set_variable = { ucr_unionists_dipl_bonus = -0.10 }
	}
	else_if = {
		limit = {
			check_variable = { var = var_ucr_support_of_unionists value = 50 compare = greater_than }
			check_variable = { var = var_ucr_support_of_unionists value = 80 compare = less_than }
		}
		set_variable = { ucr_unionists_polit_power = 0.05 }
		set_variable = { ucr_unionists_dipl_bonus = 0 }
	} 
	else = {
		set_variable = { ucr_unionists_polit_power = 0 }
		set_variable = { ucr_unionists_dipl_bonus = 0.10 }
	}
	ucr_summare_bonuses = yes
}
ucr_recalc_bonuses_for_guards_of_order = {
	if = {
		limit = { check_variable = { var_ucr_support_of_guards_of_order > 79 } }
		set_variable = { ucr_guards_polit_power = 0.08 }
		set_variable = { ucr_guards_dipl_bonus = -0.10 }
	}
	else_if = {
		limit = {
			check_variable = { var = var_ucr_support_of_guards_of_order value = 50 compare = greater_than }
			check_variable = { var = var_ucr_support_of_guards_of_order value = 80 compare = less_than }
		}
		set_variable = { ucr_guards_polit_power = 0.05 }
		set_variable = { ucr_guards_dipl_bonus = 0 }
	} 
	else = {
		set_variable = { ucr_guards_polit_power = 0 }
		set_variable = { ucr_guards_dipl_bonus = 0.10 }
	}
	ucr_summare_bonuses = yes
}
ucr_recalc_bonuses_for_right_wing = {
	if = {
		limit = { check_variable = { var_ucr_support_of_right_wing >79 } }
		set_variable = { ucr_right_polit_power = 0.08 }
		set_variable = { ucr_right_dipl_bonus = -0.10 }
	}
	else_if = {
		limit = {
			check_variable = { var = var_ucr_support_of_right_wing value = 50 compare = greater_than }
			check_variable = { var = var_ucr_support_of_right_wing value = 80 compare = less_than }
		}
		set_variable = { ucr_right_polit_power = 0.05 }
		set_variable = { ucr_right_dipl_bonus = 0 }
	} 
	else = {
		set_variable = { ucr_right_polit_power = 0 }
		set_variable = { ucr_right_dipl_bonus = 0.10 }
	}
	ucr_summare_bonuses = yes
}
ucr_recalc_bonuses_for_black_rada = {
	if = {
		limit = { check_variable = { var_ucr_support_of_black_rada > 79 } }
		set_variable = { ucr_black_polit_power = 0.08 }
		set_variable = { ucr_black_dipl_bonus = -0.10 }
	}
	else_if = {
		limit = {
			check_variable = { var = var_ucr_support_of_black_rada value = 50 compare = greater_than }
			check_variable = { var = var_ucr_support_of_black_rada value = 80 compare = less_than }
		}
		set_variable = { ucr_black_polit_power = 0.05 }
		set_variable = { ucr_black_dipl_bonus = 0 }
	} 
	else = {
		set_variable = { ucr_black_polit_power = 0 }
		set_variable = { ucr_black_dipl_bonus = 0.10 }
	}
	ucr_summare_bonuses = yes
}
ucr_summare_bonuses = {
	set_variable = { ucr_modifier_polit_power = 0 }
	add_to_variable = { ucr_modifier_polit_power = ucr_unionists_polit_power }
	add_to_variable = { ucr_modifier_polit_power = ucr_guards_polit_power }
	add_to_variable = { ucr_modifier_polit_power = ucr_right_polit_power }
	add_to_variable = { ucr_modifier_polit_power = ucr_black_polit_power }
	set_variable = { ucr_modifier_wargoal = 0 }
	add_to_variable = { ucr_modifier_wargoal = ucr_unionists_dipl_bonus }
	add_to_variable = { ucr_modifier_wargoal = ucr_guards_dipl_bonus }
	add_to_variable = { ucr_modifier_wargoal = ucr_right_dipl_bonus }
	add_to_variable = { ucr_modifier_wargoal = ucr_black_dipl_bonus }
}
ucr_calculate_promised_posts = {
		hidden_effect = {
			if = {
				limit = { check_variable = { var_ucr_promised_positions > 4 } }
				random_list = {
					50 = { set_variable = { ucr_loyality_of_osavul = 0 } }
					50 = { set_variable = { ucr_loyality_of_osavul = -1 } }
				}
				random_list = {
					50 = { set_variable = { ucr_loyality_of_pisar = 0 } }
					50 = { set_variable = { ucr_loyality_of_pisar = -1 } }
				}
				random_list = {
					50 = { set_variable = { ucr_loyality_of_judge = 0 } }
					50 = { set_variable = { ucr_loyality_of_judge = -1 } }
				}
				random_list = {
					50 = { set_variable = { ucr_loyality_of_wagonmaster = 0 } }
					50 = { set_variable = { ucr_loyality_of_wagonmaster = -1 } }
				}
				random_list = {
					50 = { set_variable = { ucr_loyality_of_khorunzhy = 0 } }
					50 = { set_variable = { ucr_loyality_of_khorunzhy = -1 } }
				}
			}
			else_if = {
				limit = { check_variable = { var_ucr_promised_positions = 4 } }
				random_list = {
					50 = { set_variable = { ucr_loyality_of_pisar = 0 } }
					50 = { set_variable = { ucr_loyality_of_pisar = -1 } }
				}
				random_list = {
					50 = { set_variable = { ucr_loyality_of_judge = 0 } }
					50 = { set_variable = { ucr_loyality_of_judge = -1 } }
				}
				random_list = {
					50 = { set_variable = { ucr_loyality_of_wagonmaster = 0 } }
					50 = { set_variable = { ucr_loyality_of_wagonmaster = -1 } }
				}
				random_list = {
					50 = { set_variable = { ucr_loyality_of_khorunzhy = 0 } }
					50 = { set_variable = { ucr_loyality_of_khorunzhy = -1 } }
				}
			}
			else_if = {
				limit = { check_variable = { var_ucr_promised_positions = 3 } }
				random_list = {
					50 = { set_variable = { ucr_loyality_of_judge = 0 } }
					50 = { set_variable = { ucr_loyality_of_judge = -1 } }
				}
				random_list = {
					50 = { set_variable = { ucr_loyality_of_wagonmaster = 0 } }
					50 = { set_variable = { ucr_loyality_of_wagonmaster = -1 } }
				}
				random_list = {
					50 = { set_variable = { ucr_loyality_of_khorunzhy = 0 } }
					50 = { set_variable = { ucr_loyality_of_khorunzhy = -1 } }
				}
			}
			else_if = {
				limit = { check_variable = { var_ucr_promised_positions = 2 } }
				random_list = {
					50 = { set_variable = { ucr_loyality_of_wagonmaster = 0 } }
					50 = { set_variable = { ucr_loyality_of_wagonmaster = -1 } }
				}
				random_list = {
					50 = { set_variable = { ucr_loyality_of_khorunzhy = 0 } }
					50 = { set_variable = { ucr_loyality_of_khorunzhy = -1 } }
				}
			}
			else = {
				random_list = {
					50 = { set_variable = { ucr_loyality_of_khorunzhy = 0 } }
					50 = { set_variable = { ucr_loyality_of_khorunzhy = -1 } }
				}
			}
		}
		set_variable = { var_ucr_promised_positions = 0 }
}
ucr_bonus_post = {#bonus for ruling faction, if it save power, additional chance for loyal post
	hidden_effect = {
		random_list = {
			20 = { set_variable = { ucr_loyality_of_osavul = 1 } }
			20 = { set_variable = { ucr_loyality_of_pisar = 1 }  }
			20 = { set_variable = { ucr_loyality_of_judge = 1 }  }
			20 = { set_variable = { ucr_loyality_of_wagonmaster = 1 }  }
			20 = { set_variable = { ucr_loyality_of_khorunzhy = 1 }  }
		}		
	}
}
ucr_reelect_posts = {
	hidden_effect = {
		remove_ideas = {
			ucr_loyal_osavul
			ucr_disloyal_osavul
			ucr_loyal_pisar
			ucr_disloyal_pisar
			ucr_loyal_judge
			ucr_disloyal_judge
			ucr_loyal_wagonmaster
			ucr_disloyal_wagonmaster
			ucr_loyal_khorunzhy
			ucr_disloyal_khorunzhy
		}
		if = {
			limit = {
				check_variable = { ucr_loyality_of_osavul = 1 }
			}
			add_ideas = ucr_loyal_osavul
		}
		else_if = {
			limit = {
				check_variable = { ucr_loyality_of_osavul = -1 }
			}
			add_ideas = ucr_disloyal_osavul
		}
		if = {
			limit = {	
				check_variable = { ucr_loyality_of_pisar = 1 }
			}
			add_ideas = ucr_loyal_pisar
		}
		else_if = {
			limit = {
				check_variable = { ucr_loyality_of_pisar = -1 }
			}
			add_ideas = ucr_disloyal_pisar
		}
		if = {
			limit = {
				check_variable = { ucr_loyality_of_judge = 1 }
			}
			add_ideas = ucr_loyal_judge
		}
		else_if = {
			limit = {
				check_variable = { ucr_loyality_of_judge = -1 }
			}
			add_ideas = ucr_disloyal_judge
		}
		if = {
			limit = {
				check_variable = { ucr_loyality_of_wagonmaster = 1 }
			}
			add_ideas = ucr_loyal_wagonmaster
		}
		else_if = {
			limit = {
				check_variable = { ucr_loyality_of_wagonmaster = -1 }
			}
			add_ideas = ucr_disloyal_wagonmaster
		}
		if = {
			limit = {
				check_variable = { ucr_loyality_of_khorunzhy = 1 }
			}
			add_ideas = ucr_loyal_khorunzhy
		}
		else_if = {
			limit = {
				check_variable = { ucr_loyality_of_khorunzhy = -1 }
			}
			add_ideas = ucr_disloyal_khorunzhy
		}
	}
}
CRI_rebellion_in_SOV_go = {
	custom_effect_tooltip = CRI_rebellion_in_SOV_go_tt
	var:SOV.CRI_rebellion_country = {
		division_template = {
			name = "Resistance Fighters"
			is_locked = yes
			priority = 1
			template_counter = 3
			regiments = {
				infantry = { x = 0 y = 0 }
				infantry = { x = 0 y = 1 }
				infantry = { x = 0 y = 2 }
				infantry = { x = 1 y = 0 }
				infantry = { x = 1 y = 1 }
			}
			is_locked = yes 
		}
		every_owned_state = {
			limit = { is_core_of = var:SOV.CRI_rebellion_country }
			create_unit = { 
				division = "name = \"Resistance Fighters\" division_template = \"Resistance Fighters\" start_experience_factor = 0.05 start_equipment_factor = 0.95" owner = var:SOV.CRI_rebellion_country count = 4
			}
		}
	}
}
UKR_promt_rebellion_in_SOV_go = {
	custom_effect_tooltip = CRI_rebellion_in_SOV_go_tt
	var:SOV.UKR_promt_rebellion_country = {
		division_template = {
			name = "Resistance Fighters"
			is_locked = yes
			priority = 1
			template_counter = 3
			regiments = {
				infantry = { x = 0 y = 0 }
				infantry = { x = 0 y = 1 }
				infantry = { x = 0 y = 2 }
				infantry = { x = 1 y = 0 }
				infantry = { x = 1 y = 1 }
			}
			is_locked = yes 
		}
		every_owned_state = {
			limit = { is_core_of = var:SOV.UKR_promt_rebellion_country }
			create_unit = { 
				division = "name = \"Resistance Fighters\" division_template = \"Resistance Fighters\" start_experience_factor = 0.05 start_equipment_factor = 0.95" owner = var:SOV.UKR_promt_rebellion_country count = 4
			}
		}
	}
}
DKR_increase_army_anarchy = {
	if = {
		limit = {
			has_idea = DKR_anarchy_in_army
		}
		hidden_effect = {
			swap_ideas = {
				add_idea = DKR_anarchy_in_army_high
				remove_idea = DKR_anarchy_in_army
			}
		}
		custom_effect_tooltip = DKR_increase_of_army_anarchy_tt
	}
	else_if = {
		limit = {
			has_idea = DKR_anarchy_in_army_low
		}
		hidden_effect = {
			swap_ideas = {
	   			add_idea = DKR_anarchy_in_army
	   			remove_idea = DKR_anarchy_in_army_low
			}
		}
		custom_effect_tooltip = DKR_increase_of_army_anarchy_tt
	}
}
DKR_reduce_army_anarchy = {
	if = {
		limit = {
			has_idea = DKR_anarchy_in_army
		}
		hidden_effect = {
			swap_ideas = {
				add_idea = DKR_anarchy_in_army_low
				remove_idea = DKR_anarchy_in_army
			}
		}
		custom_effect_tooltip = DKR_reduce_of_army_anarchy_tt
	}
	else_if = {
		limit = {
			has_idea = DKR_anarchy_in_army_high
		}
		hidden_effect = {
			swap_ideas = {
	  			add_idea = DKR_anarchy_in_army
	   			remove_idea = DKR_anarchy_in_army_high
			}
		}
		custom_effect_tooltip = DKR_reduce_of_army_anarchy_tt
	}
}
DKR_calculate_days_of_build_for_fc = {
	set_temp_variable = { base_days = 70 }
	subtract_from_temp_variable = { base_days = num_of_factories }
	set_variable = { var_free_competitions_build_days = base_days }
	clamp_variable = { var = var_free_competitions_build_days min = 30 }
}
DKR_calculate_days_of_research_for_fc = {
    set_temp_variable = { tech_days = 20 }
    add_to_temp_variable = { tech_days = num_researched_technologies }
	set_variable = { var_free_competitions_research_days = tech_days }
	clamp_variable = { var = var_free_competitions_research_days max = 180 }
}
UKR_increase_trust_of_london = {
	custom_effect_tooltip = UKR_increase_trust_of_london_tt
	if = {
		limit = { 
			check_variable = { var_ukr_trust_of_london > 100 } 
		}
		set_variable = { var_ukr_trust_of_london = 100 }
	}
}
UKR_promt_upgrade_department = {
	if = {
		limit = {
			has_idea = UKR_prometheism_idea_1
		}
		swap_ideas = {
	  		add_idea = UKR_prometheism_idea_2
	   		remove_idea = UKR_prometheism_idea_1
		}
	}
	else_if = {
		limit = {
			has_idea = UKR_prometheism_idea_2
		}
		swap_ideas = {
	  		add_idea = UKR_prometheism_idea_3
	   		remove_idea = UKR_prometheism_idea_2
		}
	}
	else_if = {
		limit = {
			has_idea = UKR_prometheism_idea_3
		}
		swap_ideas = {
	  		add_idea = UKR_prometheism_idea_4
	   		remove_idea = UKR_prometheism_idea_3
		}
	}
}

### OUN factions system ###
oun_increase_radicalisation = {
	custom_effect_tooltip = oun_increase_radicalisation_tt
	add_to_variable = { var_oun_radicalisation_level = 1 }
	clamp_variable = {
		var = var_oun_radicalisation_level
		max = 5
	}
}
oun_decrease_radicalisation = {
	custom_effect_tooltip = oun_decrease_radicalisation_tt
	subtract_from_variable = { var_oun_radicalisation_level = 1 }
	clamp_variable = {
		var = var_oun_radicalisation_level
		min = 1
	}
}
oun_burst_of_violence_againsts_melnyk = {
	hidden_effect = {
		random_list = {
			15 = { 
				modifier = {
					UKR = { NOT = { has_character = UKR_omelyan_senik } }
					factor = 0
				}
				country_event = { id = ukraine.636 days = 3 random_days = 2 }
			}
			15 = { 
				modifier = {
					UKR = { NOT = { has_character = UKR_olena_teliha } }
					factor = 0
				}
				country_event = { id = ukraine.637 days = 3 random_days = 2 }
			}
			15 = { 
				modifier = {
					UKR = { NOT = { has_character = UKR_mykola_stsiborskyi } }
					factor = 0
				}
				country_event = { id = ukraine.638 days = 3 random_days = 2 }
			}
			15 = { 
				modifier = {
					UKR = { NOT = { has_character = UKR_volodymyr_kubiyovych } }
					factor = 0
				}
				country_event = { id = ukraine.642 days = 3 random_days = 2 }
			}
			40 = { 
				modifier = {
					UKR = { check_variable = { var_oun_radicalisation_level > 1 } }
					factor = 0.5
				}
				modifier = {
					UKR = { check_variable = { var_oun_radicalisation_level > 3 } }
					factor = 0.5
				}
				#do nothing
			}
		}
	}
}
oun_burst_of_violence_againsts_bandera = {
	hidden_effect = {
		random_list = {
			15 = { 
				modifier = {
					OR = {
						UKR = { NOT = { has_character = UKR_mykola_lebid } }
						NOT = { has_dlc = "La Resistance" }
					}
					factor = 0
				}
				country_event = { id = ukraine.639 days = 3 random_days = 2 }
			}
			15 = { 
				modifier = {
					UKR = { NOT = { has_character = UKR_yaroslav_stetsko } }
					factor = 0
				}
				country_event = { id = ukraine.640 days = 3 random_days = 2 }
			}
			15 = { 
				modifier = {
					UKR = { NOT = { has_character = UKR_lev_rebet } }
					factor = 0
				}
				country_event = { id = ukraine.641 days = 3 random_days = 2 }
			}
			15 = { 
				modifier = {
					UKR = { NOT = { has_character = UKR_vsevolod_petriv } }
					factor = 0
				}
				country_event = { id = ukraine.643 days = 3 random_days = 2 }
			}
			40 = { 
				modifier = {
					UKR = { check_variable = { var_oun_radicalisation_level > 1 } }
					factor = 0.5
				}
				modifier = {
					UKR = { check_variable = { var_oun_radicalisation_level > 3 } }
					factor = 0.5
				}
				#do nothing
			}
		}
	}
}
oun_calculate_changes = {
	set_temp_variable = { temp_summa = 0 }
	add_to_temp_variable = { temp_summa = var_oun_authority_of_conovalets }
	add_to_temp_variable = { temp_summa = var_oun_control_of_melnyk }
	add_to_temp_variable = { temp_summa = var_oun_onslaught_of_bandera }
	set_temp_variable = { temp_coef = 100 }
	divide_temp_variable = { temp_coef = temp_summa }
	multiply_variable = { var_oun_authority_of_conovalets = temp_coef }
	multiply_variable = { var_oun_control_of_melnyk = temp_coef }
	multiply_variable = { var_oun_onslaught_of_bandera = temp_coef }
	round_variable = var_oun_authority_of_conovalets
	round_variable = var_oun_control_of_melnyk
	round_variable = var_oun_onslaught_of_bandera
	# 1 - low Konovalets, 2 - strong Konovalets, 3 - low Melnyk, 4 - strong Melnyk, 5 - low Bandera, 6 - strong Bandera
	set_temp_variable = { temp_prev_leader = var_oun_status_of_power }
	if = {
		limit = { 
			check_variable = { var_oun_authority_of_conovalets > 75 }
		}
		set_variable = { var_oun_status_of_power = 2 }
		hidden_effect = { 
			if = { limit = { has_idea = oun_fallen_leader } remove_ideas = oun_fallen_leader }
			if = { limit = { NOT = { has_idea = oun_strong_leader } } add_ideas = oun_strong_leader } 
		}
	}
	else_if = {
		limit = {
			check_variable = { var_oun_authority_of_conovalets > 50 }
		}
		set_variable = { var_oun_status_of_power = 1 }
		hidden_effect = { 
			if = { limit = { has_idea = oun_fallen_leader } remove_ideas = oun_fallen_leader } 
			if = { limit = { has_idea = oun_strong_leader } remove_ideas = oun_strong_leader }
		}
	}
	else_if = {
		limit = {
			check_variable = { var_oun_control_of_melnyk > 75 }
		}
		set_variable = { var_oun_status_of_power = 4 }
		hidden_effect = { 
			if = { limit = { has_idea = oun_melnyk_opposition } remove_ideas = oun_melnyk_opposition } 
			if = { limit = { NOT = { has_idea = oun_melnyk_max_power } } add_ideas = oun_melnyk_max_power } 
		}
	}
	else_if = {
		limit = {
			check_variable = { var_oun_control_of_melnyk > 50 }
		}
		set_variable = { var_oun_status_of_power = 3 }
		hidden_effect = { 
			if = { limit = { has_idea = oun_melnyk_opposition } remove_ideas = oun_melnyk_opposition }
			if = { limit = { has_idea = oun_melnyk_max_power } remove_ideas = oun_melnyk_max_power } 
		}
	}
	else_if = {
		limit = {
			check_variable = { var_oun_onslaught_of_bandera > 75 }
		}
		set_variable = { var_oun_status_of_power = 6 }
		hidden_effect = { 
			if = { limit = { has_idea = oun_bandera_opposition } remove_ideas = oun_bandera_opposition }
			if = { limit = { NOT = { has_idea = oun_bandera_max_power } } add_ideas = oun_bandera_max_power } 
		}
	}
	else_if = {
		limit = {
			check_variable = { var_oun_onslaught_of_bandera > 50 }
		}
		set_variable = { var_oun_status_of_power = 5 }
		hidden_effect = { 
			if = { limit = { has_idea = oun_bandera_opposition } remove_ideas = oun_bandera_opposition }
			if = { limit = { has_idea = oun_bandera_max_power } remove_ideas = oun_bandera_max_power }
		}
	}
	# check if ruling faction was changed
	if = {
		limit = {
			check_variable = { var = temp_prev_leader value = var_oun_status_of_power compare = not_equals }
		}
		if = { # Bandera lost power
			limit = {
				check_variable = { temp_prev_leader > 4 }
				check_variable = { var_oun_status_of_power < 5 }
			}
			if = {
				limit = {
					check_variable = { var_oun_status_of_power > 2 }
				}
				oun_burst_of_violence_againsts_bandera = yes
			}
			oun_increase_radicalisation = yes
			hidden_effect = {
				add_ideas = oun_bandera_opposition 
				if = { limit = { has_idea = oun_bandera_max_power } remove_ideas = oun_bandera_max_power }
			}
		}
		else_if = { # Melnyk lost power
			limit = {
				check_variable = { temp_prev_leader > 2 }
				check_variable = { temp_prev_leader < 5 }
				OR = {
					check_variable = { var_oun_status_of_power < 3 }
					check_variable = { var_oun_status_of_power > 4 }
				}
			}
			if = {
				limit = {
					check_variable = { var_oun_status_of_power > 4 }
				}
				oun_burst_of_violence_againsts_melnyk = yes
			}
			oun_increase_radicalisation = yes
			hidden_effect = {
				add_ideas = oun_melnyk_opposition 
				if = { limit = { has_idea = oun_melnyk_max_power } remove_ideas = oun_melnyk_max_power }
			}
		}
		else_if = { # Konovalets lost power
			limit = {
				check_variable = { temp_prev_leader < 3 }
				check_variable = { var_oun_status_of_power > 2 }
			}
			if = {
				limit = {
					check_variable = { var_oun_status_of_power > 4 }
				}
				oun_burst_of_violence_againsts_melnyk = yes
			}
			else = {
				oun_burst_of_violence_againsts_bandera = yes
			}
			oun_increase_radicalisation = yes
			hidden_effect = { 
				add_ideas = oun_fallen_leader 
				if = { limit = { has_idea = oun_strong_leader } remove_ideas = oun_strong_leader }
			}
		}
	}
	# change country leader with change of ruling faction
	UKR = {
		if = {
			limit = {
				check_variable = { var_oun_status_of_power = 6 } # Bandera is new country leader
				NOT = { has_country_leader = { character = UKR_stepan_bandera ruling_only = yes } }
			}
			country_event = ukraine.6
		}
		else_if = {
			limit = {
				check_variable = { var_oun_status_of_power = 4 } # Melnyk is new country leader
				NOT = { has_country_leader = { character = UKR_andriy_melnyk ruling_only = yes } }
			}
			country_event = ukraine.5
		}
		else_if = {
			limit = {
				check_variable = { var_oun_status_of_power > 0 } #for tooltips of advisor at game start
				OR = {
					check_variable = { var_oun_status_of_power < 4 }
					check_variable = { var_oun_status_of_power = 5 }
				}
				NOT = { has_country_leader = { character = UKR_yevhen_konovalets ruling_only = yes } }
			}
			promote_character = UKR_yevhen_konovalets
		}
	}
}
oun_increase_authority_small = {
	custom_effect_tooltip = oun_increase_authority_small_tt
	add_to_variable = { var_oun_authority_of_conovalets = @oun_small }
	if = {
		limit = { check_variable = { var_oun_authority_of_conovalets > 100 } }
		set_variable = { var_oun_authority_of_conovalets = 100 }
	}
	oun_calculate_changes = yes
}
oun_lower_authority_small = {
	custom_effect_tooltip = oun_lower_authority_small_tt
	subtract_from_variable = { var_oun_authority_of_conovalets = @oun_small }
	if = {
		limit = { check_variable = { var_oun_authority_of_conovalets < 0 } }
		set_variable = { var_oun_authority_of_conovalets = 0 }
	}
	oun_calculate_changes = yes
}
oun_increase_control_small = {
	custom_effect_tooltip = oun_increase_control_small_tt
	add_to_variable = { var_oun_control_of_melnyk = @oun_small }
	if = {
		limit = { check_variable = { var_oun_control_of_melnyk > 100 } }
		set_variable = { var_oun_control_of_melnyk = 100 }
	}
	oun_calculate_changes = yes
}
oun_lower_control_small = {
	custom_effect_tooltip = oun_lower_control_small_tt
	subtract_from_variable = { var_oun_control_of_melnyk = @oun_small }
	if = {
		limit = { check_variable = { var_oun_control_of_melnyk < 0 } }
		set_variable = { var_oun_control_of_melnyk = 0 }
	}
	oun_calculate_changes = yes
}
oun_increase_onslaught_small = {
	custom_effect_tooltip = oun_increase_onslaught_small_tt
	add_to_variable = { var_oun_onslaught_of_bandera = @oun_small }
	if = {
		limit = { check_variable = { var_oun_onslaught_of_bandera > 100 } }
		set_variable = { var_oun_onslaught_of_bandera = 100 }
	}
	oun_calculate_changes = yes
}
oun_lower_onslaught_small = {
	custom_effect_tooltip = oun_lower_onslaught_small_tt
	subtract_from_variable = { var_oun_onslaught_of_bandera = @oun_small }
	if = {
		limit = { check_variable = { var_oun_onslaught_of_bandera < 0 } }
		set_variable = { var_oun_onslaught_of_bandera = 0 }
	}
	oun_calculate_changes = yes
}
oun_increase_authority_big = {
	custom_effect_tooltip = oun_increase_authority_big_tt
	add_to_variable = { var_oun_authority_of_conovalets = @oun_big }
	if = {
		limit = { check_variable = { var_oun_authority_of_conovalets > 100 } }
		set_variable = { var_oun_authority_of_conovalets = 100 }
	}
	oun_calculate_changes = yes
}
oun_lower_authority_big = {
	custom_effect_tooltip = oun_lower_authority_big_tt
	subtract_from_variable = { var_oun_authority_of_conovalets = @oun_big }
	if = {
		limit = { check_variable = { var_oun_authority_of_conovalets < 0 } }
		set_variable = { var_oun_authority_of_conovalets = 0 }
	}
	oun_calculate_changes = yes
}
oun_increase_control_big = {
	custom_effect_tooltip = oun_increase_control_big_tt
	add_to_variable = { var_oun_control_of_melnyk = @oun_big }
	if = {
		limit = { check_variable = { var_oun_control_of_melnyk > 100 } }
		set_variable = { var_oun_control_of_melnyk = 100 }
	}
	oun_calculate_changes = yes
}
oun_lower_control_big = {
	custom_effect_tooltip = oun_lower_control_big_tt
	subtract_from_variable = { var_oun_control_of_melnyk = @oun_big }
	if = {
		limit = { check_variable = { var_oun_control_of_melnyk < 0 } }
		set_variable = { var_oun_control_of_melnyk = 0 }
	}
	oun_calculate_changes = yes
}
oun_increase_onslaught_big = {
	custom_effect_tooltip = oun_increase_onslaught_big_tt
	add_to_variable = { var_oun_onslaught_of_bandera = @oun_big }
	if = {
		limit = { check_variable = { var_oun_onslaught_of_bandera > 100 } }
		set_variable = { var_oun_onslaught_of_bandera = 100 }
	}
	oun_calculate_changes = yes
}
oun_lower_onslaught_big = {
	custom_effect_tooltip = oun_lower_onslaught_big_tt
	subtract_from_variable = { var_oun_onslaught_of_bandera = @oun_big }
	if = {
		limit = { check_variable = { var_oun_onslaught_of_bandera < 0 } }
		set_variable = { var_oun_onslaught_of_bandera = 0 }
	}
	oun_calculate_changes = yes
}

#####
##### PROPAGANDA SYSTEM #####
#####
UKR_pick_propaganda_campaign_slot_effect = {
	hidden_effect = {
		if = {
			limit = {
				check_variable = { UKR_poster_left_icon_frame = UKR_propaganda_empty_slot_index }
			}
			set_variable = { UKR_poster_left_icon_frame = UKR_new_propaganda_campaign }
			set_country_flag = { flag = UKR_propaganda_left_days_remaining_flag days = 180 }
		}
		else_if = {
			limit = {
				check_variable = { UKR_poster_center_icon_frame = UKR_propaganda_empty_slot_index }
			}
			set_variable = { UKR_poster_center_icon_frame = UKR_new_propaganda_campaign }
			set_country_flag = { flag = UKR_propaganda_center_days_remaining_flag days = 180 }
		}
		else_if = {
			limit = {
				check_variable = { UKR_poster_right_icon_frame = UKR_propaganda_empty_slot_index }
			}
			set_variable = { UKR_poster_right_icon_frame = UKR_new_propaganda_campaign }
			set_country_flag = { flag = UKR_propaganda_right_days_remaining_flag days = 180 }
		}
		set_variable = { UKR_new_propaganda_campaign = 0 } # Reset var
	}
}

UKR_reset_propaganda_campaign_slot_effect = {
	hidden_effect = {
		if = {
			limit = {
				check_variable = { UKR_poster_left_icon_frame = UKR_propaganda_campaign_to_remove }
			}
			set_variable = { UKR_poster_left_icon_frame = UKR_propaganda_empty_slot_index }
		}
		else_if = {
			limit = {
				check_variable = { UKR_poster_center_icon_frame = UKR_propaganda_campaign_to_remove }
			}
			set_variable = { UKR_poster_center_icon_frame = UKR_propaganda_empty_slot_index }
		}
		else_if = { #This could be turned into an else, but leaving it like this to hopefully make it easier to see
			limit = {
				check_variable = { UKR_poster_right_icon_frame = UKR_propaganda_campaign_to_remove }
			}
			set_variable = { UKR_poster_right_icon_frame = UKR_propaganda_empty_slot_index }
		}
		set_variable = { UKR_propaganda_campaign_to_remove = 0 } # Reset var
	}
}

UKR_unlock_propaganda_campaign_slot_effect = {
	custom_effect_tooltip = UKR_unlock_propaganda_campaign_slot_effect_tt
	hidden_effect = {
		if = {
			limit = {
				check_variable = { UKR_poster_left_icon_frame = UKR_propaganda_locked_slot_index }
			}
			set_variable = { UKR_poster_left_icon_frame = UKR_propaganda_empty_slot_index }
		}
		else_if = {
			limit = {
				check_variable = { UKR_poster_center_icon_frame = UKR_propaganda_locked_slot_index }
			}
			set_variable = { UKR_poster_center_icon_frame = UKR_propaganda_empty_slot_index }
		}
		else_if = {
			limit = {
				check_variable = { UKR_poster_right_icon_frame = UKR_propaganda_locked_slot_index }
			}
			set_variable = { UKR_poster_right_icon_frame = UKR_propaganda_empty_slot_index }
		}
	}
}

UKR_increase_propaganda_campaign_cost_effect = {
	multiply_variable = { UKR_propaganda_cost = UKR_propaganda_cost_increase }
}
# Replace AI vanilla paths for Intermarium root (only non historical)
replace_AI_paths_for_POL = {
	POL = {
		if = {
			limit = {
				OR = {
					has_dlc = "Poland: United and Ready"
					has_dlc = "No Step Back"
				}
				OR = {
					has_game_rule = {
						rule = POL_ai_behavior
						option = DEFAULT
					}
					has_game_rule = {
						rule = POL_ai_behavior
						option = RANDOM
					}
				}
			}
			POL = {
				clr_country_flag = POL_AI_RANDOM_COMMUNIST
				clr_country_flag = POL_AI_RANDOM_HISTORICAL
				clr_country_flag = POL_AI_RANDOM_DEMOCRATIC
				clr_country_flag = POL_AI_RANDOM_FASCIST
				clr_country_flag = POL_AI_RANDOM_FASCIST_INDEPENDENT
				clr_country_flag = POL_AI_RANDOM_COMMONWEALTH
				clr_country_flag = POL_AI_RANDOM_ROMANIA
				clr_country_flag = POL_AI_RANDOM_HABSBURG
				clr_country_flag = POL_AI_RANDOM_BERMONDT
				random_list = {
					15 = {
						modifier = {
							factor = 0.25
							game_weight_can_add_communist = no
						}
						set_country_flag = POL_AI_RANDOM_COMMUNIST
						set_add_communist_weight_small = yes
					}
					25 = {
						modifier = {
							factor = 2
							UKR = {
								has_game_rule = {
									rule = UKR_ai_behavior
									option = INTERMARIUM
								}
							}							
						}
						set_country_flag = POL_AI_RANDOM_INTERMARIUM
						log = "POL_AI_RANDOM_INTERMARIUM"
					}
					15 = {
						modifier = {
							factor = 0.25
							game_weight_can_add_democratic = no
						}
						set_country_flag = POL_AI_RANDOM_DEMOCRATIC
						set_add_democratic_weight_small = yes
					}
					10 = {
						modifier = {
							factor = 0.25
							game_weight_can_add_fascist = no
						}
						set_country_flag = POL_AI_RANDOM_FASCIST
						set_add_fascist_weight_small = yes
					}
					10 = {
						set_country_flag = POL_AI_RANDOM_FASCIST_INDEPENDENT
						set_add_fascist_weight_small = yes
						modifier = {
							factor = 0
							NOT = { has_dlc = "No Step Back" }
						}
						modifier = {
							factor = 0.25
							game_weight_can_add_fascist = no
						}
					}
					6 = {
						set_country_flag = POL_AI_RANDOM_COMMONWEALTH
						modifier = {
							factor = 0
							NOT = { has_dlc = "No Step Back" }
						}
						modifier = {
							factor = 0.25
							game_weight_can_add_unaligned = no
						}
						set_add_unaligned_weight_small = yes
					}
					6 = {
						set_country_flag = POL_AI_RANDOM_ROMANIA
						modifier = {
							factor = 0
							NOT = { has_dlc = "No Step Back" }
						}
						modifier = {
							factor = 0.25
							game_weight_can_add_unaligned = no
						}
						set_add_unaligned_weight_small = yes
					}
					6 = {
						set_country_flag = POL_AI_RANDOM_HABSBURG
						modifier = {
							factor = 0
							NOT = { has_dlc = "No Step Back" }
						}
						modifier = {
							factor = 0.25
							game_weight_can_add_unaligned = no
						}
						set_add_unaligned_weight_small = yes
					}
					3 = {
						set_country_flag = POL_AI_RANDOM_BERMONDT
						modifier = {
							factor = 0
							NOT = { has_dlc = "No Step Back" }
						}
						modifier = {
							factor = 0.25
							game_weight_can_add_fascist = no
						}
						set_add_fascist_weight_small = yes
					}
				}
			}
		}
	}
}
# White peace with all members of factions
# needs "add_to_array = { white_peace_countries_array = TAG }" before use
UKR_white_peace_with_alliances = {
	custom_effect_tooltip = UKR_white_peace_with_alliances_tt
	hidden_effect = {
		for_each_scope_loop = {
			array = white_peace_countries_array
			white_peace = ROOT
			every_other_country = {
				limit = { 
					OR = {
						is_in_faction_with = ROOT
						is_subject_of = ROOT
					}
					has_war_with = PREV
				}
				white_peace = PREV
			}
			every_other_country = {
				limit = { 
					OR = {
						is_in_faction_with = PREV
						is_subject_of = PREV
					}
					has_war_with = ROOT
				}
				white_peace = ROOT
			}
		}
		clear_array = white_peace_countries_array
	}
}
UKR_create_wargoal_against_poland = {
	create_wargoal = {
		type = take_state_focus
		target = POL
		generator = { 89 91 93 1052 }
	}
}
#####
##### SANITARY CORDON #####
#####
UKR_sancordon_bonus_defence_increase = {
	hidden_effect = {
		if = {
			limit = {
				has_idea = sancordon_bonus_defence_minus_5
			}
			swap_ideas = {
				add_idea = sancordon_bonus_defence_null
				remove_idea = sancordon_bonus_defence_minus_5
			}
			set_variable = { var_ukr_sancordon_bonus_defence_loc = 0 }
		}
		else_if = {
			limit = {
				has_idea = sancordon_bonus_defence_null
			}
			swap_ideas = {
				add_idea = sancordon_bonus_defence_5
				remove_idea = sancordon_bonus_defence_null
			}
			set_variable = { var_ukr_sancordon_bonus_defence_loc = 5 }
		}
		else_if = {
			limit = {
				has_idea = sancordon_bonus_defence_5
			}
			swap_ideas = {
				add_idea = sancordon_bonus_defence_10
				remove_idea = sancordon_bonus_defence_5
			}
			set_variable = { var_ukr_sancordon_bonus_defence_loc = 10 }
		}
		else_if = {
			limit = {
				has_idea = sancordon_bonus_defence_10
			}
			swap_ideas = {
				add_idea = sancordon_bonus_defence_15
				remove_idea = sancordon_bonus_defence_10
			}
			set_variable = { var_ukr_sancordon_bonus_defence_loc = 15 }
		}
	}
	if = {
		limit = {
			has_idea = UKR_sanitary_cordon
			OR = {
				has_idea = sancordon_bonus_defence_minus_5
				has_idea = sancordon_bonus_defence_null
				has_idea = sancordon_bonus_defence_5
				has_idea = sancordon_bonus_defence_10
			}
		}
		custom_effect_tooltip = UKR_sancordon_bonus_defence_increase_tt
	}
}
UKR_sancordon_bonus_defence_decrease = {
	hidden_effect = {
		if = {
			limit = {
				has_idea = sancordon_bonus_defence_null
			}
			swap_ideas = {
				add_idea = sancordon_bonus_defence_minus_5
				remove_idea = sancordon_bonus_defence_null
			}
			set_variable = { var_ukr_sancordon_bonus_defence_loc = -5 }
		}
		else_if = {
			limit = {
				has_idea = sancordon_bonus_defence_5
			}
			swap_ideas = {
				add_idea = sancordon_bonus_defence_null
				remove_idea = sancordon_bonus_defence_5
			}
			set_variable = { var_ukr_sancordon_bonus_defence_loc = 0 }
		}
		else_if = {
			limit = {
				has_idea = sancordon_bonus_defence_10
			}
			swap_ideas = {
				add_idea = sancordon_bonus_defence_5
				remove_idea = sancordon_bonus_defence_10
			}
			set_variable = { var_ukr_sancordon_bonus_defence_loc = 5 }
		}
		else_if = {
			limit = {
				has_idea = sancordon_bonus_defence_15
			}
			swap_ideas = {
				add_idea = sancordon_bonus_defence_10
				remove_idea = sancordon_bonus_defence_15
			}
			set_variable = { var_ukr_sancordon_bonus_defence_loc = 10 }
		}
	}
	if = {
		limit = {
			has_idea = UKR_sanitary_cordon
			OR = {
				has_idea = sancordon_bonus_defence_null
				has_idea = sancordon_bonus_defence_5
				has_idea = sancordon_bonus_defence_10
				has_idea = sancordon_bonus_defence_15
			}
		}
		custom_effect_tooltip = UKR_sancordon_bonus_defence_decrease_tt
	}
}
UKR_sancordon_bonus_attack_increase = {
	hidden_effect = {
		if = {
			limit = {
				has_idea = sancordon_bonus_attack_minus_5
			}
			swap_ideas = {
				add_idea = sancordon_bonus_attack_null
				remove_idea = sancordon_bonus_attack_minus_5
			}
			set_variable = { var_ukr_sancordon_bonus_attack_loc = 0 }
		}
		else_if = {
			limit = {
				has_idea = sancordon_bonus_attack_null
			}
			swap_ideas = {
				add_idea = sancordon_bonus_attack_5
				remove_idea = sancordon_bonus_attack_null
			}
			set_variable = { var_ukr_sancordon_bonus_attack_loc = 5 }
		}
		else_if = {
			limit = {
				has_idea = sancordon_bonus_attack_5
			}
			swap_ideas = {
				add_idea = sancordon_bonus_attack_10
				remove_idea = sancordon_bonus_attack_5
			}
			set_variable = { var_ukr_sancordon_bonus_attack_loc = 10 }
		}
	}
	if = {
		limit = {
			has_idea = UKR_sanitary_cordon
			OR = {
				has_idea = sancordon_bonus_attack_minus_5
				has_idea = sancordon_bonus_attack_null
				has_idea = sancordon_bonus_attack_5
			}
		}
		custom_effect_tooltip = UKR_sancordon_bonus_attack_increase_tt
	}
}
UKR_sancordon_bonus_attack_decrease = {
	hidden_effect = {
		if = {
			limit = {
				has_idea = sancordon_bonus_attack_null
			}
			swap_ideas = {
				add_idea = sancordon_bonus_attack_minus_5
				remove_idea = sancordon_bonus_attack_null
			}
			set_variable = { var_ukr_sancordon_bonus_attack_loc = -5 }
		}
		else_if = {
			limit = {
				has_idea = sancordon_bonus_attack_5
			}
			swap_ideas = {
				add_idea = sancordon_bonus_attack_null
				remove_idea = sancordon_bonus_attack_5
			}
			set_variable = { var_ukr_sancordon_bonus_attack_loc = 0 }
		}
		else_if = {
			limit = {
				has_idea = sancordon_bonus_attack_10
			}
			swap_ideas = {
				add_idea = sancordon_bonus_attack_5
				remove_idea = sancordon_bonus_attack_10
			}
			set_variable = { var_ukr_sancordon_bonus_attack_loc = 5 }
		}
	}
	if = {
		limit = {
			has_idea = UKR_sanitary_cordon
			OR = {
				has_idea = sancordon_bonus_attack_null
				has_idea = sancordon_bonus_attack_5
				has_idea = sancordon_bonus_attack_10
			}
		}
		custom_effect_tooltip = UKR_sancordon_bonus_attack_decrease_tt
	}
}
UKR_inner_circle_set_ascension_cd = {
	set_country_flag = {
		flag = UKR_inner_circle_cd_flag
		days = 175
		value = 1
	}
}
UKR_remove_replaced_advisor_1_effects = {
	custom_effect_tooltip = {
		localization_key = replace_ascended_advisor_tt
		CHARACTER = [UKRGetAscendedAdvisorName1]
		TRAIT = [UKRGetAscendedAdvisorDesc1]
	}
	hidden_effect = {
		if = { 
			limit = {
				check_variable = { UKR_ascended_advisor_1 = 1 }
			}
			UKR_remove_chubar_effects = yes
		}
		else_if = { 
			limit = {
				check_variable = { UKR_ascended_advisor_1 = 2 }
			}
			UKR_remove_khvylovy_effects = yes
		}
		else_if = { 
			limit = {
				check_variable = { UKR_ascended_advisor_1 = 3 }
			}
			UKR_remove_shumskyi_effects = yes
		}
		else_if = { 
			limit = {
				check_variable = { UKR_ascended_advisor_1 = 4 }
			}
			UKR_remove_sokolovska_effects = yes
		}
		else_if = { 
			limit = {
				check_variable = { UKR_ascended_advisor_1 = 5 }
			}
			UKR_remove_trotsky_effects = yes
		}
		else_if = { 
			limit = {
				check_variable = { UKR_ascended_advisor_1 = 6 }
			}
			UKR_remove_mazepa_effects = yes
		}
		else = {
			log = "Something bad happened trying to remove advisor [?UKR_ascended_advisor_1] effects."
		}
	}
}

UKR_remove_replaced_advisor_2_effects = {
	custom_effect_tooltip = {
		localization_key = replace_ascended_advisor_tt
		CHARACTER = [UKRGetAscendedAdvisorName2]
		TRAIT = [UKRGetAscendedAdvisorDesc2]
	}
	hidden_effect = {
		if = { 
			limit = {
				check_variable = { UKR_ascended_advisor_2 = 1 }
			}
			UKR_remove_chubar_effects = yes
		}
		else_if = { 
			limit = {
				check_variable = { UKR_ascended_advisor_2 = 2 }
			}
			UKR_remove_khvylovy_effects = yes
		}
		else_if = { 
			limit = {
				check_variable = { UKR_ascended_advisor_2 = 3 }
			}
			UKR_remove_shumskyi_effects = yes
		}
		else_if = { 
			limit = {
				check_variable = { UKR_ascended_advisor_2 = 4 }
			}
			UKR_remove_sokolovska_effects = yes
		}
		else_if = { 
			limit = {
				check_variable = { UKR_ascended_advisor_2 = 5 }
			}
			UKR_remove_trotsky_effects = yes
		}
		else_if = { 
			limit = {
				check_variable = { UKR_ascended_advisor_2 = 6 }
			}
			UKR_remove_mazepa_effects = yes
		}
		else = {
			log = "Something bad happened trying to remove advisor [?UKR_ascended_advisor_2] effects."
		}
	}
}

UKR_remove_replaced_advisor_3_effects = {
	custom_effect_tooltip = {
		localization_key = replace_ascended_advisor_tt
		CHARACTER = [UKRGetAscendedAdvisorName3]
		TRAIT = [UKRGetAscendedAdvisorDesc3]
	}
	hidden_effect = {
		if = { 
			limit = {
				check_variable = { UKR_ascended_advisor_3 = 1 }
			}
			UKR_remove_chubar_effects = yes
		}
		else_if = { 
			limit = {
				check_variable = { UKR_ascended_advisor_3 = 2 }
			}
			UKR_remove_khvylovy_effects = yes
		}
		else_if = { 
			limit = {
				check_variable = { UKR_ascended_advisor_3 = 3 }
			}
			UKR_remove_shumskyi_effects = yes
		}
		else_if = { 
			limit = {
				check_variable = { UKR_ascended_advisor_3 = 4 }
			}
			UKR_remove_sokolovska_effects = yes
		}
		else_if = { 
			limit = {
				check_variable = { UKR_ascended_advisor_3 = 5 }
			}
			UKR_remove_trotsky_effects = yes
		}
		else_if = { 
			limit = {
				check_variable = { UKR_ascended_advisor_3 = 6 }
			}
			UKR_remove_mazepa_effects = yes
		}
		else = {
			log = "Something bad happened trying to remove advisor [?UKR_ascended_advisor_3] effects."
		}
	}
}
UKR_remove_chubar_effects = {
	if = {
		limit = {
			has_idea = UKR_chubar_secretar_idea_1
		}
		remove_ideas = UKR_chubar_secretar_idea_1
	}
	else_if = {
		limit = {
			has_idea = UKR_chubar_secretar_idea_2
		}
		remove_ideas = UKR_chubar_secretar_idea_2
	}
	else_if = {
		limit = {
			has_idea = UKR_chubar_secretar_idea_3
		}
		remove_ideas = UKR_chubar_secretar_idea_3
	}
	else = {
		log = "NOTHING TO REMOVE FROM CHUBAR"
	}

	if = { #STOP ANY FOCUS IN-PROGRESS (WITH SHINY EFFECT)
		limit = {
			has_shine_effect_on_focus = UKR_finance_heavy_industry
		}
		deactivate_shine_on_focus = UKR_finance_heavy_industry
		clr_country_flag = UKR_finance_heavy_industry_in_progress_flag
	}
	else_if = {
		limit = {
			has_shine_effect_on_focus = UKR_financing_of_field_development
		}
		deactivate_shine_on_focus = UKR_financing_of_field_development
		clr_country_flag = UKR_financing_of_field_development_in_progress_flag
	}
	else_if = {
		limit = {
			has_shine_effect_on_focus = UKR_purchase_of_modern_machines
		}
		deactivate_shine_on_focus = UKR_purchase_of_modern_machines
		clr_country_flag = UKR_purchase_of_modern_machines_in_progress_flag
	}

	#Uncomplete Ascension focus so that he can be picked later on
	uncomplete_national_focus = {
		focus = UKR_secsec_chubar
		uncomplete_children = no
		refund_political_power = no
	}

	if = { # REMOVE FROM ASCENDED ADVISOR
		limit = {
			check_variable = { UKR_ascended_advisor_1 = 1 }
		}
		set_variable = { UKR_ascended_advisor_1 = 0 }
	}
	else_if = {
		limit = {
			check_variable = { UKR_ascended_advisor_2 = 1 }
		}
		set_variable = { UKR_ascended_advisor_2 = 0 }
	}
	else_if = {
		limit = {
			check_variable = { UKR_ascended_advisor_3 = 1 }
		}
		set_variable = { UKR_ascended_advisor_3 = 0 }
	}
}
UKR_remove_khvylovy_effects = {
	if = {
		limit = {
			has_idea = UKR_khvylovy_secretar_idea_1
		}
		remove_ideas = UKR_khvylovy_secretar_idea_1
	}
	else_if = {
		limit = {
			has_idea = UKR_khvylovy_secretar_idea_2
		}
		remove_ideas = UKR_khvylovy_secretar_idea_2
	}
	else_if = {
		limit = {
			has_idea = UKR_khvylovy_secretar_idea_3
		}
		remove_ideas = UKR_khvylovy_secretar_idea_3
	}
	else_if = {
		limit = {
			has_idea = UKR_khvylovy_secretar_idea_4
		}
		remove_ideas = UKR_khvylovy_secretar_idea_4
	}
	else = {
		log = "NOTHING TO REMOVE FROM KHVYLOVY"
	}

	if = { #STOP ANY FOCUS IN-PROGRESS (WITH SHINY EFFECT)
		limit = {
			has_shine_effect_on_focus = UKR_education_of_the_masses
		}
		deactivate_shine_on_focus = UKR_education_of_the_masses
		clr_country_flag = UKR_education_of_the_masses_in_progress_flag
	}
	else_if = {
		limit = {
			has_shine_effect_on_focus = UKR_finanses_for_kino
		}
		deactivate_shine_on_focus = UKR_finanses_for_kino
		clr_country_flag = UKR_finanses_for_kino_in_progress_flag
	}
	else_if = {
		limit = {
			has_shine_effect_on_focus = UKR_national_revival
		}
		deactivate_shine_on_focus = UKR_national_revival
		clr_country_flag = UKR_national_revival_in_progress_flag
	}

	#Uncomplete Ascension focus so that he can be picked later on
	uncomplete_national_focus = {
		focus = UKR_secsec_khvylovy
		uncomplete_children = no
		refund_political_power = no
	}

	if = { # REMOVE FROM ASCENDED ADVISOR
		limit = {
			check_variable = { UKR_ascended_advisor_1 = 2 }
		}
		set_variable = { UKR_ascended_advisor_1 = 0 }
	}
	else_if = {
		limit = {
			check_variable = { UKR_ascended_advisor_2 = 2 }
		}
		set_variable = { UKR_ascended_advisor_2 = 0 }
	}
	else_if = {
		limit = {
			check_variable = { UKR_ascended_advisor_3 = 2 }
		}
		set_variable = { UKR_ascended_advisor_3 = 0 }
	}
}
UKR_remove_sokolovska_effects = {
	if = {
		limit = {
			has_idea = UKR_sokolovska_secretar_idea_1
		}
		remove_ideas = UKR_sokolovska_secretar_idea_1
	}
	else_if = {
		limit = {
			has_idea = UKR_sokolovska_secretar_idea_2
		}
		remove_ideas = UKR_sokolovska_secretar_idea_2
	}
	else_if = {
		limit = {
			has_idea = UKR_sokolovska_secretar_idea_3
		}
		remove_ideas = UKR_sokolovska_secretar_idea_3
	}
	else_if = {
		limit = {
			has_idea = UKR_sokolovska_secretar_idea_4
		}
		remove_ideas = UKR_sokolovska_secretar_idea_4
	}
	else = {
		log = "NOTHING TO REMOVE FROM SOKOLOVSKA"
	}

	if = { #STOP ANY FOCUS IN-PROGRESS (WITH SHINY EFFECT)
		limit = {
			has_shine_effect_on_focus = UKR_socialistic_education
		}
		deactivate_shine_on_focus = UKR_socialistic_education
		clr_country_flag = UKR_socialistic_education_in_progress_flag
	}
	else_if = {
		limit = {
			has_shine_effect_on_focus = UKR_universal_equality
		}
		deactivate_shine_on_focus = UKR_universal_equality
		clr_country_flag = UKR_universal_equality_in_progress_flag
	}
	else_if = {
		limit = {
			has_shine_effect_on_focus = UKR_special_science_projects
		}
		deactivate_shine_on_focus = UKR_special_science_projects
		clr_country_flag = UKR_special_science_projects_in_progress_flag
	}

	#Uncomplete Ascension focus so that he can be picked later on
	uncomplete_national_focus = {
		focus = UKR_secsec_sokolovska
		uncomplete_children = no
		refund_political_power = no
	}

	if = { # REMOVE FROM ASCENDED ADVISOR
		limit = {
			check_variable = { UKR_ascended_advisor_1 = 4 }
		}
		set_variable = { UKR_ascended_advisor_1 = 0 }
	}
	else_if = {
		limit = {
			check_variable = { UKR_ascended_advisor_2 = 4 }
		}
		set_variable = { UKR_ascended_advisor_2 = 0 }
	}
	else_if = {
		limit = {
			check_variable = { UKR_ascended_advisor_3 = 4 }
		}
		set_variable = { UKR_ascended_advisor_3 = 0 }
	}
}
UKR_remove_shumskyi_effects = {
	if = {
		limit = {
			has_idea = UKR_shumskyi_secretar_idea_1
		}
		remove_ideas = UKR_shumskyi_secretar_idea_1
	}
	else_if = {
		limit = {
			has_idea = UKR_shumskyi_secretar_idea_2
		}
		remove_ideas = UKR_shumskyi_secretar_idea_2
	}
	else_if = {
		limit = {
			has_idea = UKR_shumskyi_secretar_idea_3
		}
		remove_ideas = UKR_shumskyi_secretar_idea_3
	}
	else = {
		log = "NOTHING TO REMOVE FROM SHUMSKYI"
	}

	if = { #STOP ANY FOCUS IN-PROGRESS (WITH SHINY EFFECT)
		limit = {
			has_shine_effect_on_focus = UKR_red_diplomacy
		}
		deactivate_shine_on_focus = UKR_red_diplomacy
		clr_country_flag = UKR_red_diplomacy_in_progress_flag
	}
	else_if = {
		limit = {
			has_shine_effect_on_focus = UKR_active_actions
		}
		deactivate_shine_on_focus = UKR_active_actions
		clr_country_flag = UKR_active_actions_in_progress_flag
	}
	else_if = {
		limit = {
			has_shine_effect_on_focus = UKR_ally_coordination
		}
		deactivate_shine_on_focus = UKR_ally_coordination
		clr_country_flag = UKR_ally_coordination_in_progress_flag
	}

	#Uncomplete Ascension focus so that he can be picked later on
	uncomplete_national_focus = {
		focus = UKR_secsec_shumskyi
		uncomplete_children = no
		refund_political_power = no
	}

	if = { # REMOVE FROM ASCENDED ADVISOR
		limit = {
			check_variable = { UKR_ascended_advisor_1 = 3 }
		}
		set_variable = { UKR_ascended_advisor_1 = 0 }
	}
	else_if = {
		limit = {
			check_variable = { UKR_ascended_advisor_2 = 3 }
		}
		set_variable = { UKR_ascended_advisor_2 = 0 }
	}
	else_if = {
		limit = {
			check_variable = { UKR_ascended_advisor_3 = 3 }
		}
		set_variable = { UKR_ascended_advisor_3 = 0 }
	}
}
UKR_remove_trotsky_effects = {
	if = {
		limit = {
			has_idea = UKR_trotsky_secretar_idea_1
		}
		remove_ideas = UKR_trotsky_secretar_idea_1
	}
	else_if = {
		limit = {
			has_idea = UKR_trotsky_secretar_idea_2
		}
		remove_ideas = UKR_trotsky_secretar_idea_2
	}
	else_if = {
		limit = {
			has_idea = UKR_trotsky_secretar_idea_3
		}
		remove_ideas = UKR_trotsky_secretar_idea_3
	}
	else_if = {
		limit = {
			has_idea = UKR_trotsky_secretar_idea_4
		}
		remove_ideas = UKR_trotsky_secretar_idea_4
	}
	else = {
		log = "NOTHING TO REMOVE FROM TROTSKY"
	}

	if = { #STOP ANY FOCUS IN-PROGRESS (WITH SHINY EFFECT)
		limit = {
			has_shine_effect_on_focus = UKR_organisator_of_red_army
		}
		deactivate_shine_on_focus = UKR_organisator_of_red_army
		clr_country_flag = UKR_organisator_of_red_army_in_progress_flag
	}
	else_if = {
		limit = {
			has_shine_effect_on_focus = UKR_prepare_for_revolution
		}
		deactivate_shine_on_focus = UKR_prepare_for_revolution
		clr_country_flag = UKR_prepare_for_revolution_in_progress_flag
	}
	else_if = {
		limit = {
			has_shine_effect_on_focus = UKR_uniting_around_idea
		}
		deactivate_shine_on_focus = UKR_uniting_around_idea
		clr_country_flag = UKR_uniting_around_idea_in_progress_flag
	}

	#Uncomplete Ascension focus so that he can be picked later on
	uncomplete_national_focus = {
		focus = UKR_secsec_trotsky
		uncomplete_children = no
		refund_political_power = no
	}

	if = { # REMOVE FROM ASCENDED ADVISOR
		limit = {
			check_variable = { UKR_ascended_advisor_1 = 5 }
		}
		set_variable = { UKR_ascended_advisor_1 = 0 }
	}
	else_if = {
		limit = {
			check_variable = { UKR_ascended_advisor_2 = 5 }
		}
		set_variable = { UKR_ascended_advisor_2 = 0 }
	}
	else_if = {
		limit = {
			check_variable = { UKR_ascended_advisor_3 = 5 }
		}
		set_variable = { UKR_ascended_advisor_3 = 0 }
	}
}
UKR_remove_mazepa_effects = {
	if = {
		limit = {
			has_idea = UKR_mazepa_secretar_idea_1
		}
		remove_ideas = UKR_mazepa_secretar_idea_1
	}
	else_if = {
		limit = {
			has_idea = UKR_mazepa_secretar_idea_2
		}
		remove_ideas = UKR_mazepa_secretar_idea_2
	}
	else_if = {
		limit = {
			has_idea = UKR_mazepa_secretar_idea_3
		}
		remove_ideas = UKR_mazepa_secretar_idea_3
	}
	else_if = {
		limit = {
			has_idea = UKR_mazepa_secretar_idea_4
		}
		remove_ideas = UKR_mazepa_secretar_idea_4
	}
	else = {
		log = "NOTHING TO REMOVE FROM MAZEPA"
	}

	if = { #STOP ANY FOCUS IN-PROGRESS (WITH SHINY EFFECT)
		limit = {
			has_shine_effect_on_focus = UKR_strengthening_of_security_service
		}
		deactivate_shine_on_focus = UKR_strengthening_of_security_service
		clr_country_flag = UKR_strengthening_of_security_service_in_progress_flag
	}
	else_if = {
		limit = {
			has_shine_effect_on_focus = UKR_unemployed_detachments
		}
		deactivate_shine_on_focus = UKR_unemployed_detachments
		clr_country_flag = UKR_unemployed_detachments_in_progress_flag
	}
	else_if = {
		limit = {
			has_shine_effect_on_focus = UKR_cooperation_or_death
		}
		deactivate_shine_on_focus = UKR_cooperation_or_death
		clr_country_flag = UKR_cooperation_or_death_in_progress_flag
	}

	#Uncomplete Ascension focus so that he can be picked later on
	uncomplete_national_focus = {
		focus = UKR_secsec_mazepa
		uncomplete_children = no
		refund_political_power = no
	}

	if = { # REMOVE FROM ASCENDED ADVISOR
		limit = {
			check_variable = { UKR_ascended_advisor_1 = 6 }
		}
		set_variable = { UKR_ascended_advisor_1 = 0 }
	}
	else_if = {
		limit = {
			check_variable = { UKR_ascended_advisor_2 = 6 }
		}
		set_variable = { UKR_ascended_advisor_2 = 0 }
	}
	else_if = {
		limit = {
			check_variable = { UKR_ascended_advisor_3 = 6 }
		}
		set_variable = { UKR_ascended_advisor_3 = 0 }
	}
}
#### Voluntarism system
UKR_update_vlnt_ui_effect = {
	if = {
		limit = {
			check_variable = { UKR_voluntarism_value = 0 }
		}
		set_variable = { UKR_voluntarism_main_meter = 1 }
	}
	else_if = {
		limit = {
			check_variable = { UKR_voluntarism_value = 5 compare = less_than_or_equals }
		}
		set_variable = { UKR_voluntarism_main_meter = 2 }
	}
	else_if = {
		limit = {
			check_variable = { UKR_voluntarism_value = 10 compare = less_than_or_equals }
		}
		set_variable = { UKR_voluntarism_main_meter = 3 }
	}
	else_if = {
		limit = {
			check_variable = { UKR_voluntarism_value = 15 compare = less_than_or_equals }
		}
		set_variable = { UKR_voluntarism_main_meter = 4 }
	}
	else_if = {
		limit = {
			check_variable = { UKR_voluntarism_value = 20 compare = less_than_or_equals }
		}
		set_variable = { UKR_voluntarism_main_meter = 5 }
	}
	else_if = {
		limit = {
			check_variable = { UKR_voluntarism_value = 25 compare = less_than_or_equals }
		}
		set_variable = { UKR_voluntarism_main_meter = 6 }
	}
	else_if = {
		limit = {
			check_variable = { UKR_voluntarism_value = 30 compare = less_than_or_equals }
		}
		set_variable = { UKR_voluntarism_main_meter = 7 }
	}
	else_if = {
		limit = {
			check_variable = { UKR_voluntarism_value = 35 compare = less_than_or_equals }
		}
		set_variable = { UKR_voluntarism_main_meter = 8 }
	}
	else_if = {
		limit = {
			check_variable = { UKR_voluntarism_value = 40 compare = less_than_or_equals }
		}
		set_variable = { UKR_voluntarism_main_meter = 9 }
	}
	else_if = {
		limit = {
			check_variable = { UKR_voluntarism_value = 45 compare = less_than_or_equals }
		}
		set_variable = { UKR_voluntarism_main_meter = 10 }
	}
	else_if = {
		limit = {
			check_variable = { UKR_voluntarism_value = 50 compare = less_than_or_equals }
		}
		set_variable = { UKR_voluntarism_main_meter = 11 }
	}
	else_if = {
		limit = {
			check_variable = { UKR_voluntarism_value = 55 compare = less_than_or_equals }
		}
		set_variable = { UKR_voluntarism_main_meter = 12 }
	}
	else_if = {
		limit = {
			check_variable = { UKR_voluntarism_value = 60 compare = less_than_or_equals }
		}
		set_variable = { UKR_voluntarism_main_meter = 13 }
	}
	else_if = {
		limit = {
			check_variable = { UKR_voluntarism_value = 65 compare = less_than_or_equals }
		}
		set_variable = { UKR_voluntarism_main_meter = 14 }
	}
	else_if = {
		limit = {
			check_variable = { UKR_voluntarism_value = 70 compare = less_than_or_equals }
		}
		set_variable = { UKR_voluntarism_main_meter = 15 }
	}
	else_if = {
		limit = {
			check_variable = { UKR_voluntarism_value = 75 compare = less_than_or_equals }
		}
		set_variable = { UKR_voluntarism_main_meter = 16 }
	}
	else_if = {
		limit = {
			check_variable = { UKR_voluntarism_value = 80 compare = less_than_or_equals }
		}
		set_variable = { UKR_voluntarism_main_meter = 17 }
	}
	else_if = {
		limit = {
			check_variable = { UKR_voluntarism_value = 85 compare = less_than_or_equals }
		}
		set_variable = { UKR_voluntarism_main_meter = 18 }
	}
	else_if = {
		limit = {
			check_variable = { UKR_voluntarism_value = 90 compare = less_than_or_equals }
		}
		set_variable = { UKR_voluntarism_main_meter = 19 }
	}
	else_if = {
		limit = {
			check_variable = { UKR_voluntarism_value = 95 compare = less_than_or_equals }
		}
		set_variable = { UKR_voluntarism_main_meter = 20 }
	}
	else = { # paranoia > 95
		set_variable = { UKR_voluntarism_main_meter = 21 }
	}
}
set_vlnt_level_1 = {
	hidden_effect = {
		if = { 
			limit = { has_idea = UKR_voluntarism_level_2 }
			remove_ideas = UKR_voluntarism_level_2
		}
		else_if = {
			limit = { has_idea = UKR_voluntarism_level_3 }
			remove_ideas = UKR_voluntarism_level_3
		}
		else_if = {
			limit = { has_idea = UKR_voluntarism_level_4 }
			remove_ideas = UKR_voluntarism_level_4
		}
		else_if = {
			limit = { has_idea = UKR_voluntarism_level_5 }
			remove_ideas = UKR_voluntarism_level_5
		}
		if = {
			limit = { NOT = { has_idea = UKR_voluntarism_level_1 } }
			add_ideas = UKR_voluntarism_level_1
		}
	}
}
set_vlnt_level_2 = {
	hidden_effect = {
		if = { 
			limit = { has_idea = UKR_voluntarism_level_1 }
			remove_ideas = UKR_voluntarism_level_1
		}
		else_if = {
			limit = { has_idea = UKR_voluntarism_level_3 }
			remove_ideas = UKR_voluntarism_level_3
		}
		else_if = {
			limit = { has_idea = UKR_voluntarism_level_4 }
			remove_ideas = UKR_voluntarism_level_4
		}
		else_if = {
			limit = { has_idea = UKR_voluntarism_level_5 }
			remove_ideas = UKR_voluntarism_level_5
		}
		if = {
			limit = { NOT = { has_idea = UKR_voluntarism_level_2 } }
			add_ideas = UKR_voluntarism_level_2
		}
	}
}
set_vlnt_level_3 = {
	hidden_effect = {
		if = { 
			limit = { has_idea = UKR_voluntarism_level_2 }
			remove_ideas = UKR_voluntarism_level_2
		}
		else_if = {
			limit = { has_idea = UKR_voluntarism_level_1 }
			remove_ideas = UKR_voluntarism_level_1
		}
		else_if = {
			limit = { has_idea = UKR_voluntarism_level_4 }
			remove_ideas = UKR_voluntarism_level_4
		}
		else_if = {
			limit = { has_idea = UKR_voluntarism_level_5 }
			remove_ideas = UKR_voluntarism_level_5
		}
		if = {
			limit = { NOT = { has_idea = UKR_voluntarism_level_3 } }
			add_ideas = UKR_voluntarism_level_3
		}
	}
}
set_vlnt_level_4 = {
	hidden_effect = {
		if = { 
			limit = { has_idea = UKR_voluntarism_level_2 }
			remove_ideas = UKR_voluntarism_level_2
		}
		else_if = {
			limit = { has_idea = UKR_voluntarism_level_3 }
			remove_ideas = UKR_voluntarism_level_3
		}
		else_if = {
			limit = { has_idea = UKR_voluntarism_level_1 }
			remove_ideas = UKR_voluntarism_level_1
		}
		else_if = {
			limit = { has_idea = UKR_voluntarism_level_5 }
			remove_ideas = UKR_voluntarism_level_5
		}
		if = {
			limit = { NOT = { has_idea = UKR_voluntarism_level_4 } }
			add_ideas = UKR_voluntarism_level_4
		}
	}
}
set_vlnt_level_5 = {
	hidden_effect = {
		if = { 
			limit = { has_idea = UKR_voluntarism_level_2 }
			remove_ideas = UKR_voluntarism_level_2
		}
		else_if = {
			limit = { has_idea = UKR_voluntarism_level_3 }
			remove_ideas = UKR_voluntarism_level_3
		}
		else_if = {
			limit = { has_idea = UKR_voluntarism_level_4 }
			remove_ideas = UKR_voluntarism_level_4
		}
		else_if = {
			limit = { has_idea = UKR_voluntarism_level_1 }
			remove_ideas = UKR_voluntarism_level_1
		}
		if = {
			limit = { NOT = { has_idea = UKR_voluntarism_level_5 } }
			add_ideas = UKR_voluntarism_level_5
		}
	}
}
UKR_vlnt_clamp_and_update_ui_effect = {
	clamp_variable = {
		var = UKR_voluntarism_value
		min = 0
		max = 100
	}
	if = {
		limit = { 
			check_variable = { UKR_voluntarism_value < 20 }
		}
		set_vlnt_level_1 = yes
	}
	else_if = {
		limit = { 
			check_variable = { UKR_voluntarism_value < 40 }
		}
		set_vlnt_level_2 = yes
	}
	else_if = {
		limit = { 
			check_variable = { UKR_voluntarism_value < 60 }
		}
		set_vlnt_level_3 = yes
	}
	else_if = {
		limit = { 
			check_variable = { UKR_voluntarism_value < 80 }
		}
		set_vlnt_level_4 = yes
	}
	else = {
		set_vlnt_level_5 = yes
	}
	if = {
		limit = { 
			has_country_flag = UKR_vlnt_not_more_50
			check_variable = { UKR_voluntarism_value > 50 }
		}
		clr_country_flag = UKR_vlnt_not_more_50
	}
	UKR_update_vlnt_ui_effect = yes
}
UKR_vlnt_weekly_increase_effect = {
	add_to_variable = { UKR_voluntarism_value = UKR_voluntarism_weekly_increase }
	UKR_vlnt_clamp_and_update_ui_effect = yes
}
UKR_vlnt_increase_small = {
	custom_effect_tooltip = UKR_vlnt_increase_small_tt
	add_to_variable = { UKR_voluntarism_value = @vlnt_small }
	UKR_vlnt_clamp_and_update_ui_effect = yes
}
UKR_vlnt_increase_big = {
	custom_effect_tooltip = UKR_vlnt_increase_big_tt
	add_to_variable = { UKR_voluntarism_value = @vlnt_big }
	UKR_vlnt_clamp_and_update_ui_effect = yes
}
UKR_vlnt_decrease_small = {
	custom_effect_tooltip = UKR_vlnt_decrease_small_tt
	subtract_from_variable = { UKR_voluntarism_value = @vlnt_small }
	UKR_vlnt_clamp_and_update_ui_effect = yes
}
UKR_vlnt_decrease_big = {
	custom_effect_tooltip = UKR_vlnt_decrease_big_tt
	subtract_from_variable = { UKR_voluntarism_value = @vlnt_big }
	UKR_vlnt_clamp_and_update_ui_effect = yes
}
