﻿###########################
# Ragnarok Events
###########################
# For mod interoperability, check for:
# has_global_flag = mod_ragnarok_1937

add_namespace = ragnarok

# New Year's Eve Party
country_event = {
	id = ragnarok.1
	title = ragnarok.1.t
	desc = ragnarok.1.d
	picture = GFX_report_event_ragnarok_party
	
	fire_only_once = yes

	trigger = {
		tag = GER
		date > 1936.12.31
		NOT = { has_global_flag = ragnarok_party }
		NOT = { has_global_flag = ragnarok_early_war }
	}

	mean_time_to_happen = {
		days = 1
	}

	immediate = {
		hidden_effect = {
			set_global_flag = ragnarok_party

			country_event = { id = ragnarok.15 } # Makes fascist countries unlikely to join Axis

			country_event = { id = ragnarok.2 days = 2 } # Fire next event in Ragnarok series in a few days
			
			disable_events = yes
		}
	}	
	
	option = {
		name = ragnarok.1.a

		add_political_power = -20
		add_named_threat = { threat = 8 name = ragnarok.1.t }
	}
}

# Diplomatic conference in London, world makes peace
country_event = {
	id = ragnarok.2
	title = ragnarok.2.t
	desc = {
		trigger = { NOT = { has_global_flag = ragnarok_early_war }	}
		text = ragnarok.2.d1
	}
	desc = {
		trigger = { has_global_flag = ragnarok_early_war }
		text = ragnarok.2.d2
	}
	picture = GFX_report_event_journalists_speech
	
	is_triggered_only = yes
	
	immediate = {
		hidden_effect = {
			add_named_threat = { threat = 15 name = ragnarok.2.t }

			relocate_east_prussia_factories = yes # Move factories out of East Prussia if placed there by a national focus [1937 only]

			# Recall von Falkenhausen from China
			if = {
				limit = { # Only do if China isn't a player-controlled nation potentially working with Germany
					CHI = { is_ai = yes } 
				}

				CHI = { country_event = { id = china.2 days = 1 } }
				every_other_country = {
					limit = {
						has_character = CHI_alexander_von_falkenhausen
					}
					retire_character = CHI_alexander_von_falkenhausen
				}
				set_global_flag = falkenhausen_recalled
			}

			every_country = {
				limit = {
					is_ai = yes # Exclude other player-controlled nations that might be working with Germany
					NOT = { tag = GER }
					NOT = { is_puppet_of = GER }
				}

				add_opinion_modifier = { target = GER modifier = german_threat }
			}
			
			# Chinese warlords finish their industrial trees so China will be a little stronger
			if = {
				limit = { # Only do if China and Japan aren't player-controlled nations potentially working with Germany
					CHI = { is_ai = yes } 
					JAP = { is_ai = yes }
				}

				every_country = {
					limit = {
						OR = {
							tag = GXC
							tag = YUN
							tag = XSM
							tag = SHX
							tag = SIK
						}
						
						is_ai = yes
						exists = yes
					}
					
					complete_industrial_focuses = yes
				}
			}
			
			# Germany's allies abandon them
			if = {
				limit = {
					GER = { is_faction_leader = yes }
				}

				every_country = {
					limit = {
						is_in_faction_with = GER
						NOT = { tag = GER }	
						NOT = { is_puppet_of = GER }
						is_ai = yes # Exclude other player-controlled nations that might be working with Germany
					}
						
					GER = { remove_from_faction = PREV }
				}
			}
			
			# Kick Germany out of Allies if in that alliance
			if = {
				limit = {
					ENG = {
						is_faction_leader = yes
						is_in_faction_with = GER
					}
				}

				ENG = { remove_from_faction = GER }
			}

			# United Kingdom leaves faction if not leader
			if = {
				limit = {
					ENG = { is_faction_leader = no }
				}

				ENG = { leave_faction = yes }
			}
			# Create new faction for United Kingdom if Allies don't exist
			if = {
				limit = {
					ENG = { is_in_faction = no }
				}

				ENG = { create_faction = Allies }
			}
			# Create new Allies faction if United Kingdom still not in any alliance
			if = {
				limit = {
					ENG = { is_in_faction = no }
				}

				ENG = { create_faction = Allies_Reborn }
			}
			
			# Add democratic or non-aligned major powers who are at peace to the Allies immediately
			every_country = {
				limit = {
					is_major_country = yes
					NOT = { tag = ENG }
					is_ai = yes # Exclude other player-controlled nations that might be working with Germany
				}
				
				country_event = { id = ragnarok.28 }
			}
			
			# Try adding democratic or non-aligned major powers to the Allies again at end of conference
			# China may be at war with Japan at start of summit
			every_country = {
				limit = {
					is_major_country = yes
					NOT = { tag = ENG }
					is_ai = yes # Exclude other player-controlled nations that might be working with Germany
				}
				
				country_event = { id = ragnarok.28 days = 6 }
			}

			USA = { # USA is just arbitrary placeholder country
				# Add a few more random democratic or non-aligned European countries to the Allies every day 
				country_event = { id = ragnarok.27 days = 1 }
				country_event = { id = ragnarok.27 days = 1 }
				country_event = { id = ragnarok.27 days = 1 }
				country_event = { id = ragnarok.27 days = 1 }
				country_event = { id = ragnarok.27 days = 2 }
				country_event = { id = ragnarok.27 days = 2 }
				country_event = { id = ragnarok.27 days = 2 }
				country_event = { id = ragnarok.27 days = 2 }
				country_event = { id = ragnarok.27 days = 2 }
				country_event = { id = ragnarok.27 days = 2 }
				
				# NO COUNTRIES SHOULD JOIN ALLIES THE SAME DAY AS PEACE TREATIES, seems to cause crashes
				
				# Random countries make peace, or more European countries join the Allies
				country_event = { id = ragnarok.20 days = 3 }
				country_event = { id = ragnarok.20 days = 4 }

				# All remaining countries make peace, or more European countries join the Allies
				country_event = { id = ragnarok.21 days = 5 }
			}
			
			# All remaining democratic or non-aligned European countries join the Allies
			every_country = {
				limit = {
					is_european_country = yes
					is_ai = yes # Exclude other player-controlled nations that might be working with Germany
				}
					
				country_event = { id = ragnarok.28 days = 6 }
			}

			country_event = { id = ragnarok.3 days = 7 } # Fire next event in Ragnarok series in a few days

			USA = { country_event = { id = ragnarok.48 } } # China annexes warlords
		}
	}

	option = {
		name = ragnarok.2.a
	}
}

# The war begins
news_event = {
	id = ragnarok.3
	title = ragnarok.3.t
	desc = {
		trigger = { NOT = { has_global_flag = ragnarok_early_war } }
		text = ragnarok.3.d1
	}
	desc = {
		trigger = { has_global_flag = ragnarok_early_war }
		text = ragnarok.3.d2
	}
	picture = GFX_news_event_019
	
	is_triggered_only = yes
	
	immediate = {
		hidden_effect = {
		
			# Keep track of whether Treaty with the USSR national focus was completed prior to the outbreak of war
			if = {
				limit = {
					has_completed_focus = GER_treaty_with_the_ussr
				}
				
				set_country_flag = completed_treaty_with_ussr
			}
			
			remove_ideas = mefo_arms
			
			add_named_threat = { threat = 120 name = ragnarok.3.t }

			country_event = { id = ragnarok.49 } # Adjust political systems for Allies
			
			# As of HoI4 v15, Soviet Union seems to spam Germany with non-aggression pact requests
			SOV = {
				if = {
					limit = {
						has_non_aggression_pact_with = GER
					}
					
					diplomatic_relation = {
						country = GER
						relation = non_aggression_pact
						active = no
					}
				}
			}
			
			# Germany's allies abandon them (again in case they rejoined)
			if = {
				limit = {
					GER = { is_faction_leader = yes }
				}

				every_country = {
					limit = {
						is_in_faction_with = GER
						NOT = { tag = GER }	
						NOT = { is_puppet_of = GER }
						is_ai = yes # Exclude other player-controlled nations that might be working with Germany
					}
						
					GER = { remove_from_faction = PREV }
				}
			}
			
			# Kick Germany out of Allies if in that alliance
			if = {
				limit = {
					ENG = {
						is_faction_leader = yes
						is_in_faction_with = GER
					}
				}

				ENG = { remove_from_faction = GER }
			}
			
			# Create faction for Germany if not in an alliance
			if = {
				limit = {
					GER = { is_in_faction = no }
				}

				GER = { create_faction = Axis }
			}
			
			# All German puppets join the Axis
			every_country = {
				limit = {
					is_puppet_of = GER
					is_in_faction = no
				}

				GER = { add_to_faction = PREV }
			}

			# Seems to be bugged sometimes, should be included in the Japan-China peace, try to force peace manually
			if = {
				limit = {
					country_exists = PRC
					country_exists = MEN
					PRC = { has_war_with = MEN }
				}
				
				PRC = { white_peace = MEN }
			}
			if = {
				limit = {
					country_exists = PRC
					country_exists = MAN
					PRC = { has_war_with = MAN }
				}
				
				PRC = { white_peace = MAN }
			}

			# All countries make peace (again in case a war started in the meantime)
			every_country = {
				limit = {
					has_war = yes
					NOT = { tag = GER }
					NOT = { is_puppet_of = GER }
					#is_puppet = no
					is_ai = yes # Exclude other player-controlled nations that might be working with Germany
				}

				country_event = { id = ragnarok.24 } # Includes puppets
			}

			# Disband all other factions besides Allies and Axis
			every_country = {
				limit = {
					is_faction_leader = yes
					NOT = { tag = GER }
					NOT = { tag = ENG }
					is_ai = yes # Exclude other player-controlled nations that might be working with Germany
				}
				
				dismantle_faction = yes
			}
			
			# Remove puppet status if necessary for China
			if = {
				limit = {
					country_exists = CHI
					country_exists = JAP
					CHI = { is_puppet_of = JAP }
					JAP = { is_ai = yes } # Exclude other player-controlled nations that might be working with Germany
				}
				
				JAP = { end_puppet = CHI }
			}
			
			# White peace when China is in the midst of a civil war and also at war with Japan can cause the civil war to never end
			if = {
				limit = {
					country_exists = CHI
					CHI = { has_civil_war = yes }
					country_exists = PRC
					CHI = { is_ai = yes } # Exclude other player-controlled nations that might be working with Germany
					PRC = { is_ai = yes }
				}
				
				PRC = { annex_country = { target = CHI transfer_troops = yes } }
				PRC = { release = CHI }
				CHI = { annex_country = { target = PRC transfer_troops = yes } }
			}
			else_if = { # PRC doesn't exist
				limit = {
					country_exists = CHI
					CHI = { has_civil_war = yes }
					CHI = { is_ai = yes } # Exclude other player-controlled nations that might be working with Germany
					JAP = { is_ai = yes }
				}
				
				JAP = { annex_country = { target = CHI transfer_troops = yes } }
				JAP = { release = CHI }
			}

			# All major powers join the Allies
			every_country = {
				limit = {
					is_major_country = yes
					NOT = { tag = ENG }
					is_in_faction = no
					is_puppet = no
					is_ai = yes # Exclude other player-controlled nations that might be working with Germany
				}

				ENG = { add_to_faction = PREV }
			}

			# All European countries join the Allies
			every_country = {
				limit = {
					is_european_country = yes
					is_in_faction = no
					is_puppet = no
					is_ai = yes # Exclude other player-controlled nations that might be working with Germany
				}

				ENG = { add_to_faction = PREV }
			}
			
			# Start the war
			FRA = {
				create_wargoal = { type = puppet_wargoal_focus target = GER }
				
				if = { # Only declare war if not already at war with Germany
					limit = { 
						NOT = { has_war_with = GER }
					}
					
					if = { # Check if a member of the Allies has a war with Germany, if so, France joins their war
						limit = {
							any_country = { 
								is_in_faction_with = ENG
								has_war_with = GER
							}
						}
						
						random_country = { # France joins another major power's war
							limit = {
								is_major_country = yes
								NOT = { tag = FRA }
								is_in_faction_with = ENG
								is_puppet = no
								has_war_with = GER
							}
							
							FRA = {
								add_to_war = { targeted_alliance = PREV enemy = GER hostility_reason = asked_to_join }
							}
						}
						
						if = { # If France still not at war, join any other member's war
							limit = {
								NOT = { has_war_with = GER }
							}
							
							random_country = {
								limit = {
									is_in_faction_with = ENG
									is_puppet = no
									has_war_with = GER
								}
								
								FRA = {
									add_to_war = { targeted_alliance = PREV enemy = GER hostility_reason = asked_to_join }
								}
							}
						}
					}
					
					if = { # If no one else in Allies has a war with Germany, France declares war
						limit = {
							NOT = { has_war_with = GER } # Verify France still not at war due to above
						}
						
						declare_war_on = { target = GER type = puppet_wargoal_focus }
					}

				}
			}

			# All German puppets join the war
			every_country = {
				limit = {
					is_puppet_of = GER
					NOT = { has_war_with = FRA } 
				}
				
				add_to_war = { targeted_alliance = GER enemy = FRA hostility_reason = puppet }
			}
			
			# All major powers join France in declaring war on Germany
			every_country = {
				limit = {
					is_major_country = yes
					NOT = { tag = FRA }
					is_in_faction_with = ENG
					is_ai = yes # Exclude other player-controlled nations that might be working with Germany
				}

				create_wargoal = { type = puppet_wargoal_focus target = GER }
				
				if = {
					limit = { 
						NOT = { has_war_with = GER } 
					}
					
					add_to_war = { targeted_alliance = FRA enemy = GER hostility_reason = ally }
				}
			}
			
			# All other countries currently in the Allies join France in declaring war on Germany
			all_allies_join_war_against_germany = yes
			
			USA = { country_event = { id = ragnarok.50 } } # Complete industrial national focuses for European minors
			
			USA = { country_event = { id = ragnarok.80 } } # Fire all bypass focus events

		}
	}

	option = {
		name = ragnarok.3.a
		custom_effect_tooltip = ragnarok.cpu1
		custom_effect_tooltip = ragnarok.cpu10

		hidden_effect = {
			# Seems to be bugged sometimes, should be included in the Japan-China peace
			# Previous peace attempts have failed, so just have Japan annex Mengkukuo/Manchukuo
			if = {
				limit = {
					country_exists = MEN
					country_exists = JAP
					MEN = { has_war_with = PRC }
				}
				
				JAP = { annex_country = { target = MEN transfer_troops = yes } }
				set_global_flag = mengkukuo_annexed
			}
			if = {
				limit = {
					country_exists = MAN
					country_exists = JAP
					MAN = { has_war_with = PRC }
				}
				
				JAP = { annex_country = { target = MAN transfer_troops = yes } }
				set_global_flag = manchukuo_annexed
			}
			
			country_event = { id = ragnarok.4 }
		}
	}
}

# Asian countries join the Allies
news_event = {
	id = ragnarok.4
	title = ragnarok.3.t
	desc = {
		trigger = { NOT = { has_global_flag = ragnarok_early_war } }
		text = ragnarok.3.d1
	}
	desc = {
		trigger = { has_global_flag = ragnarok_early_war }
		text = ragnarok.3.d2
	}
	picture = GFX_news_event_019
	
	is_triggered_only = yes
	
	immediate = {
		hidden_effect = {

			# Prevents rebel countries popping up during the war
			every_country = {
				limit = {
					is_ai = yes # Exclude other player-controlled nations that might be working with Germany
					NOT = { tag = GER }
					NOT = { is_puppet_of = GER }
				}

				resistance_disabled = yes
			}
			set_global_flag = ragnarok_uprisings_disabled
			
			if = {
				limit = {
					country_exists = PRC
				}
				
				PRC = { country_event = { id = ragnarok.53 } } # Negate Communist China infiltration
			}
			
			# Release Mengkukuo and/or Manchukuo if they were annexed because of peace bug
			if = {
				limit = {
					has_global_flag = mengkukuo_annexed
					NOT = { country_exists = MEN }
				}
				
				#JAP = { release_puppet = MEN } # doesn't seem to work
				JAP = { 
					release = MEN
					puppet = MEN
				}
				ENG = { add_to_faction = MEN }
				clr_global_flag = mengkukuo_annexed
			}
			if = {
				limit = {
					has_global_flag = manchukuo_annexed
					NOT = { country_exists = MAN }
				}
				
				JAP = { 
					release = MAN
					puppet = MAN
				}
				ENG = { add_to_faction = MAN }
				clr_global_flag = manchukuo_annexed
			}
			
			every_country = {
				limit = {
					is_asian_country = yes
					is_in_faction = no
					is_puppet = no
					is_ai = yes # Exclude other player-controlled nations that might be working with Germany
				}

				ENG = { add_to_faction = PREV }
			}
			
			# All countries in the Allies join France in declaring war on Germany
			all_allies_join_war_against_germany = yes
			
		}
	}

	option = {
		name = ragnarok.3.a
		custom_effect_tooltip = ragnarok.cpu2
		custom_effect_tooltip = ragnarok.cpu10

		hidden_effect = {
			country_event = { id = ragnarok.5 }
		}
	}
}

# African and Middle Eastern countries join the Allies
news_event = {
	id = ragnarok.5
	title = ragnarok.3.t
	desc = {
		trigger = { NOT = { has_global_flag = ragnarok_early_war } }
		text = ragnarok.3.d1
	}
	desc = {
		trigger = { has_global_flag = ragnarok_early_war }
		text = ragnarok.3.d2
	}
	picture = GFX_news_event_019
	
	is_triggered_only = yes
	
	immediate = {
		hidden_effect = {

			every_country = {
				limit = {
					is_african_country = yes
					is_in_faction = no
					is_puppet = no
					is_ai = yes # Exclude other player-controlled nations that might be working with Germany
				}

				ENG = { add_to_faction = PREV }
			}

			# All countries in the Allies join France in declaring war on Germany
			all_allies_join_war_against_germany = yes

		}
	}

	option = {
		name = ragnarok.3.a
		custom_effect_tooltip = ragnarok.cpu3
		custom_effect_tooltip = ragnarok.cpu10

		hidden_effect = {
			country_event = { id = ragnarok.6 }
		}
	}
}

# North and Central American countries join the Allies
news_event = {
	id = ragnarok.6
	title = ragnarok.3.t
	desc = {
		trigger = { NOT = { has_global_flag = ragnarok_early_war } }
		text = ragnarok.3.d1
	}
	desc = {
		trigger = { has_global_flag = ragnarok_early_war }
		text = ragnarok.3.d2
	}
	picture = GFX_news_event_019
	
	is_triggered_only = yes
	
	immediate = {
		hidden_effect = {

			every_country = {
				limit = {
					is_north_american_country = yes
					is_in_faction = no
					is_puppet = no
					is_ai = yes # Exclude other player-controlled nations that might be working with Germany
				}

				ENG = { add_to_faction = PREV }
			}

			# All countries in the Allies join France in declaring war on Germany
			all_allies_join_war_against_germany = yes

		}
	}

	option = {
		name = ragnarok.3.a
		custom_effect_tooltip = ragnarok.cpu4
		custom_effect_tooltip = ragnarok.cpu10

		hidden_effect = {
			country_event = { id = ragnarok.7 }
		}
	}
}

# South American countries join the Allies
news_event = {
	id = ragnarok.7
	title = ragnarok.3.t
	desc = {
		trigger = { NOT = { has_global_flag = ragnarok_early_war } }
		text = ragnarok.3.d1
	}
	desc = {
		trigger = { has_global_flag = ragnarok_early_war }
		text = ragnarok.3.d2
	}
	picture = GFX_news_event_019
	
	is_triggered_only = yes
	
	immediate = {
		hidden_effect = {

			every_country = {
				limit = {
					is_south_american_country = yes
					is_in_faction = no
					is_puppet = no
					is_ai = yes # Exclude other player-controlled nations that might be working with Germany
				}

				ENG = { add_to_faction = PREV }
			}

			# Any remaining countries that might've been missed join the Allies
			every_country = {
				limit = {
					NOT = { tag = GER }
					NOT = { is_puppet_of = GER }
					is_in_faction = no
					is_ai = yes # Exclude other player-controlled nations that might be working with Germany
				}

				ENG = { add_to_faction = PREV }
			}

			# All countries in the Allies join France in declaring war on Germany
			all_allies_join_war_against_germany = yes
			
			# No longer necessary
			every_country = {
				limit = {
					has_idea = avoid_axis_idea
				}

				remove_ideas = avoid_axis_idea
			}
			
			# Ask any non-Germany player countries which side they want to join, if they aren't in an alliance already
			every_country = {
				limit = {
					NOT = { tag = GER }
					is_puppet = no
					is_in_faction = no
					is_ai = no
				}

				country_event = { id = ragnarok.18 } # Ask player countries which side they wish to join in the war
			}
			
		}
	}

	option = {
		name = ragnarok.3.a
		custom_effect_tooltip = ragnarok.cpu5
		
		hidden_effect = {
			country_event = { id = ragnarok.8 days = 2 } # Fire next event in Ragnarok series in a few days
		}
	}
}

# Assigning blame
country_event = {
	id = ragnarok.8
	title = ragnarok.8.t
	desc = {
		trigger = { NOT = { has_global_flag = ragnarok_early_war } }
		text = ragnarok.8.d1
	}
	desc = {
		trigger = { has_global_flag = ragnarok_early_war }
		text = ragnarok.8.d2
	}
	picture = GFX_report_event_german_inspect_troops # GFX_report_event_german_reichstag_gathering

	is_triggered_only = yes
	
	# Himmler? Beck?
	
	option = { 
		name = ragnarok.8.a # Replace Hitler with Göring

		add_war_support = -0.1

		#hidden_effect = {
		#	if = {
		#		limit = {
		#			NOT = { has_completed_focus = GER_ascension_of_goring }
		#		}
		#		complete_national_focus = GER_ascension_of_goring
		#	}
		#}

		custom_effect_tooltip = generic_skip_one_line_tt

		retire_country_leader = yes
		add_political_power = -120
		add_stability = -0.05
		
		custom_effect_tooltip = generic_skip_one_line_tt

		#create_country_leader = {
		#	name = "Hermann Göring"
		#	desc = "POLITICS_HERMANN_GORING_DESC"
		#	picture = "Portrait_Germany_Hermann_Goring.dds"
		#	expire = "1965.1.1"
		#	ideology = nazism
		#	traits = { air_to_ground_proponent }
		#}
		add_country_leader_role = {
			character =  GER_hermann_goring
			country_leader = {
				ideology = nazism
				expire = 1965.1.1
				traits = { GER_goring_fuhrer2 }
			}
			promote_leader = yes
		}
		
		#Manage Inner Circle
		hidden_effect = {
			if = {
				limit = {
					NOT = { has_completed_focus = GER_ascension_of_goring }
				}
				unlock_national_focus = GER_ascension_of_goring
			}

			GER_remove_goring_effects = yes
			GER_replace_goring_as_prevailing_industrialist = yes
		}
		
		add_tech_bonus = {
			name = cv_bonus
			bonus = 1.0
			uses = 1
			category = cv_tech
		}

		hidden_effect = {
			set_country_flag = hitler_replaced
			country_event = { id = ragnarok.9 days = 2 } # Fire next event in Ragnarok series in a few days
		}
	}
	option = { # Keep Hitler
		name = ragnarok.8.b

		add_war_support = -0.15

		custom_effect_tooltip = generic_skip_one_line_tt

		if = {
			limit = { # Only if playing with Man the Guns DLC
				has_dlc = "Man the Guns"
			}
			
			add_tech_bonus = {
				name = bb_bonus
				ahead_reduction = 4
				uses = 1
				technology = advanced_ship_hull_heavy
			}
		}
		else = { # For base game
			add_tech_bonus = {
				name = bb_bonus
				ahead_reduction = 4
				uses = 1
				technology = heavy_battleship2
			}
			custom_effect_tooltip = ragnarok.8.b2
		}
		
		hidden_effect = {
			country_event = { id = ragnarok.9 days = 2 } # Fire next event in Ragnarok series in a few days
		}
	}
}

# German people rally to the cause
country_event = {
	id = ragnarok.9
	title = ragnarok.9.t
	desc = { # Hitler still in charge
		trigger = { NOT = { has_country_flag = hitler_replaced }	}
		text = ragnarok.9.d1
	}
	desc = { # Hitler has been removed from power
		trigger = { has_country_flag = hitler_replaced }
		text = ragnarok.9.d2
	}
	picture = GFX_report_event_ragnarok_olympiastadion
	
	is_triggered_only = yes
	
	immediate = { 
		hidden_effect = {
			
			if = {
				limit = {
					OR = {
						NOT = { country_exists = POL } # if Poland doesn't exist, Ostpreussen is probably safe
						
						AND = {
							divisions_in_state = { state = 763 size > 1 } # Königsberg
							divisions_in_state = { state = 5 size > 1 } # Ermland-Masuren
						}
					}
				}

				set_country_flag = east_prussia_defended
			}
			
			country_event = { id = ragnarok.60 } # AI countries gear up for war
			
		}
	}

	option = {
		name = ragnarok.9.a
		trigger = {
			has_country_flag = east_prussia_defended
		}

		add_political_power = 35
		add_ideas = gotterdammerung

		hidden_effect = {
			clr_country_flag = east_prussia_defended
		}
	}
	option = {
		name = ragnarok.9.b
		trigger = {
			NOT = { has_country_flag = east_prussia_defended }
		}
		custom_effect_tooltip = ragnarok.9.b2

		add_political_power = 30
		add_ideas = gotterdammerung

		hidden_effect = {
			clr_country_flag = east_prussia_defended
		}
	}
}

# Ensures New Year's Eve party event always fires on January 1st, 1937
country_event = {
	id = ragnarok.10
	title = ragnarok.10.t
	desc = ragnarok.10.d
	
	fire_only_once = yes

	trigger = {
		date > 1936.12.31
		is_ai = yes
	}

	mean_time_to_happen = {
		days = 1
	}

	option = {
		name = ragnarok.10.a
		
		if = {
			limit = {
				NOT = { has_global_flag = ragnarok_party }
				NOT = { has_global_flag = ragnarok_early_war }
			}
			
			GER = {	country_event = { id = ragnarok.1 } }
		}
	}
}

# Begins Ragnarok early war scenario
country_event = {
	id = ragnarok.11
	title = ragnarok.11.t
	desc = ragnarok.11.d
	
	fire_only_once = yes

	trigger = {
		is_major = yes
		is_ai = yes # Exclude other player-controlled nations that might be working with Germany

		GER = { has_war = yes }
	}

	mean_time_to_happen = {
		days = 1
	}

	option = {
		name = ragnarok.11.a
		
		if = {
			limit = {
				date < 1937.1.1
				NOT = { has_global_flag = ragnarok_party }
				NOT = { has_global_flag = ragnarok_early_war }
			}
			
			set_global_flag = ragnarok_early_war	

			GER = { remove_ideas = mefo_arms }

			GER = { country_event = { id = ragnarok.15 } } # Makes fascist countries unlikely to join Axis

			disable_events = yes

			# Start the diplomatic conference
			GER = { country_event = { id = ragnarok.2 } }
		}
	}
}

# Free France annexes Vichy France (should never occur unless using an overhaul mod)
country_event = {
	id = ragnarok.14
	title = ragnarok.14.t
	desc = ragnarok.14.d
	
	fire_only_once = yes

	trigger = {
		country_exists = VIC

		is_major = yes
		is_ai = yes # Exclude other player-controlled nations that might be working with Germany

		country_exists = FRA
		OR = {
			has_global_flag = ragnarok_party
			has_global_flag = ragnarok_early_war
		}
		ENG = { has_war_with = GER }
	}

	mean_time_to_happen = {
		days = 5
	}

	option = {
		name = ragnarok.14.a

		FRA = {
			annex_country = { target = VIC transfer_troops = yes }
		
			country_event = { id = ragnarok.16 } # Verify correct leaders for France and Britain
		}
	}
}

# Makes fascist countries unlikely to join Axis
country_event = {
	id = ragnarok.15

	hidden = yes
	
	is_triggered_only = yes

	immediate = {

		every_country = {
			limit = {				
				NOT = { tag = GER }
				NOT = { is_puppet_of = GER }
				NOT = { has_idea = avoid_axis_idea }
				
				OR = {
					has_government = fascism
					tag = HUN
					tag = YUG
					tag = ROM
					tag = BUL
				}
				is_ai = yes # Exclude other player-controlled nations that might be working with Germany
			}

			add_ideas = avoid_axis_idea
		}

		# If Spanish Civil War hasn't started by now, then won't ever happen
		if = {
			limit = {
				NOT = { has_global_flag = spanish_civil_war }
			}

			set_global_flag = spanish_civil_war
			set_global_flag = scw_over
		}
		
	}
}

# Verify correct leaders for France and Britain
# Needs to be done frequently because for some reason it keeps changing
country_event = {
	id = ragnarok.16
	title = ragnarok.16.t
	desc = ragnarok.16.d
	
	fire_only_once = no # in case needs to happen repeatedly

	trigger = {
		is_major = yes
		is_ai = yes

		OR = {
			has_global_flag = ragnarok_party
			has_global_flag = ragnarok_early_war
		}
		GER = { has_war = yes }
	}

	mean_time_to_happen = {
		days = 2
	}

	option = {
		name = ragnarok.16.a

		FRA = {
			if = {
				limit = {
					exists = yes
					is_ai = yes # Exclude other player-controlled nations that might be working with Germany
					NOT = { has_country_leader = { ruling_only = yes character = FRA_charles_de_gaulle } }
				}
				
				if = {
					limit = {
						has_unit_leader = 101 # Charles de Gaulle
					}
					random_unit_leader = {
						limit = {
							has_id = 101 # Charles de Gaulle
						}
						retire = yes
					}
				}
				
				set_country_flag = france_de_gaulle
				
				retire_country_leader = yes
				
				#country_event = { id = france.20 }
				
				# Have to create new this time
				create_country_leader = {
					name = "Charles de Gaulle"
					desc = "POLITICS_CHARLES_DE_GAULLE_DESC"
					picture = GFX_portrait_FRA_charles_de_gaulle
					expire = "1965.1.1"
					ideology = conservatism
					traits = {
					}
				}
				
				if = { # Never seems to get past this focus, so complete it now
					limit = {
						has_focus_tree = free_french_focus
						NOT = { has_completed_focus = FRA_appeal_to_the_french_nation }
					}
					complete_national_focus = FRA_appeal_to_the_french_nation
				}
			}
			
			# Fix bug with Factory Strikes idea
			if = {
				limit = {
					NOT = { has_idea = FRA_matignon_agreements }
				}
				add_ideas = FRA_matignon_agreements
			}
			if = {
				limit = {
					has_idea = FRA_factory_strikes
				}
				remove_ideas = FRA_factory_strikes
			}
			
		}

		ENG = {
			if = {
				limit = {
					exists = yes
					is_ai = yes # Exclude other player-controlled nations that might be working with Germany
					NOT = { has_country_leader = { ruling_only = yes character = ENG_winston_churchill } }
				}

				retire_country_leader = yes
				
				# Have to create new this time
				create_country_leader = {
					name = "Winston Churchill"
					desc = "POLITICS_WINSTON_CHURCHILL_DESC"
					picture = GFX_portrait_Winston_Churchill
					expire = "1965.1.1"
					ideology = conservatism
					traits = {
						british_bulldog
					}
				}
			}		
		}
	}
}

# Ask player countries which side they wish to join in the war
country_event = {
	id = ragnarok.18
	title = ragnarok.18.t
	desc = ragnarok.18.d
	
	is_triggered_only = yes
	
	option = {
		name = ragnarok.18.a
		
		ENG = { add_to_faction = ROOT }
		add_to_war = { targeted_alliance = FRA enemy = GER hostility_reason = asked_to_join }
	}
	option = {
		name = ragnarok.18.b
		
		GER = { add_to_faction = ROOT }
		add_to_war = { targeted_alliance = GER enemy = FRA hostility_reason = asked_to_join }
	}
	option = {
		name = ragnarok.18.c
	}
}

# Random country that is at war with someone besides Germany makes peace
# Alternatively, if world is peaceful, more European democratic or non-aligned countries join the Allies
# Having both peace deals and countries joining the Allies on the same day seems to occasionally cause game crashes
country_event = {
	id = ragnarok.20
	title = ragnarok.20.t
	desc = ragnarok.20.d
	
	is_triggered_only = yes
	
	option = {
		name = ragnarok.20.a

		# Check if any ongoing wars
		if = {
			limit = {
				any_country = {
					has_war = yes
					NOT = { has_war_with = GER }
					NOT = { tag = GER }
					is_puppet = no
					is_ai = yes # Exclude other player-controlled nations that might be working with Germany
				}
			}

			set_global_flag = ongoing_wars
		}
		
		# If there is a war going on, have them make peace
		if = {
			limit = {
				has_global_flag = ongoing_wars
			}
			
			random_country = {
				limit = {
					has_war = yes
					NOT = { has_war_with = GER }
					NOT = { tag = GER }
					is_puppet = no
					is_ai = yes # Exclude other player-controlled nations that might be working with Germany
				}

				country_event = { id = ragnarok.23 } # Excludes puppets
			}
		}
		
		# If no ongoing wars, add a few more random European countries to the Allies
		if = {
			limit = {
				NOT = { has_global_flag = ongoing_wars }
			}

			country_event = { id = ragnarok.27 }
			country_event = { id = ragnarok.27 }
			country_event = { id = ragnarok.27 }
		}		

		clr_global_flag = ongoing_wars
	}
}

# All countries at war with someone besides Germany make peace
# Alternatively, if world is peaceful, more European democratic or non-aligned countries join the Allies
# Having both peace deals and countries joining the Allies on the same day seems to occasionally cause game crashes
country_event = {
	id = ragnarok.21
	title = ragnarok.21.t
	desc = ragnarok.21.d
	
	is_triggered_only = yes
	
	option = {
		name = ragnarok.21.a

		# Check if any ongoing wars
		if = {
			limit = {
				any_country = {
					has_war = yes
					NOT = { tag = GER }
					NOT = { is_puppet_of = GER }
					#is_puppet = no
					is_ai = yes # Exclude other player-controlled nations that might be working with Germany
				}
			}

			set_global_flag = ongoing_wars
		}
		
		# If there are any wars going on, have them all make peace
		if = {
			limit = {
				has_global_flag = ongoing_wars
			}
			
			every_country = {
				limit = {
					has_war = yes
					NOT = { tag = GER }
					NOT = { is_puppet_of = GER }
					#is_puppet = no
					is_ai = yes # Exclude other player-controlled nations that might be working with Germany
				}

				country_event = { id = ragnarok.24 } # Includes puppets
			}
		}
		
		# If no ongoing wars, add a few more random European countries to the Allies
		if = {
			limit = {
				NOT = { has_global_flag = ongoing_wars }
			}

			country_event = { id = ragnarok.27 }
			country_event = { id = ragnarok.27 }
			country_event = { id = ragnarok.27 }
		}		

		clr_global_flag = ongoing_wars
	}
}

# Country makes peace with all other countries excluding puppets (except with Germany)
country_event = {
	id = ragnarok.23
	title = ragnarok.23.t
	desc = ragnarok.23.d
	
	is_triggered_only = yes
	
	option = {
		name = ragnarok.23.a

		every_country = {
			limit = {
				has_war_with = ROOT
				NOT = { tag = GER }
				is_puppet = no
				is_ai = yes # Exclude other player-controlled nations that might be working with Germany
			}

			white_peace = ROOT
		}
	}
}

# Country makes peace with all other countries including puppets (except with Germany)
country_event = {
	id = ragnarok.24
	title = ragnarok.24.t
	desc = ragnarok.24.d
	
	is_triggered_only = yes
	
	option = {
		name = ragnarok.24.a

		every_country = {
			limit = {
				has_war_with = ROOT
				NOT = { tag = GER }
				NOT = { is_puppet_of = GER }
				is_ai = yes # Exclude other player-controlled nations that might be working with Germany
			}

			white_peace = ROOT
		}
	}
}

# Random democratic or non-aligned European country that is at peace joins the Allies
country_event = {
	id = ragnarok.27
	title = ragnarok.27.t
	desc = ragnarok.27.d
	
	is_triggered_only = yes
	
	option = {
		name = ragnarok.27.a

		random_country = {
			limit = {
				is_european_country = yes
				has_war = no
				is_in_faction = no
				is_puppet = no
				OR = {
					has_government = democratic
					has_government = neutrality
				}
				is_ai = yes # Exclude other player-controlled nations that might be working with Germany
			}

			ENG = { add_to_faction = PREV }
		}
	}
}

# Democratic or non-aligned country that is at peace joins the Allies
country_event = {
	id = ragnarok.28
	title = ragnarok.28.t
	desc = ragnarok.28.d
	
	is_triggered_only = yes
	
	option = {
		name = ragnarok.28.a
		
		if = {
			limit = {
				has_war = no
				is_in_faction = no
				is_puppet = no
				OR = {
					has_government = democratic
					has_government = neutrality
				}
				is_ai = yes # Exclude other player-controlled nations that might be working with Germany
			}
			
			ENG = { add_to_faction = ROOT }
		}
	}
}

## Give Germany extra special forces cap after Anschluss
#country_event = {
#	id = ragnarok.33
#
#	hidden = yes
#	
#	fire_only_once = yes
#
#	trigger = {
#		tag = GER
#		
#		OR = {
#			has_country_flag = AUS_annexed
#			has_country_flag = integrated_austria
#		}
#	}
#
#	mean_time_to_happen = {
#		days = 1
#	}
#
#	immediate = {
#		add_ideas = mountain_expertise
#	}
#}

## Give Germany extra operative slots since focus tree doesn't offer any way to get more
#country_event = {
#	id = ragnarok.34
#
#	hidden = yes
#	
#	fire_only_once = yes
#
#	trigger = {
#		tag = GER
#		has_intelligence_agency = yes
#		is_spymaster = yes
#		#has_done_agency_upgrade = upgrade_training_centers
#		#has_done_agency_upgrade = upgrade_commando_training
#	}
#
#	mean_time_to_happen = {
#		days = 1
#	}
#
#	immediate = {
#		add_ideas = abwehr_bonus
#	}
#}

# Give Germany an improved SHBB variant when research is completed
country_event = {
	id = ragnarok.35
	title = ragnarok.35.t
	desc = ragnarok.35.d
	picture = GFX_report_event_ragnarok_battleship
	
	fire_only_once = yes

	trigger = {
		tag = GER
		NOT = { has_country_flag = hitler_replaced }
		NOT = { has_dlc = "Man the Guns" }
		has_tech = heavy_battleship2
	}

	mean_time_to_happen = {
		days = 5
	}
	
	option = {
		name = ragnarok.35.a

		create_equipment_variant = {
			name = "H44 Class"
			type = SH_battleship_2
			design_team = mio:GER_germaniawerft_organization
			parent_version = 0
			upgrades = {
				ship_reliability_upgrade = 5
				ship_engine_upgrade = 5
				ship_armor_upgrade = 5
				ship_gun_upgrade = 5
			}
		}
	}
}

# Steadily increase randomness of the focus start delay for inner circle members
country_event = {
	id = ragnarok.36
	
	hidden = yes

	fire_only_once = no

	trigger = {
		tag = GER
	}

	mean_time_to_happen = {
		days = 180
	}

	immediate = {
		if = {
			limit = {
				check_variable = { GER_inner_circle_random_days < GER_inner_circle_random_days_original_value }
			}
			
			add_to_variable = { GER_inner_circle_random_days = 5 }
		}
	}
}

## Impose a penalty on the Reichskommissariat puppets
#country_event = {
#	id = ragnarok.38
#	
#	hidden = yes
#
#	fire_only_once = no
#
#	trigger = {
#		has_country_flag = GER_reichskommissariats_puppet_flag
#		is_puppet_of = GER
#	}
#
#	mean_time_to_happen = {
#		days = 30
#	}
#
#	immediate = {
#		add_ideas = puppet_resistance_movement
#	}
#}

# Fire 'An Offer from Disgruntled Cossacks' event after Romania or Turkey has fallen
country_event = {
	id = ragnarok.39
	
	hidden = yes

	fire_only_once = yes

	trigger = {
		tag = GER
		
		OR = {
			ROM = { has_capitulated = yes }
			TUR = { has_capitulated = yes }
		}
	}

	mean_time_to_happen = {
		days = 90
	}

	immediate = {
		if = {
			limit = {
				KUB = { exists = no }
				DON = { exists = no }
				
				SOV = {
					NOT = { has_completed_focus = SOV_beaten_but_not_defeated }
				}
			}
			
			country_event = { id = wuw_GER_legions.8 }	
		}
	}
}

# Mod compatibility start screen
country_event = {
	id = ragnarok.40
	title = ragnarok.40.t
	desc = ragnarok.40.d
	
	is_triggered_only = yes

	option = {
		name = ragnarok.40.a
		ai_chance = {
			factor = 100
		}

		hidden_effect = {
			country_event = { id = ragnarok.140 } # Allows player to enable compatibility with various mods
			#country_event = { id = ragnarok.240 } # Temporary compatibility option for Expert AI
		}
	}
	option = {
		name = ragnarok.40.b
		ai_chance = {
			factor = 0
		}

		hidden_effect = {
			country_event = { id = ragnarok.41 } # Help Germany prepare for the coming war
		}
	}
}

# Help Germany prepare for the coming war
# Subject to frequent change based on balance testing
country_event = {
	id = ragnarok.41
	title = ragnarok.41.t
	desc = ragnarok.41.d
	#picture = GFX_report_event_german_troops_paris
	picture = GFX_report_event_hindenburg_flames
	
	is_triggered_only = yes
	
	immediate = {
	
		hidden_effect = {
			set_global_flag = ragnarok_initialized
			set_global_flag = state_renames_handled
			
			apply_immediate_difficulty_settings = yes
			
			YUG = {
				if = {
					limit = {
						is_ai = yes # Exclude other player-controlled nations that might be working with Germany
					}
					country_event = { id = ragnarok.90 } # Prevent DOD_yugoslavia.10 event from occurring as it causes a tremendous amount of lag shortly after war begins
				}
			}
			
			ENG = { # Force England down ahistorical path
				if = {
					limit = { 
						is_ai = yes # Exclude other player-controlled nations that might be working with Germany
						NOT = { has_completed_focus = ENG_global_defense }
						NOT = { has_completed_focus = ENG_home_defence }
					}
					complete_national_focus = ENG_global_defense
				}
			}
		}
		
	}

	option = { # Normal difficulty
		name = ragnarok.41.a1
		ai_chance = {
			factor = 100
		}

		add_equipment_to_stockpile = { type = infantry_equipment_1 amount = 68000 producer = GER }
		add_equipment_to_stockpile = { type = support_equipment_1 amount = 5750 producer = GER }
		add_equipment_to_stockpile = { type = artillery_equipment_1 amount = 4000 producer = GER }
		add_equipment_to_stockpile = { type = anti_air_equipment_1 amount = 2600 producer = GER }
		add_equipment_to_stockpile = { type = motorized_equipment_1 amount = 1800 producer = GER }
		
		set_country_flag = ragnarok_difficulty_normal
		apply_common_difficulty_settings = yes
	}
	option = { # Challenging difficulty
		name = ragnarok.41.a2
		ai_chance = {
			factor = 0
		}

		add_equipment_to_stockpile = { type = infantry_equipment_1 amount = 42000 producer = GER }
		add_equipment_to_stockpile = { type = support_equipment_1 amount = 3200 producer = GER }
		add_equipment_to_stockpile = { type = artillery_equipment_1 amount = 1250 producer = GER }
		add_equipment_to_stockpile = { type = anti_air_equipment_1 amount = 800 producer = GER }
		add_equipment_to_stockpile = { type = motorized_equipment_1 amount = 1200 producer = GER }
		
		set_country_flag = ragnarok_difficulty_challenging
		apply_common_difficulty_settings = yes
	}
	option = { # Brutal difficulty
		name = ragnarok.41.a3
		ai_chance = {
			factor = 0
		}

		add_equipment_to_stockpile = { type = infantry_equipment_1 amount = 8000 producer = GER }
		
		set_country_flag = ragnarok_difficulty_brutal
		apply_common_difficulty_settings = yes
	}
}

# Complete Italian-German Technology Treaty before world war starts
country_event = {
	id = ragnarok.46
	title = ragnarok.46.t
	desc = ragnarok.46.d
	
	fire_only_once = yes

	trigger = {
		tag = ITA
		date > 1936.10.12
		is_ai = yes # Exclude other player-controlled nations that might be working with Germany
	}

	mean_time_to_happen = {
		days = 2
	}
	
	option = {
		name = ragnarok.46.a

		if = {
			limit = {
				date < 1937.1.1
				NOT = { has_completed_focus = ITA_treaty_with_germany }
				NOT = { has_global_flag = ragnarok_early_war }
				NOT = { has_war_with = GER }
			}
			
			complete_national_focus = ITA_treaty_with_germany
		}
		
	}
}

# Forcibly end Italian-Ethiopian War a couple months before the war
# Gives Italy time to send their troops back home, otherwise Italy will be very poorly defended
country_event = {
	id = ragnarok.47
	title = ragnarok.47.t
	desc = ragnarok.47.d
	
	fire_only_once = yes

	trigger = {
		tag = ITA
		date > 1936.11.1
		is_ai = yes # Exclude other player-controlled nations that might be working with Germany
	}

	mean_time_to_happen = {
		days = 2
	}
	
	option = {
		name = ragnarok.47.a

		if = {
			limit = {
				date < 1937.1.1
				NOT = { has_global_flag = ragnarok_early_war }
				country_exists = ETH
				has_war_with = ETH
			}

			annex_country = { target = ETH }
		}
	}
}

# Get rid of the Chinese warlords, makes China stronger and speeds up the process of countries joining the Allies
country_event = {
	id = ragnarok.48
	title = ragnarok.48.t
	desc = ragnarok.48.d
	
	is_triggered_only = yes
	
	option = {
		name = ragnarok.48.a

		if = {
			limit = {
				country_exists = CHI
				
				CHI = { is_ai = yes } # Exclude other player-controlled nations that might be working with Germany
				JAP = { is_ai = yes } # Exclude other player-controlled nations that might be working with Germany
			}

			CHI = {
				if = {
					limit = {
						country_exists = GXC
					}
					
					annex_country = { target = GXC transfer_troops = yes }
				}
				if = {
					limit = {
						country_exists = YUN
					}
					
					annex_country = { target = YUN transfer_troops = yes }
				}
				if = {
					limit = {
						country_exists = XSM
					}
					
					annex_country = { target = XSM transfer_troops = yes }
				}
				if = {
					limit = {
						country_exists = SIK
					}
					
					annex_country = { target = SIK transfer_troops = yes }
				}
				if = {
					limit = {
						country_exists = SHX
						NOT = { country_exists = PRC }
					}
					
					annex_country = { target = SHX transfer_troops = yes }
				}
			
				if = {
					limit = {
						has_focus_tree = china_nationalist_focus
						NOT = { has_completed_focus = CHI_subjugate_the_warlords }
					}
					
					unlock_national_focus = CHI_subjugate_the_warlords
				}
			
				if = {
					limit = {
						JAP = { controls_state = 609 } # East Hebei
					}
					
					transfer_state = 609 # East Hebei
				}
				if = {
					limit = {
						JAP = { controls_state = 524 } # Taiwan
					}
					
					transfer_state = 524 # Taiwan
				}
			}
		}
		
		if = {
			limit = {
				country_exists = PRC
				country_exists = SHX
				
				CHI = { is_ai = yes } # Exclude other player-controlled nations that might be working with Germany
				JAP = { is_ai = yes } # Exclude other player-controlled nations that might be working with Germany
			}

			PRC = { annex_country = { target = SHX transfer_troops = yes } }
		}
		
		if = {
			limit = {
				country_exists = MAN
				
				MAN = { is_ai = yes } # Exclude other player-controlled nations that might be working with Germany
				JAP = { is_ai = yes } # Exclude other player-controlled nations that might be working with Germany

				JAP = { controls_state = 745 } # Dalian
			}

			MAN = { transfer_state = 745 } # Dalian
		}
		
		if = {
			limit = {
				country_exists = CHI
				
				CHI = { is_ai = yes } # Exclude other player-controlled nations that might be working with Germany
				FRA = { is_ai = yes } # Exclude other player-controlled nations that might be working with Germany

				FRA = { controls_state = 728 } # Guangzhouwan
			}

			CHI = { transfer_state = 728 } # Guangzhouwan
		}
		
	}
}

# Adjust political systems for Allies
country_event = {
	id = ragnarok.49

	hidden = yes
	
	is_triggered_only = yes
	
	immediate = {
	
		FRA = {
			if = {
				limit = {
					has_idea = FRA_disjointed_government
				}
				remove_ideas = FRA_disjointed_government
			}
		
			#remove_country_leader_trait = stout_defender
			#retire_country_leader = yes
			
			country_event = { id = france.20 }
			
			#create_country_leader = {
			#	name = "Charles de Gaulle"
			#	desc = "POLITICS_CHARLES_DE_GAULLE_DESC"
			#	picture = GFX_portrait_FRA_charles_de_gaulle
			#	expire = "1965.1.1"
			#	ideology = conservatism
			#	traits = {
			#	}
			#}
			
			#set_country_leader_ideology = moderatism # Neutrality ideology
			#add_popularity = {
			#	ideology = neutrality
			#	popularity = 0.5
			#}
			#set_politics = {
			#	ruling_party = neutrality
			#	elections_allowed = no
			#}
			
			add_stability = 0.30
			add_war_support = 0.20
			add_political_power = 180
			
			add_ideas = FRA_gaston_henry_haye
		}

		ENG = {
			if = {
				limit = {
					has_government = democratic
					NOT = { has_global_flag = chamberlain_resigned }
					NOT = { has_global_flag = chamberlain_died }
				}
				
				set_country_flag = chamberlain_resigned
				set_country_flag = chamberlain_died
				
				if = {
					limit = {
						has_dlc = "Man the Guns"
					}
					
					country_event = { id = mtg_britain.22 }
				}
				else = {
					retire_country_leader = yes
					create_country_leader = {
						name = "Winston Churchill"
						desc = "POLITICS_WINSTON_CHURCHILL_DESC"
						picture = GFX_portrait_Winston_Churchill
						expire = "1965.1.1"
						ideology = conservatism
						traits = {
							british_bulldog
						}
					}
				}
			}
			
			add_political_power = 180
		}
		
	}
}

# Once world war begins, finish the industrial national focus trees for the European minors
country_event = {
	id = ragnarok.50
	title = ragnarok.50.t
	desc = ragnarok.50.d
	
	is_triggered_only = yes
	
	option = {
		name = ragnarok.50.a
		
		every_country = {
			limit = {
				is_european_country = yes
				is_ai = yes # Exclude other player-controlled nations that might be working with Germany
				NOT = { is_puppet_of = GER }
			}
			
			complete_industrial_focuses = yes
		}
		
		apply_late_difficulty_settings = yes
		
		# Prevent Croatian uprising
		YUG = {
			remove_ideas = YUG_idea_croatian_opposition
			remove_ideas = YUG_idea_croats_suppressed

			set_global_flag = ustasa_crushed
		
			add_stability = 0.20
		}
		
		if = {
			limit = {
				country_exists = SPA
				is_ai = yes # Exclude other player-controlled nations that might be working with Germany
			}
			
			SPA = { country_event = { id = ragnarok.52 } } # Give Spain a few more factories since it has very few and no national focuses that give more
		}
		else_if = {
			limit = {
				country_exists = SPR
				is_ai = yes # Exclude other player-controlled nations that might be working with Germany
			}
			
			SPR = { country_event = { id = ragnarok.52 } } # Give Spain a few more factories since it has very few and no national focuses that give more
		}
		
	}
}

# Give Spain a few more factories since it has very few and no national focuses that give more
country_event = {
	id = ragnarok.52

	hidden = yes
	
	is_triggered_only = yes
	
	immediate = {
		
		every_core_state = {
			random_select_amount = 6
			limit = {
				is_fully_controlled_by = ROOT
				infrastructure > 2
				free_building_slots = {
					building = industrial_complex
					size > 0
					include_locked = yes
				}
			}
			
			add_extra_state_shared_building_slots = 1
			add_building_construction = {
				type = industrial_complex
				level = 1
				instant_build = yes
			}
		}
		
		every_core_state = {
			random_select_amount = 2
			limit = {
				is_fully_controlled_by = ROOT
				infrastructure > 2
				free_building_slots = {
					building = arms_factory
					size > 0
					include_locked = yes
				}
			}
			
			add_extra_state_shared_building_slots = 1
			add_building_construction = {
				type = arms_factory
				level = 1
				instant_build = yes
			}
		}
		
	}
}

# Negate Communist China infiltration
country_event = {
	id = ragnarok.53

	hidden = yes
	
	fire_only_once = no # needs to be recurring
	
	trigger = {
		tag = PRC
		is_ai = yes
		
		OR = {
			has_global_flag = ragnarok_party
			has_global_flag = ragnarok_early_war
		}
	}

	mean_time_to_happen = {
		days = 60
	}
	
	immediate = {
		
		clr_country_flag = wtt_political_struggle
		clear_variable = total_political_support_points
		
		event_target:WTT_current_china_leader = {
			every_controlled_state = {
				clr_state_flag = PRC_infiltration_@ROOT
				clr_state_flag = discovered_infiltration
			}
		}

		MAN = {
			every_controlled_state = {
				clr_state_flag = PRC_infiltration_@ROOT
				clr_state_flag = discovered_infiltration
			}
		}

		MEN = {
			every_controlled_state = {
				clr_state_flag = PRC_infiltration_@ROOT
				clr_state_flag = discovered_infiltration
			}
		}

		JAP = {
			every_controlled_state = {
				clr_state_flag = PRC_infiltration_@ROOT
				clr_state_flag = discovered_infiltration
			}
		}

	}
}

# Complete Poland's Danzig-related national focuses a little sooner because they add some forts
country_event = {
	id = ragnarok.54

	hidden = yes
	
	fire_only_once = yes
	
	trigger = {
		tag = POL
		date > 1936.11.1
		is_ai = yes
	}

	mean_time_to_happen = {
		days = 2
	}
	
	immediate = {
		
		if = {
			limit = {
				NOT = { has_war_with = GER }
				NOT = { has_global_flag = ragnarok_party }
				NOT = { has_global_flag = ragnarok_early_war }
			}

			complete_industrial_focuses_POL_danzig = yes
		}

	}
}

# AI countries gear up for war (phase 1) - 1937
country_event = {
	id = ragnarok.60

	hidden = yes
	
	is_triggered_only = yes
	
	immediate = {
		
		set_global_flag = ragnarok_applied_stable_government
		
		every_country = {
			limit = {
				has_war_with = GER
			}

			apply_AI_bonuses = yes
		}
		
		CHI = {
			add_ideas = tot_economic_mobilisation
		}

		FRA = {
			#if = {
			#	limit = {
			#		has_idea = FRA_victors_of_wwi
			#	}
			#	remove_ideas = FRA_victors_of_wwi
			#}
			
			add_stability = 0.15
		}
		
		#ENG = {
		#	if = {
		#		limit = {
		#			has_idea = ENG_the_war_to_end_all_wars
		#		}
		#		remove_ideas = ENG_the_war_to_end_all_wars
		#	}
		#}

	}
}

# AI countries gear up for war (phase 2) - 1938
country_event = {
	id = ragnarok.61

	hidden = yes

	fire_only_once = yes

	trigger = {
		tag = USA
		date > 1938.1.1
	}

	mean_time_to_happen = {
		days = 5
	}
	
	immediate = {
		
		# Give USA some help with landing techs
		add_tech_bonus = {
			name = tp_bonus
			bonus = 1.0
			uses = 2
			technology = transport
			technology = landing_craft
			technology = tank_landing_craft
		}

		# If Soviet Union hasn't gotten Russian Bear Awakes event before 1938, fire it now
		SOV = {
			if = {
				limit = {
					exists = yes
					is_ai = yes # Exclude other player-controlled nations that might be working with Germany
					NOT = { has_idea = russian_bear_awakes }
				}
				
				country_event = { id = ragnarok.71 }
			}
		}

		allied_resource_bonus = yes # Extra resources for some of the major powers
	}
}

# Guarantees certain major powers keep a good chunk of their resources for themselves
# Also has some resource-rich countries stay on Free Trade
country_event = {
	id = ragnarok.62

	hidden = yes
	
	fire_only_once = no

	trigger = {
		tag = USA
		OR = {
			has_global_flag = ragnarok_party
			has_global_flag = ragnarok_early_war
		}
	}

	mean_time_to_happen = {
		days = 30
	}
	
	immediate = {
	
		every_country = {
			limit = {
				OR = {
					tag = SOV
					tag = CHI
					
					AND = {
						tag = USA
						date > 1939.1.1
					}
				}
				
				is_ai = yes # Exclude other player-controlled nations that might be working with Germany
				
				has_idea = free_trade
			}

			add_ideas = export_focus
		}
		
		every_country = {
			limit = {
				OR = {
					tag = JAP
					tag = ITA
				}
				
				is_ai = yes # Exclude other player-controlled nations that might be working with Germany
				
				NOT = { has_idea = limited_exports }
				NOT = { has_idea = closed_economy }
			}

			add_ideas = limited_exports
		}
		
		every_country = {
			limit = {
				OR = {
					tag = INS
					tag = MAL
					tag = SIA
					tag = RAJ
					tag = BRA
				}
				
				is_ai = yes # Exclude other player-controlled nations that might be working with Germany
				
				NOT = { has_idea = free_trade }
			}

			add_ideas = free_trade
		}
		
	}
}

# Maintenance event for Stable Government ideas
# In case government changed by focus/event
country_event = {
	id = ragnarok.63

	hidden = yes
	
	fire_only_once = no

	trigger = {
		tag = USA
		OR = {
			has_global_flag = ragnarok_party
			has_global_flag = ragnarok_early_war
		}
	}

	mean_time_to_happen = {
		days = 75
	}
	
	immediate = {

		every_country = {
			limit = {
				has_war_with = GER
				is_ai = yes # Exclude other player-controlled nations that might be working with Germany
			}

			if = { # Ensure government type matches Stable Government idea
				limit = {
					OR = {
						AND = {
							has_government = fascism
							NOT = { has_idea = stable_government_fascism }
						}
						AND = {
							has_government = communism
							NOT = { has_idea = stable_government_communism }
						}
						AND = {
							has_government = democratic
							NOT = { has_idea = stable_government_democratic }
						}
						AND = {
							has_government = neutrality
							NOT = { has_idea = stable_government_unaligned }
						}
					}
				}
					
				# Remove any existing Stable Governemnt idea
				remove_ideas = stable_government_fascism
				remove_ideas = stable_government_communism
				remove_ideas = stable_government_democratic
				remove_ideas = stable_government_unaligned

				apply_AI_stable_government = yes
			}
		}
		
	}
}

# Sync naval invasions - enable landings
country_event = {
	id = ragnarok.65

	hidden = yes
	
	fire_only_once = no

	trigger = {
		tag = USA
		NOT = { has_global_flag = naval_invasions_active }
		has_war_with = GER
	}

	mean_time_to_happen = {
		days = 165
	}
	
	immediate = {
	
		set_global_flag = naval_invasions_active

		if = {
			limit = {
				FRA = { has_capitulated = yes }
			}
			
			ENG = { set_country_flag = launch_naval_invasion }
			USA = { set_country_flag = launch_naval_invasion }
			CAN = { set_country_flag = launch_naval_invasion }
		}
	
		if = {
			limit = {
				OR = {
					ITA = { has_capitulated = yes }
				
					AND = {
						BUL = { has_capitulated = yes }
						GRE = { has_capitulated = yes }
					}
				}
			}
			
			JAP = { set_country_flag = launch_naval_invasion }
		}
	
		if = {
			limit = {
				OR = {
					date > 1937.10.1
					POL = { has_capitulated = yes }
				}
			}
			
			NOR = { set_country_flag = launch_naval_invasion }
			SWE = { set_country_flag = launch_naval_invasion }
			FIN = { set_country_flag = launch_naval_invasion }
		}
		
	}
}

# Sync naval invasions - disable landings
# Gives countries time to rebuild their armies after the naval invasions
country_event = {
	id = ragnarok.66

	hidden = yes
	
	fire_only_once = no

	trigger = {
		tag = USA
		has_global_flag = naval_invasions_active
	}

	mean_time_to_happen = {
		days = 75
	}
	
	immediate = {
	
		clr_global_flag =  naval_invasions_active
	
		every_country = {
			limit = {
				has_country_flag = launch_naval_invasion
			}

			clr_country_flag = launch_naval_invasion
		}
		
	}
}

# Soviet Union receives some armor bonuses
country_event = {
	id = ragnarok.70
	title = ragnarok.70.t
	desc = ragnarok.70.d
	
	fire_only_once = yes

	trigger = {
		tag = SOV
		is_ai = yes # Exclude other player-controlled nations that might be working with Germany
		date > 1936.9.26
	}

	mean_time_to_happen = {
		days = 5
	}
	
	option = {
		name = ragnarok.70.a
		
		if = {
			limit = {
				NOT = { has_dlc = "Arms Against Tyranny" }
				SOV_has_active_tank_designer_any = no
			}
			
			add_ideas = SOV_morozov_design_bureau
		}
		
		if = {
			limit = { # Only if playing with No Step Back DLC
				has_dlc = "No Step Back"
			}
			
			if = { # Normally starts with this, but just in case
				limit = {
					NOT = { has_tech = basic_light_tank_chassis }
				}
				set_technology = { basic_light_tank_chassis = 1 }
			}
			if = {
				limit = {
					NOT = { has_tech = improved_light_tank_chassis }
				}
				set_technology = { improved_light_tank_chassis = 1 }
			}
		}
		else = { # For base game
			if = { # Normally starts with this, but just in case
				limit = {
					NOT = { has_tech = basic_light_tank }
				}
				set_technology = { basic_light_tank = 1 }
			}
			if = {
				limit = {
					NOT = { has_tech = improved_light_tank }
				}
				set_technology = { improved_light_tank = 1 }
			}
		}

		if = {
			limit = {
				NOT = { has_tech = interwar_antitank }
			}
			set_technology = { interwar_antitank = 1 }
		}
	}
}

# Russian Bear Awakes
country_event = {
	id = ragnarok.71
	title = ragnarok.71.t
	desc = ragnarok.71.d
	
	fire_only_once = yes

	trigger = {
		tag = SOV
		is_ai = yes # Exclude other player-controlled nations that might be working with Germany
		date > 1937.2.15
		OR = {
			has_global_flag = ragnarok_party
			has_global_flag = ragnarok_early_war
		}
	}

	mean_time_to_happen = {
		days = 120
	}
	
	option = {
		name = ragnarok.71.a
		
		add_ideas = russian_bear_awakes

		if = {
			limit = {
				NOT = { has_idea = tot_economic_mobilisation }
			}
			
			add_ideas = tot_economic_mobilisation
			activate_decision = women_in_the_workforce
		}
		
		if = { # Only if playing with No Step Back DLC
			limit = {
				has_dlc = "No Step Back"
			}
			
			if = {
				limit = {
					NOT = { has_tech = basic_medium_tank_chassis }
				}
				set_technology = { basic_medium_tank_chassis = 1 }
			}
			if = { # Normally starts with this, but just in case
				limit = {
					NOT = { has_tech = basic_heavy_tank_chassis }
				}
				set_technology = { basic_heavy_tank_chassis = 1 }
			}
			if = { # Normally starts with this, but just in case
				limit = {
					NOT = { has_tech = engine_tech_1 }
				}
				set_technology = { engine_tech_1 = 1 }
			}
			if = { # Normally starts with this, but just in case
				limit = {
					NOT = { has_tech = engine_tech_2 }
				}
				set_technology = { engine_tech_2 = 1 }
			}
			
			# A-20 tank variant automatically created if Treaty with the USSR focus completed
			if = {
				limit = {
					GER = { NOT = { has_country_flag = completed_treaty_with_ussr } }
				}

				create_equipment_variant = {
					name = "A-20"
					type = medium_tank_chassis_1
					design_team = mio:SOV_morozov_design_bureau_organization
					parent_version = 0
					modules = {
						main_armament_slot = tank_small_cannon_2
						turret_type_slot = tank_medium_two_man_tank_turret
						suspension_type_slot = tank_christie_suspension
						armor_type_slot = tank_welded_armor
						engine_type_slot = tank_diesel_engine
						special_type_slot_1 = sloped_armor
					}
					upgrades = {
						tank_nsb_engine_upgrade = 8
						tank_nsb_armor_upgrade = 2
					}
					icon = "GFX_SOV_basic_medium_tank_medium"
				}
			}
			
			add_equipment_production = {
				equipment = {
					type = medium_tank_chassis_1
					creator = "SOV"
					version_name = "A-20"
				}
				requested_factories = 8
				progress = 0.5
				efficiency = 100
				industrial_manufacturer = mio:SOV_astrov_design_bureau_organization
			}
		}
		else = { # For base game
			if = {
				limit = {
					NOT = { has_tech = basic_medium_tank }
				}
				set_technology = { basic_medium_tank = 1 }
			}
			if = { # Normally starts with this, but just in case
				limit = {
					NOT = { has_tech = basic_heavy_tank }
				}
				set_technology = { basic_heavy_tank = 1 }
			}
			
			add_equipment_production = {
				equipment = {
					type = medium_tank_equipment_1
					creator = "SOV" 
				}
				requested_factories = 8
				progress = 0.5
				efficiency = 100
				industrial_manufacturer = mio:SOV_astrov_design_bureau_organization
			}
		}

		load_oob = "SOV_tank_template"

		soviet_industrial_buildup = yes # Build 8 civilian and 12 military factories in the east
		
		229 = { # Azerbaijan
			add_building_construction = {
				type = infrastructure
				level = 1
				instant_build = yes
			}
			add_extra_state_shared_building_slots = 1
			add_building_construction = {
				type = fuel_silo
				level = 1
				instant_build = yes
			}
		}
		232 = { # Dagestan
			add_building_construction = {
				type = infrastructure
				level = 1
				instant_build = yes
			}
		}
		821 = { # Chechnya-Ingushetia
			add_building_construction = {
				type = infrastructure
				level = 1
				instant_build = yes
			}
		}
		
	}
}

# Soviets redouble their efforts after the fall of France
country_event = {
	id = ragnarok.72
	title = ragnarok.72.t
	desc = ragnarok.72.d
	
	fire_only_once = yes

	trigger = {
		tag = SOV
		has_global_flag = achievement_france_surrender
		is_ai = yes # Exclude other player-controlled nations that might be working with Germany		
		has_idea = russian_bear_awakes
		
		set_temp_variable = { t = global.num_days }
		subtract_from_temp_variable = { t = global.FRA_capitulation_days }
		OR = {
			AND = {				
				GER = { has_country_flag = completed_treaty_with_ussr }
				check_variable = { t > 30 }
			}
			
			AND = { # Longer delay if did not sign Treaty with the USSR
				GER = { NOT = { has_country_flag = completed_treaty_with_ussr } }
				check_variable = { t > 90 }
			}
		}
	}

	mean_time_to_happen = {
		days = 90
	}
	
	option = {
		name = ragnarok.72.a
		
		set_country_flag = intensify_tank_production
	
		add_doctrine_cost_reduction = {
			name = land_doc_bonus
			cost_reduction = 0.5
			uses = 1
			category = land_doctrine
		}
		army_experience = 60

		if = {
			limit = {
				NOT = { has_tech = interwar_artillery }
			}
			set_technology = { interwar_artillery = 1 }
		}
		if = {
			limit = {
				NOT = { has_tech = artillery1 }
			}
			set_technology = { artillery1 = 1 }
		}
		if = {
			limit = {
				NOT = { has_tech = antitank1 }
			}
			set_technology = { antitank1 = 1 }
		}
		if = {
			limit = {
				NOT = { has_tech = motorized_rocket_unit }
			}
			set_technology = { motorized_rocket_unit = 1 }
		}

		add_equipment_production = {
			equipment = {
				type = motorized_rocket_equipment_1
				creator = "SOV" 
			}
			requested_factories = 3
			progress = 0.5
			efficiency = 100
			industrial_manufacturer = mio:SOV_gaz_organization
		}

		if = { # Only if playing with No Step Back DLC
			limit = {
				has_dlc = "No Step Back"
			}
			
			if = {
				limit = {
					NOT = { has_tech = improved_medium_tank_chassis }
				}
				set_technology = { improved_medium_tank_chassis = 1 }
			}
			if = {
				limit = {
					NOT = { has_tech = improved_heavy_tank_chassis }
				}
				set_technology = { improved_heavy_tank_chassis = 1 }
			}
			if = {
				limit = {
					NOT = { has_tech = armor_tech_1 }
				}
				set_technology = { armor_tech_1 = 1 }
			}
			
			# Focus will give T-34 tank variant
			if = {
				limit = {
					NOT = { has_completed_focus = SOV_superior_war_machines }
				}
				complete_national_focus = SOV_superior_war_machines
			}

			create_equipment_variant = {
				name = "KV-1S"
				type = heavy_tank_chassis_2
				design_team = mio:SOV_kirov_organization
				parent_version = 0
				modules = {
					main_armament_slot = tank_medium_cannon
					turret_type_slot = tank_heavy_three_man_tank_turret
					suspension_type_slot = tank_torsion_bar_suspension
					armor_type_slot = tank_welded_armor
					engine_type_slot = tank_diesel_engine
				}
				upgrades = {
					tank_nsb_engine_upgrade = 10
					tank_nsb_armor_upgrade = 8
				}
				icon = "GFX_SOV_improved_heavy_tank_medium"
			}
			
			add_equipment_production = {
				equipment = {
					type = heavy_tank_chassis_2
					creator = "SOV" 
					version_name = "KV-1S"
				}
				requested_factories = 3
				progress = 0.5
				efficiency = 100
				industrial_manufacturer = mio:SOV_kirov_organization
			}
		}
		else = { # For base game
			if = {
				limit = {
					NOT = { has_tech = improved_medium_tank }
				}
				set_technology = { improved_medium_tank = 1 }
			}
			if = {
				limit = {
					NOT = { has_tech = improved_heavy_tank }
				}
				set_technology = { improved_heavy_tank = 1 }
			}
			
			add_equipment_production = {
				equipment = {
					type = heavy_tank_equipment_2
					creator = "SOV" 
				}
				requested_factories = 3
				progress = 0.5
				efficiency = 100
				industrial_manufacturer = mio:SOV_kirov_organization
			}
		}

		load_oob = "SOV_heavy_tank_template"

		soviet_industrial_buildup = yes # Build 8 civilian and 12 military factories in the east
	}
}

# Advanced Soviet tank designs
country_event = {
	id = ragnarok.73
	title = ragnarok.73.t
	desc = ragnarok.73.d
	
	fire_only_once = yes

	trigger = {
		tag = SOV
		is_ai = yes # Exclude other player-controlled nations that might be working with Germany		
		has_idea = russian_bear_awakes
		
		OR = {
			AND = {
				date > 1941.4.1
				GER = { has_country_flag = completed_treaty_with_ussr }
			}
			
			AND = { # Several months later if did not sign Treaty with the USSR
				date > 1942.1.1
				GER = { NOT = { has_country_flag = completed_treaty_with_ussr } }
			}
		}
	}

	mean_time_to_happen = {
		days = 90
	}
	
	option = {
		name = ragnarok.73.a
		
		set_country_flag = advanced_tank_production

		if = {
			limit = {
				NOT = { has_tech = mechanised_infantry }
			}
			set_technology = { mechanised_infantry = 1 }
		}
		if = {
			limit = {
				NOT = { has_tech = mechanised_infantry2 }
			}
			set_technology = { mechanised_infantry2 = 1 }
		}
		if = { # Should already have this, but just in case
			limit = {
				NOT = { has_tech = artillery1 }
			}
			set_technology = { artillery1 = 1 }
		}
		if = {
			limit = {
				NOT = { has_tech = artillery2 }
			}
			set_technology = { artillery2 = 1 }
		}
		if = {
			limit = {
				NOT = { has_tech = rocket_artillery }
			}
			set_technology = { rocket_artillery = 1 }
		}
		if = {
			limit = {
				NOT = { has_tech = rocket_artillery2 }
			}
			set_technology = { rocket_artillery2 = 1 }
		}
		if = { # Should already have this, but just in case
			limit = {
				NOT = { has_tech = motorized_rocket_unit }
			}
			set_technology = { motorized_rocket_unit = 1 }
		}
		if = { # Should already have this, but just in case
			limit = {
				NOT = { has_tech = antitank1 }
			}
			set_technology = { antitank1 = 1 }
		}
		if = {
			limit = {
				NOT = { has_tech = antitank2 }
			}
			set_technology = { antitank2 = 1 }
		}
		if = {
			limit = {
				NOT = { has_tech = antitank3 }
			}
			set_technology = { antitank3 = 1 }
		}

		if = { # Only if playing with No Step Back DLC
			limit = {
				has_dlc = "No Step Back"
			}
			
			if = { # Should already have this, but just in case
				limit = {
					NOT = { has_tech = improved_medium_tank_chassis }
				}
				set_technology = { improved_medium_tank_chassis = 1 }
			}
			if = {
				limit = {
					NOT = { has_tech = advanced_medium_tank_chassis }
				}
				set_technology = { advanced_medium_tank_chassis = 1 }
			}
			if = { # Should already have this, but just in case
				limit = {
					NOT = { has_tech = improved_heavy_tank_chassis }
				}
				set_technology = { improved_heavy_tank_chassis = 1 }
			}
			if = {
				limit = {
					NOT = { has_tech = advanced_heavy_tank_chassis }
				}
				set_technology = { advanced_heavy_tank_chassis = 1 }
			}
			if = { # Should already have this, but just in case
				limit = {
					NOT = { has_tech = armor_tech_1 }
				}
				set_technology = { armor_tech_1 = 1 }
			}
			if = {
				limit = {
					NOT = { has_tech = armor_tech_2 }
				}
				set_technology = { armor_tech_2 = 1 }
			}
			if = {
				limit = {
					NOT = { has_tech = engine_tech_3 }
				}
				set_technology = { engine_tech_3 = 1 }
			}
			
			create_equipment_variant = {
				name = "T-34-85"
				type = medium_tank_chassis_3
				design_team = mio:SOV_morozov_design_bureau_organization
				parent_version = 0
				modules = {
					main_armament_slot = tank_medium_cannon_2
					turret_type_slot = tank_medium_three_man_tank_turret
					suspension_type_slot = tank_christie_suspension
					armor_type_slot = tank_welded_armor
					engine_type_slot = tank_diesel_engine
					special_type_slot_1 = sloped_armor
				}
				upgrades = {
					tank_nsb_engine_upgrade = 12
					tank_nsb_armor_upgrade = 9
				}
				icon = "GFX_SOV_improved_medium_tank_medium"
			}
			
			create_equipment_variant = {
				name = "IS-2"
				type = heavy_tank_chassis_3
				design_team = mio:SOV_kirov_organization
				parent_version = 0
				modules = {
					main_armament_slot = tank_heavy_cannon_2
					turret_type_slot = tank_heavy_three_man_tank_turret
					suspension_type_slot = tank_torsion_bar_suspension
					armor_type_slot = tank_welded_armor
					engine_type_slot = tank_diesel_engine
					special_type_slot_1 = tank_radio_1
					special_type_slot_2 = sloped_armor
					special_type_slot_3 = smoke_launchers
				}
				upgrades = {
					tank_nsb_engine_upgrade = 8
					tank_nsb_armor_upgrade = 6
				}
				icon = "GFX_SOV_advanced_heavy_tank_medium"
			}
		}
		else = { # For base game
			if = { # Should already have this, but just in case
				limit = {
					NOT = { has_tech = improved_medium_tank }
				}
				set_technology = { improved_medium_tank = 1 }
			}
			if = {
				limit = {
					NOT = { has_tech = advanced_medium_tank }
				}
				set_technology = { advanced_medium_tank = 1 }
			}
			if = { # Should already have this, but just in case
				limit = {
					NOT = { has_tech = improved_heavy_tank }
				}
				set_technology = { improved_heavy_tank = 1 }
			}
			if = {
				limit = {
					NOT = { has_tech = advanced_heavy_tank }
				}
				set_technology = { advanced_heavy_tank = 1 }
			}
		}

		load_oob = "SOV_tank_template_2"
		load_oob = "SOV_heavy_tank_template_2"
		
		if = {
			limit = {
				has_full_control_of_state = 229 # Azerbaijan
				TUR = { has_capitulated = no }
			}
			
			229 = { # Azerbaijan
				add_building_construction = {
					type = infrastructure
					level = 1
					instant_build = yes
				}
			}
		}
	}
}

# Soviet armor begins rolling off the assembly lines
country_event = {
	id = ragnarok.74
	title = ragnarok.74.t
	desc = ragnarok.74.d
	
	fire_only_once = no

	trigger = {
		tag = SOV
		is_ai = yes # Exclude other player-controlled nations that might be working with Germany
		has_idea = russian_bear_awakes

		OR = {
			AND = {
				date > 1938.4.1
				GER = { has_country_flag = completed_treaty_with_ussr }
			}
			
			AND = { # Several months later if did not sign Treaty with the USSR
				date > 1938.8.1
				GER = { NOT = { has_country_flag = completed_treaty_with_ussr } }
			}

			AND = { # Alternatively, at least 150 days after fall of France
				has_global_flag = achievement_france_surrender	
				set_temp_variable = { t = global.num_days }
				subtract_from_temp_variable = { t = global.FRA_capitulation_days }
				check_variable = { t > 150 }
				
				#FRA = { has_capitulated = yes }
				#FRA = { days_since_capitulated > 150 }
			}
		}
		
		has_manpower > 200000
		has_army_size = { size > 60 }
		is_moscow_safe = yes
	}

	mean_time_to_happen = {
		days = 180
		
		modifier = {
			factor = 0.9
			date > 1939.1.1
		}
		modifier = {
			factor = 0.9
			date > 1940.6.1
		}
		modifier = {
			factor = 0.9
			date > 1942.1.1
		}
	}
	
	option = {
		name = ragnarok.74.a
		
		if = { # Advanced production
			limit = {
				has_country_flag = advanced_tank_production
			}
			
			load_oob = "SOV_tank_production_2"
			load_oob = "SOV_heavy_tank_production_2"

			# 25% chance of doubled production, but only after several years of war
			if = {
				limit = {
					date > 1941.1.1
				}
				
				random_list = {
					25 = {
						load_oob = "SOV_tank_production_2"
						load_oob = "SOV_heavy_tank_production_2"
					}
					75 = {
					}
				}
			}
		}
		else_if = { # Intensified production
			limit = {
				has_country_flag = intensify_tank_production
			}
			
			load_oob = "SOV_tank_production"
			load_oob = "SOV_heavy_tank_production"

			# 25% chance of doubled production, but only after several years of war
			if = {
				limit = {
					date > 1941.1.1
				}
				
				random_list = {
					25 = {
						load_oob = "SOV_tank_production"
						load_oob = "SOV_heavy_tank_production"
					}
					75 = {
					}
				}
			}
		}
		else = { # Regular production
			load_oob = "SOV_tank_production"
		}
		
		add_manpower = -80000
		
		country_event = { id = ragnarok.75 } # Extra supplies to cover huge equipment deficits from combat; ensures eastern onslaught never abates
		
	}
}

# Extra supplies to help cover the massive equipment deficits from combat
# Otherwise, onslaught turns into pinprick attacks and not very exciting
# AI prioritizes reinforcements over new deployments
country_event = {
	id = ragnarok.75
	title = ragnarok.75.t
	desc = ragnarok.75.d
	
	fire_only_once = no

	trigger = {
		OR = {
			tag = SOV
			tag = CHI
			tag = JAP
			
			tag = FRA
			tag = ITA
			AND = {
				tag = ENG
				FRA = { has_capitulated = no }
			}
			
			tag = POL
			tag = YUG
			tag = ROM
			tag = TUR
			tag = PRC
		}
		is_ai = yes # Exclude other player-controlled nations that might be working with Germany
		
		date > 1937.9.1 # Combined with the MTTH, gives the player about 5 months to expand against weak Allied armies
		has_capitulated = no
		
		has_manpower > 100000
		
		OR = {
			surrender_progress < 0.01

			AND = {
				is_major_country = yes
				surrender_progress < 0.35
				has_army_size = { size > 24 }
			}

			AND = {
				is_major_country = no
				surrender_progress < 0.5
				has_army_size = { size > 12 }
			}
		}
	}

	mean_time_to_happen = {
		days = 75

		modifier = {
			factor = 0.65
			tag = SOV
			date < 1938.6.1
		}
		modifier = { # Soviets get this event every time new wave of tanks produced later on
			factor = 1.4
			tag = SOV
			date > 1938.6.1
		}
		modifier = {
			factor = 1.5
			date > 1942.1.1
		}
		modifier = {
			factor = 1.5
			date > 1944.1.1
		}
	}
	
	option = {
		name = ragnarok.75.a
		
		set_temp_variable = { eq_factor = 1 }
		
		if = {
			limit = { tag = SOV }
			multiply_temp_variable = { eq_factor = 1.4 }
		}
		else_if = {
			limit = { tag = CHI }
			multiply_temp_variable = { eq_factor = 1.0 }
		}
		else_if = {
			limit = { OR = { tag = FRA tag = ENG tag = JAP } }
			multiply_temp_variable = { eq_factor = 0.6 }
		}
		else_if = {
			limit = { tag = ITA }
			multiply_temp_variable = { eq_factor = 0.5 }
		}
		else = {
			multiply_temp_variable = { eq_factor = 0.35 }
		}

		if = {
			limit = { FRA = { has_capitulated = yes } }
			multiply_temp_variable = { eq_factor = 1.25 }
		}
		if = {
			limit = { ITA = { has_capitulated = yes } }
			multiply_temp_variable = { eq_factor = 1.25 }
		}
		if = {
			limit = { ENG = { has_capitulated = yes } }
			multiply_temp_variable = { eq_factor = 1.25 }
		}

		if = {
			limit = { date > 1938.6.1 }
			multiply_temp_variable = { eq_factor = 1.1 }
		}
		if = {
			limit = { date > 1939.6.1 }
			multiply_temp_variable = { eq_factor = 1.1 }
		}
		if = {
			limit = { date > 1940.6.1 }
			multiply_temp_variable = { eq_factor = 1.1 }
		}
		if = {
			limit = { date > 1941.6.1 }
			multiply_temp_variable = { eq_factor = 1.1 }
		}
		
		if = { # First batch of supplies is extra large to help rebuild shattered armies after the initial Allied offensive
			limit = { NOT = { has_country_flag = received_first_resupply } }
			multiply_temp_variable = { eq_factor = 1.5 }
			set_country_flag = received_first_resupply
		}
		
		if = {
			limit = {
				has_equipment = { infantry_equipment < 3000 }
			}
			
			set_temp_variable = { eq_amount = 24000 }
			multiply_temp_variable = { eq_amount = eq_factor }
			add_equipment_to_stockpile = { type = infantry_equipment amount = eq_amount }
		}

		if = {
			limit = {
				has_tech = tech_support
				has_equipment = { support_equipment < 300 }
			}
			
			set_temp_variable = { eq_amount = 500 }
			multiply_temp_variable = { eq_amount = eq_factor }
			add_equipment_to_stockpile = { type = support_equipment amount = eq_amount }
		}
		
		if = {
			limit = {
				has_tech = gw_artillery
				has_equipment = { artillery_equipment < 300 }
			}
			
			set_temp_variable = { eq_amount = 500 }
			multiply_temp_variable = { eq_amount = eq_factor }
			add_equipment_to_stockpile = { type = artillery_equipment amount = eq_amount }
		}
		
		if = {
			limit = {
				tag = SOV
				has_equipment = { motorized_equipment < 800 }
			}
			
			set_temp_variable = { eq_amount = 2000 }
			multiply_temp_variable = { eq_amount = eq_factor }
			add_equipment_to_stockpile = { type = motorized_equipment amount = eq_amount }
		}
		else_if = {
			limit = {
				has_tech = tech_trucks
				has_equipment = { motorized_equipment < 400 }
			}
			
			set_temp_variable = { eq_amount = 600 }
			multiply_temp_variable = { eq_amount = eq_factor }
			add_equipment_to_stockpile = { type = motorized_equipment amount = eq_amount }
		}		
		
		if = {
			limit = {
				tag = SOV
				has_country_flag = advanced_tank_production
				has_equipment = { mechanized_equipment < 600 }
			}
			
			set_temp_variable = { eq_amount = 1600 }
			multiply_temp_variable = { eq_amount = eq_factor }
			add_equipment_to_stockpile = { type = mechanized_equipment amount = eq_amount }
		}
		
		if = {
			limit = {
				tag = SOV
				has_country_flag = advanced_tank_production
				has_equipment = { motorized_rocket_equipment < 200 }
			}
			
			set_temp_variable = { eq_amount = 300 }
			multiply_temp_variable = { eq_amount = eq_factor }
			add_equipment_to_stockpile = { type = motorized_rocket_equipment amount = eq_amount }
		}

		if = { # Light tanks
			limit = {
				OR = {
					AND = {
						tag = SOV
						date < 1940.6.1
					}

					tag = FRA
					tag = ENG
				}
			}
			
			set_temp_variable = { eq_amount = 800 }
			multiply_temp_variable = { eq_amount = eq_factor }
			
			if = { # Only if playing with No Step Back DLC
				limit = {
					has_dlc = "No Step Back"
					has_equipment = { light_tank_chassis < 300 }
				}
				
				add_equipment_to_stockpile = { type = light_tank_chassis amount = eq_amount }
			}			
			else = { # For base game
				if = { # Improved light tanks
					limit = {
						has_tech = improved_light_tank
						has_equipment = { light_tank_equipment_2 < 300 }
					}
					
					add_equipment_to_stockpile = { type = light_tank_equipment_2 amount = eq_amount }
				}
				else = { # Basic light tanks
					limit = {
						has_equipment = { light_tank_equipment_1 < 300 }
					}
					
					add_equipment_to_stockpile = { type = light_tank_equipment_1 amount = eq_amount }
				}
			}
		}
		
		if = { # Medium tanks
			limit = {
				tag = SOV
				date > 1939.6.1
			}
			
			set_temp_variable = { eq_amount = 1600 }
			multiply_temp_variable = { eq_amount = eq_factor }
			
			if = { # Only if playing with No Step Back DLC
				limit = {
					has_dlc = "No Step Back"
					has_equipment = { medium_tank_chassis < 1000 }
				}
				
				add_equipment_to_stockpile = { type = medium_tank_chassis amount = eq_amount }
			}
			else = { # For base game
				if = { # Advanced production
					limit = {
						has_country_flag = advanced_tank_production
						has_equipment = { medium_tank_equipment_3 < 1000 }
					}
					
					add_equipment_to_stockpile = { type = medium_tank_equipment_3 amount = eq_amount }
				}
				else_if = { # Intensified production
					limit = {
						has_country_flag = intensify_tank_production
						has_equipment = { medium_tank_equipment_2 < 1000 }
					}
					
					add_equipment_to_stockpile = { type = medium_tank_equipment_2 amount = eq_amount }
				}
				else_if = { # Regular production
					limit = {
						has_equipment = { medium_tank_equipment_1 < 1000 }
					}
					
					add_equipment_to_stockpile = { type = medium_tank_equipment_1 amount = eq_amount }
				}
			}
		}
		
		if = { # Heavy tanks
			limit = {
				tag = SOV
				date > 1939.6.1
			}
			
			set_temp_variable = { eq_amount = 600 }
			multiply_temp_variable = { eq_amount = eq_factor }
			
			if = { # Only if playing with No Step Back DLC
				limit = {
					has_dlc = "No Step Back"
					has_equipment = { heavy_tank_chassis < 300 }
				}
				
				add_equipment_to_stockpile = { type = heavy_tank_chassis amount = eq_amount }
			}
			else = { # For base game
				if = { # Advanced production
					limit = {
						has_country_flag = advanced_tank_production
						has_equipment = { heavy_tank_equipment_3 < 300 }
					}
					
					add_equipment_to_stockpile = { type = heavy_tank_equipment_3 amount = eq_amount }
				}
				else_if = { # Intensified production
					limit = {
						has_country_flag = intensify_tank_production
						has_equipment = { heavy_tank_equipment_2 < 300 }
					}
					
					add_equipment_to_stockpile = { type = heavy_tank_equipment_2 amount = eq_amount }
				}
			}
		}
		
	}
}

# Because Japan seems hard-coded to produce little or no additional units
country_event = {
	id = ragnarok.76
	title = ragnarok.76.t
	desc = ragnarok.76.d
	
	fire_only_once = no

	trigger = {
		tag = JAP
		is_ai = yes # Exclude other player-controlled nations that might be working with Germany
		
		date > 1937.10.1
		has_capitulated = no
		surrender_progress < 0.01
		SOV = { has_capitulated = no }
		CHI = { has_capitulated = no }
		
		has_manpower > 100000
		has_army_size = { size < 120 }
	}

	mean_time_to_happen = {
		days = 42
	}
	
	option = {
		name = ragnarok.76.a
		
		if = { # Add templates if necessary
			limit = {
				NOT = { has_country_flag = received_templates }
			}
			
			load_oob = "JAP_infantry_template"
			load_oob = "JAP_marine_template"
			set_country_flag = received_templates
		}

		if = {
			limit = {
				has_army_size = { size < 60 }
			}
			
			load_oob = "JAP_infantry_production"
			load_oob = "JAP_infantry_production"
			load_oob = "JAP_infantry_production"
			load_oob = "JAP_marine_production"

			add_manpower = -50000
		}
		else_if = {
			limit = {
				has_army_size = { size < 90 }
			}
			
			load_oob = "JAP_infantry_production"
			load_oob = "JAP_infantry_production"
			
			random_list = {
				40 = {
					load_oob = "JAP_infantry_production"
				}
				60 = {
					load_oob = "JAP_marine_production"
				}
			}

			add_manpower = -40000
		}
		else = {
			load_oob = "JAP_infantry_production"
			
			random_list = {
				60 = {
					load_oob = "JAP_infantry_production"
				}
				40 = {
					load_oob = "JAP_marine_production"
				}
			}

			add_manpower = -25000
		}
		
	}
}

# Soviets redouble their efforts after the fall of Italy
country_event = {
	id = ragnarok.77
	title = ragnarok.77.t
	desc = ragnarok.77.d
	
	fire_only_once = yes

	trigger = {
		tag = SOV
		OR = {
			ITA = { has_capitulated = yes }
			ITA = { surrender_progress > 0.8 }
		}
		is_ai = yes # Exclude other player-controlled nations that might be working with Germany		
		has_idea = russian_bear_awakes
		is_moscow_safe = yes
	}

	mean_time_to_happen = {
		days = 90
	}
	
	option = {
		name = ragnarok.77.a
		
		soviet_industrial_buildup = yes # Build 8 civilian and 12 military factories in the east
	}
}

# Soviets redouble their efforts after the fall of England
country_event = {
	id = ragnarok.78
	title = ragnarok.78.t
	desc = ragnarok.78.d
	
	fire_only_once = yes

	trigger = {
		tag = SOV
		OR = {
			ENG = { has_capitulated = yes }
			ENG = { surrender_progress > 0.8 }
		}
		is_ai = yes # Exclude other player-controlled nations that might be working with Germany		
		has_idea = russian_bear_awakes
		is_moscow_safe = yes
	}

	mean_time_to_happen = {
		days = 90
	}
	
	option = {
		name = ragnarok.78.a
		
		soviet_industrial_buildup = yes # Build 8 civilian and 12 military factories in the east
	}
}

# Fire all bypass focus events
country_event = {
	id = ragnarok.80
	title = ragnarok.80.t
	desc = ragnarok.80.d
	
	is_triggered_only = yes
	
	option = {
		name = ragnarok.80.a
		
		GER = { country_event = { id = ragnarok.81 } } # Germany bypasses national focuses that are no longer valid after war has begun
		
		USA = { # United States bypasses Neutrality Act
			if = {
				limit = {
					NOT = { has_completed_focus = USA_limited_intervention }
					NOT = { has_completed_focus = USA_neutrality_act }
				}
				unlock_national_focus = USA_neutrality_act
			}
		}
		
		if = {
			limit = {
				country_exists = SOV
				SOV = { is_ai = yes } # Exclude other player-controlled nations that might be working with Germany
			}
			
			SOV = { country_event = { id = ragnarok.82 } } # Soviet Union bypasses national focuses targeting allies now that they're all on the same side
		}
		if = {
			limit = {
				country_exists = ITA
				ITA = { is_ai = yes } # Exclude other player-controlled nations that might be working with Germany
			}
			
			ITA = { country_event = { id = ragnarok.83 } } # Italy bypasses national focuses targeting allies now that they're all on the same side
		}
		if = {
			limit = {
				country_exists = JAP
				JAP = { is_ai = yes } # Exclude other player-controlled nations that might be working with Germany
			}
			
			JAP = { country_event = { id = ragnarok.84 } } # Japan bypasses national focuses targeting allies now that they're all on the same side
		}
		if = {
			limit = {
				country_exists = SPA
				SPA = { is_ai = yes } # Exclude other player-controlled nations that might be working with Germany
			}
			
			SPA = { country_event = { id = ragnarok.86 } } # Spain completes/bypasses focuses to avoid civil wars
		}
		if = {
			limit = {
				country_exists = SPR
				SPR = { is_ai = yes } # Exclude other player-controlled nations that might be working with Germany
			}
			
			SPR = { country_event = { id = ragnarok.86 } } # Spain completes/bypasses focuses to avoid civil wars
		}
		
		every_country = {
			limit = {
				OR = {
					tag = CHI
					tag = PRC
					tag = MAN
				}
				is_ai = yes # Exclude other player-controlled nations that might be working with Germany
			}

			country_event = { id = ragnarok.85 } # China bypasses national focuses targeting allies now that they're all on the same side
		}

		USA = { country_event = { id = ragnarok.89 } } # Minors bypass national focuses targeting allies now that they're all on the same side
		
	}
}

# Germany bypasses national focuses that are no longer valid after war has begun
country_event = {
	id = ragnarok.81

	hidden = yes
	
	is_triggered_only = yes
	
	immediate = {		
		
		if = {
			limit = {
				NOT = { has_completed_focus = GER_molotov_ribbentrop_pact }
			}
			unlock_national_focus = GER_molotov_ribbentrop_pact
		}
		if = {
			limit = {
				NOT = { has_completed_focus = GER_treaty_with_the_ussr }
			}
			unlock_national_focus = GER_treaty_with_the_ussr
		}
		if = {
			limit = {
				NOT = { has_completed_focus = GER_anti_comintern_pact }
			}
			unlock_national_focus = GER_anti_comintern_pact
		}
		if = {
			limit = {
				NOT = { has_completed_focus = GER_anti_soviet_pact }
			}
			unlock_national_focus = GER_anti_soviet_pact
		}
		if = {
			limit = {
				NOT = { has_completed_focus = GER_support_finland }
			}
			unlock_national_focus = GER_support_finland
		}
		if = {
			limit = {
				NOT = { has_completed_focus = GER_war_with_the_ussr }
			}
			unlock_national_focus = GER_war_with_the_ussr
		}
		if = {
			limit = {
				NOT = { has_completed_focus = GER_befriend_turkey }
			}
			unlock_national_focus = GER_befriend_turkey
		}
		if = {
			limit = {
				NOT = { has_completed_focus = GER_the_final_blow_to_communism }
			}
			unlock_national_focus = GER_the_final_blow_to_communism
		}
		
		if = {
			limit = {
				NOT = { has_completed_focus = GER_around_maginot }
			}
			unlock_national_focus = GER_around_maginot
		}
		if = {
			limit = {
				NOT = { has_completed_focus = GER_reintegrate_luxemburg_and_alsace_lorraine }
			}
			unlock_national_focus = GER_reintegrate_luxemburg_and_alsace_lorraine
		}
		if = {
			limit = {
				NOT = { has_completed_focus = GER_operation_tannenbaum }
			}
			unlock_national_focus = GER_operation_tannenbaum
		}
		if = {
			limit = {
				NOT = { has_completed_focus = GER_the_swiss_gold }
			}
			unlock_national_focus = GER_the_swiss_gold
		}
		
		if = {
			limit = {
				NOT = { has_completed_focus = GER_anschluss }
			}
			unlock_national_focus = GER_anschluss
		}
		if = {
			limit = {
				NOT = { has_completed_focus = GER_demand_sudetenland }
			}
			unlock_national_focus = GER_demand_sudetenland
		}
		if = {
			limit = {
				NOT = { has_completed_focus = GER_befriend_czechoslovakia }
			}
			unlock_national_focus = GER_befriend_czechoslovakia
		}
		if = {
			limit = {
				NOT = { has_completed_focus = GER_integrate_czechoslovakia }
			}
			unlock_national_focus = GER_integrate_czechoslovakia
		}
		if = {
			limit = {
				NOT = { has_completed_focus = GER_first_vienna_award }
			}
			unlock_national_focus = GER_first_vienna_award
		}
		if = {
			limit = {
				NOT = { has_completed_focus = GER_reassert_eastern_claims }
			}
			unlock_national_focus = GER_reassert_eastern_claims
		}
		if = {
			limit = {
				NOT = { has_completed_focus = GER_expand_claims_in_baltic }
			}
			unlock_national_focus = GER_expand_claims_in_baltic
		}
		if = {
			limit = {
				NOT = { has_completed_focus = GER_influence_the_baltics }
			}
			unlock_national_focus = GER_influence_the_baltics
		}
		if = {
			limit = {
				NOT = { has_completed_focus = GER_danzig_or_war }
			}
			unlock_national_focus = GER_danzig_or_war
		}
		if = {
			limit = {
				NOT = { has_completed_focus = GER_danzig_for_slovakia }
			}
			unlock_national_focus = GER_danzig_for_slovakia
		}
		if = {
			limit = {
				NOT = { has_completed_focus = GER_befriend_poland }
			}
			unlock_national_focus = GER_befriend_poland
		}
		if = {
			limit = {
				NOT = { has_completed_focus = GER_subjugate_romanian_economy }
			}
			unlock_national_focus = GER_subjugate_romanian_economy
		}
		if = {
			limit = {
				NOT = { has_completed_focus = GER_influence_the_benelux }
			}
			unlock_national_focus = GER_influence_the_benelux
		}
		if = {
			limit = {
				NOT = { has_completed_focus = GER_war_with_france }
			}
			unlock_national_focus = GER_war_with_france
		}
		if = {
			limit = {
				NOT = { has_completed_focus = GER_invade_italy }
			}
			unlock_national_focus = GER_invade_italy
		}
		
		if = {
			limit = {
				NOT = { has_completed_focus = GER_operation_weserubung }
			}
			unlock_national_focus = GER_operation_weserubung
			
			add_tech_bonus = {
				name = tp_bonus
				bonus = 1.0
				ahead_reduction = 2
				uses = 1
				category = tp_tech
			}
		}
		if = {
			limit = {
				NOT = { has_completed_focus = GER_demands_to_sweden }
			}
			unlock_national_focus = GER_demands_to_sweden
		}
		if = {
			limit = {
				NOT = { has_completed_focus = GER_utilize_the_nordliche_gesellschaft }
			}
			unlock_national_focus = GER_utilize_the_nordliche_gesellschaft
		}
		if = {
			limit = {
				NOT = { has_completed_focus = GER_secure_finland }
			}
			unlock_national_focus = GER_secure_finland
		}
		
		if = {
			limit = {
				NOT = { has_completed_focus = GER_demand_slovenia }
			}
			unlock_national_focus = GER_demand_slovenia
		}
		if = {
			limit = {
				NOT = { has_completed_focus = GER_first_ljubljana_award }
			}
			unlock_national_focus = GER_first_ljubljana_award
		}
		if = {
			limit = {
				NOT = { has_completed_focus = GER_fate_of_yugoslavia }
			}
			unlock_national_focus = GER_fate_of_yugoslavia
		}
		if = {
			limit = {
				NOT = { has_completed_focus = GER_war_with_greece }
			}
			unlock_national_focus = GER_war_with_greece
		}
		if = {
			limit = {
				NOT = { has_completed_focus = GER_second_ljubljana_award }
			}
			unlock_national_focus = GER_second_ljubljana_award
		}
		if = {
			limit = {
				NOT = { has_completed_focus = GER_fate_of_greece }
			}
			unlock_national_focus = GER_fate_of_greece
		}
		
		if = {
			limit = {
				NOT = { has_completed_focus = GER_alliance_with_spain }
			}
			unlock_national_focus = GER_alliance_with_spain
		}
		if = {
			limit = {
				NOT = { has_completed_focus = GER_operation_felix }
			}
			unlock_national_focus = GER_operation_felix
		}
		if = {
			limit = {
				NOT = { has_completed_focus = GER_alliance_with_portugal }
			}
			unlock_national_focus = GER_alliance_with_portugal
		}
		if = {
			limit = {
				NOT = { has_completed_focus = GER_operation_isabella }
			}
			unlock_national_focus = GER_operation_isabella
		}
		
		if = {
			limit = {
				NOT = { has_completed_focus = GER_operation_green }
			}
			unlock_national_focus = GER_operation_green
		}

	}
}

# Soviet Union bypasses national focuses targeting allies now that they're all on the same side
country_event = {
	id = ragnarok.82

	hidden = yes
	
	is_triggered_only = yes
	
	immediate = {
		
		if = {
			limit = {
				NOT = { has_completed_focus = SOV_baltic_security }
			}
			unlock_national_focus = SOV_baltic_security
		}
		if = {
			limit = {
				NOT = { has_completed_focus = SOV_respect_baltic_self_determination }
			}
			unlock_national_focus = SOV_respect_baltic_self_determination
		}
		if = {
			limit = {
				NOT = { has_completed_focus = SOV_claims_in_baltic }
			}
			unlock_national_focus = SOV_claims_in_baltic
		}
		if = {
			limit = {
				NOT = { has_completed_focus = SOV_secure_leningrad }
			}
			unlock_national_focus = SOV_secure_leningrad
		}
		if = {
			limit = {
				NOT = { has_completed_focus = SOV_control_scandinavia }
			}
			unlock_national_focus = SOV_control_scandinavia
		}
		if = {
			limit = {
				NOT = { has_completed_focus = SOV_claims_on_poland }
			}
			unlock_national_focus = SOV_claims_on_poland
		}
		if = {
			limit = {
				NOT = { has_completed_focus = SOV_demand_eastern_poland }
			}
			unlock_national_focus = SOV_demand_eastern_poland
		}
		if = {
			limit = {
				NOT = { has_completed_focus = SOV_offer_poland_protection }
			}
			unlock_national_focus = SOV_offer_poland_protection
		}
		if = {
			limit = {
				NOT = { has_completed_focus = SOV_claim_on_bessarabia }
			}
			unlock_national_focus = SOV_claim_on_bessarabia
		}
		if = {
			limit = {
				NOT = { has_completed_focus = SOV_demand_balkan_submission }
			}
			unlock_national_focus = SOV_demand_balkan_submission
		}		
		if = {
			limit = {
				NOT = { has_completed_focus = SOV_seek_balkan_cooperation }
			}
			unlock_national_focus = SOV_seek_balkan_cooperation
		}
		
		if = {
			limit = {
				NOT = { has_completed_focus = SOV_middle_east_diplomacy }
			}
			unlock_national_focus = SOV_middle_east_diplomacy
		}
		if = {
			limit = {
				NOT = { has_completed_focus = SOV_the_southern_thrust }
			}
			unlock_national_focus = SOV_the_southern_thrust
		}
		if = {
			limit = {
				NOT = { has_completed_focus = SOV_support_afghan_ideology }
			}
			unlock_national_focus = SOV_support_afghan_ideology
		}
		if = {
			limit = {
				NOT = { has_completed_focus = SOV_preemptive_invasion_of_iran }
			}
			unlock_national_focus = SOV_preemptive_invasion_of_iran
		}
		
		if = {
			limit = {
				NOT = { has_completed_focus = SOV_intervention_in_china }
			}
			unlock_national_focus = SOV_intervention_in_china
		}
		if = {
			limit = {
				NOT = { has_completed_focus = SOV_spheres_of_influence_in_china }
			}
			unlock_national_focus = SOV_spheres_of_influence_in_china
		}
		if = {
			limit = {
				NOT = { has_completed_focus = SOV_soviet_japanese_pact_against_usa_focus }
			}
			unlock_national_focus = SOV_soviet_japanese_pact_against_usa_focus
		}
	
		if = {
			limit = {
				NOT = { has_completed_focus = SOV_annex_tannu_tuva }
			}
			unlock_national_focus = SOV_annex_tannu_tuva
		}
	
		if = {
			limit = {
				NOT = { has_completed_focus = SOV_policy_of_collective_security }
				NOT = { has_completed_focus = SOV_policy_of_individual_security }
			}
			complete_national_focus = SOV_policy_of_collective_security
		}
	}
}

# Italy bypasses national focuses targeting allies now that they're all on the same side
country_event = {
	id = ragnarok.83

	hidden = yes
	
	is_triggered_only = yes
	
	immediate = {
		
		if = { # Make sure Mussolini never gets deposed
			limit = {
				has_focus_tree = italian_focus
				NOT = { has_completed_focus = ITA_crush_opposition }
			}
			complete_national_focus = ITA_crush_opposition
		}

		if = {
			limit = {
				NOT = { has_completed_focus = ITA_albanian_occupation }
			}
			unlock_national_focus = ITA_albanian_occupation
		}
		if = {
			limit = {
				NOT = { has_completed_focus = ITA_demand_ticino }
			}
			unlock_national_focus = ITA_demand_ticino
		}

		if = {
			limit = {
				NOT = { has_completed_focus = ITA_spanish_italian_alliance }
			}
			unlock_national_focus = ITA_spanish_italian_alliance
		}
		if = {
			limit = {
				NOT = { has_completed_focus = ITA_demand_balearic_islands_bba }
			}
			unlock_national_focus = ITA_demand_balearic_islands_bba
		}
		
	}
}

# Japan bypasses national focuses targeting allies now that they're all on the same side
country_event = {
	id = ragnarok.84

	hidden = yes
	
	is_triggered_only = yes
	
	immediate = {
		
		#if = {
		#	limit = {
		#		NOT = { has_completed_focus = JAP_greater_east_asian_co_prosperity_sphere }
		#	}
		#	unlock_national_focus = JAP_greater_east_asian_co_prosperity_sphere
		#}
		#if = {
		#	limit = {
		#		NOT = { has_completed_focus = JAP_sign_tripartite_pact }
		#	}
		#	unlock_national_focus = JAP_sign_tripartite_pact
		#}
		#if = {
		#	limit = {
		#		NOT = { has_completed_focus = JAP_intervene_in_china }
		#	}
		#	unlock_national_focus = JAP_intervene_in_china
		#}
		#if = {
		#	limit = {
		#		NOT = { has_completed_focus = JAP_strike_south_doctrine }
		#	}
		#	unlock_national_focus = JAP_strike_south_doctrine
		#}
		#if = {
		#	limit = {
		#		NOT = { has_completed_focus = JAP_non_aggression_pact_with_the_soviet_union }
		#	}
		#	unlock_national_focus = JAP_non_aggression_pact_with_the_soviet_union
		#}
		#if = {
		#	limit = {
		#		NOT = { has_completed_focus = JAP_bypass_the_philippines }
		#		NOT = { has_completed_focus = JAP_secure_the_philippines }
		#	}
		#	complete_national_focus = JAP_bypass_the_philippines
		#}
		#if = {
		#	limit = {
		#		NOT = { has_completed_focus = JAP_strike_on_the_southern_resource_area }
		#	}
		#	unlock_national_focus = JAP_strike_on_the_southern_resource_area
		#}
		
		if = {
			limit = {
				NOT = { has_completed_focus = JAP_technological_exchange }
			}
			unlock_national_focus = JAP_technological_exchange
		}
		if = {
			limit = {
				NOT = { has_completed_focus = JAP_preemptive_war }
			}
			unlock_national_focus = JAP_preemptive_war
		}
	
	}
}

# China bypasses national focuses targeting allies now that they're all on the same side
country_event = {
	id = ragnarok.85

	hidden = yes
	
	is_triggered_only = yes
	
	immediate = {

		if = {
			limit = {
				has_focus_tree = china_nationalist_focus
			}

			if = {
				limit = {
					NOT = { has_completed_focus = CHI_united_front }
				}
				unlock_national_focus = CHI_united_front
			}
			if = {
				limit = {
					NOT = { has_completed_focus = CHI_anti_communism }
				}
				unlock_national_focus = CHI_anti_communism
			}
			if = {
				limit = {
					NOT = { has_completed_focus = CHI_subjugate_the_warlords }
				}
				unlock_national_focus = CHI_subjugate_the_warlords
			}
			if = {
				limit = {
					NOT = { has_completed_focus = CHI_pick_a_fight_with_japan }
				}
				unlock_national_focus = CHI_pick_a_fight_with_japan
			}
			if = {
				limit = {
					NOT = { has_completed_focus = CHI_war_of_resistance }
				}
				unlock_national_focus = CHI_war_of_resistance
			}
		}
		
		if = {
			limit = {
				OR = {
					has_focus_tree = china_nationalist_focus
					has_focus_tree = china_communist_focus
					has_focus_tree = manchukuo_focus
				}
			}

			if = {
				limit = {
					NOT = { has_completed_focus = CHI_one_china_policy }
				}
				unlock_national_focus = CHI_one_china_policy
			}
			if = {
				limit = {
					NOT = { has_completed_focus = CHI_integrate_tibet }
				}
				unlock_national_focus = CHI_integrate_tibet
			}
			if = {
				limit = {
					NOT = { has_completed_focus = CHI_conquer_tibet }
				}
				unlock_national_focus = CHI_conquer_tibet
			}
			if = {
				limit = {
					NOT = { has_completed_focus = CHI_renounce_the_mcmahon_line }
				}
				unlock_national_focus = CHI_renounce_the_mcmahon_line
			}
			if = {
				limit = {
					NOT = { has_completed_focus = CHI_demand_mongolia }
				}
				unlock_national_focus = CHI_demand_mongolia
			}
			if = {
				limit = {
					NOT = { has_completed_focus = CHI_commit_to_korean_independence }
				}
				unlock_national_focus = CHI_commit_to_korean_independence
			}
			if = {
				limit = {
					NOT = { has_completed_focus = CHI_overlordship_over_indochina }
				}
				unlock_national_focus = CHI_overlordship_over_indochina
			}
			if = {
				limit = {
					NOT = { has_completed_focus = CHI_secure_the_peninsula }
				}
				unlock_national_focus = CHI_secure_the_peninsula
			}
			if = {
				limit = {
					NOT = { has_completed_focus = CHI_dominate_japan }
				}
				unlock_national_focus = CHI_dominate_japan
			}
		}
		
	}
}

# Spain completes/bypasses focuses to avoid civil wars 
country_event = {
	id = ragnarok.86

	hidden = yes
	
	is_triggered_only = yes
	
	immediate = {

		set_global_flag = spain_focuses_done

		if = {
			limit = {
				tag = SPA
				has_focus_tree = spanish_focus
			}

			if = {
				limit = {
					NOT = { has_completed_focus = SPA_unify_the_nationalist_front }
				}
				complete_national_focus = SPA_unify_the_nationalist_front
			}
			if = {
				limit = {
					NOT = { has_completed_focus = SPA_save_the_alcazar }
				}
				complete_national_focus = SPA_save_the_alcazar
			}
			if = {
				limit = {
					NOT = { has_completed_focus = SPA_martyrdom_for_primo_de_rivera }
				}
				complete_national_focus = SPA_martyrdom_for_primo_de_rivera
			}
			if = {
				limit = {
					NOT = { has_completed_focus = SPA_caudillo_of_spain }
				}
				complete_national_focus = SPA_caudillo_of_spain
			}
			if = {
				limit = {
					NOT = { has_completed_focus = SPA_extol_the_martyrs_of_the_war }
				}
				complete_national_focus = SPA_extol_the_martyrs_of_the_war
			}
			
			if = {
				limit = {
					NOT = { has_completed_focus = SPA_consolidate_the_north }
				}
				complete_national_focus = SPA_consolidate_the_north
			}
			if = {
				limit = {
					NOT = { has_completed_focus = SPA_foment_a_carlist_split }
				}
				complete_national_focus = SPA_foment_a_carlist_split
			}
			if = {
				limit = {
					NOT = { has_completed_focus = SPA_banish_the_party_leaders }
				}
				complete_national_focus = SPA_banish_the_party_leaders
			}
			if = {
				limit = {
					NOT = { has_completed_focus = SPA_safeguard_the_freedom_of_worship }
				}
				complete_national_focus = SPA_safeguard_the_freedom_of_worship
			}
			if = {
				limit = {
					NOT = { has_completed_focus = SPA_fuse_the_parties }
				}
				complete_national_focus = SPA_fuse_the_parties
			}
		}		
		else_if = {
			limit = {
				tag = SPR
				has_focus_tree = spanish_focus
			}

			if = {
				limit = {
					NOT = { has_completed_focus = SPR_crush_the_revolution }
				}
				unlock_national_focus = SPR_crush_the_revolution
			}
		}
		
		every_state = {
			limit = {
				OR = {
					state = 41
					state = 165
					state = 166
					state = 167
					state = 168
					state = 169
					state = 170
					state = 171
					state = 172
					state = 173
					state = 174
					state = 175
					state = 176
					state = 788
					state = 789
					state = 790
					state = 791
					state = 792
					state = 793
					state = 794
				}
			}
			
			clr_state_flag = SPR_unplanned_offensive_flag
			
			if = {
				limit = {
					has_dynamic_modifier = { modifier = unplanned_offensive }
				}
				remove_dynamic_modifier = { modifier = unplanned_offensive }
			}
		}
		
	}
}

# Minors bypass national focuses targeting allies now that they're all on the same side
country_event = {
	id = ragnarok.89

	hidden = yes
	
	is_triggered_only = yes
	
	immediate = {
		
		if = {
			limit = {
				country_exists = HUN
				HUN = { has_focus_tree = hungarian_focus }
			}
			
			HUN = {
				if = {
					limit = {
						NOT = { has_completed_focus = HUN_reaffirm_territorial_claims }
					}
					unlock_national_focus = HUN_reaffirm_territorial_claims
				}
				if = {
					limit = {
						NOT = { has_completed_focus = HUN_demand_transylvania }
					}
					unlock_national_focus = HUN_demand_transylvania
				}
				if = {
					limit = {
						NOT = { has_completed_focus = HUN_demand_southern_slovakia }
					}
					unlock_national_focus = HUN_demand_southern_slovakia
				}
				if = {
					limit = {
						NOT = { has_completed_focus = HUN_demand_the_vojvodina }
					}
					unlock_national_focus = HUN_demand_the_vojvodina
				}
				if = {
					limit = {
						NOT = { has_completed_focus = HUN_claim_overlordship_over_slovakia }
					}
					unlock_national_focus = HUN_claim_overlordship_over_slovakia
				}
				if = {
					limit = {
						NOT = { has_completed_focus = HUN_proclaim_greater_hungary }
					}
					unlock_national_focus = HUN_proclaim_greater_hungary
				}
			}
		}
		
		if = {
			limit = {
				country_exists = ROM
				ROM = { has_focus_tree = romanian_focus }
			}
			
			ROM = {
				if = {
					limit = {
						NOT = { has_completed_focus = ROM_demand_transnistria }
					}
					unlock_national_focus = ROM_demand_transnistria
				}
				if = {
					limit = {
						NOT = { has_completed_focus = ROM_renew_the_romanian_polish_alliance }
					}
					unlock_national_focus = ROM_renew_the_romanian_polish_alliance
				}
			}
		}
		
		if = {
			limit = {
				country_exists = BUL
				BUL = { has_focus_tree = bulgarian_focus }
			}
			
			BUL = {
				if = {
					limit = {
						NOT = { has_completed_focus = BUL_condemn_macedonian_organizations }
						NOT = { has_completed_focus = BUL_support_macedonian_organizations }
					}
					unlock_national_focus = BUL_condemn_macedonian_organizations
				}
			}
		}
		
		if = {
			limit = {
				country_exists = GRE
				GRE = { has_focus_tree = greek_focus }
			}
			
			GRE = {
				if = {
					limit = {
						NOT = { has_completed_focus = GRE_the_gordian_knot }
					}
					unlock_national_focus = GRE_the_gordian_knot
				}
				
				if = {
					limit = {
						NOT = { has_completed_focus = GRE_horror_and_fear }
					}
					unlock_national_focus = GRE_horror_and_fear
				}
			}
		}
		
		if = {
			limit = {
				country_exists = ETH
				ETH = { has_focus_tree = ethiopia_tree }
			}
			
			ETH = {
				if = {
					limit = {
						NOT = { has_completed_focus = ETH_liberate_aussa }
					}
					unlock_national_focus = ETH_liberate_aussa
				}
			}
		}
		
		if = {
			limit = {
				country_exists = MAN
				MAN = { has_focus_tree = manchukuo_focus }
			}
			
			MAN = {
				if = {
					limit = {
						NOT = { has_completed_focus = MAN_independence_war }
					}
					unlock_national_focus = MAN_independence_war
				}
			}
		}
		
	}
}

# Prevent DOD_yugoslavia.10 event from occurring as it causes a tremendous amount of lag shortly after war begins
country_event = {
	id = ragnarok.90

	hidden = yes
	
	is_triggered_only = yes

	immediate = {
				
		if = {
			limit = {
				has_focus_tree = yugoslavian_focus
			}
			
			if = {
				limit = {
					NOT = { has_completed_focus = YUG_evolution }
				}
				complete_national_focus = YUG_evolution
			}
			if = {
				limit = {
					NOT = { has_completed_focus = YUG_establish_the_banovina_of_croatia }
				}
				complete_national_focus = YUG_establish_the_banovina_of_croatia
			}
			if = {
				limit = {
					NOT = { has_completed_focus = YUG_ban_slovene_nationalist_parties }
				}
				complete_national_focus = YUG_ban_slovene_nationalist_parties
			}
			if = {
				limit = {
					NOT = { has_completed_focus = YUG_concessions_for_macedonians }
				}
				complete_national_focus = YUG_concessions_for_macedonians
			}
			
			if = {
				limit = {
					NOT = { has_completed_focus = YUG_invite_german_military_mission }
				}
				unlock_national_focus = YUG_invite_german_military_mission
			}
			if = {
				limit = {
					NOT = { has_completed_focus = YUG_join_axis }
				}
				unlock_national_focus = YUG_join_axis
			}
			if = {
				limit = {
					NOT = { has_completed_focus = YUG_surrender_italian_claims }
				}
				unlock_national_focus = YUG_surrender_italian_claims
			}
			if = {
				limit = {
					NOT = { has_completed_focus = YUG_zara_for_axis }
				}
				unlock_national_focus = YUG_zara_for_axis
			}
			if = {
				limit = {
					NOT = { has_completed_focus = YUG_claim_macedonia }
				}
				unlock_national_focus = YUG_claim_macedonia
			}
			if = {
				limit = {
					NOT = { has_completed_focus = YUG_greater_yugoslavia }
				}
				unlock_national_focus = YUG_greater_yugoslavia
			}

		}
		
	}
}

# Disable French non-intervention in Spain decisions
country_event = {
	id = ragnarok.91

	hidden = yes
	
	is_triggered_only = yes

	immediate = {
		
		if = {
			limit = {
				has_focus_tree = french_focus
			}
			
			if = {
				limit = {
					NOT = { has_completed_focus = FRA_intervention_in_spain }
				}
				unlock_national_focus = FRA_intervention_in_spain
			}		

		}
		
	}
}

# Disable Danish trade with Germany focus [1937 only]
country_event = {
	id = ragnarok.92
	title = ragnarok.92.t
	desc = ragnarok.92.d

	fire_only_once = yes

	trigger = {
		tag = DEN
		is_ai = yes # Exclude other player-controlled nations that might be working with Germany
	}

	mean_time_to_happen = {
		days = 5
	}
	
	option = {
		name = ragnarok.92.a
		
		if = {
			limit = {
				has_focus_tree = danish_focus
				NOT = { has_completed_focus = DEN_trade_with_germany }
			}
			unlock_national_focus = DEN_trade_with_germany
		}
	}
}

# Complete Sweden seizes Landsverk focus after war starts
country_event = {
	id = ragnarok.93
	title = ragnarok.93.t
	desc = ragnarok.93.d

	fire_only_once = yes

	trigger = {
		tag = SWE
		is_ai = yes # Exclude other player-controlled nations that might be working with Germany
		
		has_war_with = GER
		OR = {
			has_global_flag = ragnarok_party
			has_global_flag = ragnarok_early_war
		}
	}

	mean_time_to_happen = {
		days = 70
	}
	
	option = {
		name = ragnarok.93.a

		if = {
			limit = {
				has_focus_tree = sweden_focus
				NOT = { has_completed_focus = SWE_sieze_landsverk }
				NOT = { has_completed_focus = SWE_allow_landsverk_to_operate }
			}
			complete_national_focus = SWE_sieze_landsverk
		}
	}
}

# Transfer control of certain Lower Austria provinces to Hungary if seized by another country
country_event = {
	id = ragnarok.94
	
	hidden = yes

	fire_only_once = no

	trigger = {
		tag = HUN
		has_war_with = GER
		is_ai = yes # Exclude other player-controlled nations that might be working with Germany
		
		# provinces east of Vienna and Graz
		GER = {
			NOT = { controls_province = 3700 }
			NOT = { controls_province = 9661 }
			NOT = { controls_province = 11630 }
		}
	}

	mean_time_to_happen = {
		days = 5
	}
	
	immediate = {
		
		if = {
			limit = {
				has_full_control_of_state = 155 # Transdanubia
			}
			
			if = {
				limit = {
					OR = {
						AND = {
							CZE = { controls_province = 3700 }
							is_ally_with = CZE
						}
						
						AND = {
							YUG = { controls_province = 3700 }
							is_ally_with = YUG
						}
					}
				}
				
				set_province_controller = 3700
			}
			
			if = {
				limit = {
					OR = {
						AND = {
							CZE = { controls_province = 9661 }
							is_ally_with = CZE
						}
						
						AND = {
							YUG = { controls_province = 9661 }
							is_ally_with = YUG
						}
					}
				}
				
				set_province_controller = 9661
			}
			
			if = {
				limit = {
					OR = {
						AND = {
							CZE = { controls_province = 11630 }
							is_ally_with = CZE
						}
						
						AND = {
							YUG = { controls_province = 11630 }
							is_ally_with = YUG
						}
					}
				}
				
				set_province_controller = 11630
			}
		}
		
	}
}

# Transfer control of certain Tyrol provinces to Italy if seized by another country
country_event = {
	id = ragnarok.95
	
	hidden = yes

	fire_only_once = no

	trigger = {
		tag = ITA
		has_war_with = GER
		is_ai = yes # Exclude other player-controlled nations that might be working with Germany
		
		# province southeast of Graz
		GER = {
			NOT = { controls_province = 668 }
			NOT = { controls_province = 671 }
			NOT = { controls_province = 6673 }
		}
	}

	mean_time_to_happen = {
		days = 5
	}
	
	immediate = {
		
		if = {
			limit = {
				has_full_control_of_state = 39 # Alto Adige
				has_full_control_of_state = 160 # Veneto
			}
			
			if = {
				limit = {
					YUG = { controls_province = 668 }
					is_ally_with = YUG
				}
				
				set_province_controller = 668
			}
			
			if = {
				limit = {
					YUG = { controls_province = 671 }
					is_ally_with = YUG
				}
				
				set_province_controller = 671
			}
			
			if = {
				limit = {
					YUG = { controls_province = 6673 }
					is_ally_with = YUG
				}
				
				set_province_controller = 6673
			}
		}
		
	}
}

# Troubleshooting event for diplomatic conference
country_event = {
	id = ragnarok.100
	title = ragnarok.100.t
	desc = ragnarok.100.d
	picture = GFX_report_event_generic_sign_treaty1
	
	is_triggered_only = yes

	option = {
		name = ragnarok.100.a
		custom_effect_tooltip = ragnarok.cpu100
		custom_effect_tooltip = ragnarok.cpu110

		hidden_effect = {

			# All countries make peace 
			every_country = {
				limit = {
					has_war = yes
					NOT = { tag = GER }
					NOT = { is_puppet_of = GER }
					#is_puppet = no
					is_ai = yes # Exclude other player-controlled nations that might be working with Germany
				}

				country_event = { id = ragnarok.24 } # Includes puppets
			}

			country_event = { id = ragnarok.101 }
		}
	}
	option = {
		name = ragnarok.100.b
	}
}

# Troubleshooting event for diplomatic conference (part 2)
country_event = {
	id = ragnarok.101
	title = ragnarok.100.t
	desc = ragnarok.100.d
	picture = GFX_report_event_generic_sign_treaty1
	
	is_triggered_only = yes

	option = {
		name = ragnarok.100.a
		custom_effect_tooltip = ragnarok.cpu101
		custom_effect_tooltip = ragnarok.cpu110

		hidden_effect = {

			# All democratic or non-aligned major powers join the Allies
			every_country = {
				limit = {
					is_major_country = yes
					NOT = { tag = ENG }
					is_ai = yes # Exclude other player-controlled nations that might be working with Germany
				}
				
				country_event = { id = ragnarok.28 }
			}

			# All democratic or non-aligned European countries join the Allies
			every_country = {
				limit = {
					is_european_country = yes
					is_ai = yes # Exclude other player-controlled nations that might be working with Germany
				}
				
				country_event = { id = ragnarok.28 }
			}

		}
	}
}




# Allows player to manually set AI supply bonuses
country_event = {
	id = ragnarok.120
	title = ragnarok.120.t
	desc = {
		trigger = {
			OR = {
				has_global_flag = ragnarok_party
				has_global_flag = ragnarok_early_war
			}
			GER = { has_war = yes }
		}
		text = ragnarok.120.d1
	}
	desc = {
		trigger = {
			#AND = {
			#	NOT = { has_global_flag = ragnarok_party }
			#	NOT = { has_global_flag = ragnarok_early_war }
			#}
			#NOT = { GER = { has_war = yes } }			
			NOT = {
				OR = {
					has_global_flag = ragnarok_party
					has_global_flag = ragnarok_early_war
				}
				GER = { has_war = yes }
			}			
		}
		text = ragnarok.120.d2
	}
	picture = GFX_report_event_generic_read_write
	
	is_triggered_only = yes

	option = {
		name = ragnarok.120.a
		trigger = {
			OR = {
				has_global_flag = ragnarok_party
				has_global_flag = ragnarok_early_war
			}
			GER = { has_war = yes }
			NOT = { has_global_flag = ai_supply_bonus_none }
		}

		hidden_effect = {
			if = {
				limit = {
					OR = {
						has_global_flag = ragnarok_party
						has_global_flag = ragnarok_early_war
					}
				}
				
				set_global_flag = ai_supply_bonus_none
				clr_global_flag = ai_supply_bonus_small
				clr_global_flag = ai_supply_bonus_large
				
				every_country = {
					limit = {
						has_war_with = GER
					}

					remove_ideas = extra_supplies_small
					remove_ideas = extra_supplies_large
				}
			}		
			
			USA = { country_event = { id = ragnarok.130 } }
		}
	}
	option = {
		name = ragnarok.120.b
		trigger = {
			OR = {
				has_global_flag = ragnarok_party
				has_global_flag = ragnarok_early_war
			}
			GER = { has_war = yes }
			NOT = { has_global_flag = ai_supply_bonus_small }
		}

		hidden_effect = {
			if = {
				limit = {
					OR = {
						has_global_flag = ragnarok_party
						has_global_flag = ragnarok_early_war
					}
				}
				
				set_global_flag = ai_supply_bonus_small
				clr_global_flag = ai_supply_bonus_none
				clr_global_flag = ai_supply_bonus_large
				
				every_country = {
					limit = {
						has_war_with = GER
					}

					remove_ideas = extra_supplies_large
					add_ideas = extra_supplies_small
				}
			}		
			
			USA = { country_event = { id = ragnarok.130 } }
		}
	}
	option = {
		name = ragnarok.120.c
		trigger = {
			OR = {
				has_global_flag = ragnarok_party
				has_global_flag = ragnarok_early_war
			}
			GER = { has_war = yes }
			NOT = { has_global_flag = ai_supply_bonus_large }
		}

		hidden_effect = {
			if = {
				limit = {
					OR = {
						has_global_flag = ragnarok_party
						has_global_flag = ragnarok_early_war
					}
				}
				
				set_global_flag = ai_supply_bonus_large
				clr_global_flag = ai_supply_bonus_none
				clr_global_flag = ai_supply_bonus_small
				
				every_country = {
					limit = {
						has_war_with = GER
					}

					remove_ideas = extra_supplies_small
					add_ideas = extra_supplies_large
				}
			}		
			
			USA = { country_event = { id = ragnarok.130 } }
		}
	}
	option = {
		name = ragnarok.120.z
	}
}

# Helper event for ragnarok.120 since an event can't fire itself
country_event = {
	id = ragnarok.130
	title = ragnarok.130.t
	desc = ragnarok.130.d
	
	is_triggered_only = yes

	option = {
		name = ragnarok.130.a
		
		GER = { country_event = { id = ragnarok.120 } }
	}
}

# Allows player to enable compatibility with various mods
# Currently supported:
#		BlackICE
#		Expert AI
#		New World Order
#		Operation Overhaul
#		Road to 56
#		Vanilla+
country_event = {
	id = ragnarok.140
	title = ragnarok.140.title
	desc = ragnarok.140.desc
	picture = GFX_report_event_generic_read_write
	
	is_triggered_only = yes

	immediate = {
		hidden_effect = {
		
			if = { # Auto-detect BlackICE overhaul mod
				limit = {
					NOT = { has_global_flag = mods_found }
				}
				
				set_global_flag = mods_found
				
				if = { # Auto-detect BlackICE overhaul mod
					limit = {
						OR = {
							GER = { has_country_flag = axis_leader }
							GER = { has_country_flag = was_fascist }
						
							any_country = { 
								OR = {
									has_country_flag = corruption_1
									has_country_flag = corruption_2
									has_country_flag = corruption_3
									has_country_flag = corruption_4
									has_country_flag = corruption_5
									has_country_flag = corruption_6
									has_country_flag = corruption_7
									has_country_flag = corruption_8
									has_country_flag = corruption_9
									has_country_flag = corruption_10
								}
							}
						}
					}
					
					set_global_flag = mod_black_ice
				}
			
				if = { # Auto-detect Expert AI overhaul mod
					limit = {
						OR = {
							#has_global_flag = EAI_lend_lease # Excluded, shared with Black ICE
							has_global_flag = EAI_anti_aggression_diplomacy
							
							has_global_flag = EAI_challenging_mode
							has_global_flag = EAI_historical_mode
							#has_global_flag = EAI_random_focuses # Excluded, shared with Black ICE

							GER = { has_country_flag = EAI_config_STARTUP }
							GER = { has_country_flag = EAI_show_country_config_decisions }
							GER = { has_country_flag = EAI_config_COUNTRY }
							GER = { has_country_flag = EAI_player_is_configuring_this_country }
						}
					}
					
					set_global_flag = mod_expert_ai
				}

				if = { # Auto-detect Road to 56 overhaul mod
					limit = {
						GXC = { has_country_flag = KMT_lzr_tt }
					}
					
					set_global_flag = mod_road_to_56
				}		
			}
			
		}
	}
	
	option = {
		name = ragnarok.140.a
		ai_chance = {
			factor = 0
		}

		#if = {
		#	limit = {
		#		has_global_flag = mod_black_ice
		#	}
		#	
		#	custom_effect_tooltip = ragnarok.140.bICE_enabled
		#	
		#	else = {
		#		custom_effect_tooltip = ragnarok.140.bICE_disabled
		#	}
		#}
		if = {
			limit = {
				has_global_flag = mod_expert_ai
			}
			
			custom_effect_tooltip = ragnarok.140.eai_enabled
		}
		else = {
			custom_effect_tooltip = ragnarok.140.eai_disabled
		}
		if = {
			limit = {
				has_global_flag = mod_operation_overhaul
			}
			
			custom_effect_tooltip = ragnarok.140.oo_enabled
		}
		else = {
			custom_effect_tooltip = ragnarok.140.oo_disabled
		}
		
		hidden_effect = {
			country_event = { id = ragnarok.141 }
		}
	}
	option = {
		name = ragnarok.140.b
		ai_chance = {
			factor = 0
		}

		if = {
			limit = {
				has_global_flag = mod_road_to_56
			}
			
			custom_effect_tooltip = ragnarok.140.r56_enabled
		}
		else = {
			custom_effect_tooltip = ragnarok.140.r56_disabled
		}
		#if = {
		#	limit = {
		#		has_global_flag = mod_vanilla_plus
		#	}
		#	
		#	custom_effect_tooltip = ragnarok.140.vanilla_enabled
		#	
		#	else = {
		#		custom_effect_tooltip = ragnarok.140.vanilla_disabled
		#	}
		#}

		hidden_effect = {
			country_event = { id = ragnarok.142 }
		}
	}
	option = {
		name = ragnarok.140.done
		ai_chance = {
			factor = 100
		}

		hidden_effect = {
			if = {
				limit = {
					NOT = { has_global_flag = ragnarok_initialized }
				}
		
				country_event = { id = ragnarok.41 } # Help Germany prepare for the coming war
			}
		}
	}
}

# Allows player to activate compatibility with various mods
country_event = {
	id = ragnarok.141
	title = ragnarok.141.title
	desc = ragnarok.141.desc
	picture = GFX_report_event_generic_read_write
	
	is_triggered_only = yes

	#option = {
	#	name = ragnarok.141.bICE_enable
	#	trigger = {
	#		NOT = { has_global_flag = mod_black_ice }
	#	}
	#
	#	custom_effect_tooltip = ragnarok.141.bICE_enable_tooltip
	#
	#	hidden_effect = {
	#		set_global_flag = mod_black_ice
	#		
	#		USA = { country_event = { id = ragnarok.151 } }
	#	}
	#}
	#option = {
	#	name = ragnarok.141.bICE_disable
	#	trigger = {
	#		has_global_flag = mod_black_ice
	#	}
	#
	#	custom_effect_tooltip = ragnarok.141.bICE_disable_tooltip
	#
	#	hidden_effect = {
	#		clr_global_flag = mod_black_ice
	#		
	#		USA = { country_event = { id = ragnarok.151 } }
	#	}
	#}
	option = {
		name = ragnarok.141.eai_enable
		trigger = {
			NOT = { has_global_flag = mod_expert_ai }
		}

		custom_effect_tooltip = ragnarok.141.eai_enable_tooltip

		hidden_effect = {
			set_global_flag = mod_expert_ai
			
			USA = { country_event = { id = ragnarok.151 } }
		}
	}
	option = {
		name = ragnarok.141.eai_disable
		trigger = {
			has_global_flag = mod_expert_ai
		}

		custom_effect_tooltip = ragnarok.141.eai_disable_tooltip

		hidden_effect = {
			clr_global_flag = mod_expert_ai
			
			USA = { country_event = { id = ragnarok.151 } }
		}
	}
	option = {
		name = ragnarok.141.oo_enable
		trigger = {
			NOT = { has_global_flag = mod_operation_overhaul }
		}

		custom_effect_tooltip = ragnarok.141.oo_enable_tooltip

		hidden_effect = {
			#set_global_flag = mod_new_world_order
			set_global_flag = mod_operation_overhaul
			
			USA = { country_event = { id = ragnarok.151 } }
		}
	}
	option = {
		name = ragnarok.141.oo_disable
		trigger = {
			has_global_flag = mod_operation_overhaul
		}

		custom_effect_tooltip = ragnarok.141.oo_disable_tooltip

		hidden_effect = {
			#clr_global_flag = mod_new_world_order
			clr_global_flag = mod_operation_overhaul
			
			USA = { country_event = { id = ragnarok.151 } }
		}
	}
	option = {
		name = ragnarok.141.done

		hidden_effect = {
			country_event = { id = ragnarok.140 }
		}
	}
}

# Allows player to activate compatibility with various mods
country_event = {
	id = ragnarok.142
	title = ragnarok.142.title
	desc = ragnarok.142.desc
	picture = GFX_report_event_generic_read_write
	
	is_triggered_only = yes

	option = {
		name = ragnarok.142.r56_enable
		trigger = {
			NOT = { has_global_flag = mod_road_to_56 }
		}

		custom_effect_tooltip = ragnarok.142.r56_enable_tooltip

		hidden_effect = {
			set_global_flag = mod_road_to_56
			
			USA = { country_event = { id = ragnarok.152 } }
		}
	}
	option = {
		name = ragnarok.142.r56_disable
		trigger = {
			has_global_flag = mod_road_to_56
		}

		custom_effect_tooltip = ragnarok.142.r56_disable_tooltip

		hidden_effect = {
			clr_global_flag = mod_road_to_56
			
			USA = { country_event = { id = ragnarok.152 } }
		}
	}
	#option = {
	#	name = ragnarok.142.vanilla_enable
	#	trigger = {
	#		NOT = { has_global_flag = mod_vanilla_plus }
	#	}
	#
	#	custom_effect_tooltip = ragnarok.142.vanilla_enable_tooltip
	#
	#	hidden_effect = {
	#		set_global_flag = mod_vanilla_plus
	#		
	#		USA = { country_event = { id = ragnarok.152 } }
	#	}
	#}
	#option = {
	#	name = ragnarok.142.vanilla_disable
	#	trigger = {
	#		has_global_flag = mod_vanilla_plus
	#	}
	#
	#	custom_effect_tooltip = ragnarok.142.vanilla_disable_tooltip
	#
	#	hidden_effect = {
	#		clr_global_flag = mod_vanilla_plus
	#		
	#		USA = { country_event = { id = ragnarok.152 } }
	#	}
	#}
	option = {
		name = ragnarok.142.done

		hidden_effect = {
			country_event = { id = ragnarok.140 }
		}
	}
}

# Helper event for ragnarok.140 since an event can't fire itself
country_event = {
	id = ragnarok.150
	title = ragnarok.150.t
	desc = ragnarok.150.d
	
	is_triggered_only = yes

	option = {
		name = ragnarok.150.a
		
		GER = { country_event = { id = ragnarok.140 } }
	}
}

# Helper event for ragnarok.141 since an event can't fire itself
country_event = {
	id = ragnarok.151
	title = ragnarok.151.t
	desc = ragnarok.151.d
	
	is_triggered_only = yes

	option = {
		name = ragnarok.151.a
		
		GER = { country_event = { id = ragnarok.141 } }
	}
}

# Helper event for ragnarok.142 since an event can't fire itself
country_event = {
	id = ragnarok.152
	title = ragnarok.152.t
	desc = ragnarok.152.d
	
	is_triggered_only = yes

	option = {
		name = ragnarok.152.a
		
		GER = { country_event = { id = ragnarok.142 } }
	}
}



# Temporary compatibility option for Expert AI and Road to 56
country_event = {
	id = ragnarok.240
	title = ragnarok.240.title
	desc = ragnarok.240.desc
	picture = GFX_report_event_generic_read_write
	
	is_triggered_only = yes
	
	immediate = {
		hidden_effect = {
		
			if = { # Auto-detect BlackICE overhaul mod
				limit = {
					NOT = { has_global_flag = mods_found }
				}
				
				set_global_flag = mods_found
				
				if = { # Auto-detect Road to 56 overhaul mod
					limit = {
						GXC = { has_country_flag = KMT_lzr_tt }
					}
					
					set_global_flag = mod_road_to_56
				}		
			}
			
		}
	}
	
	option = {
		name = ragnarok.141.eai_enable
		trigger = {
			NOT = { has_global_flag = mod_expert_ai }
		}
		ai_chance = {
			factor = 0
		}

		custom_effect_tooltip = ragnarok.141.eai_enable_tooltip

		hidden_effect = {
			set_global_flag = mod_expert_ai
			
			USA = { country_event = { id = ragnarok.250 } }
		}
	}
	option = {
		name = ragnarok.141.eai_disable
		trigger = {
			has_global_flag = mod_expert_ai
		}
		ai_chance = {
			factor = 0
		}

		custom_effect_tooltip = ragnarok.141.eai_disable_tooltip

		hidden_effect = {
			clr_global_flag = mod_expert_ai
			
			USA = { country_event = { id = ragnarok.250 } }
		}
	}
	option = {
		name = ragnarok.142.r56_enable
		trigger = {
			NOT = { has_global_flag = mod_road_to_56 }
		}

		custom_effect_tooltip = ragnarok.142.r56_enable_tooltip

		hidden_effect = {
			set_global_flag = mod_road_to_56
			
			USA = { country_event = { id = ragnarok.250 } }
		}
	}
	option = {
		name = ragnarok.142.r56_disable
		trigger = {
			has_global_flag = mod_road_to_56
		}

		custom_effect_tooltip = ragnarok.142.r56_disable_tooltip

		hidden_effect = {
			clr_global_flag = mod_road_to_56
			
			USA = { country_event = { id = ragnarok.250 } }
		}
	}
	option = {
		name = ragnarok.140.done
		ai_chance = {
			factor = 100
		}

		hidden_effect = {
			if = {
				limit = {
					NOT = { has_global_flag = ragnarok_initialized }
				}
		
				country_event = { id = ragnarok.41 } # Help Germany prepare for the coming war
			}
		}
	}
}

# Helper event for ragnarok.240 since an event can't fire itself
country_event = {
	id = ragnarok.250
	title = ragnarok.250.t
	desc = ragnarok.250.d
	
	is_triggered_only = yes

	option = {
		name = ragnarok.250.a
		
		GER = { country_event = { id = ragnarok.240 } }
	}
}

# Applies state renames to games started before Ragnarok v1.6.6
country_event = {
	id = ragnarok.320
	
	hidden = yes

	fire_only_once = yes

	trigger = {
		tag = GER
	}

	mean_time_to_happen = {
		days = 2
	}
	
	immediate = {
		
		if = {
			limit = {
				NOT = { has_global_flag = state_renames_handled }
			}
			
			set_global_flag = state_renames_handled

			if = {
				limit = {
					has_country_flag = integrated_luxemburg
				}
				
				set_province_name = { id = 6583 name = "Luxemburg" }

				8 = { set_state_name = "Luxemburg" }
			}

			if = {
				limit = {
					has_country_flag = integrated_alsace
				}
				
				set_province_name = { id = 9503 name = "Straßburg" }
				set_province_name = { id = 678 name = "Mülhausen" }
				set_province_name = { id = 549 name = "Hagenau" }

				28 = { set_state_name = "Elsaß-Lothringen" }
			}
			
			if = {
				limit = {
					has_country_flag = integrated_danzig
				}
				
				set_province_name = { id = 9263 name = "Gotenhafen" }
				set_province_name = { id = 3295 name = "Thorn" }
				set_province_name = { id = 279 name = "Bromberg" }

				807 = { set_state_name = "Gotenhafen" }
			}
			
			if = {
				limit = {
					has_country_flag = integrated_poznan
				}
				
				set_province_name = { id = 6558 name = "Posen" }

				86 = { set_state_name = "Posen" }
			}
			
			if = {
				limit = {
					has_country_flag = integrated_katowice
				}
				
				set_province_name = { id = 6464 name = "Kattowitz" }

				762 = { set_state_name = "Kattowitz" }
			}
			
			if = {
				limit = {
					has_country_flag = integrated_memel
				}
				
				set_province_name = { id = 3288 name = "Memel" }

				188 = { set_state_name = "Memelland" }
			}
			
			if = {
				limit = {
					has_country_flag = integrated_austria
				}
				
				set_province_name = { id = 11666 name = "Wien" }
				set_province_name = { id = 11598 name = "Bozen" }
				set_province_name = { id = 9598 name = "Trient" }
				
				152 = { set_state_name = "Oberösterreich" }
				4 = { set_state_name = "Niederösterreich" }
				153 = { set_state_name = "Tirol" }
				39 = { set_state_name = "Südtirol" }
				850 = { set_state_name = "Trient" }
			}
			
			if = {
				limit = {
					has_country_flag = integrated_south_tyrol
				}
				
				set_province_name = { id = 11598 name = "Bozen" }
				set_province_name = { id = 9598 name = "Trient" }

				39 = { set_state_name = "Südtirol" }
				850 = { set_state_name = "Trient" }
			}
			
			if = {
				limit = {
					has_country_flag = integrated_sudetenland
				}
				
				set_province_name = { id = 11401 name = "Reichenberg" }
				set_province_name = { id = 11432 name = "Aussig" }
				set_province_name = { id = 3585 name = "Karlsbad" }
				set_province_name = { id = 557 name = "Znaim" }
				set_province_name = { id = 3414 name = "Troppau" }
				set_province_name = { id = 3583 name = "Ostrau" }

				69 = { set_state_name = "Deutschböhmen" }
				972 = { set_state_name = "Böhmerwaldgau" }
				74 = { set_state_name = "Sudetenschlesien" }
			}
		}
		
	}
}

# Debug event: French defeat
country_event = {
	id = ragnarok.1001
	title = ragnarok.1001.t
	desc = ragnarok.1001.d
	
	is_triggered_only = yes

	option = {
		name = ragnarok.1001.a
		
		FRA = { country_event = france.10 }
	}
}

# Debug event: Allow forming the Reichskommissariats
country_event = {
	id = ragnarok.1002
	title = ragnarok.1002.t
	desc = ragnarok.1002.d
	
	is_triggered_only = yes

	option = {
		name = ragnarok.1002.a
		
		if = {
			limit = {
				NOT = { has_completed_focus = GER_uplift_the_rosenberg_office }
			}
			complete_national_focus = GER_uplift_the_rosenberg_office
		}
	}
}

# Debug event: Reintegrate Eastern Lands alt version
country_event = {
	id = ragnarok.1005
	title = ragnarok.1005.t
	desc = ragnarok.1005.d

	is_triggered_only = yes
	
	option = {
		name = ragnarok.1002.a
		
		GER = {
			add_state_core = 188
		}
	}
}

# Debug event: inner circle randomness
country_event = {
	id = ragnarok.1006
	title = ragnarok.1006.t
	desc = ragnarok.1006.d
	
	is_triggered_only = yes

	option = {
		name = ragnarok.1006.a
	}
}
