
mst_reformat_variables = {
	set_variable = { global.mst_display_variable_C1 = global.mst_variable_C1 }
	set_variable = { global.mst_display_variable_C2 = global.mst_variable_C2 }
	set_variable = { global.mst_display_variable_S1 = global.mst_variable_S1 }
	set_variable = { global.mst_display_variable_S2 = global.mst_variable_S2 }
	divide_variable = { global.mst_display_variable_C1 = 1000 }
	divide_variable = { global.mst_display_variable_C2 = 1000 }
	divide_variable = { global.mst_display_variable_S1 = 1000 }
	divide_variable = { global.mst_display_variable_S2 = 1000 }
}

smt_upgrade_state_category = {
	IF = {
		limit = {
			OR = {
				has_state_category = state_inhospitable
				has_state_category = state_military_base
			}
		}
		set_state_category = state_00
	}
	ELSE_IF = {
		limit = { has_state_category = state_00 }
		set_state_category = state_01
	}
	ELSE_IF = {
		limit = { has_state_category = state_01 }
		set_state_category = state_02
	}
	ELSE_IF = {
		limit = { has_state_category = state_02 }
		set_state_category = state_03
	}
	ELSE_IF = {
		limit = { has_state_category = state_03 }
		set_state_category = state_04
	}
	ELSE_IF = {
		limit = { has_state_category = state_04 }
		set_state_category = state_05
	}
	ELSE_IF = {
		limit = { has_state_category = state_05 }
		set_state_category = state_06
	}
	ELSE_IF = {
		limit = { has_state_category = state_06 }
		set_state_category = state_07
	}
	ELSE_IF = {
		limit = { has_state_category = state_07 }
		set_state_category = state_08
	}
	ELSE_IF = {
		limit = { has_state_category = state_08 }
		set_state_category = state_09
	}
	ELSE_IF = {
		limit = { has_state_category = state_09 }
		set_state_category = state_10
	}
	ELSE_IF = {
		limit = { has_state_category = state_10 }
		set_state_category = state_11
	}
	ELSE_IF = {
		limit = { has_state_category = state_11 }
		set_state_category = state_12
	}
	ELSE_IF = {
		limit = { has_state_category = state_12 }
		set_state_category = state_13
	}
	ELSE_IF = {
		limit = { has_state_category = state_13 }
		set_state_category = state_14
	}
	ELSE_IF = {
		limit = { has_state_category = state_14 }
		set_state_category = state_15
	}
	ELSE_IF = {
		limit = { has_state_category = state_15 }
		set_state_category = state_16
	}
	ELSE_IF = {
		limit = { has_state_category = state_16 }
		set_state_category = state_17
	}
	ELSE_IF = {
		limit = { has_state_category = state_17 }
		set_state_category = state_18
	}
}

smt_downgrade_state_category = {
	IF = {
		limit = { has_state_category = state_18 }
		set_state_category = state_17
	}	
	ELSE_IF = {
		limit = { has_state_category = state_17 }
		set_state_category = state_16
	}	
	ELSE_IF = {
		limit = { has_state_category = state_16 }
		set_state_category = state_15
	}	
	ELSE_IF = {
		limit = { has_state_category = state_15 }
		set_state_category = state_14
	}	
	ELSE_IF = {
		limit = { has_state_category = state_14 }
		set_state_category = state_13
	}	
	ELSE_IF = {
		limit = { has_state_category = state_13 }
		set_state_category = state_12
	}	
	ELSE_IF = {
		limit = { has_state_category = state_12 }
		set_state_category = state_11
	}	
	ELSE_IF = {
		limit = { has_state_category = state_11 }
		set_state_category = state_10
	}	
	ELSE_IF = {
		limit = { has_state_category = state_10 }
		set_state_category = state_09
	}	
	ELSE_IF = {
		limit = { has_state_category = state_09 }
		set_state_category = state_08
	}	
	ELSE_IF = {
		limit = { has_state_category = state_08 }
		set_state_category = state_07
	}	
	ELSE_IF = {
		limit = { has_state_category = state_07 }
		set_state_category = state_06
	}	
	ELSE_IF = {
		limit = { has_state_category = state_06 }
		set_state_category = state_05
	}	
	ELSE_IF = {
		limit = { has_state_category = state_05 }
		set_state_category = state_04
	}	
	ELSE_IF = {
		limit = { has_state_category = state_04 }
		set_state_category = state_03
	}	
	ELSE_IF = {
		limit = { has_state_category = state_03 }
		set_state_category = state_02
	}	
	ELSE_IF = {
		limit = { has_state_category = state_02 }
		set_state_category = state_01
	}	
	ELSE_IF = {
		limit = { has_state_category = state_01 }
		set_state_category = state_00
	}
	ELSE_IF = {
		limit = { has_state_category = state_00 }
		set_state_category = state_inhospitable
	}
}

bst_count_buildings = {
	bst_count_navf = yes
	bst_count_armsf = yes
	bst_count_civf = yes
	bst_count_inf = yes
	bst_count_airb = yes
	bst_count_aa = yes
	bst_count_radar = yes
	bst_count_rocket = yes
	bst_count_nuclear = yes
	bst_count_synthetic = yes
	bst_count_silo = yes
}

bst_count_inf = {
	
	every_country = {
		set_variable = {
			This.bst_country_average_inf = 0
		}
		set_variable = {
			This.bst_country_num_states = This.num_owned_states
		}
	}	
	every_state = {
		set_variable = {
			bst_state_inf = 0
		}
		add_to_variable = { bst_state_inf = This.infrastructure_level }
		OWNER = {
			add_to_variable = { This.bst_country_average_inf = Prev.bst_state_inf }
		}
	}
	every_country = {
		divide_variable = { This.bst_country_average_inf = This.bst_country_num_states }
	}	
}


bst_count_airb = {
	
	every_country = {
		set_variable = {
			This.bst_country_average_airb = 0
		}
		set_variable = {
			This.bst_country_num_states = This.num_owned_states
		}
	}	
	every_state = {
		set_variable = {
			This.airb_level = 0
		}
		if = {
			limit = {
				air_base < 1
			}
			add_to_variable = { This.airb_level = 0 }
		}
		if = {
			limit = {
				air_base > 0
				air_base < 2
			}
			add_to_variable = { This.airb_level = 1 }
		}
		if = {
			limit = {
				air_base > 1
				air_base < 3
			}
			add_to_variable = { This.airb_level = 2 }
		}
		if = {
			limit = {
				air_base > 2
				air_base < 4
			}
			add_to_variable = { This.airb_level = 3 }
		}
		if = {
			limit = {
				air_base > 3
				air_base < 5
			}
			
			add_to_variable = { This.airb_level = 4 }
		}
		if = {
			limit = {
				air_base > 4
				air_base < 6
			}
			add_to_variable = { This.airb_level = 5 }
		}
		if = {
			limit = {
				air_base > 5
				air_base < 7
			}
			add_to_variable = { This.airb_level = 6 }
		}
		if = {
			limit = {
				air_base > 6
				air_base < 8
			}
			add_to_variable = { This.airb_level = 7 }
		}
		if = {
			limit = {
				air_base > 7
				air_base < 9
			}
			add_to_variable = { This.airb_level = 8 }
		} 
		if = {
			limit = {
				air_base > 8
				air_base < 10
			}
			add_to_variable = { This.airb_level = 9 }
		}
		if = {
			limit = {
				air_base > 9
				air_base < 11
			}
			add_to_variable = { This.airb_level = 10 }
		}
		if = {
			limit = {
				air_base > 10
				air_base < 12
			}
			add_to_variable = { This.airb_level = 11 }
		}
		if = {
			limit = {
				air_base > 11
				air_base < 13
			}
			add_to_variable = { This.airb_level = 12 }
		}
		if = {
			limit = {
				air_base > 12
				air_base < 14
			}
			add_to_variable = { This.airb_level = 13 }
		}
		if = {
			limit = {
				air_base > 13
				air_base < 15
			}
			add_to_variable = { This.airb_level = 14 }
		}
		if = {
			limit = {
				air_base > 14
				air_base < 16
			}
			add_to_variable = { This.airb_level = 15 }
		}
		if = {
			limit = {
				air_base > 15
				air_base < 17
			}
			add_to_variable = { This.airb_level = 16 }
		}
		if = {
			limit = {
				air_base > 16
				air_base < 18
			}
			add_to_variable = { This.airb_level = 17 }
		}
		if = {
			limit = {
				air_base > 17
				air_base < 19
			}
			add_to_variable = { This.airb_level = 18 }
		}
		if = {
			limit = {
				air_base > 18
				air_base < 20
			}
			add_to_variable = { This.airb_level = 19 }
		}
		if = {
			limit = {
				air_base > 19
				air_base < 21
			}
			add_to_variable = { This.airb_level = 20 }
		}

		OWNER = {
			add_to_variable = { This.bst_country_average_airb = Prev.airb_level }
		}
	}
	every_country = {
		divide_variable = { This.bst_country_average_airb = This.bst_country_num_states }
	}	
}



bst_count_aa = {
	
	every_country = {
		set_variable = {
			This.bst_country_average_aa = 0
		}
		set_variable = {
			This.bst_country_num_states = This.num_owned_states
		}
	}	
	every_state = {
		set_variable = {
			This.aa_level = 0
		}
		if = {
			limit = {
				anti_air_building < 1
			}
			add_to_variable = { This.aa_level = 0 }
		}
		if = {
			limit = {
				anti_air_building > 0
				anti_air_building < 2
			}
			add_to_variable = { This.aa_level = 1 }
		}
		if = {
			limit = {
				anti_air_building > 1
				anti_air_building < 3
			}
			add_to_variable = { This.aa_level = 2 }
		}
		if = {
			limit = {
				anti_air_building > 2
				anti_air_building < 4
			}
			add_to_variable = { This.aa_level = 3 }
		}
		if = {
			limit = {
				anti_air_building > 3
				anti_air_building < 5
			}
			
			add_to_variable = { This.aa_level = 4 }
		}
		if = {
			limit = {
				anti_air_building > 4
				anti_air_building < 6
			}
			add_to_variable = { This.aa_level = 5 }
		}
		if = {
			limit = {
				anti_air_building > 5
				anti_air_building < 7
			}
			add_to_variable = { This.aa_level = 6 }
		}
		if = {
			limit = {
				anti_air_building > 6
				anti_air_building < 8
			}
			add_to_variable = { This.aa_level = 7 }
		}
		if = {
			limit = {
				anti_air_building > 7
				anti_air_building < 9
			}
			add_to_variable = { This.aa_level = 8 }
		} 
		if = {
			limit = {
				anti_air_building > 8
				anti_air_building < 10
			}
			add_to_variable = { This.aa_level = 9 }
		}
		if = {
			limit = {
				anti_air_building > 9
				anti_air_building < 11
			}
			add_to_variable = { This.aa_level = 10 }
		}
		if = {
			limit = {
				anti_air_building > 10
				anti_air_building < 12
			}
			add_to_variable = { This.aa_level = 11 }
		}
		if = {
			limit = {
				anti_air_building > 11
				anti_air_building < 13
			}
			add_to_variable = { This.aa_level = 12 }
		}
		if = {
			limit = {
				anti_air_building > 12
				anti_air_building < 14
			}
			add_to_variable = { This.aa_level = 13 }
		}
		if = {
			limit = {
				anti_air_building > 13
				anti_air_building < 15
			}
			add_to_variable = { This.aa_level = 14 }
		}
		if = {
			limit = {
				anti_air_building > 14
				anti_air_building < 16
			}
			add_to_variable = { This.aa_level = 15 }
		}
		if = {
			limit = {
				anti_air_building > 15
				anti_air_building < 17
			}
			add_to_variable = { This.aa_level = 16 }
		}
		if = {
			limit = {
				anti_air_building > 16
				anti_air_building < 18
			}
			add_to_variable = { This.aa_level = 17 }
		}
		if = {
			limit = {
				anti_air_building > 17
				anti_air_building < 19
			}
			add_to_variable = { This.aa_level = 18 }
		}
		if = {
			limit = {
				anti_air_building > 18
				anti_air_building < 20
			}
			add_to_variable = { This.aa_level = 19 }
		}
		if = {
			limit = {
				anti_air_building > 19
				anti_air_building < 21
			}
			add_to_variable = { This.aa_level = 20 }
		}

		OWNER = {
			add_to_variable = { This.bst_country_average_aa = Prev.aa_level }
		}
	}
	every_country = {
		divide_variable = { This.bst_country_average_aa = This.bst_country_num_states }
	}	
}

bst_count_radar = {
	
	every_country = {
		set_variable = {
			This.bst_country_average_radar = 0
		}
		set_variable = {
			This.bst_country_num_states = This.num_owned_states
		}
	}	
	every_state = {
		set_variable = {
			This.radar_level = 0
		}
		if = {
			limit = {
				radar_station < 1
			}
			add_to_variable = { This.radar_level = 0 }
		}
		if = {
			limit = {
				radar_station > 0
				radar_station < 2
			}
			add_to_variable = { This.radar_level = 1 }
		}
		if = {
			limit = {
				radar_station > 1
				radar_station < 3
			}
			add_to_variable = { This.radar_level = 2 }
		}
		if = {
			limit = {
				radar_station > 2
				radar_station < 4
			}
			add_to_variable = { This.radar_level = 3 }
		}
		if = {
			limit = {
				radar_station > 3
				radar_station < 5
			}
			
			add_to_variable = { This.radar_level = 4 }
		}
		if = {
			limit = {
				radar_station > 4
				radar_station < 6
			}
			add_to_variable = { This.radar_level = 5 }
		}
		if = {
			limit = {
				radar_station > 5
				radar_station < 7
			}
			add_to_variable = { This.radar_level = 6 }
		}
		if = {
			limit = {
				radar_station > 6
				radar_station < 8
			}
			add_to_variable = { This.radar_level = 7 }
		}
		if = {
			limit = {
				radar_station > 7
				radar_station < 9
			}
			add_to_variable = { This.radar_level = 8 }
		} 
		if = {
			limit = {
				radar_station > 8
				radar_station < 10
			}
			add_to_variable = { This.radar_level = 9 }
		}
		if = {
			limit = {
				radar_station > 9
				radar_station < 11
			}
			add_to_variable = { This.radar_level = 10 }
		}
		if = {
			limit = {
				radar_station > 10
				radar_station < 12
			}
			add_to_variable = { This.radar_level = 11 }
		}
		if = {
			limit = {
				radar_station > 11
				radar_station < 13
			}
			add_to_variable = { This.radar_level = 12 }
		}
		if = {
			limit = {
				radar_station > 12
				radar_station < 14
			}
			add_to_variable = { This.radar_level = 13 }
		}
		if = {
			limit = {
				radar_station > 13
				radar_station < 15
			}
			add_to_variable = { This.radar_level = 14 }
		}
		if = {
			limit = {
				radar_station > 14
				radar_station < 16
			}
			add_to_variable = { This.radar_level = 15 }
		}
		if = {
			limit = {
				radar_station > 15
				radar_station < 17
			}
			add_to_variable = { This.radar_level = 16 }
		}
		if = {
			limit = {
				radar_station > 16
				radar_station < 18
			}
			add_to_variable = { This.radar_level = 17 }
		}
		if = {
			limit = {
				radar_station > 17
				radar_station < 19
			}
			add_to_variable = { This.radar_level = 18 }
		}
		if = {
			limit = {
				radar_station > 18
				radar_station < 20
			}
			add_to_variable = { This.radar_level = 19 }
		}
		if = {
			limit = {
				radar_station > 19
				radar_station < 21
			}
			add_to_variable = { This.radar_level = 20 }
		}

		OWNER = {
			add_to_variable = { This.bst_country_average_radar = Prev.radar_level }
		}
	}
	every_country = {
		divide_variable = { This.bst_country_average_radar = This.bst_country_num_states }
	}	
}


bst_count_rocket = {
	
	every_country = {
		set_variable = {
			This.bst_country_average_rocket_site = 0
		}
		set_variable = {
			This.bst_country_num_states = This.num_owned_states
		}
	}	
	every_state = {
		set_variable = {
			This.rocket_site_level = 0
		}
		if = {
			limit = {
				rocket_site < 1
			}
			add_to_variable = { This.rocket_site_level = 0 }
		}
		if = {
			limit = {
				rocket_site > 0
				rocket_site < 2
			}
			add_to_variable = { This.rocket_site_level = 1 }
		}
		if = {
			limit = {
				rocket_site> 1
				rocket_site< 3
			}
			add_to_variable = { This.rocket_site_level = 2 }
		}
		if = {
			limit = {
				rocket_site> 2
				rocket_site< 4
			}
			add_to_variable = { This.rocket_site_level = 3 }
		}
		if = {
			limit = {
				rocket_site> 3
				rocket_site< 5
			}
			
			add_to_variable = { This.rocket_site_level = 4 }
		}
		if = {
			limit = {
				rocket_site > 4
				rocket_site < 6
			}
			add_to_variable = { This.rocket_site_level = 5 }
		}
		if = {
			limit = {
				rocket_site > 5
				rocket_site < 7
			}
			add_to_variable = { This.rocket_site_level = 6 }
		}
		if = {
			limit = {
				rocket_site > 6
				rocket_site < 8
			}
			add_to_variable = { This.rocket_site_level = 7 }
		}
		if = {
			limit = {
				rocket_site > 7
				rocket_site < 9
			}
			add_to_variable = { This.rocket_site_level = 8 }
		} 
		if = {
			limit = {
				rocket_site > 8
				rocket_site < 10
			}
			add_to_variable = { This.rocket_site_level = 9 }
		}
		if = {
			limit = {
				rocket_site > 9
				rocket_site < 11
			}
			add_to_variable = { This.rocket_site_level = 10 }
		}
		if = {
			limit = {
				rocket_site > 10
				rocket_site < 12
			}
			add_to_variable = { This.rocket_site_level = 11 }
		}
		if = {
			limit = {
				rocket_site > 11
				rocket_site < 13
			}
			add_to_variable = { This.rocket_site_level = 12 }
		}
		if = {
			limit = {
				rocket_site > 12
				rocket_site < 14
			}
			add_to_variable = { This.rocket_site_level = 13 }
		}
		if = {
			limit = {
				rocket_site > 13
				rocket_site < 15
			}
			add_to_variable = { This.rocket_site_level = 14 }
		}
		if = {
			limit = {
				rocket_site > 14
				rocket_site < 16
			}
			add_to_variable = { This.rocket_site_level = 15 }
		}
		if = {
			limit = {
				rocket_site > 15
				rocket_site < 17
			}
			add_to_variable = { This.rocket_site_level = 16 }
		}
		if = {
			limit = {
				rocket_site > 16
				rocket_site < 18
			}
			add_to_variable = { This.rocket_site_level = 17 }
		}
		if = {
			limit = {
				rocket_site > 17
				rocket_site < 19
			}
			add_to_variable = { This.rocket_site_level = 18 }
		}
		if = {
			limit = {
				rocket_site > 18
				rocket_site < 20
			}
			add_to_variable = { This.rocket_site_level = 19 }
		}
		if = {
			limit = {
				rocket_site > 19
				rocket_site < 21
			}
			add_to_variable = { This.rocket_site_level = 20 }
		}

		OWNER = {
			add_to_variable = { This.bst_country_average_rocket_site = Prev.rocket_site_level }
		}
	}
}


bst_count_nuclear = {
	
	every_country = {
		set_variable = {
			This.bst_country_average_nuclear_reactor = 0
		}
		set_variable = {
			This.bst_country_num_states = This.num_owned_states
		}
	}	
	every_state = {
		set_variable = {
			This.nuclear_reactor_level = 0
		}
		if = {
			limit = {
				nuclear_reactor < 1
			}
			add_to_variable = { This.nuclear_reactor_level = 0 }
		}
		if = {
			limit = {
				nuclear_reactor > 0
				nuclear_reactor < 2
			}
			add_to_variable = { This.nuclear_reactor_level = 1 }
		}
		if = {
			limit = {
				nuclear_reactor > 1
				nuclear_reactor < 3
			}
			add_to_variable = { This.nuclear_reactor_level = 2 }
		}
		if = {
			limit = {
				nuclear_reactor > 2
				nuclear_reactor < 4
			}
			add_to_variable = { This.nuclear_reactor_level = 3 }
		}
		if = {
			limit = {
				nuclear_reactor > 3
				nuclear_reactor < 5
			}
			
			add_to_variable = { This.nuclear_reactor_level = 4 }
		}
		if = {
			limit = {
				nuclear_reactor > 4
				nuclear_reactor < 6
			}
			add_to_variable = { This.nuclear_reactor_level = 5 }
		}
		if = {
			limit = {
				nuclear_reactor > 5
				nuclear_reactor < 7
			}
			add_to_variable = { This.nuclear_reactor_level = 6 }
		}
		if = {
			limit = {
				nuclear_reactor > 6
				nuclear_reactor < 8
			}
			add_to_variable = { This.nuclear_reactor_level = 7 }
		}
		if = {
			limit = {
				nuclear_reactor > 7
				nuclear_reactor < 9
			}
			add_to_variable = { This.nuclear_reactor_level = 8 }
		} 
		if = {
			limit = {
				nuclear_reactor > 8
				nuclear_reactor < 10
			}
			add_to_variable = { This.nuclear_reactor_level = 9 }
		}
		if = {
			limit = {
				nuclear_reactor > 9
				nuclear_reactor < 11
			}
			add_to_variable = { This.nuclear_reactor_level = 10 }
		}
		if = {
			limit = {
				nuclear_reactor > 10
				nuclear_reactor < 12
			}
			add_to_variable = { This.nuclear_reactor_level = 11 }
		}
		if = {
			limit = {
				nuclear_reactor > 11
				nuclear_reactor < 13
			}
			add_to_variable = { This.nuclear_reactor_level = 12 }
		}
		if = {
			limit = {
				nuclear_reactor > 12
				nuclear_reactor < 14
			}
			add_to_variable = { This.nuclear_reactor_level = 13 }
		}
		if = {
			limit = {
				nuclear_reactor > 13
				nuclear_reactor < 15
			}
			add_to_variable = { This.nuclear_reactor_level = 14 }
		}
		if = {
			limit = {
				nuclear_reactor > 14
				nuclear_reactor < 16
			}
			add_to_variable = { This.nuclear_reactor_level = 15 }
		}
		if = {
			limit = {
				nuclear_reactor > 15
				nuclear_reactor < 17
			}
			add_to_variable = { This.nuclear_reactor_level = 16 }
		}
		if = {
			limit = {
				nuclear_reactor > 16
				nuclear_reactor < 18
			}
			add_to_variable = { This.nuclear_reactor_level = 17 }
		}
		if = {
			limit = {
				nuclear_reactor > 17
				nuclear_reactor < 19
			}
			add_to_variable = { This.nuclear_reactor_level = 18 }
		}
		if = {
			limit = {
				nuclear_reactor > 18
				nuclear_reactor < 20
			}
			add_to_variable = { This.nuclear_reactor_level = 19 }
		}
		if = {
			limit = {
				nuclear_reactor > 19
				nuclear_reactor < 21
			}
			add_to_variable = { This.nuclear_reactor_level = 20 }
		}

		OWNER = {
			add_to_variable = { This.bst_country_average_nuclear_reactor = Prev.nuclear_reactor_level }
		}
	}
}
bst_count_synthetic = {
	
	every_country = {
		set_variable = {
			This.bst_country_average_synthetic_refinery = 0
		}
		set_variable = {
			This.bst_country_num_states = This.num_owned_states
		}
	}	
	every_state = {
		set_variable = {
			This.synthetic_refinery_level = 0
		}
		if = {
			limit = {
				synthetic_refinery < 1
			}
			add_to_variable = { This.synthetic_refinery_level = 0 }
		}
		if = {
			limit = {
				synthetic_refinery > 0
				synthetic_refinery < 2
			}
			add_to_variable = { This.synthetic_refinery_level = 1 }
		}
		if = {
			limit = {
				synthetic_refinery > 1
				synthetic_refinery < 3
			}
			add_to_variable = { This.synthetic_refinery_level = 2 }
		}
		if = {
			limit = {
				synthetic_refinery > 2
				synthetic_refinery < 4
			}
			add_to_variable = { This.synthetic_refinery_level = 3 }
		}
		if = {
			limit = {
				synthetic_refinery > 3
				synthetic_refinery < 5
			}
			
			add_to_variable = { This.synthetic_refinery_level = 4 }
		}
		if = {
			limit = {
				synthetic_refinery > 4
				synthetic_refinery < 6
			}
			add_to_variable = { This.synthetic_refinery_level = 5 }
		}
		if = {
			limit = {
				synthetic_refinery > 5
				synthetic_refinery < 7
			}
			add_to_variable = { This.synthetic_refinery_level = 6 }
		}
		if = {
			limit = {
				synthetic_refinery > 6
				synthetic_refinery < 8
			}
			add_to_variable = { This.synthetic_refinery_level = 7 }
		}
		if = {
			limit = {
				synthetic_refinery > 7
				synthetic_refinery < 9
			}
			add_to_variable = { This.synthetic_refinery_level = 8 }
		} 
		if = {
			limit = {
				synthetic_refinery > 8
				synthetic_refinery < 10
			}
			add_to_variable = { This.synthetic_refinery_level = 9 }
		}
		if = {
			limit = {
				synthetic_refinery > 9
				synthetic_refinery < 11
			}
			add_to_variable = { This.synthetic_refinery_level = 10 }
		}
		if = {
			limit = {
				synthetic_refinery > 10
				synthetic_refinery < 12
			}
			add_to_variable = { This.synthetic_refinery_level = 11 }
		}
		if = {
			limit = {
				synthetic_refinery > 11
				synthetic_refinery < 13
			}
			add_to_variable = { This.synthetic_refinery_level = 12 }
		}
		if = {
			limit = {
				synthetic_refinery > 12
				synthetic_refinery < 14
			}
			add_to_variable = { This.synthetic_refinery_level = 13 }
		}
		if = {
			limit = {
				synthetic_refinery > 13
				synthetic_refinery < 15
			}
			add_to_variable = { This.synthetic_refinery_level = 14 }
		}
		if = {
			limit = {
				synthetic_refinery > 14
				synthetic_refinery < 16
			}
			add_to_variable = { This.synthetic_refinery_level = 15 }
		}
		if = {
			limit = {
				synthetic_refinery > 15
				synthetic_refinery < 17
			}
			add_to_variable = { This.synthetic_refinery_level = 16 }
		}
		if = {
			limit = {
				synthetic_refinery > 16
				synthetic_refinery < 18
			}
			add_to_variable = { This.synthetic_refinery_level = 17 }
		}
		if = {
			limit = {
				synthetic_refinery > 17
				synthetic_refinery < 19
			}
			add_to_variable = { This.synthetic_refinery_level = 18 }
		}
		if = {
			limit = {
				synthetic_refinery > 18
				synthetic_refinery < 20
			}
			add_to_variable = { This.synthetic_refinery_level = 19 }
		}
		if = {
			limit = {
				synthetic_refinery > 19
				synthetic_refinery < 21
			}
			add_to_variable = { This.synthetic_refinery_level = 20 }
		}

		OWNER = {
			add_to_variable = { This.bst_country_average_synthetic_refinery = Prev.synthetic_refinery_level }
		}
	}
}

bst_count_silo = {
	
	every_country = {
		set_variable = {
			This.bst_country_average_fuel_silo = 0
		}
		set_variable = {
			This.bst_country_num_states = This.num_owned_states
		}
	}	
	every_state = {
		set_variable = {
			This.fuel_silo_level = 0
		}
		if = {
			limit = {
				fuel_silo < 1
			}
			add_to_variable = { This.fuel_silo_level = 0 }
		}
		if = {
			limit = {
				fuel_silo > 0
				fuel_silo < 2
			}
			add_to_variable = { This.fuel_silo_level = 1 }
		}
		if = {
			limit = {
				fuel_silo > 1
				fuel_silo < 3
			}
			add_to_variable = { This.fuel_silo_level = 2 }
		}
		if = {
			limit = {
				fuel_silo > 2
				fuel_silo < 4
			}
			add_to_variable = { This.fuel_silo_level = 3 }
		}
		if = {
			limit = {
				fuel_silo > 3
				fuel_silo < 5
			}
			
			add_to_variable = { This.fuel_silo_level = 4 }
		}
		if = {
			limit = {
				fuel_silo > 4
				fuel_silo < 6
			}
			add_to_variable = { This.fuel_silo_level = 5 }
		}
		if = {
			limit = {
				fuel_silo > 5
				fuel_silo < 7
			}
			add_to_variable = { This.fuel_silo_level = 6 }
		}
		if = {
			limit = {
				fuel_silo > 6
				fuel_silo < 8
			}
			add_to_variable = { This.fuel_silo_level = 7 }
		}
		if = {
			limit = {
				fuel_silo > 7
				fuel_silo < 9
			}
			add_to_variable = { This.fuel_silo_level = 8 }
		} 
		if = {
			limit = {
				fuel_silo > 8
				fuel_silo < 10
			}
			add_to_variable = { This.fuel_silo_level = 9 }
		}
		if = {
			limit = {
				fuel_silo > 9
				fuel_silo < 11
			}
			add_to_variable = { This.fuel_silo_level = 10 }
		}
		if = {
			limit = {
				fuel_silo > 10
				fuel_silo < 12
			}
			add_to_variable = { This.fuel_silo_level = 11 }
		}
		if = {
			limit = {
				fuel_silo > 11
				fuel_silo < 13
			}
			add_to_variable = { This.fuel_silo_level = 12 }
		}
		if = {
			limit = {
				fuel_silo > 12
				fuel_silo < 14
			}
			add_to_variable = { This.fuel_silo_level = 13 }
		}
		if = {
			limit = {
				fuel_silo > 13
				fuel_silo < 15
			}
			add_to_variable = { This.fuel_silo_level = 14 }
		}
		if = {
			limit = {
				fuel_silo > 14
				fuel_silo < 16
			}
			add_to_variable = { This.fuel_silo_level = 15 }
		}
		if = {
			limit = {
				fuel_silo > 15
				fuel_silo < 17
			}
			add_to_variable = { This.fuel_silo_level = 16 }
		}
		if = {
			limit = {
				fuel_silo > 16
				fuel_silo < 18
			}
			add_to_variable = { This.fuel_silo_level = 17 }
		}
		if = {
			limit = {
				fuel_silo > 17
				fuel_silo < 19
			}
			add_to_variable = { This.fuel_silo_level = 18 }
		}
		if = {
			limit = {
				fuel_silo > 18
				fuel_silo < 20
			}
			add_to_variable = { This.fuel_silo_level = 19 }
		}
		if = {
			limit = {
				fuel_silo > 19
				fuel_silo < 21
			}
			add_to_variable = { This.fuel_silo_level = 20 }
		}

		OWNER = {
			add_to_variable = { This.bst_country_average_fuel_silo = Prev.fuel_silo_level }
		}
	}
}


bst_count_armsf = {
	
	every_country = {
		set_variable = {
			This.bst_country_armsf = 0
		}
	}	
	every_state = {
		set_variable = {
			bst_state_armsf = 0
		}
		add_to_variable = { bst_state_armsf = This.arms_factory_level }
		OWNER = {
			add_to_variable = { This.bst_country_armsf = Prev.bst_state_armsf }
		}
	}
}

bst_count_civf = {
	
	every_country = {
		set_variable = {
			This.bst_country_civf = 0
		}
	}
	every_state = {
		set_variable = {
			bst_state_civf = 0
		}
		add_to_variable = { bst_state_civf = This.industrial_complex_level }
		OWNER = {
			add_to_variable = { This.bst_country_civf = Prev.bst_state_civf }
		}
	}

	# The best code ever - RIP
	#every_country = {
	#	set_variable = { ger.bst_civf_country = this.num_of_civilian_factories }
	#	every_owned_state = {
	#		set_variable = { this.bst_civf_amount = ger.bst_civf_country }
	#	}
	#	####################
	#	set_variable = { ger.bst_civf_country = this.num_of_civilian_factories }
	#	every_owned_state = {
	#		set_variable = {
	#			this.bst_civf_country = this.industrial_complex
	#		}
	#	}
	#}
}


tcw_clear_all_global_confirms = {
	clr_global_flag = tpt_confirm_faction_dismantling
	clr_global_flag = dst_a_confirm_unit_deletion
	clr_global_flag = dst_b_confirm_unit_deletion
	clr_global_flag = sst_confirm_ship_deletion
}


bst_count_navf = {
	every_country = {
		set_variable = {
			This.bst_country_navf = 0
		}
	}
	every_state = {
		set_variable = {
			bst_state_navf = 0
		}
		if = {
			limit = {
				dockyard > 0
				dockyard < 2
			}
			add_to_variable = { bst_state_navf = 1 }
			OWNER = {
				add_to_variable = { This.bst_country_navf = Prev.bst_state_navf }
			}
		}
		if = {
			limit = {
				dockyard > 1
				dockyard < 3
			}
			add_to_variable = { bst_state_navf = 2 }
			OWNER = {
				add_to_variable = { This.bst_country_navf = Prev.bst_state_navf }
			}
		}
		if = {
			limit = {
				dockyard > 2
				dockyard < 4
			}
			add_to_variable = { bst_state_navf = 3 }
			OWNER = {
				add_to_variable = { This.bst_country_navf = Prev.bst_state_navf }
			}
		}
		if = {
			limit = {
				dockyard > 3
				dockyard < 5
			}
			add_to_variable = { bst_state_navf = 4 }
			OWNER = {
				add_to_variable = { This.bst_country_navf = Prev.bst_state_navf }
			}
		}
		if = {
			limit = {
				dockyard > 4
				dockyard < 6
			}
			add_to_variable = { bst_state_navf = 5 }
			OWNER = {
				add_to_variable = { This.bst_country_navf = Prev.bst_state_navf }
			}
		}
		if = {
			limit = {
				dockyard > 5
				dockyard < 7
			}
			add_to_variable = { bst_state_navf = 6 }
			OWNER = {
				add_to_variable = { This.bst_country_navf = Prev.bst_state_navf }
			}
		}
		if = {
			limit = {
				dockyard > 6
				dockyard < 8
			}
			add_to_variable = { bst_state_navf = 7 }
			OWNER = {
				add_to_variable = { This.bst_country_navf = Prev.bst_state_navf }
			}
		}
		if = {
			limit = {
				dockyard > 7
				dockyard < 9
			}
			add_to_variable = { bst_state_navf = 8 }
			OWNER = {
				add_to_variable = { This.bst_country_navf = Prev.bst_state_navf }
			}
		}
		if = {
			limit = {
				dockyard > 8
				dockyard < 10
			}
			add_to_variable = { bst_state_navf = 9 }
			OWNER = {
				add_to_variable = { This.bst_country_navf = Prev.bst_state_navf }
			}
		}
		if = {
			limit = {
				dockyard > 9
				dockyard < 11
			}
			add_to_variable = { bst_state_navf = 10 }
			OWNER = {
				add_to_variable = { This.bst_country_navf = Prev.bst_state_navf }
			}
		}
		if = {
			limit = {
				dockyard > 10
				dockyard < 12
			}
			add_to_variable = { bst_state_navf = 11 }
			OWNER = {
				add_to_variable = { This.bst_country_navf = Prev.bst_state_navf }
			}
		}
		if = {
			limit = {
				dockyard > 11
				dockyard < 13
			}
			add_to_variable = { bst_state_navf = 12 }
			OWNER = {
				add_to_variable = { This.bst_country_navf = Prev.bst_state_navf }
			}
		}
		if = {
			limit = {
				dockyard > 12
				dockyard < 14
			}
			add_to_variable = { bst_state_navf = 13 }
			OWNER = {
				add_to_variable = { This.bst_country_navf = Prev.bst_state_navf }
			}
		}
		if = {
			limit = {
				dockyard > 13
				dockyard < 15
			}
			add_to_variable = { bst_state_navf = 14 }
			OWNER = {
				add_to_variable = { This.bst_country_navf = Prev.bst_state_navf }
			}
		}
		if = {
			limit = {
				dockyard > 14
				dockyard < 16
			}
			add_to_variable = { bst_state_navf = 15 }
			OWNER = {
				add_to_variable = { This.bst_country_navf = Prev.bst_state_navf }
			}
		}
		if = {
			limit = {
				dockyard > 15
				dockyard < 17
			}
			add_to_variable = { bst_state_navf = 16 }
			OWNER = {
				add_to_variable = { This.bst_country_navf = Prev.bst_state_navf }
			}
		}
		if = {
			limit = {
				dockyard > 16
				dockyard < 18
			}
			add_to_variable = { bst_state_navf = 17 }
			OWNER = {
				add_to_variable = { This.bst_country_navf = Prev.bst_state_navf }
			}
		}
		if = {
			limit = {
				dockyard > 17
				dockyard < 19
			}
			add_to_variable = { bst_state_navf = 18 }
			OWNER = {
				add_to_variable = { This.bst_country_navf = Prev.bst_state_navf }
			}
		}
		if = {
			limit = {
				dockyard > 18
				dockyard < 20
			}
			add_to_variable = { bst_state_navf = 19 }
			OWNER = {
				add_to_variable = { This.bst_country_navf = Prev.bst_state_navf }
			}
		}
		if = {
			limit = {
				dockyard > 19
			}
			add_to_variable = { bst_state_navf = 20 }
			OWNER = {
				add_to_variable = { This.bst_country_navf = Prev.bst_state_navf }
			}
		}
	}
}
tpt_remove_template_lock = {
	if = {
		limit = {
			has_template = "Makedonska Revolyutsionna Militsiya"
		}
		set_division_template_lock = {
			division_template = "Makedonska Revolyutsionna Militsiya"
			is_locked = no
		}
	}
	#France
	if = {
		limit = {
			has_template = "Syria Intervention Force" 	
		}
		set_division_template_lock = {
			division_template = "Syria Intervention Force" 	
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Syria Defense Force" 	
		}
		set_division_template_lock = {
			division_template = "Syria Defense Force" 	
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Indochina Intervention Force" 
		}
		set_division_template_lock = {
			division_template = "Indochina Intervention Force" 
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Indochina Defense Force"
		}
		set_division_template_lock = {
			division_template = "Indochina Defense Force"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Central Africa Intervention Force"
		}
		set_division_template_lock = {
			division_template = "Central Africa Intervention Force"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Central Africa Defense Force"
		}
		set_division_template_lock = {
			division_template = "Central Africa Defense Force"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "West Africa Intervention Force"
		}
		set_division_template_lock = {
			division_template = "West Africa Intervention Force"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "West Africa Defense Force"
		}
		set_division_template_lock = {
			division_template = "West Africa Defense Force"
			is_locked = no
		}
	}
	#Italy
	if = {
		limit = {
			has_template = "Divisione Partigiana"
		}
		set_division_template_lock = {
			division_template = "Divisione Partigiana"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Truppe Irregolari a Cavallo"
		}
		set_division_template_lock = {
			division_template = "Truppe Irregolari a Cavallo"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Truppe Irregolari di Cammelli"
		}
		set_division_template_lock = {
			division_template = "Truppe Irregolari di Cammelli"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Cavalleria Coloniale"
		}
		set_division_template_lock = {
			division_template = "Cavalleria Coloniale"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Banda Indigena Irregolare"
		}
		set_division_template_lock = {
			division_template = "Banda Indigena Irregolare"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Camicie Nere" 
		}
		set_division_template_lock = {
			division_template = "Camicie Nere"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Camicie Rosse" 
		}
		set_division_template_lock = {
			division_template = "Camicie Rosse"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Banda Irregolare Eritrea"
		}
		set_division_template_lock = {
			division_template = "Banda Irregolare Eritrea"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Banda Irregolare Somala"
		}
		set_division_template_lock = {
			division_template = "Banda Irregolare Somala"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Banda Irregolare Libica"
		}
		set_division_template_lock = {
			division_template = "Banda Irregolare Libica"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Banda Indigena Irregolare"
		}
		set_division_template_lock = {
			division_template = "Banda Indigena Irregolare"
			is_locked = no
		}
	}
	#???
	if = {
		limit = {
			has_template = "Tomislav's Royal Guards"
		}
		set_division_template_lock = {
			division_template = "Tomislav's Royal Guards"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Montenegrin Chetniks"
		}
		set_division_template_lock = {
			division_template = "Montenegrin Chetniks"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Redemption Army"
		}
		set_division_template_lock = {
			division_template = "Redemption Army"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Manchu Banner"
		}
		set_division_template_lock = {
			division_template = "Manchu Banner"
			is_locked = no
		}
	}
	#Soviets
	if = {
		limit = {
			has_template = "Shtrafnaya Chast"
		}
		set_division_template_lock = {
			division_template = "Shtrafnaya Chast"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Trotskyist Revolutionary Militias"
		}
		set_division_template_lock = {
			division_template = "Trotskyist Revolutionary Militias"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Resistance Fighters"	#Also used by Ethiopia
		}
		set_division_template_lock = {
			division_template = "Resistance Fighters"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Peasant Militia"
		}
		set_division_template_lock = {
			division_template = "Peasant Militia"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "International Marxist Brigades"
		}
		set_division_template_lock = {
			division_template = "International Marxist Brigades"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Soviet Special Brigades"
		}
		set_division_template_lock = {
			division_template = "Soviet Special Brigades"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "POUM Special Brigades"
		}
		set_division_template_lock = {
			division_template = "POUM Special Brigades"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Brigada de las Juventudes del POUM"
		}
		set_division_template_lock = {
			division_template = "Brigada de las Juventudes del POUM"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Trotskyist Workers' Militia"
		}
		set_division_template_lock = {
			division_template = "Trotskyist Workers' Militia"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Trotskyist Peasant Militia"
		}
		set_division_template_lock = {
			division_template = "Trotskyist Peasant Militia"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Bukharinist Workers' Militia"
		}
		set_division_template_lock = {
			division_template = "Bukharinist Workers' Militia"
			is_locked = no
		}
	}		
	if = {
		limit = {
			has_template = "Bukharinist Peasant Militia"
		}
		set_division_template_lock = {
			division_template = "Bukharinist Peasant Militia"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Japanese Expeditionary Force"
		}
		set_division_template_lock = {
			division_template = "Japanese Expeditionary Force"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Opposition Partisan Brigade"
		}
		set_division_template_lock = {
			division_template = "Opposition Partisan Brigade"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "International Brigades"
		}
		set_division_template_lock = {
			division_template = "International Brigades"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "German Trained Division"
		}
		set_division_template_lock = {
			division_template = "German Trained Division"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "NKVD Pogranichnaya Diviziya"
		}
		set_division_template_lock = {
			division_template = "NKVD Pogranichnaya Diviziya"
			is_locked = no
		}
	}
	#Spain
	if = {
		limit = {
			has_template = "Brigada Internacionales"
		}
		set_division_template_lock = {
			division_template = "Brigada Internacionales"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Fifth Columnist Brigade"
		}
		set_division_template_lock = {
			division_template = "Fifth Columnist Brigade"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Anarchist Militia"
		}
		set_division_template_lock = {
			division_template = "Anarchist Militia"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Carabineros"
		}
		set_division_template_lock = {
			division_template = "Carabineros"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Brigada Legionario"
		}
		set_division_template_lock = {
			division_template = "Brigada Legionario"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Guarnición Nacionalista"
		}
		set_division_template_lock = {
			division_template = "Guarnición Nacionalista"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Guarnición Republicana"
		}
		set_division_template_lock = {
			division_template = "Guarnición Republicana"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Requeté Carlista"
		}
		set_division_template_lock = {
			division_template = "Requeté Carlista"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "División de la Guardia de Asalto"
		}
		set_division_template_lock = {
			division_template = "División de la Guardia de Asalto"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Brigada de la Guardia Civil"
		}
		set_division_template_lock = {
			division_template = "Brigada de la Guardia Civil"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Brigada de la Guardia Civil"
		}
		set_division_template_lock = {
			division_template = "Brigada de la Guardia Civil"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Brigada de Juventudes Sindicales"
		}
		set_division_template_lock = {
			division_template = "Brigada de Juventudes Sindicales"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Brigada Popular"
		}
		set_division_template_lock = {
			division_template = "Brigada Popular"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Brigada Anarquista"
		}
		set_division_template_lock = {
			division_template = "Brigada Anarquista"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Spanish Loyalist Division"
		}
		set_division_template_lock = {
			division_template = "Spanish Loyalist Division"
			is_locked = no
		}
	}
	#Britain
	if = {
		limit = {
			has_template = "Loyalist Brigade"
		}
		set_division_template_lock = {
			division_template = "Loyalist Brigade"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Blackshirt Brigade"
		}
		set_division_template_lock = {
			division_template = "Blackshirt Brigade"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Pakistani Liberation Army"
		}
		set_division_template_lock = {
			division_template = "Pakistani Liberation Army"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Hindu Militia"
		}
		set_division_template_lock = {
			division_template = "Hindu Militia"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Bangladeshi Liberation Army"
		}
		set_division_template_lock = {
			division_template = "Bangladeshi Liberation Army"
			is_locked = no
		}
	}
	#USA
	if = {
		limit = {
			has_template = "Local Volunteers"
		}
		set_division_template_lock = {
			division_template = "Local Volunteers"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Citizen Militia"
		}
		set_division_template_lock = {
			division_template = "Citizen Militia"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Silver Legion"
		}
		set_division_template_lock = {
			division_template = "Silver Legion"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Exiles"
		}
		set_division_template_lock = {
			division_template = "Exiles"
			is_locked = no
		}
	}
	#Baltics
	if = {
		limit = {
			has_template = "Soviet Volunteers" #Also used by Japan
		}
		set_division_template_lock = {
			division_template = "Soviet Volunteers"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Forest Brothers"
		}
		set_division_template_lock = {
			division_template = "Forest Brothers"
			is_locked = no
		}
	}	
	#Germany (SS)
	if = {
		limit = {
			has_template = "SS Motorisierte Division"
		}
		set_division_template_lock = {
			division_template = "SS Motorisierte Division"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "SS Panzergrenadier Division"
		}
		set_division_template_lock = {
			division_template = "SS Panzergrenadier Division"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "SS Panzergrenadier Division (n.A.)"
		}
		set_division_template_lock = {
			division_template = "SS Panzergrenadier Division (n.A.)"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "SS Panzer Division"
		}
		set_division_template_lock = {
			division_template = "SS Panzer Division"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "SS Panzer Division (n.A.)"
		}
		set_division_template_lock = {
			division_template = "SS Panzer Division (n.A.)"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "SS Panzer Division (vollgep.)"
		}
		set_division_template_lock = {
			division_template = "SS Panzer Division (vollgep.)"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "SS Waffen-Grenadier-Division"
		}
		set_division_template_lock = {
			division_template = "SS Waffen-Grenadier-Division"
			is_locked = no
		}
	}
	#Germany (civil war)
	if = {
		limit = {
			has_template = "SS-Sturmbrigade"
		}
		set_division_template_lock = {
			division_template = "SS-Sturmbrigade"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Landsturmregiment"
		}
		set_division_template_lock = {
			division_template = "Landsturmregiment"
			is_locked = no
		}
	}
	#Ethiopia
	if = {
		limit = {
			has_template = "Arbegnoch Fighters"
		}
		set_division_template_lock = {
			division_template = "Arbegnoch Fighters"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Kebur Zabagna"
		}
		set_division_template_lock = {
			division_template = "Kebur Zabagna"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Chitet Sefari"
		}
		set_division_template_lock = {
			division_template = "Chitet Sefari"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Guards"
		}
		set_division_template_lock = {
			division_template = "Guards"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Red Guards"
		}
		set_division_template_lock = {
			division_template = "Red Guards"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Black Lions"
		}
		set_division_template_lock = {
			division_template = "Black Lions"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Eritrean Askari"
		}
		set_division_template_lock = {
			division_template = "Eritrean Askari"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "International brigade"
		}
		set_division_template_lock = {
			division_template = "International brigade"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Irregular Cavalry Division"
		}
		set_division_template_lock = {
			division_template = "Irregular Cavalry Division"
			is_locked = no
		}
	}
	if = {	#might be a typo here
		limit = {
			has_template = "Irregular Camalry Division"
		}
		set_division_template_lock = {
			division_template = "Irregular Camalry Division"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Congolese Mercenaries"
		}
		set_division_template_lock = {
			division_template = "Congolese Mercenaries"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Arab Mercenaries"
		}
		set_division_template_lock = {
			division_template = "Arab Mercenaries"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Sudanese Mercenaries"
		}
		set_division_template_lock = {
			division_template = "Sudanese Mercenaries"
			is_locked = no
		}
	}
	#Rebellions
	if = {
		limit = {
			has_template = "Resistance"
		}
		set_division_template_lock = {
			division_template = "Resistance"
			is_locked = no
		}
	}
	#India
	if = {
		limit = {
			has_template = "Battaglione Azad Hindoustan"
		}
		set_division_template_lock = {
			division_template = "Battaglione Azad Hindoustan"
			is_locked = no
		}
	}
	#Bulgaria
	if = {
		limit = {
			has_template = "Fatherland Front Militia"
		}
		set_division_template_lock = {
			division_template = "Fatherland Front Militia"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Fatherland Front Partisans"
		}
		set_division_template_lock = {
			division_template = "Fatherland Front Partisans"
			is_locked = no
		}
	}
	#Yugoslavia
	if = {
		limit = {
			has_template = "Yugoslavian Defence Army"
		}
		set_division_template_lock = {
			division_template = "Yugoslavian Defence Army"
			is_locked = no
		}
	}
	#Switzerland
	if = {
		limit = {
			has_template = "Leichte-Brigade"
		}
		set_division_template_lock = {
			division_template = "Leichte-Brigade"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Swiss Citizen Militia"
		}
		set_division_template_lock = {
			division_template = "Swiss Citizen Militia"
			is_locked = no
		}
	}
	#Mixed
	if = {
		limit = {
			has_template ="FFI Demi-Brigade" #Free France
		}
		set_division_template_lock = {
			division_template ="FFI Demi-Brigade"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "East African Irregulars" #Horn of Africa
		}
		set_division_template_lock = {
			division_template = "East African Irregulars"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Maori Volunteers" #New Zealand
		}
		set_division_template_lock = {
			division_template = "Maori Volunteers"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Morges Division" #Poland
		}
		set_division_template_lock = {
			division_template = "Morges Division"
			is_locked = no
		}
	}
	#Japan (civil war)
	if = {
		limit = {
			has_template = "Japanese People's Regiment"
		}
		set_division_template_lock = {
			division_template = "Japanese People's Regiment"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "Japanese Loyalist Regiment"
		}
		set_division_template_lock = {
			division_template = "Japanese Loyalist Regiment"
			is_locked = no
		}
	}
	#Latvia
	if = {
		limit = {
			has_template = "Ugonskrust Division"
		}
		set_division_template_lock = {
			division_template = "Ugonskrust Division"
			is_locked = no
		}
	}
	#Netherlands
	if = {
		limit = {
			has_template = "Hare Majesteits Duitse Legioen"
		}
		set_division_template_lock = {
			division_template = "Hare Majesteits Duitse Legioen"
			is_locked = no
		}
	}
	if = {
		limit = {
			has_template = "American Garrison"
		}
		set_division_template_lock = {
			division_template = "American Garrison"
			is_locked = no
		}
	}
}
sst_spawn_ship = {
	meta_effect = {
		text = {
			if = {	#Non-MTG
				limit = {
					NOT = {
						has_dlc = "Man the Guns"
					}
				}
				if = {
					limit = {
						has_global_flag = sst_destroyer_enabled
					}
					if = {
						limit = {
							NOT = { has_tech = early_destroyer }
						}
						set_technology = {
							early_destroyer = 1
						}
					}
					if = {
						limit = {
							NOT = { has_tech = basic_destroyer }
							has_global_flag = sst_y2_enabled
						}
						set_technology = {
							basic_destroyer = 1
						}
					}
					if = {
						limit = {
							NOT = { has_tech = improved_destroyer }
							has_global_flag = sst_y3_enabled
						}
						set_technology = {
							improved_destroyer = 1
						}
					}
					if = {
						limit = {
							NOT = { has_tech = advanced_destroyer }
							has_global_flag = sst_y4_enabled
						}
						set_technology = {
							advanced_destroyer = 1
						}
					}
					if = {
						limit = {
							NOT = {
								has_country_flag = toolpack_has_destroyer_design_[EQ_LEVEL]
							}
						}
						create_equipment_variant = {
							name = "Toolpack Destroyer [EQ_LEVEL]"
							type = destroyer_[EQ_LEVEL]
							upgrades = {
								ship_torpedo_upgrade = 1
								destroyer_engine_upgrade = 1
								ship_ASW_upgrade = 1
								ship_anti_air_upgrade = 1
							}
						}
						set_country_flag = toolpack_has_destroyer_design_[EQ_LEVEL]
					}
					create_ship = {
						type = destroyer_[EQ_LEVEL]
						equipment_variant = "Toolpack Destroyer [EQ_LEVEL]"
					}
				}
				if = {
					limit = {
						has_global_flag = sst_lc_enabled
					}
					if = {
						limit = {
							NOT = { has_tech = early_light_cruiser }
						}
						set_technology = {
							early_light_cruiser = 1
						}
					}
					if = {
						limit = {
							NOT = { has_tech = basic_light_cruiser }
							has_global_flag = sst_y2_enabled
						}
						set_technology = {
							basic_light_cruiser = 1
						}
					}
					if = {
						limit = {
							NOT = { has_tech = improved_light_cruiser }
							has_global_flag = sst_y3_enabled
						}
						set_technology = {
							improved_light_cruiser = 1
						}
					}
					if = {
						limit = {
							NOT = { has_tech = advanced_light_cruiser }
							has_global_flag = sst_y4_enabled
						}
						set_technology = {
							advanced_light_cruiser = 1
						}
					}
					if = {
						limit = {
							NOT = {
								has_country_flag = toolpack_has_lcruiser_design_[EQ_LEVEL]
							}
						}
						create_equipment_variant = {
							name = "Toolpack Light Cruiser [EQ_LEVEL]"
							type = light_cruiser_[EQ_LEVEL]
							upgrades = {
								ship_reliability_upgrade = 1
								ship_engine_upgrade = 1
								ship_gun_upgrade = 1
								ship_anti_air_upgrade = 1
							}
						}
						set_country_flag = toolpack_has_lcruiser_design_[EQ_LEVEL]
					}
					create_ship = {
						type = light_cruiser_[EQ_LEVEL]
						equipment_variant = "Toolpack Light Cruiser [EQ_LEVEL]"
					}
				}
				if = {
					limit = {
						has_global_flag = sst_corvette_enabled
					}
					if = {
						limit = {
							NOT = { has_tech = early_heavy_cruiser }
						}
						set_technology = {
							early_heavy_cruiser = 1
						}
					}
					if = {
						limit = {
							NOT = { has_tech = basic_heavy_cruiser }
							has_global_flag = sst_y2_enabled
						}
						set_technology = {
							basic_heavy_cruiser = 1
						}
					}
					if = {
						limit = {
							NOT = { has_tech = improved_heavy_cruiser }
							has_global_flag = sst_y3_enabled
						}
						set_technology = {
							improved_heavy_cruiser = 1
						}
					}
					if = {
						limit = {
							NOT = { has_tech = advanced_heavy_cruiser }
							has_global_flag = sst_y4_enabled
						}
						set_technology = {
							advanced_heavy_cruiser = 1
						}
					}
					if = {
						limit = {
							NOT = {
								has_country_flag = toolpack_has_hcruiser_design_[EQ_LEVEL]
							}
						}
						create_equipment_variant = {
							name = "Toolpack Heavy Cruiser [EQ_LEVEL]"
							type = heavy_cruiser_[EQ_LEVEL]
							upgrades = {
								ship_reliability_upgrade = 1
								ship_engine_upgrade = 1
								ship_armor_upgrade = 1
								ship_gun_upgrade = 1
							}
						}
						set_country_flag = toolpack_has_hcruiser_design_[EQ_LEVEL]
					}
					create_ship = {
						type = heavy_cruiser_[EQ_LEVEL]
						equipment_variant = "Toolpack Heavy Cruiser [EQ_LEVEL]"
					}
				}
				if = {
					limit = {
						has_global_flag = sst_bc_enabled
					}
					if = {
						limit = {
							NOT = { has_tech = early_battlecruiser }
						}
						set_technology = {
							early_battlecruiser = 1
						}
					}
					if = {
						limit = {
							NOT = { has_tech = basic_battlecruiser }
							OR = {
								has_global_flag = sst_y3_enabled
								has_global_flag = sst_y4_enabled
							}
						}
						set_technology = {
							basic_battlecruiser = 1
						}
					}
					if = {	#battlecruiser has just 2 tiers
						limit = {
							OR = {
								has_global_flag = sst_y3_enabled
								has_global_flag = sst_y4_enabled
							}
						}
						if = {
							limit = {
								NOT = {
									has_country_flag = toolpack_has_bcruiser_design_2
								}
							}
							create_equipment_variant = {
								name = "Toolpack Battlecruiser 2"
								type = battle_cruiser_2
								upgrades = {
									ship_reliability_upgrade = 1
									ship_engine_upgrade = 1
									ship_armor_upgrade = 1
									ship_gun_upgrade = 1
								}
							}
							set_country_flag = toolpack_has_bcruiser_design_2
						}
						create_ship = {
							type = battle_cruiser_2
							equipment_variant = "Toolpack Battlecruiser 2"
						}
					}
					else = {
						if = {
							limit = {
								NOT = {
									has_country_flag = toolpack_has_bcruiser_design_1
								}
							}
							create_equipment_variant = {
								name = "Toolpack Battlecruiser 1"
								type = battle_cruiser_1
								upgrades = {
									ship_reliability_upgrade = 1
									ship_engine_upgrade = 1
									ship_armor_upgrade = 1
									ship_gun_upgrade = 1
								}
							}
							set_country_flag = toolpack_has_bcruiser_design_1
						}
						create_ship = {
							type = battle_cruiser_1
							equipment_variant = "Toolpack Battlecruiser 1"
						}
					}
				}
				if = {
					limit = {
						has_global_flag = sst_attack_sub_enabled
					}
					if = {
						limit = {
							NOT = { has_tech = early_battleship }
						}
						set_technology = {
							early_battleship = 1
						}
					}
					if = {
						limit = {
							NOT = { has_tech = basic_battleship }
							has_global_flag = sst_y2_enabled
						}
						set_technology = {
							basic_battleship = 1
						}
					}
					if = {
						limit = {
							NOT = { has_tech = improved_battleship }
							has_global_flag = sst_y3_enabled
						}
						set_technology = {
							improved_battleship = 1
						}
					}
					if = {
						limit = {
							NOT = { has_tech = advanced_battleship }
							has_global_flag = sst_y4_enabled
						}
						set_technology = {
							advanced_battleship = 1
						}
					}
					if = {
						limit = {
							NOT = {
								has_country_flag = toolpack_has_battleship_design_[EQ_LEVEL]
							}
						}
						create_equipment_variant = {
							name = "Toolpack Battleship [EQ_LEVEL]"
							type = battleship_[EQ_LEVEL]
							upgrades = {
								ship_reliability_upgrade = 1
								ship_engine_upgrade = 1
								ship_armor_upgrade = 1
								ship_gun_upgrade = 1
							}
						}
						set_country_flag = toolpack_has_battleship_design_[EQ_LEVEL]
					}
					create_ship = {
						type = battleship_[EQ_LEVEL]
						equipment_variant = "Toolpack Battleship [EQ_LEVEL]"
					}
				}
				if = {
					limit = {
						has_global_flag = sst_carrier_enabled
					}
					if = {
						limit = {
							NOT = { has_tech = early_carrier }
						}
						set_technology = {
							early_carrier = 1
						}
					}
					if = {
						limit = {
							NOT = { has_tech = basic_carrier }
							has_global_flag = sst_y2_enabled
						}
						set_technology = {
							basic_carrier = 1
						}
					}
					if = {
						limit = {
							NOT = { has_tech = improved_carrier }
							has_global_flag = sst_y3_enabled
						}
						set_technology = {
							improved_carrier = 1
						}
					}
					if = {
						limit = {
							NOT = { has_tech = advanced_carrier }
							has_global_flag = sst_y4_enabled
						}
						set_technology = {
							advanced_carrier = 1
						}
					}
					if = {
						limit = {
							NOT = {
								has_country_flag = toolpack_has_carrier_design_[EQ_LEVEL]
							}
						}
						create_equipment_variant = {
							name = "Toolpack Carrier [EQ_LEVEL]"
							type = carrier_[EQ_LEVEL]
							upgrades = {
								ship_deckspace_upgrade = 1
								carrier_armor_upgrade = 1
								ship_engine_upgrade = 1
								ship_reliability_upgrade = 1
							}
						}
						set_country_flag = toolpack_has_carrier_design_[EQ_LEVEL]
					}
					create_ship = {
						type = carrier_[EQ_LEVEL]
						equipment_variant = "Toolpack Carrier [EQ_LEVEL]"
					}
				}
				if = {
					limit = {
						has_global_flag = sst_sub_enabled
					}
					if = {
						limit = {
							NOT = { has_tech = early_submarine }
						}
						set_technology = {
							early_submarine = 1
						}
					}
					if = {
						limit = {
							NOT = {
								has_country_flag = toolpack_has_submarine_design_[EQ_LEVEL]
							}
						}
						create_equipment_variant = {
							name = "Toolpack Submarine [EQ_LEVEL]"
							type = submarine_[EQ_LEVEL]
							upgrades = {
								ship_reliability_upgrade = 1
								sub_engine_upgrade = 1
								sub_stealth_upgrade = 1
								sub_torpedo_upgrade = 1
							}
						}
						set_country_flag = toolpack_has_submarine_design_[EQ_LEVEL]
					}
					create_ship = {
						type = submarine_[EQ_LEVEL]
						equipment_variant = "Toolpack Submarine [EQ_LEVEL]"
					}
				}
			}
			else = {	#MTG
				if = {
					limit = {
						has_global_flag = sst_destroyer_enabled
					}
					if = {
						limit = {
							NOT = { has_tech = early_ship_hull_light }
						}
						set_technology = {
							early_ship_hull_light = 1
						}
					}
					if = {
						limit = {
							NOT = { has_tech = basic_ship_hull_light }
							has_global_flag = sst_y2_enabled
						}
						set_technology = {
							basic_ship_hull_light = 1
						}
					}
					if = {
						limit = {
							NOT = { has_tech = improved_ship_hull_light }
							has_global_flag = sst_y3_enabled
						}
						set_technology = {
							improved_ship_hull_light = 1
						}
					}
					if = {
						limit = {
							NOT = { has_tech = advanced_ship_hull_light }
							has_global_flag = sst_y4_enabled
						}
						set_technology = {
							advanced_ship_hull_light = 1
						}
					}
					if = {
						limit = {
							NOT = {
								has_country_flag = toolpack_has_destroyer_design_[EQ_LEVEL]
							}
						}
						create_equipment_variant = {
							name = "Toolpack Destroyer [EQ_LEVEL]"
							type = ship_hull_light_[EQ_LEVEL]
							modules = {	#Gabianno Class
								fixed_ship_battery_slot = ship_light_battery_1
								fixed_ship_anti_air_slot = ship_anti_air_2
								fixed_ship_fire_control_system_slot = ship_sonar_2
								fixed_ship_radar_slot = empty
								fixed_ship_engine_slot = light_ship_engine_1
								fixed_ship_torpedo_slot = ship_torpedo_1
								mid_1_custom_slot = ship_depth_charge_2
								rear_1_custom_slot = ship_depth_charge_2
								#front_1_custom_slot = ship_light_battery_2
							}
						}
						set_country_flag = toolpack_has_destroyer_design_[EQ_LEVEL]
					}
					create_ship = {
						type = ship_hull_light_[EQ_LEVEL]
						equipment_variant = "Toolpack Destroyer [EQ_LEVEL]"
					}
				}
				if = {
					limit = {
						has_global_flag = sst_lc_enabled
					}
					if = {
						limit = {
							NOT = { has_tech = early_ship_hull_cruiser }
						}
						set_technology = {
							early_ship_hull_cruiser = 1
						}
					}
					if = {
						limit = {
							NOT = { has_tech = basic_ship_hull_cruiser }
							has_global_flag = sst_y2_enabled
						}
						set_technology = {
							basic_ship_hull_cruiser = 1
						}
					}
					if = {
						limit = {
							NOT = { has_tech = improved_ship_hull_cruiser }
							has_global_flag = sst_y3_enabled
						}
						set_technology = {
							improved_ship_hull_cruiser = 1
						}
					}
					if = {
						limit = {
							NOT = { has_tech = advanced_ship_hull_cruiser }
							has_global_flag = sst_y4_enabled
						}
						set_technology = {
							advanced_ship_hull_cruiser = 1
						}
					}
					if = {
						limit = {
							NOT = {
								has_country_flag = toolpack_has_lcruiser_design_[EQ_LEVEL]
							}
						}
						create_equipment_variant = {
							name = "Toolpack Light Cruiser [EQ_LEVEL]"
							type = ship_hull_cruiser_[EQ_LEVEL]
							modules = {	#from British AI
								fixed_ship_battery_slot = ship_light_medium_battery_1
								fixed_ship_anti_air_slot = ship_anti_air_1
								fixed_ship_fire_control_system_slot = ship_fire_control_system_0
								fixed_ship_radar_slot = empty
								fixed_ship_engine_slot = cruiser_ship_engine_1
								fixed_ship_armor_slot = ship_armor_cruiser_1
								mid_1_custom_slot = ship_torpedo_1
								mid_2_custom_slot = empty
								rear_1_custom_slot = empty
							}
						}
						set_country_flag = toolpack_has_lcruiser_design_[EQ_LEVEL]
					}
					create_ship = {
						type = ship_hull_cruiser_[EQ_LEVEL]
						equipment_variant = "Toolpack Light Cruiser [EQ_LEVEL]"
					}
				}
				if = {
					limit = {
						has_global_flag = sst_corvette_enabled
					}
					if = {
						limit = {
							NOT = { has_tech = early_ship_hull_cruiser }
						}
						set_technology = {
							early_ship_hull_cruiser = 1
						}
					}
					if = {
						limit = {
							NOT = { has_tech = basic_ship_hull_cruiser }
							has_global_flag = sst_y2_enabled
						}
						set_technology = {
							basic_ship_hull_cruiser = 1
						}
					}
					if = {
						limit = {
							NOT = { has_tech = improved_ship_hull_cruiser }
							has_global_flag = sst_y3_enabled
						}
						set_technology = {
							improved_ship_hull_cruiser = 1
						}
					}
					if = {
						limit = {
							NOT = { has_tech = advanced_ship_hull_cruiser }
							has_global_flag = sst_y4_enabled
						}
						set_technology = {
							advanced_ship_hull_cruiser = 1
						}
					}
					if = {
						limit = {
							NOT = {
								has_country_flag = toolpack_has_hcruiser_design_[EQ_LEVEL]
							}
						}
						create_equipment_variant = {
							name = "Toolpack Heavy Cruiser [EQ_LEVEL]"
							type = ship_hull_cruiser_[EQ_LEVEL]
							modules = {
								fixed_ship_battery_slot = ship_medium_battery_1	#should turn it into heavy
								fixed_ship_anti_air_slot = ship_anti_air_1
								fixed_ship_fire_control_system_slot = ship_fire_control_system_0
								fixed_ship_radar_slot = empty
								fixed_ship_engine_slot = cruiser_ship_engine_1
								fixed_ship_armor_slot = ship_armor_cruiser_1
								fixed_ship_secondaries_slot = empty
								mid_1_custom_slot = ship_torpedo_1
								mid_2_custom_slot = ship_medium_battery_1
								rear_1_custom_slot = ship_mine_layer_1
							}
						}
						set_country_flag = toolpack_has_hcruiser_design_[EQ_LEVEL]
					}
					create_ship = {
						type = ship_hull_cruiser_[EQ_LEVEL]
						equipment_variant = "Toolpack Heavy Cruiser [EQ_LEVEL]"
					}
				}
				if = {
					limit = {
						has_global_flag = sst_bc_enabled
					}
					if = {
						limit = {
							NOT = { has_tech = early_ship_hull_heavy }
						}
						set_technology = {
							early_ship_hull_heavy = 1
						}
					}
					if = {
						limit = {
							NOT = { has_tech = basic_ship_hull_heavy }
							has_global_flag = sst_y2_enabled
						}
						set_technology = {
							basic_ship_hull_heavy = 1
						}
					}
					if = {
						limit = {
							NOT = { has_tech = improved_ship_hull_heavy }
							has_global_flag = sst_y3_enabled
						}
						set_technology = {
							improved_ship_hull_heavy = 1
						}
					}
					if = {
						limit = {
							NOT = { has_tech = advanced_ship_hull_heavy }
							has_global_flag = sst_y4_enabled
						}
						set_technology = {
							advanced_ship_hull_heavy = 1
						}
					}
					if = {
						limit = {
							NOT = {
								has_country_flag = toolpack_has_bcruiser_design_[EQ_LEVEL]
							}
						}
						create_equipment_variant = {
							name = "Toolpack Battlecruiser [EQ_LEVEL]"
							type = ship_hull_heavy_[EQ_LEVEL]
							modules = { #From Salami's class
								fixed_ship_battery_slot = ship_heavy_battery_2
								fixed_ship_anti_air_slot = ship_anti_air_1 
								fixed_ship_fire_control_system_slot = ship_fire_control_system_0
								fixed_ship_radar_slot = empty
								fixed_ship_engine_slot = heavy_ship_engine_2 
								fixed_ship_secondaries_slot = ship_secondaries_2
								fixed_ship_armor_slot = ship_armor_bc_2 
								front_1_custom_slot = ship_anti_air_1
								mid_1_custom_slot = ship_secondaries_2
								mid_2_custom_slot = empty
								rear_1_custom_slot = ship_heavy_battery_2 
							}
						}
						set_country_flag = toolpack_has_bcruiser_design_[EQ_LEVEL]
					}
					create_ship = {
						type = ship_hull_heavy_[EQ_LEVEL]
						equipment_variant = "Toolpack Battlecruiser [EQ_LEVEL]"
					}
				}
				if = {
					limit = {
						has_global_flag = sst_attack_sub_enabled
					}
					if = {
						limit = {
							NOT = { has_tech = early_ship_hull_heavy }
						}
						set_technology = {
							early_ship_hull_heavy = 1
						}
					}
					if = {
						limit = {
							NOT = { has_tech = basic_ship_hull_heavy }
							has_global_flag = sst_y2_enabled
						}
						set_technology = {
							basic_ship_hull_heavy = 1
						}
					}
					if = {
						limit = {
							NOT = { has_tech = improved_ship_hull_heavy }
							has_global_flag = sst_y3_enabled
						}
						set_technology = {
							improved_ship_hull_heavy = 1
						}
					}
					if = {
						limit = {
							NOT = { has_tech = advanced_ship_hull_heavy }
							has_global_flag = sst_y4_enabled
						}
						set_technology = {
							advanced_ship_hull_heavy = 1
						}
					}
					if = {
						limit = {
							NOT = {
								has_country_flag = toolpack_has_battleship_design_[EQ_LEVEL]
							}
						}
						create_equipment_variant = {
							name = "Toolpack Battleship [EQ_LEVEL]"
							type = ship_hull_heavy_[EQ_LEVEL]
							modules = { #random Greek battleship, with some edits
								fixed_ship_battery_slot = ship_heavy_battery_1
								fixed_ship_anti_air_slot = ship_anti_air_1 
								fixed_ship_fire_control_system_slot = ship_fire_control_system_0
								fixed_ship_radar_slot = empty
								fixed_ship_engine_slot = heavy_ship_engine_1 
								fixed_ship_secondaries_slot = ship_secondaries_1
								fixed_ship_armor_slot = ship_armor_bb_1
								front_1_custom_slot = ship_anti_air_1
								mid_1_custom_slot = ship_secondaries_1 
								mid_2_custom_slot = empty
								rear_1_custom_slot = empty
							} 
						}
						set_country_flag = toolpack_has_battleship_design_[EQ_LEVEL]
					}
					create_ship = {
						type = ship_hull_heavy_[EQ_LEVEL]
						equipment_variant = "Toolpack Battleship [EQ_LEVEL]"
					}
				}
				if = {	#changed to scale from 2-5
					limit = {
						has_global_flag = sst_carrier_enabled
					}
					if = {
						limit = {
							NOT = { has_tech = carrier_hull_2 }
						}
						set_technology = {
							carrier_hull_2 = 1
						}
					}
					if = {
						limit = {
							NOT = { has_tech = carrier_hull_3 }
							has_global_flag = sst_y2_enabled
						}
						set_technology = {
							carrier_hull_3 = 1
						}
					}
					if = {
						limit = {
							NOT = { has_tech = carrier_hull_4 }
							has_global_flag = sst_y3_enabled
						}
						set_technology = {
							carrier_hull_4 = 1
						}
					}
					if = {
						limit = {
							NOT = { has_tech = carrier_hull_5 }
							has_global_flag = sst_y4_enabled
						}
						set_technology = {
							carrier_hull_5 = 1
						}
					}
					if = {
						limit = {
							NOT = {
								has_country_flag = toolpack_has_carrier_design_[EQ_LEVEL]
							}
						}
						create_equipment_variant = {
							name = "Toolpack Carrier [EQ_LEVEL]"
							type = [CARRIER_HULL]
							modules = { #Joffre class
								fixed_ship_deck_slot_1 = ship_deck_space
								fixed_ship_deck_slot_2 = ship_deck_space
								fixed_ship_anti_air_slot = ship_anti_air_1
								fixed_ship_radar_slot = empty
								fixed_ship_engine_slot = carrier_ship_engine_2
								fixed_ship_secondaries_slot = dp_ship_secondaries_2
								front_1_custom_slot = empty
							}
						}
						set_country_flag = toolpack_has_carrier_design_[EQ_LEVEL]
					}
					create_ship = {
						type = [CARRIER_HULL]
						equipment_variant = "Toolpack Carrier [EQ_LEVEL]"
					}
				}
				if = {
					limit = {
						has_global_flag = sst_sub_enabled
					}
					if = {
						limit = {
							NOT = { has_tech = early_ship_hull_submarine }
						}
						set_technology = {
							early_ship_hull_submarine = 1
						}
					}
					if = {
						limit = {
							NOT = { has_tech = basic_ship_hull_submarine }
							has_global_flag = sst_y2_enabled
						}
						set_technology = {
							basic_ship_hull_submarine = 1
						}
					}
					if = {
						limit = {
							NOT = { has_tech = improved_ship_hull_submarine }
							has_global_flag = sst_y3_enabled
						}
						set_technology = {
							improved_ship_hull_submarine = 1
						}
					}
					if = {
						limit = {
							NOT = { has_tech = advanced_ship_hull_submarine }
							has_global_flag = sst_y4_enabled
						}
						set_technology = {
							advanced_ship_hull_submarine = 1
						}
					}
					if = {
						limit = {
							NOT = {
								has_country_flag = toolpack_has_submarine_design_[EQ_LEVEL]
							}
						}
						create_equipment_variant = {
							name = "Toolpack Submarine [EQ_LEVEL]"
							type = ship_hull_submarine_[EQ_LEVEL]
							modules = {	#taken from submarine_early
								fixed_ship_engine_slot = sub_ship_engine_1
								fixed_ship_torpedo_slot = ship_torpedo_sub_1
								rear_1_custom_slot = empty
							}
						}
						set_country_flag = toolpack_has_submarine_design_[EQ_LEVEL]
					}
					create_ship = {
						type = ship_hull_submarine_[EQ_LEVEL]
						equipment_variant = "Toolpack Submarine [EQ_LEVEL]"
					}
				}
			}
		}
		EQ_LEVEL = "[This.GetSSTShipTier]"
		CARRIER_HULL = "[This.GetSSTCarrierTier]"	#Carriers dont start at 1 for MTG owners
	}
}
sst_destroy_ship = {	#edit to actually match types on cruisers
	if = {
		limit = {
			has_global_flag = sst_destroyer_enabled
		}
		destroy_ships = {
			type = ship_hull_light
			count = all
		}
	}
	if = {
		limit = {
			has_global_flag = sst_lc_enabled
		}
		destroy_ships = {
			type = ship_hull_cruiser
			count = all
		}
	}
	if = {
		limit = {
			has_global_flag = sst_corvette_enabled
		}
		destroy_ships = {
			type = ship_hull_heavy
			count = all
		}
	}
	if = {
		limit = {
			has_global_flag = sst_bc_enabled
		}
		destroy_ships = {
			type = ship_hull_heavy
			count = all
		}
	}
	if = {
		limit = {
			has_global_flag = sst_attack_sub_enabled
		}
		destroy_ships = {
			type = ship_hull_heavy
			count = all
		}
	}
	if = {
		limit = {
			has_global_flag = sst_carrier_enabled
		}
		destroy_ships = {
			type = ship_hull_carrier
			count = all
		}
	}
	if = {
		limit = {
			has_global_flag = sst_sub_enabled
		}
		destroy_ships = {
			type = ship_hull_submarine
			count = all
		}
	}
}
dst_a_delete_units = {
	if = {
		limit = {
			has_global_flag = dst_infantry_enabled
			has_global_flag = dst_1_battalion
		}
		delete_unit_template_and_units = {
			division_template = "Inf1B"
		}
	}
	if = {
		limit = {
			has_global_flag = dst_infantry_enabled
			has_global_flag = dst_2_battalions
		}
		delete_unit_template_and_units = {
			division_template = "Inf2B"
		}
	}
	if = {
		limit = {
			has_global_flag = dst_infantry_enabled
			has_global_flag = dst_4_battalions
		}
		delete_unit_template_and_units = {
			division_template = "Inf4B"
		}
	}
	if = {
		limit = {
			has_global_flag = dst_infantry_enabled
			has_global_flag = dst_6_battalions
		}
		delete_unit_template_and_units = {
			division_template = "Inf5B"
		}
	}
	if = {
		limit = {
			has_global_flag = dst_infantry_enabled
			has_global_flag = dst_8_battalions
		}
		delete_unit_template_and_units = {
			division_template = "Inf8B"
		}
	}
	if = {
		limit = {
			has_global_flag = dst_infantry_enabled
			has_global_flag = dst_10_battalions
		}
		delete_unit_template_and_units = {
			division_template = "Inf10B"
		}
	}
	if = {
		limit = {
			has_global_flag = dst_infantry_enabled
			has_global_flag = dst_16_battalions
		}
		delete_unit_template_and_units = {
			division_template = "Inf16B"
		}
	}
	if = {
		limit = {
			has_global_flag = dst_infantry_enabled
			has_global_flag = dst_20_battalions
		}
		delete_unit_template_and_units = {
			division_template = "Inf20B"
		}
	}
	if = {
		limit = {
			has_global_flag = dst_cavalry_enabled
			has_global_flag = dst_1_battalion
		}
		delete_unit_template_and_units = {
			division_template = "Cav1B"
		}
	}
	if = {
		limit = {
			has_global_flag = dst_cavalry_enabled
			has_global_flag = dst_2_battalions
		}
		delete_unit_template_and_units = {
			division_template = "Cav2B"
		}
	}
	if = {
		limit = {
			has_global_flag = dst_cavalry_enabled
			has_global_flag = dst_4_battalions
		}
		delete_unit_template_and_units = {
			division_template = "Cav4B"
		}
	}
	if = {
		limit = {
			has_global_flag = dst_cavalry_enabled
			has_global_flag = dst_6_battalions
		}
		delete_unit_template_and_units = {
			division_template = "Cav5B"
		}
	}
	if = {
		limit = {
			has_global_flag = dst_cavalry_enabled
			has_global_flag = dst_8_battalions
		}
		delete_unit_template_and_units = {
			division_template = "Cav8B"
		}
	}
	if = {
		limit = {
			has_global_flag = dst_cavalry_enabled
			has_global_flag = dst_10_battalions
		}
		delete_unit_template_and_units = {
			division_template = "Cav10B"
		}
	}
	if = {
		limit = {
			has_global_flag = dst_cavalry_enabled
			has_global_flag = dst_16_battalions
		}
		delete_unit_template_and_units = {
			division_template = "Cav16B"
		}
	}
	if = {
		limit = {
			has_global_flag = dst_cavalry_enabled
			has_global_flag = dst_20_battalions
		}
		delete_unit_template_and_units = {
			division_template = "Cav20B"
		}
	}
	if = {
		limit = {
			has_global_flag = dst_motorized_enabled
			has_global_flag = dst_1_battalion
		}
		delete_unit_template_and_units = {
			division_template = "Mot1B"
		}
	}
	if = {
		limit = {
			has_global_flag = dst_motorized_enabled
			has_global_flag = dst_2_battalions
		}
		delete_unit_template_and_units = {
			division_template = "Mot2B"
		}
	}
	if = {
		limit = {
			has_global_flag = dst_motorized_enabled
			has_global_flag = dst_4_battalions
		}
		delete_unit_template_and_units = {
			division_template = "Mot4B"
		}
	}
	if = {
		limit = {
			has_global_flag = dst_motorized_enabled
			has_global_flag = dst_6_battalions
		}
		delete_unit_template_and_units = {
			division_template = "Mot5B"
		}
	}
	if = {
		limit = {
			has_global_flag = dst_motorized_enabled
			has_global_flag = dst_8_battalions
		}
		delete_unit_template_and_units = {
			division_template = "Mot8B"
		}
	}
	if = {
		limit = {
			has_global_flag = dst_motorized_enabled
			has_global_flag = dst_10_battalions
		}
		delete_unit_template_and_units = {
			division_template = "Mot10B"
		}
	}
	if = {
		limit = {
			has_global_flag = dst_motorized_enabled
			has_global_flag = dst_16_battalions
		}
		delete_unit_template_and_units = {
			division_template = "Mot16B"
		}
	}
	if = {
		limit = {
			has_global_flag = dst_motorized_enabled
			has_global_flag = dst_20_battalions
		}
		delete_unit_template_and_units = {
			division_template = "Mot20B"
		}
	}
	if = {
		limit = {
			has_global_flag = dst_armor_enabled
			has_global_flag = dst_1_battalion
		}
		delete_unit_template_and_units = {
			division_template = "Arm1B"
		}
	}
	if = {
		limit = {
			has_global_flag = dst_armor_enabled
			has_global_flag = dst_2_battalions
		}
		delete_unit_template_and_units = {
			division_template = "Arm2B"
		}
	}
	if = {
		limit = {
			has_global_flag = dst_armor_enabled
			has_global_flag = dst_4_battalions
		}
		delete_unit_template_and_units = {
			division_template = "Arm4B"
		}
	}
	if = {
		limit = {
			has_global_flag = dst_armor_enabled
			has_global_flag = dst_6_battalions
		}
		delete_unit_template_and_units = {
			division_template = "Arm5B"
		}
	}
	if = {
		limit = {
			has_global_flag = dst_armor_enabled
			has_global_flag = dst_8_battalions
		}
		delete_unit_template_and_units = {
			division_template = "Arm8B"
		}
	}
	if = {
		limit = {
			has_global_flag = dst_armor_enabled
			has_global_flag = dst_10_battalions
		}
		delete_unit_template_and_units = {
			division_template = "Arm10B"
		}
	}
	if = {
		limit = {
			has_global_flag = dst_armor_enabled
			has_global_flag = dst_16_battalions
		}
		delete_unit_template_and_units = {
			division_template = "Arm16B"
		}
	}
	if = {
		limit = {
			has_global_flag = dst_armor_enabled
			has_global_flag = dst_20_battalions
		}
		delete_unit_template_and_units = {
			division_template = "Arm20B"
		}
	}
	if = {
		limit = {
			has_global_flag = dst_mech_enabled
			has_global_flag = dst_1_battalion
		}
		delete_unit_template_and_units = {
			division_template = "Mech1B"
		}
	}
	if = {
		limit = {
			has_global_flag = dst_mech_enabled
			has_global_flag = dst_2_battalions
		}
		delete_unit_template_and_units = {
			division_template = "Mech2B"
		}
	}
	if = {
		limit = {
			has_global_flag = dst_mech_enabled
			has_global_flag = dst_4_battalions
		}
		delete_unit_template_and_units = {
			division_template = "Mech4B"
		}
	}
	if = {
		limit = {
			has_global_flag = dst_mech_enabled
			has_global_flag = dst_6_battalions
		}
		delete_unit_template_and_units = {
			division_template = "Mech5B"
		}
	}
	if = {
		limit = {
			has_global_flag = dst_mech_enabled
			has_global_flag = dst_8_battalions
		}
		delete_unit_template_and_units = {
			division_template = "Mech8B"
		}
	}
	if = {
		limit = {
			has_global_flag = dst_mech_enabled
			has_global_flag = dst_10_battalions
		}
		delete_unit_template_and_units = {
			division_template = "Mech10B"
		}
	}
	if = {
		limit = {
			has_global_flag = dst_mech_enabled
			has_global_flag = dst_16_battalions
		}
		delete_unit_template_and_units = {
			division_template = "Mech16B"
		}
	}
	if = {
		limit = {
			has_global_flag = dst_mech_enabled
			has_global_flag = dst_20_battalions
		}
		delete_unit_template_and_units = {
			division_template = "Mech20B"
		}
	}
}

dst_b_delete_units = {
	if = {
		limit = {
			has_country_flag = dst_template_1_enabled
		}
		delete_unit_template_and_units = {
			division_template = "Crack Unit"
		}
	}
	if = {
		limit = {
			has_country_flag = dst_template_2_enabled
		}
		delete_unit_template_and_units = {
			division_template = "Crack Unit Type 2"
		}
	}
	if = {
		limit = {
			has_country_flag = dst_template_3_enabled
		}
		delete_unit_template_and_units = {
			division_template = "Crack Unit Type 3"
		}
	}
}
















dst_spawn_unit = {
	if = {
		limit = {
			has_global_flag = dst_infantry_enabled
			has_global_flag = dst_1_battalion
		}
		if = {
			limit = {
				NOT = { has_template = "Inf1B" }
			}
			division_template = {
				name = "Inf1B"
				division_names_group = TP_TYPE_01
				regiments = {
					L_Inf_Bat = { x = 0 y = 0 }
				}
			}
		}
		transfer_state = var:FROM.dst_state_var
		var:FROM.dst_state_var = {
			create_unit = { 
				division = "name = \"Inf1B\" division_template = \"Inf1B\" start_experience_factor = 5.0" 
				owner = PREV
			}
			var:dst_state_original_owner = {
				transfer_state = var:FROM.dst_state_var
			}
		}
	}
	if = {
		limit = {
			has_global_flag = dst_infantry_enabled
			has_global_flag = dst_2_battalions
		}
		if = {
			limit = {
				NOT = { has_template = "Inf2B" }
			}
			division_template = {
				name = "Inf2B"
				division_names_group = TP_TYPE_01
				regiments = {
					L_Inf_Bat = { x = 0 y = 0 }
					L_Inf_Bat = { x = 0 y = 1 }
				}
			}
		}
		transfer_state = var:FROM.dst_state_var
		var:FROM.dst_state_var = {
			create_unit = { 
				division = "name = \"Inf2B\" division_template = \"Inf2B\" start_experience_factor = 5.0" 
				owner = PREV
			}
			var:dst_state_original_owner = {
				transfer_state = var:FROM.dst_state_var
			}
		}
	}
	if = {
		limit = {
			has_global_flag = dst_infantry_enabled
			has_global_flag = dst_4_battalions
		}
		if = {
			limit = {
				NOT = { has_template = "Inf4B" }
			}
			division_template = {
				name = "Inf4B"
				division_names_group = TP_TYPE_01
				regiments = {
					L_Inf_Bat = { x = 0 y = 0 }
					L_Inf_Bat = { x = 0 y = 1 }
					L_Inf_Bat = { x = 0 y = 2 }
					L_Inf_Bat = { x = 0 y = 3 }
				}
			}
		}
		transfer_state = var:FROM.dst_state_var
		var:FROM.dst_state_var = {
			create_unit = { 
				division = "name = \"Inf4B\" division_template = \"Inf4B\" start_experience_factor = 5.0" 
				owner = PREV
			}
			var:dst_state_original_owner = {
				transfer_state = var:FROM.dst_state_var
			}
		}
	}
	if = {
		limit = {
			has_global_flag = dst_infantry_enabled
			has_global_flag = dst_6_battalions
		}
		if = {
			limit = {
				NOT = { has_template = "Inf5B" }
			}
			division_template = {
				name = "Inf5B"
				division_names_group = TP_TYPE_01
				regiments = {
					L_Inf_Bat = { x = 0 y = 0 }
					L_Inf_Bat = { x = 0 y = 1 }
					L_Inf_Bat = { x = 0 y = 2 }
	
					L_Inf_Bat = { x = 1 y = 0 }
					L_Inf_Bat = { x = 1 y = 1 }
				}
			}
		}
		transfer_state = var:FROM.dst_state_var
		var:FROM.dst_state_var = {
			create_unit = { 
				division = "name = \"Inf5B\" division_template = \"Inf5B\" start_experience_factor = 5.0" 
				owner = PREV
			}
			var:dst_state_original_owner = {
				transfer_state = var:FROM.dst_state_var
			}
		}
	}
	if = {
		limit = {
			has_global_flag = dst_infantry_enabled
			has_global_flag = dst_8_battalions
		}
		if = {
			limit = {
				NOT = { has_template = "Inf8B" }
			}
			division_template = {
				name = "Inf8B"
				division_names_group = TP_TYPE_01
				regiments = {
					L_Inf_Bat = { x = 0 y = 0 }
					L_Inf_Bat = { x = 0 y = 1 }
					L_Inf_Bat = { x = 0 y = 2 }
					L_Inf_Bat = { x = 0 y = 3 }

					L_Inf_Bat = { x = 1 y = 0 }
					L_Inf_Bat = { x = 1 y = 1 }
					L_Inf_Bat = { x = 1 y = 2 }
					L_Inf_Bat = { x = 1 y = 3 }
				}
			}
		}
		transfer_state = var:FROM.dst_state_var
		var:FROM.dst_state_var = {
			create_unit = { 
				division = "name = \"Inf8B\" division_template = \"Inf8B\" start_experience_factor = 5.0" 
				owner = PREV
			}
			var:dst_state_original_owner = {
				transfer_state = var:FROM.dst_state_var
			}
		}
	}
	if = {
		limit = {
			has_global_flag = dst_infantry_enabled
			has_global_flag = dst_10_battalions
		}
		if = {
			limit = {
				NOT = { has_template = "Inf10B" }
			}
			division_template = {
				name = "Inf10B"
				division_names_group = TP_TYPE_01
				regiments = {
					L_Inf_Bat = { x = 0 y = 0 }
					L_Inf_Bat = { x = 0 y = 1 }
					L_Inf_Bat = { x = 0 y = 2 }
					L_Inf_Bat = { x = 0 y = 3 }
					L_Inf_Bat = { x = 0 y = 4 }
	
					L_Inf_Bat = { x = 1 y = 0 }
					L_Inf_Bat = { x = 1 y = 1 }
					L_Inf_Bat = { x = 1 y = 2 }
					L_Inf_Bat = { x = 1 y = 3 }
					L_Inf_Bat = { x = 1 y = 4 }
				}
			}
		}
		transfer_state = var:FROM.dst_state_var
		var:FROM.dst_state_var = {
			create_unit = { 
				division = "name = \"Inf10B\" division_template = \"Inf10B\" start_experience_factor = 5.0" 
				owner = PREV
			}
			var:dst_state_original_owner = {
				transfer_state = var:FROM.dst_state_var
			}
		}
	}
	if = {
		limit = {
			has_global_flag = dst_infantry_enabled
			has_global_flag = dst_16_battalions
		}
		if = {
			limit = {
				NOT = { has_template = "Inf16B" }
			}
			division_template = {
				name = "Inf16B"
				division_names_group = TP_TYPE_01
				regiments = {
					L_Inf_Bat = { x = 0 y = 0 }
					L_Inf_Bat = { x = 0 y = 1 }
					L_Inf_Bat = { x = 0 y = 2 }
					L_Inf_Bat = { x = 0 y = 3 }
	
					L_Inf_Bat = { x = 1 y = 0 }
					L_Inf_Bat = { x = 1 y = 1 }
					L_Inf_Bat = { x = 1 y = 2 }
					L_Inf_Bat = { x = 1 y = 3 }
			
					L_Inf_Bat = { x = 2 y = 0 }
					L_Inf_Bat = { x = 2 y = 1 }
					L_Inf_Bat = { x = 2 y = 2 }
					L_Inf_Bat = { x = 2 y = 3 }
						
					L_Inf_Bat = { x = 3 y = 0 }
					L_Inf_Bat = { x = 3 y = 1 }
					L_Inf_Bat = { x = 3 y = 2 }
					L_Inf_Bat = { x = 3 y = 3 }
				}
			}
		}
		transfer_state = var:FROM.dst_state_var
		var:FROM.dst_state_var = {
			create_unit = { 
				division = "name = \"Inf16B\" division_template = \"Inf16B\" start_experience_factor = 5.0" 
				owner = PREV
			}
			var:dst_state_original_owner = {
				transfer_state = var:FROM.dst_state_var
			}
		}
	}
	if = {
		limit = {
			has_global_flag = dst_infantry_enabled
			has_global_flag = dst_20_battalions
		}
		if = {
			limit = {
				NOT = { has_template = "Inf20B" }
			}
			division_template = {
				name = "Inf20B"
				division_names_group = TP_TYPE_01
				regiments = {
					L_Inf_Bat = { x = 0 y = 0 }
					L_Inf_Bat = { x = 0 y = 1 }
					L_Inf_Bat = { x = 0 y = 2 }
					L_Inf_Bat = { x = 0 y = 3 }
					L_Inf_Bat = { x = 0 y = 4 }
	
					L_Inf_Bat = { x = 1 y = 0 }
					L_Inf_Bat = { x = 1 y = 1 }
					L_Inf_Bat = { x = 1 y = 2 }
					L_Inf_Bat = { x = 1 y = 3 }
					L_Inf_Bat = { x = 1 y = 4 }
			
					L_Inf_Bat = { x = 2 y = 0 }
					L_Inf_Bat = { x = 2 y = 1 }
					L_Inf_Bat = { x = 2 y = 2 }
					L_Inf_Bat = { x = 2 y = 3 }
					L_Inf_Bat = { x = 2 y = 4 }
						
					L_Inf_Bat = { x = 3 y = 0 }
					L_Inf_Bat = { x = 3 y = 1 }
					L_Inf_Bat = { x = 3 y = 2 }
					L_Inf_Bat = { x = 3 y = 3 }
					L_Inf_Bat = { x = 3 y = 4 }
				}
			}
		}
		transfer_state = var:FROM.dst_state_var
		var:FROM.dst_state_var = {
			create_unit = { 
				division = "name = \"Inf20B\" division_template = \"Inf20B\" start_experience_factor = 5.0" 
				owner = PREV
			}
			var:dst_state_original_owner = {
				transfer_state = var:FROM.dst_state_var
			}
		}
	}
	if = {
		limit = {
			has_global_flag = dst_cavalry_enabled
			has_global_flag = dst_1_battalion
		}
		if = {
			limit = {
				NOT = { has_template = "Cav1B" }
			}
			division_template = {
				name = "Cav1B"
				division_names_group = TP_TYPE_01
				regiments = {
					Arm_Inf_Bat = { x = 0 y = 0 }
				}
			}
		}
		transfer_state = var:FROM.dst_state_var
		var:FROM.dst_state_var = {
			create_unit = { 
				division = "name = \"Cav1B\" division_template = \"Cav1B\" start_experience_factor = 5.0"  
				owner = PREV
			}
			var:dst_state_original_owner = {
				transfer_state = var:FROM.dst_state_var
			}
		}
	}
				
	if = {
		limit = {
			has_global_flag = dst_cavalry_enabled
			has_global_flag = dst_2_battalions
		}
		if = {
			limit = {
				NOT = { has_template = "Cav2B" }
			}
			division_template = {
				name = "Cav2B"
				division_names_group = TP_TYPE_01
				regiments = {
					Arm_Inf_Bat = { x = 0 y = 0 }
					Arm_Inf_Bat = { x = 0 y = 1 }
				}
			}
		}
		transfer_state = var:FROM.dst_state_var
		var:FROM.dst_state_var = {
			create_unit = { 
				division = "name = \"Cav2B\" division_template = \"Cav2B\" start_experience_factor = 5.0"  
				owner = PREV
			}
			var:dst_state_original_owner = {
				transfer_state = var:FROM.dst_state_var
			}
		}
	}
	if = {
		limit = {
			has_global_flag = dst_cavalry_enabled
			has_global_flag = dst_4_battalions
		}
		if = {
			limit = {
				NOT = { has_template = "Cav4B" }
			}
			division_template = {
				name = "Cav4B"
				division_names_group = TP_TYPE_01
				regiments = {
					Arm_Inf_Bat = { x = 0 y = 0 }
					Arm_Inf_Bat = { x = 0 y = 1 }
					Arm_Inf_Bat = { x = 0 y = 2 }
					Arm_Inf_Bat = { x = 0 y = 3 }
				}
			}
		}
		transfer_state = var:FROM.dst_state_var
		var:FROM.dst_state_var = {
			create_unit = { 
				division = "name = \"Cav4B\" division_template = \"Cav4B\" start_experience_factor = 5.0"  
				owner = PREV
			}
			var:dst_state_original_owner = {
				transfer_state = var:FROM.dst_state_var
			}
		}
	}
	if = {
		limit = {
			has_global_flag = dst_cavalry_enabled
			has_global_flag = dst_6_battalions
		}
		if = {
			limit = {
				NOT = { has_template = "Cav5B" }
			}
			division_template = {
				name = "Cav5B"
				division_names_group = TP_TYPE_01
				regiments = {
					Arm_Inf_Bat = { x = 0 y = 0 }
					Arm_Inf_Bat = { x = 0 y = 1 }
					Arm_Inf_Bat = { x = 0 y = 2 }
	
					Arm_Inf_Bat = { x = 1 y = 0 }
					Arm_Inf_Bat = { x = 1 y = 1 }
				}
			}
		}
		transfer_state = var:FROM.dst_state_var
		var:FROM.dst_state_var = {
			create_unit = { 
				division = "name = \"Cav5B\" division_template = \"Cav5B\" start_experience_factor = 5.0"  
				owner = PREV
			}
			var:dst_state_original_owner = {
				transfer_state = var:FROM.dst_state_var
			}
		}
	}
	if = {
		limit = {
			has_global_flag = dst_cavalry_enabled
			has_global_flag = dst_8_battalions
		}
		if = {
			limit = {
				NOT = { has_template = "Cav8B" }
			}
			division_template = {
				name = "Cav8B"
				division_names_group = TP_TYPE_01
				regiments = {
					Arm_Inf_Bat = { x = 0 y = 0 }
					Arm_Inf_Bat = { x = 0 y = 1 }
					Arm_Inf_Bat = { x = 0 y = 2 }
					Arm_Inf_Bat = { x = 0 y = 3 }

					Arm_Inf_Bat = { x = 1 y = 0 }
					Arm_Inf_Bat = { x = 1 y = 1 }
					Arm_Inf_Bat = { x = 1 y = 2 }
					Arm_Inf_Bat = { x = 1 y = 3 }
				}
			}
		}
		transfer_state = var:FROM.dst_state_var
		var:FROM.dst_state_var = {
			create_unit = { 
				division = "name = \"Cav8B\" division_template = \"Cav8B\" start_experience_factor = 5.0"  
				owner = PREV
			}
			var:dst_state_original_owner = {
				transfer_state = var:FROM.dst_state_var
			}
		}
	}
	if = {
		limit = {
			has_global_flag = dst_cavalry_enabled
			has_global_flag = dst_10_battalions
		}
		if = {
			limit = {
				NOT = { has_template = "Cav10B" }
			}
			division_template = {
				name = "Cav10B"
				division_names_group = TP_TYPE_01
				regiments = {
					Arm_Inf_Bat = { x = 0 y = 0 }
					Arm_Inf_Bat = { x = 0 y = 1 }
					Arm_Inf_Bat = { x = 0 y = 2 }
					Arm_Inf_Bat = { x = 0 y = 3 }
					Arm_Inf_Bat = { x = 0 y = 4 }
	
					Arm_Inf_Bat = { x = 1 y = 0 }
					Arm_Inf_Bat = { x = 1 y = 1 }
					Arm_Inf_Bat = { x = 1 y = 2 }
					Arm_Inf_Bat = { x = 1 y = 3 }
					Arm_Inf_Bat = { x = 1 y = 4 }
				}
			}
		}
		transfer_state = var:FROM.dst_state_var
		var:FROM.dst_state_var = {
			create_unit = { 
				division = "name = \"Cav10B\" division_template = \"Cav10B\" start_experience_factor = 5.0"  
				owner = PREV
			}
			var:dst_state_original_owner = {
				transfer_state = var:FROM.dst_state_var
			}
		}
	}
	if = {
		limit = {
			has_global_flag = dst_cavalry_enabled
			has_global_flag = dst_16_battalions
		}
		if = {
			limit = {
				NOT = { has_template = "Cav16B" }
			}
			division_template = {
				name = "Cav16B"
				division_names_group = TP_TYPE_01
				regiments = {
					Arm_Inf_Bat = { x = 0 y = 0 }
					Arm_Inf_Bat = { x = 0 y = 1 }
					Arm_Inf_Bat = { x = 0 y = 2 }
					Arm_Inf_Bat = { x = 0 y = 3 }
	
					Arm_Inf_Bat = { x = 1 y = 0 }
					Arm_Inf_Bat = { x = 1 y = 1 }
					Arm_Inf_Bat = { x = 1 y = 2 }
					Arm_Inf_Bat = { x = 1 y = 3 }
			
					Arm_Inf_Bat = { x = 2 y = 0 }
					Arm_Inf_Bat = { x = 2 y = 1 }
					Arm_Inf_Bat = { x = 2 y = 2 }
					Arm_Inf_Bat = { x = 2 y = 3 }
						
					Arm_Inf_Bat = { x = 3 y = 0 }
					Arm_Inf_Bat = { x = 3 y = 1 }
					Arm_Inf_Bat = { x = 3 y = 2 }
					Arm_Inf_Bat = { x = 3 y = 3 }
				}
			}
		}
		transfer_state = var:FROM.dst_state_var
		var:FROM.dst_state_var = {
			create_unit = { 
				division = "name = \"Cav16B\" division_template = \"Cav16B\" start_experience_factor = 5.0"  
				owner = PREV
			}
			var:dst_state_original_owner = {
				transfer_state = var:FROM.dst_state_var
			}
		}
	}
	if = {
		limit = {
			has_global_flag = dst_cavalry_enabled
			has_global_flag = dst_20_battalions
		}
		if = {
			limit = {
				NOT = { has_template = "Cav20B" }
			}
			division_template = {
				name = "Cav20B"
				division_names_group = TP_TYPE_01
				regiments = {
					Arm_Inf_Bat = { x = 0 y = 0 }
					Arm_Inf_Bat = { x = 0 y = 1 }
					Arm_Inf_Bat = { x = 0 y = 2 }
					Arm_Inf_Bat = { x = 0 y = 3 }
					Arm_Inf_Bat = { x = 0 y = 4 }
	
					Arm_Inf_Bat = { x = 1 y = 0 }
					Arm_Inf_Bat = { x = 1 y = 1 }
					Arm_Inf_Bat = { x = 1 y = 2 }
					Arm_Inf_Bat = { x = 1 y = 3 }
					Arm_Inf_Bat = { x = 1 y = 4 }
			
					Arm_Inf_Bat = { x = 2 y = 0 }
					Arm_Inf_Bat = { x = 2 y = 1 }
					Arm_Inf_Bat = { x = 2 y = 2 }
					Arm_Inf_Bat = { x = 2 y = 3 }
					Arm_Inf_Bat = { x = 2 y = 4 }
						
					Arm_Inf_Bat = { x = 3 y = 0 }
					Arm_Inf_Bat = { x = 3 y = 1 }
					Arm_Inf_Bat = { x = 3 y = 2 }
					Arm_Inf_Bat = { x = 3 y = 3 }
					Arm_Inf_Bat = { x = 3 y = 4 }
				}
			}
		}
		transfer_state = var:FROM.dst_state_var
		var:FROM.dst_state_var = {
			create_unit = { 
				division = "name = \"Cav20B\" division_template = \"Cav20B\" start_experience_factor = 5.0"  
				owner = PREV
			}
			var:dst_state_original_owner = {
				transfer_state = var:FROM.dst_state_var
			}
		}
	}
	if = {
		limit = {
			has_global_flag = dst_motorized_enabled
			has_global_flag = dst_1_battalion
		}
		if = {
			limit = {
				NOT = { has_template = "Mot1B" }
			}
			division_template = {
				name = "Mot1B"
				division_names_group = TP_TYPE_01
				regiments = {
					Mot_Inf_Bat ={ x = 0 y = 0 }
				}
			}
		}
		transfer_state = var:FROM.dst_state_var
		var:FROM.dst_state_var = {
			create_unit = { 
				division = "name = \"Mot1B\" division_template = \"Mot1B\" start_experience_factor = 5.0"  
				owner = PREV
			}
			var:dst_state_original_owner = {
				transfer_state = var:FROM.dst_state_var
			}
		}
	}
	if = {
		limit = {
			has_global_flag = dst_motorized_enabled
			has_global_flag = dst_2_battalions
		}
		if = {
			limit = {
				NOT = { has_template = "Mot2B" }
			}
			division_template = {
				name = "Mot2B"
				division_names_group = TP_TYPE_01
				regiments = {
					Mot_Inf_Bat ={ x = 0 y = 0 }
					Mot_Inf_Bat ={ x = 0 y = 1 }
				}
			}
		}
		transfer_state = var:FROM.dst_state_var
		var:FROM.dst_state_var = {
			create_unit = { 
				division = "name = \"Mot2B\" division_template = \"Mot2B\" start_experience_factor = 5.0"  
				owner = PREV
			}
			var:dst_state_original_owner = {
				transfer_state = var:FROM.dst_state_var
			}
		}
	}
	if = {
		limit = {
			has_global_flag = dst_motorized_enabled
			has_global_flag = dst_4_battalions
		}
		if = {
			limit = {
				NOT = { has_template = "Mot4B" }
			}
			division_template = {
				name = "Mot4B"
				division_names_group = TP_TYPE_01
				regiments = {
					Mot_Inf_Bat ={ x = 0 y = 0 }
					Mot_Inf_Bat ={ x = 0 y = 1 }
					Mot_Inf_Bat ={ x = 0 y = 2 }
					Mot_Inf_Bat ={ x = 0 y = 3 }
				}
			}
		}
		transfer_state = var:FROM.dst_state_var
		var:FROM.dst_state_var = {
			create_unit = { 
				division = "name = \"Mot4B\" division_template = \"Mot4B\" start_experience_factor = 5.0"  
				owner = PREV
			}
			var:dst_state_original_owner = {
				transfer_state = var:FROM.dst_state_var
			}
		}
	}
	if = {
		limit = {
			has_global_flag = dst_motorized_enabled
			has_global_flag = dst_6_battalions
		}
		if = {
			limit = {
				NOT = { has_template = "Mot5B" }
			}
			division_template = {
				name = "Mot5B"
				division_names_group = TP_TYPE_01
				regiments = {
					Mot_Inf_Bat ={ x = 0 y = 0 }
					Mot_Inf_Bat ={ x = 0 y = 1 }
					Mot_Inf_Bat ={ x = 0 y = 2 }
	
					Mot_Inf_Bat ={ x = 1 y = 0 }
					Mot_Inf_Bat ={ x = 1 y = 1 }
				}
			}
		}
		transfer_state = var:FROM.dst_state_var
		var:FROM.dst_state_var = {
			create_unit = { 
				division = "name = \"Mot5B\" division_template = \"Mot5B\" start_experience_factor = 5.0"  
				owner = PREV
			}
			var:dst_state_original_owner = {
				transfer_state = var:FROM.dst_state_var
			}
		}
	}
	if = {
		limit = {
			has_global_flag = dst_motorized_enabled
			has_global_flag = dst_8_battalions
		}
		if = {
			limit = {
				NOT = { has_template = "Mot8B" }
			}
			division_template = {
				name = "Mot8B"
				division_names_group = TP_TYPE_01
				regiments = {
					Mot_Inf_Bat ={ x = 0 y = 0 }
					Mot_Inf_Bat ={ x = 0 y = 1 }
					Mot_Inf_Bat ={ x = 0 y = 2 }
					Mot_Inf_Bat ={ x = 0 y = 3 }

					Mot_Inf_Bat ={ x = 1 y = 0 }
					Mot_Inf_Bat ={ x = 1 y = 1 }
					Mot_Inf_Bat ={ x = 1 y = 2 }
					Mot_Inf_Bat ={ x = 1 y = 3 }
				}
			}
		}
		transfer_state = var:FROM.dst_state_var
		var:FROM.dst_state_var = {
			create_unit = { 
				division = "name = \"Mot8B\" division_template = \"Mot8B\" start_experience_factor = 5.0"  
				owner = PREV
			}
			var:dst_state_original_owner = {
				transfer_state = var:FROM.dst_state_var
			}
		}
	}
	if = {
		limit = {
			has_global_flag = dst_motorized_enabled
			has_global_flag = dst_10_battalions
		}
		if = {
			limit = {
				NOT = { has_template = "Mot10B" }
			}
			division_template = {
				name = "Mot10B"
				division_names_group = TP_TYPE_01
				regiments = {
					Mot_Inf_Bat ={ x = 0 y = 0 }
					Mot_Inf_Bat ={ x = 0 y = 1 }
					Mot_Inf_Bat ={ x = 0 y = 2 }
					Mot_Inf_Bat ={ x = 0 y = 3 }
					Mot_Inf_Bat ={ x = 0 y = 4 }
	
					Mot_Inf_Bat ={ x = 1 y = 0 }
					Mot_Inf_Bat ={ x = 1 y = 1 }
					Mot_Inf_Bat ={ x = 1 y = 2 }
					Mot_Inf_Bat ={ x = 1 y = 3 }
					Mot_Inf_Bat ={ x = 1 y = 4 }
				}
			}
		}
		transfer_state = var:FROM.dst_state_var
		var:FROM.dst_state_var = {
			create_unit = { 
				division = "name = \"Mot10B\" division_template = \"Mot10B\" start_experience_factor = 5.0"  
				owner = PREV
			}
			var:dst_state_original_owner = {
				transfer_state = var:FROM.dst_state_var
			}
		}
	}
	if = {
		limit = {
			has_global_flag = dst_motorized_enabled
			has_global_flag = dst_16_battalions
		}
		if = {
			limit = {
				NOT = { has_template = "Mot16B" }
			}
			division_template = {
				name = "Mot16B"
				division_names_group = TP_TYPE_01
				regiments = {
					Mot_Inf_Bat ={ x = 0 y = 0 }
					Mot_Inf_Bat ={ x = 0 y = 1 }
					Mot_Inf_Bat ={ x = 0 y = 2 }
					Mot_Inf_Bat ={ x = 0 y = 3 }
	
					Mot_Inf_Bat ={ x = 1 y = 0 }
					Mot_Inf_Bat ={ x = 1 y = 1 }
					Mot_Inf_Bat ={ x = 1 y = 2 }
					Mot_Inf_Bat ={ x = 1 y = 3 }
			
					Mot_Inf_Bat ={ x = 2 y = 0 }
					Mot_Inf_Bat ={ x = 2 y = 1 }
					Mot_Inf_Bat ={ x = 2 y = 2 }
					Mot_Inf_Bat ={ x = 2 y = 3 }
						
					Mot_Inf_Bat ={ x = 3 y = 0 }
					Mot_Inf_Bat ={ x = 3 y = 1 }
					Mot_Inf_Bat ={ x = 3 y = 2 }
					Mot_Inf_Bat ={ x = 3 y = 3 }
				}
			}
		}
		transfer_state = var:FROM.dst_state_var
		var:FROM.dst_state_var = {
			create_unit = { 
				division = "name = \"Mot16B\" division_template = \"Mot16B\" start_experience_factor = 5.0"  
				owner = PREV
			}
			var:dst_state_original_owner = {
				transfer_state = var:FROM.dst_state_var
			}
		}
	}
	if = {
		limit = {
			has_global_flag = dst_motorized_enabled
			has_global_flag = dst_20_battalions
		}
		if = {
			limit = {
				NOT = { has_template = "Mot20B" }
			}
			division_template = {
				name = "Mot20B"
				division_names_group = TP_TYPE_01
				regiments = {
					Mot_Inf_Bat ={ x = 0 y = 0 }
					Mot_Inf_Bat ={ x = 0 y = 1 }
					Mot_Inf_Bat ={ x = 0 y = 2 }
					Mot_Inf_Bat ={ x = 0 y = 3 }
					Mot_Inf_Bat ={ x = 0 y = 4 }
	
					Mot_Inf_Bat ={ x = 1 y = 0 }
					Mot_Inf_Bat ={ x = 1 y = 1 }
					Mot_Inf_Bat ={ x = 1 y = 2 }
					Mot_Inf_Bat ={ x = 1 y = 3 }
					Mot_Inf_Bat ={ x = 1 y = 4 }
			
					Mot_Inf_Bat ={ x = 2 y = 0 }
					Mot_Inf_Bat ={ x = 2 y = 1 }
					Mot_Inf_Bat ={ x = 2 y = 2 }
					Mot_Inf_Bat ={ x = 2 y = 3 }
					Mot_Inf_Bat ={ x = 2 y = 4 }
						
					Mot_Inf_Bat ={ x = 3 y = 0 }
					Mot_Inf_Bat ={ x = 3 y = 1 }
					Mot_Inf_Bat ={ x = 3 y = 2 }
					Mot_Inf_Bat ={ x = 3 y = 3 }
					Mot_Inf_Bat ={ x = 3 y = 4 }
				}
			}
		}
		transfer_state = var:FROM.dst_state_var
		var:FROM.dst_state_var = {
			create_unit = { 
				division = "name = \"Mot20B\" division_template = \"Mot20B\" start_experience_factor = 5.0"  
				owner = PREV
			}
			var:dst_state_original_owner = {
				transfer_state = var:FROM.dst_state_var
			}
		}
	}
	if = {
		limit = {
			has_global_flag = dst_armor_enabled
			has_global_flag = dst_1_battalion
		}
		if = {
			limit = {
				NOT = { has_template = "Arm1B" }
			}
			division_template = {
				name = "Arm1B"
				division_names_group = TP_TYPE_01
				regiments = {
					armor_Bat = { x = 0 y = 0 }
				}
			}
		}
		transfer_state = var:FROM.dst_state_var
		var:FROM.dst_state_var = {
			create_unit = { 
				division = "name = \"Arm1B\" division_template = \"Arm1B\" start_experience_factor = 5.0"  
				owner = PREV
			}
			var:dst_state_original_owner = {
				transfer_state = var:FROM.dst_state_var
			}
		}
	}
	if = {
		limit = {
			has_global_flag = dst_armor_enabled
			has_global_flag = dst_2_battalions
		}
		if = {
			limit = {
				NOT = { has_template = "Arm2B" }
			}
			division_template = {
				name = "Arm2B"
				division_names_group = TP_TYPE_01
				regiments = {
					armor_Bat = { x = 0 y = 0 }
					armor_Bat = { x = 0 y = 1 }
				}
			}
		}
		transfer_state = var:FROM.dst_state_var
		var:FROM.dst_state_var = {
			create_unit = { 
				division = "name = \"Arm2B\" division_template = \"Arm2B\" start_experience_factor = 5.0"  
				owner = PREV
			}
			var:dst_state_original_owner = {
				transfer_state = var:FROM.dst_state_var
			}
		}
	}
	if = {
		limit = {
			has_global_flag = dst_armor_enabled
			has_global_flag = dst_4_battalions
		}
		if = {
			limit = {
				NOT = { has_template = "Arm4B" }
			}
			division_template = {
				name = "Arm4B"
				division_names_group = TP_TYPE_01
				regiments = {
					armor_Bat = { x = 0 y = 0 }
					armor_Bat = { x = 0 y = 1 }
					armor_Bat = { x = 0 y = 2 }
					armor_Bat = { x = 0 y = 3 }
				}
			}
		}
		transfer_state = var:FROM.dst_state_var
		var:FROM.dst_state_var = {
			create_unit = { 
				division = "name = \"Arm4B\" division_template = \"Arm4B\" start_experience_factor = 5.0"  
				owner = PREV
			}
			var:dst_state_original_owner = {
				transfer_state = var:FROM.dst_state_var
			}
		}
	}
	if = {
		limit = {
			has_global_flag = dst_armor_enabled
			has_global_flag = dst_6_battalions
		}
		if = {
			limit = {
				NOT = { has_template = "Arm5B" }
			}
			division_template = {
				name = "Arm5B"
				division_names_group = TP_TYPE_01
				regiments = {
					armor_Bat = { x = 0 y = 0 }
					armor_Bat = { x = 0 y = 1 }
					armor_Bat = { x = 0 y = 2 }
	
					armor_Bat = { x = 1 y = 0 }
					armor_Bat = { x = 1 y = 1 }
				}
			}
		}
		transfer_state = var:FROM.dst_state_var
		var:FROM.dst_state_var = {
			create_unit = { 
				division = "name = \"Arm5B\" division_template = \"Arm5B\" start_experience_factor = 5.0"  
				owner = PREV
			}
			var:dst_state_original_owner = {
				transfer_state = var:FROM.dst_state_var
			}
		}
	}
	if = {
		limit = {
			has_global_flag = dst_armor_enabled
			has_global_flag = dst_8_battalions
		}
		if = {
			limit = {
				NOT = { has_template = "Arm8B" }
			}
			division_template = {
				name = "Arm8B"
				division_names_group = TP_TYPE_01
				regiments = {
					armor_Bat = { x = 0 y = 0 }
					armor_Bat = { x = 0 y = 1 }
					armor_Bat = { x = 0 y = 2 }
					armor_Bat = { x = 0 y = 3 }

					armor_Bat = { x = 1 y = 0 }
					armor_Bat = { x = 1 y = 1 }
					armor_Bat = { x = 1 y = 2 }
					armor_Bat = { x = 1 y = 3 }
				}
			}
		}
		transfer_state = var:FROM.dst_state_var
		var:FROM.dst_state_var = {
			create_unit = { 
				division = "name = \"Arm8B\" division_template = \"Arm8B\" start_experience_factor = 5.0"  
				owner = PREV
			}
			var:dst_state_original_owner = {
				transfer_state = var:FROM.dst_state_var
			}
		}
	}
	if = {
		limit = {
			has_global_flag = dst_armor_enabled
			has_global_flag = dst_10_battalions
		}
		if = {
			limit = {
				NOT = { has_template = "Arm10B" }
			}
			division_template = {
				name = "Arm10B"
				division_names_group = TP_TYPE_01
				regiments = {
					armor_Bat = { x = 0 y = 0 }
					armor_Bat = { x = 0 y = 1 }
					armor_Bat = { x = 0 y = 2 }
					armor_Bat = { x = 0 y = 3 }
					armor_Bat = { x = 0 y = 4 }
	
					armor_Bat = { x = 1 y = 0 }
					armor_Bat = { x = 1 y = 1 }
					armor_Bat = { x = 1 y = 2 }
					armor_Bat = { x = 1 y = 3 }
					armor_Bat = { x = 1 y = 4 }
				}
			}
		}
		transfer_state = var:FROM.dst_state_var
		var:FROM.dst_state_var = {
			create_unit = { 
				division = "name = \"Arm10B\" division_template = \"Arm10B\" start_experience_factor = 5.0"  
				owner = PREV
			}
			var:dst_state_original_owner = {
				transfer_state = var:FROM.dst_state_var
			}
		}
	}
	if = {
		limit = {
			has_global_flag = dst_armor_enabled
			has_global_flag = dst_16_battalions
		}
		if = {
			limit = {
				NOT = { has_template = "Arm16B" }
			}
			division_template = {
				name = "Arm16B"
				division_names_group = TP_TYPE_01
				regiments = {
					armor_Bat = { x = 0 y = 0 }
					armor_Bat = { x = 0 y = 1 }
					armor_Bat = { x = 0 y = 2 }
					armor_Bat = { x = 0 y = 3 }
	
					armor_Bat = { x = 1 y = 0 }
					armor_Bat = { x = 1 y = 1 }
					armor_Bat = { x = 1 y = 2 }
					armor_Bat = { x = 1 y = 3 }
			
					armor_Bat = { x = 2 y = 0 }
					armor_Bat = { x = 2 y = 1 }
					armor_Bat = { x = 2 y = 2 }
					armor_Bat = { x = 2 y = 3 }
						
					armor_Bat = { x = 3 y = 0 }
					armor_Bat = { x = 3 y = 1 }
					armor_Bat = { x = 3 y = 2 }
					armor_Bat = { x = 3 y = 3 }
				}
			}
		}
		transfer_state = var:FROM.dst_state_var
		var:FROM.dst_state_var = {
			create_unit = { 
				division = "name = \"Arm16B\" division_template = \"Arm16B\" start_experience_factor = 5.0"  
				owner = PREV
			}
			var:dst_state_original_owner = {
				transfer_state = var:FROM.dst_state_var
			}
		}
	}
	if = {
		limit = {
			has_global_flag = dst_armor_enabled
			has_global_flag = dst_20_battalions
		}
		if = {
			limit = {
				NOT = { has_template = "Arm20B" }
			}
			division_template = {
				name = "Arm20B"
				division_names_group = TP_TYPE_01
				regiments = {
					armor_Bat = { x = 0 y = 0 }
					armor_Bat = { x = 0 y = 1 }
					armor_Bat = { x = 0 y = 2 }
					armor_Bat = { x = 0 y = 3 }
					armor_Bat = { x = 0 y = 4 }
	
					armor_Bat = { x = 1 y = 0 }
					armor_Bat = { x = 1 y = 1 }
					armor_Bat = { x = 1 y = 2 }
					armor_Bat = { x = 1 y = 3 }
					armor_Bat = { x = 1 y = 4 }
			
					armor_Bat = { x = 2 y = 0 }
					armor_Bat = { x = 2 y = 1 }
					armor_Bat = { x = 2 y = 2 }
					armor_Bat = { x = 2 y = 3 }
					armor_Bat = { x = 2 y = 4 }
						
					armor_Bat = { x = 3 y = 0 }
					armor_Bat = { x = 3 y = 1 }
					armor_Bat = { x = 3 y = 2 }
					armor_Bat = { x = 3 y = 3 }
					armor_Bat = { x = 3 y = 4 }
				}
			}
		}
		transfer_state = var:FROM.dst_state_var
		var:FROM.dst_state_var = {
			create_unit = { 
				division = "name = \"Arm20B\" division_template = \"Arm20B\" start_experience_factor = 5.0"  
				owner = PREV
			}
			var:dst_state_original_owner = {
				transfer_state = var:FROM.dst_state_var
			}
		}
	}
	if = {
		limit = {
			has_global_flag = dst_mech_enabled
			has_global_flag = dst_1_battalion
		}
		if = {
			limit = {
				NOT = { has_template = "Mech1B" }
			}
			division_template = {
				name = "Mech1B"
				division_names_group = TP_TYPE_01
				regiments = {
					Mech_Inf_Bat = { x = 0 y = 0 }
				}
			}
		}
		transfer_state = var:FROM.dst_state_var
		var:FROM.dst_state_var = {
			create_unit = { 
				division = "name = \"Mech1B\" division_template = \"Mech1B\" start_experience_factor = 5.0" 
				owner = PREV
			}
			var:dst_state_original_owner = {
				transfer_state = var:FROM.dst_state_var
			}
		}
	}
	if = {
		limit = {
			has_global_flag = dst_mech_enabled
			has_global_flag = dst_2_battalions
		}
		if = {
			limit = {
				NOT = { has_template = "Mech2B" }
			}
			division_template = {
				name = "Mech2B"
				division_names_group = TP_TYPE_01
				regiments = {
					Mech_Inf_Bat = { x = 0 y = 0 }
					Mech_Inf_Bat = { x = 0 y = 1 }
				}
			}
		}
		transfer_state = var:FROM.dst_state_var
		var:FROM.dst_state_var = {
			create_unit = { 
				division = "name = \"Mech2B\" division_template = \"Mech2B\" start_experience_factor = 5.0" 
				owner = PREV
			}
			var:dst_state_original_owner = {
				transfer_state = var:FROM.dst_state_var
			}
		}
	}
	if = {
		limit = {
			has_global_flag = dst_mech_enabled
			has_global_flag = dst_4_battalions
		}
		if = {
			limit = {
				NOT = { has_template = "Mech4B" }
			}
			division_template = {
				name = "Mech4B"
				division_names_group = TP_TYPE_01
				regiments = {
					Mech_Inf_Bat = { x = 0 y = 0 }
					Mech_Inf_Bat = { x = 0 y = 1 }
					Mech_Inf_Bat = { x = 0 y = 2 }
					Mech_Inf_Bat = { x = 0 y = 3 }
				}
			}
		}
		transfer_state = var:FROM.dst_state_var
		var:FROM.dst_state_var = {
			create_unit = { 
				division = "name = \"Mech4B\" division_template = \"Mech4B\" start_experience_factor = 5.0" 
				owner = PREV
			}
			var:dst_state_original_owner = {
				transfer_state = var:FROM.dst_state_var
			}
		}
	}
	if = {
		limit = {
			has_global_flag = dst_mech_enabled
			has_global_flag = dst_6_battalions
		}
		if = {
			limit = {
				NOT = { has_template = "Mech5B" }
			}
			division_template = {
				name = "Mech5B"
				division_names_group = TP_TYPE_01
				regiments = {
					Mech_Inf_Bat = { x = 0 y = 0 }
					Mech_Inf_Bat = { x = 0 y = 1 }
					Mech_Inf_Bat = { x = 0 y = 2 }
	
					Mech_Inf_Bat = { x = 1 y = 0 }
					Mech_Inf_Bat = { x = 1 y = 1 }
				}
			}
		}
		transfer_state = var:FROM.dst_state_var
		var:FROM.dst_state_var = {
			create_unit = { 
				division = "name = \"Mech5B\" division_template = \"Mech5B\" start_experience_factor = 5.0" 
				owner = PREV
			}
			var:dst_state_original_owner = {
				transfer_state = var:FROM.dst_state_var
			}
		}
	}
	if = {
		limit = {
			has_global_flag = dst_mech_enabled
			has_global_flag = dst_8_battalions
		}
		if = {
			limit = {
				NOT = { has_template = "Mech8B" }
			}
			division_template = {
				name = "Mech8B"
				division_names_group = TP_TYPE_01
				regiments = {
					Mech_Inf_Bat = { x = 0 y = 0 }
					Mech_Inf_Bat = { x = 0 y = 1 }
					Mech_Inf_Bat = { x = 0 y = 2 }
					Mech_Inf_Bat = { x = 0 y = 3 }

					Mech_Inf_Bat = { x = 1 y = 0 }
					Mech_Inf_Bat = { x = 1 y = 1 }
					Mech_Inf_Bat = { x = 1 y = 2 }
					Mech_Inf_Bat = { x = 1 y = 3 }
				}
			}
		}
		transfer_state = var:FROM.dst_state_var
		var:FROM.dst_state_var = {
			create_unit = { 
				division = "name = \"Mech8B\" division_template = \"Mech8B\" start_experience_factor = 5.0" 
				owner = PREV
			}
			var:dst_state_original_owner = {
				transfer_state = var:FROM.dst_state_var
			}
		}
	}
	if = {
		limit = {
			has_global_flag = dst_mech_enabled
			has_global_flag = dst_10_battalions
		}
		if = {
			limit = {
				NOT = { has_template = "Mech10B" }
			}
			division_template = {
				name = "Mech10B"
				division_names_group = TP_TYPE_01
				regiments = {
					Mech_Inf_Bat = { x = 0 y = 0 }
					Mech_Inf_Bat = { x = 0 y = 1 }
					Mech_Inf_Bat = { x = 0 y = 2 }
					Mech_Inf_Bat = { x = 0 y = 3 }
					Mech_Inf_Bat = { x = 0 y = 4 }
	
					Mech_Inf_Bat = { x = 1 y = 0 }
					Mech_Inf_Bat = { x = 1 y = 1 }
					Mech_Inf_Bat = { x = 1 y = 2 }
					Mech_Inf_Bat = { x = 1 y = 3 }
					Mech_Inf_Bat = { x = 1 y = 4 }
				}
			}
		}
		transfer_state = var:FROM.dst_state_var
		var:FROM.dst_state_var = {
			create_unit = { 
				division = "name = \"Mech10B\" division_template = \"Mech10B\" start_experience_factor = 5.0" 
				owner = PREV
			}
			var:dst_state_original_owner = {
				transfer_state = var:FROM.dst_state_var
			}
		}
	}
	if = {
		limit = {
			has_global_flag = dst_mech_enabled
			has_global_flag = dst_16_battalions
		}
		if = {
			limit = {
				NOT = { has_template = "Mech16B" }
			}
			division_template = {
				name = "Mech16B"
				division_names_group = TP_TYPE_01
				regiments = {
					Mech_Inf_Bat = { x = 0 y = 0 }
					Mech_Inf_Bat = { x = 0 y = 1 }
					Mech_Inf_Bat = { x = 0 y = 2 }
					Mech_Inf_Bat = { x = 0 y = 3 }
	
					Mech_Inf_Bat = { x = 1 y = 0 }
					Mech_Inf_Bat = { x = 1 y = 1 }
					Mech_Inf_Bat = { x = 1 y = 2 }
					Mech_Inf_Bat = { x = 1 y = 3 }
			
					Mech_Inf_Bat = { x = 2 y = 0 }
					Mech_Inf_Bat = { x = 2 y = 1 }
					Mech_Inf_Bat = { x = 2 y = 2 }
					Mech_Inf_Bat = { x = 2 y = 3 }
						
					Mech_Inf_Bat = { x = 3 y = 0 }
					Mech_Inf_Bat = { x = 3 y = 1 }
					Mech_Inf_Bat = { x = 3 y = 2 }
					Mech_Inf_Bat = { x = 3 y = 3 }
				}
			}
		}
		transfer_state = var:FROM.dst_state_var
		var:FROM.dst_state_var = {
			create_unit = { 
				division = "name = \"Mech16B\" division_template = \"Mech16B\" start_experience_factor = 5.0" 
				owner = PREV
			}
			var:dst_state_original_owner = {
				transfer_state = var:FROM.dst_state_var
			}
		}
	}
	if = {
		limit = {
			has_global_flag = dst_mech_enabled
			has_global_flag = dst_20_battalions
		}
		if = {
			limit = {
				NOT = { has_template = "Mech20B" }
			}
			division_template = {
				name = "Mech20B"
				division_names_group = TP_TYPE_01
				regiments = {
					Mech_Inf_Bat = { x = 0 y = 0 }
					Mech_Inf_Bat = { x = 0 y = 1 }
					Mech_Inf_Bat = { x = 0 y = 2 }
					Mech_Inf_Bat = { x = 0 y = 3 }
					Mech_Inf_Bat = { x = 0 y = 4 }
	
					Mech_Inf_Bat = { x = 1 y = 0 }
					Mech_Inf_Bat = { x = 1 y = 1 }
					Mech_Inf_Bat = { x = 1 y = 2 }
					Mech_Inf_Bat = { x = 1 y = 3 }
					Mech_Inf_Bat = { x = 1 y = 4 }
			
					Mech_Inf_Bat = { x = 2 y = 0 }
					Mech_Inf_Bat = { x = 2 y = 1 }
					Mech_Inf_Bat = { x = 2 y = 2 }
					Mech_Inf_Bat = { x = 2 y = 3 }
					Mech_Inf_Bat = { x = 2 y = 4 }
						
					Mech_Inf_Bat = { x = 3 y = 0 }
					Mech_Inf_Bat = { x = 3 y = 1 }
					Mech_Inf_Bat = { x = 3 y = 2 }
					Mech_Inf_Bat = { x = 3 y = 3 }
					Mech_Inf_Bat = { x = 3 y = 4 }
				}
			}
		}
		transfer_state = var:FROM.dst_state_var
		var:FROM.dst_state_var = {
			create_unit = { 
				division = "name = \"Mech20B\" division_template = \"Mech20B\" start_experience_factor = 5.0" 
				owner = PREV
			}
			var:dst_state_original_owner = {
				transfer_state = var:FROM.dst_state_var
			}
		}
	}
}


ret_load_releasable = {
	every_state = {
		clear_variable = country_with_core_of_this_state_1
		clear_variable = country_with_core_of_this_state_2
		clear_variable = country_with_core_of_this_state_3
		clear_variable = country_with_core_of_this_state_4
		clear_variable = country_with_core_of_this_state_5
		clear_variable = country_with_core_of_this_state_6
		clear_variable = country_with_core_of_this_state_7
		clear_variable = country_with_core_of_this_state_8
	}
	every_possible_country = {
		limit = {
			OR = {
				has_global_flag = RET_show_exist_countries	#TODO
				exists = no
			}
		}
		every_state = {
			limit = {
				OR = {
					is_core_of = PREV
					#is_claimed_by = PREV
				}
				NOT = {
					is_owned_by = PREV
				}
			}
			if = {
				limit = {
					NOT = {
						has_variable = country_with_core_of_this_state_1
					}
				}
				set_variable = {
					country_with_core_of_this_state_1 = PREV.id
				}
			}
			else_if = {
				limit = {
					NOT = {
						has_variable = country_with_core_of_this_state_2
					}
				}
				set_variable = {
					country_with_core_of_this_state_2 = PREV.id
				}
			}
			else_if = {
				limit = {
					NOT = {
						has_variable = country_with_core_of_this_state_3
					}
				}
				set_variable = {
					country_with_core_of_this_state_3 = PREV.id
				}
			}
			else_if = {
				limit = {
					NOT = {
						has_variable = country_with_core_of_this_state_4
					}
				}
				set_variable = {
					country_with_core_of_this_state_4 = PREV.id
				}
			}
			else_if = {
				limit = {
					NOT = {
						has_variable = country_with_core_of_this_state_5
					}
				}
				set_variable = {
					country_with_core_of_this_state_5 = PREV.id
				}
			}
			else_if = {
				limit = {
					NOT = {
						has_variable = country_with_core_of_this_state_6
					}
				}
				set_variable = {
					country_with_core_of_this_state_6 = PREV.id
				}
			}
			else_if = {
				limit = {
					NOT = {
						has_variable = country_with_core_of_this_state_7
					}
				}
				set_variable = {
					country_with_core_of_this_state_7 = PREV.id
				}
			}
			else_if = {
				limit = {
					NOT = {
						has_variable = country_with_core_of_this_state_8
					}
				}
				set_variable = {
					country_with_core_of_this_state_8 = PREV.id
				}
			}
		}
	}
}