on_actions = {
    
    on_weekly = {
		effect = {	
	
			##### Resets immigration attraction weekly for recalculation ##############
			every_country = {

			set_variable = { magtdd = 0 }
			
			}
			# approval rating tooltip calculator
			set_variable = { approvalc = 0 }
			###########################################################################
			###########################################################################
			
			##### Export income
			
			set_variable = { budj_exports = num_of_naval_factories }

			set_temp_variable = { temp_impc_oil = resource_exported@oil }
			multiply_temp_variable = { temp_impc_oil = 0.011 }

			set_temp_variable = { temp_expo_alu = resource_exported@aluminium }
			multiply_temp_variable = { temp_expo_alu = 0.013 }

			set_temp_variable = { temp_expo_rub = resource_exported@rubber }
			multiply_temp_variable = { temp_expo_rub = 0.012 }

			set_temp_variable = { temp_expo_tung = resource_exported@tungsten }
			multiply_temp_variable = { temp_expo_tung = 0.013 }

			set_temp_variable = { temp_expo_steel = resource_exported@steel }
			multiply_temp_variable = { temp_expo_steel = 0.012 }

			set_temp_variable = { temp_expo_chom = resource_exported@chromium }
			multiply_temp_variable = { temp_expo_chom = 0.014 }

			set_temp_variable = { temp_expo_food = resource_exported@food }
			multiply_temp_variable = { temp_expo_food = 0.01 }

			set_temp_variable = { temp_budext = temp_expo_oil }
			add_to_temp_variable = { temp_budext = temp_expo_alu }
			add_to_temp_variable = { temp_budext = temp_expo_rub }
			add_to_temp_variable = { temp_budext = temp_expo_tung }
			add_to_temp_variable = { temp_budext = temp_expo_steel }
			add_to_temp_variable = { temp_budext = temp_expo_chom }
			add_to_temp_variable = { temp_budext = temp_expo_food }

			set_variable = { budj_rexp =  temp_budext }
			divide_variable = { budj_rexp = 4 }
			set_variable = { money = budj_rexp }
			
			###########################################################################
			###########################################################################
			
			##### Imports

			set_temp_variable = { temp_impc_oil = resource_imported@oil }
			divide_temp_variable = { temp_impc_oil = 24 }

			set_temp_variable = { temp_impc_alu = resource_imported@aluminium }
			divide_temp_variable = { temp_impc_alu = 24 }

			set_temp_variable = { temp_impc_rub = resource_imported@rubber }
			divide_temp_variable = { temp_impc_rub = 24 }

			set_temp_variable = { temp_impc_tung = resource_imported@tungsten }
			divide_temp_variable = { temp_impc_tung = 24 }

			set_temp_variable = { temp_impc_steel = resource_imported@steel }
			divide_temp_variable = { temp_impc_steel = 24 }

			set_temp_variable = { temp_impc_chom = resource_imported@chromium }
			divide_temp_variable = { temp_impc_chom = 24 }

			set_temp_variable = { temp_impc_food = resource_imported@food }
			divide_temp_variable = { temp_impc_food = 24 }

			set_temp_variable = { temp_budimp = temp_impc_oil }
			add_to_temp_variable = { temp_budimp = temp_impc_alu }
			add_to_temp_variable = { temp_budimp = temp_impc_rub }
			add_to_temp_variable = { temp_budimp = temp_impc_tung }
			add_to_temp_variable = { temp_budimp = temp_impc_steel }
			add_to_temp_variable = { temp_budimp = temp_impc_chom }
			add_to_temp_variable = { temp_budimp = temp_impc_food }
	
			set_variable = { budj_imports =  temp_budimp }
			divide_variable = { budj_imports = 2 }
			
			###########################################################################
			###########################################################################
			###########################################################################
			
			#### Tariffs 
			
			if = { limit = { check_variable = { 10tarequip = 1 } } 
					add_ideas = very_low_tariffs_idea
					remove_ideas = {
					    low_tariffs_idea
					    high_tariffs_idea
					    very_high_tariffs_idea
					}
					multiply_variable = { budj_exports = 0.25 }
					}

			if = { limit = { check_variable = { 25tarequip = 1 } } 
					add_ideas = low_tariffs_idea
					remove_ideas = {
					    very_low_tariffs_idea
					    high_tariffs_idea
					    very_high_tariffs_idea
					}
					multiply_variable = { budj_exports = 0.5 }
				}

			if = { limit = { check_variable = { htarequip = 1 } } 
					remove_ideas = {
					    very_low_tariffs_idea
					    low_tariffs_idea
					    high_tariffs_idea
					    very_high_tariffs_idea
					}

				}

			if = { limit = { check_variable = { 45tarequip = 1 } } 
					add_ideas = high_tariffs_idea
					remove_ideas = {
					    very_low_tariffs_idea
					    low_tariffs_idea
					    very_high_tariffs_idea
					}
					multiply_variable = { budj_exports = 1.2 }
				}

			if = { limit = { check_variable = { 60tarequip = 1 } } 
					add_ideas = very_high_tariffs_idea
					remove_ideas = {
					    very_low_tariffs_idea
					    low_tariffs_idea
					    high_tariffs_idea
					}
					multiply_variable = { budj_exports = 1.5 }
				}
				
			divide_variable = { budj_exports = 2 }
			
			###########################################################################
			###########################################################################
			###########################################################################
			
			##### Laws and constitution for released countries depending on their ideology
			
				if = { limit = { has_government = democratic NOT =  { has_country_flag = alreadyrecieved_it } }
				add_ideas = {
   					freesecondary_idea
   					 privatehealthcare_idea
					 lowwage_idea
   					 strictmigrate_idea
					 yesfreedom_idea
   					 freepress_idea
					 segregation_idea
					 hierarchy_idea
					 medtax_idea
					licensegun_idea
					lowgov_idea
					}
				set_variable = { partysupport = 90 }
				set_variable = { partyopposition = 10 }
				set_variable = { money_view = 250 }
				set_variable = { approvalr = 55 }
				set_country_flag = gotpartysupport
				set_country_flag = alrdem

				add_equipment_to_stockpile = { 
				type = ration_equipment_0
				amount = 3500
				}
							clr_country_flag = sep_churchs
							set_country_flag = sep_church
							set_variable = { sepstat = 1 }
							set_variable = { sepstatt = 2 }

							set_country_flag = gun_rest
							clr_country_flag = gun_prot
							set_variable = { gunstat = 1 }
							set_variable = { gunstatt = 2 }

							set_country_flag = unitary_c
							clr_country_flag = federal_c
							set_variable = { fedstat = 2 }
							set_variable = { fedstatt = 1 }

							set_country_flag = liberties_protected
							clr_country_flag = liberties_restricted
							set_variable = { freestat = 1 }
							set_variable = { freestatt = 2 }

							set_variable = { parlstat = 1 }
							set_variable = { parlstatt = 2 }

							
							if = { limit = { has_elections = yes }
							set_variable = { elecstat = 1 }
							set_variable = { elecstatt = 2 }
							}
			
							if = { limit = { has_elections = no }
							set_variable = { elecstat = 2 }
							set_variable = { elecstatt = 1 }
								}

							

							set_country_flag = interventionisteconomy
							clr_country_flag = laissez_faire
							clr_country_flag = state_capitalism
							clr_country_flag = planned_economy
							set_variable = { ecomintervene = 2 }
							set_variable = { ecomlaissez = 1 }
							set_variable = { ecomstatecontrolled = 1 }
							set_variable = { ecomplanned = 1 }
							set_variable = { ecomworkdem = 1 }
							set_variable = { ecomworkcoun = 1 }

							set_variable = { 10hthequip = 2 }
							set_variable = { 25hthequip = 2 }
							set_variable = { hhthequip = 1 }
							set_variable = { 45hthequip = 2 }
							set_variable = { 60hthequip = 2 }
							set_country_flag = hihth

							set_variable = { 10edequip = 2 }
							set_variable = { 25edequip = 2 }
							set_variable = { hedequip = 1 }
							set_variable = { 45edequip = 2 }
							set_variable = { 60edequip = 2 }
							set_country_flag = hied	

							set_variable = { 10tarequip = 2 }
							set_variable = { 25tarequip = 2 }
							set_variable = { htarequip = 1 }
							set_variable = { 45tarequip = 2 }
							set_variable = { 60tarequip = 2 }
							set_country_flag = htar	

							set_country_flag = alreadyrecieved_it	
					}
					
					if = { limit = { has_government = neutrality NOT =  { has_country_flag = alreadyrecieved_it } }
					add_ideas = {
   					privateedu_idea
   					 privatehealthcare_idea
					 lowwage_idea
   					 strictmigrate_idea
					 yesfreedom_idea
   					 censoredpress_idea
					 segregation_idea
					 hierarchy_idea
					 medtax_idea
					licensegun_idea
				
					}
				set_variable = { partysupport = 90 }
				set_variable = { partyopposition = 10 }
				set_variable = { money_view = 150 }
				set_variable = { approvalr = 55 }
				set_country_flag = gotpartysupport
				set_country_flag = alreadyrecieved_it	
				set_country_flag = alrneu

					add_equipment_to_stockpile = { 
				type = ration_equipment_0
				amount = 3500
				}
					

							set_country_flag = sep_churchs
							clr_country_flag = sep_church
							set_variable = { sepstat = 2 }
							set_variable = { sepstatt = 1 }

							set_country_flag = gun_rest
							clr_country_flag = gun_prot
							set_variable = { gunstat = 1 }
							set_variable = { gunstatt = 2 }

							set_country_flag = unitary_c
							clr_country_flag = federal_c
							set_variable = { fedstat = 2 }
							set_variable = { fedstatt = 1 }

							set_country_flag = liberties_restricted
							clr_country_flag = liberties_protected
							set_variable = { freestat = 2 }
							set_variable = { freestatt = 1 }

							set_variable = { parlstat = 2 }
							set_variable = { parlstatt = 1 }

							if = { limit = { has_elections = yes }
							set_variable = { elecstat = 1 }
							set_variable = { elecstatt = 2 }
							}

							if = { limit = { has_elections = no }
							set_variable = { elecstat = 2 }
							set_variable = { elecstatt = 1 }
								}

							clr_country_flag = interventionisteconomy
							clr_country_flag = laissez_faire
							set_country_flag = state_capitalism
							clr_country_flag = planned_economy
							set_variable = { ecomintervene = 1 }
							set_variable = { ecomlaissez = 1 }
							set_variable = { ecomstatecontrolled = 2 }
							set_variable = { ecomplanned = 1 }
							set_variable = { ecomworkdem = 1 }
							set_variable = { ecomworkcoun = 1 }

							
							set_variable = { 10hthequip = 2 }
							set_variable = { 25hthequip = 2 }
							set_variable = { hhthequip = 1 }
							set_variable = { 45hthequip = 2 }
							set_variable = { 60hthequip = 2 }
							set_country_flag = hihth

							set_variable = { 10edequip = 2 }
							set_variable = { 25edequip = 2 }
							set_variable = { hedequip = 1 }
							set_variable = { 45edequip = 2 }
							set_variable = { 60edequip = 2 }
							set_country_flag = hied	

							set_variable = { 10tarequip = 2 }
							set_variable = { 25tarequip = 2 }
							set_variable = { htarequip = 1 }
							set_variable = { 45tarequip = 2 }
							set_variable = { 60tarequip = 2 }
							set_country_flag = htar	
							
			}
			
			if = { limit = { has_government = communism NOT =  { has_country_flag = alreadyrecieved_it } }
			
		add_ideas = {
   					privateedu_idea_idea
   					 privatehealthcare_idea
					 lowwage_idea
   					 strictmigrate_idea
					 nofreedom_idea
   					 statepress_idea
					 slavery_idea
					 hierarchy_idea
					 medtax_idea
					nogun_idea
					medgov_idea
					}
				set_variable = { partysupport = 90 }
				set_variable = { partyopposition = 10 }
				set_variable = { money_view = 150 }
				set_variable = { approvalr = 55 }
				set_country_flag = gotpartysupport
				set_country_flag = alreadyrecieved_it	
					add_equipment_to_stockpile = { 
				type = ration_equipment_0
				amount = 3500
				}


					

							set_country_flag = sep_churchs
							clr_country_flag = sep_church
							set_variable = { sepstat = 2 }
							set_variable = { sepstatt = 1 }

							set_country_flag = gun_rest
							clr_country_flag = gun_prot
							set_variable = { gunstat = 1 }
							set_variable = { gunstatt = 2 }

							set_country_flag = unitary_c
							clr_country_flag = federal_c
							set_variable = { fedstat = 2 }
							set_variable = { fedstatt = 1 }

							set_country_flag = liberties_restricted
							clr_country_flag = liberties_protected
							set_variable = { freestat = 2 }
							set_variable = { freestatt = 1 }

							set_variable = { parlstat = 2 }
							set_variable = { parlstatt = 1 }

							if = { limit = { has_elections = yes }
							set_variable = { elecstat = 1 }
							set_variable = { elecstatt = 2 }
							}

							if = { limit = { has_elections = no }
							set_variable = { elecstat = 2 }
							set_variable = { elecstatt = 1 }
									}
									
							set_country_flag = alrcom


							clr_country_flag = interventionisteconomy
							clr_country_flag = laissez_faire
							set_country_flag = state_capitalism
							clr_country_flag = planned_economy
							set_variable = { ecomintervene = 1 }
							set_variable = { ecomlaissez = 1 }
							set_variable = { ecomstatecontrolled = 2 }
							set_variable = { ecomplanned = 1 }
							set_variable = { ecomworkdem = 1 }
							set_variable = { ecomworkcoun = 1 }

							
							set_variable = { 10hthequip = 2 }
							set_variable = { 25hthequip = 2 }
							set_variable = { hhthequip = 1 }
							set_variable = { 45hthequip = 2 }
							set_variable = { 60hthequip = 2 }
							set_country_flag = hihth

							set_variable = { 10edequip = 2 }
							set_variable = { 25edequip = 2 }
							set_variable = { hedequip = 1 }
							set_variable = { 45edequip = 2 }
							set_variable = { 60edequip = 2 }
							set_country_flag = hied	

							set_variable = { 10tarequip = 2 }
							set_variable = { 25tarequip = 2 }
							set_variable = { htarequip = 1 }
							set_variable = { 45tarequip = 2 }
							set_variable = { 60tarequip = 2 }
							set_country_flag = htar	
							
			}
			
			if = { limit = { has_government = fascism NOT =  { has_country_flag = alreadyrecieved_it } }
			add_ideas = {
   					privateedu_idea_idea
   					 privatehealthcare_idea
					 lowwage_idea
   					 strictmigrate_idea
					 nofreedom_idea
   					 statepress_idea
					 slavery_idea
					 hierarchy_idea
					 medtax_idea
					nogun_idea
					medgov_idea
					}

				set_variable = { partysupport = 90 }
				set_variable = { partyopposition = 10 }
				set_variable = { money_view = 200 }
				set_variable = { approvalr = 55 }
				set_country_flag = gotpartysupport
				set_country_flag = alreadyrecieved_it	
				set_country_flag = alrfas
					add_equipment_to_stockpile = { 
				type = ration_equipment_0
				amount = 3500
				}


						
				
							clr_country_flag = sep_churchs
							set_country_flag = sep_church
							set_variable = { sepstat = 1 }
							set_variable = { sepstatt = 2 }

							set_country_flag = gun_rest
							clr_country_flag = gun_prot
							set_variable = { gunstat = 1 }
							set_variable = { gunstatt = 2 }

							set_country_flag = unitary_c
							clr_country_flag = federal_c
							set_variable = { fedstat = 2 }
							set_variable = { fedstatt = 1 }

							set_country_flag = liberties_restricted
							clr_country_flag = liberties_protected
							set_variable = { freestat = 2 }
							set_variable = { freestatt = 1 }

							set_variable = { parlstat = 2 }
							set_variable = { parlstatt = 1 }

							if = { limit = { has_elections = yes }
							set_variable = { elecstat = 1 }
							set_variable = { elecstatt = 2 }
							}

							if = { limit = { has_elections = no }
							set_variable = { elecstat = 2 }
							set_variable = { elecstatt = 1 }
										}


							clr_country_flag = interventionisteconomy
							clr_country_flag = laissez_faire
							clr_country_flag = state_capitalism
							set_country_flag = planned_economy
							set_variable = { ecomintervene = 1 }
							set_variable = { ecomlaissez = 1 }
							set_variable = { ecomstatecontrolled = 1 }
							set_variable = { ecomplanned = 2 }
							set_variable = { ecomworkdem = 1 }
							set_variable = { ecomworkcoun = 1 }

							
							set_variable = { 10hthequip = 2 }
							set_variable = { 25hthequip = 2 }
							set_variable = { hhthequip = 1 }
							set_variable = { 45hthequip = 2 }
							set_variable = { 60hthequip = 2 }
							set_country_flag = hihth

							set_variable = { 10edequip = 2 }
							set_variable = { 25edequip = 2 }
							set_variable = { hedequip = 1 }
							set_variable = { 45edequip = 2 }
							set_variable = { 60edequip = 2 }
							set_country_flag = hied	

							set_variable = { 10tarequip = 2 }
							set_variable = { 25tarequip = 2 }
							set_variable = { htarequip = 1 }
							set_variable = { 45tarequip = 2 }
							set_variable = { 60tarequip = 2 }
							set_country_flag = htar	
					
			}
		
			
				if = { limit = { has_government = democratic NOT =  { has_country_flag = alrdem } }
				add_ideas = {
   					freesecondary_idea
   					 privatehealthcare_idea
					 lowwage_idea
   					 strictmigrate_idea
					 yesfreedom_idea
   					 freepress_idea
					 segregation_idea
					 hierarchy_idea
					 medtax_idea
					licensegun_idea
					lowgov_idea
					}
				set_variable = { partysupport = 90 }
				set_variable = { partyopposition = 10 }
				set_variable = { money_view = 250 }
				set_variable = { approvalr = 55 }
				set_country_flag = gotpartysupport
				set_country_flag = alrdem
			clr_country_flag = alrneu
			clr_country_flag = alrcom
			clr_country_flag = alrfas	

				add_equipment_to_stockpile = { 
				type = ration_equipment_0
				amount = 3500
				}
							clr_country_flag = sep_churchs
							set_country_flag = sep_church
							set_variable = { sepstat = 1 }
							set_variable = { sepstatt = 2 }

							set_country_flag = gun_rest
							clr_country_flag = gun_prot
							set_variable = { gunstat = 1 }
							set_variable = { gunstatt = 2 }

							set_country_flag = unitary_c
							clr_country_flag = federal_c
							set_variable = { fedstat = 2 }
							set_variable = { fedstatt = 1 }

							set_country_flag = liberties_protected
							clr_country_flag = liberties_restricted
							set_variable = { freestat = 1 }
							set_variable = { freestatt = 2 }

							set_variable = { parlstat = 1 }
							set_variable = { parlstatt = 2 }

							
							if = { limit = { has_elections = yes }
							set_variable = { elecstat = 1 }
							set_variable = { elecstatt = 2 }
							}
			
							if = { limit = { has_elections = no }
							set_variable = { elecstat = 2 }
							set_variable = { elecstatt = 1 }
								}

							

							set_country_flag = interventionisteconomy
							clr_country_flag = laissez_faire
							clr_country_flag = state_capitalism
							clr_country_flag = planned_economy
							set_variable = { ecomintervene = 2 }
							set_variable = { ecomlaissez = 1 }
							set_variable = { ecomstatecontrolled = 1 }
							set_variable = { ecomplanned = 1 }
							set_variable = { ecomworkdem = 1 }
							set_variable = { ecomworkcoun = 1 }

							set_variable = { 10hthequip = 2 }
							set_variable = { 25hthequip = 2 }
							set_variable = { hhthequip = 1 }
							set_variable = { 45hthequip = 2 }
							set_variable = { 60hthequip = 2 }
							set_country_flag = hihth

							set_variable = { 10edequip = 2 }
							set_variable = { 25edequip = 2 }
							set_variable = { hedequip = 1 }
							set_variable = { 45edequip = 2 }
							set_variable = { 60edequip = 2 }
							set_country_flag = hied	

							set_variable = { 10tarequip = 2 }
							set_variable = { 25tarequip = 2 }
							set_variable = { htarequip = 1 }
							set_variable = { 45tarequip = 2 }
							set_variable = { 60tarequip = 2 }
							set_country_flag = htar	

							set_country_flag = alreadyrecieved_it	
					}
					
					if = { limit = { has_government = neutrality NOT =  { has_country_flag = alrneu } }
					add_ideas = {
   					privateedu_idea
   					 privatehealthcare_idea
					 lowwage_idea
   					 strictmigrate_idea
					 yesfreedom_idea
   					 censoredpress_idea
					 segregation_idea
					 hierarchy_idea
					 medtax_idea
					licensegun_idea
				
					}
				set_variable = { partysupport = 90 }
				set_variable = { partyopposition = 10 }
				set_variable = { money_view = 150 }
				set_variable = { approvalr = 55 }
				set_country_flag = gotpartysupport
				set_country_flag = alreadyrecieved_it	
				set_country_flag = alrneu
					clr_country_flag = alrdem
			clr_country_flag = alrcom
			clr_country_flag = alrfas

					add_equipment_to_stockpile = { 
				type = ration_equipment_0
				amount = 3500
				}
					

							set_country_flag = sep_churchs
							clr_country_flag = sep_church
							set_variable = { sepstat = 2 }
							set_variable = { sepstatt = 1 }

							set_country_flag = gun_rest
							clr_country_flag = gun_prot
							set_variable = { gunstat = 1 }
							set_variable = { gunstatt = 2 }

							set_country_flag = unitary_c
							clr_country_flag = federal_c
							set_variable = { fedstat = 2 }
							set_variable = { fedstatt = 1 }

							set_country_flag = liberties_restricted
							clr_country_flag = liberties_protected
							set_variable = { freestat = 2 }
							set_variable = { freestatt = 1 }

							set_variable = { parlstat = 2 }
							set_variable = { parlstatt = 1 }

							if = { limit = { has_elections = yes }
							set_variable = { elecstat = 1 }
							set_variable = { elecstatt = 2 }
							}

							if = { limit = { has_elections = no }
							set_variable = { elecstat = 2 }
							set_variable = { elecstatt = 1 }
								}

							clr_country_flag = interventionisteconomy
							clr_country_flag = laissez_faire
							set_country_flag = state_capitalism
							clr_country_flag = planned_economy
							set_variable = { ecomintervene = 1 }
							set_variable = { ecomlaissez = 1 }
							set_variable = { ecomstatecontrolled = 2 }
							set_variable = { ecomplanned = 1 }
							set_variable = { ecomworkdem = 1 }
							set_variable = { ecomworkcoun = 1 }

							
							set_variable = { 10hthequip = 2 }
							set_variable = { 25hthequip = 2 }
							set_variable = { hhthequip = 1 }
							set_variable = { 45hthequip = 2 }
							set_variable = { 60hthequip = 2 }
							set_country_flag = hihth

							set_variable = { 10edequip = 2 }
							set_variable = { 25edequip = 2 }
							set_variable = { hedequip = 1 }
							set_variable = { 45edequip = 2 }
							set_variable = { 60edequip = 2 }
							set_country_flag = hied	

							set_variable = { 10tarequip = 2 }
							set_variable = { 25tarequip = 2 }
							set_variable = { htarequip = 1 }
							set_variable = { 45tarequip = 2 }
							set_variable = { 60tarequip = 2 }
							set_country_flag = htar	
							
			}
			
			if = { limit = { has_government = communism NOT =  { has_country_flag = alrcom } }
			
		add_ideas = {
   					privateedu_idea_idea
   					 privatehealthcare_idea
					 lowwage_idea
   					 strictmigrate_idea
					 nofreedom_idea
   					 statepress_idea
					 slavery_idea
					 hierarchy_idea
					 medtax_idea
					nogun_idea
					medgov_idea
					}
				set_variable = { partysupport = 90 }
				set_variable = { partyopposition = 10 }
				set_variable = { money_view = 150 }
				set_variable = { approvalr = 55 }
				set_country_flag = gotpartysupport
				set_country_flag = alreadyrecieved_it	
			clr_country_flag = alrdem
			clr_country_flag = alrneu
			clr_country_flag = alrfas
					add_equipment_to_stockpile = { 
				type = ration_equipment_0
				amount = 3500
				}


					

							set_country_flag = sep_churchs
							clr_country_flag = sep_church
							set_variable = { sepstat = 2 }
							set_variable = { sepstatt = 1 }

							set_country_flag = gun_rest
							clr_country_flag = gun_prot
							set_variable = { gunstat = 1 }
							set_variable = { gunstatt = 2 }

							set_country_flag = unitary_c
							clr_country_flag = federal_c
							set_variable = { fedstat = 2 }
							set_variable = { fedstatt = 1 }

							set_country_flag = liberties_restricted
							clr_country_flag = liberties_protected
							set_variable = { freestat = 2 }
							set_variable = { freestatt = 1 }

							set_variable = { parlstat = 2 }
							set_variable = { parlstatt = 1 }

							if = { limit = { has_elections = yes }
							set_variable = { elecstat = 1 }
							set_variable = { elecstatt = 2 }
							}

							if = { limit = { has_elections = no }
							set_variable = { elecstat = 2 }
							set_variable = { elecstatt = 1 }
									}
									
							set_country_flag = alrcom


							clr_country_flag = interventionisteconomy
							clr_country_flag = laissez_faire
							set_country_flag = state_capitalism
							clr_country_flag = planned_economy
							set_variable = { ecomintervene = 1 }
							set_variable = { ecomlaissez = 1 }
							set_variable = { ecomstatecontrolled = 2 }
							set_variable = { ecomplanned = 1 }
							set_variable = { ecomworkdem = 1 }
							set_variable = { ecomworkcoun = 1 }

							
							set_variable = { 10hthequip = 2 }
							set_variable = { 25hthequip = 2 }
							set_variable = { hhthequip = 1 }
							set_variable = { 45hthequip = 2 }
							set_variable = { 60hthequip = 2 }
							set_country_flag = hihth

							set_variable = { 10edequip = 2 }
							set_variable = { 25edequip = 2 }
							set_variable = { hedequip = 1 }
							set_variable = { 45edequip = 2 }
							set_variable = { 60edequip = 2 }
							set_country_flag = hied	

							set_variable = { 10tarequip = 2 }
							set_variable = { 25tarequip = 2 }
							set_variable = { htarequip = 1 }
							set_variable = { 45tarequip = 2 }
							set_variable = { 60tarequip = 2 }
							set_country_flag = htar	
							
			}
			
			if = { limit = { has_government = fascism NOT =  { has_country_flag = alrfas } }
			add_ideas = {
   					privateedu_idea_idea
   					 privatehealthcare_idea
					 lowwage_idea
   					 strictmigrate_idea
					 nofreedom_idea
   					 statepress_idea
					 slavery_idea
					 hierarchy_idea
					 medtax_idea
					nogun_idea
					medgov_idea
					}

				set_variable = { partysupport = 90 }
				set_variable = { partyopposition = 10 }
				set_variable = { money_view = 200 }
				set_variable = { approvalr = 55 }
				set_country_flag = gotpartysupport
				set_country_flag = alreadyrecieved_it	
				set_country_flag = alrfas
			clr_country_flag = alrdem
			clr_country_flag = alrneu
			clr_country_flag = alrcom
					add_equipment_to_stockpile = { 
				type = ration_equipment_0
				amount = 3500
				}


						
				
							clr_country_flag = sep_churchs
							set_country_flag = sep_church
							set_variable = { sepstat = 1 }
							set_variable = { sepstatt = 2 }

							set_country_flag = gun_rest
							clr_country_flag = gun_prot
							set_variable = { gunstat = 1 }
							set_variable = { gunstatt = 2 }

							set_country_flag = unitary_c
							clr_country_flag = federal_c
							set_variable = { fedstat = 2 }
							set_variable = { fedstatt = 1 }

							set_country_flag = liberties_restricted
							clr_country_flag = liberties_protected
							set_variable = { freestat = 2 }
							set_variable = { freestatt = 1 }

							set_variable = { parlstat = 2 }
							set_variable = { parlstatt = 1 }

							if = { limit = { has_elections = yes }
							set_variable = { elecstat = 1 }
							set_variable = { elecstatt = 2 }
							}

							if = { limit = { has_elections = no }
							set_variable = { elecstat = 2 }
							set_variable = { elecstatt = 1 }
										}


							clr_country_flag = interventionisteconomy
							clr_country_flag = laissez_faire
							clr_country_flag = state_capitalism
							set_country_flag = planned_economy
							set_variable = { ecomintervene = 1 }
							set_variable = { ecomlaissez = 1 }
							set_variable = { ecomstatecontrolled = 1 }
							set_variable = { ecomplanned = 2 }
							set_variable = { ecomworkdem = 1 }
							set_variable = { ecomworkcoun = 1 }

							
							set_variable = { 10hthequip = 2 }
							set_variable = { 25hthequip = 2 }
							set_variable = { hhthequip = 1 }
							set_variable = { 45hthequip = 2 }
							set_variable = { 60hthequip = 2 }
							set_country_flag = hihth

							set_variable = { 10edequip = 2 }
							set_variable = { 25edequip = 2 }
							set_variable = { hedequip = 1 }
							set_variable = { 45edequip = 2 }
							set_variable = { 60edequip = 2 }
							set_country_flag = hied	

							set_variable = { 10tarequip = 2 }
							set_variable = { 25tarequip = 2 }
							set_variable = { htarequip = 1 }
							set_variable = { 45tarequip = 2 }
							set_variable = { 60tarequip = 2 }
							set_country_flag = htar	
					
			}

######################################################################################################################################################
######################################################################################################################################################
	
				
				

				



### Parliament Majorities
			
			

if = { limit  { NOT = { original_tag = USA } }
			if = { limit = {
				check_variable = { parliament_seat_array^1 > 101 } }
				set_country_flag = conservative_majority
				clr_country_flag = liberal_majority
				clr_country_flag = progressive_majority
				clr_country_flag = nationalist_majority }

			if = { limit = {
				check_variable = { parliament_seat_array^0 > 101 } }
				set_country_flag = progressive_majority
				clr_country_flag = conservative_majority
				clr_country_flag = liberal_majority
				clr_country_flag = nationalist_majority }
			
			if = { limit = {
				check_variable = { parliament_seat_array^2 > 101 } }
				set_country_flag = liberal_majority
				clr_country_flag = conservative_majority
				clr_country_flag = progressive_majority
				clr_country_flag = nationalist_majority }
			
			if = { limit = {
				check_variable = { parliament_seat_array^3 > 101 } }
				set_country_flag = nationalist_majority
				clr_country_flag = conservative_majority
				clr_country_flag = progressive_majority
				clr_country_flag = liberal_majority }
				
			}
			
	##### Constitution
	
	
							if = { limit = { has_elections = yes }
							set_variable = { elecstat = 1 }
							set_variable = { elecstatt = 2 }
							}
			
							if = { limit = { has_elections = no }
							set_variable = { elecstat = 2 }
							set_variable = { elecstatt = 1 }
							}
							
							if = { limit = { OR = {  has_country_flag = ablist
			has_country_flag = alrparl } }
							set_variable = { parlstat = 1 }
							set_variable = { parlstatt = 2 }
							clr_country_flag = parlab
							}
			
							if = { limit = { NOT = { OR = {  has_country_flag = ablist
			has_country_flag = alrparl } } }
							set_variable = { parlstat = 2 }
							set_variable = { parlstatt = 1 }
							set_country_flag = parlab
							}
			
	###########################################################################
	###########################################################################

		##### Parties
			if = { limit = {
				fascism > 0.15 }
				set_country_flag = radicalnatspa
				clr_country_flag = mergedlibspa
								 }

			if = { limit = {
				communism > 0.15 }
				set_country_flag = communistspa
				clr_country_flag = progressivespa
								 }

			if = { limit = {
				fascism < 0.15 
				has_country_flag = radicalnatspa }
				set_country_flag = mergedlibspa
				clr_country_flag = radicalnatspa
								 }

			if = { limit = {
				communism < 0.15 
				has_country_flag = communistspa }
				set_country_flag = progressivespa
				clr_country_flag = communistspa
								 }

			if = { limit = {
				has_government = democratic
				NOT = { has_country_flag = alrparl } }
				parliament_gui_initial = yes
				set_variable = { approvalr = 70 }
				set_country_flag = alrparl
								 }
								 
	###########################################################################
	###########################################################################
		
	#### Total population calculator
			set_variable = { population_count = max_manpower_k }
			divide_variable = { population_count = 1000 }
			round_variable = population_count

	###########################################################################
	
		## Poliburo Support
			if = { limit = {
				OR = { 
				has_government = democratic
				has_government = fascism
				has_government = neutrality
					}
					 }
				set_variable = { partysupport = 100 }
				set_variable = { partyopposition = 0 }
								 }
								 
	###########################################################################

		### Economy laws
			if = {
					limit = { has_idea = civilian_economy }
					add_to_variable = { approvalr = 0.2 } 
					add_to_variable = { approvalc = 0.2 }
					set_variable = { approvalmobe = 0.2 }
					multiply_variable = { budj_fab = 1.2 }   
					add_to_variable = { magtdd = 20 }     
				}

			if = {
					limit = { has_idea = partial_economic_mobilisation }
					add_to_variable = { approvalr = -0.1 } 
					add_to_variable = { approvalc = -0.1 }
					set_variable = { approvalmobe = -0.1 }
					multiply_variable = { budj_fab = 0.79 } 
					add_to_variable = { magtdd = 5 }       
				}

			if = {
					limit = { has_idea = war_economy }
					add_to_variable = { approvalr = -0.2 } 
					add_to_variable = { approvalc = -0.2 } 
					set_variable = { approvalmobe = -0.2 }
					multiply_variable = { budj_fab = 0.67 }  
					add_to_variable = { magtdd = -30 }      
				}
			
			if = {
					limit = { has_idea = tot_economic_mobilisation }
					add_to_variable = { approvalr = -0.3 } 
					add_to_variable = { approvalc = -0.3 }
					set_variable = { approvalmobe = -0.3 }					
					multiply_variable = { budj_fab = 0.45 }  
					add_to_variable = { magtdd = -50 }      
				}
			
	###########################################################################
	###########################################################################


	#### Name Calculations used in court cases

			
			subtract_from_variable = { lastnamejudge = 1 }
			add_to_variable = { firstnamejudge = 1 }

		if = { limit = { NOT = { has_country_flag = gotpartysupport } }
					set_variable = { partysupport = 90 }
					set_variable = { partyopposition = 10 }
					set_variable = { approvalr = 55 }
				}

		if = { limit = { OR = { check_variable = { lastnamejudge = -1 }
			check_variable = { firstnamejudge = 18 }
			check_variable = { lastnamejudge = 0 }
			check_variable = { firstnamejudge = 17 }  } }
				
			set_variable = { lastnamejudge = 16 }
			set_variable = { firstnamejudge = 1 }
		}
	
	###########################################################################
	
	#### Investment Pool

			set_temp_variable = { temp_ava_1 = num_of_available_civilian_factories }
			divide_temp_variable = { temp_ava_1 = 4 }
			set_variable = { budj_pool_1 = temp_ava_1 }
		
			if = {
				set_variable = { budj_pool = budj_pool_1 }   
			}
		
		
			add_to_variable = { money = budj_pool }
			
	###########################################################################
			
	### Government modifier on migrant attraction
		
			if = { limit = { has_government = fascism } 
				add_to_variable = { magtdd = -45 } 
					}

			if = { limit = { has_government = communism } 
				add_to_variable = { magtdd = -30 } 
					}

	###########################################################################

	#### Government form & church and state
	
			if = { limit = { has_country_flag = federal_c
					 NOT = { has_idea = federal_gov_idea } } 
				add_ideas = { federal_gov_idea }
				remove_ideas = { unitary_gov_idea }
			}

			if = { limit = { has_country_flag = sep_church
					 NOT = { has_idea = church_seperate_idea } } 
				add_ideas = { church_seperate_idea }
				remove_ideas = { church_intergrate_idea }
			}

			if = { limit = { has_country_flag = unitary_c
					 NOT = { has_idea = unitary_gov_idea } } 
				add_ideas = { unitary_gov_idea }
				remove_ideas = { federal_gov_idea }
			}

			if = { limit = { has_country_flag = sep_churchs
					 NOT = { has_idea = church_intergrate_idea } } 
				add_ideas = { church_intergrate_idea }
				remove_ideas = { church_seperate_idea }
			}
			
	###########################################################################

	#### Factory income 
	
			set_temp_variable = { temp_industry_1 = num_of_civilian_factories }
			add_to_temp_variable = { temp_industry_1 = num_of_military_factories }
			divide_temp_variable = { temp_industry_1 = 4 }
			set_variable = { budj_fab_1 = temp_industry_1 }
			
			set_temp_variable = { temp_industry_2 = num_of_civilian_factories }
			add_to_temp_variable = { temp_industry_2 = num_of_military_factories }
			divide_temp_variable = { temp_industry_2 = 6 }
			set_variable = { budj_fab_2 = temp_industry_2 }
			
			set_temp_variable = { temp_industry_3 = num_of_civilian_factories }
			add_to_temp_variable = { temp_industry_3 = num_of_military_factories }
			divide_temp_variable = { temp_industry_3 = 8 }
			set_variable = { budj_fab_3 = temp_industry_3 }

			set_temp_variable = { temp_industry_4 = num_of_civilian_factories }
			add_to_temp_variable = { temp_industry_4 = num_of_military_factories }
			divide_temp_variable = { temp_industry_4 = 10 }
			set_variable = { budj_fab_4 = temp_industry_4 }
			
			if = {
				limit = { has_idea = veryhightax_idea }
				set_variable = { budj_fab = budj_fab_1 }
				subtract_from_variable = { approvalr = 0.7 } 
				subtract_from_variable = { approvalc = 0.7 }
				set_variable = { approvaltax = 2.2 }				
				add_to_variable = { magtdd = -80 }  
			}

			if = {
				limit = { has_idea = hightax_idea }
				set_variable = { budj_fab = budj_fab_1 }
				subtract_from_variable = { approvalr = 0.5 }   
				subtract_from_variable = { approvalc = 0.5 }  
				add_to_variable = { magtdd = -60 }  
			}
			if = {
				limit = { has_idea = medtax_idea }
				set_variable = { budj_fab = budj_fab_2 }
				add_to_variable = { magtdd = -30 } 
			}
			if = {
				limit = { has_idea = lowtax_idea }
				set_variable = { budj_fab = budj_fab_3 }
				add_to_variable = { magtdd = 30 } 
			}
				if = {
				limit = { has_idea = verylowtax_idea }
				set_variable = { budj_fab = budj_fab_4 }
				add_to_variable = { magtdd = 50 } 
			}
			
	###########################################################################
			
	#### Economic System affect on factory income

			if = {
				limit = { has_country_flag = planned_economy }
				multiply_variable = { budj_fab = 1.75 }
			}

			if = {
				limit = { has_country_flag = state_capitalism }
				multiply_variable = { budj_fab = 1.25 }
			}
			
			if = {
				limit = { has_country_flag = workers_councils }
				multiply_variable = { budj_fab = 1.75 }
			}
			
			if = {
				limit = { has_country_flag = workplace_democracy }
				multiply_variable = { budj_fab = 1.50 }
			}

			divide_variable = { budj_fab = 2 }
			add_to_variable = { money = budj_fab }
			
	###########################################################################

	#### Emigration when losing a war
	
				if = {
					limit = { surrender_progress > 0.75 }
					add_to_variable = { magtdd = -85 } 
				}

				
				if = {
					limit = { surrender_progress > 0.25
						  surrender_progress < 0.75 }
					add_to_variable = { magtdd = -55 } 
				}
				
	###########################################################################
				
	#### Taxes on the population
	
			set_temp_variable = { temp_taxes_1 = max_manpower_k }
				divide_temp_variable = { temp_taxes_1 = 6000 }
				set_variable = { budj_taxes_1 = temp_taxes_1 }

				set_temp_variable = { temp_taxes_2 = max_manpower_k }
				divide_temp_variable = { temp_taxes_2 = 8000 }
				set_variable = { budj_taxes_2 = temp_taxes_2 }
				
				set_temp_variable = { temp_taxes_3 = max_manpower_k }
				divide_temp_variable = { temp_taxes_3 = 10000 }
				set_variable = { budj_taxes_3 = temp_taxes_3 }
				
				set_temp_variable = { temp_taxes_4 = max_manpower_k }
				divide_temp_variable = { temp_taxes_4 = 12000 }
				set_variable = { budj_taxes_4 = temp_taxes_4 }
			
				set_temp_variable = { temp_taxes_5 = max_manpower_k }
				divide_temp_variable = { temp_taxes_5 = 14000 }
				set_variable = { budj_taxes_5 = temp_taxes_5 }
				
			
				
				if = {
					limit = { has_idea = veryhightax_idea }
					set_variable = { budj_taxes = budj_taxes_1 }
					subtract_from_variable = { approvalr = 1.5 }    
					subtract_from_variable = { approvalc = 1.5 }
					add_to_variable = { depression_clock = 0.02 }
				}
				if = {
					limit = { has_idea = hightax_idea }
					set_variable = { budj_taxes = budj_taxes_2 }
					subtract_from_variable = { approvalr = 1 }  
					subtract_from_variable = { approvalc = 1 }
					set_variable = { approvaltax = 1.5 }
					add_to_variable = { depression_clock = 0.01 }
				}
				if = {
					limit = { has_idea = medtax_idea }
					set_variable = { budj_taxes = budj_taxes_3 }
				}
				if = {
					limit = { has_idea = lowtax_idea }
					set_variable = { budj_taxes = budj_taxes_4 }
					add_to_variable = { approvalr = 0.3 }
					add_to_variable = { approvalc = 0.3 }
					set_variable = { approvaltax = 0.3 }
					subtract_from_variable = { depression_clock = 0.05 }
				}
				if = {
					limit = { has_idea = verylowtax_idea }
					set_variable = { budj_taxes = budj_taxes_5 }
					add_to_variable = { approvalr = 0.8 }
					add_to_variable = { approvalc = 0.8 }
					set_variable = { approvaltax = 0.8 }
					subtract_from_variable = { depression_clock = 0.1 }
				}
				
				
	###########################################################################
				
	#### Less stability means less tax income
		
				if = {
					limit = { has_stability < 0.2 }
					divide_variable = { budj_taxes = 3 }
					add_to_variable = { magtdd = -85 } 
				}
				if = {
					limit = { has_stability < 0.4 
							NOT = { has_stability < 0.2 } 
									}
					divide_variable = { budj_taxes = 2.5 }
					add_to_variable = { magtdd = -60 } 
				}
				if = {
					limit = { has_stability < 0.6 
							NOT = { has_stability < 0.4 } 
									}
					divide_variable = { budj_taxes = 2 }
					add_to_variable = { magtdd = -35 } 
				}
				if = {
					limit = { has_stability < 0.8 
							NOT = { has_stability < 0.6 } 
									}
					divide_variable = { budj_taxes = 1.5 }
				}
				
	###########################################################################
				
	#### Less civilian factories means less tax income
				
				if = {
					limit = { num_of_civilian_factories < 8 }
					divide_variable = { budj_taxes = 5 }
					 
				}
				if = {
					limit = { num_of_civilian_factories < 16 
							NOT = { num_of_civilian_factories < 8 } 
									}
					divide_variable = { budj_taxes = 4.5 }
					 
				}
				if = {
					limit = { num_of_civilian_factories < 24 
							NOT = { num_of_civilian_factories < 16 } 
									}
					divide_variable = { budj_taxes = 3.8 }
					
				}
				if = {
					limit = { num_of_civilian_factories < 32 
							NOT = { num_of_civilian_factories < 24 } 
									}
					divide_variable = { budj_taxes = 3 }
					
				}
				if = {
					limit = { num_of_civilian_factories < 38 
							NOT = { num_of_civilian_factories < 32 } 
									}
					divide_variable = { budj_taxes = 1.8 }
				
				}
				
				if = {
					limit = { num_of_civilian_factories < 46 
							NOT = { num_of_civilian_factories < 32 } 
									}
					divide_variable = { budj_taxes = 1.5 }
					
				}
				
	###########################################################################
	###########################################################################
				
	#### Factory Value
				
				if = {
					limit = { num_of_civilian_factories < 8 }
					multiply_variable = { budj_fab = 3.8 }
					 
				}
				if = {
					limit = { num_of_civilian_factories < 16 
							NOT = { num_of_civilian_factories < 8 } 
									}
					multiply_variable = { budj_fab = 3.4 }
					 
				}
				if = {
					limit = { num_of_civilian_factories < 24 
							NOT = { num_of_civilian_factories < 16 } 
									}
					multiply_variable = { budj_fab = 2.8 }
					
				}
				if = {
					limit = { num_of_civilian_factories < 32 
							NOT = { num_of_civilian_factories < 24 } 
									}
					multiply_variable = { budj_fab = 2.4 }
					
				}
				if = {
					limit = { num_of_civilian_factories < 38 
							NOT = { num_of_civilian_factories < 32 } 
									}
					multiply_variable = { budj_fab = 1.8 }
				
				}
				
				if = {
					limit = { num_of_civilian_factories < 46 
							NOT = { num_of_civilian_factories < 32 } 
									}
					multiply_variable = { budj_fab = 1.4 }
					
				}
				
				# Decrease in value
				
				if = {
					limit = { num_of_civilian_factories > 350 }
					multiply_variable = { budj_fab = 0.25 }
					 
				}
				if = {
					limit = { num_of_civilian_factories > 325 
							  num_of_civilian_factories < 350 
									}
					multiply_variable = { budj_fab = 0.30}
					 
				}
				if = {
					limit = { num_of_civilian_factories > 300 
							  num_of_civilian_factories < 325 
									}
					multiply_variable = { budj_fab = 0.35 }
					 
				}
				if = {
					limit = { num_of_civilian_factories > 280
							  num_of_civilian_factories < 300
									}
					multiply_variable = { budj_fab = 0.40 }
					 
				}
				if = {
					limit = { num_of_civilian_factories > 265
							  num_of_civilian_factories < 280
									}
					multiply_variable = { budj_fab = 0.45 }
					 
				}
				if = {
					limit = { num_of_civilian_factories > 245
							  num_of_civilian_factories < 265
									}
					multiply_variable = { budj_fab = 0.50 }
					 
				}
				if = {
					limit = { num_of_civilian_factories > 225
							  num_of_civilian_factories < 245
									}
					multiply_variable = { budj_fab = 0.55 }
					 
				}
				if = {
					limit = { num_of_civilian_factories > 200
							  num_of_civilian_factories < 225
									}
					multiply_variable = { budj_fab = 0.60 }
					 
				}
				if = {
					limit = { num_of_civilian_factories > 180
							  num_of_civilian_factories < 225
									}
					multiply_variable = { budj_fab = 0.65 }
					 
				}
				if = {
					limit = { num_of_civilian_factories > 165
							  num_of_civilian_factories < 180
									}
					multiply_variable = { budj_fab = 0.70 }
					 
				}
				if = {
					limit = { num_of_civilian_factories > 150
							  num_of_civilian_factories < 165
									}
					multiply_variable = { budj_fab = 0.75 }
					 
				}
				if = {
					limit = { num_of_civilian_factories > 125
							  num_of_civilian_factories < 150
									}
					multiply_variable = { budj_fab = 0.80 }
					 
				}
				if = {
					limit = { num_of_civilian_factories > 100
							  num_of_civilian_factories < 125
									}
					multiply_variable = { budj_fab = 0.85 }
					 
				}
				if = {
					limit = { num_of_civilian_factories > 85
							  num_of_civilian_factories < 100
									}
					multiply_variable = { budj_fab = 0.90 }
					 
				}
				if = {
					limit = { num_of_civilian_factories > 80
							  num_of_civilian_factories < 85
									}
					multiply_variable = { budj_fab = 0.95 }
					 
				}
				
				
	###########################################################################
	###########################################################################
				
	#### Economic System influence on tax income

				if = {
					limit = { has_country_flag = laissez_faire }
					multiply_variable = { budj_taxes = 2.8 }
					add_to_variable = { magtdd = -35 }
					add_ideas = unregcap_idea
						}	
				
				if = {
					limit = { has_country_flag = interventionisteconomy }
					multiply_variable = { budj_taxes = 2.3 }
					add_to_variable = { magtdd = 35 }
						}

				if = {
					limit = { has_country_flag = state_capitalism }
					multiply_variable = { budj_taxes = 1.75 }
						}

				if = {
					limit = { has_country_flag = workplace_democracy }
					multiply_variable = { budj_taxes = 1.20 }
						}
						
					divide_variable = { budj_taxes = 2 }
					add_to_variable = { money = budj_taxes }
					
				if = {
					limit = { has_country_flag = interventionisteconomy NOT = { has_idea = capitalism_m } }
					add_ideas = capitalism_m
						}
				if = {
					limit = { has_country_flag = laissez_faire NOT = { has_idea = capitalism_m } }
					add_ideas = capitalism_m
						}
						
				if = {
					limit = { has_country_flag = planned_economy NOT = { has_idea = planned_eco_m } }
					add_ideas = planned_eco_m
						}
						
				if = {
					limit = { has_country_flag = workplace_democracy NOT = { has_idea = workers_demo_m } }
					add_ideas = workers_demo_m
						}
				
				if = {
					limit = { has_country_flag = workers_councils NOT = { has_idea = workers_council_m } }
					add_ideas = workers_council_m
						}
						
	#### Government spending

				set_temp_variable = { temp_govern_1 = num_controlled_states }
				divide_temp_variable={ temp_govern_1 = 4 }
				set_variable = { budj_gov_1 = temp_govern_1 }
				
				set_temp_variable = { temp_govern_2 = num_controlled_states }
				divide_temp_variable = { temp_govern_2 = 6 }
				set_variable = { budj_gov_2 = temp_govern_2 }
				
				set_temp_variable = { temp_govern_3 = num_controlled_states }
				divide_temp_variable = { temp_govern_3 = 8 }
				set_variable = { budj_gov_3 = temp_govern_3 }
			
				
				if = {
					limit = { has_idea = highgov_idea }
					set_variable = { budj_gov = budj_gov_1 }
					subtract_from_variable = { approvalr = 0.7 }
					subtract_from_variable = { approvalc = 0.7 }
					set_variable = { approvalgov = -0.7 }
				}
				if = {
					limit = { has_idea = medgov_idea }
					set_variable = { budj_gov = budj_gov_2 }
					subtract_from_variable = { approvalr = 0.4 }
					subtract_from_variable = { approvalc = 0.4 }
					set_variable = { approvalgov = -0.4 }
				}
				if = {
					limit = { has_idea = lowgov_idea }
					set_variable = { budj_gov = budj_gov_3 }
					subtract_from_variable = { approvalr = 0.2 }
					subtract_from_variable = { approvalc = 0.2 }
					set_variable = { approvalgov = -0.2 }
				}
				
			divide_variable = { budj_gov = 2 }
			
	###########################################################################
	###########################################################################
	###########################################################################
	
	#### Conscription 
	
	if = { limit = { has_idea = limited_conscription }
	add_to_variable = { approvalr = -0.2 } 
	set_variable = { approvalcon = -0.2 }
	}
	if = { limit = { has_idea = extensive_conscription }
	add_to_variable = { approvalr = -0.4 } 
	set_variable = { approvalcon = -0.4 }
	}
	if = { limit = { has_idea = service_by_requirement }
	add_to_variable = { approvalr = -0.6 } 
	set_variable = { approvalcon = -0.6 }
	}
	if = { limit = { has_idea = all_adults_serve }
	add_to_variable = { approvalr = -0.8 } 
	set_variable = { approvalcon = -0.8 }
	}
	if = { limit = { has_idea = scraping_the_barrel }
	add_to_variable = { approvalr = -1 } 
	set_variable = { approvalcon = -1 }
	}

	#### Welfare Spending
	
				set_temp_variable = { temp_social_1 = max_manpower_k }
				divide_temp_variable = { temp_social_1 = 16000 }
				set_variable = { budj_soc_1 = temp_social_1 }
				
				set_temp_variable = { temp_social_2 = max_manpower_k }
				divide_temp_variable = { temp_social_2 = 24000 }
				set_variable = { budj_soc_2 = temp_social_2 }
				
				set_temp_variable = { temp_social_3 = max_manpower_k }
				divide_temp_variable = { temp_social_3 = 28000 }
				set_variable = { budj_soc_3 = temp_social_3 }
				
				
				if = {
					limit = { has_idea = highwel_idea }
					set_variable = { budj_soc = budj_soc_1 }
					add_to_variable = { approvalr = 0.8 }   
					add_to_variable = { approvalc = 0.8 } 
					set_variable = { approvalwel = 0.8 }
					add_to_variable = { magtdd = 70 }       
				}
				if = {
					limit = { has_idea = medwel_idea }
					set_variable = { budj_soc = budj_soc_2 }
					add_to_variable = { approvalr = 0.6 }
					add_to_variable = { approvalc = 0.6 }
					set_variable = { approvalwel = 0.6 }
					add_to_variable = { magtdd = 50 }         
				}
				if = {
					limit = { has_idea = lowwel_idea }
					set_variable = { budj_soc = budj_soc_3 }
					add_to_variable = { approvalr = 0.3 } 
					add_to_variable = { approvalc = 0.3 }
					set_variable = { approvalwel = 0.3 }
					add_to_variable = { magtdd = 30 }         
				}
			
			
	###########################################################################
			
	#### Education Spending
	
			set_temp_variable = { temp_education_1 = max_manpower_k }
				divide_temp_variable = { temp_education_1 = 12000 }
				set_variable = { budj_edu_1 = temp_education_1 }
				
				set_temp_variable = { temp_education_2 = max_manpower_k }
				divide_temp_variable = { temp_education_2 = 16000 }
				set_variable = { budj_edu_2 = temp_education_2 }
	
				
				
				if = {
					limit = { has_idea = universaledu_idea }
					set_variable = { budj_edu = budj_edu_1 }
					add_to_variable = { approvalr = 0.5 }
					add_to_variable = { approvalc = 0.5 }
					set_variable = { approvaledu = 0.5 }
					add_to_variable = { magtdd = 65 } 
				}
				if = {
					limit = { has_idea = freesecondary_idea }
					set_variable = { budj_edu = budj_edu_2 }
					add_to_variable = { approvalr = 0.2 }
					add_to_variable = { approvalc = 0.2 }
					set_variable = { approvaledu = 0.2 }
					add_to_variable = { magtdd = 40 } 
				}
	
			
				


			divide_variable = { budj_edu = 2 }
			
	###########################################################################
			
	#### Healthcare Spending
	
			set_temp_variable = { temp_health_1 = max_manpower_k }
				divide_temp_variable = { temp_health_1 = 11200 }
				set_variable = { budj_health_1 = temp_health_1 }
				
				set_temp_variable = { temp_health_2 = max_manpower_k }
				divide_temp_variable = { temp_health_2 = 16200 }
				set_variable = { budj_health_2 = temp_health_2 }
				
				
				if = {
					limit = { has_idea = unhealthcare_idea }
					set_variable = { budj_pol = budj_health_1 }
					add_to_variable = { approvalr = 0.8 }
					add_to_variable = { approvalc = 0.8 }
					set_variable = { approvalhth = 0.8 }
					add_to_variable = { magtdd = 60 } 
				}
				if = {
					limit = { has_idea = mixedhealthcare_idea }
					set_variable = { budj_pol = budj_health_2 }
					add_to_variable = { approvalr = 0.4 }
					add_to_variable = { approvalc = 0.4 }
					set_variable = { approvalhth = 0.4 }
					add_to_variable = { magtdd = 35 } 
				}
				
				divide_variable = { budj_pol = 2 }
				
	###########################################################################
			
	#### Add Exports to income
			
			subtract_from_variable = { money = budj_imports }
			add_to_variable = { money = budj_exports }
			
	###########################################################################
		
			
	#### Military Spending
	
			set_variable = { air_cash_upkeep = num_deployed_planes }
			divide_variable = { air_cash_upkeep = 180 }
			divide_variable = { air_cash_upkeep = 4 }

			set_variable = { capital_ship_cash_upkeep = num_ships_with_type@capital }
			divide_variable = { capital_ship_cash_upkeep = 4 }
			divide_variable = { capital_ship_cash_upkeep = 4 }

			set_variable = { screen_ship_cash_upkeep = num_ships_with_type@screen }
			divide_variable = { screen_ship_cash_upkeep = 8 }
			divide_variable = { screen_ship_cash_upkeep = 4 }

			set_variable = { submarine_cash_upkeep = num_ships_with_type@submarine }
			divide_variable = { submarine_cash_upkeep = 6 }
			divide_variable = { submarine_cash_upkeep = 4 }
		
			set_variable = { tank_cash_upkeep = num_armies_with_type@heavy_armor }
			add_to_variable = { tank_cash_upkeep = num_armies_with_type@light_armor }
			add_to_variable = { tank_cash_upkeep = num_armies_with_type@medium_armor }
			add_to_variable = { tank_cash_upkeep = num_armies_with_type@modern_armor }
			divide_variable = { tank_cash_upkeep = 16 }
			divide_variable = { tank_cash_upkeep = 4 }

			set_variable = { infantry_cash_upkeep = num_divisions }
			subtract_from_variable = { infantry_cash_upkeep = tank_cash_upkeep }
			divide_variable = { infantry_cash_upkeep = 32 }
			divide_variable = { infantry_cash_upkeep = 4 }
	
			set_variable = { special_weapons_cash_upkeep = num_of_nukes }
			multiply_variable = { special_weapons_cash_upkeep = 0.15 }

			add_to_temp_variable = { budj_army1 = air_cash_upkeep }
			add_to_temp_variable = { budj_army1 = capital_ship_cash_upkeep }
			add_to_temp_variable = { budj_army1 = screen_ship_cash_upkeep }
			add_to_temp_variable = { budj_army1 = submarine_cash_upkeep }
			add_to_temp_variable = { budj_army1 = tank_cash_upkeep }
			add_to_temp_variable = { budj_army1 = infantry_cash_upkeep }
			add_to_temp_variable = { budj_army1 = special_weapons_cash_upkeep }
			
			set_variable = { budj_army = budj_army1 }
			
			### Fascists spend less
			
					if = {
						limit = { has_government = fascism }
						divide_variable = { budj_army = 1.50 }
						}	
			subtract_from_variable = { money = budj_army }
			
	###########################################################################
	###########################################################################
	###########################################################################
			
	#### Debt Limit

			set_temp_variable = { temp_debtlimit_1 = max_manpower_k }
			divide_temp_variable = { temp_debtlimit_1 = 30 }
			set_variable = { debt_limit = temp_debtlimit_1 }
			set_variable = { zerostwo = 0 }
			subtract_from_variable = { zerostwo = debt_limit }
			
	###########################################################################
			
	#### Corruption

			set_variable = { corcuptcost = budj_all }
			divide_variable = { corcuptcost = 8 }
			multiply_variable = { corcuptcost = corrupt_level }
			
	###########################################################################
			
	#### Education and health Spending
			
					if = { limit = { check_variable = { 10edequip = 1 }
					 OR = { has_idea = universaledu_idea
						has_idea = freesecondary_idea } 
							} 
					add_ideas = very_low_ed_idea
					remove_ideas = {
					    low_ed_idea
					    high_ed_idea
					    very_high_ed_idea
					}
					multiply_variable = { budj_edu = 0.5 }
				}

			if = { limit = { check_variable = { 25edequip = 1 }
					 OR = { has_idea = universaledu_idea
						has_idea = freesecondary_idea } 
							} 
					add_ideas = low_ed_idea
					remove_ideas = {
					    very_low_ed_idea
					    high_ed_idea
					    very_high_ed_idea
					}
					multiply_variable = { budj_edu = 0.75 }
				}
		
			if = { limit = { check_variable = { hedequip = 1 }
					 OR = { has_idea = universaledu_idea
						has_idea = freesecondary_idea } 
							} 
					remove_ideas = {
					    very_low_ed_idea
					    low_ed_idea
					    high_ed_idea
					    very_high_ed_idea
					}
				}

			if = { limit = { check_variable = { 45edequip = 1 }
					 OR = { has_idea = universaledu_idea
						has_idea = freesecondary_idea } 
							} 
					add_ideas = high_ed_idea
					remove_ideas = {
					    very_low_ed_idea
					    low_ed_idea
					    very_high_ed_idea
					}
					multiply_variable = { budj_edu = 1.25 }
				}

			if = { limit = { check_variable = { 60edequip = 1 }
					 OR = { has_idea = universaledu_idea
						has_idea = freesecondary_idea } 
							} 
					add_ideas = very_high_ed_idea
					remove_ideas = {
					    very_low_ed_idea
					    low_ed_idea
					    high_ed_idea
					}
					multiply_variable = { budj_edu = 1.50 }
				}

			if = { limit = { OR = { has_country_flag = 60ed
						has_country_flag = 45ed
						has_country_flag = hied
						has_country_flag = 25ed
						has_country_flag = 10ed  } 
				NOT = {
					 OR = { has_idea = universaledu_idea
						has_idea = freesecondary_idea } 
							 }
							} 
					remove_ideas = {
					    very_low_ed_idea
					    low_ed_idea
					    high_ed_idea
					    very_high_ed_idea
					}
				}


			# Healthcare


			if = { limit = { check_variable = { 10hthequip = 1 }
					 OR = { has_idea = unhealthcare_idea
						has_idea = mixedhealthcare_idea } 
							} 
					add_ideas = very_low_hth_idea
					remove_ideas = {
					    low_hth_idea
					    high_hth_idea
					    very_high_hth_idea
					}
					multiply_variable = { budj_pol = 0.5 }
				}

			if = { limit = { check_variable = { 25hthequip = 1 }
					 OR = { has_idea = unhealthcare_idea
						has_idea = mixedhealthcare_idea } 
							} 
					add_ideas = low_hth_idea
					remove_ideas = {
					    very_low_hth_idea
					    high_hth_idea
					    very_high_hth_idea
					}
					multiply_variable = { budj_pol = 0.75 }
				}
		
			if = { limit = { check_variable = { hhthequip = 1 }
					 OR = { has_idea = unhealthcare_idea
						has_idea = mixedhealthcare_idea } 
							} 
					remove_ideas = {
					    very_low_hth_idea
					    low_hth_idea
					    high_hth_idea
					    very_high_hth_idea
					}
				}

			if = { limit = { check_variable = { 45hthequip = 1 }
					 OR = { has_idea = unhealthcare_idea
						has_idea = mixedhealthcare_idea } 
							} 
					add_ideas = high_hth_idea
					remove_ideas = {
					    very_low_hth_idea
					    low_hth_idea
					    very_high_hth_idea
					}
					multiply_variable = { budj_pol = 1.25 }
				}

			if = { limit = { check_variable = { 60hthequip = 1 }
					 OR = { has_idea = unhealthcare_idea
						has_idea = mixedhealthcare_idea } 
							} 
					add_ideas = very_high_hth_idea
					remove_ideas = {
					    very_low_hth_idea
					    low_hth_idea
					    high_hth_idea
					}
					multiply_variable = { budj_pol = 1.50 }
				}

			if = { limit = { OR = { has_country_flag = 60hth
						has_country_flag = 45hth
						has_country_flag = hihth
						has_country_flag = 25hth
						has_country_flag = 10hth  } 
				NOT = {
					 OR = { has_idea = unhealthcare_idea
						has_idea = mixedhealthcare_idea } 
							 }
							} 
					remove_ideas = {
					    very_low_hth_idea
					    low_hth_idea
					    high_hth_idea
					    very_high_hth_idea
					}
				}
				
		divide_variable = { budj_pol = 2 }
		divide_variable = { budj_edu = 2 }
		subtract_from_variable = { money = budj_pol }
		subtract_from_variable = { money = budj_edu }
				
	###########################################################################
	###########################################################################
				
	#### Policies

			
			if = { limit = { has_idea = police_funding_idea } 
			multiply_variable = { budj_gov = 1.2 }
			}
			if = { limit = { has_idea = pensions_funding_idea } 
			multiply_variable = { budj_soc = 1.2 }
			add_to_variable = { approvalr = 0.5 }
			add_to_variable = { approvalc = 0.5 }
			set_variable = { pineapplepen = 0.5 }
			}
			if = { limit = { has_idea = nationalist_pride_funding_idea } 
			add_to_variable = { magtdd = 20 } 
			}
			
			subtract_from_variable = { money = budj_gov }
			subtract_from_variable = { money = budj_soc }
			
	###########################################################################
			
	
	#### Final Economic Calculations
	
			set_temp_variable = { temp1 = budj_fab }
			set_temp_variable = { temp2 = budj_taxes }
			set_temp_variable = { temp8 = budj_pool }
			set_temp_variable = { temp11 = budj_exports } 
			### ^ is not actually exports, its dockyards
			set_temp_variable = { temp13 = budj_rexp }
			### ^ this one is exports
			add_to_temp_variable={ temp_all = temp1 }
			add_to_temp_variable={ temp_all = temp2 }
			add_to_temp_variable={ temp_all = temp8 }
			add_to_temp_variable={ temp_all = temp11 }
			add_to_temp_variable={ temp_all = temp13 }
			set_temp_variable = { temp3 = budj_gov }
			set_temp_variable = { temp4 = budj_soc }
			set_temp_variable = { temp5 = budj_edu }
			set_temp_variable = { temp6 = budj_pol }
			set_temp_variable = { temp7 = budj_army }
			set_temp_variable = { temp10 = corcuptcost }
			set_temp_variable = { temp12 = budj_imports }
			subtract_from_temp_variable={ temp_all = temp3 }
			subtract_from_temp_variable={ temp_all = temp4 }
			subtract_from_temp_variable={ temp_all = temp5 }
			subtract_from_temp_variable={ temp_all = temp6 }
			subtract_from_temp_variable={ temp_all = temp7 }
			subtract_from_temp_variable={ temp_all = temp10 }
			subtract_from_temp_variable={ temp_all = temp12 }
		

			set_variable = { var = budj_all value = temp_all }
			
	###########################################################################

	#### Immigration Policy
	
				if = {
					limit = { has_idea = noborderc_idea }
					add_to_variable = { magtdd = 45 }       
				}
				if = {
					limit = { has_idea = closedborder_idea }
					set_variable = { magtdd = 0 }         
				}
				if = {
					limit = { has_idea = strictmigrate_idea }
					add_to_variable = { magtdd = -15 }         
				}
				if = {
					limit = { has_idea = limitedmigrate_idea }
					
					add_to_variable = { magtdd = -8 }         
				}


			
			if = { limit = { any_neighbor_country = { check_variable = { migration_attraction < 0 } } }
			add_to_variable = { magtdd = 35 }
			}
			
	###########################################################################
	###########################################################################

	#### Money
		
			add_to_variable = { money_view = budj_all }
	
			clear_variable = money
			clamp_variable = {
				var = money_view
				min = -1000000
				max = 1000000
			}
			
			#### Rounding
			
			set_variable = { money_show = money_view }
			
			if = { limit = { check_variable = { money_view < 1 }
							check_variable = { money_view > 0 } } 
			multiply_variable = { money_show = 100 }
			}
			
			if = { limit = { check_variable = { money_view > 999 } } 
			divide_variable = { money_show = 1000 }
			}
			
	###########################################################################
			
	#### Immigration Calculations
	
			add_to_variable = { magtdd = budj_all }
			divide_variable = { magtdd = 8 }
			set_variable = { migration_attraction = magtdd }

			round_variable = migrant_attraction

			set_variable = { migrantmap = migration_attraction }
			multiply_variable = { migrantmap = 3 }

		if = { limit = { check_variable = { migration_attraction < 0 } } 
			set_variable = { migrantmap2 = migration_attraction }
			subtract_from_variable = { migrantmap2 = migration_attraction }
			subtract_from_variable = { migrantmap2 = migration_attraction }

			multiply_variable = { migrantmap2 = 3 }
			}
			
			


			round_variable = migration_attraction
			
	###########################################################################

	#### Variable caps
	
			clamp_variable = {
				var = migrant_attraction
				min = -100
				max = 100
			}
			clamp_variable = {
				var = corrupt_level
				min = 0
				max = 8
			}
			clamp_variable = {
				var = approvalr
				min = 0
				max = 100
			}
			clamp_variable = {
				var = depression_clock
				min = 0
				max = 5
			}
			clamp_variable = {
				var = partyopposition
				min = 0
				max = 100
			}
			clamp_variable = {
				var = partysupport
				min = 0
				max = 100
			}
		}
	}
			
}