ENG_congress_get_quorum = {
	set_variable = { var = quorum_low value = senators_total }
	multiply_variable = { var = quorum_low value = 0.4 }
	set_variable = { var = quorum_medium value = senators_total }
	multiply_variable = { var = quorum_medium value = 0.5 }
	set_variable = { var = quorum_high value = senators_total }
	multiply_variable = { var = quorum_high value = 0.6 }
	round_variable = quorum_low 
	round_variable = quorum_medium 
	round_variable = quorum_high
	ENG_recalc_congress_icon_frames = yes
}
ENG_congress_remove_state = {
	custom_effect_tooltip = mtg_eng_congress_remove_state_tt
	subtract_from_variable = { senators_total = 2 }
	clamp_variable = { var = senators_support max = senators_total min = 0 }
	ENG_congress_get_quorum = yes
	ENG_recalc_congress_icon_frames = yes
}
ENG_congress_add_state = {
	custom_effect_tooltip = mtg_eng_congress_add_state_tt
	add_to_variable = { senators_total = 2 }
	add_to_variable = { senators_support = 2 }
	ENG_congress_get_quorum = yes
	ENG_recalc_congress_icon_frames = yes
}
ENG_congress_small_opposition = {
	custom_effect_tooltip = mtg_eng_congress_small_opposition_tt
	hidden_effect = {
		ENG_senate_small_opposition = yes
		ENG_house_small_opposition = yes
		
	}
}

ENG_senate_small_opposition = {
	custom_effect_tooltip = mtg_eng_senate_small_opposition_tt
	set_temp_variable = { temp_factor = random }
	multiply_temp_variable = { temp_factor = -8 }
	add_to_variable = { senators_support = temp_factor }
	round_variable = senators_support
	clamp_variable = { var = senators_support max = senators_total min = 0 }
	ENG_recalc_congress_icon_frames = yes
}

ENG_house_small_opposition = {
	custom_effect_tooltip = mtg_eng_house_small_opposition_tt
	set_temp_variable = { temp_factor = random }
	multiply_temp_variable = { temp_factor = -20 }
	add_to_variable = { representatives_support = temp_factor }
	round_variable = representatives_support
	clamp_variable = { var = representatives_support max = representatives_total min = 0 }
	ENG_recalc_congress_icon_frames = yes
}
ENG_senate_small_support = {
	custom_effect_tooltip = mtg_eng_senate_small_support_tt
	set_temp_variable = { temp_factor = random }
	multiply_temp_variable = { temp_factor = 8 }
	add_to_variable = { senators_support = temp_factor }
	round_variable = senators_support
	clamp_variable = { var = senators_support max = senators_total min = 0 }
	ENG_recalc_congress_icon_frames = yes
}

ENG_house_small_support = {
	custom_effect_tooltip = mtg_eng_house_small_support_tt
	set_temp_variable = { temp_factor = random }
	multiply_temp_variable = { temp_factor = 25 }
	clamp_temp_variable = { var = temp_factor max = 25 min = 10}
	add_to_variable = { representatives_support = temp_factor }
	round_variable = representatives_support
	clamp_variable = { var = representatives_support max = representatives_total min = 0 }
	ENG_recalc_congress_icon_frames = yes
}

ENG_senate_medium_opposition = {
	custom_effect_tooltip = mtg_eng_senate_medium_opposition_tt
	set_temp_variable = { temp_factor = random }
	multiply_temp_variable = { temp_factor = -15 }
	clamp_temp_variable = { var = temp_factor max = -6 min = -15 }
	add_to_variable = { senators_support = temp_factor }
	round_variable = senators_support
	clamp_variable = { var = senators_support max = senators_total min = 0 }
	ENG_recalc_congress_icon_frames = yes
}

ENG_house_medium_opposition = {
	custom_effect_tooltip = mtg_eng_house_medium_opposition_tt
	set_temp_variable = { temp_factor = random }
	multiply_temp_variable = { temp_factor = -40 }
	clamp_temp_variable = { var = temp_factor max = -20 min = -40 }
	add_to_variable = { representatives_support = temp_factor }
	round_variable = representatives_support
	clamp_variable = { var = representatives_support max = representatives_total min = 0 }
	ENG_recalc_congress_icon_frames = yes
}
ENG_senate_medium_support = {
	custom_effect_tooltip = mtg_eng_senate_medium_support_tt
	set_temp_variable = { temp_factor = random }
	multiply_temp_variable = { temp_factor = 20 }
	clamp_temp_variable = { var = temp_factor max = 20 min = 8 }
	add_to_variable = { senators_support = temp_factor }
	round_variable = senators_support
	clamp_variable = { var = senators_support max = senators_total min = 0 }
	ENG_recalc_congress_icon_frames = yes
}

ENG_house_medium_support = {
	custom_effect_tooltip = mtg_eng_house_medium_support_tt
	set_temp_variable = { temp_factor = random }
	multiply_temp_variable = { temp_factor = 50 }
	clamp_temp_variable = { var = temp_factor max = 50 min = 20 }
	add_to_variable = { representatives_support = temp_factor }
	round_variable = representatives_support
	clamp_variable = { var = representatives_support max = representatives_total min = 0 }
	ENG_recalc_congress_icon_frames = yes
}
ENG_senate_large_opposition = {
	custom_effect_tooltip = mtg_eng_senate_large_opposition_tt
	set_temp_variable = { temp_factor = random }
	multiply_temp_variable = { temp_factor = -25 }
	clamp_temp_variable = { var = temp_factor max = 25 min = -10 }
	add_to_variable = { senators_support = temp_factor }
	round_variable = senators_support
	clamp_variable = { var = senators_support max = senators_total min = 0 }
	ENG_recalc_congress_icon_frames = yes
}

ENG_house_large_opposition = {
	custom_effect_tooltip = mtg_eng_house_large_opposition_tt
	set_temp_variable = { temp_factor = random }
	multiply_temp_variable = { temp_factor = -100 }
	clamp_temp_variable = { var = temp_factor max = -50 min = -100 }
	add_to_variable = { representatives_support = temp_factor }
	round_variable = representatives_support
	clamp_variable = { var = representatives_support max = representatives_total min = 0 }
	ENG_recalc_congress_icon_frames = yes
}
ENG_senate_large_support = {
	custom_effect_tooltip = mtg_eng_senate_large_support_tt
	set_temp_variable = { temp_factor = random }
	multiply_temp_variable = { temp_factor = 30 }
	clamp_temp_variable = { var = temp_factor max = 30 min = 15 }
	add_to_variable = { senators_support = temp_factor }
	round_variable = senators_support
	clamp_variable = { var = senators_support max = senators_total min = 0 }
	ENG_recalc_congress_icon_frames = yes
}

ENG_house_large_support = {
	custom_effect_tooltip = mtg_eng_house_large_support_tt
	set_temp_variable = { temp_factor = random }
	multiply_temp_variable = { temp_factor = 125 }
	clamp_temp_variable = { var = temp_factor max = 125 min = 80 }
	add_to_variable = { representatives_support = temp_factor }
	round_variable = representatives_support
	clamp_variable = { var = representatives_support max = representatives_total min = 0 }
	ENG_recalc_congress_icon_frames = yes
}
ENG_congress_medium_opposition = {
	custom_effect_tooltip = mtg_eng_congress_medium_opposition_tt
	hidden_effect = {
		ENG_senate_medium_opposition = yes
		ENG_house_medium_opposition = yes
		
	}
}

ENG_congress_large_opposition = {
	custom_effect_tooltip = mtg_eng_congress_large_opposition_tt
	hidden_effect = {
		ENG_senate_large_opposition = yes
		ENG_house_large_opposition = yes
		
	}
}
ENG_congress_small_support = {
	custom_effect_tooltip = mtg_eng_congress_small_support_tt
	hidden_effect = {
		ENG_senate_small_support = yes
		ENG_house_small_support = yes
		
	}
}

ENG_congress_medium_support = {
	custom_effect_tooltip = mtg_eng_congress_medium_support_tt
	hidden_effect = {
		ENG_senate_medium_support = yes
		ENG_house_medium_support = yes
		
	}
}
ENG_congress_large_support = {
	custom_effect_tooltip = mtg_eng_congress_large_support_tt
	hidden_effect = {
		ENG_senate_large_support = yes
		ENG_house_large_support = yes
		
	}
}
ENG_election_senate = {
	set_variable = { var = senators_for_reelection value = senators_total } #not temp because needed for events
	multiply_variable = { senators_for_reelection = 0.3 }
	multiply_variable = { senators_for_reelection = election_factor }
	add_to_variable = { senators_support = senators_for_reelection }
	round_variable = senators_support
	round_variable = senators_for_reelection
	set_variable = { sen_loc = senators_for_reelection }
	if = {
		limit = {
			check_variable = { sen_loc < 0 }
		}
		multiply_variable = { sen_loc = -1 }
	}
	clamp_variable = { var = senators_support max = senators_total min = 0 }
	ENG_recalc_congress_icon_frames = yes
}
ENG_election_house = {
	set_variable = { var = representatives_for_reelection value = representatives_total } #not temp because needed for events
	multiply_variable = { representatives_for_reelection = 0.5 }
	multiply_variable = { representatives_for_reelection = election_factor }
	set_variable = { representatives_support = representatives_total }
	multiply_variable = { representatives_support = 0.5 }
	add_to_variable = { representatives_support = representatives_for_reelection }
	round_variable = representatives_support
	round_variable = representatives_for_reelection
	set_variable = { ror_loc = representatives_for_reelection }
	if = {
		limit = {
			check_variable = { ror_loc < 0 }
		}
		multiply_variable = { ror_loc = -1 }
	}
	clamp_variable = { var = senators_support max = representatives_total min = 0 }
	ENG_recalc_congress_icon_frames = yes
}
ENG_return_majority = { #for communist/fascist
	custom_effect_tooltip = ENG_return_majority_tt
	set_variable = { var = goal_value_senators value = senators_total }
	multiply_variable = { var = goal_value_senators value = 0.7 }
	round_variable = goal_value_senators
	if = {
		limit = {
			check_variable = { var = senators_support value = goal_value_senators compare = less_than } #shouldn't punish player
		}
		set_variable = { var = senators_support value = goal_value_senators }
	}
	set_variable = { var = goal_value_representatives value = representatives_total }
	multiply_variable = { var = goal_value_representatives value = 0.7 }
	round_variable = goal_value_representatives
	if = {
		limit = {
			check_variable = { var = representatives_support value = goal_value_representatives compare = less_than } #shouldn't punish player
		}
		set_variable = { var = representatives_support value = goal_value_representatives }
	}
	ENG_recalc_congress_icon_frames = yes
}
ENG_flip_support = {
	set_temp_variable = { senators_temp = senators_total }
	subtract_from_temp_variable = { senators_temp = senators_support }
	set_variable = { senators_support = senators_temp }
	set_temp_variable = { representatives_temp = representatives_total }
	subtract_from_temp_variable = { representatives_temp = representatives_support }
	set_variable = { representatives_support = representatives_temp }
	ENG_recalc_congress_icon_frames = yes
}

ENG_recalc_congress_icon_frames = {
	
	set_temp_variable = { senators_temp = senators_support }
	divide_temp_variable = { senators_temp = senators_total }
	multiply_temp_variable = { senators_temp = 21 }
	if = {
		limit = { check_variable = { senators_temp > 0 } }
		clamp_temp_variable = {
			var = senators_temp
			min = 1
			max = 21
		}
	}
	else = {
		set_temp_variable = { senators_temp = 1 }
	}
	set_variable = { current_senate_icon_frame = senators_temp }

	set_temp_variable = { house_temp = representatives_support }
	divide_temp_variable = { house_temp = representatives_total }
	multiply_temp_variable = { house_temp = 21 }
	if = {
		limit = { check_variable = { house_temp > 0 } }
		clamp_temp_variable = {
			var = house_temp
			min = 1
			max = 21
		}
	}
	else = {
		set_temp_variable = { house_temp = 1 }		
	}
	set_variable = { current_house_icon_frame = house_temp }
}
