#	Example:
#
#	example_trigger = {
#		tag = GER
#		is_ai = no
#	}
#
#
#	In a script file:
#
#	trigger = {
#		example_trigger = yes
#	}
#

can_ROOT_get_wargoal_on_THIS = {
	exists = yes
	NOT = { is_in_faction_with = ROOT }
	NOT = { is_subject_of = ROOT }
}

#Country scope
is_JAP_or_ally_of_JAP = {
	OR = {
		tag = JAP
		is_in_faction_with = JAP
		is_subject_of = JAP
	}
}

is_border_conflict_defender_vs_FROM = {
	has_variable = ROOT.defender_state_vs_@FROM
}

has_not_initiated_border_incident_with_FROM = {
	custom_trigger_tooltip = {
		tooltip = not_initiated_border_incident_with_FROM
		NOT = {
			any_state = {
				check_variable = { FROM.defender_state_vs_@PREV = id }
			}
		}
	}
}

has_not_initiated_border_incident_with_ROOT = {
	custom_trigger_tooltip = {
		tooltip = not_initiated_border_incident_with_ROOT
		NOT = {
			any_state = {
				check_variable = { ROOT.defender_state_vs_@PREV = id }
			}
		}
	}
}

#State scope
has_ROOT_at_least_1_div_in_current_state_scope = {
	custom_trigger_tooltip = {
		tooltip = at_least_one_division_in_state
		ROOT = { divisions_in_state = { state = PREV size > 0 } }
	}
}

check_has_focus_tree_to_switch_to_fascism = {
	NOT = { tag = JAP }
	NOT = { tag = GER }
	NOT = { tag = MAN }
	NOT = { tag = ITA }
	OR = {
		NOT = {
			AND = {
				tag = SAF
				has_dlc = "Together for Victory"
			}
		}
		AND = {
			tag = SAF
			has_dlc = "Together for Victory"
			has_completed_focus = SAF_south_africa_first
		}
	}
	NOT = {
		AND = {
			tag = RAJ
			has_dlc = "Together for Victory"
		}
	}
	NOT = {
		AND = {
			tag = USA
			has_dlc = "Man the Guns"
		}
	}
	NOT = {
		AND = {
			tag = ENG
			has_dlc = "Man the Guns"
		}
	}
	NOT = {
		AND = {
			tag = FRA
			has_dlc = "La Resistance"
		}
	}
	NOT = {
		AND = {
			original_tag = SPR
			OR = {
				has_completed_focus = SPA_the_phalanx_ascendant
				has_completed_focus = SPA_supremacy_of_the_communion
				has_completed_focus = SPR_the_popular_front
			}
			has_dlc = "La Resistance"
		}
	}
	NOT = {
		AND = {
			tag = HUN
			has_dlc = "Gotterdammerung"
		}
	}
}

check_has_focus_tree_to_switch_to_democratic = {
	NOT = { tag = MAN }
	NOT = { tag = FRA }
	NOT = { tag = USA }
	NOT = { tag = ENG }
	NOT = { tag = CAN }
	NOT = { tag = SAF }
	NOT = { tag = AST }
	NOT = { tag = NZL }
	NOT = { tag = RAJ }
	NOT = { tag = CZE }
	NOT = {
		AND = {
			tag = HUN
			has_dlc = "Death or Dishonor"
		}
	}
	NOT = {
		AND = {
			tag = JAP
			has_dlc = "Waking the Tiger"
		}
	}
	NOT = {
		AND = {
			tag = GER
			has_dlc = "Waking the Tiger"
		}
	}
}

check_has_focus_tree_to_switch_to_communism = {
	NOT = { tag = PRC }
	NOT = { tag = SIK }
	NOT = { tag = MAN }
	NOT = { tag = SOV }
	NOT = {
		AND = {
			tag = RAJ
			has_dlc = "Together for Victory"
		}
	}
	NOT = {
		AND = {
			tag = JAP
			has_dlc = "Waking the Tiger"
		}
	}
	NOT = {
		AND = {
			tag = YUN
			has_dlc = "Waking the Tiger"
		}
	}
	NOT = {
		AND = {
			tag = USA
			has_dlc = "Man the Guns"
		}
	}
	NOT = {
		AND = {
			tag = ENG
			has_dlc = "Man the Guns"
		}
	}
	NOT = {
		AND = {
			tag = FRA
			has_dlc = "La Resistance"
		}
	}
	NOT = {
		AND = {
			original_tag = SPR
			has_dlc = "La Resistance"
		}
	}
	NOT = {
		AND = {
			original_tag = NOR
			has_dlc =  "Arms Against Tyranny"
		}
	}
	NOT = {
		AND = {
			original_tag = ARG
			has_dlc =  "Trial of Allegiance"
		}
	}
	NOT = {
		AND = {
			original_tag = GER
			has_dlc =  "Gotterdammerung"
		}
	}
}

#State scope
is_controlled_by_ROOT_or_subject = {
	custom_trigger_tooltip = {
		tooltip = is_controlled_by_ROOT_or_subject
		CONTROLLER = {
			OR = {
				tag = ROOT
				is_subject_of = ROOT
			}
		}
	}
}

is_not_controlled_by_ROOT_or_subject = {
	custom_trigger_tooltip = {
		tooltip = is_not_controlled_by_ROOT_or_subject
		CONTROLLER = {
			NOT = {
				OR = {
					tag = ROOT
					is_subject_of = ROOT
				}
			}
		}
	}
}

#Country scope
is_free_or_subject_of_root = {
	OR = {
		is_subject = no
		is_subject_of = ROOT
	}
}

#State scope
is_controlled_by_ROOT_or_ally = {
	custom_trigger_tooltip = {
		tooltip = is_controlled_by_ROOT_or_ally
		CONTROLLER = {
			OR = {
				tag = ROOT
				is_subject_of = ROOT
				is_in_faction_with = ROOT
			}
		}
	}
}

#State scope
is_not_controlled_by_ROOT_or_ally = {
	custom_trigger_tooltip = {
		tooltip = is_not_controlled_by_ROOT_or_ally
		CONTROLLER = {
			NOT = {
				tag = ROOT
				is_subject_of = ROOT
				is_in_faction_with = ROOT
			}
		}
	}
}

is_csa_state = {
	OR = {
		state = 366
		state = 365
		state = 367
		state = 370
		state = 362
		state = 363
		state = 364
		state = 371
		state = 375
		state = 368
		state = 372
	}
}

has_naval_treaty_trigger = {
	OR = {
		has_idea = MTG_naval_treaty_adherent
		has_idea = MTG_naval_treaty_cheating
		has_idea = MTG_naval_treaty_adherent_reduced
		has_idea = MTG_naval_treaty_cheating_reduced
	}
}

ai_air_doctrine_tier_1_trigger = {
	OR = {
		has_tech = naval_strike_tactics
		has_tech = direct_ground_support
		has_tech = low_echelon_support
	}
}

ai_air_doctrine_tier_2_trigger = {
	OR = {
		has_tech = multialtitude_flying
		has_tech = hunt_and_destroy
		has_tech = operational_destruction
	}
}
ai_air_doctrine_tier_3_trigger = {
	OR = {
		has_tech = flying_fortress
		has_tech = naval_strike_torpedo_tactics
		has_tech = infiltration_bombing
	}
}

ai_land_doctrine_tier_1_trigger = {
	OR = {
		has_tech = elastic_defence
		has_tech = mobile_defence
		has_tech = grand_assault
		has_tech = defence_in_depth
	}
}

ai_land_doctrine_tier_2_trigger = {
	OR = {
		has_tech = kampfgruppe
		has_tech = mechanised_offensive
		has_tech = branch_interoperation
		has_tech = infiltration_assault
		has_tech = vast_offensives
		has_tech = large_front_offensive
	}
}

CHI_is_on_historical_plan_trigger = {
	has_dlc = "Waking the Tiger"
	OR = {
		AND = {
			is_historical_focus_on = yes
			has_game_rule = {
				rule = CHI_ai_behavior
				option = DEFAULT
			}
		}
		has_country_flag = CHI_AI_RANDOM_HISTORICAL
		has_game_rule = {
			rule = CHI_ai_behavior
			option = HISTORICAL
		}
	}
}
SOV_is_on_historical_plan_trigger = {
	OR = {
		AND = {
			is_historical_focus_on = yes
			has_game_rule = {
				rule = SOV_ai_behavior
				option = DEFAULT
			}
		}
		has_country_flag = SOV_AI_RANDOM_COMMUNIST_HISTORICAL
		has_game_rule = {
			rule = SOV_ai_behavior
			option = HISTORICAL
		}
	}
}
USA_is_on_historical_plan_trigger = {
	OR = {
		AND = {
			is_historical_focus_on = yes
			has_game_rule = {
				rule = USA_ai_behavior
				option = DEFAULT
			}
		}
		has_country_flag = USA_AI_DEMOCRATIC_HISTORICAL
		has_game_rule = {
			rule = USA_ai_behavior
			option = DEMOCRATIC_HISTORICAL
		}
	}
}
ROM_is_on_historical_plan_trigger = {
	has_dlc = "Death or Dishonor"
	OR = {
		AND = {
			is_historical_focus_on = yes
			has_game_rule = {
				rule = ROM_ai_behavior
				option = DEFAULT
			}
		}
		has_country_flag = ROM_AI_RANDOM_FASCIST_HISTORICAL
		has_game_rule = {
			rule = ROM_ai_behavior
			option = FASCIST_HISTORICAL
		}
	}
}
HUN_is_on_historical_plan_trigger = {
	has_dlc = "Death or Dishonor"
	OR = {
		AND = {
			is_historical_focus_on = yes
			has_game_rule = {
				rule = HUN_ai_behavior
				option = DEFAULT
			}
		}
		has_country_flag = HUN_AI_RANDOM_FASCIST_HISTORICAL
		has_game_rule = {
			rule = HUN_ai_behavior
			option = FASCIST_HISTORICAL
		}
	}
}
COG_is_on_historical_plan_trigger = {
	has_dlc = "Gotterdammerung"
	OR = {
		AND = {
			is_historical_focus_on = yes
			has_game_rule = {
				rule = COG_AI_BEHAVIOR
				option = DEFAULT
			}
		}
		has_country_flag = COG_AI_RANDOM_HISTORICAL
		has_game_rule = {
			rule = COG_AI_BEHAVIOR
			option = HISTORICAL
		}
	}
}
ENG_is_on_historical_plan_trigger = {
	OR = {
		AND = {
			is_historical_focus_on = yes
			has_game_rule = {
				rule = ENG_ai_behavior
				option = DEFAULT
			}
		}
		has_country_flag = ENG_AI_DEMOCRATIC_HISTORICAL
		has_game_rule = {
			rule = eng_ai_behavior
			option = DEMOCRATIC_HISTORICAL
		}
	}
}

SOV_save_pp_for_manpower_trouble = {
	has_manpower < 1000000
	has_political_power < 200
	surrender_progress > 0
}

anti_submarine_strategy_required_trigger = {
	OR = {
		AND = {
			tag = ENG
			not = { is_in_faction_with = GER }
			GER = {
				has_navy_size = {
					type = submarine
					size > 30
				}
			}
		}
		AND = {
			tag = USA
			not = { is_in_faction_with = GER }
			GER = {
				has_navy_size = {
					type = submarine
					size > 30
				}
			}
		}
		AND = {
			tag = JAP
			not = { is_in_faction_with = USA }
		}
		AND = {
			has_war = yes
			any_enemy_country = {
				has_navy_size = {
					type = submarine
					size > 30
				}
			}
		}
		convoy_threat > 0.3
	}
}

should_USA_invade_europe_or_africa = {
	USA = {
		OR = {
			is_in_faction_with = ENG
			has_military_access_to = ENG
		}
	}
	surrender_progress < 0.05
	FRA = {
		has_capitulated = yes
	}
	OR = {
		GER = {
			exists = yes
			has_war_with = USA
		}
		ITA = {
			exists = yes
			has_war_with = USA
		}
		SPR = {
			exists = yes
			has_war_with = USA
		}
		USA = {
			OR = {
				AND = {
					has_government = democratic
					ENG = { has_government = democratic }
					OR = {
						GER = { has_government = fascism }
						ITA = { has_government = fascism }
					}
				}
				is_in_array = { potential_and_current_enemies = GER }
				is_in_array = { potential_and_current_enemies = ITA }
				is_in_array = { potential_and_current_enemies = SPR }
			}
		}
	}
}

enemy_has_equal_or_better_radar_tech_trigger = {
	custom_trigger_tooltip = {
		tooltip = enemy_has_equal_or_better_radar_tech_trigger_tt
		if = {
			limit = {
				ROOT = {
					has_tech = radio_detection
					NOT = {
						has_tech = cavity_magnatron
					}
				}
			}
			FROM = {
				OR = {
					has_tech = radio_detection
					has_tech = cavity_magnatron
				}
			}
		}
		else_if = {
			limit = {
				ROOT = {
					has_tech = cavity_magnatron

				}
			}
			FROM = {
				has_tech = cavity_magnatron
			}
		}
		else_if = {
			limit = {
				ROOT = {
					NOT = {
						has_tech = centimetric_radar
					}
				}
			}
			FROM = {
				has_tech = centimetric_radar
			}
		}
		else_if = {
			limit = {
				ROOT = {
					has_tech = centimetric_radar
					NOT = {
						has_tech = phased_array
					}
				}
			}
			FROM = {
				OR = {
					has_tech = centimetric_radar
					has_tech = phased_array
				}
			}
		}
		else_if = {
			limit = {
				ROOT = {
					has_tech = phased_array
					NOT = {
						has_tech = monopulse_radar
					}
				}
			}
			FROM = {
				OR = {
					has_tech = phased_array
					has_tech = monopulse_radar
				}
			}
		}
		#no more steps needed because end of research tree is reached
	}
}

is_available_to_collaboration_government = { # occupied_countries.1 should be updated along with this
	is_subject = no
	if = {
		limit = {
			original_tag = ITA
		}
		NOT = { FROM = { original_tag = YUG } }
	}

	if = {
		limit = {
			original_tag = POL
		}
		NOT = { FROM = { original_tag = DNZ } }
	}
	if = {
		limit = {
			original_tag = TUR
		}
		NOT = { FROM = { original_tag = KUR } }
	}
	NOT = {
		any_country_with_original_tag = {
			original_tag_to_check = FROM
			is_puppet_of = PREV # if already created one do not create another
			has_autonomy_state = autonomy_collaboration_government
		}
	}
}

has_large_ally_not_pick_closed_economy = {
	any_of_scopes = {
		array = faction_members

		NOT = { tag = PREV }
		num_of_military_factories > 30
	}
}

owns_or_subject_of = {
	custom_trigger_tooltip = {
		tooltip = owns_or_subject_of_tt
		owner = {
			OR = {
				tag = ROOT
				is_subject_of = ROOT
			}
		}
	}
}

controls_or_subject_of = {
	custom_trigger_tooltip = {
		tooltip = controls_or_subject_of_tt
		controller = {
			OR = {
				tag = ROOT
				is_subject_of = ROOT
			}
		}
	}
}

is_core_or_compliance_60 = {
	custom_trigger_tooltip = {
		tooltip = is_core_or_compliance_60_tt
		OR = {
			controller = {
				PREV = { is_core_of = PREV }
			}
			compliance > 60
		}
	}
}

has_any_byz_cosmetic_tag = {
	OR = {
		has_cosmetic_tag = BYZ_UNIFIED
		has_cosmetic_tag = BYZ_UNIFIED_communism
		has_cosmetic_tag = BYZ_UNIFIED_democratic
		has_cosmetic_tag = BYZ_UNIFIED_fascism
		has_cosmetic_tag = BYZ_UNIFIED_neutrality
	}
}

has_same_ideology = {
	custom_trigger_tooltip = {
		tooltip = has_same_ideology_tt
		OR = {
			AND = {
				has_government = democratic
				ROOT = { has_government = democratic }
			}
			AND = {
				has_government = fascism
				ROOT = { has_government = fascism }
			}
			AND = {
				has_government = communism
				ROOT = { has_government = communism }
			}
			AND = {
				has_government = neutrality
				ROOT = { has_government = neutrality }
			}
		}
	}
}

is_latin_american_country = {
	OR = {
		original_tag = CUB
		original_tag = ARG
		original_tag = BRA
		original_tag = URG
		original_tag = PAR
		original_tag = CHL
		original_tag = BOL
		original_tag = PRU
		original_tag = ECU
		original_tag = COL
		original_tag = VEN
		original_tag = PAN
		original_tag = COS
		original_tag = NIC
		original_tag = HON
		original_tag = ELS
		original_tag = GUA
		original_tag = MEX
		original_tag = HAI
		original_tag = DOM
	}
}

has_specialist_level_trigger = {
	skill > 5
	skill < 6
}

has_expert_level_trigger = {
	skill > 6
	skill < 7
}

has_genius_level_trigger = {
	skill > 7
}

is_league_of_nations_member = {
	custom_trigger_tooltip = {
		tooltip = is_league_of_nations_member_tt
		has_idea = league_of_nations_member_idea
	}
}

state_is_in_the_mediterranean_sea = {
	custom_trigger_tooltip = {
		tooltip = state_is_in_the_mediterranean_sea_tt
		OR = {
			state = 118 #GIBRALTAR
			state = 173
			state = 168
			state = 167
			state = 165
			state = 177
			state = 31
			state = 22
			state = 21
			state = 851
			state = 911
			state = 735
			state = 162
			state = 2
			state = 117
			state = 156
			state = 115
			state = 1
			state = 114
			state = 116
			state = 849
			state = 157
			state = 158
			state = 161
			state = 160
			state = 736
			state = 852
			state = 103
			state = 163
			state = 105
			state = 44
			state = 805
			state = 185
			state = 186
			state = 47
			state = 731
			state = 184
			state = 187
			state = 182
			state = 164
			state = 341
			state = 797
			state = 340
			state = 339
			state = 342
			state = 345
			state = 344
			state = 799
			state = 677
			state = 553
			state = 183
			state = 454
			state = 453
			state = 446
			state = 907
			state = 447
			state = 452
			state = 451
			state = 450
			state = 449
			state = 448
			state = 665
			state = 458
			state = 460
			state = 459
			state = 461
			state = 290
			state = 934
		}
	}
}

state_is_in_the_baltic_sea = { # Checks if the state borders the Baltic Sea  
	OR = {	
		state = 37 # Sjaelland
		state = 911 # Fyn
		state = 912 # Sonderjylland
		state = 909
		state = 58
		state = 61
		state = 62
		state = 63
		state = 807
		state = 85
		state = 5
		state = 763
		state = 188
		state = 189
		state = 190
		state = 809
		state = 808
		state = 12
		state = 13
		state = 811 
		state = 812
		state = 813
		state = 208
		state = 195
		state = 146
		state = 928
		state = 111
		state = 926
		state = 145
		state = 149
		state = 929 
		state = 148 # Lappi
		state = 666 # Norrbotten
		state = 918 # Vasterbotten
		state = 38 # Gavleborg
		state = 141 # Sodermaland
		state = 913 # Ostergotland
		state = 139 # Smaland
		state = 138 # Skane
		state = 124 # Gotland
	}
}

is_major_not_original_tag_root = {
	is_major = yes
	hidden_trigger = {
		NOT = { original_tag = ROOT }
	}
}

is_initial_ethiopian_state = {
	OR = {
		state = 271
		state = 835
		state = 836
		state = 837
		state = 838
		state = 839
		state = 840
		state = 841
		state = 842
		state = 843
	}
}

has_subject_autonomy_feature = {
	has_dlc = "Together for Victory"
}

is_organization_of_african_unity_member = {
	custom_trigger_tooltip = {
		tooltip = is_league_of_nations_member_tt
		has_idea = organization_of_african_unity_member_idea
	}
}

has_tech_sharing_feature = {
	OR = {
		has_dlc = "Together for Victory"
		has_dlc = "Death or Dishonor"
		has_dlc = "Waking the Tiger"
		has_dlc = "La Resistance"
	}
}

has_war_with_non_exiled_country = {
	custom_trigger_tooltip = {
		tooltip = has_war_with_non_exiled_country_tt
		has_war = yes
		any_enemy_country = {
			is_government_in_exile = no
		}
	}

}

is_at_peace_exiled_countries_excluded = {
	custom_trigger_tooltip = {
		tooltip = is_at_peace_exiled_countries_excluded_tt
		NOT = {
			any_enemy_country = {
				is_government_in_exile = no
			}
		}
	}
}

#State scope
state_is_fully_controlled_by_ROOT_or_subject = {
	custom_trigger_tooltip = {
		tooltip = state_is_fully_controlled_by_ROOT_or_subject_tt
		OR = {
			is_fully_controlled_by = ROOT
			controller = {
				is_subject_of = ROOT
				has_full_control_of_state = PREV
			}
		}
	}
}

#State scope
state_is_fully_controlled_by_ROOT_subject_or_faction_member = {
	custom_trigger_tooltip = {
		tooltip = state_is_fully_controlled_by_ROOT_subject_or_faction_member_tt
		OR = {
			is_fully_controlled_by = ROOT
			controller = {
				OR = {
					is_subject_of = ROOT
					is_in_faction_with = ROOT
				}
				has_full_control_of_state = PREV
			}
		}
	}
}

is_alpine_state = {
	custom_trigger_tooltip = {
		tooltip = is_alpine_TT
	}
	hidden_trigger = {
		OR = {
			state = 21 #Bouche-du-Rhone - FRA
			state = 851 #Var - FRA 
			state = 735 #Savoy - FRA 
			state = 32 #Alpes - FRA 
			state = 158 #Piemonte - ITA
			state = 159 #Lombardia - ITA 
			state = 850 #Trentino - ITA 
			state = 39 #Alto Adige - ITA
			state = 847 #Western Swiss Alps - SWI
			state = 151 #Eastern Swiss Alps - SWI 
			state = 846 #Ticino - SWI
			state = 848 #Vorarlberg - AUS
			state = 153 #Tyrol - AUS 
			state = 152 #Upper Austria - AUS 
			state = 4 #Lower Austria 
			state = 975 #Burgenland
			state = 1032 #Steiermark-Kömten 
			state = 1025 #Steiermark-Kömten 
			state = 1031 #Steiermark-Kömten 
			state = 1028 #Steiermark-Kömten 
			state = 1022 #Steiermark-Kömten 
			state = 1020 #Steiermark-Kömten 
			state = 736 #Steiermark-Kömten 
			state = 1033 #Steiermark-Kömten 
			state = 853 #Steiermark-Kömten 
			state = 102 #Steiermark-Kömten 
			state = 1029 #Steiermark-Kömten
			state = 1023 #Steiermark-Kömten
		}
	}
}

state_has_any_resource = {
	OR = {
		has_resources_amount = {
			resource = oil
			amount > 0
		}
		has_resources_amount = {
			resource = aluminium
			amount > 0
		}
		has_resources_amount = {
			resource = rubber
			amount > 0
		}
		has_resources_amount = {
			resource = tungsten
			amount > 0
		}
		has_resources_amount = {
			resource = steel
			amount > 0
		}
		has_resources_amount = {
			resource = chromium
			amount > 0
		}
	}
}

country_can_be_reasonable_target_of_wargoal = { #Expected scopes: Target country is THIS, country getting wargoal is PREV
	NOT = {
		has_war_with = ROOT
		is_in_faction_with = PREV
		has_guaranteed = PREV
		is_guaranteed_by = PREV
		has_non_aggression_pact_with = PREV
		is_subject_of = PREV
	}
}

is_unlikely_country_tag = {
	OR = {
	    tag = BRI
	    tag = CAT
	    tag = NAV
	    tag = GLC
	    tag = ADU
	    tag = BRI
	    tag = OCC
	    tag = COR
	    tag = DNZ
	    tag = KSH
	    tag = CKK
	    tag = FER
	    tag = YAK
	    tag = VLA
	    tag = KKP
	    tag = YAM
	    tag = TAY
	    tag = OVO
	    tag = NEN
	    tag = KOM
	    tag = CHU
	    tag = MEL
	    tag = RIF
	    tag = HAR
	    tag = TIG
	    tag = AFA
	    tag = BEG
	    tag = GBA
	    tag = SID
	    tag = ORO
	    tag = QEM
	    tag = LBV
	    tag = PAP
	    tag = TOS
	    tag = SPM
	    tag = TTS
		tag = BSK
		tag = TAT
		tag = UDM
		tag = KHA
		tag = VGE
		tag = KAL
		tag = KAR
		tag = SIL
		tag = KSH
		tag = ALT
		tag = BUK
		tag = KHI
		tag = SMI
		tag = QUE
		tag = YUC
		tag = RIG
		tag = WLA
		tag = GRN
		tag = EVE
		tag = SHL
		tag = MEK
		tag = HAN
		tag = SAX
		tag = PRE
		tag = BAY
		tag = WUR
		tag = THU
		tag = HES
		tag = RHI
	}
}

big_communist_exists = {
	any_other_country = {
		is_major = yes 
		has_government = communism
		has_capitulated = no 
		exists = yes 
	}
}

big_fascist_exists = {
	any_other_country = {
		is_major = yes 
		has_government = fascism
		has_capitulated = no 
		exists = yes 
	}
}

has_lar = {
	has_dlc = "La Resistance"
}

has_mtg = {
	has_dlc = "Man the Guns"
}

has_hide_rule = {
	has_game_rule = {
		rule = obsolete_focus_branches_visibility
		option = HIDE
	}
}


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

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

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

has_aat = {
	has_dlc = "Arms Against Tyranny"
}

is_aat_sweden = {
		has_aat = yes
		original_tag = SWE
}

is_trotsky_valid_for_mexico = {
	OR = {
		has_government = communism
		has_government = neutrality
	}
	has_global_flag = flag_mexico_invited_trotsky_to_government
	NOT = {
		OR = {
			has_global_flag = trotsky_not_welcome_in_mexico
			has_global_flag = flag_trotsky_dead
			has_global_flag = flag_trotsky_has_returned_to_ussr_from_mexico
		}
	}
	if = {
		limit = {
			OR = {
				SOV_is_left_opposition = yes 
				SOV_is_right_opposition = yes
			}
		}
		SOV = { NOT = { has_idea = SOV_lev_trotsky } }
		SOV = { NOT = { has_country_leader = { character = SOV_lev_trotsky } } }
	}
	if = {
		limit = {
			has_aat = yes 
		}
		has_global_flag = AAT_trotsky_in_mexico
	}	
}
NOR_trotsky_not_in_sov = {
	any_other_country = {
		original_tag = SOV 
		has_government = communism 
		NOT = { has_completed_focus = SOV_the_left_opposition }
	}
}

NOR_trotsky_not_in_mex = {
	NOT = { 
		has_global_flag = AAT_trotsky_in_mexico 
		has_global_flag = flag_trotsky_dead
		has_global_flag = flag_trotsky_has_returned_to_ussr_from_mexico
	} 
}

has_any_tank_tech = {
	if = {
		limit = {
			has_dlc = "No Step Back"
		}
		OR = {
			has_tech = basic_light_tank_chassis
			has_tech = basic_medium_tank_chassis
			has_tech = basic_heavy_tank_chassis
		}
	}
	else = {
		has_tech = gwtank
	}
}

has_any_tanks = {
	if = {
		limit = {
			has_dlc = "No Step Back"
		}
		OR = {
			has_equipment = { light_tank_chassis_0 > 0}
			has_equipment = { medium_tank_chassis > 0 }
			has_equipment = { light_tank_chassis > 0 }
			has_equipment = { heavy_tank_chassis > 0 }
		}
	}
	else = {
		OR = {
			has_equipment = { gw_tank_equipment > 0	}
			has_equipment = { light_tank_equipment_1 > 0	}
			has_equipment = { light_tank_equipment_2 > 0	}
			has_equipment = { light_tank_equipment_3 > 0	}
			has_equipment = { medium_tank_equipment_1 > 0	}
			has_equipment = { medium_tank_equipment_2 > 0	}
			has_equipment = { medium_tank_equipment_3 > 0	}
			has_equipment = { modern_tank_equipment_1 > 0	}
			has_equipment = { heavy_tank_equipment_1 > 0	}
			has_equipment = { heavy_tank_equipment_2 > 0	}
			has_equipment = { heavy_tank_equipment_3 > 0	}
			has_equipment = { super_heavy_tank_equipment_1 > 0	}
		}
	}
}

is_danish_belt_state = { # Checks if state should be considered to be around the Danish Belt  
	OR = {
		state = 922 # Agder
		state = 921 # Telemark
		state = 110 # Oslofjord
		state = 915 # Bohuslan
		state = 140 # Vastergotland 
		state = 138 # Skane 
		state = 99 # Norrejylland
		state = 911 # Fyn
		state = 912 # Sonderjylland 
		state = 37 # Sjaelland 
		state = 909 # Schleswig 
		state = 58 # Holstein 
		state = 61 # Mecklenburg
		state = 62 # Vorpommern   
	}
} 

is_scandinavian_northern_sea_state = {
	OR = {
		state = 909 # Schleswig 
		state = 58 # Holstein 
		state = 912 # Sonderjylland		
		state = 99 # Norrejylland
		state = 922 # Agder
		state = 142 # Vestlandet 
		state = 143 # Trondelag
		state = 923 # Helgeland
		state = 144 # Nordland 
		state = 924 # Troms 
		state = 925 # Finnmark
	}
}

is_germanic = {
	OR = {
		original_tag = GER
		original_tag = NOR
		original_tag = SWE
		original_tag = DEN
		original_tag = SWI
		original_tag = HOL
		original_tag = LUX
		original_tag = BEL
		original_tag = AUS
	}
}

mio_original_country_exists_and_not_at_war_with_ROOT = { #Used for MIO decisions visibility - THIS is original country
	exists = yes
	has_capitulated = no
	NOT = { has_war_with = ROOT }
}

mio_original_country_available_with_opinion_subject_and_war_requirements_fulfilled = { #Used for MIO decisions availability - THIS is original country
	has_opinion = {
		target = ROOT
		value > 49
	}
	OR = {
		is_subject = no
		is_subject_of = ROOT
	}
	has_capitulated = no
	NOT = { has_war_with = ROOT }
}


can_unlock_new_special_forces_tree = {
	if = {
		limit = { NOT = { has_variable = sf_trees } }
		custom_trigger_tooltip = {
			tooltip = can_unlock_new_special_forces_tree_none
			NOT = { has_variable = sf_trees }
		}
	}
	else_if = {
		limit = { check_variable = { sf_trees > 0 } }
		custom_trigger_tooltip = {
			tooltip = can_unlock_new_special_forces_tree_more_yes
			check_variable = { sf_trees > 0 }
		}
	}
	else = {
		custom_trigger_tooltip = {
			tooltip = can_unlock_new_special_forces_tree_more_no
			always = no
		}
	}
}
# These are to make strength comparisons easier 

FROM_is_stronger = {
	strength_ratio = {
		tag = FROM 
		ratio < 1
	}
}

FROM_is_twice_as_strong = {
	strength_ratio = {
		tag = FROM 
		ratio < 0.5
	}
}

FROM_is_weaker = {
	strength_ratio = {
		tag = FROM 
		ratio > 1
	}
}

FROM_is_twice_as_weak = {
	strength_ratio = {
		tag = FROM 
		ratio > 2
	}
}

ai_has_completed_army_doctrine = {
	is_ai = yes
	OR = {
		has_tech = werwolf_guerillas
		has_tech = modern_blitzkrieg
		has_tech = air_land_battle
		has_tech = shock_and_awe
		has_tech = c3i_theory
		has_tech = infiltration_in_depth
		has_tech = continuous_offensive
		has_tech = guerilla_warfare
	}
}

ai_has_completed_air_doctrine = {
	is_ai = yes
	OR = {
		has_tech = offensive_formations
		has_tech = mass_destruction
		has_tech = forward_interception
		has_tech = high_level_bombing
	}
}

ai_has_completed_naval_doctrine = {
	is_ai = yes
	OR = {
		has_tech = grand_battlefleet
		has_tech = submarine_offensive
		has_tech = floating_airfield
		has_tech = combined_operations_raiding
		has_tech = integrated_convoy_defence
		has_tech = submarine_offensive_bs
		has_tech = carrier_battlegroups
	}
}

### Neutrality Act - only trade with countries at peace 
trade_partner_not_at_war = {
	custom_trigger_tooltip = {
		tooltip = trade_partner_not_at_war_tt
		FROM = { 
			has_war = yes 
		}
	}
}

is_democratic_seller_trigger = {
	custom_trigger_tooltip = {
		tooltip = "Democratic Countries"
		FROM = {
			has_government = democratic
		}
	}
}

#Subsidy Seller Triggers
is_fascist_seller_trigger = {
	NOT = { has_war_with = ROOT	}
	has_government = fascism 
}

is_democracy_seller_trigger = {
	NOT = { has_war_with = ROOT	}
	has_government = democratic 
}

is_communist_seller_trigger = {
	NOT = { has_war_with = ROOT }
	has_government = communism
}

is_allied_seller_trigger = {
	custom_trigger_tooltip = {
		tooltip = subsidy_allied_nation_tt
		FROM = { is_in_faction_with = ROOT }
	}
}

