#	Example:
#
#	example_effect = {
#		add_political_power = 66
#		add_popularity = {
#			ideology = fascism
#			popularity = 0.33
#		}
#	}
#
#
#	In a script file:
#
#	effect = {
#		example_effect = yes
#	}
#

#####################################
### emergency_factory_conversion ####
#####################################

#This is going to give misleading and ugly tooltips. Making it nice will take effort. TODO_WTT_CD make nice or ignore and remove comment. Easiest solution is just making a custom tooltip that says "5 civilian factories will be converted to military factories" and ignore telling the player the states where it will happen.

replace_civ_with_arms_factories = {

	random_owned_controlled_state = {
		limit = {
			is_fully_controlled_by = ROOT
			industrial_complex > 0
		}
		remove_building = {
			type = industrial_complex
			level = 1
		}
		add_building_construction = {
			type = arms_factory
			level = 1
			instant_build = yes
		}
	}

	random_owned_controlled_state = {
		limit = {
			is_fully_controlled_by = ROOT
			industrial_complex > 0
		}
		remove_building = {
			type = industrial_complex
			level = 1
		}
		add_building_construction = {
			type = arms_factory
			level = 1
			instant_build = yes
		}
	}

	random_owned_controlled_state = {
		limit = {
			is_fully_controlled_by = ROOT
			industrial_complex > 0
		}
		remove_building = {
			type = industrial_complex
			level = 1
		}
		add_building_construction = {
			type = arms_factory
			level = 1
			instant_build = yes
		}
	}

	random_owned_controlled_state = {
		limit = {
			is_fully_controlled_by = ROOT
			industrial_complex > 0
		}
		remove_building = {
			type = industrial_complex
			level = 1
		}
		add_building_construction = {
			type = arms_factory
			level = 1
			instant_build = yes
		}
	}

	random_owned_controlled_state = {
		limit = {
			is_fully_controlled_by = ROOT
			industrial_complex > 0
		}
		remove_building = {
			type = industrial_complex
			level = 1
		}
		add_building_construction = {
			type = arms_factory
			level = 1
			instant_build = yes
		}
	}
}

#Country scope
ROOT_inherit_current_scope_wars_effect = {
	custom_effect_tooltip = ROOT_inherit_current_scope_wars_effect
	hidden_effect = {
		every_country = {
			limit = {
				has_defensive_war_with = PREV
			}
			ROOT = { declare_war_on = { target = PREV type = annex_everything } }
		}
		every_country = {
			limit = {
				has_offensive_war_with = PREV
			}
			declare_war_on = { target = ROOT type = annex_everything }
		}
	}
}

# Add AI strategies in case of Central European Alliance
GER_democratic_nations_ai_strategies = {
	# Reduce Contain against SOV
	add_ai_strategy = {
		type = contain
		id = "SOV"
		value = -800
	}
	add_ai_strategy = {
		type = contain
		id = "ITA"
		value = -800
	}
	# Poland
	add_ai_strategy = {
		type = protect
		id = "POL"
		value = -200
	}
	add_ai_strategy = {
		type = ignore
		id = "POL"
		value = 200
	}
	add_ai_strategy = {
		type = befriend
		id = "POL"
		value = -200
	}
	add_ai_strategy = {
		type = alliance
		id = "POL"
		value = -200
	}
	# Finland
	add_ai_strategy = {
		type = protect
		id = "FIN"
		value = -200
	}
	add_ai_strategy = {
		type = ignore
		id = "FIN"
		value = 200
	}
	add_ai_strategy = {
		type = befriend
		id = "FIN"
		value = -200
	}
	add_ai_strategy = {
		type = alliance
		id = "FIN"
		value = -200
	}
	# Estonia
	add_ai_strategy = {
		type = protect
		id = "EST"
		value = -200
	}
	add_ai_strategy = {
		type = ignore
		id = "EST"
		value = 200
	}
	add_ai_strategy = {
		type = befriend
		id = "EST"
		value = -200
	}
	add_ai_strategy = {
		type = alliance
		id = "EST"
		value = -200
	}
	# Latvia
	add_ai_strategy = {
		type = protect
		id = "LAT"
		value = -200
	}
	add_ai_strategy = {
		type = ignore
		id = "LAT"
		value = 200
	}
	add_ai_strategy = {
		type = befriend
		id = "LAT"
		value = -200
	}
	add_ai_strategy = {
		type = alliance
		id = "LAT"
		value = -200
	}
	# Lithuania
	add_ai_strategy = {
		type = protect
		id = "LIT"
		value = -200
	}
	add_ai_strategy = {
		type = ignore
		id = "LIT"
		value = 200
	}
	add_ai_strategy = {
		type = befriend
		id = "LIT"
		value = -200
	}
	add_ai_strategy = {
		type = alliance
		id = "LIT"
		value = -200
	}
	# Romania
	add_ai_strategy = {
		type = protect
		id = "ROM"
		value = -200
	}
	add_ai_strategy = {
		type = ignore
		id = "ROM"
		value = 200
	}
	add_ai_strategy = {
		type = befriend
		id = "ROM"
		value = -200
	}
	add_ai_strategy = {
		type = alliance
		id = "ROM"
		value = -200
	}
	# Norway
	add_ai_strategy = {
		type = ignore
		id = "NOR"
		value = 200
	}
	add_ai_strategy = {
		type = protect
		id = "NOR"
		value = -200
	}
	add_ai_strategy = {
		type = befriend
		id = "NOR"
		value = -200
	}
	add_ai_strategy = {
		type = alliance
		id = "NOR"
		value = -200
	}
	# Sweden
	add_ai_strategy = {
		type = ignore
		id = "SWE"
		value = 200
	}
	add_ai_strategy = {
		type = protect
		id = "SWE"
		value = -200
	}
	add_ai_strategy = {
		type = befriend
		id = "SWE"
		value = -200
	}
	add_ai_strategy = {
		type = alliance
		id = "SWE"
		value = -200
	}
	# Denmark
	add_ai_strategy = {
		type = ignore
		id = "DEN"
		value = 200
	}
	add_ai_strategy = {
		type = protect
		id = "DEN"
		value = -200
	}
	add_ai_strategy = {
		type = befriend
		id = "DEN"
		value = -200
	}
	add_ai_strategy = {
		type = alliance
		id = "DEN"
		value = -200
	}
	# Netherlands
	add_ai_strategy = {
		type = ignore
		id = "HOL"
		value = 200
	}
	add_ai_strategy = {
		type = protect
		id = "HOL"
		value = -200
	}
	add_ai_strategy = {
		type = befriend
		id = "HOL"
		value = -200
	}
	add_ai_strategy = {
		type = alliance
		id = "HOL"
		value = -200
	}
	# Belgium
	add_ai_strategy = {
		type = ignore
		id = "BEL"
		value = 200
	}
	add_ai_strategy = {
		type = protect
		id = "BEL"
		value = -200
	}
	add_ai_strategy = {
		type = befriend
		id = "BEL"
		value = -200
	}
	add_ai_strategy = {
		type = alliance
		id = "BEL"
		value = -200
	}
	# Luxemburg
	add_ai_strategy = {
		type = ignore
		id = "LUX"
		value = 200
	}
	add_ai_strategy = {
		type = protect
		id = "LUX"
		value = -200
	}
	add_ai_strategy = {
		type = befriend
		id = "LUX"
		value = -200
	}
	add_ai_strategy = {
		type = alliance
		id = "LUX"
		value = -200
	}
	# Austria
	add_ai_strategy = {
		type = ignore
		id = "AUS"
		value = 200
	}
	add_ai_strategy = {
		type = protect
		id = "AUS"
		value = -200
	}
	add_ai_strategy = {
		type = befriend
		id = "AUS"
		value = -200
	}
	add_ai_strategy = {
		type = alliance
		id = "AUS"
		value = -200
	}
	# Hungary
	add_ai_strategy = {
		type = ignore
		id = "HUN"
		value = 200
	}
	add_ai_strategy = {
		type = protect
		id = "HUN"
		value = -200
	}
	add_ai_strategy = {
		type = befriend
		id = "HUN"
		value = -200
	}
	add_ai_strategy = {
		type = alliance
		id = "HUN"
		value = -200
	}
	# Czechoslovakia
	add_ai_strategy = {
		type = ignore
		id = "CZE"
		value = 200
	}
	add_ai_strategy = {
		type = protect
		id = "CZE"
		value = -200
	}
	add_ai_strategy = {
		type = befriend
		id = "CZE"
		value = -200
	}
	add_ai_strategy = {
		type = alliance
		id = "CZE"
		value = -200
	}
	# Yugoslavia
	add_ai_strategy = {
		type = ignore
		id = "YUG"
		value = 200
	}
	add_ai_strategy = {
		type = protect
		id = "YUG"
		value = -200
	}
	add_ai_strategy = {
		type = befriend
		id = "YUG"
		value = -200
	}
	add_ai_strategy = {
		type = alliance
		id = "YUG"
		value = -200
	}
}

print_variable_log_effect = {
	print_variables = {
		file = variables_yug
		append = yes
	}
}

get_best_alliance_match_democratic_effect = { #arguably a trigger, but it does stuff so we keep it in here. If this is your first time seeing this, welcome to my personal hell.
	if = {
		limit = {
			any_other_country = {
				is_faction_leader = yes
				is_major = yes
				has_government = democratic
				not = { has_war_with = ROOT }
				set_temp_variable = { ROOT.best_leader = this }
				set_temp_variable = { ROOT.best_leader_score = 0 }
			}
		}
	}
	if = {
		limit = {
			all_other_country = {
				is_faction_leader = yes
				is_major = yes
				has_government = democratic
				not = { has_war_with = ROOT }
				set_temp_variable = { this.leader_score = num_of_factories }
				add_to_temp_variable = { this.leader_score = num_battalions }
				all_of_scopes = {
					array = allies
					add_to_temp_variable = { PREV.leader_score = num_of_factories }
					add_to_temp_variable = { PREV.leader_score = num_battalions }
				}
				if = {
					limit = {
						capital_scope = {
							is_on_continent = ROOT
						}
					}
					multiply_temp_variable = { leader_score = 2 }
				}
				if = {
					limit = {
						any_neighbor_country = { tag = ROOT }
					}
					multiply_temp_variable = { leader_score = 1.25 }
				}
				if = {
					limit = {
						check_variable = { ROOT.best_leader_score < leader_score }
						set_temp_variable = { ROOT.best_leader = this }
						set_temp_variable = { ROOT.best_leader_score = leader_score }
					}
				}
			}
		}
	}
}

get_best_alliance_match_fascism_effect = { #arguably a trigger, but it does stuff so we keep it in here. If this is your first time seeing this, welcome to my personal hell.
	if = {
		limit = {
			any_other_country = {
				is_faction_leader = yes
				is_major = yes
				has_government = fascism
				not = { has_war_with = ROOT }
				set_temp_variable = { ROOT.best_leader = this }
				set_temp_variable = { ROOT.best_leader_score = 0 }
			}
		}
	}
	if = {
		limit = {
			all_other_country = {

				is_faction_leader = yes
				is_major = yes
				has_government = fascism
				not = { has_war_with = ROOT }

				set_temp_variable = { this.leader_score = num_of_factories }
				add_to_temp_variable = { this.leader_score = num_battalions }
				all_of_scopes = {
					array = allies
					add_to_temp_variable = { PREV.leader_score = num_of_factories }
					add_to_temp_variable = { PREV.leader_score = num_battalions }
				}
				if = {
					limit = {
						capital_scope = {
							is_on_continent = ROOT
						}
					}
					multiply_temp_variable = { this.leader_score = 2 }
				}
				if = {
					limit = {
						any_neighbor_country = { tag = ROOT }
					}
					multiply_temp_variable = { this.leader_score = 1.25 }
				}
				if = {
					limit = {
						check_variable = { ROOT.best_leader_score < this.leader_score }
					}
					set_temp_variable = { ROOT.best_leader = this }
					set_temp_variable = { ROOT.best_leader_score = this.leader_score }
				}
			}
		}
	}
}

get_best_alliance_match_communism_effect = { #arguably a trigger, but it does stuff so we keep it in here. If this is your first time seeing this, welcome to my personal hell.
	if = {
		limit = {
			any_other_country = {
				is_faction_leader = yes
				is_major = yes
				has_government = communism
				not = { has_war_with = ROOT }
				set_temp_variable = { ROOT.best_leader = this }
				set_temp_variable = { ROOT.best_leader_score = 0 }
			}
		}
	}
	if = {
		limit = {
			all_other_country = {
				is_faction_leader = yes
				is_major = yes
				has_government = communism
				not = { has_war_with = ROOT }
				set_temp_variable = { this.leader_score = num_of_factories }
				add_to_temp_variable = { this.leader_score = num_battalions }
				all_of_scopes = {
					array = allies
					add_to_temp_variable = { PREV.leader_score = num_of_factories }
					add_to_temp_variable = { PREV.leader_score = num_battalions }
				}
				if = {
					limit = {
						capital_scope = {
							is_on_continent = ROOT
						}
					}
					multiply_temp_variable = { leader_score = 2 }
				}
				if = {
					limit = {
						any_neighbor_country = { tag = ROOT }
					}
					multiply_temp_variable = { leader_score = 1.25 }
				}
				if = {
					limit = {
						check_variable = { ROOT.best_leader_score < leader_score }
						set_temp_variable = { ROOT.best_leader = this }
						set_temp_variable = { ROOT.best_leader_score = leader_score }
					}
				}
			}
		}
	}
}

remove_naval_treaty_effect = {
	if = {
		limit = {
			has_idea = MTG_naval_treaty_adherent
		}
		remove_ideas = MTG_naval_treaty_adherent
	}
	else_if = {
		limit = {
			has_idea = MTG_naval_treaty_cheating
		}
		remove_ideas = MTG_naval_treaty_cheating
	}
	else_if = {
		limit = {
			has_idea = MTG_naval_treaty_adherent_reduced
		}
		remove_ideas = MTG_naval_treaty_adherent_reduced
	}
	else_if = {
		limit = {
			has_idea = MTG_naval_treaty_cheating_reduced
		}
		remove_ideas = MTG_naval_treaty_cheating_reduced
	}
	set_country_flag = MTG_naval_treaty_abandoned
}

civil_war_anti_exploiter_punitive_action = {
	# Anti-exploiter punitive brigades! BET YA DIDN'T SEE THAT COMING DID YA?!
	if = {
		limit = {
			has_army_size = {
			    size < 1
			}
		}
		division_template = {
			name = "Anti-Exploit Punitive Brigade"
			priority = 1
			division_names_group = ENG_MAR_01
			is_locked = yes
			regiments = {
				infantry = { x = 0 y = 0 }
				infantry = { x = 0 y = 1 }
				infantry = { x = 0 y = 2 }

		   	   	infantry = { x = 1 y = 0 }
				infantry = { x = 1 y = 1 }
				infantry = { x = 1 y = 2 }

		   	   	infantry = { x = 2 y = 0 }
				artillery_brigade = { x = 2 y = 1 }
				artillery_brigade = { x = 2 y = 2 }
			}
			support = {
				engineer = { x = 0 y = 0 }
				recon = { x = 0 y = 1 }
				artillery = { x = 0 y = 2 }
			}
		}
		random_state = {
			limit = {
				is_capital = yes
				is_fully_controlled_by = PREV
			}
			create_unit = {
				division = "division_template = \"Anti-Exploit Punitive Brigade\" start_experience_factor = 1 start_equipment_factor = 1"
				owner = PREV
			}
			create_unit = {
				division = "division_template = \"Anti-Exploit Punitive Brigade\" start_experience_factor = 1 start_equipment_factor = 1"
				owner = PREV
			}
			create_unit = {
				division = "division_template = \"Anti-Exploit Punitive Brigade\" start_experience_factor = 1 start_equipment_factor = 1"
				owner = PREV
			}
			create_unit = {
				division = "division_template = \"Anti-Exploit Punitive Brigade\" start_experience_factor = 1 start_equipment_factor = 1"
				owner = PREV
			}
		}
		random_state = {
			limit = {
				is_in_home_area = yes
				is_fully_controlled_by = PREV
			}
			create_unit = {
				division = "division_template = \"Anti-Exploit Punitive Brigade\" start_experience_factor = 1 start_equipment_factor = 1"
				owner = PREV
			}
			create_unit = {
				division = "division_template = \"Anti-Exploit Punitive Brigade\" start_experience_factor = 1 start_equipment_factor = 1"
				owner = PREV
			}
			create_unit = {
				division = "division_template = \"Anti-Exploit Punitive Brigade\" start_experience_factor = 1 start_equipment_factor = 1"
				owner = PREV
			}
			create_unit = {
				division = "division_template = \"Anti-Exploit Punitive Brigade\" start_experience_factor = 1 start_equipment_factor = 1"
				owner = PREV
			}
		}
		random_state = {
			limit = {
				is_in_home_area = yes
				is_fully_controlled_by = PREV
			}
			create_unit = {
				division = "division_template = \"Anti-Exploit Punitive Brigade\" start_experience_factor = 1 start_equipment_factor = 1"
				owner = PREV
			}
			create_unit = {
				division = "division_template = \"Anti-Exploit Punitive Brigade\" start_experience_factor = 1 start_equipment_factor = 1"
				owner = PREV
			}
			create_unit = {
				division = "division_template = \"Anti-Exploit Punitive Brigade\" start_experience_factor = 1 start_equipment_factor = 1"
				owner = PREV
			}
			create_unit = {
				division = "division_template = \"Anti-Exploit Punitive Brigade\" start_experience_factor = 1 start_equipment_factor = 1"
				owner = PREV
			}
		}
		random_state = {
			limit = {
				is_in_home_area = yes
				is_fully_controlled_by = PREV
			}
			create_unit = {
				division = "division_template = \"Anti-Exploit Punitive Brigade\" start_experience_factor = 1 start_equipment_factor = 1"
				owner = PREV
			}
			create_unit = {
				division = "division_template = \"Anti-Exploit Punitive Brigade\" start_experience_factor = 1 start_equipment_factor = 1"
				owner = PREV
			}
			create_unit = {
				division = "division_template = \"Anti-Exploit Punitive Brigade\" start_experience_factor = 1 start_equipment_factor = 1"
				owner = PREV
			}
			create_unit = {
				division = "division_template = \"Anti-Exploit Punitive Brigade\" start_experience_factor = 1 start_equipment_factor = 1"
				owner = PREV
			}
		}
		random_state = {
			limit = {
				is_in_home_area = yes
				is_fully_controlled_by = PREV
			}
			create_unit = {
				division = "division_template = \"Anti-Exploit Punitive Brigade\" start_experience_factor = 1 start_equipment_factor = 1"
				owner = PREV
			}
			create_unit = {
				division = "division_template = \"Anti-Exploit Punitive Brigade\" start_experience_factor = 1 start_equipment_factor = 1"
				owner = PREV
			}
			create_unit = {
				division = "division_template = \"Anti-Exploit Punitive Brigade\" start_experience_factor = 1 start_equipment_factor = 1"
				owner = PREV
			}
			create_unit = {
				division = "division_template = \"Anti-Exploit Punitive Brigade\" start_experience_factor = 1 start_equipment_factor = 1"
				owner = PREV
			}
		}
	}
}

clear_sabotaged_resources_if_necesary = {
	if = {
		limit = {
			not = {
				has_dynamic_modifier = {
					modifier = sabotaged_resources
				}
			}
		}

		clear_variable = sabotaged_oil
		clear_variable = sabotaged_aluminium
		clear_variable = sabotaged_rubber
		clear_variable = sabotaged_tungsten
		clear_variable = sabotaged_steel
		clear_variable = sabotaged_chromium
	}
}

remove_from_allowed_party = {
	if = {
		limit = { has_government = democratic }
		set_temp_variable = { allowed_party_democratic = 0 }
	}
	else_if = {
		limit = { has_government = fascism }
		set_temp_variable = { allowed_party_fascism = 0 }
	}
	else_if = {
		limit = { has_government = communism }
		set_temp_variable = { allowed_party_communism = 0 }
	}
	else = {
#		limit = { has_government = neutrality }
		set_temp_variable = { allowed_party_neutrality = 0 }
	}
}

#expectes a temp variable country_to_initiate which should contain original_tag to instantiate as a collabration government
instantiate_collaboration_government = {
	custom_effect_tooltip = compliance_80_effect_tooltip
	hidden_effect = {
		set_variable = { collaboration_formed@var:country_to_initiate = 1 }

		if = {
			# if country_to_initiate does not exist, simply release it as a puppet
			limit = {
				var:country_to_initiate = {
					exists = no
				}
			}
			var:country_to_initiate = { set_variable = { collaboration_formed_by = PREV } }
			release_autonomy = {
				target = country_to_initiate
				autonomy_state = autonomy_collaboration_government
				freedom_level = 0.5
				release_non_owned_controlled = yes
			}
			var:country_to_initiate = {
				if = {
					limit = {
						original_tag = BRM
						NOT = { is_subject_of = ENG }
					}
					set_cosmetic_tag = ENG_BRM
				}
				#################
				if = { #GAB
					limit = { original_tag = GAB }
					if = {
						limit = { 
							is_subject_of = FRA 
						}
						set_cosmetic_tag = GAB_FRA
					}
				}		
				if = { #MLI
					limit = { original_tag = MLI }
					if = {
						limit = { 
							is_subject_of = FRA 
						}
						set_cosmetic_tag = MLI_FRA
					}
				}						
				if = { #MOR
					limit = { original_tag = MOR }
					if = {
						limit = { is_subject_of = FRA }
						set_cosmetic_tag = MOR_FRA
					}
				}		
				if = { #MOR
					limit = { original_tag = MOR }
					if = {
						limit = {
							OR = {
								is_subject_of = SPR
								AND = {
									controls_state = 290
									NOT = {
										controls_state = 461	
									}
								}
							}
							 
						}
						set_cosmetic_tag = MOR_SPR
					}
				}

				if = { #Raj
					limit = { original_tag = RAJ }
					if = {
						limit = { is_subject_of = FRA }
						set_cosmetic_tag = RAJ_FRA
						if = {
							limit = {
								has_government = communism
								NOT = {
									any_other_country = {
										has_country_leader = {
											name = "Caïlacha Subbiah"
											ruling_only = no
										}
									}
								}
							}
							create_country_leader = { #Pondichéry communist
								name = "Caïlacha Subbiah"
								desc = "POLITICS_LORD_LINLITHGOW_DESC"
								picture = "gfx/leaders/kr_generic/Portrait_India_Generic_new_6.dds"
								expire = "1965.1.1"
								ideology = stalinism
							}
						}
						else_if = {
							limit = {
								has_government = neutrality
								NOT = {
									any_other_country = {
										has_country_leader = {
											name = "Deiva Zivarattinam"
											ruling_only = no
										}
									}
								}
							}
							create_country_leader = { #Representative of Pondichéry
								name = "Deiva Zivarattinam"
								desc = "POLITICS_LORD_LINLITHGOW_DESC"
								picture = "gfx/leaders/kr_generic/Portrait_India_Generic_new_4.dds"
								expire = "1965.1.1"
								ideology = centrism
							}
						}
						else_if = {
							limit = {
								has_government = fascism
								NOT = {
									any_other_country = {
										has_country_leader = {
											name = "Prem Sahgal"
											ruling_only = no
										}
									}
								}
							}
							create_country_leader = { #indian in japanese indian army but coulen't find better
								name = "Prem Sahgal"
								desc = "POLITICS_LORD_LINLITHGOW_DESC"
								picture = "gfx/leaders/kr_generic/Portrait_India_Generic_land_new_7.dds"
								expire = "1965.1.1"
								ideology = fascism_ideology
							}
						}
					}

					else_if = {
						limit = { is_subject_of = POR }
						set_cosmetic_tag = RAJ_POR
						if = {
							limit = {
								has_government = fascism
								NOT = {
									any_other_country = {
										has_country_leader = {
											name = "Jose Ricardo Pereira Cabral"
											ruling_only = no
										}
									}
								}
							}
							create_country_leader = {
								name = "Jose Ricardo Pereira Cabral"
								desc = " "
								picture = "gfx/leaders/r56_generic/r56_portrait_ITA_generic_land_2.dds"
								expire = "1965.1.1"
								ideology = fascism_ideology
							}
						}
						else_if = {
							limit = {
								has_government = democratic
								NOT = {
									any_other_country = {
										has_country_leader = {
											name = "Jose Ricardo Pereira Cabral"
											ruling_only = no
										}
									}
								}
							}
							create_country_leader = {
								name = "Jose Ricardo Pereira Cabral"
								desc = " "
								picture = "gfx/leaders/r56_generic/r56_portrait_ITA_generic_land_2.dds"
								expire = "1965.1.1"
								ideology = conservatism
							}
						}
						else_if = {
							limit = {
								has_government = neutrality
								NOT = {
									any_other_country = {
										has_country_leader = {
											name = "Jose Ricardo Pereira Cabral"
											ruling_only = no
										}
									}
								}
							}
							create_country_leader = {
								name = "Jose Ricardo Pereira Cabral"
								desc = " "
								picture = "gfx/leaders/r56_generic/r56_portrait_ITA_generic_land_2.dds"
								expire = "1965.1.1"
								ideology = moderatism
							}
						}
					}
				}
						
				if = {
					limit = {
						original_tag = POR
						owns_state = 698
						NOT = {
							any_owned_state = {
								is_owned_by = ROOT
								is_core_of = ROOT
								NOT = {
									state = 698
								}
							}
						}
					}
					set_cosmetic_tag = POR_AZORES
				}

				if = { #SEN
					limit = { original_tag = SEN }
					if = {
						limit = { 
							OR = {
								is_subject_of = FRA
								is_subject_of = BEL
							}
							 
						}
						set_cosmetic_tag = SEN_FRA
					}
				}

				if = { #TOG
					limit = { original_tag = TOG }
					if = {
						limit = { 
							is_subject_of = FRA 
						}
						set_cosmetic_tag = TOG_FRA
					}
				}

				if = { #CHI
					limit = { original_tag = CHI }
					if = {
						limit = {
							NOT = {
								any_other_country = {
									has_country_leader = {
										name = "Liang Hongzhi"
										ruling_only = no
									}
								}
							}
						}
						create_country_leader = {
							name = "Liang Hongzhi"
							desc = "POLITICS_WANG_JINGWEI_DESC"
							picture = "gfx/leaders/CHI/r56_portrait_CHI_Liang_Hongzhi.dds"
							expire = "1965.1.1"
							ideology = fascism_ideology
							traits = {
								eager_collaborator
							}
						}
						create_country_leader = {
							name = "Liang Hongzhi"
							desc = "POLITICS_WANG_JINGWEI_DESC"
							picture = "gfx/leaders/CHI/r56_portrait_CHI_Liang_Hongzhi.dds"
							expire = "1965.1.1"
							ideology = despotism
							traits = {
								eager_collaborator
							}
						}
						set_party_name = { ideology = fascism long_name = KMT_wjw name = KMT_wjw }
					}
					else = {
						create_country_leader = {
							name = "Wang Jingwei"
							desc = "POLITICS_WANG_JINGWEI_DESC"
							picture = "gfx/leaders/CHI/r56_portrait_CHI_Wang_Jingwei.dds"
							expire = "1965.1.1"
							ideology = fascism_ideology
							traits = {
								eager_collaborator
							}
						}
						set_party_name = { ideology = fascism long_name = KMT_wjw name = KMT_wjw }
						create_country_leader = {
							name = "Wang Jingwei"
							desc = "POLITICS_WANG_JINGWEI_DESC"
							picture = "gfx/leaders/CHI/r56_portrait_CHI_Wang_Jingwei.dds"
							expire = "1965.1.1"
							ideology = despotism
							traits = {
								eager_collaborator
							}
						}
						set_party_name = { ideology = neutrality long_name = KMT_wjw name = KMT_wjw }
					}

					if = {
						limit = {
							NOT = {
								owns_state = 524
								owns_state = 591
								owns_state = 592
								owns_state = 594
								owns_state = 596
								owns_state = 613
								owns_state = 620
								owns_state = 605
								owns_state = 603
								owns_state = 597
								owns_state = 622
								owns_state = 615
								owns_state = 608
								owns_state = 716
								owns_state = 328
								owns_state = 325
							}
						}
						if = {
							limit = {
								is_subject_of = ENG
								owns_state = 326
							}
							set_cosmetic_tag = CHI_HK_UK
						}
						else_if = {
							limit = {
								is_subject_of = POR
								owns_state = 729
							}
							set_cosmetic_tag = CHI_MAC_POR
						}
						else_if = {
							limit = {
								NOT = { is_subject_of = ENG }
								owns_state = 326
							}
							set_cosmetic_tag = CHI_HK
						}
						else_if = {
							limit = {
								NOT = { is_subject_of = POR }
								owns_state = 729
							}
							set_cosmetic_tag = CHI_MAC
						}
					}
				}

				#######
				#yes this is the grandpa of Boris Johnson, it's a joke alright?
				if = {
					limit = {
						original_tag = ENG
						has_government = neutrality
						OVERLORD = {
							OR = {
								has_cosmetic_tag = OTT_SULTANATE_neutrality
								has_cosmetic_tag = TUR_PROVISIONARY_neutrality
								has_cosmetic_tag = TUR_GREATER_TURKEY_neutrality
								has_cosmetic_tag = OTT_UNIFIED
								has_cosmetic_tag = OTT_UNIFIED_neutrality
								has_cosmetic_tag = TUR_neutrality
							}
						}
						NOT = {
							any_other_country = {
								has_country_leader = {
									name = "Osman Kemal"
									ruling_only = no
								}
							}
						}
					}
					create_country_leader = {
						name = "Osman Kemal"
						desc = ""
						picture = "gfx/leaders/r56_generic/r56_portrait_generic_middle_east_1.dds"
						expire = "1965.1.1"
						ideology = moderatism
						traits = {
							eager_collaborator
						}
					}
				}

				#### Turkish Cypriot as leader of puppet cyprus
				#Fazil Kutchuk owner of Halkim Sesi biggest Turksih journal and founder of Cyprus National Turkish People's Party
				#probably need another trait for ethnically divisive figure or something like that.
				#he was probably never a fascist but we have to work with what we have.
				if = { # CYP
					limit = {
						original_tag = CYP
						is_subject_of = TUR
						NOT = {
							any_other_country = {
								has_country_leader = {
									name = "Fazil Kutchuk"
									ruling_only = no
								}
							}
						}
					}
					set_cosmetic_tag = CYP_TUR
					if = {
						limit = {
							has_government = fascism
							OVERLORD = { has_government = fascism }
						}
						create_country_leader = {
							name = "Fazil Kutchuk"
							desc = ""
							picture = "gfx/leaders/r56_generic/r56_portrait_generic_middle_east_1.dds"
							expire = "1965.1.1"
							ideology = fascism_ideology
							traits = {
								editor
							}
						}
					}
					else_if = {
						limit = {
							has_government = neutrality
							OVERLORD = { has_government = neutrality }
						}
						create_country_leader = {
							name = "Fazil Kutchuk"
							desc = ""
							picture = "gfx/leaders/r56_generic/r56_portrait_generic_middle_east_1.dds"
							expire = "1965.1.1"
							ideology = moderatism
							traits = {
								editor
							}
						}
					}
				}

				if = { #HUN
					limit = {
						ROOT = { tag = HUN }
						FROM = {
							OR = {
								original_tag = ROM
								original_tag = TRA
								original_tag = CZE
								original_tag = SLO
								original_tag = YUG
								original_tag = SER
							}
						}
						NOT = {
							any_other_country = {
								has_country_leader = {
									name = "Vilmos Rőder"
									ruling_only = no
								}
							}
						}
					}
					#set_party_name = { ideology = fascism long_name = HUN_arrow_cross_party_long name = HUN_arrow_cross_party }
					if = {
						limit = {
							FROM = { has_government = neutrality }
						}
						#the generic portrait is actually him
						create_country_leader = {
							name = "Vilmos Rőder"
							desc = "POLITICS_FERENC_SZALASI_DESC"
							picture = "gfx/leaders/Europe/portrait_europe_generic_6.dds"
							expire = "1965.1.1"
							ideology = oligarchism
							traits = {
								r56_trait_opposed_to_communism
								rearmer
							}
						}
					}
					else_if = {
						limit = {
							FROM = { has_government = fascism }
						}
						#the generic portrait is actually him
						create_country_leader = {
							name = "Vilmos Rőder"
							desc = "POLITICS_FERENC_SZALASI_DESC"
							picture = "gfx/leaders/Europe/portrait_europe_generic_6.dds"
							expire = "1965.1.1"
							ideology = fascism_ideology
							traits = {
								r56_trait_opposed_to_communism
								rearmer
							}
						}
					}
				}

				if = {
					limit = {
						original_tag = HUN
						OVERLORD = {
							has_government = fascism
							NOT = {
								original_tag = ROM
								original_tag = TRA
								original_tag = CZE
								original_tag = SLO
								original_tag = YUG
								original_tag = SER
							}
						}
						NOT = {
							any_other_country = {
								has_country_leader = {
									name = "Ferenc Szalasi"
									ruling_only = no
								}
							}
						}
					}
					create_country_leader = {
						name = "Ferenc Szalasi"
						desc = "POLITICS_FERENC_SZALASI_DESC"
						picture = "gfx/leaders/HUN/r56_portrait_HUN_Ferenc_Szalasi.dds"
						expire = "1965.1.1"
						ideology = nazism
						traits = {
							anti_communist
							fascist_militia_leader
						}
					}
					set_party_name = { ideology = fascism long_name = HUN_arrow_cross_party_long name = HUN_arrow_cross_party }
				}

				if = {
					limit = {
						original_tag = PHI
						NOT = {
							any_other_country = {
								has_country_leader = {
									name = "José P. Laurel"
									ruling_only = no
								}
							}
						}
					}
					create_country_leader = {
						name = "José P. Laurel"
						desc = "POLITICS_FERENC_SZALASI_DESC"
						picture = "gfx/leaders/Asia/Portrait_Asia_Generic_fascism.dds"
						expire = "1965.1.1"
						ideology = fascism_ideology
					}
				}

				if = { #CZE
					limit = { original_tag = CZE }
					if = {
						limit = {
							has_dlc = "Death or Dishonor"
							OR = {
								is_subject_of = GER
								is_subject_of = PRE
							}
							NOT = {
								any_other_country = {
									has_country_leader = {
										name = "Konstantin von Neurath"
										ruling_only = no
									}
								}
							}
						}
						create_country_leader = {
							name = "Konstantin von Neurath"
							desc = "POLITICS_FERENC_SZALASI_DESC"
							picture = "gfx/leaders/CZE/portrait_konstantin_von_neurath.dds"
							expire = "1965.1.1"
							ideology = nazism
							traits = {
								anti_communist
							}
						}
					}

					if = {
						limit = {
							is_subject_of = GER
							controls_state = 69
							controls_state = 74
							GER = {
								controls_state = 65
								controls_state = 66
							}
						}
						69 = { add_core_of = GER }
						GER = { transfer_state = 69 }
						74 = { add_core_of = GER }
						GER = { transfer_state = 74 }
					}
				}

				if = {
					limit = {
						original_tag = SOV
						OVERLORD = {
							has_government = fascism
						}
						NOT = {
							any_other_country = {
								has_country_leader = {
									name = "Constantin Kromiadi"
									ruling_only = no
								}
							}
						}
					}
					create_country_leader = {
						name = "Constantin Kromiadi"
						desc = "POLITICS_FERENC_SZALASI_DESC"
						picture = "gfx/leaders/Europe/Portrait_Europe_Generic_land_1.dds"
						expire = "1965.1.1"
						ideology = nazism
						traits = {
							anti_communist
						}
					}
				}

				if = {
					limit = {
						ROOT = {
							original_tag = ROM
							NOT = {
								tag = ROM
							}
						}
						#FROM = { tag = JAP } For specific country probably won't be necessary here
						OVERLORD = {
							has_government = fascism
							FROM = {
								NOT = {
									original_tag = HUN
								}
							}
						}
						NOT = {
							any_other_country = {
								OR = {
									has_country_leader = {
										name = "Horia Sima"
										ruling_only = no
									}
									has_country_leader = {
										name = "Corneliu Codreanu"
										ruling_only = yes
									}
									has_idea = ROM_horia_sima
								}
							}
						}
					}
					create_country_leader = {
						name = "Horia Sima"
						desc = "POLITICS_KONSTADINOS_LOGOTHETOPOULOS_DESC"
						picture = "gfx/leaders/ROM/r56_portrait_ROM_Horia_Sima.dds"
						expire = "1965.1.1"
						ideology = nazism
						traits = {
							fascistic_paramilitarist
						}
					}
				}

				if = {
					limit = {
						OR = {
							original_tag = SPR
							original_tag = SPA
						}
						has_government = fascism

						NOT = {
							any_other_country = {
								has_country_leader = {
									name = "Rafael Sánchez Mazas"
									ruling_only = no
								}
							}
						}
					}
					create_country_leader = {
						name = "Rafael Sánchez Mazas"
						desc = "POLITICS_FERENC_SZALASI_DESC"
						picture = "gfx/leaders/r56_generic/r56_portrait_generic_politician_europe_1.dds"
						expire = "1965.1.1"
						ideology = falangism
						traits = {
							editor
						}
					}
				}

				if = { #ALB
					limit = {
						original_tag = ALB
						has_government = fascism
					}
					if = {
						limit = {
							is_subject_of = GER
							NOT = {
								any_other_country = {
									has_country_leader = {
										name = "Mehdi Frashëri"
										ruling_only = no
									}
								}
							}
						}
						create_country_leader = {
							name = "Mehdi Frashëri"
							desc = "POLITICS_FERENC_SZALASI_DESC"
							picture = "gfx/leaders/Europe/portrait_europe_generic_4.dds"
							expire = "1965.1.1"
							ideology = fascism_ideology
						}
					}
					else_if = {
						limit = {
							NOT = { is_subject_of = GER }

							NOT = {
								any_other_country = {
									has_country_leader = {
										name = "Shefqet Vërlaci"
										ruling_only = no
									}
								}
							}
						}
						create_country_leader = {
							name = "Shefqet Vërlaci"
							desc = "POLITICS_FERENC_SZALASI_DESC"
							picture = "gfx/leaders/Europe/portrait_europe_generic_6.dds"
							expire = "1965.1.1"
							ideology = fascism_ideology
						}
					}
				}

				if = {
					limit = {
						original_tag = POL
						OR = {
							is_subject_of = GER
							is_subject_of = PRE
						}
						NOT = {
							any_other_country = {
								has_country_leader = {
									name = "Hans Frank"
									ruling_only = no
								}
							}
							any_other_country = {
								has_country_leader = {
									name = "Fryderyk Krystian Wettyn"
									ruling_only = no
								}
							}
						}
					}
					POL = { set_cosmetic_tag = POLG }
					POL = { set_party_name = { ideology = fascism long_name = GER_fascism_party_long name = GER_fascism_party } }
					create_country_leader = {
						name = "Hans Frank"
						desc = "HANS_FRANK_DESC"
						picture = "r56_portrait_POL_Hans_Frank.dds"
						expire = "1965.1.1"
						ideology = nazism
						traits = {
							prince_of_terror
							governor_general
							r56_trait_opposed_to_communism
						}
					}
					POL = { set_party_name = { ideology = neutrality long_name = POL_monarchy_party_long name = POL_monarchy_party } }
					create_country_leader = {
						name = "Fryderyk Krystian Wettyn"
						desc = "FRYDERYK_KRYSTIAN_WETTYN_DESC"
						picture = "r56_portrait_POL_Fryderyk_Krystian_Wettyn.dds"
						expire = "1965.1.1"
						ideology = despotism
						traits = {
							POL_king_of_poland
							POL_german_origins
							r56_trait_opposed_to_communism
						}
					}
				}

			#Force Hjalmar Mae as collaborator instead of Artur Sirk
				if = {
					limit = {
						original_tag = EST
						has_government = fascism
						OR = {
							OVERLORD = {
								original_tag = GER
							}
							any_other_country = {
								has_country_leader = {
									name = "Artur Sirk"
								}
							}
						}
						NOT = {
							any_other_country = {
								has_country_leader = {
									name = "Hjalmar Mae"
								}
							}
						}
					}
					create_country_leader = {
						name = "Hjalmar Mae"
						picture = "r56_portrait_EST_Hjalmar_Mae.dds"
						expire = "1959.1.1"
						ideology = nazism
					}
				}

				### Non Aligned Britain empowers Philip of Greece (future Philip Mountbatten - husband of Elisabeth II)
				if = {
					limit = {
						FROM = { tag = ENG }
						ENG = { has_government = neutrality }
						NOT = {
							any_other_country = {
								has_country_leader = {
									name = "Philip of Greece"
									ruling_only = no
								}
							}
						}
					}
					if = {
						limit = {
							OR = {
								ROOT = { original_tag = GRE }
								ROOT = { original_tag = DEN } ### Same but for Denmark as the house of Glucksburg had relatives on both thrones
							}
						}
						create_country_leader = {
							name = "Philip of Greece"
							desc = ""
							picture = "gfx/leaders/r56_generic/r56_portrait_generic_admiral_europe_3.dds"
							expire = "1965.1.1"
							ideology = despotism
							traits = {
								eager_collaborator
								popular_figurehead2
							}
						}
					}
				}

				#Andrija Hebrang as pro Soviet Yug/Cro leader
				if = {
					limit = {
						OR = {
							tag = YUG
							tag = CRO
						}
						NOT = {
							any_other_country = {
								has_country_leader = {
									name = "Andrija Hebrang"
									ruling_only = yes
								}
							}
						}

						OVERLORD = {
							OR = {
								original_tag = SOV
								is_in_faction_with = SOV
							}
							has_government = communism
							SOV = { has_government = communism }
						}
					}
					create_country_leader = {
						name = "Andrija Hebrang"
						desc = ""
						picture = "gfx/leaders/YUG/r56_portrait_YUG_Andrija_Hebrang.dds"
						expire = "1965.1.1"
						ideology = stalinism
					}
				}

				if = {
					limit = {
						original_tag = SOV
						OVERLORD = {
							has_government = fascism
						}
						NOT = {
							any_other_country = {
								has_country_leader = {
									name = "Constantin Kromiadi"
									ruling_only = no
								}
							}
						}
					}
					create_country_leader = {
						name = "Constantin Kromiadi"
						desc = "POLITICS_FERENC_SZALASI_DESC"
						picture = "gfx/leaders/Europe/Portrait_Europe_Generic_land_1.dds"
						expire = "1965.1.1"
						ideology = nazism
						traits = {
							anti_communist
						}
					}
				}
				if = {
					limit = {
						ROOT = {
							tag = ITA
						}
						OVERLORD = {
							OR = {
								original_tag = GER
								original_tag = USA
								original_tag = POL
								original_tag = IRE
								AND = {
									original_tag = FRA
									has_country_leader = {
										name = "Jacques Doriot"
										ruling_only = yes
									}
								}
							}
							has_government = fascism
						}
					}
					ROOT = {
						remove_ideas = victor_emmanuel
						set_cosmetic_tag = ITA_RSI
						set_party_name = {
							ideology = fascism
							long_name = "Partito Fascista Repubblicano"
							name = "PFR"
						}
					}
				}
				if = {
					limit = {
						ROOT = {
							original_tag = ROM
							NOT = {
								tag = ROM
							}
						}
						#FROM = { tag = JAP } For specific country probably won't be necessary here
						OVERLORD = {
							has_government = fascism
							FROM = {
								NOT = {
									original_tag = HUN
								}
							}
						}
						NOT = {
							any_other_country = {
								OR = {
									has_country_leader = {
										name = "Horia Sima"
										ruling_only = no
									}
									has_country_leader = {
										name = "Corneliu Codreanu"
										ruling_only = yes
									}
									has_idea = ROM_horia_sima
								}
							}
						}
					}
					create_country_leader = {
						name = "Horia Sima"
						desc = "POLITICS_KONSTADINOS_LOGOTHETOPOULOS_DESC"
						picture = "gfx/leaders/ROM/r56_portrait_ROM_Horia_Sima.dds"
						expire = "1965.1.1"
						ideology = nazism
						traits = {
							fascistic_paramilitarist
						}
					}
				}
				if = {
					limit = {
						OR = {
							original_tag = SPR
							original_tag = SPA
						}
						has_government = fascism

						NOT = {
							any_other_country = {
								has_country_leader = {
									name = "Rafael Sánchez Mazas"
									ruling_only = no
								}
							}
						}
					}
					create_country_leader = {
						name = "Rafael Sánchez Mazas"
						desc = "POLITICS_FERENC_SZALASI_DESC"
						picture = "gfx/leaders/r56_generic/r56_portrait_generic_politician_europe_1.dds"
						expire = "1965.1.1"
						ideology = falangism
						traits = {
							editor
						}
					}
				}
			}
		}

		else = {
			# if country_to_initiate exists, create a dynamic country as our new puppet

			create_dynamic_country = {
				original_tag = country_to_initiate

				set_variable = { collaboration_formed_by = PREV }
				set_temp_variable = { new_country = this }

				PREV = {
					every_controlled_state = {
						limit = {
							occupied_country_tag = country_to_initiate
							NOT = {
								is_core_of = PREV
							}
						}

						var:new_country = {
							transfer_state = PREV
						}
					}

					puppet = new_country

					set_autonomy = {
						target = new_country
						autonomy_state = autonomy_collaboration_government
						freedom_level = 0.5
					}
					var:new_country = {
						if = {
							limit = {
								original_tag = BRM
								NOT = {
									is_subject_of = ENG
								}
							}
							set_cosmetic_tag = ENG_BRM
						}

						if = { #Raj
							limit = { original_tag = RAJ }
							if = { #French puppet
								limit = { is_subject_of = FRA }
								set_cosmetic_tag = RAJ_FRA
								if = {
									limit = {
										has_government = communism
										NOT = {
											any_other_country = {
												has_country_leader = {
													name = "Caïlacha Subbiah"
													ruling_only = no
												}
											}
										}
									}
									create_country_leader = { #indian in japanese indian army but coulen't find better
										name = "Caïlacha Subbiah"
										desc = "POLITICS_LORD_LINLITHGOW_DESC"
										picture = "gfx/leaders/RAJ/Portrait_The_Raj_Political_Leader_Generic.dds"
										expire = "1965.1.1"
										ideology = stalinism
									}
								}
								else_if = {
									limit = {
										has_government = neutrality
										NOT = {
											any_other_country = {
												has_country_leader = {
													name = "Deiva Zivarattinam"
													ruling_only = no
												}
											}
										}
									}
									create_country_leader = { #Representative of Pondichéry
										name = "Deiva Zivarattinam"
										desc = "POLITICS_LORD_LINLITHGOW_DESC"
										picture = "gfx/leaders/RAJ/Portrait_The_Raj_Political_Leader_Generic.dds"
										expire = "1965.1.1"
										ideology = centrism
									}
								}
								else_if = {
									limit = {
										has_government = fascism
										NOT = {
											any_other_country = {
												has_country_leader = {
													name = "Prem Sahgal"
													ruling_only = no
												}
											}
										}
									}
									create_country_leader = { #indian in japanese indian army but coulen't find better
										name = "Prem Sahgal"
										desc = "POLITICS_LORD_LINLITHGOW_DESC"
										picture = "gfx/leaders/RAJ/Portrait_The_Raj_Political_Leader_Generic_2.dds"
										expire = "1965.1.1"
										ideology = fascism_ideology
									}
								}
							}

							else_if = { #Portuguese puppet
								limit = { is_subject_of = POR }
								set_cosmetic_tag = RAJ_POR
								if = {
									limit = {
										has_government = fascism
										NOT = {
											any_other_country = {
												has_country_leader = {
													name = "Jose Ricardo Pereira Cabral"
													ruling_only = no
												}
											}
										}
									}
									create_country_leader = {
										name = "Jose Ricardo Pereira Cabral"
										picture = "gfx/leaders/r56_generic/r56_portrait_ITA_generic_land_2.dds"
										expire = "1965.1.1"
										ideology = fascism_ideology
									}
								}
								else_if = {
									limit = {
										has_government = democratic
										NOT = {
											any_other_country = {
												has_country_leader = {
													name = "Jose Ricardo Pereira Cabral"
													ruling_only = no
												}
											}
										}
									}
									create_country_leader = {
										name = "Jose Ricardo Pereira Cabral"
										picture = "gfx/leaders/r56_generic/r56_portrait_ITA_generic_land_2.dds"
										expire = "1965.1.1"
										ideology = conservatism
									}
								}
								else_if = {
									limit = {
										has_government = neutrality
										NOT = {
											any_other_country = {
												has_country_leader = {
													name = "Jose Ricardo Pereira Cabral"
													ruling_only = no
												}
											}
										}
									}
									create_country_leader = {
										name = "Jose Ricardo Pereira Cabral"
										picture = "gfx/leaders/r56_generic/r56_portrait_ITA_generic_land_2.dds"
										expire = "1965.1.1"
										ideology = moderatism
									}
								}
							}
						}

						if = {
							limit = {
								original_tag = POR
								owns_state = 698
								NOT = {
									any_owned_state = {
										is_owned_by = ROOT
										is_core_of = ROOT
										NOT = {
											state = 698
										}

									}
								}
							}
							set_cosmetic_tag = POR_AZORES
						}

						if = { #CHI
							limit = { original_tag = CHI }
							if = {
								limit = {
									NOT = {
										any_other_country = {
											has_country_leader = {
												name = "Liang Hongzhi"
												ruling_only = no
											}
										}
									}
								}
								create_country_leader = {
									name = "Liang Hongzhi"
									desc = "POLITICS_WANG_JINGWEI_DESC"
									picture = "gfx/leaders/CHI/r56_portrait_CHI_Liang_Hongzhi.dds"
									expire = "1965.1.1"
									ideology = fascism_ideology
									traits = {
										eager_collaborator
									}
								}
								create_country_leader = {
									name = "Liang Hongzhi"
									desc = "POLITICS_WANG_JINGWEI_DESC"
									picture = "gfx/leaders/CHI/r56_portrait_CHI_Liang_Hongzhi.dds"
									expire = "1965.1.1"
									ideology = despotism
									traits = {
										eager_collaborator
									}
								}
								set_party_name = { ideology = fascism long_name = KMT_wjw name = KMT_wjw }
							}
							else = {
								create_country_leader = {
									name = "Wang Jingwei"
									desc = "POLITICS_WANG_JINGWEI_DESC"
									picture = "gfx/leaders/CHI/r56_portrait_CHI_Wang_Jingwei.dds"
									expire = "1965.1.1"
									ideology = fascism_ideology
									traits = {
										eager_collaborator
									}
								}
								set_party_name = { ideology = fascism long_name = KMT_wjw name = KMT_wjw }
								create_country_leader = {
									name = "Wang Jingwei"
									desc = "POLITICS_WANG_JINGWEI_DESC"
									picture = "gfx/leaders/CHI/r56_portrait_CHI_Wang_Jingwei.dds"
									expire = "1965.1.1"
									ideology = despotism
									traits = {
										eager_collaborator
									}
								}
								set_party_name = { ideology = neutrality long_name = KMT_wjw name = KMT_wjw }
							}

							if = {
								limit = {
									NOT = {
										owns_state = 524
										owns_state = 591
										owns_state = 592
										owns_state = 594
										owns_state = 596
										owns_state = 613
										owns_state = 620
										owns_state = 605
										owns_state = 603
										owns_state = 597
										owns_state = 622
										owns_state = 615
										owns_state = 608
										owns_state = 716
										owns_state = 328
										owns_state = 325
									}
								}
								if = {
									limit = {
										is_subject_of = ENG
										owns_state = 326
									}
									set_cosmetic_tag = CHI_HK_UK
								}
								else_if = {
									limit = {
										FROM = { is_subject_of = POR }
										owns_state = 729
									}
									set_cosmetic_tag = CHI_MAC_POR
								}
								else_if = {
									limit = {
										FROM = {
											NOT = { is_subject_of = POR }
										}
										owns_state = 729
									}
									set_cosmetic_tag = CHI_MAC
								}
								else_if = {
									limit = {
										FROM = {
											NOT = { is_subject_of = ENG }
										}
										owns_state = 326
									}
									set_cosmetic_tag = CHI_HK
								}
							}
						}

						#######
						if = { #HUN
							limit = {
								ROOT = {
									tag = HUN
								}
								FROM = {
									OR = {
										original_tag = ROM
										original_tag = TRA
										original_tag = CZE
										original_tag = SLO
										original_tag = YUG
										original_tag = SER
									}
								}
								NOT = {
									any_other_country = {
										has_country_leader = {
											name = "Vilmos Rőder"
											ruling_only = no
										}
									}
								}
							}
							if = {
								limit = {
									FROM = { has_government = neutrality }
								}
								#the generic portrait is actually him
								create_country_leader = {
									name = "Vilmos Rőder"
									picture = "gfx/leaders/Europe/portrait_europe_generic_6.dds"
									expire = "1965.1.1"
									ideology = oligarchism
									traits = {
										r56_trait_opposed_to_communism
										rearmer
									}
								}
								#set_party_name = { ideology = fascism long_name = HUN_arrow_cross_party_long name = HUN_arrow_cross_party }
							}
							else_if = {
								limit = {
									FROM = { has_government = fascism }
								}
								#the generic portrait is actually him
								create_country_leader = {
									name = "Vilmos Rőder"
									picture = "gfx/leaders/Europe/portrait_europe_generic_6.dds"
									expire = "1965.1.1"
									ideology = fascism_ideology
									traits = {
										r56_trait_opposed_to_communism
										rearmer
									}
								}
								#set_party_name = { ideology = fascism long_name = HUN_arrow_cross_party_long name = HUN_arrow_cross_party }
							}
						}

						if = {
							limit = {
								original_tag = HUN
								OVERLORD = {
									has_government = fascism
									NOT = {
										original_tag = ROM
										original_tag = TRA
										original_tag = CZE
										original_tag = SLO
										original_tag = YUG
										original_tag = SER
									}
								}
								NOT = {
									any_other_country = {
										has_country_leader = {
											name = "Ferenc Szalasi"
											ruling_only = no
										}
									}
								}

							}
							create_country_leader = {
								name = "Ferenc Szalasi"
								desc = "POLITICS_FERENC_SZALASI_DESC"
								picture = "gfx/leaders/HUN/r56_portrait_HUN_Ferenc_Szalasi.dds"
								expire = "1965.1.1"
								ideology = nazism
								traits = {
									anti_communist
									fascist_militia_leader
								}
							}
							set_party_name = { ideology = fascism long_name = HUN_arrow_cross_party_long name = HUN_arrow_cross_party }
						}

						if = {
							limit = {
								original_tag = PHI
								NOT = {
									any_other_country = {
										has_country_leader = {
											name = "José P. Laurel"
											ruling_only = no
										}
									}
								}

							}
							create_country_leader = {
								name = "José P. Laurel"
								desc = "POLITICS_FERENC_SZALASI_DESC"
								picture = "gfx/leaders/Asia/Portrait_Asia_Generic_fascism.dds"
								expire = "1965.1.1"
								ideology = fascism_ideology
							}
						}

						if = { #CZE
							limit = { original_tag = CZE }
							if = {
								limit = {
									has_dlc = "Death or Dishonor"
									OR = {
										is_subject_of = GER
										is_subject_of = PRE
									}
									NOT = {
										any_other_country = {
											has_country_leader = {
												name = "Konstantin von Neurath"
												ruling_only = no
											}
										}
									}
								}
								create_country_leader = {
									name = "Konstantin von Neurath"
									picture = "gfx/leaders/CZE/portrait_konstantin_von_neurath.dds"
									expire = "1965.1.1"
									ideology = nazism
									traits = {
										anti_communist
									}
								}
							}

							if = {
								limit = {
									is_subject_of = GER
									controls_state = 69
									controls_state = 74
									GER = {
										controls_state = 65
										controls_state = 66
									}
								}
								69 = { add_core_of = GER }
								GER = { transfer_state = 69 }
								74 = { add_core_of = GER }
								GER = { transfer_state = 74 }
							}
						}

						if = {
							limit = {
								original_tag = SOV
								OVERLORD = {
									has_government = fascism
								}
								NOT = {
									any_other_country = {
										has_country_leader = {
											name = "Constantin Kromiadi"
											ruling_only = no
										}
									}
								}
							}
							create_country_leader = {
								name = "Constantin Kromiadi"
								desc = "POLITICS_FERENC_SZALASI_DESC"
								picture = "gfx/leaders/Europe/Portrait_Europe_Generic_land_1.dds"
								expire = "1965.1.1"
								ideology = nazism
								traits = {
									anti_communist
								}
							}
						}

						if = {
							limit = {
								ROOT = {
									original_tag = ROM
									NOT = {
										tag = ROM
									}
								}
								#FROM = { tag = JAP } For specific country probably won't be necessary here
								OVERLORD = {
									has_government = fascism
									FROM = {
										NOT = {
											original_tag = HUN
										}
									}
								}
								NOT = {
									any_other_country = {
										OR = {
											has_country_leader = {
												name = "Horia Sima"
												ruling_only = no
											}
											has_country_leader = {
												name = "Corneliu Codreanu"
												ruling_only = yes
											}
											has_idea = ROM_horia_sima
										}
									}
								}
							}
							create_country_leader = {
								name = "Horia Sima"
								desc = "POLITICS_KONSTADINOS_LOGOTHETOPOULOS_DESC"
								picture = "gfx/leaders/ROM/r56_portrait_ROM_Horia_Sima.dds"
								expire = "1965.1.1"
								ideology = nazism
								traits = {
									fascistic_paramilitarist
								}
							}
						}

						if = {
							limit = {
								OR = {
									original_tag = SPR
									original_tag = SPA
								}
								has_government = fascism

								NOT = {
									any_other_country = {
										has_country_leader = {
											name = "Rafael Sánchez Mazas"
											ruling_only = no
										}
									}
								}
							}
							create_country_leader = {
								name = "Rafael Sánchez Mazas"
								desc = "POLITICS_FERENC_SZALASI_DESC"
								picture = "gfx/leaders/r56_generic/r56_portrait_generic_politician_europe_1.dds"
								expire = "1965.1.1"
								ideology = falangism
								traits = {
									editor
								}
							}
						}

						if = {#ALB
							limit = {
								original_tag = ALB
								has_government = fascism
							}
							if = {
								limit = {
									is_subject_of = GER
									NOT = {
										any_other_country = {
											has_country_leader = {
												name = "Mehdi Frashëri"
												ruling_only = no
											}
										}
									}
								}
								create_country_leader = {
									name = "Mehdi Frashëri"
									picture = "gfx/leaders/Europe/portrait_europe_generic_4.dds"
									expire = "1965.1.1"
									ideology = fascism_ideology
								}
							}
							else_if = {
								limit = {
									NOT = { is_subject_of = GER }
									NOT = {
										any_other_country = {
											has_country_leader = {
												name = "Shefqet Vërlaci"
												ruling_only = no
											}
										}
									}
								}
								create_country_leader = {
									name = "Shefqet Vërlaci"
									picture = "gfx/leaders/Europe/portrait_europe_generic_6.dds"
									expire = "1965.1.1"
									ideology = fascism_ideology
								}
							}
						}
					}

				}
			}
		}
	}
}

abandon_colony_tag = {
	if = {
		limit = {
			is_subject = yes
		}
		if = {
			limit = {
				original_tag = CAN
			}
			if = {
				limit = { NOT = { has_dlc = "Together for Victory" } }
				set_cosmetic_tag = CAN_ALY
			}
			else = {
				set_cosmetic_tag = CAN_UK
			}
		}
		else_if = {
			limit = {
				original_tag = RAJ
			}
			set_cosmetic_tag = RAJ_UK
		}
		else_if = {
			limit = {
				original_tag = LES
			}
			set_cosmetic_tag = LES_ENG
		}
		else_if = {
			limit = {
				original_tag = MAL
			}
			set_cosmetic_tag = MAL_UK
		}
		else_if = {
			limit = {
				original_tag = INS
			}
			set_cosmetic_tag = INS_HOL
		}
	}
	else = {
		if = {
			limit = {
				OR = {
					has_cosmetic_tag = united_polynesia
					has_cosmetic_tag = MAJ_UNIFIED
				}
			}
		}
		else = {
			drop_cosmetic_tag = yes
		}
	}
}

upgrade_economy_law = {
	if = {
		limit = {
			has_idea = civilian_economy
		}
		add_ideas = low_economic_mobilisation
	}
	else_if = {
		limit = {
			has_idea = low_economic_mobilisation
		}
		add_ideas = partial_economic_mobilisation
	}
	else_if = {
		limit = {
			has_idea = partial_economic_mobilisation
		}
		add_ideas = war_economy
	}
	else_if = {
		limit = {
			has_idea = war_economy
		}
		add_ideas = tot_economic_mobilisation
	}
	else = {
		add_political_power = 150
	}
}

gain_random_agency_upgrade = { #Gives a random agency upgrade or grants a free agency if one has not yet been established
	custom_effect_tooltip = free_agency_upgrade_tt
	hidden_effect = {
		if = {
			limit = {
				has_intelligence_agency = no
			}
			create_intelligence_agency = yes
		}
		else = {
			random_list = {
				1 = {
					upgrade_intelligence_agency = upgrade_economy_civilian
					modifier = {
						factor = 0
						has_done_agency_upgrade = upgrade_economy_civilian
					}
				}
				1 = {
					upgrade_intelligence_agency = upgrade_army_department
					modifier = {
						factor = 0
						has_done_agency_upgrade = upgrade_army_department
					}
				}
				1 = {
					upgrade_intelligence_agency = upgrade_naval_department
					modifier = {
						factor = 0
						has_done_agency_upgrade = upgrade_naval_department
					}
				}
				1 = {
					upgrade_intelligence_agency = upgrade_airforce_department
					modifier = {
						factor = 0
						has_done_agency_upgrade = upgrade_airforce_department
					}
				}
				1 = {
					upgrade_intelligence_agency = upgrade_passive_defense
					modifier = {
						factor = 0
						has_done_agency_upgrade = upgrade_passive_defense
					}
				}
				1 = {
					upgrade_intelligence_agency = upgrade_anti_partisan
					modifier = {
						factor = 0
						has_done_agency_upgrade = upgrade_anti_partisan
					}
				}
				1 = {
					upgrade_intelligence_agency = upgrade_blueprint_stealing
					modifier = {
						factor = 0
						has_done_agency_upgrade = upgrade_blueprint_stealing
					}
				}
				1 = {
					upgrade_intelligence_agency = upgrade_portable_radios
					modifier = {
						factor = 0
						has_done_agency_upgrade = upgrade_portable_radios
					}
				}
				1 = {
					upgrade_intelligence_agency = upgrade_invisible_ink
					modifier = {
						factor = 0
						has_done_agency_upgrade = upgrade_invisible_ink
					}
				}
				1 = {
					upgrade_intelligence_agency = upgrade_plastic_explosives
					modifier = {
						factor = 0
						has_done_agency_upgrade = upgrade_plastic_explosives
					}
				}
				1 = {
					upgrade_intelligence_agency = upgrade_suicide_pills
					modifier = {
						factor = 0
						has_done_agency_upgrade = upgrade_suicide_pills
					}
				}
				1 = {
					upgrade_intelligence_agency = upgrade_training_centers
					modifier = {
						factor = 0
						has_done_agency_upgrade = upgrade_training_centers
					}
				}
				1 = {
					upgrade_intelligence_agency = upgrade_commando_training
					modifier = {
						factor = 0
						has_done_agency_upgrade = upgrade_commando_training
					}
				}
				1 = {
					upgrade_intelligence_agency = upgrade_interrogation_techniques
					modifier = {
						factor = 0
						has_done_agency_upgrade = upgrade_interrogation_techniques
					}
				}
				1 = {
					upgrade_intelligence_agency = upgrade_diplo_training
					modifier = {
						factor = 0
						has_done_agency_upgrade = upgrade_diplo_training
					}
				}
				1 = {
					upgrade_intelligence_agency = upgrade_psycho_warfare
					modifier = {
						factor = 0
						has_done_agency_upgrade = upgrade_psycho_warfare
					}
				}
				1 = {
					upgrade_intelligence_agency = upgrade_form_department
					modifier = {
						factor = 0
						has_done_agency_upgrade = upgrade_form_department
					}
				}
				1 = {
					upgrade_intelligence_agency = upgrade_decryption_boost
					modifier = {
						factor = 0
						OR = {
							has_done_agency_upgrade = upgrade_decryption_boost
							NOT = { has_done_agency_upgrade = upgrade_form_department }
						}
					}
				}
				1 = {
					upgrade_intelligence_agency = upgrade_decryption_boost_2
					modifier = {
						factor = 0
						OR = {
							has_done_agency_upgrade = upgrade_decryption_boost_2
							NOT = { has_done_agency_upgrade = upgrade_form_department }
							NOT = { has_done_agency_upgrade = upgrade_decryption_boost }
						}
					}
				}
				1 = {
					upgrade_intelligence_agency = upgrade_crypto_strength
					modifier = {
						factor = 0
						OR = {
							has_done_agency_upgrade = upgrade_crypto_strength
							NOT = { has_done_agency_upgrade = upgrade_form_department }
						}
					}
				}
				1 = {
					upgrade_intelligence_agency = upgrade_crypto_strength_2
					modifier = {
						factor = 0
						OR = {
							has_done_agency_upgrade = upgrade_crypto_strength_2
							NOT = { has_done_agency_upgrade = upgrade_form_department }
							NOT = { has_done_agency_upgrade = upgrade_crypto_strength }
						}
					}
				}
			}
		}
	}
}

join_allies_effect = {
	if = {
		limit = {
			ENG = {
				is_faction_leader = yes
				has_government = democratic
				not = { has_war_with = ROOT }
			}
		}
		ENG = { country_event = generic.2 }
	}
	else = {
		get_best_alliance_match_democratic_effect = yes
		var:best_leader = {
			country_event = generic.2
		}
	}
}

#Should remove any and all fascist foreign influence, to be updated
remove_fascist_spirits_effect = {
	if = {
		limit = { has_idea = fascist_influence }
		remove_ideas = fascist_influence
	}
	if = {
		limit = { has_idea = GER_align_hungary }
		remove_ideas = GER_align_hungary
	}
	if = {
		limit = { has_idea = GER_align_romania }
		remove_ideas = GER_align_romania
	}
}

#Should remove any and all communist foreign influence
remove_communist_spirits_effect = {
	if = {
		limit = { has_idea = comintern_influence }
		remove_ideas = comintern_influence
	}
	if = {
		limit = { has_idea = pan_slavic_propaganda }
		remove_ideas = pan_slavic_propaganda
	}
	if = {
		limit = { has_idea = agitated_peasants }
		remove_ideas = agitated_peasants
	}
	if = {
		limit = { has_idea = armed_communist_militants }
		remove_ideas = armed_communist_militants
	}
	if = {
		limit = { has_idea = bra_influencia_comunista_idea }
		remove_ideas = bra_influencia_comunista_idea
	}
}
#Should remove any and all democratic foreign influence
remove_democratic_spirits_effect = {
	if = {
		limit = { has_idea = democratic_influence }
		remove_ideas = democratic_influence
	}
}
#Adds current ruling popularity to a new ideology - useful to represent ideological shifts within the same party
add_ruling_to_dem = {
	custom_effect_tooltip = add_ruling_to_dem_tt
	hidden_effect = {
		if = {
			limit = {
				has_government = neutrality
			}
			set_variable = {
				var = neutrality_support_var
				value = party_popularity_100@neutrality
			}
			set_variable = {
				var = democratic_support_var
				value = party_popularity_100@democratic
			}
			set_variable = {
				var = communism_support_var
				value = party_popularity_100@communism
			}
			set_variable = {
				var = fascism_support_var
				value = party_popularity_100@fascism
			}
			add_to_variable = {
				democratic_support_var = neutrality_support_var
			}
			set_variable = {
				var = neutrality_support_var
				value = 0
			}
		}
		if = {
			limit = {
				has_government = communism
			}
			set_variable = {
				var = neutrality_support_var
				value = party_popularity_100@neutrality
			}
			set_variable = {
				var = democratic_support_var
				value = party_popularity_100@democratic
			}
			set_variable = {
				var = communism_support_var
				value = party_popularity_100@communism
			}
			set_variable = {
				var = fascism_support_var
				value = party_popularity_100@fascism
			}
			add_to_variable = {
				democratic_support_var = communism_support_var
			}
			set_variable = {
				var = communism_support_var
				value = 0
			}
		}
		if = {
			limit = {
				has_government = fascism
			}
			set_variable = {
				var = neutrality_support_var
				value = party_popularity_100@neutrality
			}
			set_variable = {
				var = democratic_support_var
				value = party_popularity_100@democratic
			}
			set_variable = {
				var = communism_support_var
				value = party_popularity_100@communism
			}
			set_variable = {
				var = fascism_support_var
				value = party_popularity_100@fascism
			}
			add_to_variable = {
				democratic_support_var = fascism_support_var
			}
			set_variable = {
				var = fascism_support_var
				value = 0
			}
		}
		set_popularities = {
			democratic = democratic_support_var
			neutrality = neutrality_support_var
			fascism = fascism_support_var
			communism = communism_support_var
		}
	}
}
add_ruling_to_fas = {
	custom_effect_tooltip = add_ruling_to_fas_tt
	hidden_effect = {
		if = {
			limit = {
				has_government = neutrality
			}
			set_variable = {
				var = neutrality_support_var
				value = party_popularity_100@neutrality
			}
			set_variable = {
				var = democratic_support_var
				value = party_popularity_100@democratic
			}
			set_variable = {
				var = communism_support_var
				value = party_popularity_100@communism
			}
			set_variable = {
				var = fascism_support_var
				value = party_popularity_100@fascism
			}
			add_to_variable = {
				fascism_support_var = neutrality_support_var
			}
			set_variable = {
				var = neutrality_support_var
				value = 0
			}
		}
		if = {
			limit = {
				has_government = communism
			}
			set_variable = {
				var = neutrality_support_var
				value = party_popularity_100@neutrality
			}
			set_variable = {
				var = democratic_support_var
				value = party_popularity_100@democratic
			}
			set_variable = {
				var = communism_support_var
				value = party_popularity_100@communism
			}
			set_variable = {
				var = fascism_support_var
				value = party_popularity_100@fascism
			}
			add_to_variable = {
				fascism_support_var = communism_support_var
			}
			set_variable = {
				var = communism_support_var
				value = 0
			}
		}
		if = {
			limit = {
				has_government = democratic
			}
			set_variable = {
				var = neutrality_support_var
				value = party_popularity_100@neutrality
			}
			set_variable = {
				var = democratic_support_var
				value = party_popularity_100@democratic
			}
			set_variable = {
				var = communism_support_var
				value = party_popularity_100@communism
			}
			set_variable = {
				var = fascism_support_var
				value = party_popularity_100@fascism
			}
			add_to_variable = {
				fascism_support_var = democratic_support_var
			}
			set_variable = {
				var = democratic_support_var
				value = 0
			}
		}
		set_popularities = {
			democratic = democratic_support_var
			neutrality = neutrality_support_var
			fascism = fascism_support_var
			communism = communism_support_var
		}
	}
}
add_ruling_to_com = {
	custom_effect_tooltip = add_ruling_to_com_tt
	hidden_effect = {
		if = {
			limit = {
				has_government = neutrality
			}
			set_variable = {
				var = neutrality_support_var
				value = party_popularity_100@neutrality
			}
			set_variable = {
				var = democratic_support_var
				value = party_popularity_100@democratic
			}
			set_variable = {
				var = communism_support_var
				value = party_popularity_100@communism
			}
			set_variable = {
				var = fascism_support_var
				value = party_popularity_100@fascism
			}
			add_to_variable = {
				communism_support_var = neutrality_support_var
			}
			set_variable = {
				var = neutrality_support_var
				value = 0
			}
		}
		if = {
			limit = {
				has_government = fascism
			}
			set_variable = {
				var = neutrality_support_var
				value = party_popularity_100@neutrality
			}
			set_variable = {
				var = democratic_support_var
				value = party_popularity_100@democratic
			}
			set_variable = {
				var = communism_support_var
				value = party_popularity_100@communism
			}
			set_variable = {
				var = fascism_support_var
				value = party_popularity_100@fascism
			}
			add_to_variable = {
				communism_support_var = fascism_support_var
			}
			set_variable = {
				var = fascism_support_var
				value = 0
			}
		}
		if = {
			limit = {
				has_government = democratic
			}
			set_variable = {
				var = neutrality_support_var
				value = party_popularity_100@neutrality
			}
			set_variable = {
				var = democratic_support_var
				value = party_popularity_100@democratic
			}
			set_variable = {
				var = communism_support_var
				value = party_popularity_100@communism
			}
			set_variable = {
				var = fascism_support_var
				value = party_popularity_100@fascism
			}
			add_to_variable = {
				communism_support_var = democratic_support_var
			}
			set_variable = {
				var = democratic_support_var
				value = 0
			}
		}
		set_popularities = {
			democratic = democratic_support_var
			neutrality = neutrality_support_var
			fascism = fascism_support_var
			communism = communism_support_var
		}
	}
}
add_ruling_to_neu = {
	custom_effect_tooltip = add_ruling_to_neu_tt
	hidden_effect = {
		if = {
			limit = {
				has_government = communism
			}
			set_variable = {
				var = neutrality_support_var
				value = party_popularity_100@neutrality
			}
			set_variable = {
				var = democratic_support_var
				value = party_popularity_100@democratic
			}
			set_variable = {
				var = communism_support_var
				value = party_popularity_100@communism
			}
			set_variable = {
				var = fascism_support_var
				value = party_popularity_100@fascism
			}
			add_to_variable = {
				neutrality_support_var = communism_support_var
			}
			set_variable = {
				var = communism_support_var
				value = 0
			}
		}
		if = {
			limit = {
				has_government = fascism
			}
			set_variable = {
				var = neutrality_support_var
				value = party_popularity_100@neutrality
			}
			set_variable = {
				var = democratic_support_var
				value = party_popularity_100@democratic
			}
			set_variable = {
				var = communism_support_var
				value = party_popularity_100@communism
			}
			set_variable = {
				var = fascism_support_var
				value = party_popularity_100@fascism
			}
			add_to_variable = {
				neutrality_support_var = fascism_support_var
			}
			set_variable = {
				var = fascism_support_var
				value = 0
			}
		}
		if = {
			limit = {
				has_government = democratic
			}
			set_variable = {
				var = neutrality_support_var
				value = party_popularity_100@neutrality
			}
			set_variable = {
				var = democratic_support_var
				value = party_popularity_100@democratic
			}
			set_variable = {
				var = communism_support_var
				value = party_popularity_100@communism
			}
			set_variable = {
				var = fascism_support_var
				value = party_popularity_100@fascism
			}
			add_to_variable = {
				neutrality_support_var = democratic_support_var
			}
			set_variable = {
				var = democratic_support_var
				value = 0
			}
		}
		set_popularities = {
			democratic = democratic_support_var
			neutrality = neutrality_support_var
			fascism = fascism_support_var
			communism = communism_support_var
		}
	}
}
on_daily = {

}

#on_daily_USA = {
#	# you can specify an on daily action for a specific country
#}

#

###BBA COPY PASTE BELOW


leave_the_league_of_nations = {
	custom_effect_tooltip = leave_the_league_of_nations_tt
	hidden_effect = { clr_country_flag = league_of_nations_member_flag }
}

bba_get_fighter_GER_effect = { #creates a fighter design if necessary and exports a number of them to ROOT
	if = {
		limit = {
			GER = {
				has_tech = basic_small_airframe
				NOT = {
					has_tech = improved_small_airframe
				}
			}
		}
		add_equipment_to_stockpile = {
			type = small_plane_airframe_1
			producer = GER
			amount = fighter_buy_amount #set before the effect is invoked (they said I couldn't have arguments in my scripted effects, BUT LOOK WHOS LAUGHING NOW!!!!!)
			variant_name = "Bf 109 D" #set up at game start
		}
	}
	else_if = {
		limit = {
			GER = {
				has_tech = improved_small_airframe
				NOT = {
					has_tech = advanced_small_airframe
				}
			}
		}
		if = {
			limit = {
				GER = { NOT = { has_country_flag = GER_improved_export_fighter_template } }
			}
			GER = {
				create_equipment_variant = {
					name = "Fw-190"
					type = small_plane_airframe_2
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = aircraft_cannon_1_2x
				fixed_auxiliary_weapon_slot_1 = light_mg_2x
				fixed_auxiliary_weapon_slot_2 = empty
				fixed_auxiliary_weapon_slot_3 = empty	
				engine_type_slot = radial_engine_3_1x
				special_type_slot_1 = drop_tanks
				special_type_slot_2 = supercharger
				special_type_slot_3 = water_injection_small
				special_type_slot_4 = armor_plate_small
				special_type_slot_5 = pressurized_cockpit	
				special_type_slot_6 = high_octane_fuel_small
				special_type_slot_7 = empty
				special_type_slot_8 = empty				
			}
					icon = "GFX_GER_fighter2_medium"
				}
				set_country_flag = GER_improved_export_fighter_template #to avoid double templates if this effect is run from different countries
			}
		}
		add_equipment_to_stockpile = {
			type = small_plane_airframe_2
			producer = GER
			amount = fighter_buy_amount
			variant_name = "Fw-190"
		}
	}
	else_if = {
		limit = {
			GER = {
				has_tech = advanced_small_airframe
			}
		}
		if = {
			limit = {
				GER = { NOT = { has_country_flag = GER_advanced_export_fighter_template } }
			}
			GER = {
				create_equipment_variant = {
					name = "Ta-152"
					type = small_plane_airframe_3
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = aircraft_cannon_1_2x
				fixed_auxiliary_weapon_slot_1 = aircraft_cannon_1_2x
				fixed_auxiliary_weapon_slot_2 = empty	
				fixed_auxiliary_weapon_slot_3 = empty				
				engine_type_slot = engine_4_1x
				special_type_slot_1 = drop_tanks
				special_type_slot_2 = supercharger 
				special_type_slot_3 = pressurized_cockpit
				special_type_slot_4 = armor_plate_small
				special_type_slot_5 = water_injection_small	
				special_type_slot_6 = high_octane_fuel_small
				special_type_slot_7 = empty
				special_type_slot_8 = empty				
			}
					icon = "GFX_GER_fighter3_medium"
				}
				set_country_flag = GER_advanced_export_fighter_template
			}
		}
		add_equipment_to_stockpile = {
			type = small_plane_airframe_3
			producer = GER
			amount = fighter_buy_amount
			variant_name = "Ta-152"
		}
	}
}

bba_get_cas_GER_effect = { #creates a CAS design if necessary and exports a number of them to ROOT
	if = {
		limit = {
			GER = {
				has_tech = basic_small_airframe
				NOT = {
					has_tech = improved_small_airframe
				}
			}
		}
		add_equipment_to_stockpile = {
			type = small_plane_cas_airframe_1
			producer = GER
			amount = cas_buy_amount
			variant_name = "Ju 87" #set up at game start
		}
	}
	else_if = {
		limit = {
			GER = {
				has_tech = improved_small_airframe
				NOT = {
					has_tech = advanced_small_airframe
				}
			}
		}
		if = {
			limit = {
				GER = { NOT = { has_country_flag = GER_improved_export_cas_template } }
			}
			GER = {
				create_equipment_variant = {
					name = "Ju-87G «Kanonenvogel»"
					type = small_plane_cas_airframe_2
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (basic frame), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = bomb_locks
				fixed_auxiliary_weapon_slot_1 = tank_buster_1
				fixed_auxiliary_weapon_slot_2 = bomb_locks
				fixed_auxiliary_weapon_slot_3 = empty		
				engine_type_slot = engine_3_1x
				special_type_slot_1 = lmg_defense_turret
				special_type_slot_2 = dive_brakes_small
				special_type_slot_3 = armor_plate_small
				special_type_slot_4 = drop_tanks
				special_type_slot_5 = aerodynamic_pylons_small
				special_type_slot_6 = aerodynamic_pylons_small
				special_type_slot_7 = empty
				special_type_slot_8 = empty				
			}
					icon = "GFX_GER_CAS2_medium"
				}
				set_country_flag = GER_improved_export_cas_template #to avoid double templates if this effect is run from different countries
			}
		}
		add_equipment_to_stockpile = {
			type = small_plane_cas_airframe_1
			producer = GER
			amount = cas_buy_amount
			variant_name = "Ju-87G «Kanonenvogel»"
		}
	}
	else_if = {
		limit = {
			GER = {
				has_tech = advanced_small_airframe
			}
		}
		if = {
			limit = {
				GER = { NOT = { has_country_flag = GER_advanced_export_cas_template } }
			}
			GER = {
				create_equipment_variant = {
					name = "Hs-129"
					type = small_plane_cas_airframe_3
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = small_bomb_bay
				fixed_auxiliary_weapon_slot_1 = tank_buster_2
				fixed_auxiliary_weapon_slot_2 = bomb_locks
				fixed_auxiliary_weapon_slot_3 = rocket_rails
				engine_type_slot = engine_4_2x
				special_type_slot_1 = lmg_defense_turret
				special_type_slot_2 = dive_brakes_small
				special_type_slot_3 = armor_plate_small
				special_type_slot_4 = drop_tanks
				special_type_slot_5 = self_sealing_fuel_tanks_small	
				special_type_slot_6 = empty	
				special_type_slot_7 = empty
				special_type_slot_8 = empty					
			}
					icon = "GFX_GER_CAS3_medium"
				}
				set_country_flag = GER_advanced_export_cas_template
			}
		}
		add_equipment_to_stockpile = {
			type = small_plane_cas_airframe_3
			producer = GER
			amount = cas_buy_amount
			variant_name = "Hs-129"
		}
	}
}

bba_get_tac_GER_effect = { #creates a tac design if necessary and exports a number of them to ROOT
	if = {
		limit = {
			GER = {
				has_tech = iw_medium_airframe
				NOT = {
					has_tech = basic_medium_airframe
				}
			}
		}
		add_equipment_to_stockpile = {
			type = medium_plane_airframe_0
			producer = GER
			amount = tac_buy_amount
			variant_name = "Ju 86" #set up at game start
		}
	}
	if = {
		limit = {
			GER = {
				has_tech = basic_medium_airframe
				NOT = {
					has_tech = improved_medium_airframe
				}
			}
		}
		if = {
			limit = {
				GER = { NOT = { has_country_flag = GER_improved_export_tac_template } }
			}
			GER = {
				create_equipment_variant = {
					name = "He-111"
					type = medium_plane_airframe_1
			modules = {
				fixed_main_weapon_slot = medium_bomb_bay
				fixed_auxiliary_weapon_slot_1 = empty
				fixed_auxiliary_weapon_slot_2 = empty
				fixed_auxiliary_weapon_slot_3 = empty
				fixed_auxiliary_weapon_slot_4 = empty
				fixed_auxiliary_weapon_slot_5 = lmg_defense_turret_2x
				fixed_auxiliary_weapon_slot_6 = empty				
				engine_type_slot = engine_2_2x
				special_type_slot_1 = armor_plate_medium
				special_type_slot_2 = dive_brakes_medium
				special_type_slot_3 = auto_extinguisher_system_medium
				special_type_slot_4 = radio_navigation_1
				special_type_slot_5 = empty
				special_type_slot_6 = empty	
				special_type_slot_7 = aircraft_lightweight_construction_medium				
			}
					icon = "GFX_GER_tactical_bomber1_medium"
				}
				set_country_flag = GER_improved_export_tac_template #to avoid double templates if this effect is run from different countries
			}
		}
		add_equipment_to_stockpile = {
			type = medium_plane_airframe_1
			producer = GER
			amount = tac_buy_amount
			variant_name = "He-111"
		}
	}	
	else_if = {
		limit = {
			GER = {
				has_tech = improved_medium_airframe
				NOT = {
					has_tech = advanced_medium_airframe
				}
			}
		}
		if = {
			limit = {
				GER = { NOT = { has_country_flag = GER_improved_export_tac_template } }
			}
			GER = {
				create_equipment_variant = {
					name = "Ju-88"
					type = medium_plane_airframe_2
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = medium_bomb_bay
				fixed_auxiliary_weapon_slot_1 = medium_bomb_bay
				fixed_auxiliary_weapon_slot_2 = empty
				fixed_auxiliary_weapon_slot_3 = empty
				fixed_auxiliary_weapon_slot_4 = empty
				fixed_auxiliary_weapon_slot_5 = lmg_defense_turret_2x
				fixed_auxiliary_weapon_slot_6 = empty				
				engine_type_slot = engine_3_2x
				special_type_slot_1 = radio_navigation_1
				special_type_slot_2 = dive_brakes_medium
				special_type_slot_3 = auto_extinguisher_system_medium
				special_type_slot_4 = armor_plate_medium
				special_type_slot_5 = empty
				special_type_slot_6 = empty	
				special_type_slot_7 = empty	
			}
					icon = "GFX_GER_tactical_bomber2_medium"
				}
				set_country_flag = GER_improved_export_tac_template #to avoid double templates if this effect is run from different countries
			}
		}
		add_equipment_to_stockpile = {
			type = medium_plane_airframe_2
			producer = GER
			amount = tac_buy_amount
			variant_name = "Ju-88"
		}
	}
	else_if = {
		limit = {
			GER = {
				has_tech = advanced_medium_airframe
			}
		}
		if = {
			limit = {
				GER = { NOT = { has_country_flag = GER_advanced_export_tac_template } }
			}
			GER = {
				create_equipment_variant = {
					name = "Ju-388"
					type = medium_plane_airframe_3
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = medium_bomb_bay
				fixed_auxiliary_weapon_slot_1 = medium_bomb_bay
				fixed_auxiliary_weapon_slot_2 = torpedo_mounting
				fixed_auxiliary_weapon_slot_3 = empty
				fixed_auxiliary_weapon_slot_4 = empty
				fixed_auxiliary_weapon_slot_5 = lmg_defense_turret_2x
				fixed_auxiliary_weapon_slot_6 = empty
				engine_type_slot = engine_4_2x
				special_type_slot_1 = radio_navigation_1
				special_type_slot_2 = dive_brakes_medium
				special_type_slot_3 = high_octane_fuel_medium
				special_type_slot_4 = auto_extinguisher_system_medium
				special_type_slot_5 = armor_plate_medium
				special_type_slot_6 = empty
				special_type_slot_7 = empty					
			}
					icon = "GFX_GER_tactical_bomber3_medium"
				}
				set_country_flag = GER_advanced_export_tac_template
			}
		}
		add_equipment_to_stockpile = {
			type = medium_plane_airframe_3
			producer = GER
			amount = tac_buy_amount
			variant_name = "Ju-388"
		}
	}
}

bba_get_heavy_fighter_GER_effect = { #creates a heavy_fighter design if necessary and exports a number of them to ROOT
	if = {
		limit = {
			GER = {
				has_tech = basic_medium_airframe
				NOT = {
					has_tech = improved_medium_airframe
				}
			}
		}
		if = {
			limit = {
				GER = { NOT = { has_country_flag = GER_basic_export_heavy_fighter_template } }
			}
			GER = {
				create_equipment_variant = {
					name = "Bf-110"
					type = medium_plane_fighter_airframe_1
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = light_mg_4x
				fixed_auxiliary_weapon_slot_1 = aircraft_cannon_1_2x
				fixed_auxiliary_weapon_slot_2 = empty
				fixed_auxiliary_weapon_slot_3 = empty
				fixed_auxiliary_weapon_slot_4 = empty
				fixed_auxiliary_weapon_slot_5 = lmg_defense_turret_2x
				fixed_auxiliary_weapon_slot_6 = empty				
				engine_type_slot = engine_2_2x
				special_type_slot_1 = drop_tanks_medium
				special_type_slot_2 = self_sealing_fuel_tanks_medium
				special_type_slot_3 = high_octane_fuel_medium
				special_type_slot_4 = empty
				special_type_slot_5 = empty
				special_type_slot_6 = empty
				special_type_slot_7 = empty
			}
					icon = "GFX_GER_heavy_fighter1_medium"
				}
				set_country_flag = GER_basic_export_heavy_fighter_template #to avoid double templates if this effect is run from different countries
			}
		}
		add_equipment_to_stockpile = {
			type = medium_plane_fighter_airframe_1
			producer = GER
			amount = heavy_fighter_buy_amount
			variant_name = "Bf-110"
		}
	}
	else_if = {
		limit = {
			GER = {
				has_tech = improved_medium_airframe
				NOT = {
					has_tech = advanced_medium_airframe
				}
			}
		}
		if = {
			limit = {
				GER = { NOT = { has_country_flag = GER_improved_export_heavy_fighter_template } }
			}
			GER = {
				create_equipment_variant = {
					name = "Me-210"
					type = medium_plane_fighter_airframe_2
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = aircraft_cannon_1_2x
				fixed_auxiliary_weapon_slot_1 = aircraft_cannon_1_2x
				fixed_auxiliary_weapon_slot_2 = empty
				fixed_auxiliary_weapon_slot_3 = empty
				fixed_auxiliary_weapon_slot_4 = empty
				fixed_auxiliary_weapon_slot_5 = lmg_defense_turret_2x
				fixed_auxiliary_weapon_slot_6 = empty								
				engine_type_slot = engine_3_2x
				special_type_slot_1 = water_injection_medium
				special_type_slot_2 = self_sealing_fuel_tanks_medium
				special_type_slot_3 = armor_plate_medium
				special_type_slot_4 = supercharger
				special_type_slot_5 = air_air_radar_1
				special_type_slot_6 = empty
				special_type_slot_7 = empty
			}
					icon = "GFX_GER_heavy_fighter2_medium"
				}
				set_country_flag = GER_improved_export_heavy_fighter_template #to avoid double templates if this effect is run from different countries
			}
		}
		add_equipment_to_stockpile = {
			type = medium_plane_fighter_airframe_2
			producer = GER
			amount = heavy_fighter_buy_amount
			variant_name = "Me-210"
		}
	}
	else_if = {
		limit = {
			GER = {
				has_tech = advanced_medium_airframe
			}
		}
		if = {
			limit = {
				GER = { NOT = { has_country_flag = GER_advanced_export_heavy_fighter_template } }
			}
			GER = {
				create_equipment_variant = {
					name = "He-219 «Uhu»"
					type = medium_plane_fighter_airframe_3
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = aircraft_cannon_1_2x
				fixed_auxiliary_weapon_slot_1 = aircraft_cannon_1_2x
				fixed_auxiliary_weapon_slot_2 = empty
				fixed_auxiliary_weapon_slot_3 = empty
				fixed_auxiliary_weapon_slot_4 = empty
				fixed_auxiliary_weapon_slot_5 = hmg_defense_turret_2x
				fixed_auxiliary_weapon_slot_6 = empty				
				engine_type_slot = engine_3_2x
				special_type_slot_1 = water_injection_medium
				special_type_slot_2 = self_sealing_fuel_tanks_medium
				special_type_slot_3 = armor_plate_medium
				special_type_slot_4 = supercharger
				special_type_slot_5 = high_octane_fuel_medium
				special_type_slot_6 = empty
				special_type_slot_7 = empty
			}
					icon = "GFX_GER_heavy_fighter3_medium"
				}
				set_country_flag = GER_advanced_export_heavy_fighter_template
			}
		}
		add_equipment_to_stockpile = {
			type = medium_plane_fighter_airframe_3
			producer = GER
			amount = heavy_fighter_buy_amount
			variant_name = "He-219 «Uhu»"
		}
	}
}

bba_get_fighter_ENG_effect = { #creates a fighter design if necessary and exports a number of them to ROOT
	if = {
		limit = {
			ENG = {
				NOT = {
					has_tech = basic_small_airframe
				}
			}
		}
		add_equipment_to_stockpile = {
			type = small_plane_airframe_0
			producer = ENG
			amount = fighter_buy_amount #set before the effect is invoked
			variant_name = "Gloster Gladiator"
		}
	}
	if = {
		limit = {
			ENG = {
				has_tech = basic_small_airframe
				NOT = {
					has_tech = improved_small_airframe
				}
			}
		}
		if = {
			limit = {
				ENG = { NOT = { has_country_flag = ENG_basic_export_fighter_template } }
			}
			ENG = {
				create_equipment_variant = {
					name = "Hawker Hurricane"
					type = small_plane_airframe_1
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = light_mg_4x
				fixed_auxiliary_weapon_slot_1 = light_mg_4x
				fixed_auxiliary_weapon_slot_2 = empty				
				engine_type_slot = engine_2_1x
				special_type_slot_1 = armor_plate_small
				special_type_slot_2 = self_sealing_fuel_tanks_small
				special_type_slot_3 = high_octane_fuel_small			
				special_type_slot_4 = fuel_tanks_small
				special_type_slot_5 = empty					
			}
					icon = "GFX_ENG_fighter1_medium"
				}
				set_country_flag = ENG_basic_export_fighter_template #to avoid double templates if this effect is run from different countries
			}
		}
		add_equipment_to_stockpile = {
			type = small_plane_airframe_1
			producer = ENG
			amount = fighter_buy_amount #set before the effect is invoked
			variant_name = "Hawker Hurricane"
		}
	}
	else_if = {
		limit = {
			ENG = {
				has_tech = improved_small_airframe
				NOT = {
					has_tech = advanced_small_airframe
				}
			}
		}
		if = {
			limit = {
				ENG = { NOT = { has_country_flag = ENG_improved_export_fighter_template } }
			}
			ENG = {
				create_equipment_variant = {
					name = "Supermarine Spitfire"
					type = small_plane_airframe_2
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = aircraft_cannon_1_2x
				fixed_auxiliary_weapon_slot_1 = light_mg_4x
				fixed_auxiliary_weapon_slot_2 = empty
				fixed_auxiliary_weapon_slot_3 = empty	
				engine_type_slot = engine_3_1x
				special_type_slot_1 = drop_tanks
				special_type_slot_2 = supercharger
				special_type_slot_3 = water_injection_small
				special_type_slot_4 = armor_plate_small
				special_type_slot_5 = self_sealing_fuel_tanks_small	
				special_type_slot_6 = empty
			}
					icon = "GFX_ENG_fighter2_medium"
				}
				set_country_flag = ENG_improved_export_fighter_template #to avoid double templates if this effect is run from different countries
			}
		}
		add_equipment_to_stockpile = {
			type = small_plane_airframe_2
			producer = ENG
			amount = fighter_buy_amount
			variant_name = "Supermarine Spitfire"
		}
	}
	else_if = {
		limit = {
			ENG = {
				has_tech = advanced_small_airframe
			}
		}
		if = {
			limit = {
				ENG = { NOT = { has_country_flag = ENG_advanced_export_fighter_template } }
			}
			ENG = {
				create_equipment_variant = {
					name = "Supermarine Spitfire Mk.XIV"
					type = small_plane_airframe_3
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = aircraft_cannon_1_2x
				fixed_auxiliary_weapon_slot_1 = aircraft_cannon_1_2x
				fixed_auxiliary_weapon_slot_2 = empty	
				fixed_auxiliary_weapon_slot_3 = empty
				engine_type_slot = engine_4_1x
				special_type_slot_1 = armor_plate_small				
				special_type_slot_2 = supercharger
				special_type_slot_3 = drop_tanks				
				special_type_slot_4 = fuel_tanks_small
				special_type_slot_5 = high_octane_fuel_small
				special_type_slot_6 = self_sealing_fuel_tanks_small
			}
					icon = "GFX_ENG_fighter3_medium"
				}
				set_country_flag = ENG_advanced_export_fighter_template
			}
		}
		add_equipment_to_stockpile = {
			type = small_plane_airframe_3
			producer = ENG
			amount = fighter_buy_amount
			variant_name = "Supermarine Spitfire Mk.XIV"
		}
	}
}

bba_get_cas_ENG_effect = { #creates a CAS design if necessary and exports a number of them to ROOT
	if = {
		limit = {
			ENG = {
				has_tech = basic_small_airframe
				NOT = {
					has_tech = improved_small_airframe
				}
			}
		}
		if = {
			limit = {
				ENG = { NOT = { has_country_flag = ENG_basic_export_cas_template } }
			}
			ENG = {
				create_equipment_variant = {
					name = "Fairey Battle"
					type = small_plane_cas_airframe_1
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = small_bomb_bay
				fixed_auxiliary_weapon_slot_1 = bomb_locks
				fixed_auxiliary_weapon_slot_2 = empty

				engine_type_slot = engine_2_1x
				special_type_slot_1 = lmg_defense_turret
				special_type_slot_2 = dive_brakes_small
				special_type_slot_3 = drop_tanks
				special_type_slot_4 = armor_plate_small
				special_type_slot_5 = self_sealing_fuel_tanks_small
			}
					icon = "GFX_ENG_CAS1_medium"
				}
				set_country_flag = ENG_basic_export_cas_template
			}
		}
		add_equipment_to_stockpile = {
			type = small_plane_cas_airframe_1
			producer = ENG
			amount = cas_buy_amount
			variant_name = "Fairey Battle" #set up at game start
		}
	}
	else_if = {
		limit = {
			ENG = {
				has_tech = improved_small_airframe
				NOT = {
					has_tech = advanced_small_airframe
				}
			}
		}
		if = {
			limit = {
				ENG = { NOT = { has_country_flag = ENG_improved_export_cas_template } }
			}
			ENG = {
				create_equipment_variant = {
					name = "Hawker Typhoon"
					type = small_plane_cas_airframe_2
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = tank_buster_1
				fixed_auxiliary_weapon_slot_1 = rocket_rails
				fixed_auxiliary_weapon_slot_2 = rocket_rails
				fixed_auxiliary_weapon_slot_3 = rocket_rails			
				engine_type_slot = engine_3_1x
				special_type_slot_1 = armor_plate_small
				special_type_slot_2 = supercharger
				special_type_slot_3 = self_sealing_fuel_tanks_small
				special_type_slot_4 = aerodynamic_pylons_small
				special_type_slot_5 = aerodynamic_pylons_small
				special_type_slot_6 = empty
				special_type_slot_7 = aircraft_reinforced_construction_small				
			}
					icon = "GFX_ENG_CAS2_medium"
				}
				set_country_flag = ENG_improved_export_cas_template #to avoid double templates if this effect is run from different countries
			}
		}
		add_equipment_to_stockpile = {
			type = small_plane_cas_airframe_2
			producer = ENG
			amount = cas_buy_amount
			variant_name = "Hawker Typhoon"
		}
	}
	else_if = {
		limit = {
			ENG = {
				has_tech = advanced_small_airframe
			}
		}
		if = {
			limit = {
				ENG = { NOT = { has_country_flag = ENG_advanced_export_cas_template } }
			}
			ENG = {
				create_equipment_variant = {
					name = "Bristol Brigand"
					type = small_plane_cas_airframe_3
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = tank_buster_2
				fixed_auxiliary_weapon_slot_1 = rocket_rails
				fixed_auxiliary_weapon_slot_2 = rocket_rails
				fixed_auxiliary_weapon_slot_3 = rocket_rails
				engine_type_slot = engine_4_2x
				special_type_slot_1 = armor_plate_small
				special_type_slot_2 = supercharger
				special_type_slot_3 = self_sealing_fuel_tanks_small
				special_type_slot_4 = aerodynamic_pylons_small
				special_type_slot_5 = aerodynamic_pylons_small
				special_type_slot_6 = empty
				special_type_slot_7 = aircraft_reinforced_construction_small			
			}
					icon = "GFX_ENG_CAS3_medium"
				}
				set_country_flag = ENG_advanced_export_cas_template
			}
		}
		add_equipment_to_stockpile = {
			type = small_plane_cas_airframe_3
			producer = ENG
			amount = cas_buy_amount
			variant_name = "Bristol Brigand"
		}
	}
}

bba_get_tac_ENG_effect = { #creates a tac design if necessary and exports a number of them to ROOT
	if = {
		limit = {
			ENG = {
				has_tech = basic_medium_airframe
				NOT = {
					has_tech = improved_medium_airframe
				}
			}
		}
		add_equipment_to_stockpile = {
			type = medium_plane_airframe_1
			producer = ENG
			amount = tac_buy_amount
			variant_name = "Bristol Blenheim" #set up at game start
		}
	}
	else_if = {
		limit = {
			ENG = {
				has_tech = improved_medium_airframe
				NOT = {
					has_tech = advanced_medium_airframe
				}
			}
		}
		if = {
			limit = {
				ENG = { NOT = { has_country_flag = ENG_improved_export_tac_template } }
			}
			ENG = {
				create_equipment_variant = {
					name = "Vickers Wellington"
					type = medium_plane_airframe_2
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = medium_bomb_bay
				fixed_auxiliary_weapon_slot_1 = medium_bomb_bay
				fixed_auxiliary_weapon_slot_2 = empty
				fixed_auxiliary_weapon_slot_3 = empty
				fixed_auxiliary_weapon_slot_4 = empty
				fixed_auxiliary_weapon_slot_5 = lmg_defense_turret_2x
				fixed_auxiliary_weapon_slot_6 = empty				
				engine_type_slot = engine_3_2x
				special_type_slot_1 = radio_navigation_1
				special_type_slot_2 = dive_brakes_medium
				special_type_slot_3 = high_octane_fuel_medium
				special_type_slot_4 = armor_plate_medium
				special_type_slot_5 = empty	
				special_type_slot_6 = empty	
				special_type_slot_7 = empty				
			}
					icon = "GFX_ENG_tactical_bomber2_medium"
				}
				set_country_flag = ENG_improved_export_tac_template #to avoid double templates if this effect is run from different countries
			}
		}
		add_equipment_to_stockpile = {
			type = medium_plane_airframe_2
			producer = ENG
			amount = tac_buy_amount
			variant_name = "Vickers Wellington"
		}
	}
	else_if = {
		limit = {
			ENG = {
				has_tech = advanced_medium_airframe
			}
		}
		if = {
			limit = {
				ENG = { NOT = { has_country_flag = ENG_advanced_export_tac_template } }
			}
			ENG = {
				create_equipment_variant = {
					name = "Mosquito B"
					type = medium_plane_airframe_3
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = medium_bomb_bay
				fixed_auxiliary_weapon_slot_1 = medium_bomb_bay
				fixed_auxiliary_weapon_slot_2 = torpedo_mounting
				fixed_auxiliary_weapon_slot_3 = empty
				fixed_auxiliary_weapon_slot_4 = empty				
				fixed_auxiliary_weapon_slot_5 = lmg_defense_turret_2x
				fixed_auxiliary_weapon_slot_6 = lmg_defense_turret_2x				
				engine_type_slot = engine_4_2x
				special_type_slot_1 = radio_navigation_2
				special_type_slot_2 = dive_brakes_medium
				special_type_slot_3 = high_octane_fuel_medium
				special_type_slot_4 = self_sealing_fuel_tanks_medium
				special_type_slot_5 = armor_plate_medium
				special_type_slot_6 = empty
				special_type_slot_7 = empty				
			}
					icon = "GFX_ENG_tactical_bomber3_medium"
				}
				set_country_flag = ENG_advanced_export_tac_template
			}
		}
		add_equipment_to_stockpile = {
			type = medium_plane_airframe_3
			producer = ENG
			amount = tac_buy_amount
			variant_name = "Mosquito B"
		}
	}
}

bba_get_heavy_fighter_ENG_effect = { #creates a heavy_fighter design if necessary and exports a number of them to ROOT
	if = {
		limit = {
			ENG = {
				has_tech = basic_medium_airframe
				NOT = {
					has_tech = improved_medium_airframe
				}
			}
		}
		if = {
			limit = {
				ENG = { NOT = { has_country_flag = ENG_basic_export_heavy_fighter_template } }
			}
			ENG = {
				create_equipment_variant = {
					name = "Blenheim IF"
					type = medium_plane_fighter_airframe_1
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = light_mg_4x
				fixed_auxiliary_weapon_slot_1 = aircraft_cannon_1_2x
				fixed_auxiliary_weapon_slot_2 = empty
				fixed_auxiliary_weapon_slot_3 = empty
				fixed_auxiliary_weapon_slot_4 = empty				
				fixed_auxiliary_weapon_slot_5 = lmg_defense_turret_2x
				fixed_auxiliary_weapon_slot_6 = empty				
				engine_type_slot = engine_2_2x
				special_type_slot_1 = non_strategic_materials_medium
				special_type_slot_2 = self_sealing_fuel_tanks_medium
				special_type_slot_3 = fuel_tanks_medium
				special_type_slot_4 = empty
				special_type_slot_5 = empty
				special_type_slot_6 = empty	
				special_type_slot_7 = aircraft_lightweight_construction_medium				
			}
					icon = "GFX_ENG_heavy_fighter1_medium"
				}
				set_country_flag = ENG_basic_export_heavy_fighter_template #to avoid double templates if this effect is run from different countries
			}
		}
		add_equipment_to_stockpile = {
			type = medium_plane_fighter_airframe_1
			producer = ENG
			amount = heavy_fighter_buy_amount
			variant_name = "Blenheim IF"
		}
	}
	else_if = {
		limit = {
			ENG = {
				has_tech = improved_medium_airframe
				NOT = {
					has_tech = advanced_medium_airframe
				}
			}
		}
		if = {
			limit = {
				ENG = { NOT = { has_country_flag = ENG_improved_export_heavy_fighter_template } }
			}
			ENG = {
				create_equipment_variant = {
					name = "Westland Whirlwind"
					type = medium_plane_fighter_airframe_2
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = aircraft_cannon_1_2x
				fixed_auxiliary_weapon_slot_1 = aircraft_cannon_1_2x
				fixed_auxiliary_weapon_slot_2 = empty
				fixed_auxiliary_weapon_slot_3 = empty
				fixed_auxiliary_weapon_slot_4 = empty				
				fixed_auxiliary_weapon_slot_5 = empty
				fixed_auxiliary_weapon_slot_6 = empty				
				engine_type_slot = engine_3_2x
				special_type_slot_1 = high_octane_fuel_medium
				special_type_slot_2 = self_sealing_fuel_tanks_medium
				special_type_slot_3 = drop_tanks_medium
				special_type_slot_4 = water_injection_medium
				special_type_slot_5 = empty
				special_type_slot_6 = empty
				special_type_slot_7 = empty				
			}
					icon = "GFX_ENG_heavy_fighter2_medium"
				}
				set_country_flag = ENG_improved_export_heavy_fighter_template #to avoid double templates if this effect is run from different countries
			}
		}
		add_equipment_to_stockpile = {
			type = medium_plane_fighter_airframe_2
			producer = ENG
			amount = heavy_fighter_buy_amount
			variant_name = "Westland Whirlwind"
		}
	}
	else_if = {
		limit = {
			ENG = {
				has_tech = advanced_medium_airframe
			}
		}
		if = {
			limit = {
				ENG = { NOT = { has_country_flag = ENG_advanced_export_heavy_fighter_template } }
			}
			ENG = {
				create_equipment_variant = {
					name = "de Havilland Hornet"
					type = medium_plane_fighter_airframe_3
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = aircraft_cannon_1_2x
				fixed_auxiliary_weapon_slot_1 = aircraft_cannon_1_2x
				fixed_auxiliary_weapon_slot_2 = aircraft_cannon_1_2x
				fixed_auxiliary_weapon_slot_3 = empty
				fixed_auxiliary_weapon_slot_4 = empty				
				fixed_auxiliary_weapon_slot_5 = empty
				fixed_auxiliary_weapon_slot_6 = empty				
				engine_type_slot = engine_4_2x
				special_type_slot_1 = drop_tanks_medium
				special_type_slot_2 = self_sealing_fuel_tanks_medium
				special_type_slot_3 = high_octane_fuel_medium
				special_type_slot_4 = supercharger
				special_type_slot_5 = air_air_radar_1
				special_type_slot_6 = water_injection_medium
				special_type_slot_7 = empty				
			}
					icon = "GFX_ENG_heavy_fighter2_medium"
				}
				set_country_flag = ENG_advanced_export_heavy_fighter_template
			}
		}
		add_equipment_to_stockpile = {
			type = medium_plane_fighter_airframe_3
			producer = ENG
			amount = heavy_fighter_buy_amount
			variant_name = "de Havilland Hornet"
		}
	}
}

bba_get_fighter_USA_effect = { #creates a fighter design if necessary and exports a number of them to ROOT
	if = {
		limit = {
			USA = {
				has_tech = basic_small_airframe
				NOT = {
					has_tech = improved_small_airframe
				}
			}
		}
		if = {
			limit = {
				USA = { NOT = { has_country_flag = USA_improved_export_fighter_template } }
			}
			USA = {
				create_equipment_variant = {
					name = "P-36 Hawk"
					type = small_plane_airframe_2
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = heavy_mg_2x
				fixed_auxiliary_weapon_slot_1 = heavy_mg_2x
				fixed_auxiliary_weapon_slot_2 = empty				
				engine_type_slot = radial_engine_2_1x
				special_type_slot_1 = armor_plate_small
				special_type_slot_2 = drop_tanks
				special_type_slot_3 = high_octane_fuel_small
				special_type_slot_4 = self_sealing_fuel_tanks_small
				special_type_slot_5 = empty
			}
					icon = "GFX_USA_fighter1_medium"
				}
				set_country_flag = USA_improved_export_fighter_template #to avoid double templates if this effect is run from different countries
			}
		}		
		add_equipment_to_stockpile = {
			type = small_plane_airframe_1
			producer = USA
			amount = fighter_buy_amount #set before the effect is invoked
			variant_name = "P-36 Hawk"
		}
	}
	else_if = {
		limit = {
			USA = {
				has_tech = improved_small_airframe
				NOT = {
					has_tech = advanced_small_airframe
				}
			}
		}
		if = {
			limit = {
				USA = { NOT = { has_country_flag = USA_improved_export_fighter_template } }
			}
			USA = {
				create_equipment_variant = {
					name = "P-40 Warhawk"
					type = small_plane_airframe_2
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = heavy_mg_4x
				fixed_auxiliary_weapon_slot_1 = heavy_mg_2x
				fixed_auxiliary_weapon_slot_2 = empty	
				fixed_auxiliary_weapon_slot_3 = empty	
				engine_type_slot = engine_3_1x
				special_type_slot_1 = drop_tanks
				special_type_slot_2 = supercharger 
				special_type_slot_3 = high_octane_fuel_small
				special_type_slot_4 = armor_plate_small
				special_type_slot_5 = water_injection_small
				special_type_slot_6 = empty	
			}
					icon = "GFX_USA_fighter2_medium"
				}
				set_country_flag = USA_improved_export_fighter_template #to avoid double templates if this effect is run from different countries
			}
		}
		add_equipment_to_stockpile = {
			type = small_plane_airframe_2
			producer = USA
			amount = fighter_buy_amount
			variant_name = "P-40 Warhawk"
		}
	}
	else_if = {
		limit = {
			USA = {
				has_tech = advanced_small_airframe
			}
		}
		if = {
			limit = {
				USA = { NOT = { has_country_flag = USA_advanced_export_fighter_template } }
			}
			USA = {
				create_equipment_variant = {
					name = "P-51 Mustang"
					type = small_plane_airframe_3
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = heavy_mg_4x
				fixed_auxiliary_weapon_slot_1 = heavy_mg_4x
				fixed_auxiliary_weapon_slot_2 = empty	
				fixed_auxiliary_weapon_slot_3 = empty	
				engine_type_slot = engine_4_1x
				special_type_slot_1 = drop_tanks
				special_type_slot_2 = supercharger 
				special_type_slot_3 = pressurized_cockpit
				special_type_slot_4 = armor_plate_small
				special_type_slot_5 = water_injection_small
				special_type_slot_6 = empty		
			}
					icon = "GFX_USA_fighter3_medium"
				}
				set_country_flag = USA_advanced_export_fighter_template
			}
		}
		add_equipment_to_stockpile = {
			type = small_plane_airframe_3
			producer = USA
			amount = fighter_buy_amount
			variant_name = "P-51 Mustang"
		}
	}
}

bba_get_cas_USA_effect = { #creates a CAS design if necessary and exports a number of them to ROOT
	if = {
		limit = {
			USA = {
				has_tech = basic_small_airframe
				NOT = {
					has_tech = improved_small_airframe
				}
			}
		}
		add_equipment_to_stockpile = {
			type = small_plane_cas_airframe_1
			producer = USA
			amount = cas_buy_amount
			variant_name = "A-17" #set up at game start
		}
	}
	else_if = {
		limit = {
			USA = {
				has_tech = improved_small_airframe
				NOT = {
					has_tech = advanced_small_airframe
				}
			}
		}
		if = {
			limit = {
				USA = { NOT = { has_country_flag = USA_improved_export_cas_template } }
			}
			USA = {
				create_equipment_variant = {
					name = "A-24 Banshee"
					type = small_plane_cas_airframe_2
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = bomb_locks
				fixed_auxiliary_weapon_slot_1 = bomb_locks
				fixed_auxiliary_weapon_slot_2 = bomb_locks
				fixed_auxiliary_weapon_slot_3 = rocket_rails	
				engine_type_slot = radial_engine_3_1x
				special_type_slot_1 = lmg_defense_turret
				special_type_slot_2 = dive_brakes_small
				special_type_slot_3 = armor_plate_small
				special_type_slot_4 = drop_tanks
				special_type_slot_5 = self_sealing_fuel_tanks_small
				special_type_slot_6 = empty		
			}
					icon = "GFX_USA_CAS2_medium"
				}
				set_country_flag = USA_improved_export_cas_template #to avoid double templates if this effect is run from different countries
			}
		}
		add_equipment_to_stockpile = {
			type = small_plane_cas_airframe_2
			producer = USA
			amount = cas_buy_amount
			variant_name = "A-24 Banshee"
		}
	}
	else_if = {
		limit = {
			USA = {
				has_tech = advanced_small_airframe
			}
		}
		if = {
			limit = {
				USA = { NOT = { has_country_flag = USA_advanced_export_cas_template } }
			}
			USA = {
				create_equipment_variant = {
					name = "A-26 Invader"
					type = small_plane_cas_airframe_3
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = small_bomb_bay
				fixed_auxiliary_weapon_slot_1 = bomb_locks
				fixed_auxiliary_weapon_slot_2 = rocket_rails
				fixed_auxiliary_weapon_slot_3 = rocket_rails
				engine_type_slot = radial_engine_4_2x
				special_type_slot_1 = lmg_defense_turret
				special_type_slot_2 = dive_brakes_small
				special_type_slot_3 = armor_plate_small
				special_type_slot_4 = drop_tanks
				special_type_slot_5 = self_sealing_fuel_tanks_small	
				special_type_slot_6 = empty	
			}
					icon = "GFX_USA_CAS3_medium"
				}
				set_country_flag = USA_advanced_export_cas_template
			}
		}
		add_equipment_to_stockpile = {
			type = small_plane_cas_airframe_3
			producer = USA
			amount = cas_buy_amount
			variant_name = "A-26 Invader"
		}
	}
}

bba_get_tac_USA_effect = { #creates a tac design if necessary and exports a number of them to ROOT
	if = {
		limit = {
			USA = {
				has_tech = basic_medium_airframe
				NOT = {
					has_tech = improved_medium_airframe
				}
			}
		}
		add_equipment_to_stockpile = {
			type = medium_plane_airframe_1
			producer = USA
			amount = tac_buy_amount
			variant_name = "B-10" #set up at game start
		}
	}
	else_if = {
		limit = {
			USA = {
				has_tech = improved_medium_airframe
				NOT = {
					has_tech = advanced_medium_airframe
				}
			}
		}
		if = {
			limit = {
				USA = { NOT = { has_country_flag = USA_improved_export_tac_template } }
			}
			USA = {
				create_equipment_variant = {
					name = "B-25 Mitchell" #aka Lockheed Ventura/Lockheed Hudson
					type = medium_plane_airframe_2
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = medium_bomb_bay
				fixed_auxiliary_weapon_slot_1 = medium_bomb_bay
				fixed_auxiliary_weapon_slot_2 = torpedo_mounting
				fixed_auxiliary_weapon_slot_3 = empty
				fixed_auxiliary_weapon_slot_4 = empty
				fixed_auxiliary_weapon_slot_5 = hmg_defense_turret_2x
				fixed_auxiliary_weapon_slot_6 = empty				
				engine_type_slot = radial_engine_3_2x
				special_type_slot_1 = auto_extinguisher_system_medium	
				special_type_slot_2 = self_sealing_fuel_tanks_medium
				special_type_slot_3 = high_octane_fuel_medium
				special_type_slot_4 = armor_plate_medium
				special_type_slot_5 = radio_navigation_2
				special_type_slot_6 = empty	
				special_type_slot_7 = empty				
			}
					icon = "GFX_USA_medium_plane_2_medium"
				}
				set_country_flag = USA_improved_export_tac_template #to avoid double templates if this effect is run from different countries
			}
		}
		add_equipment_to_stockpile = {
			type = medium_plane_airframe_2
			producer = USA
			amount = tac_buy_amount
			variant_name = "B-25 Mitchell"
		}
	}
	else_if = {
		limit = {
			USA = {
				has_tech = advanced_medium_airframe
			}
		}
		if = {
			limit = {
				USA = { NOT = { has_country_flag = USA_advanced_export_tac_template } }
			}
			USA = {
				create_equipment_variant = {
					name = "B-26 Marauder"
					type = medium_plane_airframe_3
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = medium_bomb_bay
				fixed_auxiliary_weapon_slot_1 = medium_bomb_bay
				fixed_auxiliary_weapon_slot_2 = torpedo_mounting
				fixed_auxiliary_weapon_slot_3 = empty
				fixed_auxiliary_weapon_slot_4 = empty
				fixed_auxiliary_weapon_slot_5 = hmg_defense_turret_2x
				fixed_auxiliary_weapon_slot_6 = empty				
				engine_type_slot = radial_engine_4_2x
				special_type_slot_1 = auto_extinguisher_system_medium
				special_type_slot_2 = self_sealing_fuel_tanks_medium
				special_type_slot_3 = high_octane_fuel_medium
				special_type_slot_4 = armor_plate_medium
				special_type_slot_5 = radio_navigation_2
				special_type_slot_6 = empty	
				special_type_slot_7 = empty				
			}
					icon = "GFX_USA_tactical_bomber3_medium"
				}
				set_country_flag = USA_advanced_export_tac_template
			}
		}
		add_equipment_to_stockpile = {
			type = medium_plane_airframe_3
			producer = USA
			amount = tac_buy_amount
			variant_name = "B-26 Marauder"
		}
	}
}

bba_get_heavy_fighter_USA_effect = { #creates a heavy_fighter design if necessary and exports a number of them to ROOT
	if = {
		limit = {
			USA = {
				has_tech = basic_medium_airframe
				NOT = {
					has_tech = improved_medium_airframe
				}
			}
		}
		if = {
			limit = {
				USA = { NOT = { has_country_flag = USA_basic_export_heavy_fighter_template } }
			}
			USA = {
				create_equipment_variant = {
					name = "Bell FM-1 Airacuda"
					type = medium_plane_fighter_airframe_1
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = heavy_mg_4x
				fixed_auxiliary_weapon_slot_1 = heavy_mg_4x
				fixed_auxiliary_weapon_slot_2 = empty
				fixed_auxiliary_weapon_slot_3 = empty
				fixed_auxiliary_weapon_slot_4 = empty
				fixed_auxiliary_weapon_slot_5 = empty
				fixed_auxiliary_weapon_slot_6 = empty				
				engine_type_slot = engine_2_2x
				special_type_slot_1 = armor_plate_medium
				special_type_slot_2 = high_octane_fuel_medium
				special_type_slot_3 = drop_tanks_medium
				special_type_slot_4 = self_sealing_fuel_tanks_medium
				special_type_slot_5 = empty
				special_type_slot_6 = empty	
			}
					icon = "GFX_USA_heavy_fighter1_medium"
				}
				set_country_flag = USA_basic_export_heavy_fighter_template #to avoid double templates if this effect is run from different countries
			}
		}
		add_equipment_to_stockpile = {
			type = medium_plane_fighter_airframe_1
			producer = USA
			amount = heavy_fighter_buy_amount
			variant_name = "Bell FM-1 Airacuda"
		}
	}
	else_if = {
		limit = {
			USA = {
				has_tech = improved_medium_airframe
				NOT = {
					has_tech = advanced_medium_airframe
				}
			}
		}
		if = {
			limit = {
				USA = { NOT = { has_country_flag = USA_improved_export_heavy_fighter_template } }
			}
			USA = {
				create_equipment_variant = {
					name = "P-38 Lightning"
					type = medium_plane_fighter_airframe_2
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = heavy_mg_4x
				fixed_auxiliary_weapon_slot_1 = heavy_mg_4x
				fixed_auxiliary_weapon_slot_2 = aircraft_cannon_1_1x
				fixed_auxiliary_weapon_slot_3 = empty
				fixed_auxiliary_weapon_slot_4 = empty
				fixed_auxiliary_weapon_slot_5 = empty
				fixed_auxiliary_weapon_slot_6 = empty				
				engine_type_slot = engine_3_2x
				special_type_slot_1 = armor_plate_medium
				special_type_slot_2 = supercharger
				special_type_slot_3 = drop_tanks_medium
				special_type_slot_4 = self_sealing_fuel_tanks_medium
				special_type_slot_5 = high_octane_fuel_medium
				special_type_slot_6 = water_injection_medium
				special_type_slot_7 = aircraft_lightweight_construction_medium				
			}
					icon = "GFX_USA_medium_plane_3_medium"
				}
				set_country_flag = USA_improved_export_heavy_fighter_template #to avoid double templates if this effect is run from different countries
			}
		}
		add_equipment_to_stockpile = {
			type = medium_plane_fighter_airframe_2
			producer = USA
			amount = heavy_fighter_buy_amount
			variant_name = "P-38 Lightning"
		}
	}
	else_if = {
		limit = {
			USA = {
				has_tech = advanced_medium_airframe
			}
		}
		if = {
			limit = {
				USA = { NOT = { has_country_flag = USA_advanced_export_heavy_fighter_template } }
			}
			USA = {
				create_equipment_variant = {
					name = "P-61 Black Widow"
					type = medium_plane_fighter_airframe_3
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = heavy_mg_4x
				fixed_auxiliary_weapon_slot_1 = heavy_mg_4x
				fixed_auxiliary_weapon_slot_2 = heavy_mg_4x
				fixed_auxiliary_weapon_slot_3 = empty
				fixed_auxiliary_weapon_slot_4 = empty
				fixed_auxiliary_weapon_slot_5 = empty
				fixed_auxiliary_weapon_slot_6 = empty				
				engine_type_slot = engine_4_2x
				special_type_slot_1 = armor_plate_medium
				special_type_slot_2 = supercharger
				special_type_slot_3 = drop_tanks_medium
				special_type_slot_4 = self_sealing_fuel_tanks_medium
				special_type_slot_5 = high_octane_fuel_medium
				special_type_slot_6 = water_injection_medium
				special_type_slot_7 = empty				
			}
					icon = "GFX_USA_heavy_fighter3_medium"
				}
				set_country_flag = USA_advanced_export_heavy_fighter_template
			}
		}
		add_equipment_to_stockpile = {
			type = medium_plane_fighter_airframe_3
			producer = USA
			amount = heavy_fighter_buy_amount
			variant_name = "P-61 Black Widow"
		}
	}
}
bba_get_fighter_ITA_effect = { #creates a fighter design if necessary and exports a number of them to ROOT
	if = {
		limit = {
			ITA = {
				NOT = {
					has_tech = basic_small_airframe
				}
			}
		}
		add_equipment_to_stockpile = {
			type = small_plane_airframe_0
			producer = ITA
			amount = fighter_buy_amount #set before the effect is invoked
			variant_name = "CR.32"
		}
	}
	else_if = {
		limit = {
			ITA = {
				has_tech = basic_small_airframe
				NOT = {
					has_tech = improved_small_airframe
				}
			}
		}
		if = {
			limit = {
				ITA = { NOT = { has_country_flag = ITA_improved_export_fighter_template } }
			}
			ITA = {
				create_equipment_variant = {
					name = "C.200 «Saetta»"
					type = small_plane_airframe_1
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = light_mg_4x
				fixed_auxiliary_weapon_slot_1 = light_mg_4x
				fixed_auxiliary_weapon_slot_2 = empty					
				engine_type_slot = radial_engine_2_1x
				special_type_slot_1 = armor_plate_small
				special_type_slot_2 = fuel_tanks_small
				special_type_slot_3 = high_octane_fuel_small
				special_type_slot_4 = self_sealing_fuel_tanks_small
				special_type_slot_5 = empty				
				
			}
				}
				set_country_flag = ITA_improved_export_fighter_template #to avoid double templates if this effect is run from different countries
			}
		}
		add_equipment_to_stockpile = {
			type = small_plane_airframe_1
			producer = ITA
			amount = fighter_buy_amount
			variant_name = "C.200 «Saetta»"
		}
	}	
	else_if = {
		limit = {
			ITA = {
				has_tech = improved_small_airframe
				NOT = {
					has_tech = advanced_small_airframe
				}
			}
		}
		if = {
			limit = {
				ITA = { NOT = { has_country_flag = ITA_improved_export_fighter_template } }
			}
			ITA = {
				create_equipment_variant = {
					name = "C.202 Folgore"
					type = small_plane_airframe_2
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = heavy_mg_2x
				fixed_auxiliary_weapon_slot_1 = heavy_mg_2x
				fixed_auxiliary_weapon_slot_2 = empty
				fixed_auxiliary_weapon_slot_3 = empty	
				engine_type_slot = engine_3_1x
				special_type_slot_1 = drop_tanks
				special_type_slot_2 = supercharger
				special_type_slot_3 = high_octane_fuel_small
				special_type_slot_4 = armor_plate_small
				special_type_slot_5 = self_sealing_fuel_tanks_small	
				special_type_slot_6 = empty
			}
				}
				set_country_flag = ITA_improved_export_fighter_template #to avoid double templates if this effect is run from different countries
			}
		}
		add_equipment_to_stockpile = {
			type = small_plane_airframe_2
			producer = ITA
			amount = fighter_buy_amount
			variant_name = "C.202 Folgore"
		}
	}
	else_if = {
		limit = {
			ITA = {
				has_tech = advanced_small_airframe
			}
		}
		if = {
			limit = {
				ITA = { NOT = { has_country_flag = ITA_advanced_export_fighter_template } }
			}
			ITA = {
				create_equipment_variant = {
					name = "G.55 Centauro"
					type = small_plane_airframe_3
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = aircraft_cannon_1_2x
				fixed_auxiliary_weapon_slot_1 = aircraft_cannon_1_2x
				fixed_auxiliary_weapon_slot_2 = empty	
				fixed_auxiliary_weapon_slot_3 = empty				
				engine_type_slot = engine_4_1x
				special_type_slot_1 = drop_tanks
				special_type_slot_2 = supercharger 
				special_type_slot_3 = pressurized_cockpit
				special_type_slot_4 = armor_plate_small
				special_type_slot_5 = water_injection_small	
				special_type_slot_6 = empty				
			}
					icon = "GFX_ITA_fighter3_medium"
				}
				set_country_flag = ITA_advanced_export_fighter_template
			}
		}
		add_equipment_to_stockpile = {
			type = small_plane_airframe_3
			producer = ITA
			amount = fighter_buy_amount
			variant_name = "G.55 Centauro"
		}
	}
}

bba_get_cas_ITA_effect = { #creates a CAS design if necessary and exports a number of them to ROOT
	if = {
		limit = {
			ITA = {
				has_tech = basic_small_airframe
				NOT = {
					has_tech = improved_small_airframe
				}
			}
		}
		add_equipment_to_stockpile = {
			type = small_plane_cas_airframe_1
			producer = ITA
			amount = cas_buy_amount
			variant_name = "Ba.65" #set up at game start
		}
	}
	else_if = {
		limit = {
			ITA = {
				has_tech = improved_small_airframe
				NOT = {
					has_tech = advanced_small_airframe
				}
			}
		}
		if = {
			limit = {
				ITA = { NOT = { has_country_flag = ITA_improved_export_cas_template } }
			}
			ITA = {
				create_equipment_variant = {
					name = "Ba.88"
					type = small_plane_cas_airframe_2
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = small_bomb_bay
				fixed_auxiliary_weapon_slot_1 = bomb_locks
				fixed_auxiliary_weapon_slot_2 = bomb_locks
				fixed_auxiliary_weapon_slot_3 = empty		
				engine_type_slot = radial_engine_2_2x
				special_type_slot_1 = lmg_defense_turret
				special_type_slot_2 = dive_brakes_small
				special_type_slot_3 = armor_plate_small
				special_type_slot_4 = drop_tanks
				special_type_slot_5 = self_sealing_fuel_tanks_small
				special_type_slot_6 = empty				
			}
					icon = "GFX_ITA_CAS2_medium"
				}
				set_country_flag = ITA_improved_export_cas_template #to avoid double templates if this effect is run from different countries
			}
		}
		add_equipment_to_stockpile = {
			type = small_plane_cas_airframe_2
			producer = ITA
			amount = cas_buy_amount
			variant_name = "Ba.88"
		}
	}
	else_if = {
		limit = {
			ITA = {
				has_tech = advanced_small_airframe
			}
		}
		if = {
			limit = {
				ITA = { NOT = { has_country_flag = ITA_advanced_export_cas_template } }
			}
			ITA = {
				create_equipment_variant = {
					name = "Ba.201"
					type = small_plane_cas_airframe_3
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = bomb_locks
				fixed_auxiliary_weapon_slot_1 = tank_buster_2
				fixed_auxiliary_weapon_slot_2 = bomb_locks
				fixed_auxiliary_weapon_slot_3 = empty
				engine_type_slot = engine_3_1x
				special_type_slot_1 = lmg_defense_turret
				special_type_slot_2 = dive_brakes_small
				special_type_slot_3 = armor_plate_small
				special_type_slot_4 = drop_tanks
				special_type_slot_5 = self_sealing_fuel_tanks_small	
				special_type_slot_6 = empty				
			}
					icon = "GFX_ITA_CAS3_medium"
				}
				set_country_flag = ITA_advanced_export_cas_template
			}
		}
		add_equipment_to_stockpile = {
			type = small_plane_cas_airframe_3
			producer = ITA
			amount = cas_buy_amount
			variant_name = "Ba.201"
		}
	}
}

bba_get_tac_ITA_effect = { #creates a tac design if necessary and exports a number of them to ROOT
	if = {
		limit = {
			ITA = {
				has_tech = basic_medium_airframe
				NOT = {
					has_tech = improved_medium_airframe
				}
			}
		}
		add_equipment_to_stockpile = {
			type = medium_plane_airframe_1
			producer = ITA
			amount = tac_buy_amount
			variant_name = "SM.79" #set up at game start
		}
	}
	else_if = {
		limit = {
			ITA = {
				has_tech = improved_medium_airframe
				NOT = {
					has_tech = advanced_medium_airframe
				}
			}
		}
		if = {
			limit = {
				ITA = { NOT = { has_country_flag = ITA_improved_export_tac_template } }
			}
			ITA = {
				create_equipment_variant = {
					name = "Z.1007 «Alcione»"
					type = medium_plane_airframe_2
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = medium_bomb_bay
				fixed_auxiliary_weapon_slot_1 = medium_bomb_bay
				fixed_auxiliary_weapon_slot_2 = empty
				fixed_auxiliary_weapon_slot_3 = empty
				fixed_auxiliary_weapon_slot_4 = empty
				fixed_auxiliary_weapon_slot_5 = lmg_defense_turret_2x
				fixed_auxiliary_weapon_slot_6 = empty					
				engine_type_slot = radial_engine_2_3x
				special_type_slot_1 = radio_navigation_1
				special_type_slot_2 = dive_brakes_medium
				special_type_slot_3 = high_octane_fuel_medium
				special_type_slot_4 = non_strategic_materials_medium
				special_type_slot_5 = empty
				special_type_slot_6 = empty
				special_type_slot_7 = empty				
			}
					icon = "GFX_ITA_tactical_bomber2_medium"
				}
				set_country_flag = ITA_improved_export_tac_template #to avoid double templates if this effect is run from different countries
			}
		}
		add_equipment_to_stockpile = {
			type = medium_plane_airframe_2
			producer = ITA
			amount = tac_buy_amount
			variant_name = "Z.1007 «Alcione»"
		}
	}
	else_if = {
		limit = {
			ITA = {
				has_tech = advanced_medium_airframe
			}
		}
		if = {
			limit = {
				ITA = { NOT = { has_country_flag = ITA_advanced_export_tac_template } }
			}
			ITA = {
				create_equipment_variant = {
					name = "Z.1018 Leone"
					type = medium_plane_airframe_3
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = medium_bomb_bay
				fixed_auxiliary_weapon_slot_1 = medium_bomb_bay
				fixed_auxiliary_weapon_slot_2 = empty	
				fixed_auxiliary_weapon_slot_3 = empty
				fixed_auxiliary_weapon_slot_4 = empty
				fixed_auxiliary_weapon_slot_5 = hmg_defense_turret_2x
				fixed_auxiliary_weapon_slot_6 = empty	
				engine_type_slot = radial_engine_3_2x
				special_type_slot_1 = radio_navigation_2
				special_type_slot_2 = dive_brakes_medium
				special_type_slot_3 = high_octane_fuel_medium
				special_type_slot_4 = non_strategic_materials_medium
				special_type_slot_5 = empty	
				special_type_slot_6 = empty	
				special_type_slot_7 = empty				
			}
					icon = "GFX_ITA_tactical_bomber3_medium"
				}
				set_country_flag = ITA_advanced_export_tac_template
			}
		}
		add_equipment_to_stockpile = {
			type = medium_plane_airframe_3
			producer = ITA
			amount = tac_buy_amount
			variant_name = "Z.1018 Leone"
		}
	}
}

bba_get_heavy_fighter_ITA_effect = { #creates a heavy_fighter design if necessary and exports a number of them to ROOT
	if = {
		limit = {
			ITA = {
				has_tech = basic_medium_airframe
				NOT = {
					has_tech = improved_medium_airframe
				}
			}
		}
		if = {
			limit = {
				ITA = { NOT = { has_country_flag = ITA_basic_export_heavy_fighter_template } }
			}
			ITA = {
				create_equipment_variant = {
					name = "IMAM Ro.57"
					type = medium_plane_fighter_airframe_1
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = light_mg_4x
				fixed_auxiliary_weapon_slot_1 = aircraft_cannon_1_2x
				fixed_auxiliary_weapon_slot_2 = empty
				fixed_auxiliary_weapon_slot_3 = empty
				fixed_auxiliary_weapon_slot_4 = empty
				fixed_auxiliary_weapon_slot_5 = lmg_defense_turret_2x
				fixed_auxiliary_weapon_slot_6 = empty				
				engine_type_slot = engine_2_2x
				special_type_slot_1 = armor_plate_medium
				special_type_slot_2 = self_sealing_fuel_tanks_medium
				special_type_slot_3 = high_octane_fuel_medium
				special_type_slot_4 = empty
				special_type_slot_5 = empty
				special_type_slot_6 = empty
				special_type_slot_7 = empty
			}
					icon = "GFX_ITA_heavy_fighter1_medium"
				}
				set_country_flag = ITA_basic_export_heavy_fighter_template #to avoid double templates if this effect is run from different countries
			}
		}
		add_equipment_to_stockpile = {
			type = medium_plane_fighter_airframe_1
			producer = ITA
			amount = heavy_fighter_buy_amount
			variant_name = "IMAM Ro.57"
		}
	}
	else_if = {
		limit = {
			ITA = {
				has_tech = improved_medium_airframe
				NOT = {
					has_tech = advanced_medium_airframe
				}
			}
		}
		if = {
			limit = {
				ITA = { NOT = { has_country_flag = ITA_improved_export_heavy_fighter_template } }
			}
			ITA = {
				create_equipment_variant = {
					name = "IMAM Ro.58"
					type = medium_plane_fighter_airframe_2
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = aircraft_cannon_1_2x
				fixed_auxiliary_weapon_slot_1 = aircraft_cannon_1_2x
				fixed_auxiliary_weapon_slot_2 = empty
				fixed_auxiliary_weapon_slot_3 = empty
				fixed_auxiliary_weapon_slot_4 = empty
				fixed_auxiliary_weapon_slot_5 = lmg_defense_turret_2x
				fixed_auxiliary_weapon_slot_6 = empty				
				engine_type_slot = engine_3_2x
				special_type_slot_1 = water_injection_medium
				special_type_slot_2 = self_sealing_fuel_tanks_medium
				special_type_slot_3 = armor_plate_medium
				special_type_slot_4 = supercharger
				special_type_slot_5 = air_air_radar_1
				special_type_slot_6 = empty 
			    special_type_slot_7 = empty
			}
					icon = "GFX_ITA_heavy_fighter2_medium"
				}
				set_country_flag = ITA_improved_export_heavy_fighter_template #to avoid double templates if this effect is run from different countries
			}
		}
		add_equipment_to_stockpile = {
			type = medium_plane_fighter_airframe_2
			producer = ITA
			amount = heavy_fighter_buy_amount
			variant_name = "IMAM Ro.58"
		}
	}
	else_if = {
		limit = {
			ITA = {
				has_tech = advanced_medium_airframe
			}
		}
		if = {
			limit = {
				ITA = { NOT = { has_country_flag = ITA_advanced_export_heavy_fighter_template } }
			}
			ITA = {
				create_equipment_variant = {
					name = "Savoia-Marchetti SM.91"
					type = medium_plane_fighter_airframe_3
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = aircraft_cannon_1_2x
				fixed_auxiliary_weapon_slot_1 = aircraft_cannon_1_2x
				fixed_auxiliary_weapon_slot_2 = aircraft_cannon_1_2x
				fixed_auxiliary_weapon_slot_3 = empty
				fixed_auxiliary_weapon_slot_4 = empty
				fixed_auxiliary_weapon_slot_5 = empty
				fixed_auxiliary_weapon_slot_6 = empty				
				engine_type_slot = engine_4_2x
				special_type_slot_1 = water_injection_medium
				special_type_slot_2 = self_sealing_fuel_tanks_medium
				special_type_slot_3 = high_octane_fuel_medium
				special_type_slot_4 = supercharger
				special_type_slot_5 = air_air_radar_1
				special_type_slot_6 = empty
				special_type_slot_7 = empty
			}
					icon = "GFX_ITA_heavy_fighter3_medium"
				}
				set_country_flag = ITA_advanced_export_heavy_fighter_template
			}
		}
		add_equipment_to_stockpile = {
			type = medium_plane_fighter_airframe_3
			producer = ITA
			amount = heavy_fighter_buy_amount
			variant_name = "Savoia-Marchetti SM.91"
		}
	}
}

bba_get_fighter_FRA_effect = { #creates a fighter design if necessary and exports a number of them to ROOT
	if = {
		limit = {
			FRA = {
				NOT = {
					has_tech = basic_small_airframe
				}
			}
		}
		add_equipment_to_stockpile = {
			type = small_plane_airframe_0
			producer = FRA
			amount = fighter_buy_amount #set before the effect is invoked
			variant_name = "D.510"
		}
	}
	if = {
		limit = {
			FRA = {
				has_tech = basic_small_airframe
				NOT = {
					has_tech = improved_small_airframe
				}
			}
		}
		if = {
			limit = {
				FRA = { NOT = { has_country_flag = FRA_basic_export_fighter_template } }
			}
			create_equipment_variant = {
				name = "MS. 406" #
				type = small_plane_airframe_1
				allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = aircraft_engine_mounted_cannon_1
				fixed_auxiliary_weapon_slot_1 = light_mg_4x
				fixed_auxiliary_weapon_slot_2 = empty					
				engine_type_slot = engine_2_1x
				special_type_slot_1 = armor_plate_small
				special_type_slot_2 = drop_tanks
				special_type_slot_3 = high_octane_fuel_small
				special_type_slot_4 = self_sealing_fuel_tanks_small
				special_type_slot_5 = empty	
				special_type_slot_6 = empty	
				special_type_slot_7 = empty
				special_type_slot_8 = empty				
				
			}
				icon = "GFX_FRA_fighter1_medium"
			}
			set_country_flag = FRA_basic_export_fighter_template #to avoid double templates if this effect is run from different countries
		}
		add_equipment_to_stockpile = {
			type = small_plane_airframe_1
			producer = FRA
			amount = fighter_buy_amount #set before the effect is invoked
			variant_name = "MS. 406"
		}
	}
	else_if = {
		limit = {
			FRA = {
				has_tech = improved_small_airframe
				NOT = {
					has_tech = advanced_small_airframe
				}
			}
		}
		if = {
			limit = {
				FRA = { NOT = { has_country_flag = FRA_improved_export_fighter_template } }
			}
			FRA = {
				create_equipment_variant = {
					name = "D.520" #
					type = small_plane_airframe_2
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = aircraft_cannon_1_2x
				fixed_auxiliary_weapon_slot_1 = light_mg_2x
				fixed_auxiliary_weapon_slot_2 = empty
				fixed_auxiliary_weapon_slot_3 = empty	
				engine_type_slot = engine_3_1x
				special_type_slot_1 = drop_tanks
				special_type_slot_2 = supercharger
				special_type_slot_3 = water_injection_small
				special_type_slot_4 = armor_plate_small
				special_type_slot_5 = pressurized_cockpit	
				special_type_slot_6 = high_octane_fuel_small
				special_type_slot_7 = empty
				special_type_slot_8 = empty				
			}
					icon = "GFX_FRA_fighter2_medium"
				}
				set_country_flag = FRA_improved_export_fighter_template #to avoid double templates if this effect is run from different countries
			}
		}
		add_equipment_to_stockpile = {
			type = small_plane_airframe_2
			producer = FRA
			amount = fighter_buy_amount
			variant_name = "D.520"
		}
	}
	else_if = {
		limit = {
			FRA = {
				has_tech = advanced_small_airframe
			}
		}
		if = {
			limit = {
				FRA = { NOT = { has_country_flag = FRA_advanced_export_fighter_template } }
			}
			FRA = {
				create_equipment_variant = {
					name = "SE.580"
					type = small_plane_airframe_3
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = aircraft_cannon_1_2x
				fixed_auxiliary_weapon_slot_1 = aircraft_cannon_1_2x
				fixed_auxiliary_weapon_slot_2 = empty	
				fixed_auxiliary_weapon_slot_3 = empty				
				engine_type_slot = engine_4_1x
				special_type_slot_1 = drop_tanks
				special_type_slot_2 = supercharger 
				special_type_slot_3 = pressurized_cockpit
				special_type_slot_4 = armor_plate_small
				special_type_slot_5 = water_injection_small	
				special_type_slot_6 = high_octane_fuel_small
				special_type_slot_7 = empty
				special_type_slot_8 = empty				
			}
				}
				set_country_flag = FRA_advanced_export_fighter_template
			}
		}
		add_equipment_to_stockpile = {
			type = small_plane_airframe_3
			producer = FRA
			amount = fighter_buy_amount
			variant_name = "SE.580"
		}
	}
}

bba_get_cas_FRA_effect = { #creates a CAS design if necessary and exports a number of them to ROOT
	if = {
		limit = {
			FRA = {
				NOT = {
					has_tech = improved_small_airframe
				}
			}
		}
		add_equipment_to_stockpile = {
			type = small_plane_cas_airframe_0
			producer = FRA
			amount = cas_buy_amount
			variant_name = "Br.19" #set up at game start
		}
	}
	else_if = {
		limit = {
			FRA = {
				has_tech = improved_small_airframe
				NOT = {
					has_tech = advanced_small_airframe
				}
			}
		}
		if = {
			limit = {
				FRA = { NOT = { has_country_flag = FRA_improved_export_cas_template } }
			}
			FRA = {
				create_equipment_variant = {
					name = "Br. 693" #
					type = small_plane_cas_airframe_2
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = bomb_locks
				fixed_auxiliary_weapon_slot_1 = empty
				fixed_auxiliary_weapon_slot_2 = empty

				engine_type_slot = engine_2_1x
				special_type_slot_1 = lmg_defense_turret
				special_type_slot_2 = dive_brakes_small
				special_type_slot_3 = drop_tanks
				special_type_slot_4 = armor_plate_small
				special_type_slot_5 = aerodynamic_pylons_small
				special_type_slot_6 = empty	
				special_type_slot_7 = empty
				special_type_slot_8 = empty		
			}
					icon = "GFX_FRA_CAS2_medium"
				}
				set_country_flag = FRA_improved_export_cas_template #to avoid double templates if this effect is run from different countries
			}
		}
		add_equipment_to_stockpile = {
			type = small_plane_cas_airframe_2
			producer = FRA
			amount = cas_buy_amount
			variant_name = "Br. 693"
		}
	}
	else_if = {
		limit = {
			FRA = {
				has_tech = advanced_small_airframe
			}
		}
		if = {
			limit = {
				FRA = { NOT = { has_country_flag = FRA_advanced_export_cas_template } }
			}
			FRA = {
				create_equipment_variant = {
					name = "MB. 174"
					type = small_plane_cas_airframe_3
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = bomb_locks
				fixed_auxiliary_weapon_slot_1 = tank_buster_1
				fixed_auxiliary_weapon_slot_2 = bomb_locks
				fixed_auxiliary_weapon_slot_3 = empty		
				engine_type_slot = engine_3_1x
				special_type_slot_1 = lmg_defense_turret
				special_type_slot_2 = dive_brakes_small
				special_type_slot_3 = armor_plate_small
				special_type_slot_4 = drop_tanks
				special_type_slot_5 = aerodynamic_pylons_small
				special_type_slot_6 = aerodynamic_pylons_small
				special_type_slot_7 = empty
				special_type_slot_8 = empty				
			}
					icon = "GFX_FRA_heavy_fighter1_medium"
				}
				set_country_flag = FRA_advanced_export_cas_template
			}
		}
		add_equipment_to_stockpile = {
			type = small_plane_cas_airframe_3
			producer = FRA
			amount = cas_buy_amount
			variant_name = "MB. 174"
		}
	}
}

bba_get_tac_FRA_effect = { #creates a tac design if necessary and exports a number of them to ROOT
	if = {
		limit = {
			FRA = {
				NOT = {
					has_tech = improved_medium_airframe
				}
			}
		}
		add_equipment_to_stockpile = {
			type = medium_plane_airframe_0
			producer = FRA
			amount = tac_buy_amount
			variant_name = "Amiot 143" #set up at game start
		}
	}
	else_if = {
		limit = {
			FRA = {
				has_tech = improved_medium_airframe
				NOT = {
					has_tech = advanced_medium_airframe
				}
			}
		}
		if = {
			limit = {
				FRA = { NOT = { has_country_flag = FRA_improved_export_tac_template } }
			}
			FRA = {
				create_equipment_variant = {
					name = "LeO 451" #
					type = medium_plane_airframe_2
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = medium_bomb_bay
				fixed_auxiliary_weapon_slot_1 = medium_bomb_bay
				fixed_auxiliary_weapon_slot_2 = empty
				fixed_auxiliary_weapon_slot_3 = empty
				fixed_auxiliary_weapon_slot_4 = empty
				fixed_auxiliary_weapon_slot_5 = lmg_defense_turret_2x
				fixed_auxiliary_weapon_slot_6 = empty				
				engine_type_slot = engine_3_2x
				special_type_slot_1 = radio_navigation_1
				special_type_slot_2 = dive_brakes_medium
				special_type_slot_3 = auto_extinguisher_system_medium
				special_type_slot_4 = armor_plate_medium
				special_type_slot_5 = empty
				special_type_slot_6 = empty	
				special_type_slot_7 = empty	
			}
					icon = "GFX_FRA_tactical_bomber2_medium"
				}
				set_country_flag = FRA_improved_export_tac_template #to avoid double templates if this effect is run from different countries
			}
		}
		add_equipment_to_stockpile = {
			type = medium_plane_airframe_2
			producer = FRA
			amount = tac_buy_amount
			variant_name = "LeO 451"
		}
	}
	else_if = {
		limit = {
			FRA = {
				has_tech = advanced_medium_airframe
			}
		}
		if = {
			limit = {
				FRA = { NOT = { has_country_flag = FRA_advanced_export_tac_template } }
			}
			FRA = {
				create_equipment_variant = {
					name = "NC.150"
					type = medium_plane_airframe_3
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = medium_bomb_bay
				fixed_auxiliary_weapon_slot_1 = medium_bomb_bay
				fixed_auxiliary_weapon_slot_2 = torpedo_mounting
				fixed_auxiliary_weapon_slot_3 = empty
				fixed_auxiliary_weapon_slot_4 = empty
				fixed_auxiliary_weapon_slot_5 = lmg_defense_turret_2x
				fixed_auxiliary_weapon_slot_6 = empty
				engine_type_slot = engine_4_2x
				special_type_slot_1 = radio_navigation_1
				special_type_slot_2 = dive_brakes_medium
				special_type_slot_3 = high_octane_fuel_medium
				special_type_slot_4 = auto_extinguisher_system_medium
				special_type_slot_5 = armor_plate_medium
				special_type_slot_6 = empty
				special_type_slot_7 = empty					
			}
					icon = "GFX_FRA_tactical_bomber3_medium"
				}
				set_country_flag = FRA_advanced_export_tac_template
			}
		}
		add_equipment_to_stockpile = {
			type = medium_plane_airframe_3
			producer = FRA
			amount = tac_buy_amount
			variant_name = "NC.150"
		}
	}
}

bba_get_heavy_fighter_FRA_effect = { #creates a heavy_fighter design if necessary and exports a number of them to ROOT
	if = {
		limit = {
			FRA = {
				has_tech = basic_medium_airframe
				NOT = {
					has_tech = improved_medium_airframe
				}
			}
		}
		if = {
			limit = {
				FRA = { NOT = { has_country_flag = FRA_basic_export_heavy_fighter_template } }
			}
			FRA = {
				create_equipment_variant = {
					name = "Potez 631" #
					type = medium_plane_fighter_airframe_1
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = light_mg_4x
				fixed_auxiliary_weapon_slot_1 = aircraft_cannon_1_2x
				fixed_auxiliary_weapon_slot_2 = empty
				fixed_auxiliary_weapon_slot_3 = empty
				fixed_auxiliary_weapon_slot_4 = empty
				fixed_auxiliary_weapon_slot_5 = lmg_defense_turret_2x
				fixed_auxiliary_weapon_slot_6 = empty				
				engine_type_slot = engine_2_2x
				special_type_slot_1 = drop_tanks_medium
				special_type_slot_2 = self_sealing_fuel_tanks_medium
				special_type_slot_3 = high_octane_fuel_medium
				special_type_slot_4 = empty
				special_type_slot_5 = empty
				special_type_slot_6 = empty
				special_type_slot_7 = empty
			}
					icon = "GFX_FRA_heavy_fighter1_medium"
				}
				set_country_flag = FRA_basic_export_heavy_fighter_template #to avoid double templates if this effect is run from different countries
			}
		}
		add_equipment_to_stockpile = {
			type = medium_plane_fighter_airframe_1
			producer = FRA
			amount = heavy_fighter_buy_amount
			variant_name = "Potez 631"
		}
	}
	else_if = {
		limit = {
			FRA = {
				has_tech = improved_medium_airframe
				NOT = {
					has_tech = advanced_medium_airframe
				}
			}
		}
		if = {
			limit = {
				FRA = { NOT = { has_country_flag = FRA_improved_export_heavy_fighter_template } }
			}
			FRA = {
				create_equipment_variant = {
					name = "SE.100"
					type = medium_plane_fighter_airframe_2
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = aircraft_cannon_1_2x
				fixed_auxiliary_weapon_slot_1 = aircraft_cannon_1_2x
				fixed_auxiliary_weapon_slot_2 = empty
				fixed_auxiliary_weapon_slot_3 = empty
				fixed_auxiliary_weapon_slot_4 = empty
				fixed_auxiliary_weapon_slot_5 = lmg_defense_turret_2x
				fixed_auxiliary_weapon_slot_6 = empty								
				engine_type_slot = engine_3_2x
				special_type_slot_1 = water_injection_medium
				special_type_slot_2 = self_sealing_fuel_tanks_medium
				special_type_slot_3 = armor_plate_medium
				special_type_slot_4 = supercharger
				special_type_slot_5 = air_air_radar_1
				special_type_slot_6 = empty
				special_type_slot_7 = empty
			}
					icon = "GFX_FRA_medium_plane_1_medium"
				}
				set_country_flag = FRA_improved_export_heavy_fighter_template #to avoid double templates if this effect is run from different countries
			}
		}
		add_equipment_to_stockpile = {
			type = medium_plane_fighter_airframe_2
			producer = FRA
			amount = heavy_fighter_buy_amount
			variant_name = "SE.100"
		}
	}
	else_if = {
		limit = {
			FRA = {
				has_tech = advanced_medium_airframe
			}
		}
		if = {
			limit = {
				FRA = { NOT = { has_country_flag = FRA_advanced_export_heavy_fighter_template } }
			}
			FRA = {
				create_equipment_variant = {
					name = "SE.255" #fictional
					type = medium_plane_fighter_airframe_3
					allow_without_tech = yes #Makes no difference since effect requires appropriate tech (above), but it improves tooltip
			modules = {
				fixed_main_weapon_slot = aircraft_cannon_1_2x
				fixed_auxiliary_weapon_slot_1 = aircraft_cannon_1_2x
				fixed_auxiliary_weapon_slot_2 = empty
				fixed_auxiliary_weapon_slot_3 = empty
				fixed_auxiliary_weapon_slot_4 = empty
				fixed_auxiliary_weapon_slot_5 = hmg_defense_turret_2x
				fixed_auxiliary_weapon_slot_6 = empty				
				engine_type_slot = engine_3_2x
				special_type_slot_1 = water_injection_medium
				special_type_slot_2 = self_sealing_fuel_tanks_medium
				special_type_slot_3 = armor_plate_medium
				special_type_slot_4 = supercharger
				special_type_slot_5 = high_octane_fuel_medium
				special_type_slot_6 = empty
				special_type_slot_7 = empty
			}
					icon = "GFX_FRA_heavy_fighter3_medium"
				}
				set_country_flag = FRA_advanced_export_heavy_fighter_template
			}
		}
		add_equipment_to_stockpile = {
			type = medium_plane_fighter_airframe_3
			producer = FRA
			amount = heavy_fighter_buy_amount
			variant_name = "SE.255"
		}
	}
}

bba_create_cas_license_effect = { #this assumes that the corresponding get_cas_effect has run already to generate a design template if necessary
	if = {
		limit = {
			has_tech = advanced_small_airframe
		}
		create_production_license = {
			target = event_target:license_target
			equipment = {
				type = small_plane_cas_airframe_3
			}
			cost_factor = 0
		}
	}
	else_if = {
		limit = {
			has_tech = improved_small_airframe
		}
		create_production_license = {
			target = event_target:license_target
			equipment = {
				type = small_plane_cas_airframe_2
			}
			cost_factor = 0
		}
	}
	else_if = {
		limit = {
			has_tech = basic_small_airframe
		}
		create_production_license = {
			target = event_target:license_target
			equipment = {
				type = small_plane_cas_airframe_1
			}
			cost_factor = 0
		}
	}
}

bba_create_fighter_license_effect = { #this assumes that the corresponding get_fighter_effect has run already to generate a design template if necessary
	if = {
		limit = {
			has_tech = advanced_small_airframe
		}
		create_production_license = {
			target = event_target:license_target
			equipment = {
				type = small_plane_airframe_3
			}
			cost_factor = 0
		}
	}
	else_if = {
		limit = {
			has_tech = improved_small_airframe
		}
		create_production_license = {
			target = event_target:license_target
			equipment = {
				type = small_plane_airframe_2
			}
			cost_factor = 0
		}
	}
	else_if = {
		limit = {
			has_tech = basic_small_airframe
		}
		create_production_license = {
			target = event_target:license_target
			equipment = {
				type = small_plane_airframe_1
			}
			cost_factor = 0
		}
	}
}

bba_create_tac_license_effect = { #this assumes that the corresponding get_tac_effect has run already to generate a design template if necessary
	if = {
		limit = {
			has_tech = advanced_medium_airframe
		}
		create_production_license = {
			target = event_target:license_target
			equipment = {
				type = medium_plane_airframe_3
			}
			cost_factor = 0
		}
	}
	else_if = {
		limit = {
			has_tech = improved_medium_airframe
		}
		create_production_license = {
			target = event_target:license_target
			equipment = {
				type = medium_plane_airframe_2
			}
			cost_factor = 0
		}
	}
	else_if = {
		limit = {
			has_tech = basic_medium_airframe
		}
		create_production_license = {
			target = event_target:license_target
			equipment = {
				type = medium_plane_airframe_1
			}
			cost_factor = 0
		}
	}
}

bba_create_heavy_fighter_license_effect = { #this assumes that the corresponding get_fighter_effect has run already to generate a design template if necessary
	if = {
		limit = {
			has_tech = advanced_medium_airframe
		}
		create_production_license = {
			target = event_target:license_target
			equipment = {
				type = medium_plane_fighter_airframe_3
			}
			cost_factor = 0
		}
	}
	else_if = {
		limit = {
			has_tech = improved_medium_airframe
		}
		create_production_license = {
			target = event_target:license_target
			equipment = {
				type = medium_plane_fighter_airframe_2
			}
			cost_factor = 0
		}
	}
	else_if = {
		limit = {
			has_tech = basic_medium_airframe
		}
		create_production_license = {
			target = event_target:license_target
			equipment = {
				type = medium_plane_fighter_airframe_1
			}
			cost_factor = 0
		}
	}
}

remove_any_country_role_from_character = { #Expected to be used inside the character scope
	#log = "I am [THIS.GetName]"
	if = {
		limit = {
			is_character_slot = air_chief
		}
		remove_advisor_role = { slot = air_chief }
	}
	if = {
		limit = {
			is_character_slot = army_chief
		}
		remove_advisor_role = { slot = army_chief }
	}
	if = {
		limit = {
			is_character_slot = navy_chief
		}
		remove_advisor_role = { slot = navy_chief }
	}
	if = {
		limit = {
			is_character_slot = high_command
		}
		remove_advisor_role = { slot = high_command }
	}
	if = {
		limit = {
			is_character_slot = theorist
		}
		remove_advisor_role = { slot = theorist }
	}
	if = {
		limit = {
			is_character_slot = political_advisor
		}
		remove_advisor_role = { slot = political_advisor }
	}
}

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

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

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

find_global_platonic_countries = { # Look for the countries that meet the best criteria for the different platonic countries we expect in HoI 
	find_biggest_fascist = yes
	find_biggest_democrat = yes
	find_biggest_communist = yes
	find_biggest_non_aligned = yes
	find_biggest_fascist_bully = yes
	find_best_democratic_ally_leader = yes
	find_democratic_sleeping_giant = yes
	find_local_dangerous_fascist = yes 
}


find_biggest_fascist_bully = { # Finds the biggest and/or meanest fascist country 
	get_highest_scored_country = {
		var = GLOBAL.platonic_fascist_bully
		scorer = fascist_bully_scorer
	}
}

find_best_democratic_ally_leader = { # Finds the most suitable democratic country to lead a faction
	get_highest_scored_country = {
		var = GLOBAL.platonic_democratic_ally_leader
		scorer = democratic_faction_leader_scorer
	}
}

find_democratic_sleeping_giant = { # Finds biggest desarmed democratic nation. Expected to be USA 
	get_highest_scored_country = {
		var = GLOBAL.platonic_democratic_sleeping_giant
		scorer = democratic_sleeping_giant_scorer
	}
}

find_biggest_fascist = { # Finds Nazi Germany, or the closest to it 
	get_highest_scored_country = {
		var = GLOBAL.platonic_big_fascist
		scorer = fascist_major_scorer
	}
}

find_biggest_democrat = { # Finds biggest Democratic Nation
	get_highest_scored_country = {
		var = GLOBAL.platonic_big_democratic
		scorer = democratic_major_scorer
	}
}

find_biggest_communist = { # Finds biggest Communist
	get_highest_scored_country = {
		var = GLOBAL.platonic_big_communist
		scorer = communist_major_scorer
	}
}

find_biggest_non_aligned = { # Finds biggest... anything else
	get_highest_scored_country = {
		var = GLOBAL.platonic_big_non_aligned
		scorer = non_aligned_major_scorer
	}
}
# There are ideology scorers for each continent. If you need more check the generic_platonic_scorers file and make a new scripted effect 

find_local_dangerous_fascist = {
	get_highest_scored_country = {
		var = platonic_local_dangerous_fascist
		scorer = local_fascist_country
	}
}


# The idea is that you can use these effects to store the party popularities (and, if desired, the ruling party) when puppeting or possibly when starting civil wars, and then use the "restore" effects to reset it after the puppeting has happened, so that you don't have to use the overlord's ideology if you don't want to. 
get_current_ideology_popularities = {
	set_variable = { ROOT.communist_support_before_change = ROOT.party_popularity_100@communism }
	set_variable = { ROOT.democratic_support_before_change = ROOT.party_popularity_100@democratic }
	set_variable = { ROOT.fascist_support_before_change = ROOT.party_popularity_100@fascism }
	set_variable = { ROOT.neutrality_support_before_change = ROOT.party_popularity_100@neutrality }
}
get_current_ruling_party = {
	set_variable = { ROOT.ruling_ideology_before_change = ROOT.current_party_ideology_group }
}
restore_ideology_popularities = {
	hidden_effect = {
		# Reset popluarities to what they were before puppeting 
		set_popularities = {
			communism = ROOT.communist_support_before_change
			democratic = ROOT.democratic_support_before_change
			fascism = ROOT.fascist_support_before_change
			neutrality = ROOT.neutrality_support_before_change
		}
		clear_variable = ROOT.communist_support_before_change
		clear_variable = ROOT.democratic_support_before_change
		clear_variable = ROOT.fascist_support_before_change
		clear_variable = ROOT.neutrality_support_before_change
	}
}
restore_ruling_party = {
	ROOT = {
		set_politics = {
			ruling_party = var:ROOT.ruling_ideology_before_change
		}
	}
}


#Upgrades state cat to the next valid level. Called from state scope

###kaas - Although this can be substituted with a pre-existing Road to 56 one, the effect tooltips would be good to port

increase_state_category = {
	if = {
		limit = {
			has_state_category = tiny_island
		}
		set_state_category = small_island
		effect_tooltip = {
			add_extra_state_shared_building_slots = 1
		}
	}

	if = {
		limit = {
			OR = {
				has_state_category = wasteland
				has_state_category = enclave
			}
		}
		set_state_category = pastoral
		effect_tooltip = {
			add_extra_state_shared_building_slots = 1
		}
	}
	else_if = {
		limit = {
			has_state_category = pastoral
		}
		set_state_category = rural
		effect_tooltip = {
			add_extra_state_shared_building_slots = 1
		}
	}
	else_if = {
		limit = {
			has_state_category = rural
		}
		set_state_category = town
		effect_tooltip = {
			add_extra_state_shared_building_slots = 2
		}
	}
	else_if = {
		limit = {
			has_state_category = town
		}
		set_state_category = large_town
		effect_tooltip = {
			add_extra_state_shared_building_slots = 1
		}
	}
	else_if = {
		limit = {
			has_state_category = large_town
		}
		set_state_category = city
		effect_tooltip = {
			add_extra_state_shared_building_slots = 1
		}
	}
	else_if = {
		limit = {
			has_state_category = city
		}
		set_state_category = metropolis
		effect_tooltip = {
			add_extra_state_shared_building_slots = 4
		}
	}

	else_if = {
		limit = {
			has_state_category = metropolis
		} 
		set_state_category = megalopolis
		effect_tooltip = {
			add_extra_state_shared_building_slots = 2
		}
	}
}

add_potential_special_forces_tree = {
	custom_effect_tooltip = add_potential_special_forces_tree_tt
	if = {
		limit = { NOT = { has_variable = sf_trees } }
		set_variable = { sf_trees = 2 }
	}
	else = {
		add_to_variable = { sf_trees = 1 }
	}
}

remove_potential_special_forces_tree = {
	if = {
		limit = { NOT = { has_variable = sf_trees } }
		set_variable = { sf_trees = 0 }
	}
	else = {
		subtract_from_variable = { sf_trees = 1 }
	}
}

store_core_states_on_game_start = { #Should be called from history file
	every_core_state = {
		ROOT = {
			add_to_array = {
				array = core_states_at_game_start
				value = PREV
			}
		}
	}
}